diff --git a/backend/core/src/main/java/org/opencdmp/authorization/authorizationcontentresolver/AuthorizationContentResolverImpl.java b/backend/core/src/main/java/org/opencdmp/authorization/authorizationcontentresolver/AuthorizationContentResolverImpl.java index 2b770cea6..db7711ea7 100644 --- a/backend/core/src/main/java/org/opencdmp/authorization/authorizationcontentresolver/AuthorizationContentResolverImpl.java +++ b/backend/core/src/main/java/org/opencdmp/authorization/authorizationcontentresolver/AuthorizationContentResolverImpl.java @@ -1,5 +1,7 @@ package org.opencdmp.authorization.authorizationcontentresolver; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.fieldset.BaseFieldSet; import org.opencdmp.authorization.AffiliatedResource; import org.opencdmp.authorization.PermissionNameProvider; import org.opencdmp.commons.enums.IsActive; @@ -9,14 +11,12 @@ import org.opencdmp.data.DescriptionEntity; import org.opencdmp.data.DmpDescriptionTemplateEntity; import org.opencdmp.data.DmpEntity; import org.opencdmp.data.DmpUserEntity; -import org.opencdmp.model.description.Description; import org.opencdmp.model.DmpDescriptionTemplate; import org.opencdmp.model.DmpUser; +import org.opencdmp.model.description.Description; import org.opencdmp.query.DescriptionQuery; import org.opencdmp.query.DmpDescriptionTemplateQuery; import org.opencdmp.query.DmpUserQuery; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.fieldset.BaseFieldSet; import org.springframework.stereotype.Service; import org.springframework.web.context.annotation.RequestScope; @@ -42,7 +42,7 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes @Override public List getPermissionNames() { - return permissionNameProvider.getPermissions(); + return this.permissionNameProvider.getPermissions(); } @Override @@ -56,12 +56,12 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes for (UUID id : ids){ affiliatedResources.put(id, new AffiliatedResource()); } - if (userId == null || !userScope.isSet()) return affiliatedResources; + if (userId == null || !this.userScope.isSet()) return affiliatedResources; List idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DmpEntity.class.getSimpleName()); if (idsToResolve.isEmpty()) return affiliatedResources; - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(ids).sectionIsEmpty(true).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._dmp)); + List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(ids).sectionIsEmpty(true).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._dmp)); for (DmpUserEntity dmpUser : dmpUsers){ affiliatedResources.get(dmpUser.getDmpId()).getDmpUserRoles().add(dmpUser.getRole()); @@ -82,16 +82,16 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes for (UUID id : ids){ affiliatedResources.put(id, new AffiliatedResource()); } - if (userId == null || !userScope.isSet()) return affiliatedResources; + if (userId == null || !this.userScope.isSet()) return affiliatedResources; List idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DescriptionEntity.class.getSimpleName()); if (idsToResolve.isEmpty()) return affiliatedResources; - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).ids(ids).collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._dmpDescriptionTemplate).ensure(Description._dmp)); - List dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntities.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().toList()).collectAs(new BaseFieldSet().ensure(DmpDescriptionTemplate._id).ensure(DmpDescriptionTemplate._sectionId)); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(ids).collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._dmpDescriptionTemplate).ensure(Description._dmp)); + List dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(descriptionEntities.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().toList()).collectAs(new BaseFieldSet().ensure(DmpDescriptionTemplate._id).ensure(DmpDescriptionTemplate._sectionId)); Map dmpDescriptionTemplateEntityMap = dmpDescriptionTemplateEntities == null ? new HashMap<>() : dmpDescriptionTemplateEntities.stream().collect(Collectors.toMap(DmpDescriptionTemplateEntity::getId, x-> x)); - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).descriptionIds(ids).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._sectionId).ensure(DmpUser._dmp)); + List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().descriptionIds(ids).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._sectionId).ensure(DmpUser._dmp)); Map> dmpUsersMap = dmpUsers.stream().collect(Collectors.groupingBy(DmpUserEntity::getDmpId)); for (DescriptionEntity description : descriptionEntities){ @@ -123,9 +123,9 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes for (UUID id : sectionIds){ affiliatedResources.put(id, new AffiliatedResource()); } - if (userId == null || !userScope.isSet()) return affiliatedResources; + if (userId == null || !this.userScope.isSet()) return affiliatedResources; - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmpId).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._sectionId).ensure(DmpUser._dmp)); + List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(dmpId).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._sectionId).ensure(DmpUser._dmp)); for (UUID sectionId : sectionIds.stream().distinct().toList()){ List dmpSectionUsers = dmpUsers.stream().filter(x-> x.getSectionId() == null || x.getSectionId().equals(sectionId)).toList(); diff --git a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java index 62aab6ad6..cf09ccb5d 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java @@ -1,25 +1,28 @@ package org.opencdmp.elastic.elasticbuilder; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.DescriptionEntity; import org.opencdmp.data.DescriptionReferenceEntity; import org.opencdmp.data.DescriptionTagEntity; import org.opencdmp.elastic.data.DescriptionElasticEntity; -import org.opencdmp.elastic.data.nested.*; +import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; +import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; +import org.opencdmp.elastic.data.nested.NestedReferenceElasticEntity; +import org.opencdmp.elastic.data.nested.NestedTagElasticEntity; import org.opencdmp.elastic.elasticbuilder.nested.NestedDescriptionTemplateElasticBuilder; import org.opencdmp.elastic.elasticbuilder.nested.NestedDmpElasticBuilder; import org.opencdmp.elastic.elasticbuilder.nested.NestedReferenceElasticBuilder; import org.opencdmp.elastic.elasticbuilder.nested.NestedTagElasticBuilder; -import org.opencdmp.model.*; +import org.opencdmp.model.DescriptionTag; import org.opencdmp.model.descriptionreference.DescriptionReference; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; import org.opencdmp.model.dmp.Dmp; import org.opencdmp.query.*; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -30,7 +33,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DescriptionElasticBuilder extends BaseElasticBuilder { private final QueryFactory queryFactory; @@ -82,10 +85,10 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); - ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); + ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).disableTracking().ids(associationEntities.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); Map itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId); Map> itemMap = new HashMap<>(); @@ -102,10 +105,10 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); - TagQuery query = this.queryFactory.query(TagQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList())); + TagQuery query = this.queryFactory.query(TagQuery.class).disableTracking().isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList())); Map itemMapById = this.builderFactory.builder(NestedTagElasticBuilder.class).asForeignKey(query, NestedTagElasticEntity::getId); Map> itemMap = new HashMap<>(); @@ -124,7 +127,7 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder itemMap; - DmpQuery q = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList())); + DmpQuery q = this.queryFactory.query(DmpQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(NestedDmpElasticBuilder.class).asForeignKey(q, NestedDmpElasticEntity::getId); return itemMap; @@ -136,7 +139,7 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder itemMap; - DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); + DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(q, NestedDescriptionTemplateElasticEntity::getId); return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DmpElasticBuilder.java b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DmpElasticBuilder.java index 013ced316..c8cd87e4d 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DmpElasticBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DmpElasticBuilder.java @@ -1,17 +1,23 @@ package org.opencdmp.elastic.elasticbuilder; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.*; -import org.opencdmp.elastic.data.DmpElasticEntity; -import org.opencdmp.elastic.data.nested.*; -import org.opencdmp.elastic.elasticbuilder.nested.*; -import org.opencdmp.model.dmpreference.DmpReference; -import org.opencdmp.query.*; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.*; +import org.opencdmp.elastic.data.DmpElasticEntity; +import org.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity; +import org.opencdmp.elastic.data.nested.NestedDescriptionElasticEntity; +import org.opencdmp.elastic.data.nested.NestedDoiElasticEntity; +import org.opencdmp.elastic.data.nested.NestedReferenceElasticEntity; +import org.opencdmp.elastic.elasticbuilder.nested.NestedCollaboratorElasticBuilder; +import org.opencdmp.elastic.elasticbuilder.nested.NestedDescriptionElasticBuilder; +import org.opencdmp.elastic.elasticbuilder.nested.NestedDoiElasticBuilder; +import org.opencdmp.elastic.elasticbuilder.nested.NestedReferenceElasticBuilder; +import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.query.*; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -22,7 +28,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpElasticBuilder extends BaseElasticBuilder { private final QueryFactory queryFactory; @@ -79,10 +85,10 @@ public class DmpElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); - ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); + ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).disableTracking().isActive(IsActive.Active).ids(associationEntities.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); Map itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId); Map> itemMap = new HashMap<>(); @@ -101,7 +107,7 @@ public class DmpElasticBuilder extends BaseElasticBuilder> itemMap; - DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).dmpSubQuery(this.queryFactory.query(DmpQuery.class).ids(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()))); + DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(this.queryFactory.query(DmpQuery.class).ids(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()))); itemMap = this.builderFactory.builder(NestedDescriptionElasticBuilder.class).asMasterKey(q, NestedDescriptionElasticEntity::getDmpId); return itemMap; @@ -112,7 +118,7 @@ public class DmpElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); Map itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId); @@ -131,7 +137,7 @@ public class DmpElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); Map itemMapById = this.builderFactory.builder(NestedDoiElasticBuilder.class).asForeignKey(associationEntities, NestedDoiElasticEntity::getId); diff --git a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedCollaboratorElasticBuilder.java b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedCollaboratorElasticBuilder.java index a43f08b0e..1af366104 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedCollaboratorElasticBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedCollaboratorElasticBuilder.java @@ -39,7 +39,7 @@ public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder(); List models = new ArrayList<>(); - Map userNameMap = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(User._id).ensure(User._name)) + Map userNameMap = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(User._id).ensure(User._name)) .stream().collect(Collectors.toMap(UserEntity::getId, UserEntity::getName)); for (DmpUserEntity d : data) { NestedCollaboratorElasticEntity m = new NestedCollaboratorElasticEntity(); diff --git a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDescriptionElasticBuilder.java b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDescriptionElasticBuilder.java index 1e0d28269..d3f971383 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDescriptionElasticBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDescriptionElasticBuilder.java @@ -1,5 +1,9 @@ package org.opencdmp.elastic.elasticbuilder.nested; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.DescriptionEntity; @@ -10,14 +14,10 @@ import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; import org.opencdmp.elastic.data.nested.NestedReferenceElasticEntity; import org.opencdmp.elastic.data.nested.NestedTagElasticEntity; import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder; -import org.opencdmp.model.descriptionreference.DescriptionReference; import org.opencdmp.model.DescriptionTag; +import org.opencdmp.model.descriptionreference.DescriptionReference; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; import org.opencdmp.query.*; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -28,7 +28,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class NestedDescriptionElasticBuilder extends BaseElasticBuilder { private final QueryFactory queryFactory; @@ -74,10 +74,10 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); - ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); + ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).disableTracking().isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); Map itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId); Map> itemMap = new HashMap<>(); @@ -94,10 +94,10 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); - TagQuery query = this.queryFactory.query(TagQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList())); + TagQuery query = this.queryFactory.query(TagQuery.class).disableTracking().isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList())); Map itemMapById = this.builderFactory.builder(NestedTagElasticBuilder.class).asForeignKey(query, NestedTagElasticEntity::getId); Map> itemMap = new HashMap<>(); @@ -116,7 +116,7 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder itemMap; - DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); + DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(q, NestedDescriptionTemplateElasticEntity::getId); return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDmpElasticBuilder.java b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDmpElasticBuilder.java index d7a7b6583..55f67c1e4 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDmpElasticBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDmpElasticBuilder.java @@ -1,22 +1,25 @@ package org.opencdmp.elastic.elasticbuilder.nested; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.DmpEntity; import org.opencdmp.data.DmpReferenceEntity; import org.opencdmp.data.DmpUserEntity; import org.opencdmp.data.EntityDoiEntity; -import org.opencdmp.elastic.data.nested.*; +import org.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity; +import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; +import org.opencdmp.elastic.data.nested.NestedDoiElasticEntity; +import org.opencdmp.elastic.data.nested.NestedReferenceElasticEntity; import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder; import org.opencdmp.model.dmpreference.DmpReference; import org.opencdmp.query.DmpReferenceQuery; import org.opencdmp.query.DmpUserQuery; import org.opencdmp.query.EntityDoiQuery; import org.opencdmp.query.ReferenceQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -27,7 +30,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class NestedDmpElasticBuilder extends BaseElasticBuilder { private final QueryFactory queryFactory; @@ -80,10 +83,10 @@ public class NestedDmpElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); - ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); + ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).disableTracking().isActive(IsActive.Active).ids(associationEntities.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); Map itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId); Map> itemMap = new HashMap<>(); @@ -101,7 +104,7 @@ public class NestedDmpElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); Map itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId); @@ -120,7 +123,7 @@ public class NestedDmpElasticBuilder extends BaseElasticBuilder associationEntities = associationQuery.collect(); Map itemMapById = this.builderFactory.builder(NestedDoiElasticBuilder.class).asForeignKey(associationEntities, NestedDoiElasticEntity::getId); diff --git a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentityremoval/AnnotationEntityRemovalIntegrationEventHandlerImpl.java b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentityremoval/AnnotationEntityRemovalIntegrationEventHandlerImpl.java index 73f8e73c5..9ba6f13de 100644 --- a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentityremoval/AnnotationEntityRemovalIntegrationEventHandlerImpl.java +++ b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentityremoval/AnnotationEntityRemovalIntegrationEventHandlerImpl.java @@ -1,14 +1,14 @@ package org.opencdmp.integrationevent.outbox.annotationentityremoval; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.data.DescriptionEntity; import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent; import org.opencdmp.integrationevent.outbox.OutboxService; import org.opencdmp.model.description.Description; import org.opencdmp.query.DescriptionQuery; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -20,7 +20,7 @@ import java.util.List; import java.util.UUID; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class AnnotationEntityRemovalIntegrationEventHandlerImpl implements AnnotationEntityRemovalIntegrationEventHandler { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AnnotationEntityRemovalIntegrationEventHandlerImpl.class)); @@ -41,7 +41,7 @@ public class AnnotationEntityRemovalIntegrationEventHandlerImpl implements Annot message.setMessageId(UUID.randomUUID()); message.setType(OutboxIntegrationEvent.ANNOTATION_ENTITY_REMOVE); message.setEvent(event); - if (this.tenantScope.isSet()) message.setTenantId(tenantScope.getTenant()); + if (this.tenantScope.isSet()) message.setTenantId(this.tenantScope.getTenant()); this.outboxService.publish(message); } @@ -55,7 +55,7 @@ public class AnnotationEntityRemovalIntegrationEventHandlerImpl implements Annot @Override public void handleDmp(UUID dmpId) throws InvalidApplicationException { - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).dmpIds(dmpId).collectAs(new BaseFieldSet().ensure(Description._id)); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().dmpIds(dmpId).collectAs(new BaseFieldSet().ensure(Description._id)); AnnotationEntitiesRemovalIntegrationEvent event = new AnnotationEntitiesRemovalIntegrationEvent(); event.setEntityIds(new ArrayList<>()); diff --git a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentitytouch/AnnotationEntityTouchedIntegrationEventHandlerImpl.java b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentitytouch/AnnotationEntityTouchedIntegrationEventHandlerImpl.java index c6044cb11..a2349701a 100644 --- a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentitytouch/AnnotationEntityTouchedIntegrationEventHandlerImpl.java +++ b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentitytouch/AnnotationEntityTouchedIntegrationEventHandlerImpl.java @@ -1,17 +1,17 @@ package org.opencdmp.integrationevent.outbox.annotationentitytouch; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.data.DescriptionEntity; import org.opencdmp.data.DmpUserEntity; import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent; import org.opencdmp.integrationevent.outbox.OutboxService; -import org.opencdmp.model.description.Description; import org.opencdmp.model.DmpUser; +import org.opencdmp.model.description.Description; import org.opencdmp.query.DescriptionQuery; import org.opencdmp.query.DmpUserQuery; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -22,7 +22,7 @@ import java.util.List; import java.util.UUID; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class AnnotationEntityTouchedIntegrationEventHandlerImpl implements AnnotationEntityTouchedIntegrationEventHandler { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AnnotationEntityTouchedIntegrationEventHandlerImpl.class)); @@ -47,9 +47,9 @@ public class AnnotationEntityTouchedIntegrationEventHandlerImpl implements Annot @Override public void handleDescription(UUID descriptionId) { - DescriptionEntity entity = this.queryFactory.query(DescriptionQuery.class).ids(descriptionId).firstAs(new BaseFieldSet().ensure(Description._dmp).ensure(DescriptionEntity._tenantId)); + DescriptionEntity entity = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(descriptionId).firstAs(new BaseFieldSet().ensure(Description._dmp).ensure(DescriptionEntity._tenantId)); if (entity == null) return; - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(entity.getDmpId()).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._user)); + List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(entity.getDmpId()).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._user)); AnnotationEntitiesTouchedIntegrationEvent event = new AnnotationEntitiesTouchedIntegrationEvent(); event.setEvents(List.of(this.buildEventItem(descriptionId, dmpUsers))); @@ -59,9 +59,9 @@ public class AnnotationEntityTouchedIntegrationEventHandlerImpl implements Annot @Override public void handleDmp(UUID dmpId) { - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).dmpIds(dmpId).collectAs(new BaseFieldSet().ensure(Description._id)); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().dmpIds(dmpId).collectAs(new BaseFieldSet().ensure(Description._id)); if (descriptionEntities == null || descriptionEntities.isEmpty()) return; - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmpId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._user)); + List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(dmpId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._user)); AnnotationEntitiesTouchedIntegrationEvent event = new AnnotationEntitiesTouchedIntegrationEvent(); event.setEvents(new ArrayList<>()); diff --git a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/usertouched/UserTouchedIntegrationEventHandlerImpl.java b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/usertouched/UserTouchedIntegrationEventHandlerImpl.java index 6c425621d..8396a9c16 100644 --- a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/usertouched/UserTouchedIntegrationEventHandlerImpl.java +++ b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/usertouched/UserTouchedIntegrationEventHandlerImpl.java @@ -1,19 +1,23 @@ package org.opencdmp.integrationevent.outbox.usertouched; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.commons.JsonHandlingService; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.types.user.AdditionalInfoEntity; import org.opencdmp.data.*; import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent; import org.opencdmp.integrationevent.outbox.OutboxService; -import org.opencdmp.model.*; +import org.opencdmp.model.TenantUser; +import org.opencdmp.model.UserContactInfo; import org.opencdmp.model.user.User; import org.opencdmp.model.usercredential.UserCredential; -import org.opencdmp.query.*; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyNotFoundException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.logging.LoggerService; +import org.opencdmp.query.TenantUserQuery; +import org.opencdmp.query.UserContactInfoQuery; +import org.opencdmp.query.UserCredentialQuery; +import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; @@ -27,7 +31,7 @@ import java.util.List; import java.util.UUID; @Component("outboxusertouchedintegrationeventhandler") -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegrationEventHandler { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserTouchedIntegrationEventHandlerImpl.class)); @@ -54,22 +58,22 @@ public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegr OutboxIntegrationEvent message = new OutboxIntegrationEvent(); message.setMessageId(UUID.randomUUID()); message.setType(OutboxIntegrationEvent.USER_TOUCH); - if (this.tenantScope.isSet()) message.setTenantId(tenantScope.getTenant()); + if (this.tenantScope.isSet()) message.setTenantId(this.tenantScope.getTenant()); try { this.entityManager.disableTenantFilters(); - UserEntity user = this.queryFactory.query(UserQuery.class).ids(userId) + UserEntity user = this.queryFactory.query(UserQuery.class).ids(userId).disableTracking() .firstAs(new BaseFieldSet().ensure(User._name).ensure(User._additionalInfo)); - if (user == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{userId, User.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (user == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{userId, User.class.getSimpleName()}, LocaleContextHolder.getLocale())); - List userContactInfoEntities = this.queryFactory.query(UserContactInfoQuery.class).userIds(userId) + List userContactInfoEntities = this.queryFactory.query(UserContactInfoQuery.class).disableTracking().userIds(userId) .collectAs(new BaseFieldSet().ensure(UserContactInfo._type).ensure(UserContactInfo._ordinal).ensure(UserContactInfo._value)); - List userCredentialEntities = this.queryFactory.query(UserCredentialQuery.class).userIds(userId) + List userCredentialEntities = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(userId) .collectAs(new BaseFieldSet().ensure(UserCredential._id, UserCredential._externalId)); - List tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).userIds(userId) + List tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).disableTracking().userIds(userId) .collectAs(new BaseFieldSet().ensure(TenantUser._id, TenantUser._tenant)); UserTouchedIntegrationEvent event = new UserTouchedIntegrationEvent(); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/DescriptionTagBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/DescriptionTagBuilder.java index fb915da9d..6cfcc61ce 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/DescriptionTagBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/DescriptionTagBuilder.java @@ -1,15 +1,5 @@ package org.opencdmp.model.builder; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DescriptionTagEntity; -import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder; -import org.opencdmp.model.description.Description; -import org.opencdmp.model.DescriptionTag; -import org.opencdmp.model.Tag; -import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.TagQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; @@ -17,6 +7,16 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.scope.tenant.TenantScope; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.DescriptionTagEntity; +import org.opencdmp.model.DescriptionTag; +import org.opencdmp.model.Tag; +import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder; +import org.opencdmp.model.description.Description; +import org.opencdmp.query.DescriptionQuery; +import org.opencdmp.query.TagQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -27,7 +27,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DescriptionTagBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -103,7 +103,7 @@ public class DescriptionTagBuilder extends BaseBuilder { private final QueryFactory queryFactory; @@ -82,7 +83,7 @@ public class DmpAssociatedUserBuilder extends BaseBuilder> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserContactInfo._user, User._id)); - UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); + UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).disableTracking().authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserContactInfoBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserContactInfo._user, User._id))) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java index c9421a7ca..dcf9d1b86 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java @@ -109,7 +109,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._groupId); - DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).groupIds(data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList())); + DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).groupIds(data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).asMasterKey(query, clone, DescriptionTemplate::getGroupId); if (!fields.hasField(DescriptionTemplate._groupId)) { @@ -155,7 +155,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder{ User::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); } if (!fields.hasField(User._id)) { @@ -132,7 +132,7 @@ public class DmpUserBuilder extends BaseBuilder{ Dmp::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); - DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getDmpId).distinct().collect(Collectors.toList())); + DmpQuery q = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getDmpId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId); } if (!fields.hasField(Dmp._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/LockBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/LockBuilder.java index 0e37c1702..1b8678c6c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/LockBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/LockBuilder.java @@ -1,12 +1,5 @@ package org.opencdmp.model.builder; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.LockEntity; -import org.opencdmp.model.Lock; -import org.opencdmp.model.user.User; -import org.opencdmp.query.UserQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; @@ -14,6 +7,13 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.scope.tenant.TenantScope; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.LockEntity; +import org.opencdmp.model.Lock; +import org.opencdmp.model.user.User; +import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -24,7 +24,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class LockBuilder extends BaseBuilder{ private final BuilderFactory builderFactory; @@ -91,7 +91,7 @@ public class LockBuilder extends BaseBuilder{ User::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(LockEntity::getLockedBy).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(LockEntity::getLockedBy).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); } if (!fields.hasField(User._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionBuilder.java index dd13acb98..964a12796 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionBuilder.java @@ -1,12 +1,5 @@ package org.opencdmp.model.builder; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DescriptionEntity; -import org.opencdmp.model.*; -import org.opencdmp.query.DescriptionTemplateQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; -import org.opencdmp.query.DmpQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; @@ -14,6 +7,16 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.DescriptionEntity; +import org.opencdmp.model.PublicDescription; +import org.opencdmp.model.PublicDescriptionTemplate; +import org.opencdmp.model.PublicDmp; +import org.opencdmp.model.PublicDmpDescriptionTemplate; +import org.opencdmp.query.DescriptionTemplateQuery; +import org.opencdmp.query.DmpDescriptionTemplateQuery; +import org.opencdmp.query.DmpQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -24,7 +27,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class PublicDescriptionBuilder extends BaseBuilder { private final QueryFactory queryFactory; @@ -101,7 +104,7 @@ public class PublicDescriptionBuilder extends BaseBuilder { private final QueryFactory queryFactory; @@ -101,7 +101,7 @@ public class PublicDmpBuilder extends BaseBuilder { Map> itemMap = null; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpReference._dmp, PublicDmp._id)); - DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(PublicDmpReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(PublicDmpReference._dmp, PublicDmp._id))) { @@ -119,7 +119,7 @@ public class PublicDmpBuilder extends BaseBuilder { Map> itemMap = null; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpUser._dmp, PublicDmp._id)); - DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).disableTracking().authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(PublicDmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(PublicDmpUser._dmp, PublicDmp._id))) { @@ -137,7 +137,7 @@ public class PublicDmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDescription._dmp, PublicDescription._id)); - DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(PublicDescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(PublicDescription._dmp, PublicDescription._id))) { @@ -155,7 +155,7 @@ public class PublicDmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicEntityDoi._entityId)); - EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).authorize(this.authorize).types(EntityType.DMP).entityIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(this.authorize).types(EntityType.DMP).entityIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(PublicEntityDoiBuilder.class).authorize(this.authorize).asMasterKey(query, clone, PublicEntityDoi::getEntityId); if (!fields.hasField(this.asIndexer(PublicEntityDoi._entityId))) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java index 960b84031..234dab424 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java @@ -1,13 +1,5 @@ package org.opencdmp.model.builder; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpDescriptionTemplateEntity; -import org.opencdmp.model.PublicDescriptionTemplate; -import org.opencdmp.model.PublicDmp; -import org.opencdmp.model.PublicDmpDescriptionTemplate; -import org.opencdmp.query.DescriptionTemplateQuery; -import org.opencdmp.query.DmpQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; @@ -15,6 +7,12 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.DmpDescriptionTemplateEntity; +import org.opencdmp.model.PublicDmp; +import org.opencdmp.model.PublicDmpDescriptionTemplate; +import org.opencdmp.query.DmpQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -25,7 +23,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -87,7 +85,7 @@ public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -92,7 +92,7 @@ public class PublicDmpReferenceBuilder extends BaseBuilder{ private final BuilderFactory builderFactory; @@ -92,7 +92,7 @@ public class PublicDmpUserBuilder extends BaseBuilder{ private final BuilderFactory builderFactory; @@ -92,7 +88,7 @@ public class PublicReferenceBuilder extends BaseBuilder x.getType().equals(RecentActivityItemType.Dmp)).map(RecentActivityItemEntity::getId).distinct().collect(Collectors.toList())); + DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().filter(x-> x.getType().equals(RecentActivityItemType.Dmp)).map(RecentActivityItemEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId); } if (!fields.hasField(Dmp._id)) { @@ -121,7 +121,7 @@ public class RecentActivityItemBuilder extends BaseBuilder x.getType().equals(RecentActivityItemType.Description)).map(RecentActivityItemEntity::getId).distinct().collect(Collectors.toList())); + DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().filter(x-> x.getType().equals(RecentActivityItemType.Description)).map(RecentActivityItemEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Description::getId); } if (!fields.hasField(Description._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/StorageFileBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/StorageFileBuilder.java index 3c42a64eb..8797c6f6b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/StorageFileBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/StorageFileBuilder.java @@ -1,12 +1,5 @@ package org.opencdmp.model.builder; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.StorageFileEntity; -import org.opencdmp.model.*; -import org.opencdmp.model.user.User; -import org.opencdmp.query.*; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; @@ -14,6 +7,13 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.scope.tenant.TenantScope; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.StorageFileEntity; +import org.opencdmp.model.StorageFile; +import org.opencdmp.model.user.User; +import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -24,7 +24,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class StorageFileBuilder extends BaseBuilder { private final QueryFactory queryFactory; @@ -100,7 +100,7 @@ public class StorageFileBuilder extends BaseBuilder{ private final QueryFactory queryFactory; @@ -89,7 +89,7 @@ public class TagBuilder extends BaseBuilder{ User::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(TagEntity::getCreatedById).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(TagEntity::getCreatedById).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); } if (!fields.hasField(User._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/TenantUserBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/TenantUserBuilder.java index 9a210ac66..d86bc7dd8 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/TenantUserBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/TenantUserBuilder.java @@ -1,5 +1,12 @@ package org.opencdmp.model.builder; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.convention.ConventionService; @@ -9,13 +16,6 @@ import org.opencdmp.model.TenantUser; import org.opencdmp.model.user.User; import org.opencdmp.query.TenantQuery; import org.opencdmp.query.UserQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.logging.DataLogEntry; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -26,7 +26,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class TenantUserBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -98,7 +98,7 @@ public class TenantUserBuilder extends BaseBuilder x -> x.getId()); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(datas.stream().map(x -> x.getUserId()).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(datas.stream().map(x -> x.getUserId()).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, x -> x.getId()); } if (!fields.hasField(User._id)) { @@ -127,7 +127,7 @@ public class TenantUserBuilder extends BaseBuilder x -> x.getId()); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Tenant._id); - TenantQuery q = this.queryFactory.query(TenantQuery.class).authorize(this.authorize).ids(datas.stream().map(x -> x.getTenantId()).distinct().collect(Collectors.toList())); + TenantQuery q = this.queryFactory.query(TenantQuery.class).disableTracking().authorize(this.authorize).ids(datas.stream().map(x -> x.getTenantId()).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(TenantBuilder.class).authorize(this.authorize).asForeignKey(q, clone, x -> x.getId()); } if (!fields.hasField(Tenant._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/UserAdditionalInfoBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/UserAdditionalInfoBuilder.java index c11a92bd5..27d5e0f89 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/UserAdditionalInfoBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/UserAdditionalInfoBuilder.java @@ -94,7 +94,7 @@ public class UserAdditionalInfoBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserContactInfo._user, User._id)); - UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); + UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).disableTracking().authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserContactInfoBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserContactInfo._user, User._id))) { @@ -145,7 +145,7 @@ public class UserBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserRole._user, User._id)); - UserRoleQuery query = this.queryFactory.query(UserRoleQuery.class).authorize(this.authorize).tenantIsSet(false).roles(this.authorizationProperties.getAllowedGlobalRoles()).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); + UserRoleQuery query = this.queryFactory.query(UserRoleQuery.class).disableTracking().authorize(this.authorize).tenantIsSet(false).roles(this.authorizationProperties.getAllowedGlobalRoles()).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserRoleBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserRole._user, User._id))) { @@ -165,7 +165,7 @@ public class UserBuilder extends BaseBuilder { if (!this.tenantScope.isSet()) throw new MyForbiddenException("tenant scope required"); - UserRoleQuery query = this.queryFactory.query(UserRoleQuery.class).authorize(this.authorize).roles(this.authorizationProperties.getAllowedTenantRoles()).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); + UserRoleQuery query = this.queryFactory.query(UserRoleQuery.class).disableTracking().authorize(this.authorize).roles(this.authorizationProperties.getAllowedTenantRoles()).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); if (this.tenantScope.isDefaultTenant()) query.tenantIsSet(false); else { try { @@ -192,7 +192,7 @@ public class UserBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserCredential._user, User._id)); - UserCredentialQuery query = this.queryFactory.query(UserCredentialQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); + UserCredentialQuery query = this.queryFactory.query(UserCredentialQuery.class).disableTracking().authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserCredentialBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserCredential._user, User._id))) { @@ -210,7 +210,7 @@ public class UserBuilder extends BaseBuilder { Map> itemMap = null; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(TenantUser._user, User._id)); - TenantUserQuery query = this.queryFactory.query(TenantUserQuery.class).authorize(this.authorize).userIds(datas.stream().map(x -> x.getId()).distinct().collect(Collectors.toList())); + TenantUserQuery query = this.queryFactory.query(TenantUserQuery.class).disableTracking().authorize(this.authorize).userIds(datas.stream().map(x -> x.getId()).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(TenantUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(TenantUser._user, User._id))) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/UserContactInfoBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/UserContactInfoBuilder.java index 3da92f5dd..0b6a3a8f7 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/UserContactInfoBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/UserContactInfoBuilder.java @@ -1,11 +1,5 @@ package org.opencdmp.model.builder; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.UserContactInfoEntity; -import org.opencdmp.model.user.User; -import org.opencdmp.model.UserContactInfo; -import org.opencdmp.query.UserQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; @@ -13,6 +7,12 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.UserContactInfoEntity; +import org.opencdmp.model.UserContactInfo; +import org.opencdmp.model.user.User; +import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -23,7 +23,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserContactInfoBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -92,7 +92,7 @@ public class UserContactInfoBuilder extends BaseBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -97,7 +97,7 @@ public class UserDescriptionTemplateBuilder extends BaseBuilder x.getId()); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._id); - DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).ids(data.stream().map(UserDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); + DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(data.stream().map(UserDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).asForeignKey(q, clone, DescriptionTemplate::getId); } if (!fields.hasField(DescriptionTemplate._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/UserRoleBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/UserRoleBuilder.java index 32ff03d21..dec43612c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/UserRoleBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/UserRoleBuilder.java @@ -1,12 +1,5 @@ package org.opencdmp.model.builder; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.UserRoleEntity; -import org.opencdmp.model.user.User; -import org.opencdmp.model.UserRole; -import org.opencdmp.query.UserQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; @@ -14,6 +7,13 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.scope.tenant.TenantScope; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.UserRoleEntity; +import org.opencdmp.model.UserRole; +import org.opencdmp.model.user.User; +import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -24,7 +24,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserRoleBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -94,7 +94,7 @@ public class UserRoleBuilder extends BaseBuilder { User::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(UserRoleEntity::getUserId).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(UserRoleEntity::getUserId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); } if (!fields.hasField(User._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/ActionConfirmationBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/ActionConfirmationBuilder.java index 23548af37..bd5de2a7a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/ActionConfirmationBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/ActionConfirmationBuilder.java @@ -1,5 +1,12 @@ package org.opencdmp.model.builder.actionconfirmation; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.scope.tenant.TenantScope; @@ -13,13 +20,6 @@ import org.opencdmp.model.builder.BaseBuilder; import org.opencdmp.model.builder.UserBuilder; import org.opencdmp.model.user.User; import org.opencdmp.query.UserQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.logging.DataLogEntry; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -30,7 +30,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ActionConfirmationBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -120,7 +120,7 @@ public class ActionConfirmationBuilder extends BaseBuilder x.getId()); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(datas.stream().map(x -> x.getCreatedById()).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(datas.stream().map(x -> x.getCreatedById()).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, x -> x.getId()); } if (!fields.hasField(User._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/DmpUserCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/DmpUserCommonModelBuilder.java index c92cb0a6a..7ce8ae9bb 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/DmpUserCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/DmpUserCommonModelBuilder.java @@ -78,7 +78,7 @@ public class DmpUserCommonModelBuilder extends BaseCommonModelBuilder itemMap; - UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId); return itemMap; } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/UserCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/UserCommonModelBuilder.java index 920c00115..3f95b476d 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/UserCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/UserCommonModelBuilder.java @@ -1,23 +1,17 @@ package org.opencdmp.model.builder.commonmodels; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commonmodels.models.DmpUserModel; -import org.opencdmp.commonmodels.models.UserContactInfoModel; -import org.opencdmp.commonmodels.models.UserModel; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.data.DmpUserEntity; -import org.opencdmp.data.UserContactInfoEntity; -import org.opencdmp.data.UserEntity; -import org.opencdmp.model.DmpUser; -import org.opencdmp.model.UserContactInfo; -import org.opencdmp.query.DmpUserQuery; -import org.opencdmp.query.UserContactInfoQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commonmodels.models.UserContactInfoModel; +import org.opencdmp.commonmodels.models.UserModel; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.UserContactInfoEntity; +import org.opencdmp.data.UserEntity; +import org.opencdmp.model.UserContactInfo; +import org.opencdmp.query.UserContactInfoQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -28,7 +22,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserCommonModelBuilder extends BaseCommonModelBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -49,7 +43,7 @@ public class UserCommonModelBuilder extends BaseCommonModelBuilder> itemMap; - UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); + UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).disableTracking().authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserContactInfoCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, UserContactInfoEntity::getUserId); return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java index 5801bf25d..943388218 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java @@ -1,5 +1,10 @@ package org.opencdmp.model.builder.commonmodels.description; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.enums.DescriptionStatus; import org.opencdmp.commonmodels.models.description.DescriptionModel; @@ -14,20 +19,17 @@ import org.opencdmp.data.DescriptionEntity; import org.opencdmp.data.DescriptionTemplateEntity; import org.opencdmp.data.DmpDescriptionTemplateEntity; import org.opencdmp.data.DmpEntity; -import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; import org.opencdmp.model.DmpDescriptionTemplate; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; -import org.opencdmp.model.builder.commonmodels.dmp.DmpCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.descriptiontemplate.DescriptionTemplateCommonModelBuilder; -import org.opencdmp.query.*; +import org.opencdmp.model.builder.commonmodels.dmp.DmpCommonModelBuilder; +import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; +import org.opencdmp.query.DescriptionTemplateQuery; +import org.opencdmp.query.DmpDescriptionTemplateQuery; +import org.opencdmp.query.DmpQuery; import org.opencdmp.service.visibility.VisibilityService; import org.opencdmp.service.visibility.VisibilityServiceImpl; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -38,7 +40,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder { private final QueryFactory queryFactory; @@ -110,7 +112,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder itemMap = new HashMap<>(); - DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); + DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); List items = q.collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._definition)); for (DescriptionTemplateEntity item : items){ DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, item.getDefinition()); @@ -144,7 +146,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder itemMap = new HashMap<>(); - DmpDescriptionTemplateQuery q = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList())); + DmpDescriptionTemplateQuery q = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList())); List items = q.collectAs(new BaseFieldSet().ensure(org.opencdmp.model.DmpDescriptionTemplate._id).ensure(DmpDescriptionTemplate._sectionId)); for (DmpDescriptionTemplateEntity item : items){ itemMap.put(item.getId(), item.getSectionId()); @@ -159,8 +161,8 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder itemMap; - DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(DmpCommonModelBuilder.class).setRepositoryId(repositoryId).useSharedStorage(useSharedStorage).setDisableDescriptions(true).authorize(this.authorize).asForeignKey(q, DmpEntity::getId); + DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(DmpCommonModelBuilder.class).setRepositoryId(this.repositoryId).useSharedStorage(this.useSharedStorage).setDisableDescriptions(true).authorize(this.authorize).asForeignKey(q, DmpEntity::getId); return itemMap; } @@ -171,7 +173,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder itemMap; - DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); + DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionTemplateCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, DescriptionTemplateEntity::getId); return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/FieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/FieldCommonModelBuilder.java index 1782946d4..0a353c716 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/FieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/FieldCommonModelBuilder.java @@ -18,12 +18,12 @@ import org.opencdmp.commons.types.description.FieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.ReferenceEntity; import org.opencdmp.data.StorageFileEntity; -import org.opencdmp.model.reference.Reference; import org.opencdmp.model.StorageFile; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; import org.opencdmp.model.builder.commonmodels.reference.ReferenceCommonModelBuilder; import org.opencdmp.model.persist.StorageFilePersist; +import org.opencdmp.model.reference.Reference; import org.opencdmp.query.ReferenceQuery; import org.opencdmp.query.StorageFileQuery; import org.opencdmp.service.storage.StorageFileProperties; @@ -105,7 +105,7 @@ public class FieldCommonModelBuilder extends BaseCommonModelBuilder itemMap; - ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().filter(x-> x.getTextListValue() != null).map(FieldEntity::getTextListValue).flatMap(List::stream).filter(x-> !this.conventionService.isNullOrEmpty(x)).map(UUID::fromString).distinct().collect(Collectors.toList())); + ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().filter(x-> x.getTextListValue() != null).map(FieldEntity::getTextListValue).flatMap(List::stream).filter(x-> !this.conventionService.isNullOrEmpty(x)).map(UUID::fromString).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(ReferenceCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, ReferenceEntity::getId); return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/DescriptionTemplateCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/DescriptionTemplateCommonModelBuilder.java index 37ac940df..6180fca3b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/DescriptionTemplateCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/DescriptionTemplateCommonModelBuilder.java @@ -1,5 +1,9 @@ package org.opencdmp.model.builder.commonmodels.descriptiontemplate; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.DescriptionTemplateTypeModel; import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel; @@ -12,10 +16,6 @@ import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; import org.opencdmp.model.builder.commonmodels.DescriptionTemplateTypeCommonModelBuilder; import org.opencdmp.query.DescriptionTemplateTypeQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -26,7 +26,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DescriptionTemplateCommonModelBuilder extends BaseCommonModelBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -88,7 +88,7 @@ public class DescriptionTemplateCommonModelBuilder extends BaseCommonModelBuilde this.logger.debug("checking related - {}", DescriptionTemplateTypeModel.class.getSimpleName()); Map itemMap; - DescriptionTemplateTypeQuery q = this.queryFactory.query(DescriptionTemplateTypeQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionTemplateEntity::getTypeId).distinct().collect(Collectors.toList())); + DescriptionTemplateTypeQuery q = this.queryFactory.query(DescriptionTemplateTypeQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionTemplateEntity::getTypeId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionTemplateTypeCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, DescriptionTemplateTypeEntity::getId); return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/fielddata/ReferenceTypeDataCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/fielddata/ReferenceTypeDataCommonModelBuilder.java index 88d251471..5b0340613 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/fielddata/ReferenceTypeDataCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/descriptiontemplate/fielddata/ReferenceTypeDataCommonModelBuilder.java @@ -36,7 +36,7 @@ public class ReferenceTypeDataCommonModelBuilder extends BaseFieldDataCommonMode @Override protected void buildChild(ReferenceTypeDataEntity d, ReferenceTypeDataModel m) { m.setMultipleSelect(d.getMultipleSelect()); - if (d.getReferenceTypeId() != null) m.setReferenceType(this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).build(this.queryFactory.query(ReferenceTypeQuery.class).ids(d.getReferenceTypeId()).first())); //TODO: Optimize + if (d.getReferenceTypeId() != null) m.setReferenceType(this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).build(this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(d.getReferenceTypeId()).first())); //TODO: Optimize } } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpCommonModelBuilder.java index c719e1562..66f647a7c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpCommonModelBuilder.java @@ -1,5 +1,11 @@ package org.opencdmp.model.builder.commonmodels.dmp; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.Ordering; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.enums.DmpAccessType; import org.opencdmp.commonmodels.enums.DmpStatus; @@ -16,7 +22,8 @@ import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.types.dmp.DmpPropertiesEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.*; -import org.opencdmp.model.*; +import org.opencdmp.model.DmpUser; +import org.opencdmp.model.EntityDoi; import org.opencdmp.model.builder.commonmodels.*; import org.opencdmp.model.builder.commonmodels.description.DescriptionCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.dmpblueprint.DmpBlueprintCommonModelBuilder; @@ -25,12 +32,6 @@ import org.opencdmp.model.description.Description; import org.opencdmp.model.dmp.Dmp; import org.opencdmp.model.dmpreference.DmpReference; import org.opencdmp.query.*; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.Ordering; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -41,7 +42,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpCommonModelBuilder extends BaseCommonModelBuilder { private final QueryFactory queryFactory; @@ -156,15 +157,15 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder dmpIds = dmpQuery.groupIds(dmpGroup).excludedIds(currentDmpId).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).toList(); //GK: Step two get it's doiEntity - List dois = this.queryFactory.query(EntityDoiQuery.class).repositoryIds(repositoryId).entityIds(dmpIds).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(EntityDoi._entityId, EntityDoi._doi)); + List dois = this.queryFactory.query(EntityDoiQuery.class).disableTracking().repositoryIds(this.repositoryId).entityIds(dmpIds).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(EntityDoi._entityId, EntityDoi._doi)); for(UUID uuid: dmpIds) { EntityDoiEntity doiEntity = dois.stream().filter(x -> x.getEntityId().equals(uuid)).findFirst().orElse(null); if (doiEntity != null) return doiEntity.getDoi(); @@ -176,7 +177,7 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder> itemMap; - DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpUserCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId); return itemMap; @@ -186,7 +187,7 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder> itemMap; - DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpReferenceCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, DmpReferenceEntity::getDmpId); return itemMap; @@ -197,8 +198,8 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder> itemMap; - DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(DescriptionCommonModelBuilder.class).setRepositoryId(repositoryId).useSharedStorage(useSharedStorage).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(DescriptionCommonModelBuilder.class).setRepositoryId(this.repositoryId).useSharedStorage(this.useSharedStorage).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId); return itemMap; } @@ -208,7 +209,7 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder> itemMap; - EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).isActive(IsActive.Active).authorize(this.authorize).entityIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).disableTracking().isActive(IsActive.Active).authorize(this.authorize).entityIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(EntityDoiCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, EntityDoiEntity::getEntityId); return itemMap; @@ -220,7 +221,7 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder itemMap; - UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getCreatorId() != null).map(DmpEntity::getCreatorId).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().disableTracking().isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getCreatorId() != null).map(DmpEntity::getCreatorId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId); return itemMap; } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpContactCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpContactCommonModelBuilder.java index 05b387a2a..dfc0b2e5a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpContactCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpContactCommonModelBuilder.java @@ -1,5 +1,9 @@ package org.opencdmp.model.builder.commonmodels.dmp; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.UserModel; import org.opencdmp.commonmodels.models.dmp.DmpContactModel; @@ -11,10 +15,6 @@ import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; import org.opencdmp.model.builder.commonmodels.UserCommonModelBuilder; import org.opencdmp.query.UserQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -25,7 +25,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpContactCommonModelBuilder extends BaseCommonModelBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -72,7 +72,7 @@ public class DmpContactCommonModelBuilder extends BaseCommonModelBuilder itemMap; - UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getUserId() != null).map(DmpContactEntity::getUserId).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getUserId() != null).map(DmpContactEntity::getUserId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserCommonModelBuilder.class).disableContacts(true).authorize(this.authorize).asForeignKey(q, UserEntity::getId); return itemMap; } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/ReferenceTypeFieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/ReferenceTypeFieldCommonModelBuilder.java index a136caac5..588f0a127 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/ReferenceTypeFieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/ReferenceTypeFieldCommonModelBuilder.java @@ -1,19 +1,19 @@ package org.opencdmp.model.builder.commonmodels.dmpblueprint; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; import org.opencdmp.commonmodels.models.dmpblueprint.ReferenceTypeFieldModel; import org.opencdmp.commons.types.dmpblueprint.ReferenceTypeFieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.ReferenceTypeCommonModelBuilder; import org.opencdmp.query.ReferenceTypeQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ReferenceTypeFieldCommonModelBuilder extends FieldCommonModelBuilder { private final QueryFactory queryFactory; private final BuilderFactory builderFactory; @@ -30,7 +30,7 @@ public class ReferenceTypeFieldCommonModelBuilder extends FieldCommonModelBuilde } protected ReferenceTypeFieldModel buildChild(ReferenceTypeFieldEntity data, ReferenceTypeFieldModel model) { - if (data.getReferenceTypeId() != null ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).build(this.queryFactory.query(ReferenceTypeQuery.class).ids(data.getReferenceTypeId()).first())); //TODO: Optimize + if (data.getReferenceTypeId() != null ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).build(this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceTypeId()).first())); //TODO: Optimize model.setMultipleSelect(data.getMultipleSelect()); return model; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpreference/DmpReferenceCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpreference/DmpReferenceCommonModelBuilder.java index cc31c57f0..c79ae4042 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpreference/DmpReferenceCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpreference/DmpReferenceCommonModelBuilder.java @@ -1,5 +1,9 @@ package org.opencdmp.model.builder.commonmodels.dmpreference; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel; import org.opencdmp.commonmodels.models.reference.ReferenceModel; @@ -12,10 +16,6 @@ import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; import org.opencdmp.model.builder.commonmodels.reference.ReferenceCommonModelBuilder; import org.opencdmp.query.ReferenceQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -26,7 +26,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpReferenceCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; @@ -78,7 +78,7 @@ public class DmpReferenceCommonModelBuilder extends BaseCommonModelBuilder itemMap; - ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); + ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(ReferenceCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, ReferenceEntity::getId); return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/reference/ReferenceCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/reference/ReferenceCommonModelBuilder.java index 09035027b..74ef14afc 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/reference/ReferenceCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/reference/ReferenceCommonModelBuilder.java @@ -1,5 +1,9 @@ package org.opencdmp.model.builder.commonmodels.reference; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.enums.ReferenceSourceType; import org.opencdmp.commonmodels.models.reference.ReferenceModel; @@ -7,16 +11,12 @@ import org.opencdmp.commonmodels.models.reference.ReferenceTypeModel; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.types.reference.DefinitionEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.ReferenceTypeEntity; import org.opencdmp.data.ReferenceEntity; +import org.opencdmp.data.ReferenceTypeEntity; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; import org.opencdmp.model.builder.commonmodels.ReferenceTypeCommonModelBuilder; import org.opencdmp.query.ReferenceTypeQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -27,7 +27,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ReferenceCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; @@ -89,7 +89,7 @@ public class ReferenceCommonModelBuilder extends BaseCommonModelBuilder itemMap; - ReferenceTypeQuery q = this.queryFactory.query(ReferenceTypeQuery.class).authorize(this.authorize).ids(data.stream().map(ReferenceEntity::getTypeId).distinct().collect(Collectors.toList())); + ReferenceTypeQuery q = this.queryFactory.query(ReferenceTypeQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(ReferenceEntity::getTypeId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, ReferenceTypeEntity::getId); return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptionproperties/DescriptionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptionproperties/DescriptionBuilder.java index 3af1df6ea..01e02c67c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptionproperties/DescriptionBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptionproperties/DescriptionBuilder.java @@ -159,7 +159,7 @@ public class DescriptionBuilder extends BaseBuilder itemMap = new HashMap<>(); - DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); + DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())); List items = q.collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._definition)); for (DescriptionTemplateEntity item : items){ DefinitionEntity definition =this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, item.getDefinition()); @@ -265,7 +265,7 @@ public class DescriptionBuilder extends BaseBuilder> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DescriptionReference._description, Description._id)); - DescriptionReferenceQuery query = this.queryFactory.query(DescriptionReferenceQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList())); + DescriptionReferenceQuery query = this.queryFactory.query(DescriptionReferenceQuery.class).disableTracking().authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDescription().getId()); if (!fields.hasField(this.asIndexer(DescriptionReference._description, Description._id))) { @@ -302,7 +302,7 @@ public class DescriptionBuilder extends BaseBuilder> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DescriptionTag._description, Description._id)); - DescriptionTagQuery query = this.queryFactory.query(DescriptionTagQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList())); + DescriptionTagQuery query = this.queryFactory.query(DescriptionTagQuery.class).disableTracking().authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionTagBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDescription().getId()); if (!fields.hasField(this.asIndexer(DescriptionTag._description, Description._id))) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptionproperties/FieldBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptionproperties/FieldBuilder.java index 2529174f7..3fde0441f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptionproperties/FieldBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptionproperties/FieldBuilder.java @@ -127,7 +127,7 @@ public class FieldBuilder extends BaseBuilder { } } FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id); - ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(ids); + ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).disableTracking().authorize(this.authorize).ids(ids); itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptionreference/DescriptionReferenceBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptionreference/DescriptionReferenceBuilder.java index 0b306697c..b6ca46a2f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptionreference/DescriptionReferenceBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptionreference/DescriptionReferenceBuilder.java @@ -113,7 +113,7 @@ public class DescriptionReferenceBuilder extends BaseBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -131,11 +131,11 @@ public class DescriptionTemplateBuilder extends BaseBuilder x.getId()); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplateType._id); - DescriptionTemplateTypeQuery q = this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(data.stream().map(DescriptionTemplateEntity::getTypeId).distinct().collect(Collectors.toList())); + DescriptionTemplateTypeQuery q = this.queryFactory.query(DescriptionTemplateTypeQuery.class).disableTracking().ids(data.stream().map(DescriptionTemplateEntity::getTypeId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).asForeignKey(q, clone, DescriptionTemplateType::getId); } if (!fields.hasField(DescriptionTemplateType._id)) { - itemMap.values().stream().filter(x -> x != null).map(x -> { + itemMap.values().stream().filter(Objects::nonNull).map(x -> { x.setId(null); return x; }).collect(Collectors.toList()); @@ -151,7 +151,7 @@ public class DescriptionTemplateBuilder extends BaseBuilder> itemMap = null; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserDescriptionTemplate._descriptionTemplate, DescriptionTemplate._id)); - UserDescriptionTemplateQuery query = this.queryFactory.query(UserDescriptionTemplateQuery.class).authorize(this.authorize).descriptionTemplateIds(data.stream().map(DescriptionTemplateEntity::getId).distinct().collect(Collectors.toList())); + UserDescriptionTemplateQuery query = this.queryFactory.query(UserDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).descriptionTemplateIds(data.stream().map(DescriptionTemplateEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserDescriptionTemplateBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDescriptionTemplate().getId()); if (!fields.hasField(this.asIndexer(UserDescriptionTemplate._descriptionTemplate, DescriptionTemplate._id))) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/fielddata/ReferenceTypeDataBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/fielddata/ReferenceTypeDataBuilder.java index 2b9912103..a0d19b27b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/fielddata/ReferenceTypeDataBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/fielddata/ReferenceTypeDataBuilder.java @@ -37,6 +37,6 @@ public class ReferenceTypeDataBuilder extends BaseFieldDataBuilder { + @PersistenceContext + private EntityManager entityManager; private final QueryFactory queryFactory; private final BuilderFactory builderFactory; @@ -148,7 +152,7 @@ public class DmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, DmpReference._id)); - DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(DmpReference._dmp, Dmp._id))) { @@ -166,7 +170,7 @@ public class DmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(EntityDoi._entityId)); - EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).authorize(this.authorize).types(EntityType.DMP).entityIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(this.authorize).types(EntityType.DMP).entityIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(EntityDoiBuilder.class).authorize(this.authorize).asMasterKey(query, clone, EntityDoi::getEntityId); if (!fields.hasField(this.asIndexer(EntityDoi._entityId))) { @@ -195,7 +199,7 @@ public class DmpBuilder extends BaseBuilder { DmpBlueprint::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DmpBlueprint._id); - DmpBlueprintQuery q = this.queryFactory.query(DmpBlueprintQuery.class).authorize(this.authorize).ids(data.stream().map(DmpEntity::getBlueprintId).distinct().collect(Collectors.toList())); + DmpBlueprintQuery q = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DmpEntity::getBlueprintId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DmpBlueprint::getId); } if (!fields.hasField(DmpBlueprint._id)) { @@ -225,7 +229,7 @@ public class DmpBuilder extends BaseBuilder { User::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(DmpEntity::getCreatorId).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DmpEntity::getCreatorId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); } if (!fields.hasField(User._id)) { @@ -245,7 +249,7 @@ public class DmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpUser._dmp, DmpUser._id)); - DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).disableTracking().authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(DmpUser._dmp, Dmp._id))) { @@ -263,7 +267,7 @@ public class DmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Description._id)); - DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(Description._dmp, Dmp._id))) { @@ -281,7 +285,7 @@ public class DmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpDescriptionTemplate._dmp, DmpDescriptionTemplate._id)); - DmpDescriptionTemplateQuery query = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + DmpDescriptionTemplateQuery query = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpDescriptionTemplateBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(DmpDescriptionTemplate._dmp, Dmp._id))) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpContactBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpContactBuilder.java index 5dbe02f08..7c209e9c3 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpContactBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpContactBuilder.java @@ -88,7 +88,7 @@ public class DmpContactBuilder extends BaseBuilder DmpAssociatedUser::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().filter(x-> x.getUserId() != null).map(DmpContactEntity::getUserId).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().filter(x-> x.getUserId() != null).map(DmpContactEntity::getUserId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpAssociatedUserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DmpAssociatedUser::getId); } if (!fields.hasField(User._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ReferenceFieldBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ReferenceFieldBuilder.java index ea29ef29d..3703ced16 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ReferenceFieldBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ReferenceFieldBuilder.java @@ -37,7 +37,7 @@ public class ReferenceFieldBuilder extends FieldBuilder { m.getFields().addAll(this.builderFactory.builder(ReferenceFieldBuilder.class).authorize(this.authorize).build(fieldsFields, referenceFieldEntities)); } if (!prefillingSourcesFields.isEmpty() && d.getPrefillingSourcesIds() != null) { - List prefillingSourceEntities = this.queryFactory.query(PrefillingSourceQuery.class).authorize(this.authorize).ids(d.getPrefillingSourcesIds()).collectAs(prefillingSourcesFields); + List prefillingSourceEntities = this.queryFactory.query(PrefillingSourceQuery.class).disableTracking().authorize(this.authorize).ids(d.getPrefillingSourcesIds()).collectAs(prefillingSourcesFields); m.setPrefillingSources(this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(this.authorize).build(prefillingSourcesFields, prefillingSourceEntities)); } models.add(m); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java index 202a7c4fe..f44571662 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java @@ -110,7 +110,7 @@ public class DmpReferenceBuilder extends BaseBuilder x.getReferenceTypeDependencyIds() != null).map(ExternalFetcherBaseSourceConfigurationEntity::getReferenceTypeDependencyIds).flatMap(List::stream).distinct().collect(Collectors.toList())); + ReferenceTypeQuery q = this.queryFactory.query(ReferenceTypeQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().filter(x-> x.getReferenceTypeDependencyIds() != null).map(ExternalFetcherBaseSourceConfigurationEntity::getReferenceTypeDependencyIds).flatMap(List::stream).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(this.authorize).asForeignKey(q, clone, ReferenceType::getId); } if (!fields.hasField(ReferenceType._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/externalfetcher/QueryCaseConfigBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/externalfetcher/QueryCaseConfigBuilder.java index 2f8afe738..3229dd19b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/externalfetcher/QueryCaseConfigBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/externalfetcher/QueryCaseConfigBuilder.java @@ -87,7 +87,7 @@ public class QueryCaseConfigBuilder extends BaseBuilder x.getReferenceTypeId() != null).map(QueryCaseConfigEntity::getReferenceTypeId).distinct().collect(Collectors.toList())); + ReferenceTypeQuery q = this.queryFactory.query(ReferenceTypeQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().filter(x-> x.getReferenceTypeId() != null).map(QueryCaseConfigEntity::getReferenceTypeId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(this.authorize).asForeignKey(q, clone, ReferenceType::getId); } if (!fields.hasField(ReferenceType._id)) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/reference/ReferenceBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/reference/ReferenceBuilder.java index 4a1245d94..e625be10d 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/reference/ReferenceBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/reference/ReferenceBuilder.java @@ -123,7 +123,7 @@ public class ReferenceBuilder extends BaseBuilder { ReferenceType::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(ReferenceType._id); - ReferenceTypeQuery q = this.queryFactory.query(ReferenceTypeQuery.class).authorize(this.authorize).ids(data.stream().map(ReferenceEntity::getTypeId).distinct().collect(Collectors.toList())); + ReferenceTypeQuery q = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(ReferenceEntity::getTypeId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(this.authorize).asForeignKey(q, clone, ReferenceType::getId); } if (!fields.hasField(ReferenceType._id)) { @@ -153,7 +153,7 @@ public class ReferenceBuilder extends BaseBuilder { User::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(ReferenceEntity::getCreatedById).distinct().collect(Collectors.toList())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(ReferenceEntity::getCreatedById).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); } if (!fields.hasField(User._id)) { @@ -172,7 +172,7 @@ public class ReferenceBuilder extends BaseBuilder { Map> itemMap = null; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._reference, Reference._id)); - DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).referenceIds(data.stream().map(ReferenceEntity::getId).distinct().collect(Collectors.toList())); + DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().authorize(this.authorize).referenceIds(data.stream().map(ReferenceEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getReference().getId()); if (!fields.hasField(this.asIndexer(DmpReference._reference, Reference._id))) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/tenantconfiguration/LogoTenantConfigurationBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/tenantconfiguration/LogoTenantConfigurationBuilder.java index 2feca6dde..8df2cb7bc 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/tenantconfiguration/LogoTenantConfigurationBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/tenantconfiguration/LogoTenantConfigurationBuilder.java @@ -1,5 +1,12 @@ package org.opencdmp.model.builder.tenantconfiguration; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.types.tenantconfiguration.LogoTenantConfigurationEntity; import org.opencdmp.convention.ConventionService; @@ -8,13 +15,6 @@ import org.opencdmp.model.builder.BaseBuilder; import org.opencdmp.model.builder.StorageFileBuilder; import org.opencdmp.model.tenantconfiguration.LogoTenantConfiguration; import org.opencdmp.query.StorageFileQuery; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.logging.DataLogEntry; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -25,7 +25,7 @@ import java.util.*; import java.util.stream.Collectors; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class LogoTenantConfigurationBuilder extends BaseBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -84,7 +84,7 @@ public class LogoTenantConfigurationBuilder extends BaseBuilder getTags() { - return tags; + return this.tags; } public void setTags(List tags) { @@ -131,7 +131,7 @@ public class DescriptionPersist { } public String getHash() { - return hash; + return this.hash; } public void setHash(String hash) { @@ -139,7 +139,7 @@ public class DescriptionPersist { } public UUID getDescriptionTemplateId() { - return descriptionTemplateId; + return this.descriptionTemplateId; } public void setDescriptionTemplateId(UUID descriptionTemplateId) { @@ -193,37 +193,37 @@ public class DescriptionPersist { this.spec() .iff(() -> this.isValidGuid(item.getId())) .must(() -> this.isValidHash(item.getHash())) - .failOn(DescriptionPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._hash}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._hash}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isValidGuid(item.getId())) .must(() -> !this.isValidHash(item.getHash())) - .failOn(DescriptionPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._hash).failWith(this.messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(DescriptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getLabel())) .must(() -> this.lessEqualLength(item.getLabel(), DescriptionEntity._labelLength)) - .failOn(DescriptionPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getDmpId())) - .failOn(DescriptionPersist._dmpId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpId}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._dmpId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getDescriptionTemplateId())) - .failOn(DescriptionPersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._descriptionTemplateId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getDmpDescriptionTemplateId())) - .failOn(DescriptionPersist._dmpDescriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpDescriptionTemplateId}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._dmpDescriptionTemplateId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpDescriptionTemplateId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getStatus())) - .failOn(DescriptionPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._status}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._status).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._status}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> item.getStatus() == DescriptionStatus.Finalized) .must(() -> !this.isNull(item.getProperties())) - .failOn(DescriptionPersist._properties).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._properties}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._properties).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._properties}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isDescriptionTemplateMaxMultiplicityValid(finalDmpBlueprintEntity, item.getDmpId(), item.getDmpDescriptionTemplateId(), this.isValidGuid(item.getId()))) - .failOn(DescriptionPersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicity", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())), + .failOn(DescriptionPersist._descriptionTemplateId).failWith(this.messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicity", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> item.getStatus() == DescriptionStatus.Finalized) .on(DescriptionPersist._properties) @@ -241,10 +241,10 @@ public class DescriptionPersist { org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); if (definition == null || this.isListNullOrEmpty(definition.getSections())) return true; - DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(dmpDescriptionTemplateId).isActive(IsActive.Active).dmpIds(dmpId).first(); + DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(dmpDescriptionTemplateId).isActive(IsActive.Active).dmpIds(dmpId).first(); if (dmpDescriptionTemplateEntity == null) return true; - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(dmpId).dmpDescriptionTemplateIds(dmpDescriptionTemplateId).isActive(IsActive.Active).collect(); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(dmpId).dmpDescriptionTemplateIds(dmpDescriptionTemplateId).isActive(IsActive.Active).collect(); for (SectionEntity section: definition.getSections()) { if (dmpDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java index 9e0707482..9aa4b4381 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java @@ -1,5 +1,8 @@ package org.opencdmp.model.persist; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.validation.ValidatorFactory; +import gr.cite.tools.validation.specification.Specification; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.enums.*; @@ -8,15 +11,12 @@ import org.opencdmp.commons.types.dmpblueprint.FieldEntity; import org.opencdmp.commons.types.dmpblueprint.SectionEntity; import org.opencdmp.commons.types.dmpblueprint.SystemFieldEntity; import org.opencdmp.commons.validation.BaseValidator; -import org.opencdmp.data.*; -import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.validation.ValidatorFactory; -import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.*; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.model.persist.dmpproperties.DmpPropertiesPersist; +import org.opencdmp.query.DescriptionQuery; +import org.opencdmp.query.DmpDescriptionTemplateQuery; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -274,8 +274,8 @@ public class DmpPersist { org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); if (definition == null || this.isListNullOrEmpty(definition.getSections())) return true; - List dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).dmpIds(dmpId).collect(); - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(dmpId).isActive(IsActive.Active).collect(); + List dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).dmpIds(dmpId).collect(); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(dmpId).isActive(IsActive.Active).collect(); for (SectionEntity section: definition.getSections()) { if (section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpBlueprintValuePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpBlueprintValuePersist.java index c94b4d633..ce242958d 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpBlueprintValuePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpBlueprintValuePersist.java @@ -1,20 +1,20 @@ package org.opencdmp.model.persist.dmpproperties; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.validation.ValidatorFactory; +import gr.cite.tools.validation.specification.Specification; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; import org.opencdmp.commons.types.dmpblueprint.FieldEntity; import org.opencdmp.commons.types.dmpblueprint.ReferenceTypeFieldEntity; import org.opencdmp.commons.validation.BaseValidator; -import org.opencdmp.model.referencetype.ReferenceType; -import org.opencdmp.query.ReferenceTypeQuery; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.validation.ValidatorFactory; -import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.model.persist.ReferencePersist; +import org.opencdmp.model.referencetype.ReferenceType; +import org.opencdmp.query.ReferenceTypeQuery; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -138,7 +138,7 @@ public class DmpBlueprintValuePersist { private String getReferenceTypeName(FieldEntity fieldEntity){ if (fieldEntity instanceof ReferenceTypeFieldEntity) { - return this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(((ReferenceTypeFieldEntity)fieldEntity).getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._name)).getName(); + return this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(((ReferenceTypeFieldEntity)fieldEntity).getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._name)).getName(); } return ""; } diff --git a/backend/core/src/main/java/org/opencdmp/query/ActionConfirmationQuery.java b/backend/core/src/main/java/org/opencdmp/query/ActionConfirmationQuery.java index 05687acae..bdff573af 100644 --- a/backend/core/src/main/java/org/opencdmp/query/ActionConfirmationQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/ActionConfirmationQuery.java @@ -1,5 +1,11 @@ package org.opencdmp.query; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.data.query.QueryBase; +import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.enums.ActionConfirmationStatus; import org.opencdmp.commons.enums.ActionConfirmationType; @@ -7,12 +13,6 @@ import org.opencdmp.commons.enums.IsActive; import org.opencdmp.data.ActionConfirmationEntity; import org.opencdmp.model.actionconfirmation.ActionConfirmation; import org.opencdmp.query.utils.QueryUtilsService; -import gr.cite.tools.data.query.FieldResolver; -import gr.cite.tools.data.query.QueryBase; -import gr.cite.tools.data.query.QueryContext; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -21,7 +21,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ActionConfirmationQuery extends QueryBase { private String like; @@ -158,6 +158,16 @@ public class ActionConfirmationQuery extends QueryBase return this; } + public ActionConfirmationQuery enableTracking() { + this.noTracking = false; + return this; + } + + public ActionConfirmationQuery disableTracking() { + this.noTracking = false; + return this; + } + public ActionConfirmationQuery authorize(EnumSet values) { this.authorize = values; @@ -185,7 +195,7 @@ public class ActionConfirmationQuery extends QueryBase protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ActionConfirmationEntity._token), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ActionConfirmationEntity._token), this.like)); } if (this.ids != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ActionConfirmationEntity._id)); diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java index c75b150b9..76dac5db4 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java @@ -1,5 +1,12 @@ package org.opencdmp.query; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.data.query.QueryBase; +import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.DescriptionStatus; @@ -8,16 +15,9 @@ import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.data.DescriptionEntity; import org.opencdmp.data.DmpDescriptionTemplateEntity; import org.opencdmp.data.DmpEntity; -import org.opencdmp.model.description.Description; import org.opencdmp.model.PublicDescription; +import org.opencdmp.model.description.Description; import org.opencdmp.query.utils.QueryUtilsService; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.query.FieldResolver; -import gr.cite.tools.data.query.QueryBase; -import gr.cite.tools.data.query.QueryContext; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -26,7 +26,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DescriptionQuery extends QueryBase { private String like; @@ -211,6 +211,16 @@ public class DescriptionQuery extends QueryBase { return this; } + public DescriptionQuery enableTracking() { + this.noTracking = false; + return this; + } + + public DescriptionQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Boolean isFalseQuery() { return @@ -240,7 +250,7 @@ public class DescriptionQuery extends QueryBase { List predicates = new ArrayList<>(); if (userId != null || usePublic) { - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id)).value(queryUtilsService.buildDescriptionAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id)).value(this.queryUtilsService.buildDescriptionAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); @@ -255,8 +265,8 @@ public class DescriptionQuery extends QueryBase { List predicates = new ArrayList<>(); if (this.like != null && !this.like.isEmpty()) { predicates.add(queryContext.CriteriaBuilder.or( - queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._description), this.like), - queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._label), this.like) + this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._description), this.like), + this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._label), this.like) )); } if (this.ids != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionReferenceQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionReferenceQuery.java index 2ec223b28..600ca21b8 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionReferenceQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionReferenceQuery.java @@ -1,12 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.DescriptionReferenceEntity; -import org.opencdmp.model.descriptionreference.DescriptionReference; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -14,6 +7,13 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.DescriptionReferenceEntity; +import org.opencdmp.model.descriptionreference.DescriptionReference; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -22,7 +22,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DescriptionReferenceQuery extends QueryBase { private Collection ids; @@ -126,6 +126,16 @@ public class DescriptionReferenceQuery extends QueryBase predicates = new ArrayList<>(); if (userId != null || usePublic ) { - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._descriptionId)).value(queryUtilsService.buildDescriptionAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._descriptionId)).value(this.queryUtilsService.buildDescriptionAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionTagQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionTagQuery.java index b03592831..f8181775a 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionTagQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionTagQuery.java @@ -1,23 +1,16 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.DescriptionEntity; -import org.opencdmp.data.DescriptionTagEntity; -import org.opencdmp.data.DmpDescriptionTemplateEntity; -import org.opencdmp.model.DescriptionTag; -import org.opencdmp.query.utils.BuildSubQueryInput; -import org.opencdmp.query.utils.QueryUtilsService; -import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; -import jakarta.persistence.criteria.Subquery; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.data.DescriptionEntity; +import org.opencdmp.data.DescriptionTagEntity; +import org.opencdmp.model.DescriptionTag; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -26,7 +19,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DescriptionTagQuery extends QueryBase { private Collection ids; @@ -121,16 +114,19 @@ public class DescriptionTagQuery extends QueryBase { this.authorize = values; return this; } + + public DescriptionTagQuery enableTracking() { + this.noTracking = false; + return this; + } + + public DescriptionTagQuery disableTracking() { + this.noTracking = false; + return this; + } - private final UserScope userScope; - private final AuthorizationService authService; - private final QueryUtilsService queryUtilsService; - public DescriptionTagQuery( - UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService) { - this.userScope = userScope; - this.authService = authService; - this.queryUtilsService = queryUtilsService; + public DescriptionTagQuery() { } @Override diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java index 40a51295a..f8359d3cd 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java @@ -1,5 +1,13 @@ package org.opencdmp.query; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.data.query.QueryBase; +import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Subquery; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.DescriptionTemplateStatus; @@ -12,14 +20,6 @@ import org.opencdmp.data.DmpEntity; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; import org.opencdmp.query.utils.BuildSubQueryInput; import org.opencdmp.query.utils.QueryUtilsService; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.query.FieldResolver; -import gr.cite.tools.data.query.QueryBase; -import gr.cite.tools.data.query.QueryContext; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; -import jakarta.persistence.criteria.Subquery; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -28,7 +28,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DescriptionTemplateQuery extends QueryBase { private String like; @@ -212,6 +212,16 @@ public class DescriptionTemplateQuery extends QueryBase predicates = new ArrayList<>(); if (userId != null || usePublic) { - Subquery dmpDescriptionTemplateSubquery = queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( + Subquery dmpDescriptionTemplateSubquery = this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( new BuildSubQueryInput.Builder<>(DmpDescriptionTemplateEntity.class, UUID.class, queryContext) .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)) .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DmpDescriptionTemplateEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) + cb.in(subQueryRoot.get(DmpDescriptionTemplateEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) ) )); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._groupId)).value(dmpDescriptionTemplateSubquery)); @@ -289,8 +299,8 @@ public class DescriptionTemplateQuery extends QueryBase { private String like; @@ -105,6 +105,16 @@ public class DescriptionTemplateTypeQuery extends QueryBase inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._isActive)); diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpBlueprintQuery.java b/backend/core/src/main/java/org/opencdmp/query/DmpBlueprintQuery.java index 33ae54db7..290f82f7b 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpBlueprintQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DmpBlueprintQuery.java @@ -1,12 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.DmpBlueprintStatus; -import org.opencdmp.commons.enums.DmpBlueprintVersionStatus; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.DmpBlueprintEntity; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -14,6 +7,13 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.DmpBlueprintStatus; +import org.opencdmp.commons.enums.DmpBlueprintVersionStatus; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.model.dmpblueprint.DmpBlueprint; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -22,7 +22,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpBlueprintQuery extends QueryBase { private String like; @@ -158,6 +158,16 @@ public class DmpBlueprintQuery extends QueryBase { return this; } + public DmpBlueprintQuery enableTracking() { + this.noTracking = false; + return this; + } + + public DmpBlueprintQuery disableTracking() { + this.noTracking = false; + return this; + } + private final QueryUtilsService queryUtilsService; public DmpBlueprintQuery( AuthorizationService authService, QueryUtilsService queryUtilsService @@ -194,7 +204,7 @@ public class DmpBlueprintQuery extends QueryBase { } if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpBlueprintEntity._label), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpBlueprintEntity._label), this.like)); } if (this.isActives != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpDescriptionTemplateQuery.java b/backend/core/src/main/java/org/opencdmp/query/DmpDescriptionTemplateQuery.java index 9e3b2a1fe..b557b8423 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpDescriptionTemplateQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DmpDescriptionTemplateQuery.java @@ -1,15 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.DescriptionTemplateEntity; -import org.opencdmp.data.DmpDescriptionTemplateEntity; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.model.DmpDescriptionTemplate; -import org.opencdmp.model.PublicDmpDescriptionTemplate; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -17,6 +7,15 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.DescriptionTemplateEntity; +import org.opencdmp.data.DmpDescriptionTemplateEntity; +import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.model.PublicDmpDescriptionTemplate; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -25,7 +24,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpDescriptionTemplateQuery extends QueryBase { private Collection ids; @@ -151,6 +150,16 @@ public class DmpDescriptionTemplateQuery extends QueryBase predicates = new ArrayList<>(); if (userId != null || usePublic) { - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java b/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java index ab3805b59..e7388f0a7 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java @@ -1,13 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.*; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.*; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.PublicDmp; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -15,6 +7,14 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.*; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.*; +import org.opencdmp.model.PublicDmp; +import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -23,7 +23,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpQuery extends QueryBase { private String like; @@ -241,6 +241,16 @@ public class DmpQuery extends QueryBase { return this; } + public DmpQuery enableTracking() { + this.noTracking = false; + return this; + } + + public DmpQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Boolean isFalseQuery() { return this.isEmpty(this.ids) || this.isEmpty(this.creatorIds) || this.isEmpty(this.isActives) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes) || this.isEmpty(this.statuses) || this.isFalseQuery(this.dmpDescriptionTemplateQuery) || this.isFalseQuery(this.dmpUserQuery); @@ -285,7 +295,7 @@ public class DmpQuery extends QueryBase { protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpEntity._label), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpEntity._label), this.like)); } if (this.ids != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)); diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpReferenceQuery.java b/backend/core/src/main/java/org/opencdmp/query/DmpReferenceQuery.java index 7d613d963..cfe0add0f 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpReferenceQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DmpReferenceQuery.java @@ -1,15 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.data.DmpReferenceEntity; -import org.opencdmp.data.ReferenceEntity; -import org.opencdmp.model.dmpreference.DmpReference; -import org.opencdmp.model.PublicDmpReference; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -17,6 +7,16 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.DmpReferenceEntity; +import org.opencdmp.data.ReferenceEntity; +import org.opencdmp.model.PublicDmpReference; +import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -25,7 +25,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpReferenceQuery extends QueryBase { private Collection ids; @@ -116,6 +116,16 @@ public class DmpReferenceQuery extends QueryBase { return this; } + public DmpReferenceQuery enableTracking() { + this.noTracking = false; + return this; + } + + public DmpReferenceQuery disableTracking() { + this.noTracking = false; + return this; + } + private final UserScope userScope; private final AuthorizationService authService; @@ -151,7 +161,7 @@ public class DmpReferenceQuery extends QueryBase { List predicates = new ArrayList<>(); if (userId != null || usePublic ) { - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpUserQuery.java b/backend/core/src/main/java/org/opencdmp/query/DmpUserQuery.java index bb858b1f9..cc49de8cf 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpUserQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DmpUserQuery.java @@ -1,15 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.DmpUserRole; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.*; -import org.opencdmp.model.DmpUser; -import org.opencdmp.model.PublicDmpUser; -import org.opencdmp.query.utils.BuildSubQueryInput; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -18,6 +8,17 @@ import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; import jakarta.persistence.criteria.Subquery; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.DescriptionEntity; +import org.opencdmp.data.DmpUserEntity; +import org.opencdmp.model.DmpUser; +import org.opencdmp.model.PublicDmpUser; +import org.opencdmp.query.utils.BuildSubQueryInput; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -26,7 +27,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DmpUserQuery extends QueryBase { private Collection ids; @@ -161,6 +162,16 @@ public class DmpUserQuery extends QueryBase { return this; } + public DmpUserQuery enableTracking() { + this.noTracking = false; + return this; + } + + public DmpUserQuery disableTracking() { + this.noTracking = false; + return this; + } + private final UserScope userScope; private final AuthorizationService authService; @@ -197,8 +208,8 @@ public class DmpUserQuery extends QueryBase { List predicates = new ArrayList<>(); if (userId != null || usePublic ) { predicates.add(queryContext.CriteriaBuilder.or( - usePublic ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(queryUtilsService.buildPublicDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, usePublic)) : queryContext.CriteriaBuilder.or(), //Creates a false query - userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(queryUtilsService.buildDmpUserAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId)) : queryContext.CriteriaBuilder.or() //Creates a false query + usePublic ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(this.queryUtilsService.buildPublicDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, usePublic)) : queryContext.CriteriaBuilder.or(), //Creates a false query + userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(this.queryUtilsService.buildDmpUserAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId)) : queryContext.CriteriaBuilder.or() //Creates a false query )); } if (!predicates.isEmpty()) { @@ -235,7 +246,7 @@ public class DmpUserQuery extends QueryBase { else predicates.add(queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(DmpUserEntity._sectionId))); } if (this.descriptionIds != null) { - Subquery descriptionSubquery = queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( + Subquery descriptionSubquery = this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( new BuildSubQueryInput.Builder<>(DescriptionEntity.class, UUID.class, queryContext) .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DescriptionEntity._dmpId)) .filterFunc((subQueryRoot, cb) -> { diff --git a/backend/core/src/main/java/org/opencdmp/query/EntityDoiQuery.java b/backend/core/src/main/java/org/opencdmp/query/EntityDoiQuery.java index c43b120ed..1d02cd234 100644 --- a/backend/core/src/main/java/org/opencdmp/query/EntityDoiQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/EntityDoiQuery.java @@ -1,5 +1,12 @@ package org.opencdmp.query; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.data.query.QueryBase; +import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.EntityType; @@ -9,13 +16,6 @@ import org.opencdmp.data.DmpEntity; import org.opencdmp.data.EntityDoiEntity; import org.opencdmp.model.EntityDoi; import org.opencdmp.query.utils.QueryUtilsService; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.query.FieldResolver; -import gr.cite.tools.data.query.QueryBase; -import gr.cite.tools.data.query.QueryContext; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -24,7 +24,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class EntityDoiQuery extends QueryBase { private Collection ids; @@ -160,6 +160,16 @@ public class EntityDoiQuery extends QueryBase { return this; } + public EntityDoiQuery enableTracking() { + this.noTracking = false; + return this; + } + + public EntityDoiQuery disableTracking() { + this.noTracking = false; + return this; + } + private final UserScope userScope; private final AuthorizationService authService; @@ -198,7 +208,7 @@ public class EntityDoiQuery extends QueryBase { List predicates = new ArrayList<>(); boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); if (userId != null || usePublic) { - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._entityId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._entityId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); diff --git a/backend/core/src/main/java/org/opencdmp/query/LanguageQuery.java b/backend/core/src/main/java/org/opencdmp/query/LanguageQuery.java index 3bd46ed2e..686168a06 100644 --- a/backend/core/src/main/java/org/opencdmp/query/LanguageQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/LanguageQuery.java @@ -1,16 +1,16 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.LanguageEntity; -import org.opencdmp.model.Language; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.data.LanguageEntity; +import org.opencdmp.model.Language; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -19,7 +19,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class LanguageQuery extends QueryBase { private String like; @@ -104,6 +104,16 @@ public class LanguageQuery extends QueryBase { return this; } + public LanguageQuery enableTracking() { + this.noTracking = false; + return this; + } + + public LanguageQuery disableTracking() { + this.noTracking = false; + return this; + } + private final QueryUtilsService queryUtilsService; public LanguageQuery( QueryUtilsService queryUtilsService) { @@ -130,7 +140,7 @@ public class LanguageQuery extends QueryBase { predicates.add(inClause); } if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(LanguageEntity._code), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(LanguageEntity._code), this.like)); } if (this.isActives != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LanguageEntity._isActive)); diff --git a/backend/core/src/main/java/org/opencdmp/query/LockQuery.java b/backend/core/src/main/java/org/opencdmp/query/LockQuery.java index e1c8cc1eb..e493137a5 100644 --- a/backend/core/src/main/java/org/opencdmp/query/LockQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/LockQuery.java @@ -1,16 +1,16 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.LockTargetType; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.LockEntity; -import org.opencdmp.model.Lock; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.LockTargetType; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.LockEntity; +import org.opencdmp.model.Lock; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -19,7 +19,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class LockQuery extends QueryBase { private String like; @@ -36,7 +36,7 @@ public class LockQuery extends QueryBase { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - private ConventionService conventionService; + private final ConventionService conventionService; public LockQuery like(String value) { this.like = value; @@ -138,6 +138,16 @@ public class LockQuery extends QueryBase { return this; } + public LockQuery enableTracking() { + this.noTracking = false; + return this; + } + + public LockQuery disableTracking() { + this.noTracking = false; + return this; + } + public LockQuery(ConventionService conventionService) { this.conventionService = conventionService; } @@ -157,7 +167,7 @@ public class LockQuery extends QueryBase { List predicates = new ArrayList<>(); if (this.like != null && !this.like.isEmpty()) { this.like = this.like.replaceAll("%", ""); - if (this.conventionService.isValidUUID(like)){ + if (this.conventionService.isValidUUID(this.like)){ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LockEntity._id)); inClause.value(UUID.fromString(this.like)); predicates.add(inClause); diff --git a/backend/core/src/main/java/org/opencdmp/query/PrefillingSourceQuery.java b/backend/core/src/main/java/org/opencdmp/query/PrefillingSourceQuery.java index 6ed274aa9..1f49ce540 100644 --- a/backend/core/src/main/java/org/opencdmp/query/PrefillingSourceQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PrefillingSourceQuery.java @@ -1,16 +1,16 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.PrefillingSourceEntity; -import org.opencdmp.model.prefillingsource.PrefillingSource; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.data.PrefillingSourceEntity; +import org.opencdmp.model.prefillingsource.PrefillingSource; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -19,7 +19,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class PrefillingSourceQuery extends QueryBase { private String like; @@ -87,6 +87,16 @@ public class PrefillingSourceQuery extends QueryBase { return this; } + public PrefillingSourceQuery enableTracking() { + this.noTracking = false; + return this; + } + + public PrefillingSourceQuery disableTracking() { + this.noTracking = false; + return this; + } + private final QueryUtilsService queryUtilsService; public PrefillingSourceQuery( @@ -114,7 +124,7 @@ public class PrefillingSourceQuery extends QueryBase { predicates.add(inClause); } if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PrefillingSourceEntity._label), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PrefillingSourceEntity._label), this.like)); } if (this.isActives != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PrefillingSourceEntity._isActive)); diff --git a/backend/core/src/main/java/org/opencdmp/query/QueueInboxQuery.java b/backend/core/src/main/java/org/opencdmp/query/QueueInboxQuery.java index 765d16856..06392b4e7 100644 --- a/backend/core/src/main/java/org/opencdmp/query/QueueInboxQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/QueueInboxQuery.java @@ -1,8 +1,6 @@ package org.opencdmp.query; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.QueueInboxEntity; import gr.cite.queueinbox.entity.QueueInboxStatus; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.Ordering; @@ -11,6 +9,8 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.data.QueueInboxEntity; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -19,7 +19,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class QueueInboxQuery extends QueryBase { private Collection ids; @@ -120,6 +120,16 @@ public class QueueInboxQuery extends QueryBase { return this; } + public QueueInboxQuery enableTracking() { + this.noTracking = false; + return this; + } + + public QueueInboxQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Class entityClass() { return QueueInboxEntity.class; diff --git a/backend/core/src/main/java/org/opencdmp/query/QueueOutboxQuery.java b/backend/core/src/main/java/org/opencdmp/query/QueueOutboxQuery.java index e34e1bf2f..2da172406 100644 --- a/backend/core/src/main/java/org/opencdmp/query/QueueOutboxQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/QueueOutboxQuery.java @@ -1,25 +1,25 @@ package org.opencdmp.query; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.QueueOutboxEntity; import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.Ordering; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.data.QueueOutboxEntity; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class QueueOutboxQuery extends QueryBase { private Collection ids; @@ -126,6 +126,16 @@ public class QueueOutboxQuery extends QueryBase { return this; } + public QueueOutboxQuery enableTracking() { + this.noTracking = false; + return this; + } + + public QueueOutboxQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Class entityClass() { return QueueOutboxEntity.class; diff --git a/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java b/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java index e686affe7..457e2990c 100644 --- a/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java @@ -178,6 +178,16 @@ public class ReferenceQuery extends QueryBase { return this; } + public ReferenceQuery enableTracking() { + this.noTracking = false; + return this; + } + + public ReferenceQuery disableTracking() { + this.noTracking = false; + return this; + } + private final UserScope userScope; private final AuthorizationService authService; diff --git a/backend/core/src/main/java/org/opencdmp/query/ReferenceTypeQuery.java b/backend/core/src/main/java/org/opencdmp/query/ReferenceTypeQuery.java index 17fcdedc7..4a7f96e2b 100644 --- a/backend/core/src/main/java/org/opencdmp/query/ReferenceTypeQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/ReferenceTypeQuery.java @@ -1,17 +1,17 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.ReferenceEntity; -import org.opencdmp.data.ReferenceTypeEntity; -import org.opencdmp.model.referencetype.ReferenceType; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.data.ReferenceEntity; +import org.opencdmp.data.ReferenceTypeEntity; +import org.opencdmp.model.referencetype.ReferenceType; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -20,7 +20,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ReferenceTypeQuery extends QueryBase { private String like; @@ -105,6 +105,16 @@ public class ReferenceTypeQuery extends QueryBase { return this; } + public ReferenceTypeQuery enableTracking() { + this.noTracking = false; + return this; + } + + public ReferenceTypeQuery disableTracking() { + this.noTracking = false; + return this; + } + private final QueryUtilsService queryUtilsService; public ReferenceTypeQuery( @@ -132,8 +142,8 @@ public class ReferenceTypeQuery extends QueryBase { predicates.add(inClause); } if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._code), this.like), - queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._name), this.like) + predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._code), this.like), + this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._name), this.like) )); } if (this.isActives != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/StorageFileQuery.java b/backend/core/src/main/java/org/opencdmp/query/StorageFileQuery.java index 1d843338f..39710ab48 100644 --- a/backend/core/src/main/java/org/opencdmp/query/StorageFileQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/StorageFileQuery.java @@ -1,12 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.StorageType; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.StorageFileEntity; -import org.opencdmp.model.StorageFile; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -14,6 +7,13 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.StorageType; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.StorageFileEntity; +import org.opencdmp.model.StorageFile; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -22,7 +22,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class StorageFileQuery extends QueryBase { private String like; private Collection ids; @@ -112,6 +112,16 @@ public class StorageFileQuery extends QueryBase { return this; } + public StorageFileQuery enableTracking() { + this.noTracking = false; + return this; + } + + public StorageFileQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Boolean isFalseQuery() { return @@ -149,7 +159,7 @@ public class StorageFileQuery extends QueryBase { protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.like != null && !this.like.isEmpty()) { - predicates.add( queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(StorageFileEntity._name), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(StorageFileEntity._name), this.like)); } if (this.ids != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(StorageFileEntity._id)); diff --git a/backend/core/src/main/java/org/opencdmp/query/SupportiveMaterialQuery.java b/backend/core/src/main/java/org/opencdmp/query/SupportiveMaterialQuery.java index fb2f3aa0f..c42c2b05e 100644 --- a/backend/core/src/main/java/org/opencdmp/query/SupportiveMaterialQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/SupportiveMaterialQuery.java @@ -1,19 +1,17 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.enums.SupportiveMaterialFieldType; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.SupportiveMaterialEntity; -import org.opencdmp.model.SupportiveMaterial; -import org.opencdmp.query.utils.QueryUtilsService; -import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.enums.SupportiveMaterialFieldType; +import org.opencdmp.data.SupportiveMaterialEntity; +import org.opencdmp.model.SupportiveMaterial; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -22,7 +20,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class SupportiveMaterialQuery extends QueryBase { private String like; @@ -124,6 +122,16 @@ public class SupportiveMaterialQuery extends QueryBase return this; } + public SupportiveMaterialQuery enableTracking() { + this.noTracking = false; + return this; + } + + public SupportiveMaterialQuery disableTracking() { + this.noTracking = false; + return this; + } + private final QueryUtilsService queryUtilsService; public SupportiveMaterialQuery( QueryUtilsService queryUtilsService) { @@ -150,8 +158,8 @@ public class SupportiveMaterialQuery extends QueryBase predicates.add(inClause); } if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._languageCode), this.like), - queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._payload), this.like) + predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._languageCode), this.like), + this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._payload), this.like) )); } if (this.isActives != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/TagQuery.java b/backend/core/src/main/java/org/opencdmp/query/TagQuery.java index 0a247bc09..d7b05b684 100644 --- a/backend/core/src/main/java/org/opencdmp/query/TagQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/TagQuery.java @@ -1,16 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.DescriptionTagEntity; -import org.opencdmp.data.DmpReferenceEntity; -import org.opencdmp.data.ReferenceEntity; -import org.opencdmp.data.TagEntity; -import org.opencdmp.model.Tag; -import org.opencdmp.query.utils.BuildSubQueryInput; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -18,6 +7,15 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.DescriptionTagEntity; +import org.opencdmp.data.TagEntity; +import org.opencdmp.model.Tag; +import org.opencdmp.query.utils.BuildSubQueryInput; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -26,7 +24,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class TagQuery extends QueryBase { private String like; @@ -153,6 +151,16 @@ public class TagQuery extends QueryBase { return this; } + public TagQuery enableTracking() { + this.noTracking = false; + return this; + } + + public TagQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Boolean isFalseQuery() { return @@ -182,12 +190,12 @@ public class TagQuery extends QueryBase { predicates.add(queryContext.CriteriaBuilder.or( queryContext.CriteriaBuilder.isNull(queryContext.Root.get(TagEntity._createdById)), userId != null ? queryContext.CriteriaBuilder.equal(queryContext.Root.get(TagEntity._createdById), userId) : queryContext.CriteriaBuilder.or(), //Creates a false query - queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id)).value(queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DescriptionTagEntity.class, UUID.class) + queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DescriptionTagEntity.class, UUID.class) .query(queryContext.Query) .criteriaBuilder(queryContext.CriteriaBuilder) .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DescriptionTagEntity._tagId)) .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DescriptionTagEntity._descriptionId)).value(queryUtilsService.buildDescriptionAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) + cb.in(subQueryRoot.get(DescriptionTagEntity._descriptionId)).value(this.queryUtilsService.buildDescriptionAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) ) ))) //Creates a false query )); @@ -204,7 +212,7 @@ public class TagQuery extends QueryBase { protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TagEntity._label), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TagEntity._label), this.like)); } if (this.ids != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id)); diff --git a/backend/core/src/main/java/org/opencdmp/query/TenantConfigurationQuery.java b/backend/core/src/main/java/org/opencdmp/query/TenantConfigurationQuery.java index 4bcf8d188..fbe519090 100644 --- a/backend/core/src/main/java/org/opencdmp/query/TenantConfigurationQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/TenantConfigurationQuery.java @@ -1,17 +1,17 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.enums.TenantConfigurationType; -import org.opencdmp.data.TenantConfigurationEntity; -import org.opencdmp.model.tenantconfiguration.TenantConfiguration; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.enums.TenantConfigurationType; +import org.opencdmp.data.TenantConfigurationEntity; +import org.opencdmp.model.tenantconfiguration.TenantConfiguration; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -20,7 +20,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class TenantConfigurationQuery extends QueryBase { private Collection ids; @@ -120,6 +120,16 @@ public class TenantConfigurationQuery extends QueryBase { private String like; @@ -109,6 +107,16 @@ public class TenantQuery extends QueryBase { return this; } + public TenantQuery enableTracking() { + this.noTracking = false; + return this; + } + + public TenantQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Boolean isFalseQuery() { return this.isEmpty(this.ids) || this.isEmpty(this.codes) ||this.isEmpty(this.isActives); @@ -135,8 +143,8 @@ public class TenantQuery extends QueryBase { } if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._code), this.like), - queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._name), this.like) + predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._code), this.like), + this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._name), this.like) )); } diff --git a/backend/core/src/main/java/org/opencdmp/query/TenantUserQuery.java b/backend/core/src/main/java/org/opencdmp/query/TenantUserQuery.java index 09415435b..aa69fe576 100644 --- a/backend/core/src/main/java/org/opencdmp/query/TenantUserQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/TenantUserQuery.java @@ -1,29 +1,28 @@ package org.opencdmp.query; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.data.query.QueryBase; +import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.data.TenantUserEntity; import org.opencdmp.data.UserEntity; -import org.opencdmp.model.Tenant; import org.opencdmp.model.TenantUser; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.query.FieldResolver; -import gr.cite.tools.data.query.QueryBase; -import gr.cite.tools.data.query.QueryContext; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.*; import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class TenantUserQuery extends QueryBase { private Collection ids; @@ -113,6 +112,16 @@ public class TenantUserQuery extends QueryBase { return this; } + public TenantUserQuery enableTracking() { + this.noTracking = false; + return this; + } + + public TenantUserQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Class entityClass() { return TenantUserEntity.class; diff --git a/backend/core/src/main/java/org/opencdmp/query/UserContactInfoQuery.java b/backend/core/src/main/java/org/opencdmp/query/UserContactInfoQuery.java index 904f9da9f..833ba0101 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserContactInfoQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserContactInfoQuery.java @@ -1,11 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.ContactInfoType; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.UserContactInfoEntity; -import org.opencdmp.model.UserContactInfo; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -13,6 +7,12 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.ContactInfoType; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.UserContactInfoEntity; +import org.opencdmp.model.UserContactInfo; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -21,7 +21,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserContactInfoQuery extends QueryBase { private Collection ids; private Collection excludedIds; @@ -129,6 +129,16 @@ public class UserContactInfoQuery extends QueryBase { return this; } + public UserContactInfoQuery enableTracking() { + this.noTracking = false; + return this; + } + + public UserContactInfoQuery disableTracking() { + this.noTracking = false; + return this; + } + public UserContactInfoQuery authorize(EnumSet values) { this.authorize = values; return this; diff --git a/backend/core/src/main/java/org/opencdmp/query/UserCredentialQuery.java b/backend/core/src/main/java/org/opencdmp/query/UserCredentialQuery.java index 6b0ab9b43..3da2927d5 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserCredentialQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserCredentialQuery.java @@ -1,10 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.UserCredentialEntity; -import org.opencdmp.model.usercredential.UserCredential; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -12,6 +7,11 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.UserCredentialEntity; +import org.opencdmp.model.usercredential.UserCredential; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -20,7 +20,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserCredentialQuery extends QueryBase { private Collection ids; private Collection excludedIds; @@ -96,6 +96,16 @@ public class UserCredentialQuery extends QueryBase { return this; } + public UserCredentialQuery enableTracking() { + this.noTracking = false; + return this; + } + + public UserCredentialQuery disableTracking() { + this.noTracking = false; + return this; + } + public UserCredentialQuery authorize(EnumSet values) { this.authorize = values; return this; diff --git a/backend/core/src/main/java/org/opencdmp/query/UserDescriptionTemplateQuery.java b/backend/core/src/main/java/org/opencdmp/query/UserDescriptionTemplateQuery.java index 9c2b58686..0e15e9753 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserDescriptionTemplateQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserDescriptionTemplateQuery.java @@ -1,16 +1,16 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.enums.UserDescriptionTemplateRole; -import org.opencdmp.data.UserDescriptionTemplateEntity; -import org.opencdmp.model.UserDescriptionTemplate; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.enums.UserDescriptionTemplateRole; +import org.opencdmp.data.UserDescriptionTemplateEntity; +import org.opencdmp.model.UserDescriptionTemplate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -19,7 +19,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserDescriptionTemplateQuery extends QueryBase { private Collection ids; @@ -121,6 +121,16 @@ public class UserDescriptionTemplateQuery extends QueryBase values) { this.authorize = values; return this; diff --git a/backend/core/src/main/java/org/opencdmp/query/UserQuery.java b/backend/core/src/main/java/org/opencdmp/query/UserQuery.java index bbd8e4fba..6903e91e3 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserQuery.java @@ -125,6 +125,16 @@ public class UserQuery extends QueryBase { return this; } + public UserQuery enableTracking() { + this.noTracking = false; + return this; + } + + public UserQuery disableTracking() { + this.noTracking = false; + return this; + } + public UserQuery authorize(EnumSet values) { this.authorize = values; return this; diff --git a/backend/core/src/main/java/org/opencdmp/query/UserRoleQuery.java b/backend/core/src/main/java/org/opencdmp/query/UserRoleQuery.java index 0957da028..758f43fed 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserRoleQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserRoleQuery.java @@ -1,10 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.UserRoleEntity; -import org.opencdmp.model.UserRole; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -12,6 +7,11 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.UserRoleEntity; +import org.opencdmp.model.UserRole; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -20,7 +20,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserRoleQuery extends QueryBase { private Collection ids; private Collection excludedIds; @@ -123,6 +123,16 @@ public class UserRoleQuery extends QueryBase { return this; } + public UserRoleQuery enableTracking() { + this.noTracking = false; + return this; + } + + public UserRoleQuery disableTracking() { + this.noTracking = false; + return this; + } + @Override protected Boolean isFalseQuery() { return diff --git a/backend/core/src/main/java/org/opencdmp/query/UserSettingsQuery.java b/backend/core/src/main/java/org/opencdmp/query/UserSettingsQuery.java index cab613abf..efc058b7f 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserSettingsQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserSettingsQuery.java @@ -1,12 +1,5 @@ package org.opencdmp.query; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.enums.UserSettingsType; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.UserSettingsEntity; -import org.opencdmp.model.UserSettings; -import org.opencdmp.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -14,6 +7,13 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.UserSettingsType; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.UserSettingsEntity; +import org.opencdmp.model.UserSettings; +import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -22,7 +22,7 @@ import java.time.Instant; import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserSettingsQuery extends QueryBase { private String like; @@ -127,6 +127,16 @@ public class UserSettingsQuery extends QueryBase { return this; } + public UserSettingsQuery enableTracking() { + this.noTracking = false; + return this; + } + + public UserSettingsQuery disableTracking() { + this.noTracking = false; + return this; + } + public UserSettingsQuery authorize(EnumSet values) { this.authorize = values; return this; @@ -165,8 +175,8 @@ public class UserSettingsQuery extends QueryBase { protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._key), this.like), - queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._value), this.like) + predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._key), this.like), + this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._value), this.like) )); } if (this.ids != null) { diff --git a/backend/core/src/main/java/org/opencdmp/service/contactsupport/ContactSupportServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/contactsupport/ContactSupportServiceImpl.java index efa7fda20..87d6bdb5a 100644 --- a/backend/core/src/main/java/org/opencdmp/service/contactsupport/ContactSupportServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/contactsupport/ContactSupportServiceImpl.java @@ -1,12 +1,17 @@ package org.opencdmp.service.contactsupport; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.query.Ordering; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.JsonHandlingService; import org.opencdmp.commons.enums.ContactInfoType; import org.opencdmp.commons.enums.notification.NotificationContactType; +import org.opencdmp.commons.notification.NotificationProperties; import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.commons.types.notification.*; -import org.opencdmp.commons.notification.NotificationProperties; import org.opencdmp.data.UserContactInfoEntity; import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent; import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventHandler; @@ -14,11 +19,6 @@ import org.opencdmp.model.UserContactInfo; import org.opencdmp.model.persist.ContactSupportPersist; import org.opencdmp.model.persist.PublicContactSupportPersist; import org.opencdmp.query.UserContactInfoQuery; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.query.Ordering; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.logging.LoggerService; -import gr.cite.tools.logging.MapLogEntry; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -69,26 +69,26 @@ public class ContactSupportServiceImpl implements ContactSupportService { event.setUserId(this.userScope.getUserId()); - UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(this.userScope.getUserId()); + UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).disableTracking().userIds(this.userScope.getUserId()); query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal)); UserContactInfoEntity contactInfo = query.first(); List contactPairs = new ArrayList<>(); - contactPairs.add(new ContactPair(ContactInfoType.Email, notificationProperties.getContactSupportEmail())); + contactPairs.add(new ContactPair(ContactInfoType.Email, this.notificationProperties.getContactSupportEmail())); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); - event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); + event.setContactHint(this.jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(notificationProperties.getContactSupportType()); + event.setNotificationType(this.notificationProperties.getContactSupportType()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); fieldInfoList.add(new FieldInfo("{subject}", DataType.String, model.getSubject())); fieldInfoList.add(new FieldInfo("{description}", DataType.String, model.getDescription())); fieldInfoList.add(new FieldInfo("{email}", DataType.String, contactInfo.getValue())); data.setFields(fieldInfoList); - event.setData(jsonHandlingService.toJsonSafe(data)); + event.setData(this.jsonHandlingService.toJsonSafe(data)); - notifyIntegrationEventHandler.handle(event); + this.notifyIntegrationEventHandler.handle(event); } @Override @@ -99,12 +99,12 @@ public class ContactSupportServiceImpl implements ContactSupportService { NotifyIntegrationEvent event = new NotifyIntegrationEvent(); List contactPairs = new ArrayList<>(); - contactPairs.add(new ContactPair(ContactInfoType.Email, notificationProperties.getContactSupportEmail())); + contactPairs.add(new ContactPair(ContactInfoType.Email, this.notificationProperties.getContactSupportEmail())); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); - event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); + event.setContactHint(this.jsonHandlingService.toJsonSafe(contactData)); event.setContactTypeHint(NotificationContactType.EMAIL); - event.setNotificationType(notificationProperties.getPublicContactSupportType()); + event.setNotificationType(this.notificationProperties.getPublicContactSupportType()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); fieldInfoList.add(new FieldInfo("{subject}", DataType.String, model.getAffiliation())); @@ -112,9 +112,9 @@ public class ContactSupportServiceImpl implements ContactSupportService { fieldInfoList.add(new FieldInfo("{email}", DataType.String, model.getEmail())); fieldInfoList.add(new FieldInfo("{name}", DataType.String, model.getFullName())); data.setFields(fieldInfoList); - event.setData(jsonHandlingService.toJsonSafe(data)); + event.setData(this.jsonHandlingService.toJsonSafe(data)); - notifyIntegrationEventHandler.handle(event); + this.notifyIntegrationEventHandler.handle(event); } diff --git a/backend/core/src/main/java/org/opencdmp/service/dashborad/DashboardServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/dashborad/DashboardServiceImpl.java index e3d720ec4..1f4c63576 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dashborad/DashboardServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/dashborad/DashboardServiceImpl.java @@ -1,5 +1,11 @@ package org.opencdmp.service.dashborad; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.OwnedResource; import org.opencdmp.authorization.Permission; @@ -18,12 +24,6 @@ import org.opencdmp.query.*; import org.opencdmp.query.lookup.DescriptionLookup; import org.opencdmp.query.lookup.DmpLookup; import org.opencdmp.service.elastic.ElasticQueryHelperService; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.logging.LoggerService; -import gr.cite.tools.logging.MapLogEntry; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -114,19 +114,19 @@ public class DashboardServiceImpl implements DashboardService { DashboardStatisticsCacheService.DashboardStatisticsCacheValue cacheValue = this.dashboardStatisticsCacheService.lookup(this.dashboardStatisticsCacheService.buildKey(DashboardStatisticsCacheService.publicKey)); if (cacheValue == null || cacheValue.getDashboardStatistics() == null) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).versionStatuses(DmpVersionStatus.Current).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public); + DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().isActive(IsActive.Active).versionStatuses(DmpVersionStatus.Current).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public); DashboardStatistics statistics = new DashboardStatistics(); statistics.setDmpCount(dmpQuery.authorize(EnumSet.of(Public)).count()); - statistics.setDescriptionCount(this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).dmpSubQuery(dmpQuery).statuses(DescriptionStatus.Finalized).authorize(EnumSet.of(Public)).count()); + statistics.setDescriptionCount(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(dmpQuery).statuses(DescriptionStatus.Finalized).authorize(EnumSet.of(Public)).count()); statistics.setReferenceTypeStatistics(new ArrayList<>()); if (!this.conventionService.isListNullOrEmpty(this.config.getReferenceTypeCounters())){ for (UUID typeId : this.config.getReferenceTypeCounters()){ DashboardReferenceTypeStatistics referenceTypeStatistics = new DashboardReferenceTypeStatistics(); - referenceTypeStatistics.setCount(this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).typeIds(typeId).authorize(EnumSet.of(Public)) - .dmpReferenceSubQuery(this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active) + referenceTypeStatistics.setCount(this.queryFactory.query(ReferenceQuery.class).disableTracking().isActive(IsActive.Active).typeIds(typeId).authorize(EnumSet.of(Public)) + .dmpReferenceSubQuery(this.queryFactory.query(DmpReferenceQuery.class).disableTracking().isActives(IsActive.Active) .dmpSubQuery(dmpQuery)).count()); - referenceTypeStatistics.setReferenceType(this.builderFactory.builder(PublicReferenceTypeBuilder.class).build(new BaseFieldSet().ensure(PublicReferenceType._id), this.queryFactory.query(ReferenceTypeQuery.class).ids(typeId).first())); + referenceTypeStatistics.setReferenceType(this.builderFactory.builder(PublicReferenceTypeBuilder.class).build(new BaseFieldSet().ensure(PublicReferenceType._id), this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(typeId).first())); statistics.getReferenceTypeStatistics().add(referenceTypeStatistics); } } @@ -145,24 +145,24 @@ public class DashboardServiceImpl implements DashboardService { DashboardStatisticsCacheService.DashboardStatisticsCacheValue cacheValue = this.dashboardStatisticsCacheService.lookup(this.dashboardStatisticsCacheService.buildKey(this.dashboardStatisticsCacheService.generateUserTenantCacheKey(this.userScope.getUserId(), this.tenantScope.getTenantCode()))); if (cacheValue == null || cacheValue.getDashboardStatistics() == null) { - DmpUserQuery dmpUserLookup = this.queryFactory.query(DmpUserQuery.class); + DmpUserQuery dmpUserLookup = this.queryFactory.query(DmpUserQuery.class).disableTracking(); dmpUserLookup.userIds(this.userScope.getUserId()); dmpUserLookup.isActives(IsActive.Active); - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).dmpUserSubQuery(dmpUserLookup).versionStatuses(List.of(DmpVersionStatus.Current, DmpVersionStatus.NotFinalized)); + DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().isActive(IsActive.Active).dmpUserSubQuery(dmpUserLookup).versionStatuses(List.of(DmpVersionStatus.Current, DmpVersionStatus.NotFinalized)); DashboardStatistics statistics = new DashboardStatistics(); statistics.setDmpCount(dmpQuery.authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).count()); - statistics.setDescriptionCount(this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).dmpSubQuery(dmpQuery).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).count()); + statistics.setDescriptionCount(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(dmpQuery).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).count()); statistics.setReferenceTypeStatistics(new ArrayList<>()); if (!this.conventionService.isListNullOrEmpty(this.config.getReferenceTypeCounters())){ for (UUID typeId : this.config.getReferenceTypeCounters()){ DashboardReferenceTypeStatistics referenceTypeStatistics = new DashboardReferenceTypeStatistics(); - referenceTypeStatistics.setCount(this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).typeIds(typeId).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission) - .dmpReferenceSubQuery(this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active) + referenceTypeStatistics.setCount(this.queryFactory.query(ReferenceQuery.class).disableTracking().isActive(IsActive.Active).typeIds(typeId).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission) + .dmpReferenceSubQuery(this.queryFactory.query(DmpReferenceQuery.class).disableTracking().isActives(IsActive.Active) .dmpSubQuery(dmpQuery)).count()); - referenceTypeStatistics.setReferenceType(this.builderFactory.builder(PublicReferenceTypeBuilder.class).build(new BaseFieldSet().ensure(PublicReferenceType._id), this.queryFactory.query(ReferenceTypeQuery.class).ids(typeId).first())); + referenceTypeStatistics.setReferenceType(this.builderFactory.builder(PublicReferenceTypeBuilder.class).build(new BaseFieldSet().ensure(PublicReferenceType._id), this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(typeId).first())); statistics.getReferenceTypeStatistics().add(referenceTypeStatistics); } } diff --git a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java index ceae768e9..5091bfaea 100644 --- a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositServiceImpl.java @@ -1,5 +1,17 @@ package org.opencdmp.service.deposit; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService; +import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction; +import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.Ordering; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.validation.ValidatorFactory; +import org.apache.commons.io.FilenameUtils; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver; @@ -24,7 +36,6 @@ import org.opencdmp.data.UserEntity; import org.opencdmp.depositbase.repository.DepositClient; import org.opencdmp.depositbase.repository.DepositConfiguration; import org.opencdmp.event.TenantConfigurationTouchedEvent; -import org.opencdmp.event.UserAddedToTenantEvent; import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent; import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventHandler; import org.opencdmp.model.EntityDoi; @@ -32,30 +43,18 @@ import org.opencdmp.model.StorageFile; import org.opencdmp.model.UserContactInfo; import org.opencdmp.model.builder.commonmodels.DepositConfigurationBuilder; import org.opencdmp.model.builder.commonmodels.dmp.DmpCommonModelBuilder; +import org.opencdmp.model.persist.EntityDoiPersist; import org.opencdmp.model.persist.StorageFilePersist; import org.opencdmp.model.persist.deposit.DepositAuthenticateRequest; import org.opencdmp.model.persist.deposit.DepositRequest; -import org.opencdmp.model.persist.EntityDoiPersist; import org.opencdmp.model.tenantconfiguration.TenantConfiguration; import org.opencdmp.query.*; import org.opencdmp.service.encryption.EncryptionService; import org.opencdmp.service.entitydoi.EntityDoiService; +import org.opencdmp.service.filetransformer.FileTransformerService; import org.opencdmp.service.storage.StorageFileProperties; import org.opencdmp.service.storage.StorageFileService; -import org.opencdmp.service.filetransformer.FileTransformerService; import org.opencdmp.service.tenant.TenantProperties; -import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction; -import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.query.Ordering; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyNotFoundException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.validation.ValidatorFactory; -import org.apache.commons.io.FilenameUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -75,7 +74,10 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.time.Duration; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @Service @@ -160,9 +162,9 @@ public class DepositServiceImpl implements DepositService { String tenantCode = this.tenantScope.isSet() && this.tenantScope.isMultitenant() ? this.tenantScope.getTenantCode() : ""; DepositSourcesCacheService.DepositSourceCacheValue cacheValue = this.depositSourcesCacheService.lookup(this.depositSourcesCacheService.buildKey(tenantCode)); if (cacheValue == null) { - List depositSourceEntities = new ArrayList<>(depositProperties.getSources()); + List depositSourceEntities = new ArrayList<>(this.depositProperties.getSources()); if (this.tenantScope.isSet() && this.tenantScope.isMultitenant()) { - TenantConfigurationQuery tenantConfigurationQuery = this.queryFactory.query(TenantConfigurationQuery.class).isActive(IsActive.Active).types(TenantConfigurationType.DepositPlugins); + TenantConfigurationQuery tenantConfigurationQuery = this.queryFactory.query(TenantConfigurationQuery.class).disableTracking().isActive(IsActive.Active).types(TenantConfigurationType.DepositPlugins); if (this.tenantScope.isDefaultTenant()) tenantConfigurationQuery.tenantIsSet(false); else tenantConfigurationQuery.tenantIsSet(true).tenantIds(this.tenantScope.getTenant()); TenantConfigurationEntity tenantConfiguration = tenantConfigurationQuery.firstAs(new BaseFieldSet().ensure(TenantConfiguration._depositPlugins)); @@ -204,7 +206,7 @@ public class DepositServiceImpl implements DepositService { item.setUrl(source.getUrl()); item.setIssuerUrl(source.getIssuerUrl()); item.setClientId(source.getClientId()); - if (!this.conventionService.isNullOrEmpty(source.getClientSecret())) item.setClientSecret(this.encryptionService.decryptAES(source.getClientSecret(), tenantProperties.getConfigEncryptionAesKey(), tenantProperties.getConfigEncryptionAesIv())); + if (!this.conventionService.isNullOrEmpty(source.getClientSecret())) item.setClientSecret(this.encryptionService.decryptAES(source.getClientSecret(), this.tenantProperties.getConfigEncryptionAesKey(), this.tenantProperties.getConfigEncryptionAesIv())); item.setScope(source.getScope()); item.setRdaTransformerId(source.getRdaTransformerId()); item.setPdfTransformerId(source.getPdfTransformerId()); @@ -234,8 +236,8 @@ public class DepositServiceImpl implements DepositService { DepositConfigurationCacheService.DepositConfigurationCacheValue cacheValue = this.depositConfigurationCacheService.lookup(this.depositConfigurationCacheService.buildKey(depositSource.getRepositoryId(), tenantCode)); if (cacheValue == null){ try { - DepositClient depositClient = getDepositClient(depositSource.getRepositoryId()); - if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{depositSource.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); + DepositClient depositClient = this.getDepositClient(depositSource.getRepositoryId()); + if (depositClient == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{depositSource.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); DepositConfiguration configuration = depositClient.getConfiguration(); cacheValue = new DepositConfigurationCacheService.DepositConfigurationCacheValue(depositSource.getRepositoryId(), tenantCode, configuration); @@ -257,17 +259,17 @@ public class DepositServiceImpl implements DepositService { public EntityDoi deposit(DepositRequest dmpDepositModel) throws Exception { this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(dmpDepositModel.getDmpId())), Permission.DepositDmp); //GK: First get the right client - DepositClient depositClient = getDepositClient(dmpDepositModel.getRepositoryId()); - if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); + DepositClient depositClient = this.getDepositClient(dmpDepositModel.getRepositoryId()); + if (depositClient == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); //GK: Second get the Target Data Management Plan - DmpEntity dmpEntity = this.queryFactory.query(DmpQuery.class).ids(dmpDepositModel.getDmpId()).first(); - if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getDmpId(), DmpEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); + DmpEntity dmpEntity = this.queryFactory.query(DmpQuery.class).disableTracking().ids(dmpDepositModel.getDmpId()).first(); + if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getDmpId(), DmpEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); //GK: Forth make the required files to be uploaded with the deposit //TODO: Properly create required files DepositSourceEntity source = this.getDepositSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(dmpDepositModel.getRepositoryId())).findFirst().orElse(null); - if (source == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositSourceEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (source == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositSourceEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); org.opencdmp.model.file.FileEnvelope pdfFile = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getPdfTransformerId(),"pdf"); org.opencdmp.model.file.FileEnvelope rda = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getRdaTransformerId(),"json"); @@ -302,16 +304,16 @@ public class DepositServiceImpl implements DepositService { doiPersist.setDoi(doi); doiPersist.setEntityId(dmpEntity.getId()); this.sendNotification(dmpEntity); - return doiService.persist(doiPersist, dmpDepositModel.getProject()); + return this.doiService.persist(doiPersist, dmpDepositModel.getProject()); } private void sendNotification(DmpEntity dmpEntity) throws InvalidApplicationException { - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmpEntity.getId()).isActives(IsActive.Active).collect(); + List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(dmpEntity.getId()).isActives(IsActive.Active).collect(); if (this.conventionService.isListNullOrEmpty(dmpUsers)){ throw new MyNotFoundException("Dmp does not have Users"); } - List users = this.queryFactory.query(UserQuery.class).ids(dmpUsers.stream().map(DmpUserEntity::getUserId).collect(Collectors.toList())).isActive(IsActive.Active).collect(); + List users = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpUsers.stream().map(DmpUserEntity::getUserId).collect(Collectors.toList())).isActive(IsActive.Active).collect(); for (UserEntity user: users) { if (!user.getId().equals(this.userScope.getUserIdSafe()) && !this.conventionService.isListNullOrEmpty(dmpUsers.stream().filter(x -> x.getUserId().equals(user.getId())).collect(Collectors.toList()))){ @@ -323,24 +325,24 @@ public class DepositServiceImpl implements DepositService { private void createDmpDepositNotificationEvent(DmpEntity dmp, UserEntity user) throws InvalidApplicationException { NotifyIntegrationEvent event = new NotifyIntegrationEvent(); event.setUserId(user.getId()); - UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId()); + UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).disableTracking().userIds(user.getId()); query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal)); List contactPairs = new ArrayList<>(); contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue())); NotificationContactData contactData = new NotificationContactData(contactPairs, null, null); - event.setContactHint(jsonHandlingService.toJsonSafe(contactData)); - event.setNotificationType(notificationProperties.getDmpDepositType()); + event.setContactHint(this.jsonHandlingService.toJsonSafe(contactData)); + event.setNotificationType(this.notificationProperties.getDmpDepositType()); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName())); - fieldInfoList.add(new FieldInfo("{reasonName}", DataType.String, this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first().getName())); + fieldInfoList.add(new FieldInfo("{reasonName}", DataType.String, this.queryFactory.query(UserQuery.class).disableTracking().ids(this.userScope.getUserId()).first().getName())); fieldInfoList.add(new FieldInfo("{name}", DataType.String, dmp.getLabel())); fieldInfoList.add(new FieldInfo("{id}", DataType.String, dmp.getId().toString())); data.setFields(fieldInfoList); - event.setData(jsonHandlingService.toJsonSafe(data)); + event.setData(this.jsonHandlingService.toJsonSafe(data)); - eventHandler.handle(event); + this.eventHandler.handle(event); } private String addFileToSharedStorage(org.opencdmp.model.file.FileEnvelope file) throws IOException { @@ -360,8 +362,8 @@ public class DepositServiceImpl implements DepositService { public String getLogo(String repositoryId) throws InvalidApplicationException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { this.authorizationService.authorizeForce(Permission.BrowseDeposit, Permission.DeferredAffiliation); - DepositClient depositClient = getDepositClient(repositoryId); - if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{repositoryId, DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); + DepositClient depositClient = this.getDepositClient(repositoryId); + if (depositClient == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{repositoryId, DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); return depositClient.getLogo(); } @@ -369,8 +371,8 @@ public class DepositServiceImpl implements DepositService { public String authenticate(DepositAuthenticateRequest model) throws InvalidApplicationException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { this.authorizationService.authorizeForce(Permission.BrowseDeposit, Permission.DeferredAffiliation); - DepositClient depositClient = getDepositClient(model.getRepositoryId()); - if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); + DepositClient depositClient = this.getDepositClient(model.getRepositoryId()); + if (depositClient == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); return depositClient.authenticate(model.getCode()); } diff --git a/backend/web/src/main/java/org/opencdmp/configurations/MyHibernateJpaDialect.java b/backend/web/src/main/java/org/opencdmp/configurations/MyHibernateJpaDialect.java index e78aed2d8..6b01834a3 100644 --- a/backend/web/src/main/java/org/opencdmp/configurations/MyHibernateJpaDialect.java +++ b/backend/web/src/main/java/org/opencdmp/configurations/MyHibernateJpaDialect.java @@ -3,17 +3,9 @@ //import jakarta.persistence.PersistenceException; //import org.hibernate.FlushMode; //import org.hibernate.Session; -//import org.springframework.context.annotation.Bean; -//import org.springframework.lang.Nullable; -//import org.springframework.orm.jpa.JpaVendorAdapter; -//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //import org.springframework.orm.jpa.vendor.HibernateJpaDialect; -//import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //import org.springframework.stereotype.Service; // -//import javax.sql.DataSource; -//import java.sql.SQLException; -// //@Service //public class MyHibernateJpaDialect extends HibernateJpaDialect { // @Override diff --git a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java index b7990eafd..fb0e918c6 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java @@ -19,11 +19,13 @@ import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.StorageFileEntity; -import org.opencdmp.model.*; -import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder; +import org.opencdmp.model.DescriptionValidationResult; +import org.opencdmp.model.PublicDescription; +import org.opencdmp.model.StorageFile; import org.opencdmp.model.builder.PublicDescriptionBuilder; -import org.opencdmp.model.censorship.description.DescriptionCensor; +import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder; import org.opencdmp.model.censorship.PublicDescriptionCensor; +import org.opencdmp.model.censorship.description.DescriptionCensor; import org.opencdmp.model.description.Description; import org.opencdmp.model.dmpblueprint.DmpBlueprint; import org.opencdmp.model.persist.*; @@ -122,7 +124,7 @@ public class DescriptionController { this.censorFactory.censor(PublicDescriptionCensor.class).censor(fieldSet); - DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(EnumSet.of(Public)).ids(id).dmpSubQuery(this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public)); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(EnumSet.of(Public)).ids(id).dmpSubQuery(this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public)); PublicDescription model = this.builderFactory.builder(PublicDescriptionBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PublicDescription.class.getSimpleName()}, LocaleContextHolder.getLocale())); @@ -156,7 +158,7 @@ public class DescriptionController { this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null); - DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).ids(id); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).ids(id); Description model = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateController.java b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateController.java index 0876724aa..f6fc19bae 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateController.java @@ -17,11 +17,11 @@ import jakarta.xml.bind.JAXBException; import org.opencdmp.audit.AuditableAction; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.data.DescriptionTemplateEntity; -import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; import org.opencdmp.model.builder.descriptiontemplate.DescriptionTemplateBuilder; import org.opencdmp.model.censorship.descriptiontemplate.DescriptionTemplateCensor; import org.opencdmp.model.censorship.dmpblueprint.DmpBlueprintCensor; +import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; +import org.opencdmp.model.dmpblueprint.DmpBlueprint; import org.opencdmp.model.persist.DescriptionTemplatePersist; import org.opencdmp.model.persist.NewVersionDescriptionTemplatePersist; import org.opencdmp.model.result.QueryResult; @@ -106,7 +106,7 @@ public class DescriptionTemplateController { this.censorFactory.censor(DescriptionTemplateCensor.class).censor(fieldSet, null); - DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateTypeController.java b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateTypeController.java index 32fdd1bf6..180217c00 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateTypeController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateTypeController.java @@ -1,16 +1,5 @@ package org.opencdmp.controllers; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.data.DescriptionTemplateTypeEntity; -import org.opencdmp.model.DescriptionTemplateType; -import org.opencdmp.model.builder.DescriptionTemplateTypeBuilder; -import org.opencdmp.model.censorship.DescriptionTemplateTypeCensor; -import org.opencdmp.model.persist.DescriptionTemplateTypePersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.DescriptionTemplateTypeQuery; -import org.opencdmp.query.lookup.DescriptionTemplateTypeLookup; -import org.opencdmp.service.descriptiontemplatetype.DescriptionTemplateTypeService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -22,6 +11,17 @@ import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.validation.ValidationFilterAnnotation; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.data.DescriptionTemplateTypeEntity; +import org.opencdmp.model.DescriptionTemplateType; +import org.opencdmp.model.builder.DescriptionTemplateTypeBuilder; +import org.opencdmp.model.censorship.DescriptionTemplateTypeCensor; +import org.opencdmp.model.persist.DescriptionTemplateTypePersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.query.DescriptionTemplateTypeQuery; +import org.opencdmp.query.lookup.DescriptionTemplateTypeLookup; +import org.opencdmp.service.descriptiontemplatetype.DescriptionTemplateTypeService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -86,10 +86,10 @@ public class DescriptionTemplateTypeController { this.censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(fieldSet, null); - DescriptionTemplateTypeQuery query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + DescriptionTemplateTypeQuery query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); DescriptionTemplateType model = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplateType.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplateType.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.DescriptionTemplateType_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), diff --git a/backend/web/src/main/java/org/opencdmp/controllers/DmpBlueprintController.java b/backend/web/src/main/java/org/opencdmp/controllers/DmpBlueprintController.java index 10adeae2b..55519ed0f 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DmpBlueprintController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DmpBlueprintController.java @@ -1,19 +1,6 @@ package org.opencdmp.controllers; import com.fasterxml.jackson.core.JsonProcessingException; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.model.persist.NewVersionDmpBlueprintPersist; -import gr.cite.tools.validation.ValidationFilterAnnotation; -import org.opencdmp.data.DmpBlueprintEntity; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.model.builder.dmpblueprint.DmpBlueprintBuilder; -import org.opencdmp.model.censorship.dmpblueprint.DmpBlueprintCensor; -import org.opencdmp.model.persist.DmpBlueprintPersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.DmpBlueprintQuery; -import org.opencdmp.query.lookup.DmpBlueprintLookup; -import org.opencdmp.service.dmpblueprint.DmpBlueprintService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -24,8 +11,21 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; import jakarta.transaction.Transactional; import jakarta.xml.bind.JAXBException; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.model.builder.dmpblueprint.DmpBlueprintBuilder; +import org.opencdmp.model.censorship.dmpblueprint.DmpBlueprintCensor; +import org.opencdmp.model.dmpblueprint.DmpBlueprint; +import org.opencdmp.model.persist.DmpBlueprintPersist; +import org.opencdmp.model.persist.NewVersionDmpBlueprintPersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.query.DmpBlueprintQuery; +import org.opencdmp.query.lookup.DmpBlueprintLookup; +import org.opencdmp.service.dmpblueprint.DmpBlueprintService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -98,10 +98,10 @@ public class DmpBlueprintController { this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null); - DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.DmpBlueprint_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), @@ -169,7 +169,7 @@ public class DmpBlueprintController { return persisted; } - @RequestMapping(method = RequestMethod.GET, value = {"/xml/export/{id}"}, produces = "application/xml") + @RequestMapping(method = RequestMethod.GET, value = "/xml/export/{id}", produces = "application/xml") public @ResponseBody ResponseEntity getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { logger.debug(new MapLogEntry("export" + DmpBlueprint.class.getSimpleName()).And("id", id)); @@ -181,7 +181,7 @@ public class DmpBlueprintController { return response; } - @RequestMapping(method = RequestMethod.POST, value = {"/xml/import"}) + @RequestMapping(method = RequestMethod.POST, value = "/xml/import") public DmpBlueprint importXml(@RequestParam("file") MultipartFile file, FieldSet fieldSet) throws IOException, JAXBException, InvalidApplicationException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException { logger.debug(new MapLogEntry("clone" + DmpBlueprint.class.getSimpleName()).And("file", file)); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java b/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java index 97dae8443..0dcd0e1e3 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java @@ -112,7 +112,7 @@ public class DmpController { this.censorFactory.censor(PublicDmpCensor.class).censor(fieldSet); - DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(EnumSet.of(Public)).ids(id).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public); + DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(EnumSet.of(Public)).ids(id).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public); PublicDmp model = this.builderFactory.builder(PublicDmpBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); @@ -144,7 +144,7 @@ public class DmpController { this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); - DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); Dmp model = this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/EntityDoiController.java b/backend/web/src/main/java/org/opencdmp/controllers/EntityDoiController.java index ec9b486a7..6bd121498 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/EntityDoiController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/EntityDoiController.java @@ -1,19 +1,5 @@ package org.opencdmp.controllers; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import gr.cite.tools.validation.ValidationFilterAnnotation; -import org.opencdmp.data.EntityDoiEntity; -import org.opencdmp.model.DescriptionTemplateType; -import org.opencdmp.model.EntityDoi; -import org.opencdmp.model.builder.EntityDoiBuilder; -import org.opencdmp.model.censorship.EntityDoiCensor; -import org.opencdmp.model.persist.EntityDoiPersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.EntityDoiQuery; -import org.opencdmp.query.lookup.EntityDoiLookup; -import org.opencdmp.service.deposit.DepositService; -import org.opencdmp.service.entitydoi.EntityDoiService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -24,6 +10,19 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.data.EntityDoiEntity; +import org.opencdmp.model.DescriptionTemplateType; +import org.opencdmp.model.EntityDoi; +import org.opencdmp.model.builder.EntityDoiBuilder; +import org.opencdmp.model.censorship.EntityDoiCensor; +import org.opencdmp.model.persist.EntityDoiPersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.query.EntityDoiQuery; +import org.opencdmp.query.lookup.EntityDoiLookup; +import org.opencdmp.service.entitydoi.EntityDoiService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -88,10 +87,10 @@ public class EntityDoiController { this.censorFactory.censor(EntityDoiCensor.class).censor(fieldSet, null); - EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); EntityDoi model = this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, EntityDoi.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, EntityDoi.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.EntityDoi_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), diff --git a/backend/web/src/main/java/org/opencdmp/controllers/LanguageController.java b/backend/web/src/main/java/org/opencdmp/controllers/LanguageController.java index 3972c796d..6013480c6 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/LanguageController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/LanguageController.java @@ -1,18 +1,6 @@ package org.opencdmp.controllers; import com.fasterxml.jackson.core.JsonProcessingException; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import gr.cite.tools.validation.ValidationFilterAnnotation; -import org.opencdmp.data.LanguageEntity; -import org.opencdmp.model.Language; -import org.opencdmp.model.builder.LanguageBuilder; -import org.opencdmp.model.censorship.LanguageCensor; -import org.opencdmp.model.persist.LanguagePersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.LanguageQuery; -import org.opencdmp.query.lookup.LanguageLookup; -import org.opencdmp.service.language.LanguageService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -24,8 +12,20 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; import jakarta.transaction.Transactional; import jakarta.xml.bind.JAXBException; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.data.LanguageEntity; +import org.opencdmp.model.Language; +import org.opencdmp.model.builder.LanguageBuilder; +import org.opencdmp.model.censorship.LanguageCensor; +import org.opencdmp.model.persist.LanguagePersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.query.LanguageQuery; +import org.opencdmp.query.lookup.LanguageLookup; +import org.opencdmp.service.language.LanguageService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; @@ -40,7 +40,7 @@ import java.util.stream.Collectors; import static org.opencdmp.authorization.AuthorizationFlags.Public; @RestController -@RequestMapping(path = {"api/language"}) +@RequestMapping(path = "api/language") public class LanguageController { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LanguageController.class)); @@ -95,10 +95,10 @@ public class LanguageController { this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null); - LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + LanguageQuery query = this.queryFactory.query(LanguageQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Language.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Language.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.Language_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), @@ -114,11 +114,11 @@ public class LanguageController { this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null); - LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(EnumSet.of(Public)).codes(code); + LanguageQuery query = this.queryFactory.query(LanguageQuery.class).disableTracking().authorize(EnumSet.of(Public)).codes(code); Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, Language.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{code, Language.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (model.getPayload() == null) { model.setPayload(this.languageService.getPayload(code)); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/LockController.java b/backend/web/src/main/java/org/opencdmp/controllers/LockController.java index 7700d4a48..c25e27ff6 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/LockController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/LockController.java @@ -1,22 +1,5 @@ package org.opencdmp.controllers; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AffiliatedResource; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver; -import org.opencdmp.commons.enums.LockTargetType; -import org.opencdmp.model.LockStatus; -import gr.cite.tools.validation.ValidationFilterAnnotation; -import org.opencdmp.data.LockEntity; -import org.opencdmp.model.Lock; -import org.opencdmp.model.builder.LockBuilder; -import org.opencdmp.model.censorship.LockCensor; -import org.opencdmp.model.persist.LockPersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.LockQuery; -import org.opencdmp.query.lookup.LockLookup; -import org.opencdmp.service.lock.LockService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; @@ -28,7 +11,24 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; import jakarta.transaction.Transactional; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AffiliatedResource; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver; +import org.opencdmp.commons.enums.LockTargetType; +import org.opencdmp.data.LockEntity; +import org.opencdmp.model.Lock; +import org.opencdmp.model.LockStatus; +import org.opencdmp.model.builder.LockBuilder; +import org.opencdmp.model.censorship.LockCensor; +import org.opencdmp.model.persist.LockPersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.query.LockQuery; +import org.opencdmp.query.lookup.LockLookup; +import org.opencdmp.service.lock.LockService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; @@ -48,7 +48,7 @@ import java.util.Map; import java.util.UUID; @RestController -@RequestMapping(path = {"api/lock"}) +@RequestMapping(path = "api/lock") public class LockController { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LockController.class)); @@ -106,10 +106,10 @@ public class LockController { this.censorFactory.censor(LockCensor.class).censor(fieldSet, null); - LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + LockQuery query = this.queryFactory.query(LockQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); Lock model = this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Lock.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Lock.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.Lock_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), @@ -142,10 +142,10 @@ public class LockController { this.censorFactory.censor(LockCensor.class).censor(fieldSet, null); - LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).targetIds(targetId); + LockQuery query = this.queryFactory.query(LockQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).targetIds(targetId); Lock model = this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{targetId, Lock.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{targetId, Lock.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.Lock_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("targetId", targetId), diff --git a/backend/web/src/main/java/org/opencdmp/controllers/PrefillingSourceController.java b/backend/web/src/main/java/org/opencdmp/controllers/PrefillingSourceController.java index 5c35e0923..db68b6e93 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/PrefillingSourceController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/PrefillingSourceController.java @@ -104,7 +104,7 @@ public class PrefillingSourceController { this.censorFactory.censor(PrefillingSourceCensor.class).censor(fieldSet, null); - PrefillingSourceQuery query = this.queryFactory.query(PrefillingSourceQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + PrefillingSourceQuery query = this.queryFactory.query(PrefillingSourceQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); PrefillingSource model = this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale())); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/ReferenceController.java b/backend/web/src/main/java/org/opencdmp/controllers/ReferenceController.java index eebfff896..adf808e49 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/ReferenceController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/ReferenceController.java @@ -124,7 +124,7 @@ public class ReferenceController { this.censorFactory.censor(ReferenceCensor.class).censor(fieldSet, null); - ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); Reference model = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Reference.class.getSimpleName()}, LocaleContextHolder.getLocale())); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/ReferenceTypeController.java b/backend/web/src/main/java/org/opencdmp/controllers/ReferenceTypeController.java index ba73e7513..4d62fbc7e 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/ReferenceTypeController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/ReferenceTypeController.java @@ -96,7 +96,7 @@ public class ReferenceTypeController{ this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null); - ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); @@ -115,7 +115,7 @@ public class ReferenceTypeController{ this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null); - ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).codes(code); + ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).codes(code); ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{code, ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/StorageFileController.java b/backend/web/src/main/java/org/opencdmp/controllers/StorageFileController.java index 070b059c9..1cac1f4a1 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/StorageFileController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/StorageFileController.java @@ -83,7 +83,7 @@ public class StorageFileController { this.authorizationService.authorizeForce(Permission.BrowseStorageFile, Permission.DeferredAffiliation); - StorageFileQuery query = this.queryFactory.query(StorageFileQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + StorageFileQuery query = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); StorageFile model = this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale())); @@ -129,7 +129,7 @@ public class StorageFileController { this.authorizationService.authorizeForce(Permission.BrowseStorageFile, Permission.DeferredAffiliation); - StorageFileEntity storageFile = this.queryFactory.query(StorageFileQuery.class).ids(id).firstAs(new BaseFieldSet().ensure(StorageFile._createdAt, StorageFile._fullName, StorageFile._mimeType, StorageFile._extension)); + StorageFileEntity storageFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().ids(id).firstAs(new BaseFieldSet().ensure(StorageFile._createdAt, StorageFile._fullName, StorageFile._mimeType, StorageFile._extension)); if (storageFile == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale())); byte[] file = this.storageFileService.readAsBytesSafe(id); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/SupportiveMaterialController.java b/backend/web/src/main/java/org/opencdmp/controllers/SupportiveMaterialController.java index 4dc25a3cd..517525769 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/SupportiveMaterialController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/SupportiveMaterialController.java @@ -1,11 +1,23 @@ package org.opencdmp.controllers; import com.fasterxml.jackson.core.JsonProcessingException; +import gr.cite.tools.auditing.AuditService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.censor.CensorFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; +import jakarta.transaction.Transactional; +import jakarta.xml.bind.JAXBException; import org.opencdmp.audit.AuditableAction; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.enums.SupportiveMaterialFieldType; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.validation.ValidationFilterAnnotation; import org.opencdmp.data.SupportiveMaterialEntity; import org.opencdmp.model.SupportiveMaterial; import org.opencdmp.model.builder.SupportiveMaterialBuilder; @@ -15,18 +27,6 @@ import org.opencdmp.model.result.QueryResult; import org.opencdmp.query.SupportiveMaterialQuery; import org.opencdmp.query.lookup.SupportiveMaterialLookup; import org.opencdmp.service.supportivematerial.SupportiveMaterialService; -import gr.cite.tools.auditing.AuditService; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.censor.CensorFactory; -import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.exception.MyForbiddenException; -import gr.cite.tools.exception.MyNotFoundException; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.logging.LoggerService; -import gr.cite.tools.logging.MapLogEntry; -import jakarta.transaction.Transactional; -import jakarta.xml.bind.JAXBException; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; @@ -44,7 +44,7 @@ import java.io.IOException; import java.util.*; @RestController -@RequestMapping(path = {"/api/supportive-material"}) +@RequestMapping(path = "/api/supportive-material") public class SupportiveMaterialController { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SupportiveMaterialController.class)); @@ -96,10 +96,10 @@ public class SupportiveMaterialController { this.censorFactory.censor(SupportiveMaterialCensor.class).censor(fieldSet, null); - SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); SupportiveMaterial model = this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.SupportiveMaterial_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), @@ -114,7 +114,7 @@ public class SupportiveMaterialController { logger.debug("querying {}", SupportiveMaterial.class.getSimpleName()); - SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).types(SupportiveMaterialFieldType.of(type)).languageCodes(language).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission); + SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).disableTracking().types(SupportiveMaterialFieldType.of(type)).languageCodes(language).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission); List data = query.collectAs(new BaseFieldSet().ensure(SupportiveMaterial._id).ensure(SupportiveMaterial._payload)); byte[] content; if (data.size() == 1) content = data.getFirst().getPayload().getBytes(); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/TagController.java b/backend/web/src/main/java/org/opencdmp/controllers/TagController.java index ebc37b001..0236acd78 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/TagController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/TagController.java @@ -1,17 +1,5 @@ package org.opencdmp.controllers; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import gr.cite.tools.validation.ValidationFilterAnnotation; -import org.opencdmp.data.TagEntity; -import org.opencdmp.model.Tag; -import org.opencdmp.model.builder.TagBuilder; -import org.opencdmp.model.censorship.TagCensor; -import org.opencdmp.model.persist.TagPersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.TagQuery; -import org.opencdmp.query.lookup.TagLookup; -import org.opencdmp.service.tag.TagService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -22,6 +10,18 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.data.TagEntity; +import org.opencdmp.model.Tag; +import org.opencdmp.model.builder.TagBuilder; +import org.opencdmp.model.censorship.TagCensor; +import org.opencdmp.model.persist.TagPersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.query.TagQuery; +import org.opencdmp.query.lookup.TagLookup; +import org.opencdmp.service.tag.TagService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -87,10 +87,10 @@ public class TagController { this.censorFactory.censor(TagCensor.class).censor(fieldSet, null); - TagQuery query = this.queryFactory.query(TagQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + TagQuery query = this.queryFactory.query(TagQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); Tag model = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tag.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tag.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.Tag_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), diff --git a/backend/web/src/main/java/org/opencdmp/controllers/TenantConfigurationController.java b/backend/web/src/main/java/org/opencdmp/controllers/TenantConfigurationController.java index 3994c2b2b..bedd067c0 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/TenantConfigurationController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/TenantConfigurationController.java @@ -1,21 +1,6 @@ package org.opencdmp.controllers; import com.fasterxml.jackson.core.JsonProcessingException; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.enums.TenantConfigurationType; -import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.data.TenantConfigurationEntity; -import org.opencdmp.model.DescriptionTemplateType; -import org.opencdmp.model.builder.tenantconfiguration.TenantConfigurationBuilder; -import org.opencdmp.model.censorship.tenantconfiguration.TenantConfigurationCensor; -import org.opencdmp.model.persist.tenantconfiguration.TenantConfigurationPersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.model.tenantconfiguration.TenantConfiguration; -import org.opencdmp.query.TenantConfigurationQuery; -import org.opencdmp.query.lookup.TenantConfigurationLookup; -import org.opencdmp.service.tenantconfiguration.TenantConfigurationService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -27,6 +12,20 @@ import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.validation.ValidationFilterAnnotation; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.enums.TenantConfigurationType; +import org.opencdmp.commons.scope.tenant.TenantScope; +import org.opencdmp.data.TenantConfigurationEntity; +import org.opencdmp.model.builder.tenantconfiguration.TenantConfigurationBuilder; +import org.opencdmp.model.censorship.tenantconfiguration.TenantConfigurationCensor; +import org.opencdmp.model.persist.tenantconfiguration.TenantConfigurationPersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.model.tenantconfiguration.TenantConfiguration; +import org.opencdmp.query.TenantConfigurationQuery; +import org.opencdmp.query.lookup.TenantConfigurationLookup; +import org.opencdmp.service.tenantconfiguration.TenantConfigurationService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -40,7 +39,10 @@ import javax.management.InvalidApplicationException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.util.*; +import java.util.AbstractMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; @RestController @RequestMapping(path = "api/tenant-configuration") @@ -99,10 +101,10 @@ public class TenantConfigurationController { this.censorFactory.censor(TenantConfigurationCensor.class).censor(fieldSet, null); - TenantConfigurationQuery query = this.queryFactory.query(TenantConfigurationQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + TenantConfigurationQuery query = this.queryFactory.query(TenantConfigurationQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); TenantConfiguration model = this.builderFactory.builder(TenantConfigurationBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, TenantConfiguration.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, TenantConfiguration.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.TenantConfiguration_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), @@ -118,7 +120,7 @@ public class TenantConfigurationController { this.censorFactory.censor(TenantConfigurationCensor.class).censor(fieldSet, null); - TenantConfigurationQuery query = this.queryFactory.query(TenantConfigurationQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).types(TenantConfigurationType.of(type)); + TenantConfigurationQuery query = this.queryFactory.query(TenantConfigurationQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).types(TenantConfigurationType.of(type)); if (this.tenantScope.isDefaultTenant()) query.tenantIsSet(false); else query.tenantIsSet(true).tenantIds(this.tenantScope.getTenant()); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/TenantController.java b/backend/web/src/main/java/org/opencdmp/controllers/TenantController.java index c622f2a1e..e881cac14 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/TenantController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/TenantController.java @@ -1,18 +1,6 @@ package org.opencdmp.controllers; import com.fasterxml.jackson.core.JsonProcessingException; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import gr.cite.tools.validation.ValidationFilterAnnotation; -import org.opencdmp.data.TenantEntity; -import org.opencdmp.model.Tenant; -import org.opencdmp.model.builder.TenantBuilder; -import org.opencdmp.model.censorship.TenantCensor; -import org.opencdmp.model.persist.TenantPersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.TenantQuery; -import org.opencdmp.query.lookup.TenantLookup; -import org.opencdmp.service.tenant.TenantService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -23,8 +11,20 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; import jakarta.transaction.Transactional; import jakarta.xml.bind.JAXBException; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.data.TenantEntity; +import org.opencdmp.model.Tenant; +import org.opencdmp.model.builder.TenantBuilder; +import org.opencdmp.model.censorship.TenantCensor; +import org.opencdmp.model.persist.TenantPersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.query.TenantQuery; +import org.opencdmp.query.lookup.TenantLookup; +import org.opencdmp.service.tenant.TenantService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -99,10 +99,10 @@ public class TenantController { this.censorFactory.censor(TenantCensor.class).censor(fieldSet, null); - TenantQuery query = this.queryFactory.query(TenantQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + TenantQuery query = this.queryFactory.query(TenantQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); Tenant model = this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tenant.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tenant.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.Tenant_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), diff --git a/backend/web/src/main/java/org/opencdmp/controllers/UserController.java b/backend/web/src/main/java/org/opencdmp/controllers/UserController.java index 75bd50747..36cd9e359 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/UserController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/UserController.java @@ -1,28 +1,6 @@ package org.opencdmp.controllers; import com.fasterxml.jackson.core.JsonProcessingException; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.scope.user.UserScope; -import gr.cite.tools.validation.ValidationFilterAnnotation; -import org.opencdmp.data.UserEntity; -import org.opencdmp.model.DmpAssociatedUser; -import org.opencdmp.model.user.User; -import org.opencdmp.model.UserRole; -import org.opencdmp.model.builder.DmpAssociatedUserBuilder; -import org.opencdmp.model.builder.UserBuilder; -import org.opencdmp.model.censorship.DmpAssociatedUserCensor; -import org.opencdmp.model.censorship.UserCensor; -import org.opencdmp.model.persist.actionconfirmation.RemoveCredentialRequestPersist; -import org.opencdmp.model.persist.UserMergeRequestPersist; -import org.opencdmp.model.persist.UserPersist; -import org.opencdmp.model.persist.UserRolePatchPersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.UserQuery; -import org.opencdmp.query.lookup.UserLookup; -import org.opencdmp.service.responseutils.ResponseUtilsService; -import org.opencdmp.service.user.UserService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -33,7 +11,29 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; import jakarta.xml.bind.JAXBException; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.data.UserEntity; +import org.opencdmp.model.DmpAssociatedUser; +import org.opencdmp.model.UserRole; +import org.opencdmp.model.builder.DmpAssociatedUserBuilder; +import org.opencdmp.model.builder.UserBuilder; +import org.opencdmp.model.censorship.DmpAssociatedUserCensor; +import org.opencdmp.model.censorship.UserCensor; +import org.opencdmp.model.persist.UserMergeRequestPersist; +import org.opencdmp.model.persist.UserPersist; +import org.opencdmp.model.persist.UserRolePatchPersist; +import org.opencdmp.model.persist.actionconfirmation.RemoveCredentialRequestPersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.model.user.User; +import org.opencdmp.query.UserQuery; +import org.opencdmp.query.lookup.UserLookup; +import org.opencdmp.service.responseutils.ResponseUtilsService; +import org.opencdmp.service.user.UserService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -132,10 +132,10 @@ public class UserController { this.censorFactory.censor(UserCensor.class).censor(fieldSet, id); - UserQuery query = this.queryFactory.query(UserQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + UserQuery query = this.queryFactory.query(UserQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); User model = this.builderFactory.builder(UserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, User.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, User.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.User_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), @@ -151,10 +151,10 @@ public class UserController { this.censorFactory.censor(UserCensor.class).censor(fieldSet, null); - UserQuery query = this.queryFactory.query(UserQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).emails(email); + UserQuery query = this.queryFactory.query(UserQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).emails(email); User model = this.builderFactory.builder(UserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{email, User.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{email, User.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.User_LookupByEmail, Map.ofEntries( new AbstractMap.SimpleEntry("email", email), @@ -183,10 +183,10 @@ public class UserController { this.censorFactory.censor(UserCensor.class).censor(fieldSet, this.userScope.getUserId()); - UserQuery query = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission); + UserQuery query = this.queryFactory.query(UserQuery.class).disableTracking().ids(this.userScope.getUserId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission); User model = this.builderFactory.builder(UserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{this.userScope.getUserId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{this.userScope.getUserId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.auditService.track(AuditableAction.User_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("fields", fieldSet) diff --git a/backend/web/src/main/java/org/opencdmp/controllers/UserSettingsController.java b/backend/web/src/main/java/org/opencdmp/controllers/UserSettingsController.java index d8b999261..f33b7a045 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/UserSettingsController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/UserSettingsController.java @@ -1,17 +1,5 @@ package org.opencdmp.controllers; -import org.opencdmp.audit.AuditableAction; -import org.opencdmp.authorization.AuthorizationFlags; -import gr.cite.tools.validation.ValidationFilterAnnotation; -import org.opencdmp.data.UserSettingsEntity; -import org.opencdmp.model.UserSettings; -import org.opencdmp.model.builder.UserSettingsBuilder; -import org.opencdmp.model.censorship.UserSettingsCensor; -import org.opencdmp.model.persist.UserSettingsPersist; -import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.UserSettingsQuery; -import org.opencdmp.query.lookup.UserSettingsLookup; -import org.opencdmp.service.user.settings.UserSettingsService; import gr.cite.tools.auditing.AuditService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.censor.CensorFactory; @@ -23,7 +11,19 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import gr.cite.tools.validation.ValidationFilterAnnotation; import jakarta.transaction.Transactional; +import org.opencdmp.audit.AuditableAction; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.data.UserSettingsEntity; +import org.opencdmp.model.UserSettings; +import org.opencdmp.model.builder.UserSettingsBuilder; +import org.opencdmp.model.censorship.UserSettingsCensor; +import org.opencdmp.model.persist.UserSettingsPersist; +import org.opencdmp.model.result.QueryResult; +import org.opencdmp.query.UserSettingsQuery; +import org.opencdmp.query.lookup.UserSettingsLookup; +import org.opencdmp.service.user.settings.UserSettingsService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; @@ -98,7 +98,7 @@ public class UserSettingsController { UserSettings._updatedAt, UserSettings._type )); - UserSettingsQuery query = this.queryFactory.query(UserSettingsQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).keys(key); + UserSettingsQuery query = this.queryFactory.query(UserSettingsQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).keys(key); UserSettings model = this.builderFactory.builder(UserSettingsBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); this.auditService.track(AuditableAction.User_Settings_Lookup, Map.ofEntries( diff --git a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java index 9a1dffe2d..07c697792 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java @@ -106,7 +106,7 @@ public class PublicDatasetsDescriptionDocumentation { ) throws Exception { DescriptionLookup lookup = getDescriptionLookup(); DescriptionQuery query = lookup.enrich(this.queryFactory).authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active); - long count = this.queryFactory.query(DescriptionQuery.class).authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active).count(); + long count = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active).count(); List data = query.collectAs(lookup.getProject()); List models = this.builderFactory.builder(DescriptionBuilder.class).build(lookup.getProject(), data); @@ -127,12 +127,12 @@ public class PublicDatasetsDescriptionDocumentation { @PathVariable @Parameter(description = "fetch the dataset with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id ) { DescriptionLookup lookup = getDescriptionLookup(); - DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(EnumSet.of(AuthorizationFlags.Public)).ids(UUID.fromString(id)).isActive(IsActive.Active); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(EnumSet.of(AuthorizationFlags.Public)).ids(UUID.fromString(id)).isActive(IsActive.Active); Description model = this.builderFactory.builder(DescriptionBuilder.class).build(lookup.getProject(), query.firstAs(lookup.getProject())); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).ids(model.getDmp().getId()).isActive(IsActive.Active); + DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().ids(model.getDmp().getId()).isActive(IsActive.Active); DmpLookup dmpLookup = getDmpLookup(); Dmp dmp = this.builderFactory.builder(DmpBuilder.class).build(dmpLookup.getProject(), dmpQuery.firstAs(dmpLookup.getProject())); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDmpsDocumentation.java b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDmpsDocumentation.java index bde3aefac..9dc7f0b9d 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDmpsDocumentation.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDmpsDocumentation.java @@ -106,7 +106,7 @@ public class PublicDmpsDocumentation { ) throws Exception { DmpLookup lookup = getDmpLookup(fieldsGroup, dmpTableRequest); DmpQuery query = lookup.enrich(this.queryFactory).authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active); - long count = this.queryFactory.query(DmpQuery.class).authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active).count(); + long count = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active).count(); List data = query.collectAs(lookup.getProject()); List models = this.builderFactory.builder(DmpBuilder.class).build(lookup.getProject(), data); @@ -192,13 +192,13 @@ public class PublicDmpsDocumentation { Dmp._finalizedAt ); dmpFieldSet.setFields(dmpFields); - DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(EnumSet.of(AuthorizationFlags.Public)).ids(UUID.fromString(id)).isActive(IsActive.Active); + DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(EnumSet.of(AuthorizationFlags.Public)).ids(UUID.fromString(id)).isActive(IsActive.Active); Dmp model = this.builderFactory.builder(DmpBuilder.class).build(dmpFieldSet, query.firstAs(dmpFieldSet)); if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); - EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).entityIds(UUID.fromString(id)).isActive(IsActive.Active); + EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().entityIds(UUID.fromString(id)).isActive(IsActive.Active); BaseFieldSet templateFieldSet = new BaseFieldSet(); - DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(UUID.fromString(id)).isActive(IsActive.Active); + DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().dmpIds(UUID.fromString(id)).isActive(IsActive.Active); List descriptionTemplates = this.builderFactory.builder(DmpDescriptionTemplateBuilder.class).build(templateFieldSet, dmpDescriptionTemplateQuery.collectAs(templateFieldSet)); DataManagementPlanPublicModel dataManagementPlan = this.dmpToPublicApiDmpMapper.toPublicModel(model, entityDoiQuery.collect(), descriptionTemplates, this.config.getReferenceTypeMap()); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));