Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-05-30 13:49:18 +03:00
commit fa6d100b41
6 changed files with 44 additions and 14 deletions

View File

@ -11,8 +11,11 @@ import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.Permission; import org.opencdmp.authorization.Permission;
import org.opencdmp.commons.enums.ContactInfoType; import org.opencdmp.commons.enums.ContactInfoType;
import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.data.DmpUserEntity;
import org.opencdmp.data.UserContactInfoEntity; import org.opencdmp.data.UserContactInfoEntity;
import org.opencdmp.model.UserContactInfo; import org.opencdmp.model.UserContactInfo;
import org.opencdmp.query.utils.BuildSubQueryInput;
import org.opencdmp.query.utils.QueryUtilsService;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -31,10 +34,11 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
private Collection<ContactInfoType> types; private Collection<ContactInfoType> types;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final QueryUtilsService queryUtilsService;
private final UserScope userScope; private final UserScope userScope;
private final AuthorizationService authService; private final AuthorizationService authService;
public UserContactInfoQuery(UserScope userScope, AuthorizationService authService) { public UserContactInfoQuery(QueryUtilsService queryUtilsService, UserScope userScope, AuthorizationService authService) {
this.queryUtilsService = queryUtilsService;
this.userScope = userScope; this.userScope = userScope;
this.authService = authService; this.authService = authService;
} }
@ -168,7 +172,17 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (userId != null) { if (userId != null) {
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(userId)); predicates.add(queryContext.CriteriaBuilder.or(
queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(userId), //Creates a false query
queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DmpUserEntity.class, UUID.class)
.query(queryContext.Query)
.criteriaBuilder(queryContext.CriteriaBuilder)
.keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpUserEntity._userId))
.filterFunc((subQueryRoot, cb) ->
cb.in(subQueryRoot.get(DmpUserEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, false))
)
)))
));
} }
if (!predicates.isEmpty()) { if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
@ -187,6 +201,12 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);
} }
if (this.types != null) {
CriteriaBuilder.In<ContactInfoType> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._type));
for (ContactInfoType item : this.types)
inClause.value(item);
predicates.add(inClause);
}
if (this.userIds != null) { if (this.userIds != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)); CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId));
for (UUID item : this.userIds) for (UUID item : this.userIds)

View File

@ -75,6 +75,14 @@
"category": "rda", "category": "rda",
"name": "rda.dataset.distribution.host.url" "name": "rda.dataset.distribution.host.url"
}, },
{
"category": "rda",
"name": "rda.dataset.distribution.host.support_versioning"
},
{
"category": "rda",
"name": "rda.dataset.distribution.license"
},
{ {
"category": "rda", "category": "rda",
"name": "rda.dataset.distribution.license.license_ref" "name": "rda.dataset.distribution.license.license_ref"

View File

@ -175,6 +175,11 @@ export class ConfigurationService extends BaseComponent {
return this._organizationId; return this._organizationId;
} }
private _depositRecordUrlIdPlaceholder: string;
get depositRecordUrlIdPlaceholder(): string {
return this._depositRecordUrlIdPlaceholder;
}
public loadConfiguration(): Promise<any> { public loadConfiguration(): Promise<any> {
return new Promise((r, e) => { return new Promise((r, e) => {
// We need to exclude all interceptors here, for the initial configuration request. // We need to exclude all interceptors here, for the initial configuration request.
@ -249,6 +254,7 @@ export class ConfigurationService extends BaseComponent {
this._researcherId = config.referenceTypes.researcherId; this._researcherId = config.referenceTypes.researcherId;
this._grantId = config.referenceTypes.grantId; this._grantId = config.referenceTypes.grantId;
this._organizationId = config.referenceTypes.organizationId; this._organizationId = config.referenceTypes.organizationId;
this._depositRecordUrlIdPlaceholder = config.deposit.recordUrlIdPlaceholder;
} }

View File

@ -32,7 +32,7 @@
</button> </button>
</div> </div>
</div> </div>
<div *ngIf="fieldSet.hasMultiplicity && (fieldSet?.multiplicity?.max - 1) > (propertiesFormGroup.get('items').length)" class="col-12 mt-1 ml-0 mr-0 addOneFieldButton"> <div *ngIf="fieldSet.hasMultiplicity && (fieldSet?.multiplicity?.max) > (propertiesFormGroup.get('items').length)" class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
<span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()"> <span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()">
<button mat-icon-button color="primary" [disabled]="propertiesFormGroup.disabled"> <button mat-icon-button color="primary" [disabled]="propertiesFormGroup.disabled">
<mat-icon>add_circle</mat-icon> <mat-icon>add_circle</mat-icon>

View File

@ -572,14 +572,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
//TODO: needs rewriting //TODO: needs rewriting
const repository = this.depositRepos.find(r => r.repositoryId == doiModel.repositoryId); const repository = this.depositRepos.find(r => r.repositoryId == doiModel.repositoryId);
if (typeof repository !== "undefined") { if (typeof repository !== "undefined") {
if (doiModel.repositoryId == "Zenodo") { return repository.repositoryRecordUrl.replace(this.configurationService.depositRecordUrlIdPlaceholder, doiModel.doi);
const doiarr = doiModel.doi.split('.');
const id = doiarr[doiarr.length - 1];
return repository.repositoryRecordUrl + id;
}
else {
return repository.repositoryRecordUrl + doiModel.doi;
}
} }
else { else {
return ""; return "";

View File

@ -82,5 +82,8 @@
"researcherId": "5a2112e7-ea99-4cfe-98a1-68665e26726e", "researcherId": "5a2112e7-ea99-4cfe-98a1-68665e26726e",
"grantId": "5b9c284f-f041-4995-96cc-fad7ad13289c", "grantId": "5b9c284f-f041-4995-96cc-fad7ad13289c",
"organizationId": "7eeffb98-58fb-4921-82ec-e27f32f8e738" "organizationId": "7eeffb98-58fb-4921-82ec-e27f32f8e738"
},
"deposit":{
"recordUrlIdPlaceholder": "{doi_id}"
} }
} }