diff --git a/backend/core/src/main/java/org/opencdmp/audit/AuditableAction.java b/backend/core/src/main/java/org/opencdmp/audit/AuditableAction.java index c498f903d..bcb01ecb5 100644 --- a/backend/core/src/main/java/org/opencdmp/audit/AuditableAction.java +++ b/backend/core/src/main/java/org/opencdmp/audit/AuditableAction.java @@ -14,39 +14,39 @@ public class AuditableAction { public static final EventId EntityDoi_Persist = new EventId(2002, "EntityDoi_Persist"); public static final EventId EntityDoi_Delete = new EventId(2003, "EntityDoi_Delete"); - public static final EventId DmpBlueprint_Query = new EventId(3000, "DmpBlueprint_Query"); - public static final EventId DmpBlueprint_Lookup = new EventId(3001, "DmpBlueprint_Lookup"); - public static final EventId DmpBlueprint_Persist = new EventId(3002, "DmpBlueprint_Persist"); - public static final EventId DmpBlueprint_Delete = new EventId(3003, "DmpBlueprint_Delete"); - public static final EventId DmpBlueprint_Clone = new EventId(3004, "DmpBlueprint_Clone"); + public static final EventId PlanBlueprint_Query = new EventId(3000, "PlanBlueprint_Query"); + public static final EventId PlanBlueprint_Lookup = new EventId(3001, "PlanBlueprint_Lookup"); + public static final EventId PlanBlueprint_Persist = new EventId(3002, "PlanBlueprint_Persist"); + public static final EventId PlanBlueprint_Delete = new EventId(3003, "PlanBlueprint_Delete"); + public static final EventId PlanBlueprint_Clone = new EventId(3004, "PlanBlueprint_Clone"); - public static final EventId DmpBlueprint_PersistNewVersion = new EventId(3005, "DmpBlueprint_PersistNewVersion"); - public static final EventId DmpBlueprint_GetXml = new EventId(3006, "DmpBlueprint_GetXml"); - public static final EventId DmpBlueprint_Import = new EventId(3007, "DmpBlueprint_Import"); + public static final EventId PlanBlueprint_PersistNewVersion = new EventId(3005, "PlanBlueprint_PersistNewVersion"); + public static final EventId PlanBlueprint_GetXml = new EventId(3006, "PlanBlueprint_GetXml"); + public static final EventId PlanBlueprint_Import = new EventId(3007, "PlanBlueprint_Import"); public static final EventId User_Settings_Query = new EventId(4000, "User_Settings_Query"); public static final EventId User_Settings_Lookup = new EventId(4001, "User_Settings_Lookup"); public static final EventId User_Settings_Persist = new EventId(4002, "User_Settings_Persist"); public static final EventId User_Settings_Delete = new EventId(4003, "User_Settings_Delete"); - public static final EventId Dmp_Query = new EventId(5000, "Dmp_Query"); - public static final EventId Dmp_Lookup = new EventId(5001, "Dmp_Lookup"); - public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist"); - public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete"); - public static final EventId Dmp_Clone = new EventId(5004, "Dmp_Clone"); - public static final EventId Dmp_PersistNewVersion = new EventId(5005, "Dmp_PersistNewVersion"); - public static final EventId Dmp_Assign_Users = new EventId(5006, "Dmp_Assign_Users"); - public static final EventId Dmp_RemoveUser = new EventId(5007, "Dmp_RemoveUser"); - public static final EventId Dmp_Invite_Users = new EventId(5008, "Dmp_Invite_Users"); - public static final EventId Dmp_Invite_Accept = new EventId(5009, "Dmp_Invite_Accept"); - public static final EventId Dmp_PublicQuery = new EventId(5010, "Dmp_PublicQuery"); - public static final EventId Dmp_Export = new EventId(5011, "Dmp_Export"); - public static final EventId Dmp_PublicLookup = new EventId(5012, "Dmp_PublicLookup"); - public static final EventId Dmp_Finalize = new EventId(5013, "Dmp_Finalize"); - public static final EventId Dmp_Undo_Finalize = new EventId(5014, "Dmp_Undo_Finalize"); - public static final EventId Dmp_Validate = new EventId(5015, "Dmp_Validate"); - public static final EventId Dmp_GetXml = new EventId(5016, "Dmp_GetXml"); - public static final EventId Dmp_Import = new EventId(5017, "Dmp_Import"); + public static final EventId Plan_Query = new EventId(5000, "Plan_Query"); + public static final EventId Plan_Lookup = new EventId(5001, "Plan_Lookup"); + public static final EventId Plan_Persist = new EventId(5002, "Plan_Persist"); + public static final EventId Plan_Delete = new EventId(5003, "Plan_Delete"); + public static final EventId Plan_Clone = new EventId(5004, "Plan_Clone"); + public static final EventId Plan_PersistNewVersion = new EventId(5005, "Plan_PersistNewVersion"); + public static final EventId Plan_Assign_Users = new EventId(5006, "Plan_Assign_Users"); + public static final EventId Plan_RemoveUser = new EventId(5007, "Plan_RemoveUser"); + public static final EventId Plan_Invite_Users = new EventId(5008, "Plan_Invite_Users"); + public static final EventId Plan_Invite_Accept = new EventId(5009, "Plan_Invite_Accept"); + public static final EventId Plan_PublicQuery = new EventId(5010, "Plan_PublicQuery"); + public static final EventId Plan_Export = new EventId(5011, "Plan_Export"); + public static final EventId Plan_PublicLookup = new EventId(5012, "Plan_PublicLookup"); + public static final EventId Plan_Finalize = new EventId(5013, "Plan_Finalize"); + public static final EventId Plan_Undo_Finalize = new EventId(5014, "Plan_Undo_Finalize"); + public static final EventId Plan_Validate = new EventId(5015, "Plan_Validate"); + public static final EventId Plan_GetXml = new EventId(5016, "Plan_GetXml"); + public static final EventId Plan_Import = new EventId(5017, "Plan_Import"); public static final EventId Description_Query = new EventId(6000, "Description_Query"); @@ -102,7 +102,7 @@ public class AuditableAction { public static final EventId User_MergeConfirm = new EventId(11011, "User_MergeConfirm"); public static final EventId User_RemoveCredentialRequest = new EventId(11012, "User_RemoveCredentialRequest"); public static final EventId User_RemoveCredentialConfirm = new EventId(11013, "User_RemoveCredentialConfirm"); - public static final EventId User_DmpAssociatedQuery = new EventId(11014, "User_DmpAssociatedQuery"); + public static final EventId User_PlanAssociatedQuery = new EventId(11014, "User_PlanAssociatedQuery"); public static final EventId User_AllowMergeAccount = new EventId(11015, "User_AllowMergeAccount"); public static final EventId User_InviteToTenant = new EventId(11016, "User_InviteToTenant"); public static final EventId User_InviteToTenantConfirm = new EventId(11017, "User_InviteToTenantConfirm"); @@ -156,7 +156,7 @@ public class AuditableAction { public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic"); public static final EventId Maintenance_SendUserTouchEvents = new EventId(230001, "Maintenance_SendUserTouchEvents"); public static final EventId Maintenance_SendTenantTouchEvents = new EventId(230002, "Maintenance_SendTenantTouchEvents"); - public static final EventId Maintenance_SendDmpTouchEvents = new EventId(230003, "Maintenance_SendDmpTouchEvents"); + public static final EventId Maintenance_SendPlanTouchEvents = new EventId(230003, "Maintenance_SendPlanTouchEvents"); public static final EventId Maintenance_SendDescriptionTouchEvents = new EventId(230004, "Maintenance_SendDescriptionTouchEvents"); public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup"); diff --git a/backend/core/src/main/java/org/opencdmp/authorization/AffiliatedResource.java b/backend/core/src/main/java/org/opencdmp/authorization/AffiliatedResource.java index 7c5a1c53f..2b2ecde24 100644 --- a/backend/core/src/main/java/org/opencdmp/authorization/AffiliatedResource.java +++ b/backend/core/src/main/java/org/opencdmp/authorization/AffiliatedResource.java @@ -1,26 +1,26 @@ package org.opencdmp.authorization; import gr.cite.commons.web.authz.policy.AuthorizationResource; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.opencdmp.commons.enums.UserDescriptionTemplateRole; import java.util.HashSet; public class AffiliatedResource extends AuthorizationResource { - private HashSet dmpUserRoles; + private HashSet planUserRoles; private HashSet userDescriptionTemplateRoles; public AffiliatedResource() { - this.dmpUserRoles = new HashSet<>(); + this.planUserRoles = new HashSet<>(); this.userDescriptionTemplateRoles = new HashSet<>(); } - public HashSet getDmpUserRoles() { - return this.dmpUserRoles; + public HashSet getPlanUserRoles() { + return this.planUserRoles; } - public void setDmpUserRoles(HashSet dmpUserRoles) { - this.dmpUserRoles = dmpUserRoles; + public void setPlanUserRoles(HashSet planUserRoles) { + this.planUserRoles = planUserRoles; } public HashSet getUserDescriptionTemplateRoles() { diff --git a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java index 6f5f98f49..df9ac7e43 100644 --- a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java +++ b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java @@ -59,7 +59,7 @@ public final class Permission { public static String ExportUsers = "ExportUsers"; public static String EditTenantUserRole = "EditTenantUserRole"; public static String InviteTenantUser = "InviteTenantUser"; - public static String BrowseDmpAssociatedUser = "BrowseDmpAssociatedUser"; + public static String BrowsePlanAssociatedUser = "BrowsePlanAssociatedUser"; //StorageFile @@ -72,38 +72,38 @@ public final class Permission { public static String EditDescriptionTemplateType = "EditDescriptionTemplateType"; public static String DeleteDescriptionTemplateType = "DeleteDescriptionTemplateType"; - //Dmp - public static String BrowseDmp = "BrowseDmp"; - public static String EditDmp = "EditDmp"; - public static String NewDmp = "NewDmp"; - public static String DepositDmp = "DepositDmp"; - public static String DeleteDmp = "DeleteDmp"; - public static String CloneDmp = "CloneDmp"; - public static String ExportDmp = "ExportDmp"; - public static String CreateNewVersionDmp = "CreateNewVersionDmp"; - public static String FinalizeDmp = "FinalizeDmp"; - public static String UndoFinalizeDmp = "UndoFinalizeDmp"; - public static String AssignDmpUsers = "AssignDmpUsers"; - public static String InviteDmpUsers = "InviteDmpUsers"; + //Plan + public static String BrowsePlan = "BrowsePlan"; + public static String EditPlan = "EditPlan"; + public static String NewPlan = "NewPlan"; + public static String DepositPlan = "DepositPlan"; + public static String DeletePlan = "DeletePlan"; + public static String ClonePlan = "ClonePlan"; + public static String ExportPlan = "ExportPlan"; + public static String CreateNewVersionPlan = "CreateNewVersionPlan"; + public static String FinalizePlan = "FinalizePlan"; + public static String UndoFinalizePlan = "UndoFinalizePlan"; + public static String AssignPlanUsers = "AssignPlanUsers"; + public static String InvitePlanUsers = "InvitePlanUsers"; - //DmpBlueprint - public static String BrowseDmpBlueprint = "BrowseDmpBlueprint"; - public static String EditDmpBlueprint = "EditDmpBlueprint"; - public static String DeleteDmpBlueprint = "DeleteDmpBlueprint"; - public static String CloneDmpBlueprint = "CloneDmpBlueprint"; - public static String CreateNewVersionDmpBlueprint = "CreateNewVersionDmpBlueprint"; - public static String ExportDmpBlueprint = "ExportDmpBlueprint"; - public static String ImportDmpBlueprint = "ImportDmpBlueprint"; + //PlanBlueprint + public static String BrowsePlanBlueprint = "BrowsePlanBlueprint"; + public static String EditPlanBlueprint = "EditPlanBlueprint"; + public static String DeletePlanBlueprint = "DeletePlanBlueprint"; + public static String ClonePlanBlueprint = "ClonePlanBlueprint"; + public static String CreateNewVersionPlanBlueprint = "CreateNewVersionPlanBlueprint"; + public static String ExportPlanBlueprint = "ExportPlanBlueprint"; + public static String ImportPlanBlueprint = "ImportPlanBlueprint"; - //DmpDescriptionTemplate - public static String BrowseDmpDescriptionTemplate = "BrowseDmpDescriptionTemplate"; - public static String EditDmpDescriptionTemplate = "EditDmpDescriptionTemplate"; - public static String DeleteDmpDescriptionTemplate = "DeleteDmpDescriptionTemplate"; + //PlanDescriptionTemplate + public static String BrowsePlanDescriptionTemplate = "BrowsePlanDescriptionTemplate"; + public static String EditPlanDescriptionTemplate = "EditPlanDescriptionTemplate"; + public static String DeletePlanDescriptionTemplate = "DeletePlanDescriptionTemplate"; - //DmpUser - public static String BrowseDmpUser = "BrowseDmpUser"; - public static String EditDmpUser = "EditDmpUser"; - public static String DeleteDmpUser = "DeleteDmpUser"; + //PlanUser + public static String BrowsePlanUser = "BrowsePlanUser"; + public static String EditPlanUser = "EditPlanUser"; + public static String DeletePlanUser = "DeletePlanUser"; //Description public static String BrowseDescription = "BrowseDescription"; @@ -142,10 +142,10 @@ public final class Permission { public static String EditTag = "EditTag"; public static String DeleteTag = "DeleteTag"; - //DmpReference - public static String BrowseDmpReference = "BrowseDmpReference"; - public static String EditDmpReference = "EditDmpReference"; - public static String DeleteDmpReference = "DeleteDmpReference"; + //PlanReference + public static String BrowsePlanReference = "BrowsePlanReference"; + public static String EditPlanReference = "EditPlanReference"; + public static String DeletePlanReference = "DeletePlanReference"; //DescriptionReference public static String BrowseDescriptionReference = "BrowseDescriptionReference"; @@ -218,14 +218,14 @@ public final class Permission { public static String ViewTenantPage = "ViewTenantPage"; public static String ViewPrefillingSourcePage = "ViewPrefillingSourcePage"; public static String ViewReferenceTypePage = "ViewReferenceTypePage"; - public static String ViewReferencePage = "ViewReferencePage"; + public static String ViewReferencePaPlge = "ViewReferencePage"; public static String ViewEntityLockPage = "ViewEntityLockPage"; public static String ViewDescriptionTemplatePage = "ViewDescriptionTemplatePage"; - public static String ViewDmpBlueprintPage = "ViewDmpBlueprintPage"; + public static String ViewPlanBlueprintPage = "ViewPlanBlueprintPage"; public static String ViewPublicDescriptionPage = "ViewPublicDescriptionPage"; public static String ViewPublicDmpPage = "ViewPublicDmpPage"; public static String ViewMyDescriptionPage = "ViewMyDescriptionPage"; - public static String ViewMyDmpPage = "ViewMyDmpPage"; + public static String ViewMyPlanPage = "ViewMyPlanPage"; public static String ViewHomePage = "ViewHomePage"; public static String ViewMineInAppNotificationPage = "ViewMineInAppNotificationPage"; public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage"; diff --git a/backend/core/src/main/java/org/opencdmp/authorization/authorizationcontentresolver/AuthorizationContentResolver.java b/backend/core/src/main/java/org/opencdmp/authorization/authorizationcontentresolver/AuthorizationContentResolver.java index 3e38bd9d9..3baf91b5b 100644 --- a/backend/core/src/main/java/org/opencdmp/authorization/authorizationcontentresolver/AuthorizationContentResolver.java +++ b/backend/core/src/main/java/org/opencdmp/authorization/authorizationcontentresolver/AuthorizationContentResolver.java @@ -23,7 +23,7 @@ public interface AuthorizationContentResolver { Map descriptionsAffiliation(List ids); - AffiliatedResource descriptionsAffiliationBySection(UUID dmpId, UUID sectionId); + AffiliatedResource descriptionsAffiliationBySection(UUID planId, UUID sectionId); - Map descriptionsAffiliationBySections(UUID dmpId, List sectionIds); + Map descriptionsAffiliationBySections(UUID planId, List sectionIds); } 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 25cd25865..5e6621364 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 @@ -10,13 +10,13 @@ import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.data.*; -import org.opencdmp.model.DmpDescriptionTemplate; -import org.opencdmp.model.DmpUser; +import org.opencdmp.model.PlanDescriptionTemplate; +import org.opencdmp.model.PlanUser; import org.opencdmp.model.UserDescriptionTemplate; import org.opencdmp.model.description.Description; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; -import org.opencdmp.query.DmpUserQuery; +import org.opencdmp.query.PlanDescriptionTemplateQuery; +import org.opencdmp.query.PlanUserQuery; import org.opencdmp.query.UserDescriptionTemplateQuery; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,12 +65,12 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes } if (userId == null || !this.userScope.isSet()) return affiliatedResources; - List idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DmpEntity.class.getSimpleName()); + List idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, PlanEntity.class.getSimpleName()); if (idsToResolve.isEmpty()) return affiliatedResources; - List dmpUsers; + List dmpUsers; try { this.tenantEntityManager.loadExplictTenantFilters(); - 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)); + dmpUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(ids).sectionIsEmpty(true).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(PlanUser._role).ensure(PlanUser._plan)); } catch (InvalidApplicationException e) { log.error(e.getMessage(), e); throw new MyApplicationException(e.getMessage()); @@ -82,11 +82,11 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes throw new MyApplicationException(e.getMessage()); } } - for (DmpUserEntity dmpUser : dmpUsers){ - affiliatedResources.get(dmpUser.getDmpId()).getDmpUserRoles().add(dmpUser.getRole()); + for (PlanUserEntity dmpUser : dmpUsers){ + affiliatedResources.get(dmpUser.getPlanId()).getPlanUserRoles().add(dmpUser.getRole()); } - this.ensureAffiliatedInCache(idsToResolve, userId, affiliatedResources, DmpEntity.class.getSimpleName()); + this.ensureAffiliatedInCache(idsToResolve, userId, affiliatedResources, PlanEntity.class.getSimpleName()); return affiliatedResources; } @@ -172,14 +172,14 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes List idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DescriptionEntity.class.getSimpleName()); if (idsToResolve.isEmpty()) return affiliatedResources; - List dmpDescriptionTemplateEntities; - List dmpUsers; + List planDescriptionTemplateEntities; + List planUsers; List descriptionEntities; try { this.tenantEntityManager.loadExplictTenantFilters(); - descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(ids).collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._dmpDescriptionTemplate).ensure(Description._dmp)); - dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(descriptionEntities.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().toList()).collectAs(new BaseFieldSet().ensure(DmpDescriptionTemplate._id).ensure(DmpDescriptionTemplate._sectionId)); - 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)); + descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(ids).collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._planDescriptionTemplate).ensure(Description._plan)); + planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(descriptionEntities.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().toList()).collectAs(new BaseFieldSet().ensure(PlanDescriptionTemplate._id).ensure(PlanDescriptionTemplate._sectionId)); + planUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().descriptionIds(ids).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(PlanUser._role).ensure(PlanUser._sectionId).ensure(PlanUser._plan)); } catch (InvalidApplicationException e) { log.error(e.getMessage(), e); @@ -195,17 +195,17 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes - Map dmpDescriptionTemplateEntityMap = dmpDescriptionTemplateEntities == null ? new HashMap<>() : dmpDescriptionTemplateEntities.stream().collect(Collectors.toMap(DmpDescriptionTemplateEntity::getId, x-> x)); - Map> dmpUsersMap = dmpUsers.stream().collect(Collectors.groupingBy(DmpUserEntity::getDmpId)); + Map planDescriptionTemplateEntityMap = planDescriptionTemplateEntities == null ? new HashMap<>() : planDescriptionTemplateEntities.stream().collect(Collectors.toMap(PlanDescriptionTemplateEntity::getId, x-> x)); + Map> planUsersMap = planUsers.stream().collect(Collectors.groupingBy(PlanUserEntity::getPlanId)); for (DescriptionEntity description : descriptionEntities){ - List dmpDescriptionUsers = dmpUsersMap.getOrDefault(description.getDmpId(), new ArrayList<>()); - for (DmpUserEntity dmpUser : dmpDescriptionUsers) { - if (dmpUser.getSectionId() == null) affiliatedResources.get(description.getId()).getDmpUserRoles().add(dmpUser.getRole()); + List dmpDescriptionUsers = planUsersMap.getOrDefault(description.getPlanId(), new ArrayList<>()); + for (PlanUserEntity dmpUser : dmpDescriptionUsers) { + if (dmpUser.getSectionId() == null) affiliatedResources.get(description.getId()).getPlanUserRoles().add(dmpUser.getRole()); else { - DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = dmpDescriptionTemplateEntityMap.getOrDefault(description.getDmpDescriptionTemplateId(), null); - if (dmpDescriptionTemplateEntity != null && dmpUser.getSectionId().equals(dmpDescriptionTemplateEntity.getSectionId())){ - affiliatedResources.get(description.getId()).getDmpUserRoles().add(dmpUser.getRole()); + PlanDescriptionTemplateEntity planDescriptionTemplateEntity = planDescriptionTemplateEntityMap.getOrDefault(description.getPlanDescriptionTemplateId(), null); + if (planDescriptionTemplateEntity != null && dmpUser.getSectionId().equals(planDescriptionTemplateEntity.getSectionId())){ + affiliatedResources.get(description.getId()).getPlanUserRoles().add(dmpUser.getRole()); } } } @@ -216,12 +216,12 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes } @Override - public AffiliatedResource descriptionsAffiliationBySection(UUID dmpId, UUID sectionId){ - return this.descriptionsAffiliationBySections(dmpId, List.of(sectionId)).getOrDefault(sectionId, new AffiliatedResource()); + public AffiliatedResource descriptionsAffiliationBySection(UUID planId, UUID sectionId){ + return this.descriptionsAffiliationBySections(planId, List.of(sectionId)).getOrDefault(sectionId, new AffiliatedResource()); } @Override - public Map descriptionsAffiliationBySections(UUID dmpId, List sectionIds){ + public Map descriptionsAffiliationBySections(UUID planId, List sectionIds){ UUID userId = this.userScope.getUserIdSafe(); Map affiliatedResources = new HashMap<>(); for (UUID id : sectionIds){ @@ -230,10 +230,10 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes if (userId == null || !this.userScope.isSet()) return affiliatedResources; - List dmpUsers; + List dmpUsers; try { this.tenantEntityManager.loadExplictTenantFilters(); - 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)); + dmpUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(planId).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(PlanUser._role).ensure(PlanUser._sectionId).ensure(PlanUser._plan)); } catch (InvalidApplicationException e) { log.error(e.getMessage(), e); throw new MyApplicationException(e.getMessage()); @@ -247,12 +247,12 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes } for (UUID sectionId : sectionIds.stream().distinct().toList()){ - List dmpSectionUsers = dmpUsers.stream().filter(x-> x.getSectionId() == null || x.getSectionId().equals(sectionId)).toList(); - for (DmpUserEntity dmpUser : dmpSectionUsers) { - if (dmpUser.getSectionId() == null) affiliatedResources.get(sectionId).getDmpUserRoles().add(dmpUser.getRole()); + List dmpSectionUsers = dmpUsers.stream().filter(x-> x.getSectionId() == null || x.getSectionId().equals(sectionId)).toList(); + for (PlanUserEntity dmpUser : dmpSectionUsers) { + if (dmpUser.getSectionId() == null) affiliatedResources.get(sectionId).getPlanUserRoles().add(dmpUser.getRole()); else { if (dmpUser.getSectionId().equals(sectionId)){ - affiliatedResources.get(sectionId).getDmpUserRoles().add(dmpUser.getRole()); + affiliatedResources.get(sectionId).getPlanUserRoles().add(dmpUser.getRole()); } } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/ActionConfirmationType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/ActionConfirmationType.java index 237ab3f7a..d5cc7382a 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/ActionConfirmationType.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/ActionConfirmationType.java @@ -9,7 +9,7 @@ public enum ActionConfirmationType implements DatabaseEnum { MergeAccount((short) 0), RemoveCredential((short) 1), - DmpInvitation((short) 2), + PlanInvitation((short) 2), UserInviteToTenant ((short) 3); private final Short value; diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintExtraFieldDataType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintExtraFieldDataType.java deleted file mode 100644 index c36a4c0e2..000000000 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintExtraFieldDataType.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.opencdmp.commons.enums; - -import com.fasterxml.jackson.annotation.JsonValue; -import org.opencdmp.data.converters.enums.DatabaseEnum; - -import java.util.Map; - -public enum DmpBlueprintExtraFieldDataType implements DatabaseEnum { - - Text((short) 0), - RichTex((short) 1), - Date((short) 2), - Number((short) 3), - ; - - private final Short value; - - DmpBlueprintExtraFieldDataType(Short value) { - this.value = value; - } - - @JsonValue - public Short getValue() { - return value; - } - - private static final Map map = EnumUtils.getEnumValueMap(DmpBlueprintExtraFieldDataType.class); - - public static DmpBlueprintExtraFieldDataType of(Short i) { - return map.get(i); - } - - public static boolean isTextType(DmpBlueprintExtraFieldDataType fieldType){ - return fieldType.equals(DmpBlueprintExtraFieldDataType.Text) || fieldType.equals(DmpBlueprintExtraFieldDataType.RichTex); - } - - public static boolean isDateType(DmpBlueprintExtraFieldDataType fieldType){ - return fieldType.equals(DmpBlueprintExtraFieldDataType.Date); - } - - public static boolean isNumberType(DmpBlueprintExtraFieldDataType fieldType){ - return fieldType.equals(DmpBlueprintExtraFieldDataType.Number); - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpAccessType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanAccessType.java similarity index 62% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpAccessType.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanAccessType.java index 9418774db..bb241e5d9 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpAccessType.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanAccessType.java @@ -5,13 +5,13 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpAccessType implements DatabaseEnum { +public enum PlanAccessType implements DatabaseEnum { Public((short) 0), Restricted((short) 1); private final Short value; - DmpAccessType(Short value) { + PlanAccessType(Short value) { this.value = value; } @@ -21,9 +21,9 @@ public enum DmpAccessType implements DatabaseEnum { return value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpAccessType.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanAccessType.class); - public static DmpAccessType of(Short i) { + public static PlanAccessType of(Short i) { return map.get(i); } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintExtraFieldDataType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintExtraFieldDataType.java new file mode 100644 index 000000000..e00c6bc41 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintExtraFieldDataType.java @@ -0,0 +1,45 @@ +package org.opencdmp.commons.enums; + +import com.fasterxml.jackson.annotation.JsonValue; +import org.opencdmp.data.converters.enums.DatabaseEnum; + +import java.util.Map; + +public enum PlanBlueprintExtraFieldDataType implements DatabaseEnum { + + Text((short) 0), + RichTex((short) 1), + Date((short) 2), + Number((short) 3), + ; + + private final Short value; + + PlanBlueprintExtraFieldDataType(Short value) { + this.value = value; + } + + @JsonValue + public Short getValue() { + return value; + } + + private static final Map map = EnumUtils.getEnumValueMap(PlanBlueprintExtraFieldDataType.class); + + public static PlanBlueprintExtraFieldDataType of(Short i) { + return map.get(i); + } + + public static boolean isTextType(PlanBlueprintExtraFieldDataType fieldType){ + return fieldType.equals(PlanBlueprintExtraFieldDataType.Text) || fieldType.equals(PlanBlueprintExtraFieldDataType.RichTex); + } + + public static boolean isDateType(PlanBlueprintExtraFieldDataType fieldType){ + return fieldType.equals(PlanBlueprintExtraFieldDataType.Date); + } + + public static boolean isNumberType(PlanBlueprintExtraFieldDataType fieldType){ + return fieldType.equals(PlanBlueprintExtraFieldDataType.Number); + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintFieldCategory.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintFieldCategory.java similarity index 67% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintFieldCategory.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintFieldCategory.java index 2db7c80b2..5faffe198 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintFieldCategory.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintFieldCategory.java @@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpBlueprintFieldCategory implements DatabaseEnum { +public enum PlanBlueprintFieldCategory implements DatabaseEnum { System((short) 0), Extra((short) 1), ReferenceType((short) 2); @@ -18,7 +18,7 @@ public enum DmpBlueprintFieldCategory implements DatabaseEnum { private final Short value; - DmpBlueprintFieldCategory(Short value) { + PlanBlueprintFieldCategory(Short value) { this.value = value; } @@ -27,9 +27,9 @@ public enum DmpBlueprintFieldCategory implements DatabaseEnum { return value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpBlueprintFieldCategory.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanBlueprintFieldCategory.class); - public static DmpBlueprintFieldCategory of(Short i) { + public static PlanBlueprintFieldCategory of(Short i) { return map.get(i); } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintStatus.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintStatus.java similarity index 59% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintStatus.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintStatus.java index d82f48001..8e1045750 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintStatus.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintStatus.java @@ -5,14 +5,14 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpBlueprintStatus implements DatabaseEnum { +public enum PlanBlueprintStatus implements DatabaseEnum { Draft((short) 0), Finalized((short) 1); private final Short value; - DmpBlueprintStatus(Short value) { + PlanBlueprintStatus(Short value) { this.value = value; } @@ -21,9 +21,9 @@ public enum DmpBlueprintStatus implements DatabaseEnum { return value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpBlueprintStatus.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanBlueprintStatus.class); - public static DmpBlueprintStatus of(Short i) { + public static PlanBlueprintStatus of(Short i) { return map.get(i); } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintSystemFieldType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintSystemFieldType.java similarity index 60% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintSystemFieldType.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintSystemFieldType.java index a04509453..63b8a2db9 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintSystemFieldType.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintSystemFieldType.java @@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpBlueprintSystemFieldType implements DatabaseEnum { +public enum PlanBlueprintSystemFieldType implements DatabaseEnum { Title((short)0), Description((short)1), @@ -15,7 +15,7 @@ public enum DmpBlueprintSystemFieldType implements DatabaseEnum { User((short)5); private final Short value; - DmpBlueprintSystemFieldType(Short value) { + PlanBlueprintSystemFieldType(Short value) { this.value = value; } @@ -24,9 +24,9 @@ public enum DmpBlueprintSystemFieldType implements DatabaseEnum { return value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpBlueprintSystemFieldType.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanBlueprintSystemFieldType.class); - public static DmpBlueprintSystemFieldType of(Short i) { + public static PlanBlueprintSystemFieldType of(Short i) { return map.get(i); } } \ No newline at end of file diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintVersionStatus.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintVersionStatus.java similarity index 58% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintVersionStatus.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintVersionStatus.java index 80fa6c976..2cfa01223 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpBlueprintVersionStatus.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanBlueprintVersionStatus.java @@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpBlueprintVersionStatus implements DatabaseEnum { +public enum PlanBlueprintVersionStatus implements DatabaseEnum { Current((short) 0), Previous((short) 1), @@ -13,7 +13,7 @@ public enum DmpBlueprintVersionStatus implements DatabaseEnum { private final Short value; - DmpBlueprintVersionStatus(Short value) { + PlanBlueprintVersionStatus(Short value) { this.value = value; } @@ -23,9 +23,9 @@ public enum DmpBlueprintVersionStatus implements DatabaseEnum { return value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpBlueprintVersionStatus.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanBlueprintVersionStatus.class); - public static DmpBlueprintVersionStatus of(Short i) { + public static PlanBlueprintVersionStatus of(Short i) { return map.get(i); } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpStatus.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanStatus.java similarity index 64% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpStatus.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanStatus.java index 0cb33f250..7254750aa 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpStatus.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanStatus.java @@ -5,13 +5,13 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpStatus implements DatabaseEnum { +public enum PlanStatus implements DatabaseEnum { Draft((short) 0), Finalized((short) 1); private final Short value; - DmpStatus(Short value) { + PlanStatus(Short value) { this.value = value; } @@ -21,9 +21,9 @@ public enum DmpStatus implements DatabaseEnum { return value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpStatus.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanStatus.class); - public static DmpStatus of(Short i) { + public static PlanStatus of(Short i) { return map.get(i); } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpUserRole.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanUserRole.java similarity index 66% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpUserRole.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanUserRole.java index a8c8e252b..9c0ae19a6 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpUserRole.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanUserRole.java @@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpUserRole implements DatabaseEnum { +public enum PlanUserRole implements DatabaseEnum { Owner((short) 0), Viewer((short) 1), @@ -14,7 +14,7 @@ public enum DmpUserRole implements DatabaseEnum { private final Short value; - DmpUserRole(Short value) { + PlanUserRole(Short value) { this.value = value; } @@ -24,9 +24,9 @@ public enum DmpUserRole implements DatabaseEnum { return this.value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpUserRole.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanUserRole.class); - public static DmpUserRole of(Short i) { + public static PlanUserRole of(Short i) { return map.get(i); } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpValidationOutput.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanValidationOutput.java similarity index 58% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpValidationOutput.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanValidationOutput.java index 2245df5b6..a770660e3 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpValidationOutput.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanValidationOutput.java @@ -5,14 +5,14 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpValidationOutput implements DatabaseEnum { +public enum PlanValidationOutput implements DatabaseEnum { Valid((short) 1), Invalid((short) 2); private final Short value; - DmpValidationOutput(Short value) { + PlanValidationOutput(Short value) { this.value = value; } @@ -21,9 +21,9 @@ public enum DmpValidationOutput implements DatabaseEnum { return value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpValidationOutput.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanValidationOutput.class); - public static DmpValidationOutput of(Short i) { + public static PlanValidationOutput of(Short i) { return map.get(i); } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpVersionStatus.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanVersionStatus.java similarity index 62% rename from backend/core/src/main/java/org/opencdmp/commons/enums/DmpVersionStatus.java rename to backend/core/src/main/java/org/opencdmp/commons/enums/PlanVersionStatus.java index af6601322..70ad4a31d 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpVersionStatus.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanVersionStatus.java @@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum; import java.util.Map; -public enum DmpVersionStatus implements DatabaseEnum { +public enum PlanVersionStatus implements DatabaseEnum { Current((short) 0), Previous((short) 1), @@ -13,7 +13,7 @@ public enum DmpVersionStatus implements DatabaseEnum { private final Short value; - DmpVersionStatus(Short value) { + PlanVersionStatus(Short value) { this.value = value; } @@ -23,9 +23,9 @@ public enum DmpVersionStatus implements DatabaseEnum { return value; } - private static final Map map = EnumUtils.getEnumValueMap(DmpVersionStatus.class); + private static final Map map = EnumUtils.getEnumValueMap(PlanVersionStatus.class); - public static DmpVersionStatus of(Short i) { + public static PlanVersionStatus of(Short i) { return map.get(i); } diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/RecentActivityItemType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/RecentActivityItemType.java index e752e2c85..be6214eb9 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/RecentActivityItemType.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/RecentActivityItemType.java @@ -7,7 +7,7 @@ import java.util.Map; public enum RecentActivityItemType implements DatabaseEnum { - Dmp((short) 0), + Plan((short) 0), Description((short) 1); private final Short value; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/actionconfirmation/DmpInvitationEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/actionconfirmation/PlanInvitationEntity.java similarity index 60% rename from backend/core/src/main/java/org/opencdmp/commons/types/actionconfirmation/DmpInvitationEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/actionconfirmation/PlanInvitationEntity.java index e01d2ccc6..95c65b086 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/actionconfirmation/DmpInvitationEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/actionconfirmation/PlanInvitationEntity.java @@ -1,22 +1,22 @@ package org.opencdmp.commons.types.actionconfirmation; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import jakarta.xml.bind.annotation.*; import java.util.UUID; @XmlRootElement(name = "dmp-invitation") @XmlAccessorType(XmlAccessType.FIELD) -public class DmpInvitationEntity { +public class PlanInvitationEntity { @XmlAttribute(name = "email") private String email; @XmlAttribute(name = "dmp") - private UUID dmpId; + private UUID planId; @XmlAttribute(name = "dmp-role") - private DmpUserRole role; + private PlanUserRole role; public String getEmail() { return email; @@ -26,19 +26,19 @@ public class DmpInvitationEntity { this.email = email; } - public UUID getDmpId() { - return dmpId; + public UUID getPlanId() { + return planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } - public DmpUserRole getRole() { + public PlanUserRole getRole() { return role; } - public void setRole(DmpUserRole role) { + public void setRole(PlanUserRole role) { this.role = role; } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpPropertiesEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpPropertiesEntity.java deleted file mode 100644 index f32378fec..000000000 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpPropertiesEntity.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.opencdmp.commons.types.dmp; - -import java.util.List; - -public class DmpPropertiesEntity { - - private List dmpBlueprintValues; - - private List contacts; - - public List getDmpBlueprintValues() { - return this.dmpBlueprintValues; - } - - public void setDmpBlueprintValues(List dmpBlueprintValues) { - this.dmpBlueprintValues = dmpBlueprintValues; - } - - public List getContacts() { - return this.contacts; - } - - public void setContacts(List contacts) { - this.contacts = contacts; - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/ExtraFieldEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/ExtraFieldEntity.java deleted file mode 100644 index 9196add10..000000000 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/ExtraFieldEntity.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.opencdmp.commons.types.dmpblueprint; - -import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import org.w3c.dom.Element; - -@XmlAccessorType(XmlAccessType.FIELD) -public class ExtraFieldEntity extends FieldEntity { - - @XmlAttribute(name="type") - private DmpBlueprintExtraFieldDataType type; - - public DmpBlueprintExtraFieldDataType getType() { - return type; - } - public void setType(DmpBlueprintExtraFieldDataType type) { - this.type = type; - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpBlueprintValueEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanBlueprintValueEntity.java similarity index 90% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpBlueprintValueEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanBlueprintValueEntity.java index 1814f72c5..1223ec31e 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpBlueprintValueEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanBlueprintValueEntity.java @@ -1,9 +1,9 @@ -package org.opencdmp.commons.types.dmp; +package org.opencdmp.commons.types.plan; import java.time.Instant; import java.util.UUID; -public class DmpBlueprintValueEntity { +public class PlanBlueprintValueEntity { private UUID fieldId; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpContactEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanContactEntity.java similarity index 88% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpContactEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanContactEntity.java index 9bdefd8be..dd4826162 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/DmpContactEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanContactEntity.java @@ -1,7 +1,7 @@ -package org.opencdmp.commons.types.dmp; +package org.opencdmp.commons.types.plan; -public class DmpContactEntity { +public class PlanContactEntity { private String firstName; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanPropertiesEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanPropertiesEntity.java new file mode 100644 index 000000000..1c9bb9fdf --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/PlanPropertiesEntity.java @@ -0,0 +1,27 @@ +package org.opencdmp.commons.types.plan; + +import java.util.List; + +public class PlanPropertiesEntity { + + private List planBlueprintValues; + + private List contacts; + + public List getPlanBlueprintValues() { + return this.planBlueprintValues; + } + + public void setPlanBlueprintValues(List planBlueprintValues) { + this.planBlueprintValues = planBlueprintValues; + } + + public List getContacts() { + return this.contacts; + } + + public void setContacts(List contacts) { + this.contacts = contacts; + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpBlueprintValueImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanBlueprintValueImportExport.java similarity index 92% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpBlueprintValueImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanBlueprintValueImportExport.java index f31ad5b6c..f6693ed8e 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpBlueprintValueImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanBlueprintValueImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmp.importexport; +package org.opencdmp.commons.types.plan.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; @@ -11,7 +11,7 @@ import java.util.UUID; @XmlAccessorType(XmlAccessType.FIELD) -public class DmpBlueprintValueImportExport { +public class PlanBlueprintValueImportExport { @XmlElement(name = "fieldId") private UUID fieldId; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpContactImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanContactImportExport.java similarity index 91% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpContactImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanContactImportExport.java index 8cd41a94a..014b41098 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpContactImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanContactImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmp.importexport; +package org.opencdmp.commons.types.plan.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; @@ -6,7 +6,7 @@ import jakarta.xml.bind.annotation.XmlElement; @XmlAccessorType(XmlAccessType.FIELD) -public class DmpContactImportExport { +public class PlanContactImportExport { @XmlElement(name = "name") private String name; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpDescriptionTemplateImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanDescriptionTemplateImportExport.java similarity index 88% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpDescriptionTemplateImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanDescriptionTemplateImportExport.java index b066aed0d..bb2b8af23 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpDescriptionTemplateImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanDescriptionTemplateImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmp.importexport; +package org.opencdmp.commons.types.plan.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; @@ -7,7 +7,7 @@ import jakarta.xml.bind.annotation.XmlElement; import java.util.UUID; @XmlAccessorType(XmlAccessType.FIELD) -public class DmpDescriptionTemplateImportExport { +public class PlanDescriptionTemplateImportExport { @XmlElement(name = "descriptionTemplateGroupId") private UUID descriptionTemplateGroupId; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanImportExport.java similarity index 72% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanImportExport.java index 9c9868b2d..1b8800ca5 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanImportExport.java @@ -1,10 +1,10 @@ -package org.opencdmp.commons.types.dmp.importexport; +package org.opencdmp.commons.types.plan.importexport; import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.opencdmp.commons.enums.DmpAccessType; +import org.opencdmp.commons.enums.PlanAccessType; import org.opencdmp.commons.types.description.importexport.DescriptionImportExport; -import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintImportExport; +import org.opencdmp.commons.types.planblueprint.importexport.BlueprintImportExport; import org.opencdmp.commons.xmladapter.InstantXmlAdapter; import java.time.Instant; @@ -13,7 +13,7 @@ import java.util.UUID; @XmlRootElement(name = "dmp") @XmlAccessorType(XmlAccessType.FIELD) -public class DmpImportExport { +public class PlanImportExport { @XmlElement(name = "id") private UUID id; @@ -28,18 +28,18 @@ public class DmpImportExport { private String language; @XmlElement(name = "access") - private DmpAccessType access; + private PlanAccessType access; @XmlElement(name = "version") private Short version; @XmlElementWrapper(name = "contacts") @XmlElement(name = "contact") - private List contacts; + private List contacts; @XmlElementWrapper(name = "users") @XmlElement(name = "user") - private List users; + private List users; @XmlElement(name = "finalizedAt") @XmlJavaTypeAdapter(InstantXmlAdapter.class) @@ -54,15 +54,15 @@ public class DmpImportExport { @XmlElementWrapper(name = "blueprintValues") @XmlElement(name = "blueprintValue") - private List blueprintValues; + private List blueprintValues; @XmlElementWrapper(name = "descriptionTemplates") @XmlElement(name = "descriptionTemplate") - private List descriptionTemplates; + private List descriptionTemplates; @XmlElementWrapper(name = "references") @XmlElement(name = "reference") - private List references; + private List references; @XmlElementWrapper(name = "descriptions") @XmlElement(name = "description") @@ -101,27 +101,27 @@ public class DmpImportExport { } - public DmpAccessType getAccess() { + public PlanAccessType getAccess() { return this.access; } - public void setAccess(DmpAccessType access) { + public void setAccess(PlanAccessType access) { this.access = access; } - public List getContacts() { + public List getContacts() { return this.contacts; } - public void setContacts(List contacts) { + public void setContacts(List contacts) { this.contacts = contacts; } - public List getUsers() { + public List getUsers() { return this.users; } - public void setUsers(List users) { + public void setUsers(List users) { this.users = users; } @@ -149,27 +149,27 @@ public class DmpImportExport { this.blueprint = blueprint; } - public List getBlueprintValues() { + public List getBlueprintValues() { return this.blueprintValues; } - public void setBlueprintValues(List blueprintValues) { + public void setBlueprintValues(List blueprintValues) { this.blueprintValues = blueprintValues; } - public List getDescriptionTemplates() { + public List getDescriptionTemplates() { return this.descriptionTemplates; } - public void setDescriptionTemplates(List descriptionTemplates) { + public void setDescriptionTemplates(List descriptionTemplates) { this.descriptionTemplates = descriptionTemplates; } - public List getReferences() { + public List getReferences() { return this.references; } - public void setReferences(List references) { + public void setReferences(List references) { this.references = references; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpReferenceImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanReferenceImportExport.java similarity index 86% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpReferenceImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanReferenceImportExport.java index 3cb6ed966..fe6ab6154 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpReferenceImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanReferenceImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmp.importexport; +package org.opencdmp.commons.types.plan.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; @@ -8,7 +8,7 @@ import org.opencdmp.commons.enums.ReferenceSourceType; import java.util.UUID; @XmlAccessorType(XmlAccessType.FIELD) -public class DmpReferenceImportExport { +public class PlanReferenceImportExport { @XmlElement(name = "id") private UUID id; @@ -19,7 +19,7 @@ public class DmpReferenceImportExport { @XmlElement(name = "fieldId") private UUID fieldId; @XmlElement(name = "type") - private DmpReferenceTypeImportExport type; + private PlanReferenceTypeImportExport type; @XmlElement(name = "source") private String source; @XmlElement(name = "sourceType") @@ -49,11 +49,11 @@ public class DmpReferenceImportExport { this.reference = reference; } - public DmpReferenceTypeImportExport getType() { + public PlanReferenceTypeImportExport getType() { return this.type; } - public void setType(DmpReferenceTypeImportExport type) { + public void setType(PlanReferenceTypeImportExport type) { this.type = type; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpReferenceTypeImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanReferenceTypeImportExport.java similarity index 79% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpReferenceTypeImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanReferenceTypeImportExport.java index c1f4de9ea..f6f5f2825 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpReferenceTypeImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanReferenceTypeImportExport.java @@ -1,15 +1,13 @@ -package org.opencdmp.commons.types.dmp.importexport; +package org.opencdmp.commons.types.plan.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlElement; -import org.opencdmp.commons.enums.DmpUserRole; import java.util.UUID; @XmlAccessorType(XmlAccessType.FIELD) -public class DmpReferenceTypeImportExport { +public class PlanReferenceTypeImportExport { @XmlElement(name = "id") private UUID id; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpUserImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanUserImportExport.java similarity index 78% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpUserImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanUserImportExport.java index 49c5a6d4c..29868289f 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpUserImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanUserImportExport.java @@ -1,14 +1,14 @@ -package org.opencdmp.commons.types.dmp.importexport; +package org.opencdmp.commons.types.plan.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlElement; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import java.util.UUID; @XmlAccessorType(XmlAccessType.FIELD) -public class DmpUserImportExport { +public class PlanUserImportExport { @XmlElement(name = "id") private UUID id; @@ -17,7 +17,7 @@ public class DmpUserImportExport { private String name; @XmlElement(name = "role") - private DmpUserRole role; + private PlanUserRole role; @XmlElement(name = "sectionId") private UUID sectionId; @@ -38,11 +38,11 @@ public class DmpUserImportExport { this.name = name; } - public DmpUserRole getRole() { + public PlanUserRole getRole() { return this.role; } - public void setRole(DmpUserRole role) { + public void setRole(PlanUserRole role) { this.role = role; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/DefinitionEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/DefinitionEntity.java similarity index 94% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/DefinitionEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/DefinitionEntity.java index 12446b555..cdde1ca78 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/DefinitionEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/DefinitionEntity.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint; +package org.opencdmp.commons.types.planblueprint; import jakarta.xml.bind.annotation.*; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/DescriptionTemplateEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/DescriptionTemplateEntity.java similarity index 96% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/DescriptionTemplateEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/DescriptionTemplateEntity.java index 8dd51c1c0..fb1f775f6 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/DescriptionTemplateEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/DescriptionTemplateEntity.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint; +package org.opencdmp.commons.types.planblueprint; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/ExtraFieldEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/ExtraFieldEntity.java new file mode 100644 index 000000000..248857946 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/ExtraFieldEntity.java @@ -0,0 +1,21 @@ +package org.opencdmp.commons.types.planblueprint; + +import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; + +@XmlAccessorType(XmlAccessType.FIELD) +public class ExtraFieldEntity extends FieldEntity { + + @XmlAttribute(name="type") + private PlanBlueprintExtraFieldDataType type; + + public PlanBlueprintExtraFieldDataType getType() { + return type; + } + public void setType(PlanBlueprintExtraFieldDataType type) { + this.type = type; + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/FieldEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/FieldEntity.java similarity index 86% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/FieldEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/FieldEntity.java index ab217c93d..0e0dd3d2f 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/FieldEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/FieldEntity.java @@ -1,9 +1,9 @@ -package org.opencdmp.commons.types.dmpblueprint; +package org.opencdmp.commons.types.planblueprint; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAttribute; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; import java.util.List; import java.util.UUID; @@ -14,7 +14,7 @@ public abstract class FieldEntity { private UUID id; @XmlAttribute(name="category") - private DmpBlueprintFieldCategory category; + private PlanBlueprintFieldCategory category; @XmlAttribute(name="label") private String label; @@ -41,10 +41,10 @@ public abstract class FieldEntity { this.id = id; } - public DmpBlueprintFieldCategory getCategory() { + public PlanBlueprintFieldCategory getCategory() { return this.category; } - public void setCategory(DmpBlueprintFieldCategory category) { + public void setCategory(PlanBlueprintFieldCategory category) { this.category = category; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/ReferenceTypeFieldEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/ReferenceTypeFieldEntity.java similarity index 94% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/ReferenceTypeFieldEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/ReferenceTypeFieldEntity.java index baaaadfe3..911ca05e7 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/ReferenceTypeFieldEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/ReferenceTypeFieldEntity.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint; +package org.opencdmp.commons.types.planblueprint; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/SectionEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/SectionEntity.java similarity index 85% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/SectionEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/SectionEntity.java index 1555a8a9e..cbd329a0b 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/SectionEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/SectionEntity.java @@ -1,7 +1,7 @@ -package org.opencdmp.commons.types.dmpblueprint; +package org.opencdmp.commons.types.planblueprint; import jakarta.xml.bind.annotation.*; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; import java.util.ArrayList; import java.util.List; @@ -24,9 +24,9 @@ public class SectionEntity { @XmlElementWrapper(name = "fields") @XmlElements({ - @XmlElement(name = DmpBlueprintFieldCategory.Names.Extra, type = ExtraFieldEntity.class), - @XmlElement(name = DmpBlueprintFieldCategory.Names.System, type = SystemFieldEntity.class), - @XmlElement(name = DmpBlueprintFieldCategory.Names.ReferenceType, type = ReferenceTypeFieldEntity.class), + @XmlElement(name = PlanBlueprintFieldCategory.Names.Extra, type = ExtraFieldEntity.class), + @XmlElement(name = PlanBlueprintFieldCategory.Names.System, type = SystemFieldEntity.class), + @XmlElement(name = PlanBlueprintFieldCategory.Names.ReferenceType, type = ReferenceTypeFieldEntity.class), }) private List fields; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/SystemFieldEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/SystemFieldEntity.java similarity index 55% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/SystemFieldEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/SystemFieldEntity.java index 9983e1800..8b4c022d6 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/SystemFieldEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/SystemFieldEntity.java @@ -1,20 +1,20 @@ -package org.opencdmp.commons.types.dmpblueprint; +package org.opencdmp.commons.types.planblueprint; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAttribute; -import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType; +import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType; @XmlAccessorType(XmlAccessType.FIELD) public class SystemFieldEntity extends FieldEntity { @XmlAttribute(name="type") - private DmpBlueprintSystemFieldType type; + private PlanBlueprintSystemFieldType type; - public DmpBlueprintSystemFieldType getType() { + public PlanBlueprintSystemFieldType getType() { return this.type; } - public void setType(DmpBlueprintSystemFieldType type) { + public void setType(PlanBlueprintSystemFieldType type) { this.type = type; } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintDefinitionImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintDefinitionImportExport.java similarity index 88% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintDefinitionImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintDefinitionImportExport.java index df7167fa8..a5e646854 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintDefinitionImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintDefinitionImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint.importexport; +package org.opencdmp.commons.types.planblueprint.importexport; import jakarta.xml.bind.annotation.*; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintDescriptionTemplateImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintDescriptionTemplateImportExport.java similarity index 96% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintDescriptionTemplateImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintDescriptionTemplateImportExport.java index 213e41643..c58563429 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintDescriptionTemplateImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintDescriptionTemplateImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint.importexport; +package org.opencdmp.commons.types.planblueprint.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintExtraFieldImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintExtraFieldImportExport.java similarity index 86% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintExtraFieldImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintExtraFieldImportExport.java index ea2dbdd7d..e9b534432 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintExtraFieldImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintExtraFieldImportExport.java @@ -1,10 +1,10 @@ -package org.opencdmp.commons.types.dmpblueprint.importexport; +package org.opencdmp.commons.types.planblueprint.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlElement; -import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType; +import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType; import java.util.List; import java.util.UUID; @@ -15,7 +15,7 @@ public class BlueprintExtraFieldImportExport { @XmlElement(name = "id") private UUID id; @XmlElement(name = "type") - private DmpBlueprintExtraFieldDataType type; + private PlanBlueprintExtraFieldDataType type; @XmlElement(name = "label") private String label; @XmlElement(name = "placeholder") @@ -37,11 +37,11 @@ public class BlueprintExtraFieldImportExport { this.id = id; } - public DmpBlueprintExtraFieldDataType getType() { + public PlanBlueprintExtraFieldDataType getType() { return this.type; } - public void setType(DmpBlueprintExtraFieldDataType type) { + public void setType(PlanBlueprintExtraFieldDataType type) { this.type = type; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintImportExport.java similarity index 69% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintImportExport.java index 402de9720..534d6970a 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint.importexport; +package org.opencdmp.commons.types.planblueprint.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; @@ -18,7 +18,7 @@ public class BlueprintImportExport { private String label; @XmlElement(name = "definition") - private BlueprintDefinitionImportExport dmpBlueprintDefinition; + private BlueprintDefinitionImportExport planBlueprintDefinition; @XmlElement(name = "groupId") private UUID groupId; @@ -39,12 +39,12 @@ public class BlueprintImportExport { this.label = label; } - public BlueprintDefinitionImportExport getDmpBlueprintDefinition() { - return this.dmpBlueprintDefinition; + public BlueprintDefinitionImportExport getPlanBlueprintDefinition() { + return this.planBlueprintDefinition; } - public void setDmpBlueprintDefinition(BlueprintDefinitionImportExport dmpBlueprintDefinition) { - this.dmpBlueprintDefinition = dmpBlueprintDefinition; + public void setPlanBlueprintDefinition(BlueprintDefinitionImportExport planBlueprintDefinition) { + this.planBlueprintDefinition = planBlueprintDefinition; } public UUID getGroupId() { diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintPrefillingSourceImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintPrefillingSourceImportExport.java similarity index 90% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintPrefillingSourceImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintPrefillingSourceImportExport.java index 15ac45059..032578379 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintPrefillingSourceImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintPrefillingSourceImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint.importexport; +package org.opencdmp.commons.types.planblueprint.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintReferenceTypeFieldImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintReferenceTypeFieldImportExport.java similarity index 97% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintReferenceTypeFieldImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintReferenceTypeFieldImportExport.java index 252e3be99..165bb74a1 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintReferenceTypeFieldImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintReferenceTypeFieldImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint.importexport; +package org.opencdmp.commons.types.planblueprint.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintSectionImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintSectionImportExport.java similarity index 98% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintSectionImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintSectionImportExport.java index 890f0ff71..d5023448c 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintSectionImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintSectionImportExport.java @@ -1,4 +1,4 @@ -package org.opencdmp.commons.types.dmpblueprint.importexport; +package org.opencdmp.commons.types.planblueprint.importexport; import jakarta.xml.bind.annotation.*; diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintSystemFieldImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintSystemFieldImportExport.java similarity index 87% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintSystemFieldImportExport.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintSystemFieldImportExport.java index 0fa4ef93e..b7fe22e4c 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpblueprint/importexport/BlueprintSystemFieldImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planblueprint/importexport/BlueprintSystemFieldImportExport.java @@ -1,10 +1,10 @@ -package org.opencdmp.commons.types.dmpblueprint.importexport; +package org.opencdmp.commons.types.planblueprint.importexport; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlElement; -import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType; +import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType; import java.util.List; import java.util.UUID; @@ -15,7 +15,7 @@ public class BlueprintSystemFieldImportExport { @XmlElement(name = "id") private UUID id; @XmlElement(name = "type") - private DmpBlueprintSystemFieldType type; + private PlanBlueprintSystemFieldType type; @XmlElement(name = "label") private String label; @XmlElement(name = "placeholder") @@ -37,11 +37,11 @@ public class BlueprintSystemFieldImportExport { this.id = id; } - public DmpBlueprintSystemFieldType getType() { + public PlanBlueprintSystemFieldType getType() { return this.type; } - public void setType(DmpBlueprintSystemFieldType type) { + public void setType(PlanBlueprintSystemFieldType type) { this.type = type; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmpreference/DmpReferenceDataEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planreference/PlanReferenceDataEntity.java similarity index 72% rename from backend/core/src/main/java/org/opencdmp/commons/types/dmpreference/DmpReferenceDataEntity.java rename to backend/core/src/main/java/org/opencdmp/commons/types/planreference/PlanReferenceDataEntity.java index 430e7e507..03c9970ee 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmpreference/DmpReferenceDataEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planreference/PlanReferenceDataEntity.java @@ -1,8 +1,8 @@ -package org.opencdmp.commons.types.dmpreference; +package org.opencdmp.commons.types.planreference; import java.util.UUID; -public class DmpReferenceDataEntity { +public class PlanReferenceDataEntity { private UUID blueprintFieldId; public UUID getBlueprintFieldId() { diff --git a/backend/core/src/main/java/org/opencdmp/data/DescriptionEntity.java b/backend/core/src/main/java/org/opencdmp/data/DescriptionEntity.java index e0cfab537..4eee26ace 100644 --- a/backend/core/src/main/java/org/opencdmp/data/DescriptionEntity.java +++ b/backend/core/src/main/java/org/opencdmp/data/DescriptionEntity.java @@ -71,12 +71,12 @@ public class DescriptionEntity extends TenantScopedBaseEntity { public static final String _createdById = "createdById"; @Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false) - private UUID dmpDescriptionTemplateId; - public static final String _dmpDescriptionTemplateId = "dmpDescriptionTemplateId"; + private UUID planDescriptionTemplateId; + public static final String _planDescriptionTemplateId = "planDescriptionTemplateId"; @Column(name = "dmp", columnDefinition = "uuid", nullable = false) - private UUID dmpId; - public static final String _dmpId = "dmpId"; + private UUID planId; + public static final String _planId = "planId"; @Column(name = "description_template", columnDefinition = "uuid", nullable = false) private UUID descriptionTemplateId; @@ -164,20 +164,20 @@ public class DescriptionEntity extends TenantScopedBaseEntity { this.createdById = createdById; } - public UUID getDmpDescriptionTemplateId() { - return this.dmpDescriptionTemplateId; + public UUID getPlanDescriptionTemplateId() { + return this.planDescriptionTemplateId; } - public void setDmpDescriptionTemplateId(UUID dmpDescriptionTemplateId) { - this.dmpDescriptionTemplateId = dmpDescriptionTemplateId; + public void setPlanDescriptionTemplateId(UUID planDescriptionTemplateId) { + this.planDescriptionTemplateId = planDescriptionTemplateId; } - public UUID getDmpId() { - return this.dmpId; + public UUID getPlanId() { + return this.planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } public UUID getDescriptionTemplateId() { diff --git a/backend/core/src/main/java/org/opencdmp/data/DmpBlueprintEntity.java b/backend/core/src/main/java/org/opencdmp/data/PlanBlueprintEntity.java similarity index 78% rename from backend/core/src/main/java/org/opencdmp/data/DmpBlueprintEntity.java rename to backend/core/src/main/java/org/opencdmp/data/PlanBlueprintEntity.java index bb6fabd6a..fd0cd835b 100644 --- a/backend/core/src/main/java/org/opencdmp/data/DmpBlueprintEntity.java +++ b/backend/core/src/main/java/org/opencdmp/data/PlanBlueprintEntity.java @@ -1,10 +1,10 @@ package org.opencdmp.data; -import org.opencdmp.commons.enums.DmpBlueprintStatus; -import org.opencdmp.commons.enums.DmpBlueprintVersionStatus; +import org.opencdmp.commons.enums.PlanBlueprintStatus; +import org.opencdmp.commons.enums.PlanBlueprintVersionStatus; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.converters.DmpBlueprintVersionStatusConverter; -import org.opencdmp.data.converters.enums.DmpBlueprintStatusConverter; +import org.opencdmp.data.converters.PlanBlueprintVersionStatusConverter; +import org.opencdmp.data.converters.enums.PlanBlueprintStatusConverter; import org.opencdmp.data.converters.enums.IsActiveConverter; import org.opencdmp.data.tenant.TenantScopedBaseEntity; import org.opencdmp.data.types.SQLXMLType; @@ -16,7 +16,7 @@ import java.util.UUID; @Entity @Table(name = "\"DmpBlueprint\"") -public class DmpBlueprintEntity extends TenantScopedBaseEntity { +public class PlanBlueprintEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @@ -24,7 +24,7 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity { public static final String _id = "id"; - @Column(name = "label", length = DmpBlueprintEntity._labelLength, nullable = false) + @Column(name = "label", length = PlanBlueprintEntity._labelLength, nullable = false) private String label; public static final String _label = "label"; @@ -38,8 +38,8 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity { public static final String _definition = "definition"; @Column(name = "status", nullable = false) - @Convert(converter = DmpBlueprintStatusConverter.class) - private DmpBlueprintStatus status; + @Convert(converter = PlanBlueprintStatusConverter.class) + private PlanBlueprintStatus status; public static final String _status = "status"; @@ -54,8 +54,8 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity { public static final String _version = "version"; @Column(name = "version_status", nullable = false) - @Convert(converter = DmpBlueprintVersionStatusConverter.class) - private DmpBlueprintVersionStatus versionStatus; + @Convert(converter = PlanBlueprintVersionStatusConverter.class) + private PlanBlueprintVersionStatus versionStatus; public static final String _versionStatus = "versionStatus"; @@ -99,11 +99,11 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity { this.definition = definition; } - public DmpBlueprintStatus getStatus() { + public PlanBlueprintStatus getStatus() { return status; } - public void setStatus(DmpBlueprintStatus status) { + public void setStatus(PlanBlueprintStatus status) { this.status = status; } @@ -123,11 +123,11 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity { this.version = version; } - public DmpBlueprintVersionStatus getVersionStatus() { + public PlanBlueprintVersionStatus getVersionStatus() { return versionStatus; } - public void setVersionStatus(DmpBlueprintVersionStatus versionStatus) { + public void setVersionStatus(PlanBlueprintVersionStatus versionStatus) { this.versionStatus = versionStatus; } diff --git a/backend/core/src/main/java/org/opencdmp/data/DmpDescriptionTemplateEntity.java b/backend/core/src/main/java/org/opencdmp/data/PlanDescriptionTemplateEntity.java similarity index 89% rename from backend/core/src/main/java/org/opencdmp/data/DmpDescriptionTemplateEntity.java rename to backend/core/src/main/java/org/opencdmp/data/PlanDescriptionTemplateEntity.java index 039dcb26b..b5186d56b 100644 --- a/backend/core/src/main/java/org/opencdmp/data/DmpDescriptionTemplateEntity.java +++ b/backend/core/src/main/java/org/opencdmp/data/PlanDescriptionTemplateEntity.java @@ -10,7 +10,7 @@ import java.util.UUID; @Entity @Table(name = "\"DmpDescriptionTemplate\"") -public class DmpDescriptionTemplateEntity extends TenantScopedBaseEntity { +public class PlanDescriptionTemplateEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @@ -19,9 +19,9 @@ public class DmpDescriptionTemplateEntity extends TenantScopedBaseEntity { public static final String _id = "id"; @Column(name = "dmp", columnDefinition = "uuid", nullable = false) - private UUID dmpId; + private UUID planId; - public static final String _dmpId = "dmpId"; + public static final String _planId = "planId"; @Column(name = "description_template_group", columnDefinition = "uuid", nullable = false) private UUID descriptionTemplateGroupId; @@ -57,12 +57,12 @@ public class DmpDescriptionTemplateEntity extends TenantScopedBaseEntity { this.id = id; } - public UUID getDmpId() { - return this.dmpId; + public UUID getPlanId() { + return this.planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } public UUID getDescriptionTemplateGroupId() { diff --git a/backend/core/src/main/java/org/opencdmp/data/DmpEntity.java b/backend/core/src/main/java/org/opencdmp/data/PlanEntity.java similarity index 83% rename from backend/core/src/main/java/org/opencdmp/data/DmpEntity.java rename to backend/core/src/main/java/org/opencdmp/data/PlanEntity.java index 970734a60..f976078a1 100644 --- a/backend/core/src/main/java/org/opencdmp/data/DmpEntity.java +++ b/backend/core/src/main/java/org/opencdmp/data/PlanEntity.java @@ -1,13 +1,13 @@ package org.opencdmp.data; import jakarta.persistence.*; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; -import org.opencdmp.commons.enums.DmpVersionStatus; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.converters.enums.DmpAccessTypeNullableConverter; -import org.opencdmp.data.converters.enums.DmpStatusConverter; -import org.opencdmp.data.converters.enums.DmpVersionStatusConverter; +import org.opencdmp.data.converters.enums.PlanAccessTypeNullableConverter; +import org.opencdmp.data.converters.enums.PlanStatusConverter; +import org.opencdmp.data.converters.enums.PlanVersionStatusConverter; import org.opencdmp.data.converters.enums.IsActiveConverter; import org.opencdmp.data.tenant.TenantScopedBaseEntity; @@ -16,7 +16,7 @@ import java.util.UUID; @Entity @Table(name = "\"Dmp\"") -public class DmpEntity extends TenantScopedBaseEntity { +public class PlanEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @@ -36,14 +36,14 @@ public class DmpEntity extends TenantScopedBaseEntity { public static final String _version = "version"; @Column(name = "version_status", nullable = false) - @Convert(converter = DmpVersionStatusConverter.class) - private DmpVersionStatus versionStatus; + @Convert(converter = PlanVersionStatusConverter.class) + private PlanVersionStatus versionStatus; public static final String _versionStatus = "versionStatus"; @Column(name = "status", nullable = false) - @Convert(converter = DmpStatusConverter.class) - private DmpStatus status; + @Convert(converter = PlanStatusConverter.class) + private PlanStatus status; public static final String _status = "status"; @@ -89,8 +89,8 @@ public class DmpEntity extends TenantScopedBaseEntity { public static final String _creatorId = "creatorId"; @Column(name = "access_type", nullable = true) - @Convert(converter = DmpAccessTypeNullableConverter.class) - private DmpAccessType accessType; + @Convert(converter = PlanAccessTypeNullableConverter.class) + private PlanAccessType accessType; public static final String _accessType = "accessType"; @@ -133,11 +133,11 @@ public class DmpEntity extends TenantScopedBaseEntity { this.version = version; } - public DmpStatus getStatus() { + public PlanStatus getStatus() { return this.status; } - public void setStatus(DmpStatus status) { + public void setStatus(PlanStatus status) { this.status = status; } @@ -205,11 +205,11 @@ public class DmpEntity extends TenantScopedBaseEntity { this.creatorId = creatorId; } - public DmpAccessType getAccessType() { + public PlanAccessType getAccessType() { return this.accessType; } - public void setAccessType(DmpAccessType accessType) { + public void setAccessType(PlanAccessType accessType) { this.accessType = accessType; } @@ -237,11 +237,11 @@ public class DmpEntity extends TenantScopedBaseEntity { this.publicAfter = publicAfter; } - public DmpVersionStatus getVersionStatus() { + public PlanVersionStatus getVersionStatus() { return this.versionStatus; } - public void setVersionStatus(DmpVersionStatus versionStatus) { + public void setVersionStatus(PlanVersionStatus versionStatus) { this.versionStatus = versionStatus; } } diff --git a/backend/core/src/main/java/org/opencdmp/data/DmpReferenceEntity.java b/backend/core/src/main/java/org/opencdmp/data/PlanReferenceEntity.java similarity index 89% rename from backend/core/src/main/java/org/opencdmp/data/DmpReferenceEntity.java rename to backend/core/src/main/java/org/opencdmp/data/PlanReferenceEntity.java index dd1649a23..39dc8f6d8 100644 --- a/backend/core/src/main/java/org/opencdmp/data/DmpReferenceEntity.java +++ b/backend/core/src/main/java/org/opencdmp/data/PlanReferenceEntity.java @@ -10,7 +10,7 @@ import java.util.UUID; @Entity @Table(name = "\"DmpReference\"") -public class DmpReferenceEntity extends TenantScopedBaseEntity { +public class PlanReferenceEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @@ -18,8 +18,8 @@ public class DmpReferenceEntity extends TenantScopedBaseEntity { public static final String _id = "id"; @Column(name = "dmp_id", columnDefinition = "uuid", nullable = false) - private UUID dmpId; - public static final String _dmpId = "dmpId"; + private UUID planId; + public static final String _planId = "planId"; @Column(name = "reference_id", columnDefinition = "uuid", nullable = false) private UUID referenceId; @@ -50,12 +50,12 @@ public class DmpReferenceEntity extends TenantScopedBaseEntity { this.id = id; } - public UUID getDmpId() { - return dmpId; + public UUID getPlanId() { + return planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } public UUID getReferenceId() { diff --git a/backend/core/src/main/java/org/opencdmp/data/DmpUserEntity.java b/backend/core/src/main/java/org/opencdmp/data/PlanUserEntity.java similarity index 81% rename from backend/core/src/main/java/org/opencdmp/data/DmpUserEntity.java rename to backend/core/src/main/java/org/opencdmp/data/PlanUserEntity.java index bc0027d55..e00558a3d 100644 --- a/backend/core/src/main/java/org/opencdmp/data/DmpUserEntity.java +++ b/backend/core/src/main/java/org/opencdmp/data/PlanUserEntity.java @@ -1,9 +1,9 @@ package org.opencdmp.data; import jakarta.persistence.*; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.converters.enums.DmpUserRoleConverter; +import org.opencdmp.data.converters.enums.PlanUserRoleConverter; import org.opencdmp.data.converters.enums.IsActiveConverter; import org.opencdmp.data.tenant.TenantScopedBaseEntity; @@ -12,7 +12,7 @@ import java.util.UUID; @Entity @Table(name = "\"DmpUser\"") -public class DmpUserEntity extends TenantScopedBaseEntity { +public class PlanUserEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @@ -21,9 +21,9 @@ public class DmpUserEntity extends TenantScopedBaseEntity { public static final String _id = "id"; @Column(name = "dmp", columnDefinition = "uuid", nullable = false) - private UUID dmpId; + private UUID planId; - public static final String _dmpId = "dmpId"; + public static final String _planId = "planId"; @Column(name = "\"user\"", columnDefinition = "uuid", nullable = false) private UUID userId; @@ -31,8 +31,8 @@ public class DmpUserEntity extends TenantScopedBaseEntity { public static final String _userId = "userId"; @Column(name = "role", nullable = false) - @Convert(converter = DmpUserRoleConverter.class) - private DmpUserRole role; + @Convert(converter = PlanUserRoleConverter.class) + private PlanUserRole role; public static final String _role = "role"; @@ -64,12 +64,12 @@ public class DmpUserEntity extends TenantScopedBaseEntity { this.id = id; } - public UUID getDmpId() { - return this.dmpId; + public UUID getPlanId() { + return this.planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } public UUID getUserId() { @@ -80,11 +80,11 @@ public class DmpUserEntity extends TenantScopedBaseEntity { this.userId = userId; } - public DmpUserRole getRole() { + public PlanUserRole getRole() { return this.role; } - public void setRole(DmpUserRole role) { + public void setRole(PlanUserRole role) { this.role = role; } diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/DmpBlueprintVersionStatusConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/DmpBlueprintVersionStatusConverter.java deleted file mode 100644 index b09a827fc..000000000 --- a/backend/core/src/main/java/org/opencdmp/data/converters/DmpBlueprintVersionStatusConverter.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.opencdmp.data.converters; - -import org.opencdmp.commons.enums.DmpBlueprintVersionStatus; -import org.opencdmp.data.converters.enums.DatabaseEnumConverter; -import jakarta.persistence.Converter; - -@Converter -public class DmpBlueprintVersionStatusConverter extends DatabaseEnumConverter { - - @Override - protected DmpBlueprintVersionStatus of(Short i) { - return DmpBlueprintVersionStatus.of(i); - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/PlanBlueprintVersionStatusConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/PlanBlueprintVersionStatusConverter.java new file mode 100644 index 000000000..1fe184fe8 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/data/converters/PlanBlueprintVersionStatusConverter.java @@ -0,0 +1,15 @@ +package org.opencdmp.data.converters; + +import org.opencdmp.commons.enums.PlanBlueprintVersionStatus; +import org.opencdmp.data.converters.enums.DatabaseEnumConverter; +import jakarta.persistence.Converter; + +@Converter +public class PlanBlueprintVersionStatusConverter extends DatabaseEnumConverter { + + @Override + protected PlanBlueprintVersionStatus of(Short i) { + return PlanBlueprintVersionStatus.of(i); + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpAccessTypeNullableConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpAccessTypeNullableConverter.java deleted file mode 100644 index 46df1d1a2..000000000 --- a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpAccessTypeNullableConverter.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.opencdmp.data.converters.enums; - -import org.opencdmp.commons.enums.DmpAccessType; -import jakarta.persistence.Converter; - -@Converter -public class DmpAccessTypeNullableConverter extends DatabaseEnumConverter { - - @Override - protected DmpAccessType of(Short i) { - return DmpAccessType.of(i); - } - - - @Override - public Short convertToDatabaseColumn(DmpAccessType value) { - if (value == null) return null; - return value.getValue(); - } - - @Override - public DmpAccessType convertToEntityAttribute(Short dbData) { - return dbData == null ? null : this.of(dbData); - } -} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpBlueprintStatusConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpBlueprintStatusConverter.java deleted file mode 100644 index e1a740578..000000000 --- a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpBlueprintStatusConverter.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.opencdmp.data.converters.enums; - -import org.opencdmp.commons.enums.DescriptionTemplateTypeStatus; -import org.opencdmp.commons.enums.DmpBlueprintStatus; -import jakarta.persistence.Converter; - -@Converter -public class DmpBlueprintStatusConverter extends DatabaseEnumConverter { - public DmpBlueprintStatus of(Short i) { - return DmpBlueprintStatus.of(i); - } -} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpStatusConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpStatusConverter.java deleted file mode 100644 index 940a4e197..000000000 --- a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpStatusConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.opencdmp.data.converters.enums; - -import org.opencdmp.commons.enums.DmpStatus; -import jakarta.persistence.Converter; - -@Converter -public class DmpStatusConverter extends DatabaseEnumConverter { - - @Override - protected DmpStatus of(Short i) { - return DmpStatus.of(i); - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpUserRoleConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpUserRoleConverter.java deleted file mode 100644 index 78c6f662f..000000000 --- a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpUserRoleConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.opencdmp.data.converters.enums; - -import org.opencdmp.commons.enums.DmpUserRole; -import jakarta.persistence.Converter; - -@Converter -public class DmpUserRoleConverter extends DatabaseEnumConverter { - - @Override - protected DmpUserRole of(Short i) { - return DmpUserRole.of(i); - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpVersionStatusConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpVersionStatusConverter.java deleted file mode 100644 index 16c9a7cdf..000000000 --- a/backend/core/src/main/java/org/opencdmp/data/converters/enums/DmpVersionStatusConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.opencdmp.data.converters.enums; - -import org.opencdmp.commons.enums.DmpVersionStatus; -import jakarta.persistence.Converter; - -@Converter -public class DmpVersionStatusConverter extends DatabaseEnumConverter { - - @Override - protected DmpVersionStatus of(Short i) { - return DmpVersionStatus.of(i); - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanAccessTypeNullableConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanAccessTypeNullableConverter.java new file mode 100644 index 000000000..68466b5fc --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanAccessTypeNullableConverter.java @@ -0,0 +1,25 @@ +package org.opencdmp.data.converters.enums; + +import org.opencdmp.commons.enums.PlanAccessType; +import jakarta.persistence.Converter; + +@Converter +public class PlanAccessTypeNullableConverter extends DatabaseEnumConverter { + + @Override + protected PlanAccessType of(Short i) { + return PlanAccessType.of(i); + } + + + @Override + public Short convertToDatabaseColumn(PlanAccessType value) { + if (value == null) return null; + return value.getValue(); + } + + @Override + public PlanAccessType convertToEntityAttribute(Short dbData) { + return dbData == null ? null : this.of(dbData); + } +} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanBlueprintStatusConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanBlueprintStatusConverter.java new file mode 100644 index 000000000..502c0ea01 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanBlueprintStatusConverter.java @@ -0,0 +1,11 @@ +package org.opencdmp.data.converters.enums; + +import org.opencdmp.commons.enums.PlanBlueprintStatus; +import jakarta.persistence.Converter; + +@Converter +public class PlanBlueprintStatusConverter extends DatabaseEnumConverter { + public PlanBlueprintStatus of(Short i) { + return PlanBlueprintStatus.of(i); + } +} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanStatusConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanStatusConverter.java new file mode 100644 index 000000000..db790afb6 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanStatusConverter.java @@ -0,0 +1,14 @@ +package org.opencdmp.data.converters.enums; + +import org.opencdmp.commons.enums.PlanStatus; +import jakarta.persistence.Converter; + +@Converter +public class PlanStatusConverter extends DatabaseEnumConverter { + + @Override + protected PlanStatus of(Short i) { + return PlanStatus.of(i); + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanUserRoleConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanUserRoleConverter.java new file mode 100644 index 000000000..031b90ca6 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanUserRoleConverter.java @@ -0,0 +1,14 @@ +package org.opencdmp.data.converters.enums; + +import org.opencdmp.commons.enums.PlanUserRole; +import jakarta.persistence.Converter; + +@Converter +public class PlanUserRoleConverter extends DatabaseEnumConverter { + + @Override + protected PlanUserRole of(Short i) { + return PlanUserRole.of(i); + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanVersionStatusConverter.java b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanVersionStatusConverter.java new file mode 100644 index 000000000..b67db9b76 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/data/converters/enums/PlanVersionStatusConverter.java @@ -0,0 +1,14 @@ +package org.opencdmp.data.converters.enums; + +import org.opencdmp.commons.enums.PlanVersionStatus; +import jakarta.persistence.Converter; + +@Converter +public class PlanVersionStatusConverter extends DatabaseEnumConverter { + + @Override + protected PlanVersionStatus of(Short i) { + return PlanVersionStatus.of(i); + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/ElasticConfiguration.java b/backend/core/src/main/java/org/opencdmp/elastic/ElasticConfiguration.java index a8325dafe..219bca825 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/ElasticConfiguration.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/ElasticConfiguration.java @@ -7,7 +7,6 @@ import gr.cite.tools.elastic.configuration.ElasticCertificateProvider; import gr.cite.tools.elastic.configuration.ElasticProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.elasticsearch.core.convert.ElasticsearchCustomConversions; @@ -28,22 +27,22 @@ public class ElasticConfiguration extends AbstractElasticConfiguration { public ElasticsearchCustomConversions elasticsearchCustomConversions() { return new ElasticsearchCustomConversions( List.of( - new DmpUserRoleToShortConverter(), + new PlanUserRoleToShortConverter(), new DescriptionTemplateVersionStatusToShortConverter(), - new DmpStatusToShortConverter(), + new PlanStatusToShortConverter(), new DescriptionStatusToShortConverter(), new IsActiveToShortConverter(), - new DmpVersionStatusToShortConverter(), - new DmpAccessTypeToShortConverter(), + new PlanVersionStatusToShortConverter(), + new PlanAccessTypeToShortConverter(), - new ShortToDmpStatusConverter(), - new ShortToDmpUserRoleConverter(), + new ShortToPlanStatusConverter(), + new ShortToPlanUserRoleConverter(), new ShortToDescriptionTemplateVersionStatusConverter(), - new ShortToDmpStatusConverter(), + new ShortToPlanStatusConverter(), new ShortToDescriptionStatusConverter(), new ShortToIsActiveConverter(), - new ShortToDmpVersionStatusConverter(), - new ShortToDmpAccessTypeConverter() + new ShortToPlanVersionStatusConverter(), + new ShortToPlanAccessTypeConverter() )); } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/DescriptionStatusToShortConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/DescriptionStatusToShortConverter.java index 55aaa86a3..4f163e6ee 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/DescriptionStatusToShortConverter.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/DescriptionStatusToShortConverter.java @@ -1,7 +1,6 @@ package org.opencdmp.elastic.converter; import org.opencdmp.commons.enums.DescriptionStatus; -import org.opencdmp.commons.enums.DmpStatus; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.WritingConverter; diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/IsActiveToShortConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/IsActiveToShortConverter.java index c8c93d851..c337a0721 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/IsActiveToShortConverter.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/IsActiveToShortConverter.java @@ -1,6 +1,5 @@ package org.opencdmp.elastic.converter; -import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.IsActive; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.WritingConverter; diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/DmpAccessTypeToShortConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/PlanAccessTypeToShortConverter.java similarity index 54% rename from backend/core/src/main/java/org/opencdmp/elastic/converter/DmpAccessTypeToShortConverter.java rename to backend/core/src/main/java/org/opencdmp/elastic/converter/PlanAccessTypeToShortConverter.java index edd116619..2cb171c0d 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/DmpAccessTypeToShortConverter.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/PlanAccessTypeToShortConverter.java @@ -1,13 +1,13 @@ package org.opencdmp.elastic.converter; -import org.opencdmp.commons.enums.DmpAccessType; +import org.opencdmp.commons.enums.PlanAccessType; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.WritingConverter; @WritingConverter -public class DmpAccessTypeToShortConverter implements Converter { +public class PlanAccessTypeToShortConverter implements Converter { @Override - public Short convert(DmpAccessType source) { + public Short convert(PlanAccessType source) { return source.getValue(); } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/DmpStatusToShortConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/PlanStatusToShortConverter.java similarity index 56% rename from backend/core/src/main/java/org/opencdmp/elastic/converter/DmpStatusToShortConverter.java rename to backend/core/src/main/java/org/opencdmp/elastic/converter/PlanStatusToShortConverter.java index fef1380e6..c80020e6d 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/DmpStatusToShortConverter.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/PlanStatusToShortConverter.java @@ -1,13 +1,13 @@ package org.opencdmp.elastic.converter; -import org.opencdmp.commons.enums.DmpStatus; +import org.opencdmp.commons.enums.PlanStatus; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.WritingConverter; @WritingConverter -public class DmpStatusToShortConverter implements Converter { +public class PlanStatusToShortConverter implements Converter { @Override - public Short convert(DmpStatus source) { + public Short convert(PlanStatus source) { return source.getValue(); } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/DmpUserRoleToShortConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/PlanUserRoleToShortConverter.java similarity index 55% rename from backend/core/src/main/java/org/opencdmp/elastic/converter/DmpUserRoleToShortConverter.java rename to backend/core/src/main/java/org/opencdmp/elastic/converter/PlanUserRoleToShortConverter.java index 7b74c6b14..065904809 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/DmpUserRoleToShortConverter.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/PlanUserRoleToShortConverter.java @@ -1,13 +1,13 @@ package org.opencdmp.elastic.converter; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.WritingConverter; @WritingConverter -public class DmpUserRoleToShortConverter implements Converter { +public class PlanUserRoleToShortConverter implements Converter { @Override - public Short convert(DmpUserRole source) { + public Short convert(PlanUserRole source) { return source.getValue(); } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/DmpVersionStatusToShortConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/PlanVersionStatusToShortConverter.java similarity index 52% rename from backend/core/src/main/java/org/opencdmp/elastic/converter/DmpVersionStatusToShortConverter.java rename to backend/core/src/main/java/org/opencdmp/elastic/converter/PlanVersionStatusToShortConverter.java index 0709ee264..0b3e114a6 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/DmpVersionStatusToShortConverter.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/PlanVersionStatusToShortConverter.java @@ -1,13 +1,13 @@ package org.opencdmp.elastic.converter; -import org.opencdmp.commons.enums.DmpVersionStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.WritingConverter; @WritingConverter -public class DmpVersionStatusToShortConverter implements Converter { +public class PlanVersionStatusToShortConverter implements Converter { @Override - public Short convert(DmpVersionStatus source) { + public Short convert(PlanVersionStatus source) { return source.getValue(); } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpAccessTypeConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpAccessTypeConverter.java deleted file mode 100644 index 93fead4a5..000000000 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpAccessTypeConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.opencdmp.elastic.converter; - -import org.opencdmp.commons.enums.DmpAccessType; -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.convert.ReadingConverter; -import org.springframework.data.convert.WritingConverter; - -@ReadingConverter -public class ShortToDmpAccessTypeConverter implements Converter { - @Override - public DmpAccessType convert(Integer source) { - return DmpAccessType.of(source.shortValue()); - } -} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpUserRoleConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpUserRoleConverter.java deleted file mode 100644 index 0a9356c75..000000000 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpUserRoleConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.opencdmp.elastic.converter; - -import org.opencdmp.commons.enums.DmpUserRole; -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.convert.ReadingConverter; -import org.springframework.data.convert.WritingConverter; - -@ReadingConverter -public class ShortToDmpUserRoleConverter implements Converter { - @Override - public DmpUserRole convert(Integer source) { - return DmpUserRole.of(source.shortValue()); - } -} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpVersionStatusConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpVersionStatusConverter.java deleted file mode 100644 index 7e1b47f55..000000000 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpVersionStatusConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.opencdmp.elastic.converter; - -import org.opencdmp.commons.enums.DmpVersionStatus; -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.convert.ReadingConverter; -import org.springframework.data.convert.WritingConverter; - -@ReadingConverter -public class ShortToDmpVersionStatusConverter implements Converter { - @Override - public DmpVersionStatus convert(Integer source) { - return DmpVersionStatus.of(source.shortValue()); - } -} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanAccessTypeConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanAccessTypeConverter.java new file mode 100644 index 000000000..dcceb3c6b --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanAccessTypeConverter.java @@ -0,0 +1,13 @@ +package org.opencdmp.elastic.converter; + +import org.opencdmp.commons.enums.PlanAccessType; +import org.springframework.core.convert.converter.Converter; +import org.springframework.data.convert.ReadingConverter; + +@ReadingConverter +public class ShortToPlanAccessTypeConverter implements Converter { + @Override + public PlanAccessType convert(Integer source) { + return PlanAccessType.of(source.shortValue()); + } +} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpStatusConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanStatusConverter.java similarity index 57% rename from backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpStatusConverter.java rename to backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanStatusConverter.java index 17b2722bb..aa4c8f748 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToDmpStatusConverter.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanStatusConverter.java @@ -5,10 +5,10 @@ import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.ReadingConverter; @ReadingConverter -public class ShortToDmpStatusConverter implements Converter { +public class ShortToPlanStatusConverter implements Converter { @Override - public DmpStatus convert(Integer source) { - return DmpStatus.of(source.shortValue()); + public PlanStatus convert(Integer source) { + return PlanStatus.of(source.shortValue()); } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanUserRoleConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanUserRoleConverter.java new file mode 100644 index 000000000..0b4d43e61 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanUserRoleConverter.java @@ -0,0 +1,13 @@ +package org.opencdmp.elastic.converter; + +import org.opencdmp.commons.enums.PlanUserRole; +import org.springframework.core.convert.converter.Converter; +import org.springframework.data.convert.ReadingConverter; + +@ReadingConverter +public class ShortToPlanUserRoleConverter implements Converter { + @Override + public PlanUserRole convert(Integer source) { + return PlanUserRole.of(source.shortValue()); + } +} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanVersionStatusConverter.java b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanVersionStatusConverter.java new file mode 100644 index 000000000..20488c317 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/elastic/converter/ShortToPlanVersionStatusConverter.java @@ -0,0 +1,13 @@ +package org.opencdmp.elastic.converter; + +import org.opencdmp.commons.enums.PlanVersionStatus; +import org.springframework.core.convert.converter.Converter; +import org.springframework.data.convert.ReadingConverter; + +@ReadingConverter +public class ShortToPlanVersionStatusConverter implements Converter { + @Override + public PlanVersionStatus convert(Integer source) { + return PlanVersionStatus.of(source.shortValue()); + } +} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java index 773166327..2b21324cc 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java @@ -3,7 +3,7 @@ package org.opencdmp.elastic.data; import gr.cite.tools.elastic.ElasticConstants; import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; -import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; +import org.opencdmp.elastic.data.nested.NestedPlanElasticEntity; import org.opencdmp.elastic.data.nested.NestedReferenceElasticEntity; import org.opencdmp.elastic.data.nested.NestedTagElasticEntity; import org.springframework.data.annotation.Id; @@ -50,7 +50,7 @@ public class DescriptionElasticEntity { public final static String _descriptionTemplate = "descriptionTemplate"; @Field(value = DescriptionElasticEntity._dmp, type = FieldType.Object) - private NestedDmpElasticEntity dmp; + private NestedPlanElasticEntity dmp; public final static String _dmp = "dmp"; @Field(value = DescriptionElasticEntity._references, type = FieldType.Nested) @@ -129,11 +129,11 @@ public class DescriptionElasticEntity { this.descriptionTemplate = descriptionTemplate; } - public NestedDmpElasticEntity getDmp() { + public NestedPlanElasticEntity getDmp() { return this.dmp; } - public void setDmp(NestedDmpElasticEntity dmp) { + public void setDmp(NestedPlanElasticEntity dmp) { this.dmp = dmp; } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/DmpElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/PlanElasticEntity.java similarity index 64% rename from backend/core/src/main/java/org/opencdmp/elastic/data/DmpElasticEntity.java rename to backend/core/src/main/java/org/opencdmp/elastic/data/PlanElasticEntity.java index 72c13cae1..e5419ae3f 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/DmpElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/PlanElasticEntity.java @@ -1,9 +1,9 @@ package org.opencdmp.elastic.data; import gr.cite.tools.elastic.ElasticConstants; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; -import org.opencdmp.commons.enums.DmpVersionStatus; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; import org.opencdmp.elastic.data.nested.*; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -13,80 +13,80 @@ import java.util.List; import java.util.UUID; @Document(indexName = "dmp") -public class DmpElasticEntity { +public class PlanElasticEntity { @Id - @Field(value = DmpElasticEntity._id, type = FieldType.Keyword) + @Field(value = PlanElasticEntity._id, type = FieldType.Keyword) private UUID id; public final static String _id = "id"; - @Field(value = DmpElasticEntity._tenantId, type = FieldType.Keyword) + @Field(value = PlanElasticEntity._tenantId, type = FieldType.Keyword) private UUID tenantId; public final static String _tenantId = "tenantId"; - @MultiField(mainField = @Field(value = DmpElasticEntity._label, type = FieldType.Text), otherFields = @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)) + @MultiField(mainField = @Field(value = PlanElasticEntity._label, type = FieldType.Text), otherFields = @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)) private String label; public final static String _label = "label"; - @Field(value = DmpElasticEntity._description, type = FieldType.Text) + @Field(value = PlanElasticEntity._description, type = FieldType.Text) private String description; public final static String _description = "description"; - @Field(value = DmpElasticEntity._version, type = FieldType.Keyword) + @Field(value = PlanElasticEntity._version, type = FieldType.Keyword) private Short version; public final static String _version = "version"; - @Field(value = DmpElasticEntity._status, type = FieldType.Short) - private DmpStatus status; + @Field(value = PlanElasticEntity._status, type = FieldType.Short) + private PlanStatus status; public final static String _status = "status"; - @Field(value = DmpElasticEntity._accessType, type = FieldType.Short) - private DmpAccessType accessType; + @Field(value = PlanElasticEntity._accessType, type = FieldType.Short) + private PlanAccessType accessType; public final static String _accessType = "accessType"; - @Field(value = DmpElasticEntity._versionStatus, type = FieldType.Short) - private DmpVersionStatus versionStatus; + @Field(value = PlanElasticEntity._versionStatus, type = FieldType.Short) + private PlanVersionStatus versionStatus; public final static String _versionStatus = "versionStatus"; - @Field(value = DmpElasticEntity._language, type = FieldType.Keyword) + @Field(value = PlanElasticEntity._language, type = FieldType.Keyword) private String language; public final static String _language = "language"; - @Field(value = DmpElasticEntity._blueprintId, type = FieldType.Keyword) + @Field(value = PlanElasticEntity._blueprintId, type = FieldType.Keyword) private UUID blueprintId; public final static String _blueprintId = "blueprintId"; - @Field(value = DmpElasticEntity._groupId, type = FieldType.Keyword) + @Field(value = PlanElasticEntity._groupId, type = FieldType.Keyword) private UUID groupId; public final static String _groupId = "groupId"; - @Field(value = DmpElasticEntity._finalizedAt, type = FieldType.Date) + @Field(value = PlanElasticEntity._finalizedAt, type = FieldType.Date) private Date finalizedAt; public final static String _finalizedAt = "finalizedAt"; - @Field(value = DmpElasticEntity._references, type = FieldType.Nested) + @Field(value = PlanElasticEntity._references, type = FieldType.Nested) private List references; public final static String _references = "references"; - @Field(value = DmpElasticEntity._collaborators, type = FieldType.Nested) + @Field(value = PlanElasticEntity._collaborators, type = FieldType.Nested) private List collaborators; public final static String _collaborators = "collaborators"; - @Field(value = DmpElasticEntity._descriptions, type = FieldType.Nested) + @Field(value = PlanElasticEntity._descriptions, type = FieldType.Nested) private List descriptions; public final static String _descriptions = "descriptions"; - @Field(value = DmpElasticEntity._dmpDescriptionTemplates, type = FieldType.Nested) - private List dmpDescriptionTemplates; + @Field(value = PlanElasticEntity._dmpDescriptionTemplates, type = FieldType.Nested) + private List planDescriptionTemplates; public final static String _dmpDescriptionTemplates = "dmpDescriptionTemplates"; - @Field(value = DmpElasticEntity._dois, type = FieldType.Nested) + @Field(value = PlanElasticEntity._dois, type = FieldType.Nested) private List dois; public final static String _dois = "dois"; - @Field(value = DmpElasticEntity._updatedAt, type = FieldType.Date) + @Field(value = PlanElasticEntity._updatedAt, type = FieldType.Date) private Date updatedAt; public final static String _updatedAt = "updatedAt"; - @Field(value = DmpElasticEntity._createdAt, type = FieldType.Date) + @Field(value = PlanElasticEntity._createdAt, type = FieldType.Date) private Date createdAt; public final static String _createdAt = "createdAt"; @@ -130,19 +130,19 @@ public class DmpElasticEntity { this.version = version; } - public DmpStatus getStatus() { + public PlanStatus getStatus() { return this.status; } - public void setStatus(DmpStatus status) { + public void setStatus(PlanStatus status) { this.status = status; } - public DmpAccessType getAccessType() { + public PlanAccessType getAccessType() { return this.accessType; } - public void setAccessType(DmpAccessType accessType) { + public void setAccessType(PlanAccessType accessType) { this.accessType = accessType; } @@ -210,20 +210,20 @@ public class DmpElasticEntity { this.dois = dois; } - public DmpVersionStatus getVersionStatus() { + public PlanVersionStatus getVersionStatus() { return this.versionStatus; } - public void setVersionStatus(DmpVersionStatus versionStatus) { + public void setVersionStatus(PlanVersionStatus versionStatus) { this.versionStatus = versionStatus; } - public List getDmpDescriptionTemplates() { - return this.dmpDescriptionTemplates; + public List getPlanDescriptionTemplates() { + return this.planDescriptionTemplates; } - public void setDmpDescriptionTemplates(List dmpDescriptionTemplates) { - this.dmpDescriptionTemplates = dmpDescriptionTemplates; + public void setPlanDescriptionTemplates(List planDescriptionTemplates) { + this.planDescriptionTemplates = planDescriptionTemplates; } public Date getCreatedAt() { diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedCollaboratorElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedCollaboratorElasticEntity.java index 228239eea..77ed3e2aa 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedCollaboratorElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedCollaboratorElasticEntity.java @@ -1,7 +1,7 @@ package org.opencdmp.elastic.data.nested; import gr.cite.tools.elastic.ElasticConstants; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.FieldType; @@ -25,7 +25,7 @@ public class NestedCollaboratorElasticEntity { public final static String _name = "name"; @Field(value = NestedCollaboratorElasticEntity._role, type = FieldType.Short) - private DmpUserRole role; + private PlanUserRole role; public final static String _role = "role"; public UUID getId() { @@ -44,11 +44,11 @@ public class NestedCollaboratorElasticEntity { this.name = name; } - public DmpUserRole getRole() { + public PlanUserRole getRole() { return this.role; } - public void setRole(DmpUserRole role) { + public void setRole(PlanUserRole role) { this.role = role; } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionElasticEntity.java index 2b42887b9..29ff2675f 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionElasticEntity.java @@ -21,7 +21,7 @@ public class NestedDescriptionElasticEntity { public final static String _id = "id"; @Field(value = NestedDescriptionElasticEntity._dmpId, type = FieldType.Keyword) - private UUID dmpId; + private UUID planId; public final static String _dmpId = "dmpId"; @MultiField(mainField = @Field(value = NestedDescriptionElasticEntity._label, type = FieldType.Text), otherFields = @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)) @@ -60,12 +60,12 @@ public class NestedDescriptionElasticEntity { this.id = id; } - public UUID getDmpId() { - return this.dmpId; + public UUID getPlanId() { + return this.planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } public String getLabel() { diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDmpDescriptionTemplateElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanDescriptionTemplateElasticEntity.java similarity index 69% rename from backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDmpDescriptionTemplateElasticEntity.java rename to backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanDescriptionTemplateElasticEntity.java index a01fbb273..e1beffe1d 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDmpDescriptionTemplateElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanDescriptionTemplateElasticEntity.java @@ -6,22 +6,22 @@ import org.springframework.data.elasticsearch.annotations.FieldType; import java.util.UUID; -public class NestedDmpDescriptionTemplateElasticEntity { +public class NestedPlanDescriptionTemplateElasticEntity { @Id - @Field(value = NestedDmpDescriptionTemplateElasticEntity._id, type = FieldType.Keyword) + @Field(value = NestedPlanDescriptionTemplateElasticEntity._id, type = FieldType.Keyword) private UUID id; public final static String _id = "id"; @Field(value = NestedDescriptionElasticEntity._dmpId, type = FieldType.Keyword) - private UUID dmpId; + private UUID planId; public final static String _dmpId = "dmpId"; - @Field(value = NestedDmpDescriptionTemplateElasticEntity._descriptionTemplateGroupId, type = FieldType.Keyword) + @Field(value = NestedPlanDescriptionTemplateElasticEntity._descriptionTemplateGroupId, type = FieldType.Keyword) private UUID descriptionTemplateGroupId; public final static String _descriptionTemplateGroupId = "descriptionTemplateGroupId"; - @Field(value = NestedDmpDescriptionTemplateElasticEntity._sectionId, type = FieldType.Keyword) + @Field(value = NestedPlanDescriptionTemplateElasticEntity._sectionId, type = FieldType.Keyword) private UUID sectionId; public final static String _sectionId = "sectionId"; @@ -50,11 +50,11 @@ public class NestedDmpDescriptionTemplateElasticEntity { this.sectionId = sectionId; } - public UUID getDmpId() { - return this.dmpId; + public UUID getPlanId() { + return this.planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDmpElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanElasticEntity.java similarity index 65% rename from backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDmpElasticEntity.java rename to backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanElasticEntity.java index d0ce3b8d1..cd9d84e06 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDmpElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanElasticEntity.java @@ -1,9 +1,8 @@ package org.opencdmp.elastic.data.nested; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; -import org.opencdmp.commons.enums.DmpVersionStatus; -import org.opencdmp.elastic.data.DmpElasticEntity; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; import gr.cite.tools.elastic.ElasticConstants; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -12,63 +11,63 @@ import java.util.Date; import java.util.List; import java.util.UUID; -public class NestedDmpElasticEntity { +public class NestedPlanElasticEntity { @Id - @Field(value = NestedDmpElasticEntity._id, type = FieldType.Keyword) + @Field(value = NestedPlanElasticEntity._id, type = FieldType.Keyword) private UUID id; public final static String _id = "id"; - @MultiField(mainField = @Field(value = NestedDmpElasticEntity._label, type = FieldType.Text), otherFields = { + @MultiField(mainField = @Field(value = NestedPlanElasticEntity._label, type = FieldType.Text), otherFields = { @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword) }) private String label; public final static String _label = "label"; - @Field(value = NestedDmpElasticEntity._description, type = FieldType.Text) + @Field(value = NestedPlanElasticEntity._description, type = FieldType.Text) private String description; public final static String _description = "description"; - @Field(value = NestedDmpElasticEntity._version, type = FieldType.Keyword) + @Field(value = NestedPlanElasticEntity._version, type = FieldType.Keyword) private Short version; public final static String _version = "version"; - @Field(value = NestedDmpElasticEntity._versionStatus, type = FieldType.Short) - private DmpVersionStatus versionStatus; + @Field(value = NestedPlanElasticEntity._versionStatus, type = FieldType.Short) + private PlanVersionStatus versionStatus; public final static String _versionStatus = "versionStatus"; - @Field(value = NestedDmpElasticEntity._status, type = FieldType.Short) - private DmpStatus status; + @Field(value = NestedPlanElasticEntity._status, type = FieldType.Short) + private PlanStatus status; public final static String _status = "status"; - @Field(value = NestedDmpElasticEntity._accessType, type = FieldType.Short) - private DmpAccessType accessType; + @Field(value = NestedPlanElasticEntity._accessType, type = FieldType.Short) + private PlanAccessType accessType; public final static String _accessType = "accessType"; - @Field(value = NestedDmpElasticEntity._language, type = FieldType.Keyword) + @Field(value = NestedPlanElasticEntity._language, type = FieldType.Keyword) private String language; public final static String _language = "language"; - @Field(value = NestedDmpElasticEntity._blueprintId, type = FieldType.Keyword) + @Field(value = NestedPlanElasticEntity._blueprintId, type = FieldType.Keyword) private UUID blueprintId; public final static String _blueprintId = "blueprintId"; - @Field(value = NestedDmpElasticEntity._groupId, type = FieldType.Keyword) + @Field(value = NestedPlanElasticEntity._groupId, type = FieldType.Keyword) private UUID groupId; public final static String _groupId = "groupId"; - @Field(value = NestedDmpElasticEntity._finalizedAt, type = FieldType.Date) + @Field(value = NestedPlanElasticEntity._finalizedAt, type = FieldType.Date) private Date finalizedAt; public final static String _finalizedAt = "finalizedAt"; - @Field(value = NestedDmpElasticEntity._references, type = FieldType.Nested) + @Field(value = NestedPlanElasticEntity._references, type = FieldType.Nested) private List references; public final static String _references = "references"; - @Field(value = NestedDmpElasticEntity._collaborators, type = FieldType.Nested) + @Field(value = NestedPlanElasticEntity._collaborators, type = FieldType.Nested) private List collaborators; public final static String _collaborators = "collaborators"; - @Field(value = NestedDmpElasticEntity._dois, type = FieldType.Nested) + @Field(value = NestedPlanElasticEntity._dois, type = FieldType.Nested) private List dois; public final static String _dois = "dois"; @@ -104,19 +103,19 @@ public class NestedDmpElasticEntity { this.version = version; } - public DmpStatus getStatus() { + public PlanStatus getStatus() { return status; } - public void setStatus(DmpStatus status) { + public void setStatus(PlanStatus status) { this.status = status; } - public DmpAccessType getAccessType() { + public PlanAccessType getAccessType() { return accessType; } - public void setAccessType(DmpAccessType accessType) { + public void setAccessType(PlanAccessType accessType) { this.accessType = accessType; } @@ -176,11 +175,11 @@ public class NestedDmpElasticEntity { this.dois = dois; } - public DmpVersionStatus getVersionStatus() { + public PlanVersionStatus getVersionStatus() { return versionStatus; } - public void setVersionStatus(DmpVersionStatus versionStatus) { + public void setVersionStatus(PlanVersionStatus versionStatus) { this.versionStatus = versionStatus; } } 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 80528860f..9fde3a84b 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 @@ -11,17 +11,17 @@ import org.opencdmp.data.DescriptionReferenceEntity; import org.opencdmp.data.DescriptionTagEntity; import org.opencdmp.elastic.data.DescriptionElasticEntity; import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; -import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; +import org.opencdmp.elastic.data.nested.NestedPlanElasticEntity; 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.NestedPlanElasticBuilder; import org.opencdmp.elastic.elasticbuilder.nested.NestedReferenceElasticBuilder; import org.opencdmp.elastic.elasticbuilder.nested.NestedTagElasticBuilder; 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.model.plan.Plan; import org.opencdmp.query.*; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -54,7 +54,7 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder> referenceElasticEntityMap = this.collectDescriptionReferences(data); Map> tagElasticEntityMap = this.collectDescriptionTags(data); - Map dmpElasticEntityMap = this.collectDmps(data); + Map planElasticEntityMap = this.collectPlans(data); Map descriptionTemplateElasticEntityMap = this.collectDescriptionTemplates(data); List models = new ArrayList<>(); @@ -74,8 +74,8 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder collectDmps(List data) throws MyApplicationException { + private Map collectPlans(List data) throws MyApplicationException { if (data.isEmpty()) return null; - this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); + this.logger.debug("checking related - {}", Plan.class.getSimpleName()); - Map itemMap; - 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); + Map itemMap; + PlanQuery q = this.queryFactory.query(PlanQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(NestedPlanElasticBuilder.class).asForeignKey(q, NestedPlanElasticEntity::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/PlanElasticBuilder.java similarity index 64% rename from backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DmpElasticBuilder.java rename to backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/PlanElasticBuilder.java index 770d88732..b634f3cb8 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DmpElasticBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/PlanElasticBuilder.java @@ -7,10 +7,10 @@ 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.PlanElasticEntity; import org.opencdmp.elastic.data.nested.*; import org.opencdmp.elastic.elasticbuilder.nested.*; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.query.*; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,33 +23,33 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpElasticBuilder extends BaseElasticBuilder { +public class PlanElasticBuilder extends BaseElasticBuilder { private final QueryFactory queryFactory; private final BuilderFactory builderFactory; @Autowired - public DmpElasticBuilder( + public PlanElasticBuilder( ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpElasticBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanElasticBuilder.class))); this.queryFactory = queryFactory; this.builderFactory = builderFactory; } @Override - public List build(List data) throws MyApplicationException { + public List build(List data) throws MyApplicationException { if (data == null) return new ArrayList<>(); - Map> referenceElasticEntityMap = this.collectDmpReferences(data); + Map> referenceElasticEntityMap = this.collectPlanReferences(data); Map> descriptionElasticEntityMap = this.collectDescriptions(data); Map> collaboratorElasticEntityMap = this.collectCollaborators(data); Map> doiElasticEntityMap = this.collectDois(data); - Map> dmpDescriptionTemplateElasticEntityMap = this.collectDmpDescriptionTemplates(data); + Map> planDescriptionTemplateElasticEntityMap = this.collectPlanDescriptionTemplates(data); - List models = new ArrayList<>(); - for (DmpEntity d : data) { - DmpElasticEntity m = new DmpElasticEntity(); + List models = new ArrayList<>(); + for (PlanEntity d : data) { + PlanElasticEntity m = new PlanElasticEntity(); m.setId(d.getId()); m.setLabel(d.getLabel()); m.setDescription(d.getDescription()); @@ -71,7 +71,7 @@ public class DmpElasticBuilder extends BaseElasticBuilder> collectDmpReferences(List data) throws MyApplicationException { + private Map> collectPlanReferences(List data) throws MyApplicationException { if (data.isEmpty()) return null; - this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); + this.logger.debug("checking related - {}", PlanReference.class.getSimpleName()); - DmpReferenceQuery associationQuery = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active); - List associationEntities = associationQuery.collect(); + PlanReferenceQuery associationQuery = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().planIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active); + List associationEntities = associationQuery.collect(); - ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).disableTracking().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(PlanReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); Map itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId); Map> itemMap = new HashMap<>(); - for (DmpReferenceEntity associationEntity : associationEntities){ - if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>()); + for (PlanReferenceEntity associationEntity : associationEntities){ + if (!itemMap.containsKey(associationEntity.getPlanId())) itemMap.put(associationEntity.getPlanId(), new ArrayList<>()); NestedReferenceElasticEntity item = itemMapById.getOrDefault(associationEntity.getReferenceId(), null); - if (item != null) itemMap.get(associationEntity.getDmpId()).add(item); + if (item != null) itemMap.get(associationEntity.getPlanId()).add(item); } return itemMap; } - private Map> collectDescriptions(List data) throws MyApplicationException { + private Map> collectDescriptions(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", DescriptionEntity.class.getSimpleName()); Map> itemMap; - 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); + DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(this.queryFactory.query(PlanQuery.class).ids(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList()))); + itemMap = this.builderFactory.builder(NestedDescriptionElasticBuilder.class).asMasterKey(q, NestedDescriptionElasticEntity::getPlanId); return itemMap; } - private Map> collectDmpDescriptionTemplates(List data) throws MyApplicationException { + private Map> collectPlanDescriptionTemplates(List data) throws MyApplicationException { if (data.isEmpty()) return null; - this.logger.debug("checking related - {}", DmpDescriptionTemplateEntity.class.getSimpleName()); + this.logger.debug("checking related - {}", PlanDescriptionTemplateEntity.class.getSimpleName()); - Map> itemMap; - DmpDescriptionTemplateQuery q = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(NestedDmpDescriptionTemplateElasticBuilder.class).asMasterKey(q, NestedDmpDescriptionTemplateElasticEntity::getDmpId); + Map> itemMap; + PlanDescriptionTemplateQuery q = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(NestedPlanDescriptionTemplateElasticBuilder.class).asMasterKey(q, NestedPlanDescriptionTemplateElasticEntity::getPlanId); return itemMap; } - private Map> collectCollaborators(List data) throws MyApplicationException { + private Map> collectCollaborators(List data) throws MyApplicationException { if (data.isEmpty()) return null; - this.logger.debug("checking related - {}", DmpUserEntity.class.getSimpleName()); + this.logger.debug("checking related - {}", PlanUserEntity.class.getSimpleName()); - DmpUserQuery associationQuery = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active); - List associationEntities = associationQuery.collect(); + PlanUserQuery associationQuery = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active); + List associationEntities = associationQuery.collect(); Map itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId); Map> itemMap = new HashMap<>(); - for (DmpUserEntity associationEntity : associationEntities){ - if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>()); + for (PlanUserEntity associationEntity : associationEntities){ + if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getPlanId(), new ArrayList<>()); NestedCollaboratorElasticEntity item = itemMapById.getOrDefault(associationEntity.getId(), null); - if (item != null) itemMap.get(associationEntity.getDmpId()).add(item); + if (item != null) itemMap.get(associationEntity.getPlanId()).add(item); } return itemMap; } - private Map> collectDois(List data) throws MyApplicationException { + private Map> collectDois(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", EntityDoiEntity.class.getSimpleName()); - EntityDoiQuery associationQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().entityIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active); + EntityDoiQuery associationQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().entityIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active); List 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 bb4d0622d..77a17caaa 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 @@ -6,7 +6,7 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.logging.LoggerService; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpUserEntity; +import org.opencdmp.data.PlanUserEntity; import org.opencdmp.data.UserEntity; import org.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity; import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder; @@ -23,7 +23,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder { +public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder { private final QueryFactory queryFactory; @Autowired @@ -34,14 +34,14 @@ public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder build(List data) throws MyApplicationException { + public List build(List data) throws MyApplicationException { if (data == null) return new ArrayList<>(); List models = new ArrayList<>(); - List users = 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)); + List users = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(PlanUserEntity::getUserId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(User._id).ensure(User._name)); Map userNameMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, UserEntity::getName)); - for (DmpUserEntity d : data) { + for (PlanUserEntity d : data) { NestedCollaboratorElasticEntity m = new NestedCollaboratorElasticEntity(); m.setId(d.getId()); m.setUserId(d.getUserId()); 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 97f3f0af5..c7a97be50 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 @@ -55,7 +55,7 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder { +public class NestedPlanDescriptionTemplateElasticBuilder extends BaseElasticBuilder { @Autowired - public NestedDmpDescriptionTemplateElasticBuilder( + public NestedPlanDescriptionTemplateElasticBuilder( ConventionService conventionService) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedDmpDescriptionTemplateElasticBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedPlanDescriptionTemplateElasticBuilder.class))); } @Override - public List build(List data) throws MyApplicationException { + public List build(List data) throws MyApplicationException { if (data == null) return new ArrayList<>(); - List models = new ArrayList<>(); - for (DmpDescriptionTemplateEntity d : data) { - NestedDmpDescriptionTemplateElasticEntity m = new NestedDmpDescriptionTemplateElasticEntity(); + List models = new ArrayList<>(); + for (PlanDescriptionTemplateEntity d : data) { + NestedPlanDescriptionTemplateElasticEntity m = new NestedPlanDescriptionTemplateElasticEntity(); m.setId(d.getId()); - m.setDmpId(d.getDmpId()); + m.setPlanId(d.getPlanId()); m.setSectionId(d.getSectionId()); m.setDescriptionTemplateGroupId(d.getDescriptionTemplateGroupId()); models.add(m); 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/NestedPlanElasticBuilder.java similarity index 68% rename from backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDmpElasticBuilder.java rename to backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedPlanElasticBuilder.java index 55f67c1e4..7a0385395 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/NestedPlanElasticBuilder.java @@ -6,18 +6,18 @@ 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.PlanEntity; +import org.opencdmp.data.PlanReferenceEntity; +import org.opencdmp.data.PlanUserEntity; import org.opencdmp.data.EntityDoiEntity; import org.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity; -import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; +import org.opencdmp.elastic.data.nested.NestedPlanElasticEntity; 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.model.planreference.PlanReference; +import org.opencdmp.query.PlanReferenceQuery; +import org.opencdmp.query.PlanUserQuery; import org.opencdmp.query.EntityDoiQuery; import org.opencdmp.query.ReferenceQuery; import org.slf4j.LoggerFactory; @@ -31,31 +31,31 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class NestedDmpElasticBuilder extends BaseElasticBuilder { +public class NestedPlanElasticBuilder extends BaseElasticBuilder { private final QueryFactory queryFactory; private final BuilderFactory builderFactory; @Autowired - public NestedDmpElasticBuilder( + public NestedPlanElasticBuilder( ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedDmpElasticBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedPlanElasticBuilder.class))); this.queryFactory = queryFactory; this.builderFactory = builderFactory; } @Override - public List build(List data) throws MyApplicationException { + public List build(List data) throws MyApplicationException { if (data == null) return new ArrayList<>(); - Map> referenceElasticEntityMap = this.collectDmpReferences(data); + Map> referenceElasticEntityMap = this.collectPlanReferences(data); Map> collaboratorElasticEntityMap = this.collectCollaborators(data); Map> doiElasticEntityMap = this.collectDois(data); - List models = new ArrayList<>(); - for (DmpEntity d : data) { - NestedDmpElasticEntity m = new NestedDmpElasticEntity(); + List models = new ArrayList<>(); + for (PlanEntity d : data) { + NestedPlanElasticEntity m = new NestedPlanElasticEntity(); m.setId(d.getId()); m.setLabel(d.getLabel()); m.setDescription(d.getDescription()); @@ -79,51 +79,51 @@ public class NestedDmpElasticBuilder extends BaseElasticBuilder> collectDmpReferences(List data) throws MyApplicationException { + private Map> collectPlanReferences(List data) throws MyApplicationException { if (data.isEmpty()) return null; - this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); + this.logger.debug("checking related - {}", PlanReference.class.getSimpleName()); - DmpReferenceQuery associationQuery = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active); - List associationEntities = associationQuery.collect(); + PlanReferenceQuery associationQuery = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().planIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active); + List associationEntities = associationQuery.collect(); - ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).disableTracking().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(PlanReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); Map itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId); Map> itemMap = new HashMap<>(); - for (DmpReferenceEntity associationEntity : associationEntities){ - if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>()); + for (PlanReferenceEntity associationEntity : associationEntities){ + if (!itemMap.containsKey(associationEntity.getPlanId())) itemMap.put(associationEntity.getPlanId(), new ArrayList<>()); NestedReferenceElasticEntity item = itemMapById.getOrDefault(associationEntity.getReferenceId(), null); - if (item != null) itemMap.get(associationEntity.getDmpId()).add(item); + if (item != null) itemMap.get(associationEntity.getPlanId()).add(item); } return itemMap; } - private Map> collectCollaborators(List data) throws MyApplicationException { + private Map> collectCollaborators(List data) throws MyApplicationException { if (data.isEmpty()) return null; - this.logger.debug("checking related - {}", DmpUserEntity.class.getSimpleName()); + this.logger.debug("checking related - {}", PlanUserEntity.class.getSimpleName()); - DmpUserQuery associationQuery = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active); - List associationEntities = associationQuery.collect(); + PlanUserQuery associationQuery = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active); + List associationEntities = associationQuery.collect(); Map itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId); Map> itemMap = new HashMap<>(); - for (DmpUserEntity associationEntity : associationEntities){ - if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>()); + for (PlanUserEntity associationEntity : associationEntities){ + if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getPlanId(), new ArrayList<>()); NestedCollaboratorElasticEntity item = itemMapById.getOrDefault(associationEntity.getId(), null); - if (item != null) itemMap.get(associationEntity.getDmpId()).add(item); + if (item != null) itemMap.get(associationEntity.getPlanId()).add(item); } return itemMap; } - private Map> collectDois(List data) throws MyApplicationException { + private Map> collectDois(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", EntityDoiEntity.class.getSimpleName()); - EntityDoiQuery associationQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().entityIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active); + EntityDoiQuery associationQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().entityIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active); List 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/query/DescriptionElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/DescriptionElasticQuery.java index ab1fb2c39..2111fc08a 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/query/DescriptionElasticQuery.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/DescriptionElasticQuery.java @@ -16,13 +16,13 @@ import gr.cite.tools.elastic.query.ElasticQuery; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.DescriptionStatus; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.elastic.data.DescriptionElasticEntity; -import org.opencdmp.elastic.data.DmpElasticEntity; -import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; +import org.opencdmp.elastic.data.PlanElasticEntity; +import org.opencdmp.elastic.data.nested.NestedPlanElasticEntity; import org.opencdmp.service.elastic.AppElasticConfiguration; import org.opencdmp.service.elastic.ElasticService; import org.springframework.beans.factory.annotation.Autowired; @@ -43,7 +43,7 @@ public class DescriptionElasticQuery extends ElasticQuery ids; private String like; - private InnerObjectDmpElasticQuery dmpSubQuery; + private InnerObjectDmpElasticQuery planSubQuery; private Instant createdAfter; private Instant createdBefore; private Instant finalizedAfter; @@ -72,8 +72,8 @@ public class DescriptionElasticQuery extends ElasticQuery predicates = new ArrayList<>(); if (usePublic ) { predicates.add(this.and( - this.equals(new ElasticField(DescriptionElasticEntity._dmp + "." + DmpElasticEntity._status, this.entityClass()).disableInfer(true), DmpStatus.Finalized.getValue()), - this.equals(new ElasticField(DescriptionElasticEntity._dmp + "." + DmpElasticEntity._accessType, this.entityClass()).disableInfer(true), DmpAccessType.Public.getValue()) + this.equals(new ElasticField(DescriptionElasticEntity._dmp + "." + PlanElasticEntity._status, this.entityClass()).disableInfer(true), PlanStatus.Finalized.getValue()), + this.equals(new ElasticField(DescriptionElasticEntity._dmp + "." + PlanElasticEntity._accessType, this.entityClass()).disableInfer(true), PlanAccessType.Public.getValue()) )); } if (userId != null) { - NestedCollaboratorElasticQuery query = this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._collaborators); + NestedCollaboratorElasticQuery query = this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DescriptionElasticEntity._dmp + "." + NestedPlanElasticEntity._collaborators); query.userIds(userId); predicates.add(this.nestedQuery(query).build()._toQuery()); } @@ -230,13 +230,13 @@ public class DescriptionElasticQuery extends ElasticQuery { - - private String like; - private Collection ids; - private Collection excludedIds; - private Collection statuses; - private Collection versionStatuses; - private Collection accessTypes; - private Collection versions; - private Collection groupIds; - private NestedCollaboratorElasticQuery dmpUserSubQuery; - private NestedDescriptionElasticQuery descriptionSubQuery; - private NestedDmpDescriptionTemplateElasticQuery dmpDescriptionTemplateSubQuery; - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - - - public DmpElasticQuery dmpSubQuery(NestedCollaboratorElasticQuery subQuery) { - this.dmpUserSubQuery = subQuery; - return this; - } - - public DmpElasticQuery descriptionSubQuery(NestedDescriptionElasticQuery subQuery) { - this.descriptionSubQuery = subQuery; - return this; - } - - public DmpElasticQuery dmpDescriptionTemplateSubQuery(NestedDmpDescriptionTemplateElasticQuery subQuery) { - this.dmpDescriptionTemplateSubQuery = subQuery; - return this; - } - - public DmpElasticQuery like(String value) { - this.like = value; - return this; - } - - public DmpElasticQuery ids(UUID value) { - this.ids = List.of(value); - return this; - } - - public DmpElasticQuery ids(UUID... value) { - this.ids = Arrays.asList(value); - return this; - } - - public DmpElasticQuery ids(Collection values) { - this.ids = values; - return this; - } - - public DmpElasticQuery excludedIds(Collection values) { - this.excludedIds = values; - return this; - } - - public DmpElasticQuery excludedIds(UUID value) { - this.excludedIds = List.of(value); - return this; - } - - public DmpElasticQuery excludedIds(UUID... value) { - this.excludedIds = Arrays.asList(value); - return this; - } - - public DmpElasticQuery versionStatuses(DmpVersionStatus value) { - this.versionStatuses = List.of(value); - return this; - } - - public DmpElasticQuery versionStatuses(DmpVersionStatus... value) { - this.versionStatuses = Arrays.asList(value); - return this; - } - - public DmpElasticQuery versionStatuses(Collection values) { - this.versionStatuses = values; - return this; - } - - public DmpElasticQuery accessTypes(DmpAccessType value) { - this.accessTypes = List.of(value); - return this; - } - - public DmpElasticQuery accessTypes(DmpAccessType... value) { - this.accessTypes = Arrays.asList(value); - return this; - } - - public DmpElasticQuery accessTypes(Collection values) { - this.accessTypes = values; - return this; - } - - public DmpElasticQuery statuses(DmpStatus value) { - this.statuses = List.of(value); - return this; - } - - public DmpElasticQuery statuses(DmpStatus... value) { - this.statuses = Arrays.asList(value); - return this; - } - - public DmpElasticQuery statuses(Collection values) { - this.statuses = values; - return this; - } - - public DmpElasticQuery versions(Integer value) { - this.versions = List.of(value); - return this; - } - - public DmpElasticQuery versions(Integer... value) { - this.versions = Arrays.asList(value); - return this; - } - - public DmpElasticQuery versions(Collection values) { - this.versions = values; - return this; - } - - public DmpElasticQuery groupIds(UUID value) { - this.groupIds = List.of(value); - return this; - } - - public DmpElasticQuery groupIds(UUID... value) { - this.groupIds = Arrays.asList(value); - return this; - } - - public DmpElasticQuery groupIds(Collection values) { - this.groupIds = values; - return this; - } - - public DmpElasticQuery authorize(EnumSet values) { - this.authorize = values; - return this; - } - - private final QueryFactory queryFactory; - private final AppElasticConfiguration appElasticConfiguration; - private final ElasticService elasticService; - private final UserScope userScope; - private final TenantScope tenantScope; - private final AuthorizationService authService; - @Autowired - public DmpElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory, AppElasticConfiguration appElasticConfiguration, ElasticService elasticService, UserScope userScope, TenantScope tenantScope, AuthorizationService authService) { - super(elasticsearchTemplate, elasticProperties); - this.queryFactory = queryFactory; - this.appElasticConfiguration = appElasticConfiguration; - this.elasticService = elasticService; - this.userScope = userScope; - this.tenantScope = tenantScope; - this.authService = authService; - } - - @Override - protected Boolean isFalseQuery() { - return this.isEmpty(this.ids) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes)|| this.isEmpty(this.statuses); - } - - @Override - protected Class entityClass() { - return DmpElasticEntity.class; - } - - private Query applyTenant(List predicates){ - if (this.tenantScope.isSet()){ - Query tenantQuery; - if (this.tenantScope.isDefaultTenant()){ - tenantQuery = this.fieldNotExists(this.elasticFieldOf(DmpElasticEntity._tenantId))._toQuery(); - } - else { - try { - tenantQuery = this.or(this.fieldNotExists(this.elasticFieldOf(DmpElasticEntity._tenantId))._toQuery(), - this.equals(this.elasticFieldOf(DmpElasticEntity._tenantId), this.tenantScope.getTenant()))._toQuery(); - } catch (InvalidApplicationException e) { - throw new RuntimeException(e); - } - } - if (predicates == null) return tenantQuery; - else return this.and(tenantQuery, this.or(predicates)._toQuery()); - } else { - if (predicates != null) return this.or(predicates)._toQuery(); - } - return null; - } - @Override - protected Query applyAuthZ() { - - if (this.authorize.contains(AuthorizationFlags.None)) return this.applyTenant(null); - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDmp)) return this.applyTenant(null); - UUID userId = null; - boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); - if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe(); - - List predicates = new ArrayList<>(); - if (usePublic) { - predicates.add(this.and( - this.equals(this.elasticFieldOf(DmpElasticEntity._status), DmpStatus.Finalized.getValue()), - this.equals(this.elasticFieldOf(DmpElasticEntity._accessType), DmpAccessType.Public.getValue()) - )); - } - if (userId != null) { - NestedCollaboratorElasticQuery query = this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators); - query.userIds(userId); - predicates.add(this.nestedQuery(query).build()._toQuery()); - } - if (!predicates.isEmpty()) { - return this.applyTenant(predicates); - } else { - return this.equals(this.elasticFieldOf(DmpElasticEntity._id), UUID.randomUUID()); - } - } - - @Override - protected Query applyFilters() { - List predicates = new ArrayList<>(); - - if (this.like != null && !this.like.isBlank()) { - - if (!this.like.startsWith("*")) this.like = "*" + this.like; - if (!this.like.endsWith("*")) this.like = this.like + "*"; - ElasticFields elasticFields = this.elasticFieldsOf(); - elasticFields.add("*", null, true); - - predicates.add(this.or( - this.like(elasticFields, List.of(this.like))._toQuery() - , - QueryBuilders.nested().path(DmpElasticEntity._collaborators).query( - this.like(elasticFields, List.of(this.like))._toQuery() - ).build()._toQuery(), - QueryBuilders.nested().path(DmpElasticEntity._references).query( - this.like(elasticFields, List.of(this.like))._toQuery() - ).build()._toQuery(), - QueryBuilders.nested().path(DmpElasticEntity._descriptions + "." + NestedDescriptionElasticEntity._references).query( - this.like(elasticFields, List.of(this.like))._toQuery() - ).build()._toQuery(), - QueryBuilders.nested().path(DmpElasticEntity._descriptions + "." + NestedDescriptionElasticEntity._tags).query( - this.like(elasticFields, List.of(this.like))._toQuery() - ).build()._toQuery(), - QueryBuilders.nested().path(DmpElasticEntity._descriptions).query( - this.like(elasticFields, List.of(this.like))._toQuery() - ).build()._toQuery() - - )._toQuery()); - } - if (this.ids != null) { - predicates.add(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id), this.ids)._toQuery()); - } - if (this.groupIds != null) { - predicates.add(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._groupId), this.groupIds)._toQuery()); - } - if (this.versions != null) { - predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._version), this.versions.toArray(new Integer[this.versions.size()]))._toQuery()); - } - if (this.excludedIds != null) { - predicates.add(this.not(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id), this.excludedIds)._toQuery())._toQuery()); - } - if (this.statuses != null) { - predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._status), this.statuses.stream().map(DmpStatus::getValue).toList().toArray(new Short[this.statuses.size()]))._toQuery()); - } - if (this.versionStatuses != null) { - predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._versionStatus), this.versionStatuses.stream().map(DmpVersionStatus::getValue).toList().toArray(new Short[this.versionStatuses.size()]))._toQuery()); - } - if (this.accessTypes != null) { - predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._accessType), this.accessTypes.stream().map(DmpAccessType::getValue).toList().toArray(new Short[this.accessTypes.size()]))._toQuery()); - } - if (this.dmpUserSubQuery != null) { - predicates.add(this.nestedQuery( this.dmpUserSubQuery.nestedPath(DmpElasticEntity._collaborators)).build()._toQuery()); - } - if (this.descriptionSubQuery != null) { - predicates.add(this.nestedQuery( this.descriptionSubQuery.nestedPath(DmpElasticEntity._descriptions)).build()._toQuery()); - } - if (this.dmpDescriptionTemplateSubQuery != null) { - predicates.add(this.nestedQuery( this.dmpDescriptionTemplateSubQuery.nestedPath(DmpElasticEntity._dmpDescriptionTemplates)).build()._toQuery()); - } - - if (!predicates.isEmpty()) { - return this.and(predicates); - } else { - return null; - } - } - - @Override - public DmpElasticEntity convert(Map rawData, Set columns) { - DmpElasticEntity mocDoc = new DmpElasticEntity(); - if (columns.contains(DmpElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._id), UUID.class)); - if (columns.contains(DmpElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._label), String.class)); - if (columns.contains(DmpElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._description), String.class)); - if (columns.contains(DmpElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._status), DmpStatus.class)); - if (columns.contains(DmpElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._versionStatus), DmpVersionStatus.class)); - if (columns.contains(DmpElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._version), Short.class)); - if (columns.contains(DmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._groupId), UUID.class)); - if (columns.contains(DmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._accessType), DmpAccessType.class)); - if (columns.contains(DmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._finalizedAt), Date.class)); - if (columns.contains(DmpElasticEntity._createdAt)) mocDoc.setCreatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._createdAt), Date.class)); - if (columns.contains(DmpElasticEntity._updatedAt)) mocDoc.setUpdatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._updatedAt), Date.class)); - mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), DmpElasticEntity._collaborators, null)); - mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), DmpElasticEntity._references, null)); - mocDoc.setDescriptions(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionElasticQuery.class), DmpElasticEntity._descriptions, null)); - mocDoc.setDmpDescriptionTemplates(this.convertNested(rawData, columns, this.queryFactory.query(NestedDmpDescriptionTemplateElasticQuery.class), DmpElasticEntity._dmpDescriptionTemplates, null)); - return mocDoc; - } - - @Override - protected ElasticField fieldNameOf(FieldResolver item) { - if (item.match(DmpElasticEntity._id)) return this.elasticFieldOf(DmpElasticEntity._id); - else if (item.match(DmpElasticEntity._label)) return item instanceof OrderingFieldResolver ? this.elasticFieldOf(DmpElasticEntity._label).subfield(ElasticConstants.SubFields.keyword) : this.elasticFieldOf(DmpElasticEntity._label); - else if (item.match(DmpElasticEntity._description)) return this.elasticFieldOf(DmpElasticEntity._description); - else if (item.match(DmpElasticEntity._status)) return this.elasticFieldOf(DmpElasticEntity._status); - else if (item.match(DmpElasticEntity._version)) return this.elasticFieldOf(DmpElasticEntity._version); - else if (item.match(DmpElasticEntity._versionStatus)) return this.elasticFieldOf(DmpElasticEntity._versionStatus); - else if (item.match(DmpElasticEntity._groupId)) return this.elasticFieldOf(DmpElasticEntity._groupId); - else if (item.match(DmpElasticEntity._finalizedAt)) return this.elasticFieldOf(DmpElasticEntity._finalizedAt); - else if (item.match(DmpElasticEntity._updatedAt)) return this.elasticFieldOf(DmpElasticEntity._updatedAt); - else if (item.match(DmpElasticEntity._createdAt)) return this.elasticFieldOf(DmpElasticEntity._createdAt); - else if (item.match(DmpElasticEntity._accessType)) return this.elasticFieldOf(DmpElasticEntity._accessType); - else if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._collaborators)); - else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._references)); - else if (item.prefix(DmpElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(DmpElasticEntity._descriptions).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._descriptions)); - else if (item.prefix(DmpElasticEntity._dmpDescriptionTemplates)) return this.queryFactory.query(NestedDmpDescriptionTemplateElasticQuery.class).nestedPath(DmpElasticEntity._dmpDescriptionTemplates).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._dmpDescriptionTemplates)); - else return null; - } - - @Override - protected String[] getIndex() { - List indexNames = new ArrayList<>(); - indexNames.add(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()); - try { - this.elasticService.ensureDescriptionIndex(); - } catch (IOException e) { - throw new RuntimeException(e); - } - return indexNames.toArray(new String[indexNames.size()]); - } - - @Override - protected UUID toKey(String key) { - return UUID.fromString(key); - } - - @Override - protected ElasticField getKeyField() { - return this.elasticFieldOf(DmpElasticEntity._id); - } - - @Override - protected ElasticNestedQuery nestedQueryOf(FieldResolver item) { - if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators); - else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references); - else if (item.prefix(DmpElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(DmpElasticEntity._descriptions); - else if (item.prefix(DmpElasticEntity._dmpDescriptionTemplates)) return this.queryFactory.query(NestedDmpDescriptionTemplateElasticQuery.class).nestedPath(DmpElasticEntity._dmpDescriptionTemplates); - else return null; - } -} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/query/InnerObjectDmpElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/InnerObjectDmpElasticQuery.java index 848293126..a41efc6f2 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/query/InnerObjectDmpElasticQuery.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/InnerObjectDmpElasticQuery.java @@ -9,11 +9,11 @@ import gr.cite.tools.elastic.query.ElasticField; import gr.cite.tools.elastic.query.ElasticFields; import gr.cite.tools.elastic.query.ElasticInnerObjectQuery; import gr.cite.tools.elastic.query.ElasticNestedQuery; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; -import org.opencdmp.commons.enums.DmpVersionStatus; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; import org.opencdmp.elastic.data.DescriptionElasticEntity; -import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; +import org.opencdmp.elastic.data.nested.NestedPlanElasticEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; @@ -26,13 +26,13 @@ import java.util.stream.Collectors; @Component //Like in C# make it Transient @Scope(BeanDefinition.SCOPE_PROTOTYPE) -public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery { +public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery { private String like; private Collection ids; private Collection excludedIds; - private Collection statuses; - private Collection versionStatuses; - private Collection accessTypes; + private Collection statuses; + private Collection versionStatuses; + private Collection accessTypes; private Collection versions; private Collection groupIds; private NestedCollaboratorElasticQuery dmpUserSubQuery; @@ -78,47 +78,47 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery values) { + public InnerObjectDmpElasticQuery versionStatuses(Collection values) { this.versionStatuses = values; return this; } - public InnerObjectDmpElasticQuery accessTypes(DmpAccessType value) { + public InnerObjectDmpElasticQuery accessTypes(PlanAccessType value) { this.accessTypes = List.of(value); return this; } - public InnerObjectDmpElasticQuery accessTypes(DmpAccessType... value) { + public InnerObjectDmpElasticQuery accessTypes(PlanAccessType... value) { this.accessTypes = Arrays.asList(value); return this; } - public InnerObjectDmpElasticQuery accessTypes(Collection values) { + public InnerObjectDmpElasticQuery accessTypes(Collection values) { this.accessTypes = values; return this; } - public InnerObjectDmpElasticQuery statuses(DmpStatus value) { + public InnerObjectDmpElasticQuery statuses(PlanStatus value) { this.statuses = List.of(value); return this; } - public InnerObjectDmpElasticQuery statuses(DmpStatus... value) { + public InnerObjectDmpElasticQuery statuses(PlanStatus... value) { this.statuses = Arrays.asList(value); return this; } - public InnerObjectDmpElasticQuery statuses(Collection values) { + public InnerObjectDmpElasticQuery statuses(Collection values) { this.statuses = values; return this; } @@ -170,8 +170,8 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery entityClass() { - return NestedDmpElasticEntity.class; + protected Class entityClass() { + return NestedPlanElasticEntity.class; } @Override @@ -187,33 +187,33 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery x.getValue()).collect(Collectors.toList()).toArray(new Short[this.statuses.size()]))._toQuery()); + predicates.add(this.contains(this.elasticFieldOf(NestedPlanElasticEntity._status).disableInfer(true), this.statuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.statuses.size()]))._toQuery()); } if (this.versionStatuses != null) { - predicates.add(this.contains(this.elasticFieldOf(NestedDmpElasticEntity._versionStatus).disableInfer(true), this.versionStatuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.versionStatuses.size()]))._toQuery()); + predicates.add(this.contains(this.elasticFieldOf(NestedPlanElasticEntity._versionStatus).disableInfer(true), this.versionStatuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.versionStatuses.size()]))._toQuery()); } if (this.accessTypes != null) { - predicates.add(this.contains(this.elasticFieldOf(NestedDmpElasticEntity._accessType).disableInfer(true), this.accessTypes.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.accessTypes.size()]))._toQuery()); + predicates.add(this.contains(this.elasticFieldOf(NestedPlanElasticEntity._accessType).disableInfer(true), this.accessTypes.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.accessTypes.size()]))._toQuery()); } if (this.dmpUserSubQuery != null) { - predicates.add(this.nestedQuery( this.dmpUserSubQuery.nestedPath(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._collaborators)).build()._toQuery()); + predicates.add(this.nestedQuery( this.dmpUserSubQuery.nestedPath(DescriptionElasticEntity._dmp + "." + NestedPlanElasticEntity._collaborators)).build()._toQuery()); } if (!predicates.isEmpty()) { @@ -224,35 +224,35 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery rawData, Set columns) { - NestedDmpElasticEntity mocDoc = new NestedDmpElasticEntity(); - if (columns.contains(NestedDmpElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._id), UUID.class)); - if (columns.contains(NestedDmpElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._label), String.class)); - if (columns.contains(NestedDmpElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._description), String.class)); - if (columns.contains(NestedDmpElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._status), DmpStatus.class)); - if (columns.contains(NestedDmpElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._versionStatus), DmpVersionStatus.class)); - if (columns.contains(NestedDmpElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._version), Short.class)); - if (columns.contains(NestedDmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._groupId), UUID.class)); - if (columns.contains(NestedDmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._accessType), DmpAccessType.class)); - if (columns.contains(NestedDmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._finalizedAt), Date.class)); - mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), NestedDmpElasticEntity._collaborators, null)); - mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), NestedDmpElasticEntity._references, null)); + public NestedPlanElasticEntity convert(Map rawData, Set columns) { + NestedPlanElasticEntity mocDoc = new NestedPlanElasticEntity(); + if (columns.contains(NestedPlanElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._id), UUID.class)); + if (columns.contains(NestedPlanElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._label), String.class)); + if (columns.contains(NestedPlanElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._description), String.class)); + if (columns.contains(NestedPlanElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._status), PlanStatus.class)); + if (columns.contains(NestedPlanElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._versionStatus), PlanVersionStatus.class)); + if (columns.contains(NestedPlanElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._version), Short.class)); + if (columns.contains(NestedPlanElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._groupId), UUID.class)); + if (columns.contains(NestedPlanElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._accessType), PlanAccessType.class)); + if (columns.contains(NestedPlanElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._finalizedAt), Date.class)); + mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), NestedPlanElasticEntity._collaborators, null)); + mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), NestedPlanElasticEntity._references, null)); return mocDoc; } @Override protected ElasticField fieldNameOf(FieldResolver item) { - if (item.match(NestedDmpElasticEntity._id)) return this.elasticFieldOf(NestedDmpElasticEntity._id); - else if (item.match(NestedDmpElasticEntity._label)) return this.elasticFieldOf(NestedDmpElasticEntity._label); - else if (item.match(NestedDmpElasticEntity._description)) return this.elasticFieldOf(NestedDmpElasticEntity._description); - else if (item.match(NestedDmpElasticEntity._status)) return this.elasticFieldOf(NestedDmpElasticEntity._status); - else if (item.match(NestedDmpElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDmpElasticEntity._versionStatus); - else if (item.match(NestedDmpElasticEntity._version)) return this.elasticFieldOf(NestedDmpElasticEntity._version); - else if (item.match(NestedDmpElasticEntity._groupId)) return this.elasticFieldOf(NestedDmpElasticEntity._groupId); - else if (item.match(NestedDmpElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedDmpElasticEntity._finalizedAt); - else if (item.match(NestedDmpElasticEntity._accessType)) return this.elasticFieldOf(NestedDmpElasticEntity._accessType); - else if (item.prefix(NestedDmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedDmpElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, NestedDmpElasticEntity._collaborators)); - else if (item.prefix(NestedDmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedDmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, NestedDmpElasticEntity._references)); + if (item.match(NestedPlanElasticEntity._id)) return this.elasticFieldOf(NestedPlanElasticEntity._id); + else if (item.match(NestedPlanElasticEntity._label)) return this.elasticFieldOf(NestedPlanElasticEntity._label); + else if (item.match(NestedPlanElasticEntity._description)) return this.elasticFieldOf(NestedPlanElasticEntity._description); + else if (item.match(NestedPlanElasticEntity._status)) return this.elasticFieldOf(NestedPlanElasticEntity._status); + else if (item.match(NestedPlanElasticEntity._versionStatus)) return this.elasticFieldOf(NestedPlanElasticEntity._versionStatus); + else if (item.match(NestedPlanElasticEntity._version)) return this.elasticFieldOf(NestedPlanElasticEntity._version); + else if (item.match(NestedPlanElasticEntity._groupId)) return this.elasticFieldOf(NestedPlanElasticEntity._groupId); + else if (item.match(NestedPlanElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedPlanElasticEntity._finalizedAt); + else if (item.match(NestedPlanElasticEntity._accessType)) return this.elasticFieldOf(NestedPlanElasticEntity._accessType); + else if (item.prefix(NestedPlanElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedPlanElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, NestedPlanElasticEntity._collaborators)); + else if (item.prefix(NestedPlanElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedPlanElasticEntity._references).fieldNameOf(this.extractPrefixed(item, NestedPlanElasticEntity._references)); else return null; } @@ -268,13 +268,13 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery nestedQueryOf(FieldResolver item) { - if (item.prefix(NestedDmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedDmpElasticEntity._collaborators); - else if (item.prefix(NestedDmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedDmpElasticEntity._references); + if (item.prefix(NestedPlanElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedPlanElasticEntity._collaborators); + else if (item.prefix(NestedPlanElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedPlanElasticEntity._references); else return null; } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/query/NestedCollaboratorElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/NestedCollaboratorElasticQuery.java index e2e1760d0..360162908 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/query/NestedCollaboratorElasticQuery.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/NestedCollaboratorElasticQuery.java @@ -6,7 +6,7 @@ import gr.cite.tools.elastic.configuration.ElasticProperties; import gr.cite.tools.elastic.mapper.FieldBasedMapper; import gr.cite.tools.elastic.query.ElasticField; import gr.cite.tools.elastic.query.ElasticNestedQuery; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -22,7 +22,7 @@ public class NestedCollaboratorElasticQuery extends ElasticNestedQuery userIds; - private Collection userRoles; + private Collection userRoles; public NestedCollaboratorElasticQuery ids(UUID value) { this.ids = List.of(value); @@ -54,17 +54,17 @@ public class NestedCollaboratorElasticQuery extends ElasticNestedQuery values) { + public NestedCollaboratorElasticQuery userRoles(Collection values) { this.userRoles = values; return this; } @@ -110,7 +110,7 @@ public class NestedCollaboratorElasticQuery extends ElasticNestedQuery { - private Collection ids; - private Collection excludedIds; - private Collection descriptionTemplateGroupIds; - private Collection dmpIds; - private Collection sectionIds; - - private String nestedPath; - - public NestedDmpDescriptionTemplateElasticQuery ids(UUID value) { - this.ids = List.of(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery ids(UUID... value) { - this.ids = Arrays.asList(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery ids(Collection values) { - this.ids = values; - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery excludedIds(UUID value) { - this.excludedIds = List.of(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery excludedIds(UUID... value) { - this.excludedIds = Arrays.asList(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery excludedIds(Collection values) { - this.excludedIds = values; - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery dmpIds(UUID value) { - this.dmpIds = List.of(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery dmpIds(UUID... value) { - this.dmpIds = Arrays.asList(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery dmpIds(Collection values) { - this.dmpIds = values; - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery descriptionTemplateGroupIds(UUID value) { - this.descriptionTemplateGroupIds = List.of(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery descriptionTemplateGroupIds(UUID... value) { - this.descriptionTemplateGroupIds = Arrays.asList(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery descriptionTemplateGroupIds(Collection values) { - this.descriptionTemplateGroupIds = values; - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery sectionIds(UUID value) { - this.sectionIds = List.of(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery sectionIds(UUID... value) { - this.sectionIds = Arrays.asList(value); - return this; - } - - public NestedDmpDescriptionTemplateElasticQuery sectionIds(Collection values) { - this.sectionIds = values; - return this; - } - - @Override - public NestedDmpDescriptionTemplateElasticQuery nestedPath(String value) { - this.nestedPath = value; - return this; - } - - - public NestedDmpDescriptionTemplateElasticQuery( - ElasticsearchTemplate elasticsearchRestTemplate, - ElasticProperties elasticProperties - ) { - super(elasticsearchRestTemplate, elasticProperties); - } - - @Override - protected Class entityClass() { - return NestedDmpDescriptionTemplateElasticEntity.class; - } - - @Override - protected Boolean isFalseQuery() { - return false; - } - - @Override - protected Query applyAuthZ() { - return null; - } - - @Override - protected Query applyFilters() { - List predicates = new ArrayList<>(); - if (this.ids != null) { - predicates.add(this.containsUUID(this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._id), this.ids)._toQuery()); - } - if (this.excludedIds != null) { - predicates.add(this.not(this.containsUUID(this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._id), this.excludedIds)._toQuery())._toQuery()); - } - - if (this.descriptionTemplateGroupIds != null) { - predicates.add(this.containsUUID(this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._descriptionTemplateGroupId), this.descriptionTemplateGroupIds)._toQuery()); - } - - if (this.sectionIds != null) { - predicates.add(this.containsUUID(this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._sectionId), this.sectionIds)._toQuery()); - } - - if (this.dmpIds != null) { - predicates.add(this.containsUUID(this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._dmpId), this.dmpIds)._toQuery()); - } - - if (!predicates.isEmpty()) { - return this.and(predicates); - } else { - return null; - } - } - - @Override - public NestedDmpDescriptionTemplateElasticEntity convert(Map rawData, Set columns) { - NestedDmpDescriptionTemplateElasticEntity mocDoc = new NestedDmpDescriptionTemplateElasticEntity(); - if (columns.contains(NestedDmpDescriptionTemplateElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpDescriptionTemplateElasticEntity._id), UUID.class)); - if (columns.contains(NestedDmpDescriptionTemplateElasticEntity._descriptionTemplateGroupId)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpDescriptionTemplateElasticEntity._descriptionTemplateGroupId), UUID.class)); - if (columns.contains(NestedDmpDescriptionTemplateElasticEntity._sectionId)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpDescriptionTemplateElasticEntity._sectionId), UUID.class)); - if (columns.contains(NestedDmpDescriptionTemplateElasticEntity._dmpId)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpDescriptionTemplateElasticEntity._dmpId), UUID.class)); - return mocDoc; - } - - @Override - protected ElasticField fieldNameOf(FieldResolver item) { - if (item.match(NestedDmpDescriptionTemplateElasticEntity._id)) return this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._id).disableInfer(true); - else if (item.match(NestedDmpDescriptionTemplateElasticEntity._descriptionTemplateGroupId)) return this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._descriptionTemplateGroupId).disableInfer(true); - else if (item.match(NestedDmpDescriptionTemplateElasticEntity._sectionId)) return this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._sectionId).disableInfer(true); - else if (item.match(NestedDmpDescriptionTemplateElasticEntity._dmpId)) return this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._dmpId).disableInfer(true); - else return null; - } - - @Override - protected String getNestedPath() { - return this.nestedPath; - } - - @Override - protected UUID toKey(String key) { - return UUID.fromString(key); - } - - @Override - protected ElasticField getKeyField() { - return this.elasticFieldOf(NestedDmpDescriptionTemplateElasticEntity._id); - } - - @Override - protected ElasticNestedQuery nestedQueryOf(FieldResolver item) { - return null; - } -} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/query/NestedPlanDescriptionTemplateElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/NestedPlanDescriptionTemplateElasticQuery.java new file mode 100644 index 000000000..1840374e0 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/NestedPlanDescriptionTemplateElasticQuery.java @@ -0,0 +1,199 @@ +package org.opencdmp.elastic.query; + +import co.elastic.clients.elasticsearch._types.query_dsl.Query; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.elastic.configuration.ElasticProperties; +import gr.cite.tools.elastic.mapper.FieldBasedMapper; +import gr.cite.tools.elastic.query.ElasticField; +import gr.cite.tools.elastic.query.ElasticNestedQuery; +import org.opencdmp.elastic.data.nested.NestedPlanDescriptionTemplateElasticEntity; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class NestedPlanDescriptionTemplateElasticQuery extends ElasticNestedQuery { + private Collection ids; + private Collection excludedIds; + private Collection descriptionTemplateGroupIds; + private Collection planIds; + private Collection sectionIds; + + private String nestedPath; + + public NestedPlanDescriptionTemplateElasticQuery ids(UUID value) { + this.ids = List.of(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery ids(UUID... value) { + this.ids = Arrays.asList(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery ids(Collection values) { + this.ids = values; + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery excludedIds(UUID value) { + this.excludedIds = List.of(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery excludedIds(UUID... value) { + this.excludedIds = Arrays.asList(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery excludedIds(Collection values) { + this.excludedIds = values; + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery planIds(UUID value) { + this.planIds = List.of(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery planIds(UUID... value) { + this.planIds = Arrays.asList(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery planIds(Collection values) { + this.planIds = values; + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery descriptionTemplateGroupIds(UUID value) { + this.descriptionTemplateGroupIds = List.of(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery descriptionTemplateGroupIds(UUID... value) { + this.descriptionTemplateGroupIds = Arrays.asList(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery descriptionTemplateGroupIds(Collection values) { + this.descriptionTemplateGroupIds = values; + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery sectionIds(UUID value) { + this.sectionIds = List.of(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery sectionIds(UUID... value) { + this.sectionIds = Arrays.asList(value); + return this; + } + + public NestedPlanDescriptionTemplateElasticQuery sectionIds(Collection values) { + this.sectionIds = values; + return this; + } + + @Override + public NestedPlanDescriptionTemplateElasticQuery nestedPath(String value) { + this.nestedPath = value; + return this; + } + + + public NestedPlanDescriptionTemplateElasticQuery( + ElasticsearchTemplate elasticsearchRestTemplate, + ElasticProperties elasticProperties + ) { + super(elasticsearchRestTemplate, elasticProperties); + } + + @Override + protected Class entityClass() { + return NestedPlanDescriptionTemplateElasticEntity.class; + } + + @Override + protected Boolean isFalseQuery() { + return false; + } + + @Override + protected Query applyAuthZ() { + return null; + } + + @Override + protected Query applyFilters() { + List predicates = new ArrayList<>(); + if (this.ids != null) { + predicates.add(this.containsUUID(this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._id), this.ids)._toQuery()); + } + if (this.excludedIds != null) { + predicates.add(this.not(this.containsUUID(this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._id), this.excludedIds)._toQuery())._toQuery()); + } + + if (this.descriptionTemplateGroupIds != null) { + predicates.add(this.containsUUID(this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._descriptionTemplateGroupId), this.descriptionTemplateGroupIds)._toQuery()); + } + + if (this.sectionIds != null) { + predicates.add(this.containsUUID(this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._sectionId), this.sectionIds)._toQuery()); + } + + if (this.planIds != null) { + predicates.add(this.containsUUID(this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._dmpId), this.planIds)._toQuery()); + } + + if (!predicates.isEmpty()) { + return this.and(predicates); + } else { + return null; + } + } + + @Override + public NestedPlanDescriptionTemplateElasticEntity convert(Map rawData, Set columns) { + NestedPlanDescriptionTemplateElasticEntity mocDoc = new NestedPlanDescriptionTemplateElasticEntity(); + if (columns.contains(NestedPlanDescriptionTemplateElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanDescriptionTemplateElasticEntity._id), UUID.class)); + if (columns.contains(NestedPlanDescriptionTemplateElasticEntity._descriptionTemplateGroupId)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanDescriptionTemplateElasticEntity._descriptionTemplateGroupId), UUID.class)); + if (columns.contains(NestedPlanDescriptionTemplateElasticEntity._sectionId)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanDescriptionTemplateElasticEntity._sectionId), UUID.class)); + if (columns.contains(NestedPlanDescriptionTemplateElasticEntity._dmpId)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanDescriptionTemplateElasticEntity._dmpId), UUID.class)); + return mocDoc; + } + + @Override + protected ElasticField fieldNameOf(FieldResolver item) { + if (item.match(NestedPlanDescriptionTemplateElasticEntity._id)) return this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._id).disableInfer(true); + else if (item.match(NestedPlanDescriptionTemplateElasticEntity._descriptionTemplateGroupId)) return this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._descriptionTemplateGroupId).disableInfer(true); + else if (item.match(NestedPlanDescriptionTemplateElasticEntity._sectionId)) return this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._sectionId).disableInfer(true); + else if (item.match(NestedPlanDescriptionTemplateElasticEntity._dmpId)) return this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._dmpId).disableInfer(true); + else return null; + } + + @Override + protected String getNestedPath() { + return this.nestedPath; + } + + @Override + protected UUID toKey(String key) { + return UUID.fromString(key); + } + + @Override + protected ElasticField getKeyField() { + return this.elasticFieldOf(NestedPlanDescriptionTemplateElasticEntity._id); + } + + @Override + protected ElasticNestedQuery nestedQueryOf(FieldResolver item) { + return null; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/elastic/query/PlanElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/PlanElasticQuery.java new file mode 100644 index 000000000..c96414d73 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/PlanElasticQuery.java @@ -0,0 +1,403 @@ +package org.opencdmp.elastic.query; + +import co.elastic.clients.elasticsearch._types.query_dsl.Query; +import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.data.query.OrderingFieldResolver; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.elastic.ElasticConstants; +import gr.cite.tools.elastic.configuration.ElasticProperties; +import gr.cite.tools.elastic.mapper.FieldBasedMapper; +import gr.cite.tools.elastic.query.ElasticField; +import gr.cite.tools.elastic.query.ElasticFields; +import gr.cite.tools.elastic.query.ElasticNestedQuery; +import gr.cite.tools.elastic.query.ElasticQuery; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; +import org.opencdmp.commons.scope.tenant.TenantScope; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.elastic.data.PlanElasticEntity; +import org.opencdmp.elastic.data.nested.NestedDescriptionElasticEntity; +import org.opencdmp.service.elastic.AppElasticConfiguration; +import org.opencdmp.service.elastic.ElasticService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.Scope; +import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; +import org.springframework.stereotype.Component; + +import javax.management.InvalidApplicationException; +import java.io.IOException; +import java.util.*; + +@Component +//Like in C# make it Transient +@Scope(BeanDefinition.SCOPE_PROTOTYPE) +public class PlanElasticQuery extends ElasticQuery { + + private String like; + private Collection ids; + private Collection excludedIds; + private Collection statuses; + private Collection versionStatuses; + private Collection accessTypes; + private Collection versions; + private Collection groupIds; + private NestedCollaboratorElasticQuery planUserSubQuery; + private NestedDescriptionElasticQuery descriptionSubQuery; + private NestedPlanDescriptionTemplateElasticQuery planDescriptionTemplateSubQuery; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + + public PlanElasticQuery planSubQuery(NestedCollaboratorElasticQuery subQuery) { + this.planUserSubQuery = subQuery; + return this; + } + + public PlanElasticQuery descriptionSubQuery(NestedDescriptionElasticQuery subQuery) { + this.descriptionSubQuery = subQuery; + return this; + } + + public PlanElasticQuery planDescriptionTemplateSubQuery(NestedPlanDescriptionTemplateElasticQuery subQuery) { + this.planDescriptionTemplateSubQuery = subQuery; + return this; + } + + public PlanElasticQuery like(String value) { + this.like = value; + return this; + } + + public PlanElasticQuery ids(UUID value) { + this.ids = List.of(value); + return this; + } + + public PlanElasticQuery ids(UUID... value) { + this.ids = Arrays.asList(value); + return this; + } + + public PlanElasticQuery ids(Collection values) { + this.ids = values; + return this; + } + + public PlanElasticQuery excludedIds(Collection values) { + this.excludedIds = values; + return this; + } + + public PlanElasticQuery excludedIds(UUID value) { + this.excludedIds = List.of(value); + return this; + } + + public PlanElasticQuery excludedIds(UUID... value) { + this.excludedIds = Arrays.asList(value); + return this; + } + + public PlanElasticQuery versionStatuses(PlanVersionStatus value) { + this.versionStatuses = List.of(value); + return this; + } + + public PlanElasticQuery versionStatuses(PlanVersionStatus... value) { + this.versionStatuses = Arrays.asList(value); + return this; + } + + public PlanElasticQuery versionStatuses(Collection values) { + this.versionStatuses = values; + return this; + } + + public PlanElasticQuery accessTypes(PlanAccessType value) { + this.accessTypes = List.of(value); + return this; + } + + public PlanElasticQuery accessTypes(PlanAccessType... value) { + this.accessTypes = Arrays.asList(value); + return this; + } + + public PlanElasticQuery accessTypes(Collection values) { + this.accessTypes = values; + return this; + } + + public PlanElasticQuery statuses(PlanStatus value) { + this.statuses = List.of(value); + return this; + } + + public PlanElasticQuery statuses(PlanStatus... value) { + this.statuses = Arrays.asList(value); + return this; + } + + public PlanElasticQuery statuses(Collection values) { + this.statuses = values; + return this; + } + + public PlanElasticQuery versions(Integer value) { + this.versions = List.of(value); + return this; + } + + public PlanElasticQuery versions(Integer... value) { + this.versions = Arrays.asList(value); + return this; + } + + public PlanElasticQuery versions(Collection values) { + this.versions = values; + return this; + } + + public PlanElasticQuery groupIds(UUID value) { + this.groupIds = List.of(value); + return this; + } + + public PlanElasticQuery groupIds(UUID... value) { + this.groupIds = Arrays.asList(value); + return this; + } + + public PlanElasticQuery groupIds(Collection values) { + this.groupIds = values; + return this; + } + + public PlanElasticQuery authorize(EnumSet values) { + this.authorize = values; + return this; + } + + private final QueryFactory queryFactory; + private final AppElasticConfiguration appElasticConfiguration; + private final ElasticService elasticService; + private final UserScope userScope; + private final TenantScope tenantScope; + private final AuthorizationService authService; + @Autowired + public PlanElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory, AppElasticConfiguration appElasticConfiguration, ElasticService elasticService, UserScope userScope, TenantScope tenantScope, AuthorizationService authService) { + super(elasticsearchTemplate, elasticProperties); + this.queryFactory = queryFactory; + this.appElasticConfiguration = appElasticConfiguration; + this.elasticService = elasticService; + this.userScope = userScope; + this.tenantScope = tenantScope; + this.authService = authService; + } + + @Override + protected Boolean isFalseQuery() { + return this.isEmpty(this.ids) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes)|| this.isEmpty(this.statuses); + } + + @Override + protected Class entityClass() { + return PlanElasticEntity.class; + } + + private Query applyTenant(List predicates){ + if (this.tenantScope.isSet()){ + Query tenantQuery; + if (this.tenantScope.isDefaultTenant()){ + tenantQuery = this.fieldNotExists(this.elasticFieldOf(PlanElasticEntity._tenantId))._toQuery(); + } + else { + try { + tenantQuery = this.or(this.fieldNotExists(this.elasticFieldOf(PlanElasticEntity._tenantId))._toQuery(), + this.equals(this.elasticFieldOf(PlanElasticEntity._tenantId), this.tenantScope.getTenant()))._toQuery(); + } catch (InvalidApplicationException e) { + throw new RuntimeException(e); + } + } + if (predicates == null) return tenantQuery; + else return this.and(tenantQuery, this.or(predicates)._toQuery()); + } else { + if (predicates != null) return this.or(predicates)._toQuery(); + } + return null; + } + @Override + protected Query applyAuthZ() { + + if (this.authorize.contains(AuthorizationFlags.None)) return this.applyTenant(null); + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowsePlan)) return this.applyTenant(null); + UUID userId = null; + boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); + if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe(); + + List predicates = new ArrayList<>(); + if (usePublic) { + predicates.add(this.and( + this.equals(this.elasticFieldOf(PlanElasticEntity._status), PlanStatus.Finalized.getValue()), + this.equals(this.elasticFieldOf(PlanElasticEntity._accessType), PlanAccessType.Public.getValue()) + )); + } + if (userId != null) { + NestedCollaboratorElasticQuery query = this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(PlanElasticEntity._collaborators); + query.userIds(userId); + predicates.add(this.nestedQuery(query).build()._toQuery()); + } + if (!predicates.isEmpty()) { + return this.applyTenant(predicates); + } else { + return this.equals(this.elasticFieldOf(PlanElasticEntity._id), UUID.randomUUID()); + } + } + + @Override + protected Query applyFilters() { + List predicates = new ArrayList<>(); + + if (this.like != null && !this.like.isBlank()) { + + if (!this.like.startsWith("*")) this.like = "*" + this.like; + if (!this.like.endsWith("*")) this.like = this.like + "*"; + ElasticFields elasticFields = this.elasticFieldsOf(); + elasticFields.add("*", null, true); + + predicates.add(this.or( + this.like(elasticFields, List.of(this.like))._toQuery() + , + QueryBuilders.nested().path(PlanElasticEntity._collaborators).query( + this.like(elasticFields, List.of(this.like))._toQuery() + ).build()._toQuery(), + QueryBuilders.nested().path(PlanElasticEntity._references).query( + this.like(elasticFields, List.of(this.like))._toQuery() + ).build()._toQuery(), + QueryBuilders.nested().path(PlanElasticEntity._descriptions + "." + NestedDescriptionElasticEntity._references).query( + this.like(elasticFields, List.of(this.like))._toQuery() + ).build()._toQuery(), + QueryBuilders.nested().path(PlanElasticEntity._descriptions + "." + NestedDescriptionElasticEntity._tags).query( + this.like(elasticFields, List.of(this.like))._toQuery() + ).build()._toQuery(), + QueryBuilders.nested().path(PlanElasticEntity._descriptions).query( + this.like(elasticFields, List.of(this.like))._toQuery() + ).build()._toQuery() + + )._toQuery()); + } + if (this.ids != null) { + predicates.add(this.containsUUID(this.elasticFieldOf(PlanElasticEntity._id), this.ids)._toQuery()); + } + if (this.groupIds != null) { + predicates.add(this.containsUUID(this.elasticFieldOf(PlanElasticEntity._groupId), this.groupIds)._toQuery()); + } + if (this.versions != null) { + predicates.add(this.contains(this.elasticFieldOf(PlanElasticEntity._version), this.versions.toArray(new Integer[this.versions.size()]))._toQuery()); + } + if (this.excludedIds != null) { + predicates.add(this.not(this.containsUUID(this.elasticFieldOf(PlanElasticEntity._id), this.excludedIds)._toQuery())._toQuery()); + } + if (this.statuses != null) { + predicates.add(this.contains(this.elasticFieldOf(PlanElasticEntity._status), this.statuses.stream().map(PlanStatus::getValue).toList().toArray(new Short[this.statuses.size()]))._toQuery()); + } + if (this.versionStatuses != null) { + predicates.add(this.contains(this.elasticFieldOf(PlanElasticEntity._versionStatus), this.versionStatuses.stream().map(PlanVersionStatus::getValue).toList().toArray(new Short[this.versionStatuses.size()]))._toQuery()); + } + if (this.accessTypes != null) { + predicates.add(this.contains(this.elasticFieldOf(PlanElasticEntity._accessType), this.accessTypes.stream().map(PlanAccessType::getValue).toList().toArray(new Short[this.accessTypes.size()]))._toQuery()); + } + if (this.planUserSubQuery != null) { + predicates.add(this.nestedQuery( this.planUserSubQuery.nestedPath(PlanElasticEntity._collaborators)).build()._toQuery()); + } + if (this.descriptionSubQuery != null) { + predicates.add(this.nestedQuery( this.descriptionSubQuery.nestedPath(PlanElasticEntity._descriptions)).build()._toQuery()); + } + if (this.planDescriptionTemplateSubQuery != null) { + predicates.add(this.nestedQuery( this.planDescriptionTemplateSubQuery.nestedPath(PlanElasticEntity._dmpDescriptionTemplates)).build()._toQuery()); + } + + if (!predicates.isEmpty()) { + return this.and(predicates); + } else { + return null; + } + } + + @Override + public PlanElasticEntity convert(Map rawData, Set columns) { + PlanElasticEntity mocDoc = new PlanElasticEntity(); + if (columns.contains(PlanElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._id), UUID.class)); + if (columns.contains(PlanElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._label), String.class)); + if (columns.contains(PlanElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._description), String.class)); + if (columns.contains(PlanElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._status), PlanStatus.class)); + if (columns.contains(PlanElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._versionStatus), PlanVersionStatus.class)); + if (columns.contains(PlanElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._version), Short.class)); + if (columns.contains(PlanElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._groupId), UUID.class)); + if (columns.contains(PlanElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._accessType), PlanAccessType.class)); + if (columns.contains(PlanElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._finalizedAt), Date.class)); + if (columns.contains(PlanElasticEntity._createdAt)) mocDoc.setCreatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._createdAt), Date.class)); + if (columns.contains(PlanElasticEntity._updatedAt)) mocDoc.setUpdatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._updatedAt), Date.class)); + mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), PlanElasticEntity._collaborators, null)); + mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), PlanElasticEntity._references, null)); + mocDoc.setDescriptions(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionElasticQuery.class), PlanElasticEntity._descriptions, null)); + mocDoc.setPlanDescriptionTemplates(this.convertNested(rawData, columns, this.queryFactory.query(NestedPlanDescriptionTemplateElasticQuery.class), PlanElasticEntity._dmpDescriptionTemplates, null)); + return mocDoc; + } + + @Override + protected ElasticField fieldNameOf(FieldResolver item) { + if (item.match(PlanElasticEntity._id)) return this.elasticFieldOf(PlanElasticEntity._id); + else if (item.match(PlanElasticEntity._label)) return item instanceof OrderingFieldResolver ? this.elasticFieldOf(PlanElasticEntity._label).subfield(ElasticConstants.SubFields.keyword) : this.elasticFieldOf(PlanElasticEntity._label); + else if (item.match(PlanElasticEntity._description)) return this.elasticFieldOf(PlanElasticEntity._description); + else if (item.match(PlanElasticEntity._status)) return this.elasticFieldOf(PlanElasticEntity._status); + else if (item.match(PlanElasticEntity._version)) return this.elasticFieldOf(PlanElasticEntity._version); + else if (item.match(PlanElasticEntity._versionStatus)) return this.elasticFieldOf(PlanElasticEntity._versionStatus); + else if (item.match(PlanElasticEntity._groupId)) return this.elasticFieldOf(PlanElasticEntity._groupId); + else if (item.match(PlanElasticEntity._finalizedAt)) return this.elasticFieldOf(PlanElasticEntity._finalizedAt); + else if (item.match(PlanElasticEntity._updatedAt)) return this.elasticFieldOf(PlanElasticEntity._updatedAt); + else if (item.match(PlanElasticEntity._createdAt)) return this.elasticFieldOf(PlanElasticEntity._createdAt); + else if (item.match(PlanElasticEntity._accessType)) return this.elasticFieldOf(PlanElasticEntity._accessType); + else if (item.prefix(PlanElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(PlanElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, PlanElasticEntity._collaborators)); + else if (item.prefix(PlanElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(PlanElasticEntity._references).fieldNameOf(this.extractPrefixed(item, PlanElasticEntity._references)); + else if (item.prefix(PlanElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(PlanElasticEntity._descriptions).fieldNameOf(this.extractPrefixed(item, PlanElasticEntity._descriptions)); + else if (item.prefix(PlanElasticEntity._dmpDescriptionTemplates)) return this.queryFactory.query(NestedPlanDescriptionTemplateElasticQuery.class).nestedPath(PlanElasticEntity._dmpDescriptionTemplates).fieldNameOf(this.extractPrefixed(item, PlanElasticEntity._dmpDescriptionTemplates)); + else return null; + } + + @Override + protected String[] getIndex() { + List indexNames = new ArrayList<>(); + indexNames.add(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()); + try { + this.elasticService.ensureDescriptionIndex(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return indexNames.toArray(new String[indexNames.size()]); + } + + @Override + protected UUID toKey(String key) { + return UUID.fromString(key); + } + + @Override + protected ElasticField getKeyField() { + return this.elasticFieldOf(PlanElasticEntity._id); + } + + @Override + protected ElasticNestedQuery nestedQueryOf(FieldResolver item) { + if (item.prefix(PlanElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(PlanElasticEntity._collaborators); + else if (item.prefix(PlanElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(PlanElasticEntity._references); + else if (item.prefix(PlanElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(PlanElasticEntity._descriptions); + else if (item.prefix(PlanElasticEntity._dmpDescriptionTemplates)) return this.queryFactory.query(NestedPlanDescriptionTemplateElasticQuery.class).nestedPath(PlanElasticEntity._dmpDescriptionTemplates); + else return null; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/event/EventBroker.java b/backend/core/src/main/java/org/opencdmp/event/EventBroker.java index 80c75baa7..defc5be38 100644 --- a/backend/core/src/main/java/org/opencdmp/event/EventBroker.java +++ b/backend/core/src/main/java/org/opencdmp/event/EventBroker.java @@ -49,7 +49,7 @@ public class EventBroker { this.applicationEventPublisher.publishEvent(event); } - public void emit(DmpTouchedEvent event) { + public void emit(PlanTouchedEvent event) { this.applicationEventPublisher.publishEvent(event); } diff --git a/backend/core/src/main/java/org/opencdmp/event/DmpTouchedEvent.java b/backend/core/src/main/java/org/opencdmp/event/PlanTouchedEvent.java similarity index 68% rename from backend/core/src/main/java/org/opencdmp/event/DmpTouchedEvent.java rename to backend/core/src/main/java/org/opencdmp/event/PlanTouchedEvent.java index 93b733cea..13f362c3a 100644 --- a/backend/core/src/main/java/org/opencdmp/event/DmpTouchedEvent.java +++ b/backend/core/src/main/java/org/opencdmp/event/PlanTouchedEvent.java @@ -2,12 +2,12 @@ package org.opencdmp.event; import java.util.UUID; -public class DmpTouchedEvent { +public class PlanTouchedEvent { - public DmpTouchedEvent() { + public PlanTouchedEvent() { } - public DmpTouchedEvent(UUID id) { + public PlanTouchedEvent(UUID id) { this.id = id; } diff --git a/backend/core/src/main/java/org/opencdmp/integrationevent/inbox/annotationentitycreated/AnnotationEntityCreatedIntegrationEventHandlerImpl.java b/backend/core/src/main/java/org/opencdmp/integrationevent/inbox/annotationentitycreated/AnnotationEntityCreatedIntegrationEventHandlerImpl.java index 714d2ad46..b67395dbc 100644 --- a/backend/core/src/main/java/org/opencdmp/integrationevent/inbox/annotationentitycreated/AnnotationEntityCreatedIntegrationEventHandlerImpl.java +++ b/backend/core/src/main/java/org/opencdmp/integrationevent/inbox/annotationentitycreated/AnnotationEntityCreatedIntegrationEventHandlerImpl.java @@ -29,7 +29,7 @@ import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventH import org.opencdmp.model.Tenant; import org.opencdmp.model.description.Description; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpUserQuery; +import org.opencdmp.query.PlanUserQuery; import org.opencdmp.query.TenantQuery; import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; @@ -129,8 +129,8 @@ public class AnnotationEntityCreatedIntegrationEventHandlerImpl implements Annot if (descriptionEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{event.getEntityId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); - List existingUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking() - .dmpIds(descriptionEntity.getDmpId()) + List existingUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking() + .planIds(descriptionEntity.getPlanId()) .isActives(IsActive.Active) .collect(); @@ -143,7 +143,7 @@ public class AnnotationEntityCreatedIntegrationEventHandlerImpl implements Annot if (sender == null) throw new MyApplicationException("Sender user not found"); List existingUSerIDs = existingUsers.stream() - .map(DmpUserEntity::getUserId) + .map(PlanUserEntity::getUserId) .filter(dmpUserId -> !dmpUserId.equals(event.getSubjectId())) .distinct().toList(); for (UUID dmpUserId : existingUSerIDs) { diff --git a/backend/core/src/main/java/org/opencdmp/integrationevent/inbox/annotationstatusentitychanged/AnnotationStatusEntityChangedIntegrationEventHandlerImpl.java b/backend/core/src/main/java/org/opencdmp/integrationevent/inbox/annotationstatusentitychanged/AnnotationStatusEntityChangedIntegrationEventHandlerImpl.java index 7969f9afd..9a534a548 100644 --- a/backend/core/src/main/java/org/opencdmp/integrationevent/inbox/annotationstatusentitychanged/AnnotationStatusEntityChangedIntegrationEventHandlerImpl.java +++ b/backend/core/src/main/java/org/opencdmp/integrationevent/inbox/annotationstatusentitychanged/AnnotationStatusEntityChangedIntegrationEventHandlerImpl.java @@ -29,7 +29,7 @@ import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventH import org.opencdmp.model.Tenant; import org.opencdmp.model.description.Description; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpUserQuery; +import org.opencdmp.query.PlanUserQuery; import org.opencdmp.query.TenantQuery; import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; @@ -129,8 +129,8 @@ public class AnnotationStatusEntityChangedIntegrationEventHandlerImpl implements if (descriptionEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{event.getEntityId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); - List existingUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking() - .dmpIds(descriptionEntity.getDmpId()) + List existingUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking() + .planIds(descriptionEntity.getPlanId()) .isActives(IsActive.Active) .collect(); @@ -143,7 +143,7 @@ public class AnnotationStatusEntityChangedIntegrationEventHandlerImpl implements if (sender == null) throw new MyApplicationException("Sender user not found"); List existingUSerIDs = existingUsers.stream() - .map(DmpUserEntity::getUserId) + .map(PlanUserEntity::getUserId) .filter(dmpUserId -> !dmpUserId.equals(event.getSubjectId())) .distinct().toList(); for (UUID dmpUserId : existingUSerIDs) { diff --git a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentityremoval/AnnotationEntityRemovalIntegrationEventHandler.java b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentityremoval/AnnotationEntityRemovalIntegrationEventHandler.java index c7150d9cf..c87538353 100644 --- a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentityremoval/AnnotationEntityRemovalIntegrationEventHandler.java +++ b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentityremoval/AnnotationEntityRemovalIntegrationEventHandler.java @@ -6,5 +6,5 @@ import java.util.UUID; public interface AnnotationEntityRemovalIntegrationEventHandler { void handleDescription(UUID descriptionId) throws InvalidApplicationException; - void handleDmp(UUID dmpId) throws InvalidApplicationException; + void handleDmp(UUID planId) throws InvalidApplicationException; } 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 2e678baf6..2a3306116 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 @@ -5,13 +5,13 @@ 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.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent; import org.opencdmp.integrationevent.outbox.OutboxService; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -56,15 +56,15 @@ public class AnnotationEntityRemovalIntegrationEventHandlerImpl implements Annot } @Override - public void handleDmp(UUID dmpId) { - DmpEntity dmp = this.queryFactory.query(DmpQuery.class).disableTracking().ids(dmpId).firstAs(new BaseFieldSet().ensure(Dmp._id).ensure(DmpEntity._tenantId)); + public void handleDmp(UUID planId) { + PlanEntity dmp = this.queryFactory.query(PlanQuery.class).disableTracking().ids(planId).firstAs(new BaseFieldSet().ensure(Plan._id).ensure(PlanEntity._tenantId)); if(dmp == null) return; - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().dmpIds(dmpId).collectAs(new BaseFieldSet().ensure(Description._id)); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(planId).collectAs(new BaseFieldSet().ensure(Description._id)); AnnotationEntitiesRemovalIntegrationEvent event = new AnnotationEntitiesRemovalIntegrationEvent(); event.setEntityIds(new ArrayList<>()); - event.getEntityIds().add(dmpId); + event.getEntityIds().add(planId); for (DescriptionEntity description : descriptionEntities) event.getEntityIds().add(description.getId()); diff --git a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentitytouch/AnnotationEntityTouchedIntegrationEventHandler.java b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentitytouch/AnnotationEntityTouchedIntegrationEventHandler.java index 5db2e6ed3..8b87f367e 100644 --- a/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentitytouch/AnnotationEntityTouchedIntegrationEventHandler.java +++ b/backend/core/src/main/java/org/opencdmp/integrationevent/outbox/annotationentitytouch/AnnotationEntityTouchedIntegrationEventHandler.java @@ -5,5 +5,5 @@ import java.util.UUID; public interface AnnotationEntityTouchedIntegrationEventHandler { void handleDescription(UUID descriptionId); - void handleDmp(UUID dmpId); + void handlePlan(UUID planId); } 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 a2349701a..986e0834f 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 @@ -5,13 +5,13 @@ 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.data.PlanUserEntity; import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent; import org.opencdmp.integrationevent.outbox.OutboxService; -import org.opencdmp.model.DmpUser; +import org.opencdmp.model.PlanUser; import org.opencdmp.model.description.Description; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpUserQuery; +import org.opencdmp.query.PlanUserQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -47,9 +47,9 @@ public class AnnotationEntityTouchedIntegrationEventHandlerImpl implements Annot @Override public void handleDescription(UUID descriptionId) { - DescriptionEntity entity = this.queryFactory.query(DescriptionQuery.class).disableTracking().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._plan).ensure(DescriptionEntity._tenantId)); if (entity == null) return; - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(entity.getDmpId()).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._user)); + List dmpUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(entity.getPlanId()).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(PlanUser._user)); AnnotationEntitiesTouchedIntegrationEvent event = new AnnotationEntitiesTouchedIntegrationEvent(); event.setEvents(List.of(this.buildEventItem(descriptionId, dmpUsers))); @@ -58,25 +58,25 @@ public class AnnotationEntityTouchedIntegrationEventHandlerImpl implements Annot } @Override - public void handleDmp(UUID dmpId) { - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().dmpIds(dmpId).collectAs(new BaseFieldSet().ensure(Description._id)); + public void handlePlan(UUID planId) { + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(planId).collectAs(new BaseFieldSet().ensure(Description._id)); if (descriptionEntities == null || descriptionEntities.isEmpty()) return; - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(dmpId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._user)); + List dmpUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(planId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(PlanUser._user)); AnnotationEntitiesTouchedIntegrationEvent event = new AnnotationEntitiesTouchedIntegrationEvent(); event.setEvents(new ArrayList<>()); - event.getEvents().add(this.buildEventItem(dmpId, dmpUsers)); + event.getEvents().add(this.buildEventItem(planId, dmpUsers)); for (DescriptionEntity description : descriptionEntities) event.getEvents().add(this.buildEventItem(description.getId(), dmpUsers)); this.handle(event, descriptionEntities.getFirst().getTenantId()); } - private AnnotationEntitiesTouchedIntegrationEvent.AnnotationEntityTouchedIntegrationEvent buildEventItem(UUID entityId, List dmpUsers){ + private AnnotationEntitiesTouchedIntegrationEvent.AnnotationEntityTouchedIntegrationEvent buildEventItem(UUID entityId, List dmpUsers){ AnnotationEntitiesTouchedIntegrationEvent.AnnotationEntityTouchedIntegrationEvent eventItem = new AnnotationEntitiesTouchedIntegrationEvent.AnnotationEntityTouchedIntegrationEvent(); eventItem.setEntityId(entityId); List users = new ArrayList<>(); - for (DmpUserEntity dmpUser : dmpUsers){ + for (PlanUserEntity dmpUser : dmpUsers){ users.add(dmpUser.getUserId()); } eventItem.setUserIds(users); diff --git a/backend/core/src/main/java/org/opencdmp/model/DmpAssociatedUser.java b/backend/core/src/main/java/org/opencdmp/model/PlanAssociatedUser.java similarity index 94% rename from backend/core/src/main/java/org/opencdmp/model/DmpAssociatedUser.java rename to backend/core/src/main/java/org/opencdmp/model/PlanAssociatedUser.java index aee9a1111..bc0fc28ad 100644 --- a/backend/core/src/main/java/org/opencdmp/model/DmpAssociatedUser.java +++ b/backend/core/src/main/java/org/opencdmp/model/PlanAssociatedUser.java @@ -2,7 +2,7 @@ package org.opencdmp.model; import java.util.UUID; -public class DmpAssociatedUser { +public class PlanAssociatedUser { private UUID id; public static final String _id = "id"; diff --git a/backend/core/src/main/java/org/opencdmp/model/DmpDescriptionTemplate.java b/backend/core/src/main/java/org/opencdmp/model/PlanDescriptionTemplate.java similarity index 92% rename from backend/core/src/main/java/org/opencdmp/model/DmpDescriptionTemplate.java rename to backend/core/src/main/java/org/opencdmp/model/PlanDescriptionTemplate.java index a803cdb35..085c96cf3 100644 --- a/backend/core/src/main/java/org/opencdmp/model/DmpDescriptionTemplate.java +++ b/backend/core/src/main/java/org/opencdmp/model/PlanDescriptionTemplate.java @@ -2,21 +2,21 @@ package org.opencdmp.model; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import java.time.Instant; import java.util.List; import java.util.UUID; -public class DmpDescriptionTemplate{ +public class PlanDescriptionTemplate { private UUID id; public static final String _id = "id"; - private Dmp dmp; + private Plan plan; - public static final String _dmp = "dmp"; + public static final String _plan = "plan"; private DescriptionTemplate currentDescriptionTemplate; @@ -61,12 +61,12 @@ public class DmpDescriptionTemplate{ this.id = id; } - public Dmp getDmp() { - return dmp; + public Plan getDmp() { + return plan; } - public void setDmp(Dmp dmp) { - this.dmp = dmp; + public void setDmp(Plan plan) { + this.plan = plan; } public DescriptionTemplate getCurrentDescriptionTemplate() { diff --git a/backend/core/src/main/java/org/opencdmp/model/DmpUser.java b/backend/core/src/main/java/org/opencdmp/model/PlanUser.java similarity index 84% rename from backend/core/src/main/java/org/opencdmp/model/DmpUser.java rename to backend/core/src/main/java/org/opencdmp/model/PlanUser.java index a61dced2a..365efbcd7 100644 --- a/backend/core/src/main/java/org/opencdmp/model/DmpUser.java +++ b/backend/core/src/main/java/org/opencdmp/model/PlanUser.java @@ -1,22 +1,22 @@ package org.opencdmp.model; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.user.User; import java.time.Instant; import java.util.UUID; -public class DmpUser { +public class PlanUser { private UUID id; public static final String _id = "id"; - private Dmp dmp; + private Plan plan; - public static final String _dmp = "dmp"; + public static final String _plan = "plan"; private User user; @@ -25,7 +25,7 @@ public class DmpUser { private String hash; public final static String _hash = "hash"; - private DmpUserRole role; + private PlanUserRole role; public static final String _role = "role"; @@ -54,12 +54,12 @@ public class DmpUser { this.id = id; } - public Dmp getDmp() { - return dmp; + public Plan getPlan() { + return plan; } - public void setDmp(Dmp dmp) { - this.dmp = dmp; + public void setPlan(Plan plan) { + this.plan = plan; } public User getUser() { @@ -70,11 +70,11 @@ public class DmpUser { this.user = user; } - public DmpUserRole getRole() { + public PlanUserRole getRole() { return role; } - public void setRole(DmpUserRole role) { + public void setRole(PlanUserRole role) { this.role = role; } diff --git a/backend/core/src/main/java/org/opencdmp/model/DmpValidationResult.java b/backend/core/src/main/java/org/opencdmp/model/PlanValidationResult.java similarity index 64% rename from backend/core/src/main/java/org/opencdmp/model/DmpValidationResult.java rename to backend/core/src/main/java/org/opencdmp/model/PlanValidationResult.java index 874dfbc2e..37bf7bfc5 100644 --- a/backend/core/src/main/java/org/opencdmp/model/DmpValidationResult.java +++ b/backend/core/src/main/java/org/opencdmp/model/PlanValidationResult.java @@ -1,26 +1,26 @@ package org.opencdmp.model; -import org.opencdmp.commons.enums.DmpValidationOutput; +import org.opencdmp.commons.enums.PlanValidationOutput; import java.util.List; import java.util.UUID; -public class DmpValidationResult { +public class PlanValidationResult { private UUID id; public static final String _id = "id"; - private DmpValidationOutput result; + private PlanValidationOutput result; private List errors; public static final String _result = "result"; - public DmpValidationResult() { + public PlanValidationResult() { } - public DmpValidationResult(UUID id, DmpValidationOutput result) { + public PlanValidationResult(UUID id, PlanValidationOutput result) { this.id = id; this.result = result; } @@ -33,11 +33,11 @@ public class DmpValidationResult { this.id = id; } - public DmpValidationOutput getResult() { + public PlanValidationOutput getResult() { return result; } - public void setResult(DmpValidationOutput result) { + public void setResult(PlanValidationOutput result) { this.result = result; } diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDescription.java b/backend/core/src/main/java/org/opencdmp/model/PublicDescription.java index 390225e9d..778d1df97 100644 --- a/backend/core/src/main/java/org/opencdmp/model/PublicDescription.java +++ b/backend/core/src/main/java/org/opencdmp/model/PublicDescription.java @@ -35,17 +35,17 @@ public class PublicDescription { public static final String _finalizedAt = "finalizedAt"; - private PublicDmpDescriptionTemplate dmpDescriptionTemplate; + private PublicPlanDescriptionTemplate planDescriptionTemplate; - public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate"; + public static final String _planDescriptionTemplate = "planDescriptionTemplate"; private PublicDescriptionTemplate descriptionTemplate; public static final String _descriptionTemplate = "descriptionTemplate"; - private PublicDmp dmp; + private PublicPlan plan; - public static final String _dmp = "dmp"; + public static final String _plan = "plan"; public UUID getId() { @@ -105,12 +105,12 @@ public class PublicDescription { this.createdAt = createdAt; } - public PublicDmpDescriptionTemplate getDmpDescriptionTemplate() { - return dmpDescriptionTemplate; + public PublicPlanDescriptionTemplate getPlanDescriptionTemplate() { + return planDescriptionTemplate; } - public void setDmpDescriptionTemplate(PublicDmpDescriptionTemplate dmpDescriptionTemplate) { - this.dmpDescriptionTemplate = dmpDescriptionTemplate; + public void setPlanDescriptionTemplate(PublicPlanDescriptionTemplate planDescriptionTemplate) { + this.planDescriptionTemplate = planDescriptionTemplate; } public PublicDescriptionTemplate getDescriptionTemplate() { @@ -121,11 +121,11 @@ public class PublicDescription { this.descriptionTemplate = descriptionTemplate; } - public PublicDmp getDmp() { - return dmp; + public PublicPlan getPlan() { + return plan; } - public void setDmp(PublicDmp dmp) { - this.dmp = dmp; + public void setPlan(PublicPlan plan) { + this.plan = plan; } } diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDmpDescriptionTemplate.java b/backend/core/src/main/java/org/opencdmp/model/PublicDmpDescriptionTemplate.java deleted file mode 100644 index 6e3e07e3d..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/PublicDmpDescriptionTemplate.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.opencdmp.model; - -import org.opencdmp.commons.enums.IsActive; - -import java.time.Instant; -import java.util.UUID; - -public class PublicDmpDescriptionTemplate { - - private UUID id; - - public static final String _id = "id"; - - private PublicDmp dmp; - - public static final String _dmp = "dmp"; - - public UUID getId() { - return id; - } - - public void setId(UUID id) { - this.id = id; - } - - public PublicDmp getDmp() { - return dmp; - } - - public void setDmp(PublicDmp dmp) { - this.dmp = dmp; - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDmp.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlan.java similarity index 68% rename from backend/core/src/main/java/org/opencdmp/model/PublicDmp.java rename to backend/core/src/main/java/org/opencdmp/model/PublicPlan.java index d3314df09..b95aded25 100644 --- a/backend/core/src/main/java/org/opencdmp/model/PublicDmp.java +++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlan.java @@ -1,14 +1,13 @@ package org.opencdmp.model; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; -import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; import java.time.Instant; import java.util.List; import java.util.UUID; -public class PublicDmp { +public class PublicPlan { private UUID id; @@ -37,22 +36,22 @@ public class PublicDmp { public static final String _publishedAt = "publishedAt"; - private DmpStatus status; + private PlanStatus status; public static final String _status = "status"; private UUID groupId; public static final String _groupId = "groupId"; - private DmpAccessType accessType; + private PlanAccessType accessType; public static final String _accessType = "accessType"; - private List dmpUsers; + private List planUsers; - public static final String _dmpUsers = "dmpUsers"; + public static final String _planUsers = "planUsers"; - private List dmpReferences; + private List planReferences; - public static final String _dmpReferences = "dmpReferences"; + public static final String _planReferences = "planReferences"; private List descriptions; public static final String _descriptions = "descriptions"; @@ -60,8 +59,8 @@ public class PublicDmp { private List entityDois; public static final String _entityDois = "entityDois"; - private List otherDmpVersions; - public static final String _otherDmpVersions = "otherDmpVersions"; + private List otherPlanVersions; + public static final String _otherPlanVersions = "otherPlanVersions"; public UUID getId() { return id; @@ -119,11 +118,11 @@ public class PublicDmp { this.publishedAt = publishedAt; } - public DmpStatus getStatus() { + public PlanStatus getStatus() { return status; } - public void setStatus(DmpStatus status) { + public void setStatus(PlanStatus status) { this.status = status; } @@ -135,28 +134,28 @@ public class PublicDmp { this.groupId = groupId; } - public DmpAccessType getAccessType() { + public PlanAccessType getAccessType() { return accessType; } - public void setAccessType(DmpAccessType accessType) { + public void setAccessType(PlanAccessType accessType) { this.accessType = accessType; } - public List getDmpUsers() { - return dmpUsers; + public List getPlanUsers() { + return planUsers; } - public void setDmpUsers(List dmpUsers) { - this.dmpUsers = dmpUsers; + public void setPlanUsers(List planUsers) { + this.planUsers = planUsers; } - public List getDmpReferences() { - return dmpReferences; + public List getPlanReferences() { + return planReferences; } - public void setDmpReferences(List dmpReferences) { - this.dmpReferences = dmpReferences; + public void setPlanReferences(List planReferences) { + this.planReferences = planReferences; } public List getDescriptions() { @@ -175,11 +174,11 @@ public class PublicDmp { this.entityDois = entityDois; } - public List getOtherDmpVersions() { - return otherDmpVersions; + public List getOtherPlanVersions() { + return otherPlanVersions; } - public void setOtherDmpVersions(List otherDmpVersions) { - this.otherDmpVersions = otherDmpVersions; + public void setOtherPlanVersions(List otherPlanVersions) { + this.otherPlanVersions = otherPlanVersions; } } diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicPlanDescriptionTemplate.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlanDescriptionTemplate.java new file mode 100644 index 000000000..00a9e6d17 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlanDescriptionTemplate.java @@ -0,0 +1,31 @@ +package org.opencdmp.model; + +import java.util.UUID; + +public class PublicPlanDescriptionTemplate { + + private UUID id; + + public static final String _id = "id"; + + private PublicPlan plan; + + public static final String _plan = "plan"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public PublicPlan getPlan() { + return plan; + } + + public void setPlan(PublicPlan plan) { + this.plan = plan; + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDmpReference.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlanReference.java similarity index 76% rename from backend/core/src/main/java/org/opencdmp/model/PublicDmpReference.java rename to backend/core/src/main/java/org/opencdmp/model/PublicPlanReference.java index e12fd708b..cfa7def79 100644 --- a/backend/core/src/main/java/org/opencdmp/model/PublicDmpReference.java +++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlanReference.java @@ -2,16 +2,15 @@ package org.opencdmp.model; import org.opencdmp.commons.enums.IsActive; -import java.time.Instant; import java.util.UUID; -public class PublicDmpReference { +public class PublicPlanReference { private UUID id; public static final String _id = "id"; - private PublicDmp dmp; - public static final String _dmp = "dmp"; + private PublicPlan plan; + public static final String _plan = "plan"; private PublicReference reference; public static final String _reference = "reference"; @@ -27,12 +26,12 @@ public class PublicDmpReference { this.id = id; } - public PublicDmp getDmp() { - return dmp; + public PublicPlan getPlan() { + return plan; } - public void setDmp(PublicDmp dmp) { - this.dmp = dmp; + public void setPlan(PublicPlan plan) { + this.plan = plan; } public PublicReference getReference() { diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDmpUser.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlanUser.java similarity index 59% rename from backend/core/src/main/java/org/opencdmp/model/PublicDmpUser.java rename to backend/core/src/main/java/org/opencdmp/model/PublicPlanUser.java index ecd6befbb..b91d7a250 100644 --- a/backend/core/src/main/java/org/opencdmp/model/PublicDmpUser.java +++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlanUser.java @@ -1,16 +1,16 @@ package org.opencdmp.model; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import java.util.UUID; -public class PublicDmpUser { +public class PublicPlanUser { public static final String _id = "id"; private UUID id; - public static final String _dmp = "dmp"; - private PublicDmp dmp; + public static final String _plan = "plan"; + private PublicPlan plan; public static final String _user = "user"; @@ -18,7 +18,7 @@ public class PublicDmpUser { public static final String _role = "role"; - private DmpUserRole role; + private PlanUserRole role; public UUID getId() { return id; @@ -28,12 +28,12 @@ public class PublicDmpUser { this.id = id; } - public PublicDmp getDmp() { - return dmp; + public PublicPlan getPlan() { + return plan; } - public void setDmp(PublicDmp dmp) { - this.dmp = dmp; + public void setPlan(PublicPlan plan) { + this.plan = plan; } public PublicUser getUser() { @@ -44,11 +44,11 @@ public class PublicDmpUser { this.user = user; } - public DmpUserRole getRole() { + public PlanUserRole getRole() { return role; } - public void setRole(DmpUserRole role) { + public void setRole(PlanUserRole role) { this.role = role; } } diff --git a/backend/core/src/main/java/org/opencdmp/model/RecentActivityItem.java b/backend/core/src/main/java/org/opencdmp/model/RecentActivityItem.java index 96c92f6d0..90962003e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/RecentActivityItem.java +++ b/backend/core/src/main/java/org/opencdmp/model/RecentActivityItem.java @@ -2,13 +2,13 @@ package org.opencdmp.model; import org.opencdmp.commons.enums.RecentActivityItemType; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; public class RecentActivityItem { private RecentActivityItemType type; public final static String _type = "type"; - private Dmp dmp; - public final static String _dmp = "dmp"; + private Plan plan; + public final static String _plan = "plan"; private Description description; public final static String _description = "description"; @@ -21,12 +21,12 @@ public class RecentActivityItem { this.type = type; } - public Dmp getDmp() { - return dmp; + public Plan getPlan() { + return plan; } - public void setDmp(Dmp dmp) { - this.dmp = dmp; + public void setPlan(Plan plan) { + this.plan = plan; } public Description getDescription() { diff --git a/backend/core/src/main/java/org/opencdmp/model/RecentActivityItemLookup.java b/backend/core/src/main/java/org/opencdmp/model/RecentActivityItemLookup.java index 793bdc42f..5840b3b3b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/RecentActivityItemLookup.java +++ b/backend/core/src/main/java/org/opencdmp/model/RecentActivityItemLookup.java @@ -1,14 +1,14 @@ package org.opencdmp.model; import org.opencdmp.commons.enums.DescriptionStatus; -import org.opencdmp.commons.enums.DmpStatus; +import org.opencdmp.commons.enums.PlanStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.RecentActivityOrder; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.query.lookup.DescriptionLookup; -import org.opencdmp.query.lookup.DmpLookup; -import org.opencdmp.query.lookup.DmpUserLookup; +import org.opencdmp.query.lookup.PlanLookup; +import org.opencdmp.query.lookup.PlanUserLookup; import gr.cite.tools.data.query.Ordering; import gr.cite.tools.data.query.Paging; import gr.cite.tools.fieldset.BaseFieldSet; @@ -100,13 +100,13 @@ public class RecentActivityItemLookup{ if (this.onlyDraft != null) lookup.setStatuses(List.of(DescriptionStatus.Draft)); else lookup.setStatuses(List.of(DescriptionStatus.Draft, DescriptionStatus.Finalized)); if (this.userIds != null) { - DmpLookup dmpLookup = new DmpLookup(); - DmpUserLookup dmpUserLookup = new DmpUserLookup(); - dmpUserLookup.setUserIds(this.userIds); - dmpUserLookup.setIsActive(List.of(IsActive.Active)); - dmpLookup.setDmpUserSubQuery(dmpUserLookup); - dmpLookup.setIsActive(List.of(IsActive.Active)); - lookup.setDmpSubQuery(dmpLookup); + PlanLookup planLookup = new PlanLookup(); + PlanUserLookup planUserLookup = new PlanUserLookup(); + planUserLookup.setUserIds(this.userIds); + planUserLookup.setIsActive(List.of(IsActive.Active)); + planLookup.setPlanUserSubQuery(planUserLookup); + planLookup.setIsActive(List.of(IsActive.Active)); + lookup.setPlanSubQuery(planLookup); } if (this.page != null) lookup.setPage(new Paging(this.page.getOffset(), this.page.getSize())); Ordering ordering = new Ordering(); @@ -125,33 +125,33 @@ public class RecentActivityItemLookup{ return lookup; } - public DmpLookup asDmpLookup() { + public PlanLookup asDmpLookup() { if (this.onlyDescription != null) return null; - DmpLookup lookup = new DmpLookup(); + PlanLookup lookup = new PlanLookup(); lookup.setIsActive(List.of(IsActive.Active)); if (this.like != null) lookup.setLike(this.like); - if (this.onlyDraft != null) lookup.setStatuses(List.of(DmpStatus.Draft)); + if (this.onlyDraft != null) lookup.setStatuses(List.of(PlanStatus.Draft)); if (this.userIds != null) { - DmpUserLookup dmpUserLookup = new DmpUserLookup(); - dmpUserLookup.setUserIds(this.userIds); - dmpUserLookup.setIsActive(List.of(IsActive.Active)); - lookup.setDmpUserSubQuery(dmpUserLookup); + PlanUserLookup planUserLookup = new PlanUserLookup(); + planUserLookup.setUserIds(this.userIds); + planUserLookup.setIsActive(List.of(IsActive.Active)); + lookup.setPlanUserSubQuery(planUserLookup); } if (this.page != null) lookup.setPage(new Paging(this.page.getOffset(), this.page.getSize())); Ordering ordering = new Ordering(); if (this.orderField != null) { switch (this.orderField){ - case Label -> ordering.addDescending(Dmp._label); - case UpdatedAt -> ordering.addDescending(Dmp._updatedAt); - case Status -> ordering.addDescending(Dmp._status).addDescending(Dmp._updatedAt); + case Label -> ordering.addDescending(Plan._label); + case UpdatedAt -> ordering.addDescending(Plan._updatedAt); + case Status -> ordering.addDescending(Plan._status).addDescending(Plan._updatedAt); default -> throw new IllegalArgumentException("Type not found" + this.orderField) ; } } else { - ordering.addDescending(Dmp._updatedAt); + ordering.addDescending(Plan._updatedAt); } lookup.setOrder(ordering); - if (this.project !=null)lookup.setProject((BaseFieldSet) this.project.extractPrefixed(RecentActivityItem._dmp)); + if (this.project !=null)lookup.setProject((BaseFieldSet) this.project.extractPrefixed(RecentActivityItem._plan)); return lookup; } diff --git a/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/ActionConfirmation.java b/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/ActionConfirmation.java index b41a3547e..38bba2f8e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/ActionConfirmation.java +++ b/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/ActionConfirmation.java @@ -30,7 +30,7 @@ public class ActionConfirmation { public static final String _userInviteToTenantRequest = "userInviteToTenantRequest"; - private DmpInvitation dmpInvitation; + private PlanInvitation planInvitation; public static final String _dmpInvitation = "dmpInvitation"; private Instant expiresAt; @@ -79,12 +79,12 @@ public class ActionConfirmation { this.status = status; } - public DmpInvitation getDmpInvitation() { - return dmpInvitation; + public PlanInvitation getDmpInvitation() { + return planInvitation; } - public void setDmpInvitation(DmpInvitation dmpInvitation) { - this.dmpInvitation = dmpInvitation; + public void setDmpInvitation(PlanInvitation planInvitation) { + this.planInvitation = planInvitation; } public Instant getExpiresAt() { diff --git a/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/DmpInvitation.java b/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/DmpInvitation.java deleted file mode 100644 index 8a5687afe..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/DmpInvitation.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.opencdmp.model.actionconfirmation; - -import org.opencdmp.commons.enums.DmpUserRole; - -import java.util.UUID; - -public class DmpInvitation { - - private String email; - public static final String _email = "email"; - - private UUID dmpId; - public static final String _dmpId = "dmpId"; - - private DmpUserRole role; - public static final String _role = "role"; - - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public UUID getDmpId() { - return dmpId; - } - - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; - } - - public DmpUserRole getRole() { - return role; - } - - public void setRole(DmpUserRole role) { - this.role = role; - } -} diff --git a/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/PlanInvitation.java b/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/PlanInvitation.java new file mode 100644 index 000000000..9224208e4 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/actionconfirmation/PlanInvitation.java @@ -0,0 +1,42 @@ +package org.opencdmp.model.actionconfirmation; + +import org.opencdmp.commons.enums.PlanUserRole; + +import java.util.UUID; + +public class PlanInvitation { + + private String email; + public static final String _email = "email"; + + private UUID planId; + public static final String _planId = "planId"; + + private PlanUserRole role; + public static final String _role = "role"; + + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public UUID getPlanId() { + return planId; + } + + public void setPlanId(UUID planId) { + this.planId = planId; + } + + public PlanUserRole getRole() { + return role; + } + + public void setRole(PlanUserRole role) { + this.role = role; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/DmpAssociatedUserBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PlanAssociatedUserBuilder.java similarity index 85% rename from backend/core/src/main/java/org/opencdmp/model/builder/DmpAssociatedUserBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/PlanAssociatedUserBuilder.java index 0a52542eb..f10dc1d9a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/DmpAssociatedUserBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PlanAssociatedUserBuilder.java @@ -11,7 +11,7 @@ import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.enums.ContactInfoType; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.UserEntity; -import org.opencdmp.model.DmpAssociatedUser; +import org.opencdmp.model.PlanAssociatedUser; import org.opencdmp.model.UserContactInfo; import org.opencdmp.model.user.User; import org.opencdmp.query.UserContactInfoQuery; @@ -26,7 +26,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpAssociatedUserBuilder extends BaseBuilder { +public class PlanAssociatedUserBuilder extends BaseBuilder { private final QueryFactory queryFactory; @@ -35,32 +35,32 @@ public class DmpAssociatedUserBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpAssociatedUserBuilder(ConventionService conventionService, - QueryFactory queryFactory, - BuilderFactory builderFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpAssociatedUserBuilder.class))); + public PlanAssociatedUserBuilder(ConventionService conventionService, + QueryFactory queryFactory, + BuilderFactory builderFactory) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanAssociatedUserBuilder.class))); this.queryFactory = queryFactory; this.builderFactory = builderFactory; } - public DmpAssociatedUserBuilder authorize(EnumSet values) { + public PlanAssociatedUserBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - List models = new ArrayList<>(); + List models = new ArrayList<>(); Map> contactsMap = this.collectUserContactInfos(new BaseFieldSet().ensure(UserContactInfo._value).ensure(UserContactInfo._type).ensure(UserContactInfo._ordinal), data); for (UserEntity d : data) { - DmpAssociatedUser m = new DmpAssociatedUser(); + PlanAssociatedUser m = new PlanAssociatedUser(); if (fields.hasField(this.asIndexer(User._id))) m.setId(d.getId()); if (fields.hasField(this.asIndexer(User._name))) m.setName(d.getName()); if (contactsMap != null && contactsMap.containsKey(d.getId())){ diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PlanDescriptionTemplateBuilder.java similarity index 63% rename from backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/PlanDescriptionTemplateBuilder.java index 2ab87c434..574228ef2 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PlanDescriptionTemplateBuilder.java @@ -11,15 +11,15 @@ import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpDescriptionTemplateEntity; +import org.opencdmp.data.PlanDescriptionTemplateEntity; import org.opencdmp.model.DescriptionTemplateType; -import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.model.PlanDescriptionTemplate; import org.opencdmp.model.builder.descriptiontemplate.DescriptionTemplateBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.query.DescriptionTemplateQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -31,7 +31,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpDescriptionTemplateBuilder extends BaseBuilder { +public class PlanDescriptionTemplateBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -41,50 +41,50 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpDescriptionTemplateBuilder( + public PlanDescriptionTemplateBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory, TenantScope tenantScope) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpDescriptionTemplateBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanDescriptionTemplateBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; this.tenantScope = tenantScope; } - public DmpDescriptionTemplateBuilder authorize(EnumSet values) { + public PlanDescriptionTemplateBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - FieldSet templateFields = fields.extractPrefixed(this.asPrefix(DmpDescriptionTemplate._descriptionTemplates)); + FieldSet templateFields = fields.extractPrefixed(this.asPrefix(PlanDescriptionTemplate._descriptionTemplates)); Map> templateItemsMap = this.collectDescriptionTemplates(templateFields, data); - FieldSet currentDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(DmpDescriptionTemplate._currentDescriptionTemplate)); + FieldSet currentDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(PlanDescriptionTemplate._currentDescriptionTemplate)); Map currentDescriptionTemplateItemsMap = this.collectCurrentDescriptionTemplates(currentDescriptionTemplateFields, data); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(DmpDescriptionTemplate._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(PlanDescriptionTemplate._plan)); + Map planItemsMap = this.collectPlans(planFields, data); - List models = new ArrayList<>(); - for (DmpDescriptionTemplateEntity d : data) { - DmpDescriptionTemplate m = new DmpDescriptionTemplate(); - if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._sectionId))) m.setSectionId(d.getSectionId()); - if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._descriptionTemplateGroupId))) m.setDescriptionTemplateGroupId(d.getDescriptionTemplateGroupId()); - if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._createdAt))) m.setCreatedAt(d.getCreatedAt()); - if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._isActive))) m.setIsActive(d.getIsActive()); - if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); + List models = new ArrayList<>(); + for (PlanDescriptionTemplateEntity d : data) { + PlanDescriptionTemplate m = new PlanDescriptionTemplate(); + if (fields.hasField(this.asIndexer(PlanDescriptionTemplate._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(PlanDescriptionTemplate._sectionId))) m.setSectionId(d.getSectionId()); + if (fields.hasField(this.asIndexer(PlanDescriptionTemplate._descriptionTemplateGroupId))) m.setDescriptionTemplateGroupId(d.getDescriptionTemplateGroupId()); + if (fields.hasField(this.asIndexer(PlanDescriptionTemplate._createdAt))) m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(PlanDescriptionTemplate._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(PlanDescriptionTemplate._isActive))) m.setIsActive(d.getIsActive()); + if (fields.hasField(this.asIndexer(PlanDescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(DescriptionTemplateType._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateGroupId())) m.setDescriptionTemplates(templateItemsMap.get(d.getDescriptionTemplateGroupId())); if (!currentDescriptionTemplateFields.isEmpty() && currentDescriptionTemplateItemsMap != null && currentDescriptionTemplateItemsMap.containsKey(d.getDescriptionTemplateGroupId())) m.setCurrentDescriptionTemplate(currentDescriptionTemplateItemsMap.get(d.getDescriptionTemplateGroupId())); - if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); + if (!planFields.isEmpty() && planItemsMap != null && planItemsMap.containsKey(d.getPlanId())) m.setDmp(planItemsMap.get(d.getPlanId())); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); @@ -92,41 +92,41 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); + this.logger.debug("checking related - {}", Plan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(Dmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(Plan._id))) { itemMap = this.asEmpty( - data.stream().map(DmpDescriptionTemplateEntity::getDmpId).distinct().collect(Collectors.toList()), + data.stream().map(PlanDescriptionTemplateEntity::getPlanId).distinct().collect(Collectors.toList()), x -> { - Dmp item = new Dmp(); + Plan item = new Plan(); item.setId(x); return item; }, - Dmp::getId); + Plan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); - DmpQuery q = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DmpDescriptionTemplateEntity::getDmpId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Plan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanDescriptionTemplateEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Plan::getId); } - if (!fields.hasField(Dmp._id)) { + if (!fields.hasField(Plan._id)) { itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; } - private Map> collectDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { + private Map> collectDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName()); Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._groupId); - DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().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(PlanDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).asMasterKey(query, clone, DescriptionTemplate::getGroupId); if (!fields.hasField(DescriptionTemplate._groupId)) { @@ -138,7 +138,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder collectCurrentDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { + private Map collectCurrentDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName()); @@ -146,7 +146,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder itemMap; if (!fields.hasOtherField(this.asIndexer(DescriptionTemplate._groupId))) { itemMap = this.asEmpty( - data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList()), + data.stream().map(PlanDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList()), x -> { DescriptionTemplate item = new DescriptionTemplate(); item.setGroupId(x); @@ -155,7 +155,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder{ +public class PlanUserBuilder extends BaseBuilder{ private final BuilderFactory builderFactory; @@ -38,46 +38,46 @@ public class DmpUserBuilder extends BaseBuilder{ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpUserBuilder( + public PlanUserBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory, TenantScope tenantScope) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanUserBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; this.tenantScope = tenantScope; } - public DmpUserBuilder authorize(EnumSet values) { + public PlanUserBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(DmpUser._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(PlanUser._plan)); + Map planItemsMap = this.collectPlans(planFields, data); - FieldSet userFields = fields.extractPrefixed(this.asPrefix(DmpUser._user)); + FieldSet userFields = fields.extractPrefixed(this.asPrefix(PlanUser._user)); Map userItemsMap = this.collectUsers(userFields, data); - List models = new ArrayList<>(); - for (DmpUserEntity d : data) { - DmpUser m = new DmpUser(); - if (fields.hasField(this.asIndexer(DmpUser._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(DmpUser._role))) m.setRole(d.getRole()); - if (fields.hasField(this.asIndexer(DmpUser._sectionId))) m.setSectionId(d.getSectionId()); - if (fields.hasField(this.asIndexer(DmpUser._createdAt))) m.setCreatedAt(d.getCreatedAt()); - if (fields.hasField(this.asIndexer(DmpUser._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if (fields.hasField(this.asIndexer(DmpUser._isActive))) m.setIsActive(d.getIsActive()); - if (fields.hasField(this.asIndexer(DmpUser._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); - if (fields.hasField(this.asIndexer(DmpUser._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); + List models = new ArrayList<>(); + for (PlanUserEntity d : data) { + PlanUser m = new PlanUser(); + if (fields.hasField(this.asIndexer(PlanUser._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(PlanUser._role))) m.setRole(d.getRole()); + if (fields.hasField(this.asIndexer(PlanUser._sectionId))) m.setSectionId(d.getSectionId()); + if (fields.hasField(this.asIndexer(PlanUser._createdAt))) m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(PlanUser._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(PlanUser._isActive))) m.setIsActive(d.getIsActive()); + if (fields.hasField(this.asIndexer(PlanUser._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); + if (fields.hasField(this.asIndexer(PlanUser._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId())); - if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); + if (!planFields.isEmpty() && planItemsMap != null && planItemsMap.containsKey(d.getPlanId())) m.setPlan(planItemsMap.get(d.getPlanId())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId())); models.add(m); } @@ -85,7 +85,7 @@ public class DmpUserBuilder extends BaseBuilder{ return models; } - private Map collectUsers(FieldSet fields, List data) throws MyApplicationException { + private Map collectUsers(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; this.logger.debug("checking related - {}", User.class.getSimpleName()); @@ -93,7 +93,7 @@ public class DmpUserBuilder extends BaseBuilder{ Map itemMap; if (!fields.hasOtherField(this.asIndexer(User._id))) { itemMap = this.asEmpty( - data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()), + data.stream().map(PlanUserEntity::getUserId).distinct().collect(Collectors.toList()), x -> { User item = new User(); item.setId(x); @@ -102,7 +102,7 @@ public class DmpUserBuilder extends BaseBuilder{ User::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().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(PlanUserEntity::getUserId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); } if (!fields.hasField(User._id)) { @@ -115,27 +115,27 @@ public class DmpUserBuilder extends BaseBuilder{ return itemMap; } - private Map collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); + this.logger.debug("checking related - {}", Plan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(Dmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(Plan._id))) { itemMap = this.asEmpty( - data.stream().map(DmpUserEntity::getDmpId).distinct().collect(Collectors.toList()), + data.stream().map(PlanUserEntity::getPlanId).distinct().collect(Collectors.toList()), x -> { - Dmp item = new Dmp(); + Plan item = new Plan(); item.setId(x); return item; }, - Dmp::getId); + Plan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); - 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); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Plan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanUserEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Plan::getId); } - if (!fields.hasField(Dmp._id)) { + if (!fields.hasField(Plan._id)) { itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } 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 964a12796..0984191d4 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 @@ -12,11 +12,11 @@ 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.model.PublicPlan; +import org.opencdmp.model.PublicPlanDescriptionTemplate; import org.opencdmp.query.DescriptionTemplateQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanDescriptionTemplateQuery; +import org.opencdmp.query.PlanQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -57,14 +57,14 @@ public class PublicDescriptionBuilder extends BaseBuilder(); - FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(PublicDescription._dmpDescriptionTemplate)); - Map dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data); + FieldSet planDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(PublicDescription._planDescriptionTemplate)); + Map planDescriptionTemplateItemsMap = this.collectPlanDescriptionTemplates(planDescriptionTemplateFields, data); FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asPrefix(PublicDescription._descriptionTemplate)); Map descriptionTemplateItemsMap = this.collectDescriptionTemplates(descriptionTemplateFields, data); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDescription._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(PublicDescription._plan)); + Map planItemsMap = this.collectPlans(planFields, data); List models = new ArrayList<>(); for (DescriptionEntity d : data) { @@ -76,8 +76,8 @@ public class PublicDescriptionBuilder extends BaseBuilder collectDmpDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlanDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDmpDescriptionTemplate.class.getSimpleName()); + this.logger.debug("checking related - {}", PublicPlanDescriptionTemplate.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(PublicDmpDescriptionTemplate._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(PublicPlanDescriptionTemplate._id))) { itemMap = this.asEmpty( - data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList()), + data.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().collect(Collectors.toList()), x -> { - PublicDmpDescriptionTemplate item = new PublicDmpDescriptionTemplate(); + PublicPlanDescriptionTemplate item = new PublicPlanDescriptionTemplate(); item.setId(x); return item; }, - PublicDmpDescriptionTemplate::getId); + PublicPlanDescriptionTemplate::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmpDescriptionTemplate._id); - DmpDescriptionTemplateQuery q = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(PublicDmpDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmpDescriptionTemplate::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicPlanDescriptionTemplate._id); + PlanDescriptionTemplateQuery q = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PublicPlanDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicPlanDescriptionTemplate::getId); } - if (!fields.hasField(PublicDmpDescriptionTemplate._id)) { + if (!fields.hasField(PublicPlanDescriptionTemplate._id)) { itemMap.forEach((id, item) -> { if (item != null) item.setId(null); @@ -147,27 +147,27 @@ public class PublicDescriptionBuilder extends BaseBuilder collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDmp.class.getSimpleName()); + this.logger.debug("checking related - {}", PublicPlan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(PublicDmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(PublicPlan._id))) { itemMap = this.asEmpty( - data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()), + data.stream().map(DescriptionEntity::getPlanId).distinct().collect(Collectors.toList()), x -> { - PublicDmp item = new PublicDmp(); + PublicPlan item = new PublicPlan(); item.setId(x); return item; }, - PublicDmp::getId); + PublicPlan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id); - 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(PublicDmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmp::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicPlan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(DescriptionEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PublicPlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicPlan::getId); } - if (!fields.hasField(PublicDmp._id)) { + if (!fields.hasField(PublicPlan._id)) { itemMap.forEach((id, item) -> { if (item != null) item.setId(null); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpBuilder.java deleted file mode 100644 index b9ed5f07a..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpBuilder.java +++ /dev/null @@ -1,194 +0,0 @@ -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.enums.EntityType; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.model.*; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.query.*; -import org.slf4j.LoggerFactory; -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; - -import java.util.*; -import java.util.stream.Collectors; - -@Component -@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class PublicDmpBuilder extends BaseBuilder { - - private final QueryFactory queryFactory; - - private final BuilderFactory builderFactory; - - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - - @Autowired - public PublicDmpBuilder(ConventionService conventionService, - QueryFactory queryFactory, - BuilderFactory builderFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDmpBuilder.class))); - this.queryFactory = queryFactory; - this.builderFactory = builderFactory; - } - - public PublicDmpBuilder authorize(EnumSet values) { - this.authorize = values; - return this; - } - - @Override - public List build(FieldSet fields, List data) throws MyApplicationException { - this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); - this.logger.trace(new DataLogEntry("requested fields", fields)); - if (fields == null || data == null || fields.isEmpty()) - return new ArrayList<>(); - - List models = new ArrayList<>(); - - FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(PublicDmp._dmpReferences)); - Map> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data); - - FieldSet dmpUsersFields = fields.extractPrefixed(this.asPrefix(PublicDmp._dmpUsers)); - Map> dmpUsersMap = this.collectDmpUsers(dmpUsersFields, data); - - FieldSet descriptionsFields = fields.extractPrefixed(this.asPrefix(PublicDmp._descriptions)); - Map> descriptionsMap = this.collectDmpDescriptions(descriptionsFields, data); - - FieldSet entityDoisFields = fields.extractPrefixed(this.asPrefix(PublicDmp._entityDois)); - Map> entityDoisMap = this.collectEntityDois(entityDoisFields, data); - - FieldSet otherDmpVersionsFields = fields.extractPrefixed(this.asPrefix(PublicDmp._otherDmpVersions)); - Map> otherDmpVersionsMap = this.collectOtherDmpVersions(otherDmpVersionsFields, data); - - for (DmpEntity d : data) { - PublicDmp m = new PublicDmp(); - if (fields.hasField(this.asIndexer(PublicDmp._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(PublicDmp._label))) m.setLabel(d.getLabel()); - if (fields.hasField(this.asIndexer(PublicDmp._version))) m.setVersion(d.getVersion()); - if (fields.hasField(this.asIndexer(PublicDmp._description))) m.setDescription(d.getDescription()); - if (fields.hasField(this.asIndexer(PublicDmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt()); - if (fields.hasField(this.asIndexer(PublicDmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if (fields.hasField(this.asIndexer(PublicDmp._accessType))) m.setAccessType(d.getAccessType()); - if (fields.hasField(this.asIndexer(PublicDmp._status))) m.setStatus(d.getStatus()); - if (fields.hasField(this.asIndexer(PublicDmp._groupId))) m.setGroupId(d.getGroupId()); - if (fields.hasField(this.asIndexer(PublicDmp._accessType))) m.setAccessType(d.getAccessType()); - - if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId())); - if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId())); - if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId())); - if (entityDoisMap != null && !entityDoisMap.isEmpty() && entityDoisMap.containsKey(d.getId())) m.setEntityDois(entityDoisMap.get(d.getId())); - if (otherDmpVersionsMap != null && !otherDmpVersionsMap.isEmpty() && otherDmpVersionsMap.containsKey(d.getGroupId())){ - m.setOtherDmpVersions(otherDmpVersionsMap.get(d.getGroupId())); - m.getOtherDmpVersions().sort(Comparator.comparing(PublicDmp::getVersion)); - } - - models.add(m); - } - this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); - - return models; - } - - private Map> collectDmpReferences(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDmpReference.class.getSimpleName()); - - Map> itemMap = null; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpReference._dmp, PublicDmp._id)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { - x.getDmp().setId(null); - }); - } - - return itemMap; - } - - private Map> collectDmpUsers(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDmpUser.class.getSimpleName()); - - Map> itemMap = null; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpUser._dmp, PublicDmp._id)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { - x.getDmp().setId(null); - }); - } - - return itemMap; - } - - private Map> collectDmpDescriptions(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDescription.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDescription._dmp, PublicDescription._id)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { - x.getDmp().setId(null); - }); - } - - return itemMap; - } - - private Map> collectEntityDois(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicEntityDoi.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicEntityDoi._entityId)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).forEach(x -> { - x.setEntityId(null); - }); - } - - return itemMap; - } - - private Map> collectOtherDmpVersions(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDmp.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id); - DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(this.authorize).groupIds(data.stream().map(DmpEntity::getGroupId).distinct().collect(Collectors.toList())).isActive(IsActive.Active); - itemMap = this.builderFactory.builder(PublicDmpBuilder.class).authorize(this.authorize).asMasterKey(query, clone, PublicDmp::getGroupId); - - if (!fields.hasField(PublicDmp._id)) { - itemMap.values().stream().flatMap(List::stream).filter(Objects::nonNull).forEach(x -> { - x.setId(null); - }); - } - - return itemMap; - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanBuilder.java new file mode 100644 index 000000000..3c70007bb --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanBuilder.java @@ -0,0 +1,193 @@ +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.enums.EntityType; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.PlanEntity; +import org.opencdmp.model.*; +import org.opencdmp.query.*; +import org.slf4j.LoggerFactory; +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; + +import java.util.*; +import java.util.stream.Collectors; + +@Component +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class PublicPlanBuilder extends BaseBuilder { + + private final QueryFactory queryFactory; + + private final BuilderFactory builderFactory; + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public PublicPlanBuilder(ConventionService conventionService, + QueryFactory queryFactory, + BuilderFactory builderFactory) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicPlanBuilder.class))); + this.queryFactory = queryFactory; + this.builderFactory = builderFactory; + } + + public PublicPlanBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + List models = new ArrayList<>(); + + FieldSet planReferencesFields = fields.extractPrefixed(this.asPrefix(PublicPlan._planReferences)); + Map> planReferenceMap = this.collectPlanReferences(planReferencesFields, data); + + FieldSet planUsersFields = fields.extractPrefixed(this.asPrefix(PublicPlan._planUsers)); + Map> planUsersMap = this.collectPlanUsers(planUsersFields, data); + + FieldSet descriptionsFields = fields.extractPrefixed(this.asPrefix(PublicPlan._descriptions)); + Map> descriptionsMap = this.collectPlanDescriptions(descriptionsFields, data); + + FieldSet entityDoisFields = fields.extractPrefixed(this.asPrefix(PublicPlan._entityDois)); + Map> entityDoisMap = this.collectEntityDois(entityDoisFields, data); + + FieldSet otherPlanVersionsFields = fields.extractPrefixed(this.asPrefix(PublicPlan._otherPlanVersions)); + Map> otherPlanVersionsMap = this.collectOtherPlanVersions(otherPlanVersionsFields, data); + + for (PlanEntity d : data) { + PublicPlan m = new PublicPlan(); + if (fields.hasField(this.asIndexer(PublicPlan._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(PublicPlan._label))) m.setLabel(d.getLabel()); + if (fields.hasField(this.asIndexer(PublicPlan._version))) m.setVersion(d.getVersion()); + if (fields.hasField(this.asIndexer(PublicPlan._description))) m.setDescription(d.getDescription()); + if (fields.hasField(this.asIndexer(PublicPlan._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt()); + if (fields.hasField(this.asIndexer(PublicPlan._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(PublicPlan._accessType))) m.setAccessType(d.getAccessType()); + if (fields.hasField(this.asIndexer(PublicPlan._status))) m.setStatus(d.getStatus()); + if (fields.hasField(this.asIndexer(PublicPlan._groupId))) m.setGroupId(d.getGroupId()); + if (fields.hasField(this.asIndexer(PublicPlan._accessType))) m.setAccessType(d.getAccessType()); + + if (planReferenceMap != null && !planReferenceMap.isEmpty() && planReferenceMap.containsKey(d.getId())) m.setPlanReferences(planReferenceMap.get(d.getId())); + if (planUsersMap != null && !planUsersMap.isEmpty() && planUsersMap.containsKey(d.getId())) m.setPlanUsers(planUsersMap.get(d.getId())); + if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId())); + if (entityDoisMap != null && !entityDoisMap.isEmpty() && entityDoisMap.containsKey(d.getId())) m.setEntityDois(entityDoisMap.get(d.getId())); + if (otherPlanVersionsMap != null && !otherPlanVersionsMap.isEmpty() && otherPlanVersionsMap.containsKey(d.getGroupId())){ + m.setOtherPlanVersions(otherPlanVersionsMap.get(d.getGroupId())); + m.getOtherPlanVersions().sort(Comparator.comparing(PublicPlan::getVersion)); + } + + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + + return models; + } + + private Map> collectPlanReferences(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", PublicPlanReference.class.getSimpleName()); + + Map> itemMap = null; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicPlanReference._plan, PublicPlan._id)); + PlanReferenceQuery query = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PublicPlanReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getPlan().getId()); + + if (!fields.hasField(this.asIndexer(PublicPlanReference._plan, PublicPlan._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getPlan() != null).forEach(x -> { + x.getPlan().setId(null); + }); + } + + return itemMap; + } + + private Map> collectPlanUsers(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", PublicPlanUser.class.getSimpleName()); + + Map> itemMap = null; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicPlanUser._plan, PublicPlan._id)); + PlanUserQuery query = this.queryFactory.query(PlanUserQuery.class).disableTracking().authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PublicPlanUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getPlan().getId()); + + if (!fields.hasField(this.asIndexer(PublicPlanUser._plan, PublicPlan._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getPlan() != null).forEach(x -> { + x.getPlan().setId(null); + }); + } + + return itemMap; + } + + private Map> collectPlanDescriptions(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", PublicDescription.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDescription._plan, PublicDescription._id)); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PublicDescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getPlan().getId()); + + if (!fields.hasField(this.asIndexer(PublicDescription._plan, PublicDescription._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getPlan() != null).forEach(x -> { + x.getPlan().setId(null); + }); + } + + return itemMap; + } + + private Map> collectEntityDois(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", PublicEntityDoi.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicEntityDoi._entityId)); + EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(this.authorize).types(EntityType.DMP).entityIds(data.stream().map(PlanEntity::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))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).forEach(x -> { + x.setEntityId(null); + }); + } + + return itemMap; + } + + private Map> collectOtherPlanVersions(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", PublicPlan.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicPlan._id); + PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(this.authorize).groupIds(data.stream().map(PlanEntity::getGroupId).distinct().collect(Collectors.toList())).isActive(IsActive.Active); + itemMap = this.builderFactory.builder(PublicPlanBuilder.class).authorize(this.authorize).asMasterKey(query, clone, PublicPlan::getGroupId); + + if (!fields.hasField(PublicPlan._id)) { + itemMap.values().stream().flatMap(List::stream).filter(Objects::nonNull).forEach(x -> { + x.setId(null); + }); + } + + return itemMap; + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanDescriptionTemplateBuilder.java similarity index 51% rename from backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanDescriptionTemplateBuilder.java index aa80d5907..52232d18d 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanDescriptionTemplateBuilder.java @@ -9,10 +9,10 @@ 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.opencdmp.data.PlanDescriptionTemplateEntity; +import org.opencdmp.model.PublicPlan; +import org.opencdmp.model.PublicPlanDescriptionTemplate; +import org.opencdmp.query.PlanQuery; 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.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder { +public class PublicPlanDescriptionTemplateBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -33,62 +33,62 @@ public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public PublicDmpDescriptionTemplateBuilder( + public PublicPlanDescriptionTemplateBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDmpDescriptionTemplateBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicPlanDescriptionTemplateBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; } - public PublicDmpDescriptionTemplateBuilder authorize(EnumSet values) { + public PublicPlanDescriptionTemplateBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpDescriptionTemplate._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(PublicPlanDescriptionTemplate._plan)); + Map planItemsMap = this.collectPlans(planFields, data); - List models = new ArrayList<>(); - for (DmpDescriptionTemplateEntity d : data) { - PublicDmpDescriptionTemplate m = new PublicDmpDescriptionTemplate(); - if (fields.hasField(this.asIndexer(PublicDmpDescriptionTemplate._id))) m.setId(d.getId()); - if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); + List models = new ArrayList<>(); + for (PlanDescriptionTemplateEntity d : data) { + PublicPlanDescriptionTemplate m = new PublicPlanDescriptionTemplate(); + if (fields.hasField(this.asIndexer(PublicPlanDescriptionTemplate._id))) m.setId(d.getId()); + if (!planFields.isEmpty() && planItemsMap != null && planItemsMap.containsKey(d.getPlanId())) m.setPlan(planItemsMap.get(d.getPlanId())); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); return models; } - private Map collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDmp.class.getSimpleName()); + this.logger.debug("checking related - {}", PublicPlan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(PublicDmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(PublicPlan._id))) { itemMap = this.asEmpty( - data.stream().map(DmpDescriptionTemplateEntity::getDmpId).distinct().collect(Collectors.toList()), + data.stream().map(PlanDescriptionTemplateEntity::getPlanId).distinct().collect(Collectors.toList()), x -> { - PublicDmp item = new PublicDmp(); + PublicPlan item = new PublicPlan(); item.setId(x); return item; }, - PublicDmp::getId); + PublicPlan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id); - DmpQuery q = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DmpDescriptionTemplateEntity::getDmpId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(PublicDmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmp::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicPlan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanDescriptionTemplateEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PublicPlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicPlan::getId); } - if (!fields.hasField(PublicDmp._id)) { + if (!fields.hasField(PublicPlan._id)) { itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpReferenceBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanReferenceBuilder.java similarity index 61% rename from backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpReferenceBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanReferenceBuilder.java index 82069be30..16665cb69 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpReferenceBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanReferenceBuilder.java @@ -10,11 +10,11 @@ import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpReferenceEntity; -import org.opencdmp.model.PublicDmp; -import org.opencdmp.model.PublicDmpReference; +import org.opencdmp.data.PlanReferenceEntity; +import org.opencdmp.model.PublicPlan; +import org.opencdmp.model.PublicPlanReference; import org.opencdmp.model.PublicReference; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.opencdmp.query.ReferenceQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +27,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class PublicDmpReferenceBuilder extends BaseBuilder { +public class PublicPlanReferenceBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -36,46 +36,46 @@ public class PublicDmpReferenceBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public PublicDmpReferenceBuilder( + public PublicPlanReferenceBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDmpReferenceBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicPlanReferenceBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; } - public PublicDmpReferenceBuilder authorize(EnumSet values) { + public PublicPlanReferenceBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(PublicDmpReference._reference)); + FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(PublicPlanReference._reference)); Map referenceItemsMap = this.collectReferences(referenceFields, data); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpReference._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(PublicPlanReference._plan)); + Map planItemsMap = this.collectPlans(planFields, data); - List models = new ArrayList<>(); - for (DmpReferenceEntity d : data) { - PublicDmpReference m = new PublicDmpReference(); - if (fields.hasField(this.asIndexer(PublicDmpReference._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(PublicDmpReference._isActive))) m.setIsActive(d.getIsActive()); + List models = new ArrayList<>(); + for (PlanReferenceEntity d : data) { + PublicPlanReference m = new PublicPlanReference(); + if (fields.hasField(this.asIndexer(PublicPlanReference._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(PublicPlanReference._isActive))) m.setIsActive(d.getIsActive()); if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId())); - if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); + if (!planFields.isEmpty() && planItemsMap != null && planItemsMap.containsKey(d.getPlanId())) m.setPlan(planItemsMap.get(d.getPlanId())); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); return models; } - private Map collectReferences(FieldSet fields, List data) throws MyApplicationException { + private Map collectReferences(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; this.logger.debug("checking related - {}", PublicReference.class.getSimpleName()); @@ -83,7 +83,7 @@ public class PublicDmpReferenceBuilder extends BaseBuilder itemMap; if (!fields.hasOtherField(this.asIndexer(PublicReference._id))) { itemMap = this.asEmpty( - data.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()), + data.stream().map(PlanReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()), x -> { PublicReference item = new PublicReference(); item.setId(x); @@ -92,7 +92,7 @@ public class PublicDmpReferenceBuilder extends BaseBuilder collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDmp.class.getSimpleName()); + this.logger.debug("checking related - {}", PublicPlan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(PublicDmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(PublicPlan._id))) { itemMap = this.asEmpty( - data.stream().map(DmpReferenceEntity::getDmpId).distinct().collect(Collectors.toList()), + data.stream().map(PlanReferenceEntity::getPlanId).distinct().collect(Collectors.toList()), x -> { - PublicDmp item = new PublicDmp(); + PublicPlan item = new PublicPlan(); item.setId(x); return item; }, - PublicDmp::getId); + PublicPlan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id); - DmpQuery q = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(this.authorize).isActive(IsActive.Active).ids(data.stream().map(DmpReferenceEntity::getDmpId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(PublicDmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmp::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicPlan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(this.authorize).isActive(IsActive.Active).ids(data.stream().map(PlanReferenceEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PublicPlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicPlan::getId); } - if (!fields.hasField(PublicDmp._id)) { + if (!fields.hasField(PublicPlan._id)) { itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpUserBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanUserBuilder.java similarity index 62% rename from backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpUserBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanUserBuilder.java index 336d4bc0f..e9f126e9e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpUserBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanUserBuilder.java @@ -9,12 +9,12 @@ 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.DmpUserEntity; -import org.opencdmp.model.PublicDmp; -import org.opencdmp.model.PublicDmpUser; +import org.opencdmp.data.PlanUserEntity; +import org.opencdmp.model.PublicPlan; +import org.opencdmp.model.PublicPlanUser; import org.opencdmp.model.PublicUser; import org.opencdmp.model.user.User; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +27,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class PublicDmpUserBuilder extends BaseBuilder{ +public class PublicPlanUserBuilder extends BaseBuilder{ private final BuilderFactory builderFactory; @@ -36,46 +36,46 @@ public class PublicDmpUserBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public PublicDmpUserBuilder( + public PublicPlanUserBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDmpUserBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicPlanUserBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; } - public PublicDmpUserBuilder authorize(EnumSet values) { + public PublicPlanUserBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - FieldSet userFields = fields.extractPrefixed(this.asPrefix(PublicDmpUser._user)); + FieldSet userFields = fields.extractPrefixed(this.asPrefix(PublicPlanUser._user)); Map userItemsMap = this.collectUsers(userFields, data); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpUser._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(PublicPlanUser._plan)); + Map planItemsMap = this.collectPlans(planFields, data); - List models = new ArrayList<>(); - for (DmpUserEntity d : data) { - PublicDmpUser m = new PublicDmpUser(); - if (fields.hasField(this.asIndexer(PublicDmpUser._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(PublicDmpUser._role))) m.setRole(d.getRole()); + List models = new ArrayList<>(); + for (PlanUserEntity d : data) { + PublicPlanUser m = new PublicPlanUser(); + if (fields.hasField(this.asIndexer(PublicPlanUser._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(PublicPlanUser._role))) m.setRole(d.getRole()); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId())); - if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); + if (!planFields.isEmpty() && planItemsMap != null && planItemsMap.containsKey(d.getPlanId())) m.setPlan(planItemsMap.get(d.getPlanId())); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); return models; } - private Map collectUsers(FieldSet fields, List data) throws MyApplicationException { + private Map collectUsers(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; this.logger.debug("checking related - {}", User.class.getSimpleName()); @@ -83,7 +83,7 @@ public class PublicDmpUserBuilder extends BaseBuilder itemMap; if (!fields.hasOtherField(this.asIndexer(PublicUser._id))) { itemMap = this.asEmpty( - data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()), + data.stream().map(PlanUserEntity::getUserId).distinct().collect(Collectors.toList()), x -> { PublicUser item = new PublicUser(); item.setId(x); @@ -92,7 +92,7 @@ public class PublicDmpUserBuilder extends BaseBuilder collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", PublicDmp.class.getSimpleName()); + this.logger.debug("checking related - {}", PublicPlan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(PublicDmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(PublicPlan._id))) { itemMap = this.asEmpty( - data.stream().map(DmpUserEntity::getDmpId).distinct().collect(Collectors.toList()), + data.stream().map(PlanUserEntity::getPlanId).distinct().collect(Collectors.toList()), x -> { - PublicDmp item = new PublicDmp(); + PublicPlan item = new PublicPlan(); item.setId(x); return item; }, - PublicDmp::getId); + PublicPlan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id); - 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(PublicDmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmp::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicPlan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanUserEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PublicPlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicPlan::getId); } - if (!fields.hasField(PublicDmp._id)) { + if (!fields.hasField(PublicPlan._id)) { itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/RecentActivityItemBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/RecentActivityItemBuilder.java index b63f009f5..a2d322b18 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/RecentActivityItemBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/RecentActivityItemBuilder.java @@ -13,11 +13,11 @@ import org.opencdmp.commons.types.dashborad.RecentActivityItemEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.RecentActivityItem; import org.opencdmp.model.builder.description.DescriptionBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -61,15 +61,15 @@ public class RecentActivityItemBuilder extends BaseBuilder descriptionItemsMap = this.collectDescriptions(descriptionFields, data); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(RecentActivityItem._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(RecentActivityItem._plan)); + Map planItemsMap = this.collectPlans(planFields, data); List models = new ArrayList<>(); for (RecentActivityItemEntity d : data) { RecentActivityItem m = new RecentActivityItem(); if (fields.hasField(this.asIndexer(RecentActivityItem._type))) m.setType(d.getType()); if (!descriptionFields.isEmpty() && descriptionItemsMap != null && descriptionItemsMap.containsKey(d.getId())) m.setDescription(descriptionItemsMap.get(d.getId())); - if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getId())) m.setDmp(dmpItemsMap.get(d.getId())); + if (!planFields.isEmpty() && planItemsMap != null && planItemsMap.containsKey(d.getId())) m.setPlan(planItemsMap.get(d.getId())); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); @@ -77,27 +77,27 @@ public class RecentActivityItemBuilder extends BaseBuilder collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); + this.logger.debug("checking related - {}", Plan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(Dmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(Plan._id))) { itemMap = this.asEmpty( - data.stream().filter(x-> x.getType().equals(RecentActivityItemType.Dmp)).map(RecentActivityItemEntity::getId).distinct().collect(Collectors.toList()), + data.stream().filter(x-> x.getType().equals(RecentActivityItemType.Plan)).map(RecentActivityItemEntity::getId).distinct().collect(Collectors.toList()), x -> { - Dmp item = new Dmp(); + Plan item = new Plan(); item.setId(x); return item; }, - Dmp::getId); + Plan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); - 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); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Plan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().filter(x-> x.getType().equals(RecentActivityItemType.Plan)).map(RecentActivityItemEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Plan::getId); } - if (!fields.hasField(Dmp._id)) { + if (!fields.hasField(Plan._id)) { itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/SupportiveMaterialBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/SupportiveMaterialBuilder.java index 75a14d252..c40eececb 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/SupportiveMaterialBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/SupportiveMaterialBuilder.java @@ -3,15 +3,9 @@ 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.DmpReferenceEntity; import org.opencdmp.data.SupportiveMaterialEntity; import org.opencdmp.model.*; -import org.opencdmp.query.DmpQuery; -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.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; @@ -22,7 +16,6 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import java.util.*; -import java.util.stream.Collectors; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) 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 5f22f13f0..548c76d5a 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 @@ -10,7 +10,7 @@ import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.commons.types.actionconfirmation.DmpInvitationEntity; +import org.opencdmp.commons.types.actionconfirmation.PlanInvitationEntity; import org.opencdmp.commons.types.actionconfirmation.MergeAccountConfirmationEntity; import org.opencdmp.commons.types.actionconfirmation.RemoveCredentialRequestEntity; import org.opencdmp.commons.types.actionconfirmation.UserInviteToTenantRequestEntity; @@ -83,9 +83,9 @@ public class ActionConfirmationBuilder extends BaseBuilder { - DmpInvitationEntity dmpInvitation = this.xmlHandlingService.fromXmlSafe(DmpInvitationEntity.class, d.getData()); - m.setDmpInvitation(this.builderFactory.builder(DmpInvitationBuilder.class).authorize(this.authorize).build(dmpInvitationFields, dmpInvitation)); + case PlanInvitation -> { + PlanInvitationEntity dmpInvitation = this.xmlHandlingService.fromXmlSafe(PlanInvitationEntity.class, d.getData()); + m.setDmpInvitation(this.builderFactory.builder(PlanInvitationBuilder.class).authorize(this.authorize).build(dmpInvitationFields, dmpInvitation)); } case RemoveCredential -> { RemoveCredentialRequestEntity emailConfirmation = this.xmlHandlingService.fromXmlSafe(RemoveCredentialRequestEntity.class, d.getData()); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/DmpInvitationBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/PlanInvitationBuilder.java similarity index 61% rename from backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/DmpInvitationBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/PlanInvitationBuilder.java index a0889e653..a8fa1163c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/DmpInvitationBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/actionconfirmation/PlanInvitationBuilder.java @@ -1,11 +1,10 @@ package org.opencdmp.model.builder.actionconfirmation; import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.types.actionconfirmation.DmpInvitationEntity; +import org.opencdmp.commons.types.actionconfirmation.PlanInvitationEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.actionconfirmation.DmpInvitation; +import org.opencdmp.model.actionconfirmation.PlanInvitation; import org.opencdmp.model.builder.BaseBuilder; -import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; @@ -20,35 +19,35 @@ import java.util.*; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpInvitationBuilder extends BaseBuilder { +public class PlanInvitationBuilder extends BaseBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpInvitationBuilder( + public PlanInvitationBuilder( ConventionService conventionService) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpInvitationBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanInvitationBuilder.class))); } - public DmpInvitationBuilder authorize(EnumSet values) { + public PlanInvitationBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - List models = new ArrayList<>(); - for (DmpInvitationEntity d : data) { - DmpInvitation m = new DmpInvitation(); - if (fields.hasField(this.asIndexer(DmpInvitation._email))) m.setEmail(d.getEmail()); - if (fields.hasField(this.asIndexer(DmpInvitation._dmpId))) m.setDmpId(d.getDmpId()); - if (fields.hasField(this.asIndexer(DmpInvitation._role))) m.setRole(d.getRole()); + List models = new ArrayList<>(); + for (PlanInvitationEntity d : data) { + PlanInvitation m = new PlanInvitation(); + if (fields.hasField(this.asIndexer(PlanInvitation._email))) m.setEmail(d.getEmail()); + if (fields.hasField(this.asIndexer(PlanInvitation._planId))) m.setPlanId(d.getPlanId()); + if (fields.hasField(this.asIndexer(PlanInvitation._role))) m.setRole(d.getRole()); models.add(m); } 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/PlanUserCommonModelBuilder.java similarity index 80% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/DmpUserCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java index e63413c8b..b14524959 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/PlanUserCommonModelBuilder.java @@ -10,7 +10,7 @@ import org.opencdmp.commonmodels.models.DmpUserModel; import org.opencdmp.commonmodels.models.UserModel; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpUserEntity; +import org.opencdmp.data.PlanUserEntity; import org.opencdmp.data.UserEntity; import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; @@ -24,7 +24,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpUserCommonModelBuilder extends BaseCommonModelBuilder { +public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; @@ -33,21 +33,21 @@ public class DmpUserCommonModelBuilder extends BaseCommonModelBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpUserCommonModelBuilder( + public PlanUserCommonModelBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserCommonModelBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanUserCommonModelBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; } - public DmpUserCommonModelBuilder authorize(EnumSet values) { + public PlanUserCommonModelBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List data) throws MyApplicationException { this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null) return new ArrayList<>(); @@ -55,8 +55,8 @@ public class DmpUserCommonModelBuilder extends BaseCommonModelBuilder userItemsMap = this.collectUsers(data); - List> models = new ArrayList<>(); - for (DmpUserEntity d : data) { + List> models = new ArrayList<>(); + for (PlanUserEntity d : data) { DmpUserModel m = new DmpUserModel(); switch (d.getRole()){ case Viewer -> m.setRole(DmpUserRole.Viewer); @@ -72,13 +72,13 @@ public class DmpUserCommonModelBuilder extends BaseCommonModelBuilder collectUsers(List data) throws MyApplicationException { + private Map collectUsers(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", UserModel.class.getSimpleName()); Map itemMap; - UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().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(PlanUserEntity::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/description/DescriptionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java index 943388218..6afc75412 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 @@ -17,17 +17,17 @@ import org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.DescriptionEntity; import org.opencdmp.data.DescriptionTemplateEntity; -import org.opencdmp.data.DmpDescriptionTemplateEntity; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.data.PlanDescriptionTemplateEntity; +import org.opencdmp.data.PlanEntity; +import org.opencdmp.model.PlanDescriptionTemplate; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; import org.opencdmp.model.builder.commonmodels.descriptiontemplate.DescriptionTemplateCommonModelBuilder; -import org.opencdmp.model.builder.commonmodels.dmp.DmpCommonModelBuilder; +import org.opencdmp.model.builder.commonmodels.plan.PlanCommonModelBuilder; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; import org.opencdmp.query.DescriptionTemplateQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanDescriptionTemplateQuery; +import org.opencdmp.query.PlanQuery; import org.opencdmp.service.visibility.VisibilityService; import org.opencdmp.service.visibility.VisibilityServiceImpl; import org.slf4j.LoggerFactory; @@ -87,10 +87,10 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder(); Map descriptionTemplates = this.collectDescriptionTemplates(data); - Map dmps = this.collectDmps(data); + Map plans = this.collectPlans(data); Map definitionEntityMap = this.collectDescriptionTemplateDefinitions(data); - Map dmpDescriptionTemplateSections = this.collectDmpDescriptionTemplateSections(data); + Map planDescriptionTemplateSections = this.collectPlanDescriptionTemplateSections(data); List> models = new ArrayList<>(); for (DescriptionEntity d : data) { @@ -106,8 +106,8 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder collectDmpDescriptionTemplateSections(List data) throws MyApplicationException { + private Map collectPlanDescriptionTemplateSections(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", DefinitionEntity.class.getSimpleName()); Map itemMap = new HashMap<>(); - 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){ + PlanDescriptionTemplateQuery q = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().collect(Collectors.toList())); + List items = q.collectAs(new BaseFieldSet().ensure(PlanDescriptionTemplate._id).ensure(PlanDescriptionTemplate._sectionId)); + for (PlanDescriptionTemplateEntity item : items){ itemMap.put(item.getId(), item.getSectionId()); } return itemMap; } - private Map collectDmps(List data) throws MyApplicationException { + private Map collectPlans(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", DmpModel.class.getSimpleName()); Map itemMap; - 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); + PlanQuery q = this.queryFactory.query(PlanQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(DescriptionEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanCommonModelBuilder.class).setRepositoryId(this.repositoryId).useSharedStorage(this.useSharedStorage).setDisableDescriptions(true).authorize(this.authorize).asForeignKey(q, PlanEntity::getId); return itemMap; } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpBlueprintValueCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanBlueprintValueCommonModelBuilder.java similarity index 63% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpBlueprintValueCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanBlueprintValueCommonModelBuilder.java index e21ccae22..827519b3a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpBlueprintValueCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanBlueprintValueCommonModelBuilder.java @@ -1,13 +1,13 @@ -package org.opencdmp.model.builder.commonmodels.dmp; +package org.opencdmp.model.builder.commonmodels.plan; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel; -import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; -import org.opencdmp.commons.types.dmp.DmpBlueprintValueEntity; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; -import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.FieldEntity; +import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; +import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity; +import org.opencdmp.commons.types.planblueprint.FieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; @@ -26,43 +26,43 @@ import java.util.Optional; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBlueprintValueCommonModelBuilder extends BaseCommonModelBuilder { +public class PlanBlueprintValueCommonModelBuilder extends BaseCommonModelBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private DefinitionEntity definition; @Autowired - public DmpBlueprintValueCommonModelBuilder( + public PlanBlueprintValueCommonModelBuilder( ConventionService conventionService ) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintValueCommonModelBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanBlueprintValueCommonModelBuilder.class))); } - public DmpBlueprintValueCommonModelBuilder authorize(EnumSet values) { + public PlanBlueprintValueCommonModelBuilder authorize(EnumSet values) { this.authorize = values; return this; } - public DmpBlueprintValueCommonModelBuilder withDefinition(DefinitionEntity definition) { + public PlanBlueprintValueCommonModelBuilder withDefinition(DefinitionEntity definition) { this.definition = definition; return this; } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List data) throws MyApplicationException { this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return new ArrayList<>(); - List> models = new ArrayList<>(); - for (DmpBlueprintValueEntity d : data) { + List> models = new ArrayList<>(); + for (PlanBlueprintValueEntity d : data) { FieldEntity fieldEntity = this.definition != null ? this.definition.getFieldById(d.getFieldId()).stream().findFirst().orElse(null) : null; - if (fieldEntity != null && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)) { + if (fieldEntity != null && fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)) { ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity; DmpBlueprintValueModel m = new DmpBlueprintValueModel(); m.setFieldId(d.getFieldId()); - if (extraFieldEntity != null && DmpBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){ + if (extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){ m.setDateValue(d.getDateValue()); - } else if (extraFieldEntity != null && DmpBlueprintExtraFieldDataType.isNumberType(extraFieldEntity.getType())){ + } else if (extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isNumberType(extraFieldEntity.getType())){ m.setNumberValue(d.getNumberValue()); } else { m.setValue(d.getValue()); 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/plan/PlanCommonModelBuilder.java similarity index 58% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java index dcc08b3b8..0ef4a14d9 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/plan/PlanCommonModelBuilder.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.builder.commonmodels.dmp; +package org.opencdmp.model.builder.commonmodels.plan; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.Ordering; @@ -20,20 +20,20 @@ import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel; import org.opencdmp.commons.JsonHandlingService; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.types.dmp.DmpPropertiesEntity; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; +import org.opencdmp.commons.types.plan.PlanPropertiesEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.*; -import org.opencdmp.model.DmpUser; +import org.opencdmp.model.PlanUser; 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; -import org.opencdmp.model.builder.commonmodels.dmpreference.DmpReferenceCommonModelBuilder; +import org.opencdmp.model.builder.commonmodels.planblueprint.PlanBlueprintCommonModelBuilder; +import org.opencdmp.model.builder.commonmodels.planreference.PlanReferenceCommonModelBuilder; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.planblueprint.PlanBlueprint; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.query.*; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -46,7 +46,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpCommonModelBuilder extends BaseCommonModelBuilder { +public class PlanCommonModelBuilder extends BaseCommonModelBuilder { private final QueryFactory queryFactory; @@ -60,64 +60,64 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpCommonModelBuilder(ConventionService conventionService, - QueryFactory queryFactory, - BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpCommonModelBuilder.class))); + public PlanCommonModelBuilder(ConventionService conventionService, + QueryFactory queryFactory, + BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanCommonModelBuilder.class))); this.queryFactory = queryFactory; this.builderFactory = builderFactory; this.jsonHandlingService = jsonHandlingService; this.xmlHandlingService = xmlHandlingService; } - public DmpCommonModelBuilder authorize(EnumSet values) { + public PlanCommonModelBuilder authorize(EnumSet values) { this.authorize = values; return this; } - public DmpCommonModelBuilder setPdfFile(FileEnvelopeModel pdfFile) { + public PlanCommonModelBuilder setPdfFile(FileEnvelopeModel pdfFile) { this.pdfFile = pdfFile; return this; } - public DmpCommonModelBuilder setRdaJsonFile(FileEnvelopeModel rdaJsonFile) { + public PlanCommonModelBuilder setRdaJsonFile(FileEnvelopeModel rdaJsonFile) { this.rdaJsonFile = rdaJsonFile; return this; } - public DmpCommonModelBuilder setRepositoryId(String repositoryId) { + public PlanCommonModelBuilder setRepositoryId(String repositoryId) { this.repositoryId = repositoryId; return this; } - public DmpCommonModelBuilder setDisableDescriptions(boolean disableDescriptions) { + public PlanCommonModelBuilder setDisableDescriptions(boolean disableDescriptions) { this.disableDescriptions = disableDescriptions; return this; } private boolean useSharedStorage; - public DmpCommonModelBuilder useSharedStorage(boolean useSharedStorage) { + public PlanCommonModelBuilder useSharedStorage(boolean useSharedStorage) { this.useSharedStorage = useSharedStorage; return this; } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List data) throws MyApplicationException { this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return new ArrayList<>(); - List> models = new ArrayList<>(); + List> models = new ArrayList<>(); - Map> dmpReferencesMap = this.collectDmpReferences(data); - Map> dmpUsersMap = this.collectDmpUsers(data); - Map> descriptionsMap = this.disableDescriptions ? null : this.collectDmpDescriptions(data); - Map> entityDois = this.collectDmpEntityDois(data); + Map> planReferencesMap = this.collectPlanReferences(data); + Map> planUsersMap = this.collectPlanUsers(data); + Map> descriptionsMap = this.disableDescriptions ? null : this.collectPlanDescriptions(data); + Map> entityDois = this.collectPlanEntityDois(data); Map creators = this.collectCreators(data); - Map dmpBlueprints = this.collectDmpBlueprints(data); - Map definitionEntityMap = this.collectDmpBlueprintDefinitions(data); + Map dmpBlueprints = this.collectPlanBlueprints(data); + Map definitionEntityMap = this.collectPlanBlueprintDefinitions(data); - for (DmpEntity d : data) { + for (PlanEntity d : data) { DmpModel m = new DmpModel(); m.setId(d.getId()); m.setLabel(d.getLabel()); @@ -136,8 +136,8 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder throw new MyApplicationException("unrecognized type " + d.getAccessType()); } - if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setReferences(dmpReferencesMap.get(d.getId())); - if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setUsers(dmpUsersMap.get(d.getId())); + if (planReferencesMap != null && !planReferencesMap.isEmpty() && planReferencesMap.containsKey(d.getId())) m.setReferences(planReferencesMap.get(d.getId())); + if (planUsersMap != null && !planUsersMap.isEmpty() && planUsersMap.containsKey(d.getId())) m.setUsers(planUsersMap.get(d.getId())); if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId())); models.add(new CommonModelBuilderItemResponse<>(m, d)); @@ -162,96 +162,96 @@ 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(); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking(); + planQuery.setOrder(new Ordering().addDescending(Plan._version)); + List planIds = planQuery.groupIds(dmpGroup).excludedIds(currentPlanId).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Plan._id)).stream().map(PlanEntity::getId).toList(); //GK: Step two get it's doiEntity - 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) { + List dois = this.queryFactory.query(EntityDoiQuery.class).disableTracking().repositoryIds(this.repositoryId).entityIds(planIds).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(EntityDoi._entityId, EntityDoi._doi)); + for(UUID uuid: planIds) { EntityDoiEntity doiEntity = dois.stream().filter(x -> x.getEntityId().equals(uuid)).findFirst().orElse(null); if (doiEntity != null) return doiEntity.getDoi(); } return null; } - private Map> collectDmpUsers(List data) throws MyApplicationException { - this.logger.debug("checking related - {}", DmpUser.class.getSimpleName()); + private Map> collectPlanUsers(List data) throws MyApplicationException { + this.logger.debug("checking related - {}", PlanUser.class.getSimpleName()); Map> itemMap; - 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); + PlanUserQuery query = this.queryFactory.query(PlanUserQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanUserCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, PlanUserEntity::getPlanId); return itemMap; } - private Map> collectDmpReferences(List data) throws MyApplicationException { - this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); + private Map> collectPlanReferences(List data) throws MyApplicationException { + this.logger.debug("checking related - {}", PlanReference.class.getSimpleName()); Map> itemMap; - 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); + PlanReferenceQuery query = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanReferenceCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, PlanReferenceEntity::getPlanId); return itemMap; } - private Map> collectDmpDescriptions(List data) throws MyApplicationException { + private Map> collectPlanDescriptions(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", Description.class.getSimpleName()); Map> itemMap; - 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); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(DescriptionCommonModelBuilder.class).setRepositoryId(this.repositoryId).useSharedStorage(this.useSharedStorage).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getPlanId); return itemMap; } - private Map> collectDmpEntityDois(List data) throws MyApplicationException { + private Map> collectPlanEntityDois(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", EntityDoi.class.getSimpleName()); Map> itemMap; - EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).disableTracking().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(PlanEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(EntityDoiCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, EntityDoiEntity::getEntityId); return itemMap; } - private Map collectCreators(List data) throws MyApplicationException { + private Map collectCreators(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", UserModel.class.getSimpleName()); Map itemMap; - 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())); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().disableTracking().isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getCreatorId() != null).map(PlanEntity::getCreatorId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(UserCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId); return itemMap; } - private Map collectDmpBlueprints(List data) throws MyApplicationException { + private Map collectPlanBlueprints(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", DmpBlueprintModel.class.getSimpleName()); Map itemMap; - DmpBlueprintQuery q = this.queryFactory.query(DmpBlueprintQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getBlueprintId() != null).map(DmpEntity::getBlueprintId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(DmpBlueprintCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, DmpBlueprintEntity::getId); + PlanBlueprintQuery q = this.queryFactory.query(PlanBlueprintQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getBlueprintId() != null).map(PlanEntity::getBlueprintId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, PlanBlueprintEntity::getId); return itemMap; } - private Map collectDmpBlueprintDefinitions(List data) throws MyApplicationException { + private Map collectPlanBlueprintDefinitions(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", DefinitionEntity.class.getSimpleName()); Map itemMap = new HashMap<>(); - DmpBlueprintQuery q = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DmpEntity::getBlueprintId).distinct().collect(Collectors.toList())); - List items = q.collectAs(new BaseFieldSet().ensure(DmpBlueprint._id).ensure(DmpBlueprint._definition)); - for (DmpBlueprintEntity item : items){ + PlanBlueprintQuery q = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanEntity::getBlueprintId).distinct().collect(Collectors.toList())); + List items = q.collectAs(new BaseFieldSet().ensure(PlanBlueprint._id).ensure(PlanBlueprint._definition)); + for (PlanBlueprintEntity item : items){ DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, item.getDefinition()); itemMap.put(item.getId(), definition); } 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/plan/PlanContactCommonModelBuilder.java similarity index 75% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpContactCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanContactCommonModelBuilder.java index ce69c18f1..6de7a490a 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/plan/PlanContactCommonModelBuilder.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.builder.commonmodels.dmp; +package org.opencdmp.model.builder.commonmodels.plan; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; @@ -6,7 +6,7 @@ import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.dmp.DmpContactModel; -import org.opencdmp.commons.types.dmp.DmpContactEntity; +import org.opencdmp.commons.types.plan.PlanContactEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; @@ -20,7 +20,7 @@ import java.util.*; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpContactCommonModelBuilder extends BaseCommonModelBuilder { +public class PlanContactCommonModelBuilder extends BaseCommonModelBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private final BuilderFactory builderFactory; @@ -28,25 +28,25 @@ public class DmpContactCommonModelBuilder extends BaseCommonModelBuilder values) { + public PlanContactCommonModelBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List data) throws MyApplicationException { this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return new ArrayList<>(); - List> models = new ArrayList<>(); - for (DmpContactEntity d : data) { + List> models = new ArrayList<>(); + for (PlanContactEntity d : data) { DmpContactModel m = new DmpContactModel(); m.setEmail(d.getEmail()); m.setFirstName(d.getFirstName()); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpPropertiesCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanPropertiesCommonModelBuilder.java similarity index 62% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpPropertiesCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanPropertiesCommonModelBuilder.java index 1a5d397d1..8c22130f2 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmp/DmpPropertiesCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanPropertiesCommonModelBuilder.java @@ -1,17 +1,15 @@ -package org.opencdmp.model.builder.commonmodels.dmp; +package org.opencdmp.model.builder.commonmodels.plan; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.dmp.DmpPropertiesModel; -import org.opencdmp.commons.types.dmp.DmpPropertiesEntity; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; +import org.opencdmp.commons.types.plan.PlanPropertiesEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; -import org.opencdmp.model.builder.commonmodels.descriptiontemplate.PageCommonModelBuilder; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.logging.LoggerService; -import org.opencdmp.model.builder.dmp.DmpPropertiesBuilder; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -25,38 +23,38 @@ import java.util.Optional; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpPropertiesCommonModelBuilder extends BaseCommonModelBuilder { +public class PlanPropertiesCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private DefinitionEntity definition; @Autowired - public DmpPropertiesCommonModelBuilder( + public PlanPropertiesCommonModelBuilder( ConventionService conventionService, BuilderFactory builderFactory ) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpPropertiesCommonModelBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanPropertiesCommonModelBuilder.class))); this.builderFactory = builderFactory; } - public DmpPropertiesCommonModelBuilder withDefinition(DefinitionEntity definition) { + public PlanPropertiesCommonModelBuilder withDefinition(DefinitionEntity definition) { this.definition = definition; return this; } - public DmpPropertiesCommonModelBuilder authorize(EnumSet values) { + public PlanPropertiesCommonModelBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List data) throws MyApplicationException { this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return new ArrayList<>(); - List> models = new ArrayList<>(); - for (DmpPropertiesEntity d : data) { + List> models = new ArrayList<>(); + for (PlanPropertiesEntity d : data) { DmpPropertiesModel m = new DmpPropertiesModel(); - if (d.getDmpBlueprintValues() != null) m.setDmpBlueprintValues(this.builderFactory.builder(DmpBlueprintValueCommonModelBuilder.class).withDefinition(definition).authorize(this.authorize).build(d.getDmpBlueprintValues())); - if (d.getContacts() != null) m.setContacts(this.builderFactory.builder(DmpContactCommonModelBuilder.class).authorize(this.authorize).build(d.getContacts())); + if (d.getPlanBlueprintValues() != null) m.setDmpBlueprintValues(this.builderFactory.builder(PlanBlueprintValueCommonModelBuilder.class).withDefinition(definition).authorize(this.authorize).build(d.getPlanBlueprintValues())); + if (d.getContacts() != null) m.setContacts(this.builderFactory.builder(PlanContactCommonModelBuilder.class).authorize(this.authorize).build(d.getContacts())); models.add(new CommonModelBuilderItemResponse<>(m, d)); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/DefinitionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/DefinitionCommonModelBuilder.java similarity index 92% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/DefinitionCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/DefinitionCommonModelBuilder.java index aa501c008..d1aff143f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/DefinitionCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/DefinitionCommonModelBuilder.java @@ -1,12 +1,11 @@ -package org.opencdmp.model.builder.commonmodels.dmpblueprint; +package org.opencdmp.model.builder.commonmodels.planblueprint; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.dmpblueprint.DefinitionModel; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; -import org.opencdmp.model.builder.commonmodels.dmp.DmpBlueprintValueCommonModelBuilder; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.logging.LoggerService; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/ExtraFieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ExtraFieldCommonModelBuilder.java similarity index 91% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/ExtraFieldCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ExtraFieldCommonModelBuilder.java index dc4f34670..51f958091 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/ExtraFieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ExtraFieldCommonModelBuilder.java @@ -1,8 +1,8 @@ -package org.opencdmp.model.builder.commonmodels.dmpblueprint; +package org.opencdmp.model.builder.commonmodels.planblueprint; import org.opencdmp.commonmodels.enums.DmpBlueprintExtraFieldDataType; import org.opencdmp.commonmodels.models.dmpblueprint.ExtraFieldModel; -import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity; +import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity; import org.opencdmp.convention.ConventionService; import gr.cite.tools.exception.MyApplicationException; import org.springframework.beans.factory.annotation.Autowired; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/FieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/FieldCommonModelBuilder.java similarity index 96% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/FieldCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/FieldCommonModelBuilder.java index 620c302c3..b5d0b336b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/FieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/FieldCommonModelBuilder.java @@ -1,9 +1,9 @@ -package org.opencdmp.model.builder.commonmodels.dmpblueprint; +package org.opencdmp.model.builder.commonmodels.planblueprint; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory; import org.opencdmp.commonmodels.models.dmpblueprint.FieldModel; -import org.opencdmp.commons.types.dmpblueprint.FieldEntity; +import org.opencdmp.commons.types.planblueprint.FieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/DmpBlueprintCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/PlanBlueprintCommonModelBuilder.java similarity index 75% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/DmpBlueprintCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/PlanBlueprintCommonModelBuilder.java index dc8abd0c2..6ca616e34 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/DmpBlueprintCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/PlanBlueprintCommonModelBuilder.java @@ -1,12 +1,12 @@ -package org.opencdmp.model.builder.commonmodels.dmpblueprint; +package org.opencdmp.model.builder.commonmodels.planblueprint; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.enums.DmpBlueprintStatus; import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel; import org.opencdmp.commons.XmlHandlingService; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.data.PlanBlueprintEntity; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; import gr.cite.tools.data.builder.BuilderFactory; @@ -25,33 +25,33 @@ import java.util.Optional; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBlueprintCommonModelBuilder extends BaseCommonModelBuilder { +public class PlanBlueprintCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; private final XmlHandlingService xmlHandlingService; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpBlueprintCommonModelBuilder(ConventionService conventionService, - BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintCommonModelBuilder.class))); + public PlanBlueprintCommonModelBuilder(ConventionService conventionService, + BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanBlueprintCommonModelBuilder.class))); this.builderFactory = builderFactory; this.xmlHandlingService = xmlHandlingService; } - public DmpBlueprintCommonModelBuilder authorize(EnumSet values) { + public PlanBlueprintCommonModelBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List data) throws MyApplicationException { this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return new ArrayList<>(); - List> models = new ArrayList<>(); + List> models = new ArrayList<>(); - for (DmpBlueprintEntity d : data) { + for (PlanBlueprintEntity d : data) { DmpBlueprintModel m = new DmpBlueprintModel(); m.setId(d.getId()); m.setLabel(d.getLabel()); 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/planblueprint/ReferenceTypeFieldCommonModelBuilder.java similarity index 92% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/ReferenceTypeFieldCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/ReferenceTypeFieldCommonModelBuilder.java index 588f0a127..2a3fce7ca 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/planblueprint/ReferenceTypeFieldCommonModelBuilder.java @@ -1,9 +1,9 @@ -package org.opencdmp.model.builder.commonmodels.dmpblueprint; +package org.opencdmp.model.builder.commonmodels.planblueprint; 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.commons.types.planblueprint.ReferenceTypeFieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.ReferenceTypeCommonModelBuilder; import org.opencdmp.query.ReferenceTypeQuery; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/SectionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SectionCommonModelBuilder.java similarity index 80% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/SectionCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SectionCommonModelBuilder.java index 498774159..e50c4d7dc 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/SectionCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SectionCommonModelBuilder.java @@ -1,12 +1,12 @@ -package org.opencdmp.model.builder.commonmodels.dmpblueprint; +package org.opencdmp.model.builder.commonmodels.planblueprint; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.dmpblueprint.SectionModel; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; -import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.ReferenceTypeFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.SectionEntity; -import org.opencdmp.commons.types.dmpblueprint.SystemFieldEntity; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; +import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity; +import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity; +import org.opencdmp.commons.types.planblueprint.SectionEntity; +import org.opencdmp.commons.types.planblueprint.SystemFieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; @@ -58,11 +58,11 @@ public class SectionCommonModelBuilder extends BaseCommonModelBuilder()); - List systemFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.System.equals(x.getCategory())).map(x-> (SystemFieldEntity)x).toList(); + List systemFieldEntities = d.getFields().stream().filter(x-> PlanBlueprintFieldCategory.System.equals(x.getCategory())).map(x-> (SystemFieldEntity)x).toList(); m.getFields().addAll(this.builderFactory.builder(SystemFieldCommonModelBuilder.class).authorize(this.authorize).build(systemFieldEntities)); - List extraFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldEntity)x).toList(); + List extraFieldEntities = d.getFields().stream().filter(x-> PlanBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldEntity)x).toList(); m.getFields().addAll(this.builderFactory.builder(ExtraFieldCommonModelBuilder.class).authorize(this.authorize).build(extraFieldEntities)); - List referenceFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldEntity)x).toList(); + List referenceFieldEntities = d.getFields().stream().filter(x-> PlanBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldEntity)x).toList(); m.getFields().addAll(this.builderFactory.builder(ReferenceTypeFieldCommonModelBuilder.class).authorize(this.authorize).build(referenceFieldEntities)); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/SystemFieldCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SystemFieldCommonModelBuilder.java similarity index 92% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/SystemFieldCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SystemFieldCommonModelBuilder.java index d68449d28..ab6cb0b9f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/SystemFieldCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planblueprint/SystemFieldCommonModelBuilder.java @@ -1,8 +1,8 @@ -package org.opencdmp.model.builder.commonmodels.dmpblueprint; +package org.opencdmp.model.builder.commonmodels.planblueprint; import org.opencdmp.commonmodels.enums.DmpBlueprintSystemFieldType; import org.opencdmp.commonmodels.models.dmpblueprint.SystemFieldModel; -import org.opencdmp.commons.types.dmpblueprint.SystemFieldEntity; +import org.opencdmp.commons.types.planblueprint.SystemFieldEntity; import org.opencdmp.convention.ConventionService; import gr.cite.tools.exception.MyApplicationException; import org.springframework.beans.factory.annotation.Autowired; 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/planreference/PlanReferenceCommonModelBuilder.java similarity index 72% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpreference/DmpReferenceCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceCommonModelBuilder.java index c79ae4042..5adacde97 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/planreference/PlanReferenceCommonModelBuilder.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.builder.commonmodels.dmpreference; +package org.opencdmp.model.builder.commonmodels.planreference; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; @@ -8,9 +8,9 @@ import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel; import org.opencdmp.commonmodels.models.reference.ReferenceModel; import org.opencdmp.commons.JsonHandlingService; -import org.opencdmp.commons.types.dmpreference.DmpReferenceDataEntity; +import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpReferenceEntity; +import org.opencdmp.data.PlanReferenceEntity; import org.opencdmp.data.ReferenceEntity; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; @@ -27,7 +27,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpReferenceCommonModelBuilder extends BaseCommonModelBuilder { +public class PlanReferenceCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; private final QueryFactory queryFactory; @@ -35,33 +35,33 @@ public class DmpReferenceCommonModelBuilder extends BaseCommonModelBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpReferenceCommonModelBuilder( + public PlanReferenceCommonModelBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory, JsonHandlingService jsonHandlingService) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceCommonModelBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanReferenceCommonModelBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; this.jsonHandlingService = jsonHandlingService; } - public DmpReferenceCommonModelBuilder authorize(EnumSet values) { + public PlanReferenceCommonModelBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List data) throws MyApplicationException { this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return new ArrayList<>(); Map referenceModelMap = this.collectReferences(data); - List> models = new ArrayList<>(); - for (DmpReferenceEntity d : data) { + List> models = new ArrayList<>(); + for (PlanReferenceEntity d : data) { DmpReferenceModel m = new DmpReferenceModel(); m.setId(d.getId()); if (d.getData() != null){ - DmpReferenceDataEntity definition = this.jsonHandlingService.fromJsonSafe(DmpReferenceDataEntity.class, d.getData()); - m.setData(this.builderFactory.builder(DmpReferenceDataCommonModelBuilder.class).authorize(this.authorize).build(definition)); + PlanReferenceDataEntity definition = this.jsonHandlingService.fromJsonSafe(PlanReferenceDataEntity.class, d.getData()); + m.setData(this.builderFactory.builder(PlanReferenceDataCommonModelBuilder.class).authorize(this.authorize).build(definition)); } if (referenceModelMap != null && d.getReferenceId() != null && referenceModelMap.containsKey(d.getReferenceId())) m.setReference(referenceModelMap.get(d.getReferenceId())); @@ -72,13 +72,13 @@ public class DmpReferenceCommonModelBuilder extends BaseCommonModelBuilder collectReferences(List data) throws MyApplicationException { + private Map collectReferences(List data) throws MyApplicationException { if (data.isEmpty()) return null; this.logger.debug("checking related - {}", ReferenceModel.class.getSimpleName()); Map itemMap; - ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).disableTracking().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(PlanReferenceEntity::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/dmpreference/DmpReferenceDataCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceDataCommonModelBuilder.java similarity index 74% rename from backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpreference/DmpReferenceDataCommonModelBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceDataCommonModelBuilder.java index 322647251..746572554 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpreference/DmpReferenceDataCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/planreference/PlanReferenceDataCommonModelBuilder.java @@ -1,8 +1,8 @@ -package org.opencdmp.model.builder.commonmodels.dmpreference; +package org.opencdmp.model.builder.commonmodels.planreference; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceDataModel; -import org.opencdmp.commons.types.dmpreference.DmpReferenceDataEntity; +import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; @@ -22,30 +22,30 @@ import java.util.Optional; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpReferenceDataCommonModelBuilder extends BaseCommonModelBuilder { +public class PlanReferenceDataCommonModelBuilder extends BaseCommonModelBuilder { private final BuilderFactory builderFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpReferenceDataCommonModelBuilder( + public PlanReferenceDataCommonModelBuilder( ConventionService conventionService, BuilderFactory builderFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceDataCommonModelBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanReferenceDataCommonModelBuilder.class))); this.builderFactory = builderFactory; } - public DmpReferenceDataCommonModelBuilder authorize(EnumSet values) { + public PlanReferenceDataCommonModelBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - protected List> buildInternal(List data) throws MyApplicationException { + protected List> buildInternal(List data) throws MyApplicationException { this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return new ArrayList<>(); - List> models = new ArrayList<>(); - for (DmpReferenceDataEntity d : data) { + List> models = new ArrayList<>(); + for (PlanReferenceDataEntity d : data) { DmpReferenceDataModel m = new DmpReferenceDataModel(); m.setBlueprintFieldId(d.getBlueprintFieldId()); models.add(new CommonModelBuilderItemResponse<>(m, d)); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java index c2d964b4b..01bfb85d6 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java @@ -20,18 +20,18 @@ import org.opencdmp.convention.ConventionService; import org.opencdmp.data.DescriptionEntity; import org.opencdmp.data.DescriptionTemplateEntity; import org.opencdmp.model.DescriptionTag; -import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.model.PlanDescriptionTemplate; import org.opencdmp.model.builder.BaseBuilder; import org.opencdmp.model.builder.DescriptionTagBuilder; -import org.opencdmp.model.builder.DmpDescriptionTemplateBuilder; +import org.opencdmp.model.builder.PlanDescriptionTemplateBuilder; import org.opencdmp.model.builder.UserBuilder; import org.opencdmp.model.builder.descriptionreference.DescriptionReferenceBuilder; import org.opencdmp.model.builder.descriptiontemplate.DescriptionTemplateBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; import org.opencdmp.model.description.Description; import org.opencdmp.model.descriptionreference.DescriptionReference; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.user.User; import org.opencdmp.query.*; import org.slf4j.LoggerFactory; @@ -85,11 +85,11 @@ public class DescriptionBuilder extends BaseBuilder(); - FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._dmpDescriptionTemplate)); - Map dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data); + FieldSet planDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._planDescriptionTemplate)); + Map planDescriptionTemplateItemsMap = this.collectPlanDescriptionTemplates(planDescriptionTemplateFields, data); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(Description._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(Description._plan)); + Map planItemsMap = this.collectPlans(planFields, data); FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._descriptionTemplate)); Map descriptionTemplateItemsMap = this.collectDescriptionTemplates(descriptionTemplateFields, data); @@ -123,8 +123,8 @@ public class DescriptionBuilder extends BaseBuilder collectDmpDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlanDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", DmpDescriptionTemplate.class.getSimpleName()); + this.logger.debug("checking related - {}", PlanDescriptionTemplate.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(DmpDescriptionTemplate._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(PlanDescriptionTemplate._id))) { itemMap = this.asEmpty( - data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList()), + data.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().collect(Collectors.toList()), x -> { - DmpDescriptionTemplate item = new DmpDescriptionTemplate(); + PlanDescriptionTemplate item = new PlanDescriptionTemplate(); item.setId(x); return item; }, - DmpDescriptionTemplate::getId); + PlanDescriptionTemplate::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DmpDescriptionTemplate._id); - DmpDescriptionTemplateQuery q = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(DmpDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DmpDescriptionTemplate::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PlanDescriptionTemplate._id); + PlanDescriptionTemplateQuery q = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PlanDescriptionTemplate::getId); } - if (!fields.hasField(DmpDescriptionTemplate._id)) { + if (!fields.hasField(PlanDescriptionTemplate._id)) { itemMap.forEach((id, item) -> { if (item != null) item.setId(null); @@ -248,27 +248,27 @@ public class DescriptionBuilder extends BaseBuilder collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); + this.logger.debug("checking related - {}", Plan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(Dmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(Plan._id))) { itemMap = this.asEmpty( - data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()), + data.stream().map(DescriptionEntity::getPlanId).distinct().collect(Collectors.toList()), x -> { - Dmp item = new Dmp(); + Plan item = new Plan(); item.setId(x); return item; }, - Dmp::getId); + Plan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); - 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(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Plan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(DescriptionEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Plan::getId); } - if (!fields.hasField(Dmp._id)) { + if (!fields.hasField(Plan._id)) { itemMap.forEach((id, item) -> { if (item != null) item.setId(null); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/DescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/DescriptionTemplateBuilder.java index 316e834b8..b95feedee 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/DescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/DescriptionTemplateBuilder.java @@ -22,7 +22,7 @@ import org.opencdmp.model.builder.BaseBuilder; import org.opencdmp.model.builder.DescriptionTemplateTypeBuilder; import org.opencdmp.model.builder.UserDescriptionTemplateBuilder; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.query.DescriptionTemplateTypeQuery; import org.opencdmp.query.UserDescriptionTemplateQuery; import org.slf4j.LoggerFactory; @@ -79,7 +79,7 @@ public class DescriptionTemplateBuilder extends BaseBuilder> usersMap = this.collectUserDescriptionTemplates(usersFields, data); - Set authorizationFlags = this.extractAuthorizationFlags(fields, Dmp._authorizationFlags, this.authorizationContentResolver.getPermissionNames()); + Set authorizationFlags = this.extractAuthorizationFlags(fields, Plan._authorizationFlags, this.authorizationContentResolver.getPermissionNames()); Map affiliatedResourceMap = authorizationFlags == null || authorizationFlags.isEmpty() ? null : this.authorizationContentResolver.descriptionTemplateAffiliation(data.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList())); FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(DescriptionTemplate._definition)); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBuilder.java deleted file mode 100644 index a8149da5a..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBuilder.java +++ /dev/null @@ -1,344 +0,0 @@ -package org.opencdmp.model.builder.dmp; - -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.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.AffiliatedResource; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver; -import org.opencdmp.commons.JsonHandlingService; -import org.opencdmp.commons.XmlHandlingService; -import org.opencdmp.commons.enums.EntityType; -import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.commons.types.dmp.DmpPropertiesEntity; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpBlueprintEntity; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.model.DmpDescriptionTemplate; -import org.opencdmp.model.DmpUser; -import org.opencdmp.model.EntityDoi; -import org.opencdmp.model.builder.*; -import org.opencdmp.model.builder.description.DescriptionBuilder; -import org.opencdmp.model.builder.dmpblueprint.DmpBlueprintBuilder; -import org.opencdmp.model.builder.dmpreference.DmpReferenceBuilder; -import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.model.dmpreference.DmpReference; -import org.opencdmp.model.user.User; -import org.opencdmp.query.*; -import org.slf4j.LoggerFactory; -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; - -import java.util.*; -import java.util.stream.Collectors; - -@Component -@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBuilder extends BaseBuilder { - - private final QueryFactory queryFactory; - - private final BuilderFactory builderFactory; - private final JsonHandlingService jsonHandlingService; - private final XmlHandlingService xmlHandlingService; - private final AuthorizationService authorizationService; - private final AuthorizationContentResolver authorizationContentResolver; - private final TenantScope tenantScope; - - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - - @Autowired - public DmpBuilder(ConventionService conventionService, - QueryFactory queryFactory, - BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBuilder.class))); - this.queryFactory = queryFactory; - this.builderFactory = builderFactory; - this.jsonHandlingService = jsonHandlingService; - this.xmlHandlingService = xmlHandlingService; - this.authorizationService = authorizationService; - this.authorizationContentResolver = authorizationContentResolver; - this.tenantScope = tenantScope; - } - - public DmpBuilder authorize(EnumSet values) { - this.authorize = values; - return this; - } - - @Override - public List build(FieldSet fields, List data) throws MyApplicationException { - this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); - this.logger.trace(new DataLogEntry("requested fields", fields)); - if (fields == null || data == null || fields.isEmpty()) - return new ArrayList<>(); - - List models = new ArrayList<>(); - - FieldSet entityDoisFields = fields.extractPrefixed(this.asPrefix(Dmp._entityDois)); - Map> entityDoisMap = this.collectEntityDois(entityDoisFields, data); - - FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpReferences)); - Map> dmpReferencesMap = this.collectDmpReferences(dmpReferencesFields, data); - - FieldSet dmpUsersFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpUsers)); - Map> dmpUsersMap = this.collectDmpUsers(dmpUsersFields, data); - - FieldSet userFields = fields.extractPrefixed(this.asPrefix(Dmp._creator)); - Map userItemsMap = this.collectUsers(userFields, data); - - FieldSet blueprintFields = fields.extractPrefixed(this.asPrefix(Dmp._blueprint)); - Map blueprintItemsMap = this.collectDmpBlueprints(blueprintFields, data); - - FieldSet descriptionsFields = fields.extractPrefixed(this.asPrefix(Dmp._descriptions)); - Map> descriptionsMap = this.collectDmpDescriptions(descriptionsFields, data); - - FieldSet dmpDescriptionTemplatesFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpDescriptionTemplates)); - Map> dmpDescriptionTemplatesMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplatesFields, data); - - FieldSet otherDmpVersionsFields = fields.extractPrefixed(this.asPrefix(Dmp._otherDmpVersions)); - Map> otherDmpVersionsMap = this.collectOtherDmpVersions(otherDmpVersionsFields, data); - - FieldSet dmpPropertiesFields = fields.extractPrefixed(this.asPrefix(Dmp._properties)); - Map definitionEntityMap = !dmpPropertiesFields.isEmpty() ? this.collectDmpBlueprintDefinitions(data) : null; - - Set authorizationFlags = this.extractAuthorizationFlags(fields, Dmp._authorizationFlags, this.authorizationContentResolver.getPermissionNames()); - Map affiliatedResourceMap = authorizationFlags == null || authorizationFlags.isEmpty() ? null : this.authorizationContentResolver.dmpsAffiliation(data.stream().map(DmpEntity::getId).collect(Collectors.toList())); - - for (DmpEntity d : data) { - Dmp m = new Dmp(); - if (fields.hasField(this.asIndexer(Dmp._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(Dmp._label))) m.setLabel(d.getLabel()); - if (fields.hasField(this.asIndexer(Dmp._version))) m.setVersion(d.getVersion()); - if (fields.hasField(this.asIndexer(Dmp._status))) m.setStatus(d.getStatus()); - if (fields.hasField(this.asIndexer(Dmp._groupId))) m.setGroupId(d.getGroupId()); - if (fields.hasField(this.asIndexer(Dmp._description))) m.setDescription(d.getDescription()); - if (fields.hasField(this.asIndexer(Dmp._createdAt))) m.setCreatedAt(d.getCreatedAt()); - if (fields.hasField(this.asIndexer(Dmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if (fields.hasField(this.asIndexer(Dmp._isActive))) m.setIsActive(d.getIsActive()); - if (fields.hasField(this.asIndexer(Dmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt()); - if (fields.hasField(this.asIndexer(Dmp._accessType))) m.setAccessType(d.getAccessType()); - if (fields.hasField(this.asIndexer(Dmp._language))) m.setLanguage(d.getLanguage()); - if (fields.hasField(this.asIndexer(Dmp._versionStatus))) m.setVersionStatus(d.getVersionStatus()); - if (fields.hasField(this.asIndexer(Dmp._publicAfter))) m.setPublicAfter(d.getPublicAfter()); - if (fields.hasField(this.asIndexer(Dmp._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); - if (fields.hasField(this.asIndexer(Dmp._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); - if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatorId())) m.setCreator(userItemsMap.get(d.getCreatorId())); - if (!blueprintFields.isEmpty() && blueprintItemsMap != null && blueprintItemsMap.containsKey(d.getBlueprintId())) m.setBlueprint(blueprintItemsMap.get(d.getBlueprintId())); - if (entityDoisMap != null && !entityDoisMap.isEmpty() && entityDoisMap.containsKey(d.getId())) m.setEntityDois(entityDoisMap.get(d.getId())); - if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId())); - if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId())); - if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId())); - if (dmpDescriptionTemplatesMap != null && !dmpDescriptionTemplatesMap.isEmpty() && dmpDescriptionTemplatesMap.containsKey(d.getId())) m.setDmpDescriptionTemplates(dmpDescriptionTemplatesMap.get(d.getId())); - if (otherDmpVersionsMap != null && !otherDmpVersionsMap.isEmpty() && otherDmpVersionsMap.containsKey(d.getGroupId())) { - m.setOtherDmpVersions(otherDmpVersionsMap.get(d.getGroupId())); - m.getOtherDmpVersions().sort(Comparator.comparing(Dmp::getVersion)); - } - if (!dmpPropertiesFields.isEmpty() && d.getProperties() != null){ - DmpPropertiesEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(DmpPropertiesEntity.class, d.getProperties()); - m.setProperties(this.builderFactory.builder(DmpPropertiesBuilder.class).withDefinition(definitionEntityMap != null ? definitionEntityMap.getOrDefault(d.getBlueprintId(), null) : null).authorize(this.authorize).build(dmpPropertiesFields, propertyDefinition)); - } - if (affiliatedResourceMap != null && !authorizationFlags.isEmpty()) m.setAuthorizationFlags(this.evaluateAuthorizationFlags(this.authorizationService, authorizationFlags, affiliatedResourceMap.getOrDefault(d.getId(), null))); - models.add(m); - } - this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); - - return models; - } - - private Map> collectDmpReferences(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, DmpReference._id)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { - x.getDmp().setId(null); - }); - } - - return itemMap; - } - - private Map> collectEntityDois(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", EntityDoi.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(EntityDoi._entityId)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).forEach(x -> { - x.setEntityId(null); - }); - } - - return itemMap; - } - - private Map collectDmpBlueprints(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) - return null; - this.logger.debug("checking related - {}", DmpBlueprint.class.getSimpleName()); - - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(DmpBlueprint._id))) { - itemMap = this.asEmpty( - data.stream().map(DmpEntity::getBlueprintId).distinct().collect(Collectors.toList()), - x -> { - DmpBlueprint item = new DmpBlueprint(); - item.setId(x); - return item; - }, - DmpBlueprint::getId); - } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DmpBlueprint._id); - 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)) { - itemMap.forEach((id, item) -> { - if (item != null) - item.setId(null); - }); - } - - return itemMap; - } - - private Map collectDmpBlueprintDefinitions(List data) throws MyApplicationException { - if (data.isEmpty()) - return null; - this.logger.debug("checking related - {}", DefinitionEntity.class.getSimpleName()); - - Map itemMap = new HashMap<>(); - DmpBlueprintQuery q = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DmpEntity::getBlueprintId).distinct().collect(Collectors.toList())); - List items = q.collectAs(new BaseFieldSet().ensure(DmpBlueprint._id).ensure(DmpBlueprint._definition)); - for (DmpBlueprintEntity item : items){ - DefinitionEntity definition =this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, item.getDefinition()); - itemMap.put(item.getId(), definition); - } - - return itemMap; - } - - private Map collectUsers(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) - return null; - this.logger.debug("checking related - {}", User.class.getSimpleName()); - - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(User._id))) { - itemMap = this.asEmpty( - data.stream().map(DmpEntity::getCreatorId).distinct().collect(Collectors.toList()), - x -> { - User item = new User(); - item.setId(x); - return item; - }, - User::getId); - } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); - 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)) { - itemMap.forEach((id, item) -> { - if (item != null) - item.setId(null); - }); - } - - return itemMap; - } - - private Map> collectDmpUsers(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) - return null; - this.logger.debug("checking related - {}", DmpUser.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpUser._dmp, DmpUser._id)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { - x.getDmp().setId(null); - }); - } - - return itemMap; - } - - private Map> collectDmpDescriptions(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", Description.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Description._id)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { - x.getDmp().setId(null); - }); - } - - return itemMap; - } - - private Map> collectDmpDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", Description.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpDescriptionTemplate._dmp, DmpDescriptionTemplate._id)); - 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))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { - x.getDmp().setId(null); - }); - } - - return itemMap; - } - - private Map> collectOtherDmpVersions(FieldSet fields, List data) throws MyApplicationException { - if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); - - Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); - DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(this.authorize).groupIds(data.stream().map(DmpEntity::getGroupId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asMasterKey(query, clone, Dmp::getGroupId); - - if (!fields.hasField(Dmp._id)) { - itemMap.values().stream().flatMap(List::stream).filter(Objects::nonNull).forEach(x -> { - x.setId(null); - }); - } - - return itemMap; - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBlueprintValueBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanBlueprintValueBuilder.java similarity index 55% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBlueprintValueBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanBlueprintValueBuilder.java index 846ebda78..a9ae2917f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBlueprintValueBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanBlueprintValueBuilder.java @@ -1,19 +1,19 @@ -package org.opencdmp.model.builder.dmp; +package org.opencdmp.model.builder.plan; import gr.cite.tools.exception.MyApplicationException; 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.enums.DmpBlueprintExtraFieldDataType; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; -import org.opencdmp.commons.types.dmp.DmpBlueprintValueEntity; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; -import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.FieldEntity; +import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; +import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity; +import org.opencdmp.commons.types.planblueprint.FieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.dmp.DmpBlueprintValue; +import org.opencdmp.model.plan.PlanBlueprintValue; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -22,52 +22,52 @@ import org.springframework.stereotype.Component; import java.util.*; -@Component("descriptionpropertiesdefinitionDmpBlueprintValuebuilder") +@Component("planblueprintvaluebuilder") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBlueprintValueBuilder extends BaseBuilder { +public class PlanBlueprintValueBuilder extends BaseBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private DefinitionEntity definition; @Autowired - public DmpBlueprintValueBuilder( + public PlanBlueprintValueBuilder( ConventionService conventionService) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintValueBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanBlueprintValueBuilder.class))); } - public DmpBlueprintValueBuilder authorize(EnumSet values) { + public PlanBlueprintValueBuilder authorize(EnumSet values) { this.authorize = values; return this; } - public DmpBlueprintValueBuilder withDefinition(DefinitionEntity definition) { + public PlanBlueprintValueBuilder withDefinition(DefinitionEntity definition) { this.definition = definition; return this; } @Override - public List build(FieldSet DmpBlueprintValues, List data) throws MyApplicationException { + public List build(FieldSet DmpBlueprintValues, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} DmpBlueprintValues", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(DmpBlueprintValues).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested DmpBlueprintValues", DmpBlueprintValues)); if (DmpBlueprintValues == null || data == null || DmpBlueprintValues.isEmpty()) return new ArrayList<>(); - List models = new ArrayList<>(); - for (DmpBlueprintValueEntity d : data) { + List models = new ArrayList<>(); + for (PlanBlueprintValueEntity d : data) { FieldEntity fieldEntity = this.definition != null ? this.definition.getFieldById(d.getFieldId()).stream().findFirst().orElse(null) : null; - if (fieldEntity != null && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)) { + if (fieldEntity != null && fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)) { ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity; - DmpBlueprintValue m = new DmpBlueprintValue(); - if (DmpBlueprintValues.hasField(this.asIndexer(DmpBlueprintValue._fieldId))) m.setFieldId(d.getFieldId()); - if (extraFieldEntity != null && DmpBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){ - if (DmpBlueprintValues.hasField(this.asIndexer(DmpBlueprintValue._dateValue))) m.setDateValue(d.getDateValue()); - } else if (extraFieldEntity != null && DmpBlueprintExtraFieldDataType.isNumberType(extraFieldEntity.getType())){ - if (DmpBlueprintValues.hasField(this.asIndexer(DmpBlueprintValue._numberValue))) m.setNumberValue(d.getNumberValue()); + PlanBlueprintValue m = new PlanBlueprintValue(); + if (DmpBlueprintValues.hasField(this.asIndexer(PlanBlueprintValue._fieldId))) m.setFieldId(d.getFieldId()); + if (extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){ + if (DmpBlueprintValues.hasField(this.asIndexer(PlanBlueprintValue._dateValue))) m.setDateValue(d.getDateValue()); + } else if (extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isNumberType(extraFieldEntity.getType())){ + if (DmpBlueprintValues.hasField(this.asIndexer(PlanBlueprintValue._numberValue))) m.setNumberValue(d.getNumberValue()); } else { - if (DmpBlueprintValues.hasField(this.asIndexer(DmpBlueprintValue._fieldValue))) m.setFieldValue(d.getValue()); + if (DmpBlueprintValues.hasField(this.asIndexer(PlanBlueprintValue._fieldValue))) m.setFieldValue(d.getValue()); } models.add(m); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanBuilder.java new file mode 100644 index 000000000..0302ceeff --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanBuilder.java @@ -0,0 +1,344 @@ +package org.opencdmp.model.builder.plan; + +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.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.AffiliatedResource; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver; +import org.opencdmp.commons.JsonHandlingService; +import org.opencdmp.commons.XmlHandlingService; +import org.opencdmp.commons.enums.EntityType; +import org.opencdmp.commons.scope.tenant.TenantScope; +import org.opencdmp.commons.types.plan.PlanPropertiesEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.PlanBlueprintEntity; +import org.opencdmp.data.PlanEntity; +import org.opencdmp.model.PlanDescriptionTemplate; +import org.opencdmp.model.PlanUser; +import org.opencdmp.model.EntityDoi; +import org.opencdmp.model.builder.*; +import org.opencdmp.model.builder.description.DescriptionBuilder; +import org.opencdmp.model.builder.planblueprint.PlanBlueprintBuilder; +import org.opencdmp.model.builder.planreference.PlanReferenceBuilder; +import org.opencdmp.model.description.Description; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.planblueprint.PlanBlueprint; +import org.opencdmp.model.planreference.PlanReference; +import org.opencdmp.model.user.User; +import org.opencdmp.query.*; +import org.slf4j.LoggerFactory; +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; + +import java.util.*; +import java.util.stream.Collectors; + +@Component +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class PlanBuilder extends BaseBuilder { + + private final QueryFactory queryFactory; + + private final BuilderFactory builderFactory; + private final JsonHandlingService jsonHandlingService; + private final XmlHandlingService xmlHandlingService; + private final AuthorizationService authorizationService; + private final AuthorizationContentResolver authorizationContentResolver; + private final TenantScope tenantScope; + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public PlanBuilder(ConventionService conventionService, + QueryFactory queryFactory, + BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanBuilder.class))); + this.queryFactory = queryFactory; + this.builderFactory = builderFactory; + this.jsonHandlingService = jsonHandlingService; + this.xmlHandlingService = xmlHandlingService; + this.authorizationService = authorizationService; + this.authorizationContentResolver = authorizationContentResolver; + this.tenantScope = tenantScope; + } + + public PlanBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + List models = new ArrayList<>(); + + FieldSet entityDoisFields = fields.extractPrefixed(this.asPrefix(Plan._entityDois)); + Map> entityDoisMap = this.collectEntityDois(entityDoisFields, data); + + FieldSet plamReferencesFields = fields.extractPrefixed(this.asPrefix(Plan._planReferences)); + Map> planReferencesMap = this.collectPlanReferences(plamReferencesFields, data); + + FieldSet planUsersFields = fields.extractPrefixed(this.asPrefix(Plan._planUsers)); + Map> planUsersMap = this.collectPlanUsers(planUsersFields, data); + + FieldSet userFields = fields.extractPrefixed(this.asPrefix(Plan._creator)); + Map userItemsMap = this.collectUsers(userFields, data); + + FieldSet blueprintFields = fields.extractPrefixed(this.asPrefix(Plan._blueprint)); + Map blueprintItemsMap = this.collectPlanBlueprints(blueprintFields, data); + + FieldSet descriptionsFields = fields.extractPrefixed(this.asPrefix(Plan._descriptions)); + Map> descriptionsMap = this.collectPlanDescriptions(descriptionsFields, data); + + FieldSet planDescriptionTemplatesFields = fields.extractPrefixed(this.asPrefix(Plan._planDescriptionTemplates)); + Map> planDescriptionTemplatesMap = this.collectPlanDescriptionTemplates(planDescriptionTemplatesFields, data); + + FieldSet otherPlanVersionsFields = fields.extractPrefixed(this.asPrefix(Plan._otherPlanVersions)); + Map> otherPlanVersionsMap = this.collectOtherPlanVersions(otherPlanVersionsFields, data); + + FieldSet planPropertiesFields = fields.extractPrefixed(this.asPrefix(Plan._properties)); + Map definitionEntityMap = !planPropertiesFields.isEmpty() ? this.collectPlanBlueprintDefinitions(data) : null; + + Set authorizationFlags = this.extractAuthorizationFlags(fields, Plan._authorizationFlags, this.authorizationContentResolver.getPermissionNames()); + Map affiliatedResourceMap = authorizationFlags == null || authorizationFlags.isEmpty() ? null : this.authorizationContentResolver.dmpsAffiliation(data.stream().map(PlanEntity::getId).collect(Collectors.toList())); + + for (PlanEntity d : data) { + Plan m = new Plan(); + if (fields.hasField(this.asIndexer(Plan._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(Plan._label))) m.setLabel(d.getLabel()); + if (fields.hasField(this.asIndexer(Plan._version))) m.setVersion(d.getVersion()); + if (fields.hasField(this.asIndexer(Plan._status))) m.setStatus(d.getStatus()); + if (fields.hasField(this.asIndexer(Plan._groupId))) m.setGroupId(d.getGroupId()); + if (fields.hasField(this.asIndexer(Plan._description))) m.setDescription(d.getDescription()); + if (fields.hasField(this.asIndexer(Plan._createdAt))) m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(Plan._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(Plan._isActive))) m.setIsActive(d.getIsActive()); + if (fields.hasField(this.asIndexer(Plan._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt()); + if (fields.hasField(this.asIndexer(Plan._accessType))) m.setAccessType(d.getAccessType()); + if (fields.hasField(this.asIndexer(Plan._language))) m.setLanguage(d.getLanguage()); + if (fields.hasField(this.asIndexer(Plan._versionStatus))) m.setVersionStatus(d.getVersionStatus()); + if (fields.hasField(this.asIndexer(Plan._publicAfter))) m.setPublicAfter(d.getPublicAfter()); + if (fields.hasField(this.asIndexer(Plan._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); + if (fields.hasField(this.asIndexer(Plan._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); + if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatorId())) m.setCreator(userItemsMap.get(d.getCreatorId())); + if (!blueprintFields.isEmpty() && blueprintItemsMap != null && blueprintItemsMap.containsKey(d.getBlueprintId())) m.setBlueprint(blueprintItemsMap.get(d.getBlueprintId())); + if (entityDoisMap != null && !entityDoisMap.isEmpty() && entityDoisMap.containsKey(d.getId())) m.setEntityDois(entityDoisMap.get(d.getId())); + if (planReferencesMap != null && !planReferencesMap.isEmpty() && planReferencesMap.containsKey(d.getId())) m.setPlanReferences(planReferencesMap.get(d.getId())); + if (planUsersMap != null && !planUsersMap.isEmpty() && planUsersMap.containsKey(d.getId())) m.setPlanUsers(planUsersMap.get(d.getId())); + if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId())); + if (planDescriptionTemplatesMap != null && !planDescriptionTemplatesMap.isEmpty() && planDescriptionTemplatesMap.containsKey(d.getId())) m.setPlanDescriptionTemplates(planDescriptionTemplatesMap.get(d.getId())); + if (otherPlanVersionsMap != null && !otherPlanVersionsMap.isEmpty() && otherPlanVersionsMap.containsKey(d.getGroupId())) { + m.setOtherPlanVersions(otherPlanVersionsMap.get(d.getGroupId())); + m.getOtherPlanVersions().sort(Comparator.comparing(Plan::getVersion)); + } + if (!planPropertiesFields.isEmpty() && d.getProperties() != null){ + PlanPropertiesEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PlanPropertiesEntity.class, d.getProperties()); + m.setProperties(this.builderFactory.builder(PlanPropertiesBuilder.class).withDefinition(definitionEntityMap != null ? definitionEntityMap.getOrDefault(d.getBlueprintId(), null) : null).authorize(this.authorize).build(planPropertiesFields, propertyDefinition)); + } + if (affiliatedResourceMap != null && !authorizationFlags.isEmpty()) m.setAuthorizationFlags(this.evaluateAuthorizationFlags(this.authorizationService, authorizationFlags, affiliatedResourceMap.getOrDefault(d.getId(), null))); + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + + return models; + } + + private Map> collectPlanReferences(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", PlanReference.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PlanReference._plan, PlanReference._id)); + PlanReferenceQuery query = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getPlan().getId()); + + if (!fields.hasField(this.asIndexer(PlanReference._plan, Plan._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getPlan() != null).forEach(x -> { + x.getPlan().setId(null); + }); + } + + return itemMap; + } + + private Map> collectEntityDois(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", EntityDoi.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(EntityDoi._entityId)); + EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(this.authorize).types(EntityType.DMP).entityIds(data.stream().map(PlanEntity::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))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).forEach(x -> { + x.setEntityId(null); + }); + } + + return itemMap; + } + + private Map collectPlanBlueprints(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) + return null; + this.logger.debug("checking related - {}", PlanBlueprint.class.getSimpleName()); + + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(PlanBlueprint._id))) { + itemMap = this.asEmpty( + data.stream().map(PlanEntity::getBlueprintId).distinct().collect(Collectors.toList()), + x -> { + PlanBlueprint item = new PlanBlueprint(); + item.setId(x); + return item; + }, + PlanBlueprint::getId); + } else { + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PlanBlueprint._id); + PlanBlueprintQuery q = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanEntity::getBlueprintId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanBlueprintBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PlanBlueprint::getId); + } + if (!fields.hasField(PlanBlueprint._id)) { + itemMap.forEach((id, item) -> { + if (item != null) + item.setId(null); + }); + } + + return itemMap; + } + + private Map collectPlanBlueprintDefinitions(List data) throws MyApplicationException { + if (data.isEmpty()) + return null; + this.logger.debug("checking related - {}", DefinitionEntity.class.getSimpleName()); + + Map itemMap = new HashMap<>(); + PlanBlueprintQuery q = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanEntity::getBlueprintId).distinct().collect(Collectors.toList())); + List items = q.collectAs(new BaseFieldSet().ensure(PlanBlueprint._id).ensure(PlanBlueprint._definition)); + for (PlanBlueprintEntity item : items){ + DefinitionEntity definition =this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, item.getDefinition()); + itemMap.put(item.getId(), definition); + } + + return itemMap; + } + + private Map collectUsers(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) + return null; + this.logger.debug("checking related - {}", User.class.getSimpleName()); + + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(User._id))) { + itemMap = this.asEmpty( + data.stream().map(PlanEntity::getCreatorId).distinct().collect(Collectors.toList()), + x -> { + User item = new User(); + item.setId(x); + return item; + }, + User::getId); + } else { + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); + UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanEntity::getCreatorId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); + } + if (!fields.hasField(User._id)) { + itemMap.forEach((id, item) -> { + if (item != null) + item.setId(null); + }); + } + + return itemMap; + } + + private Map> collectPlanUsers(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) + return null; + this.logger.debug("checking related - {}", PlanUser.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PlanUser._plan, PlanUser._id)); + PlanUserQuery query = this.queryFactory.query(PlanUserQuery.class).disableTracking().authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getPlan().getId()); + + if (!fields.hasField(this.asIndexer(PlanUser._plan, Plan._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getPlan() != null).forEach(x -> { + x.getPlan().setId(null); + }); + } + + return itemMap; + } + + private Map> collectPlanDescriptions(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", Description.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._plan, Description._id)); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getPlan().getId()); + + if (!fields.hasField(this.asIndexer(Description._plan, Plan._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getPlan() != null).forEach(x -> { + x.getPlan().setId(null); + }); + } + + return itemMap; + } + + private Map> collectPlanDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", Description.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PlanDescriptionTemplate._plan, PlanDescriptionTemplate._id)); + PlanDescriptionTemplateQuery query = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanDescriptionTemplateBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); + + if (!fields.hasField(this.asIndexer(PlanDescriptionTemplate._plan, Plan._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { + x.getDmp().setId(null); + }); + } + + return itemMap; + } + + private Map> collectOtherPlanVersions(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", Plan.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Plan._id); + PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(this.authorize).groupIds(data.stream().map(PlanEntity::getGroupId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanBuilder.class).authorize(this.authorize).asMasterKey(query, clone, Plan::getGroupId); + + if (!fields.hasField(Plan._id)) { + itemMap.values().stream().flatMap(List::stream).filter(Objects::nonNull).forEach(x -> { + x.setId(null); + }); + } + + return itemMap; + } + +} 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/plan/PlanContactBuilder.java similarity index 66% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpContactBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanContactBuilder.java index 53ff433f5..aa7d0d01f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpContactBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanContactBuilder.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.builder.dmp; +package org.opencdmp.model.builder.plan; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; @@ -7,10 +7,10 @@ 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.dmp.DmpContactEntity; +import org.opencdmp.commons.types.plan.PlanContactEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.dmp.DmpContact; +import org.opencdmp.model.plan.PlanContact; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -19,9 +19,9 @@ import org.springframework.stereotype.Component; import java.util.*; -@Component("dmpcontactbuilder") +@Component("plancontactbuilder") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpContactBuilder extends BaseBuilder { +public class PlanContactBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -29,20 +29,20 @@ public class DmpContactBuilder extends BaseBuilder private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpContactBuilder( + public PlanContactBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpContactBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanContactBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; } - public DmpContactBuilder authorize(EnumSet values) { + public PlanContactBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) @@ -50,12 +50,12 @@ public class DmpContactBuilder extends BaseBuilder //Not Bulk Build because is XML no interaction with db - List models = new ArrayList<>(); - for (DmpContactEntity d : data) { - DmpContact m = new DmpContact(); - if (fields.hasField(this.asIndexer(DmpContact._email))) m.setEmail(d.getEmail()); - if (fields.hasField(this.asIndexer(DmpContact._firstName))) m.setFirstName(d.getFirstName()); - if (fields.hasField(this.asIndexer(DmpContact._lastName))) m.setLastName(d.getLastName()); + List models = new ArrayList<>(); + for (PlanContactEntity d : data) { + PlanContact m = new PlanContact(); + if (fields.hasField(this.asIndexer(PlanContact._email))) m.setEmail(d.getEmail()); + if (fields.hasField(this.asIndexer(PlanContact._firstName))) m.setFirstName(d.getFirstName()); + if (fields.hasField(this.asIndexer(PlanContact._lastName))) m.setLastName(d.getLastName()); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpPropertiesBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanPropertiesBuilder.java similarity index 59% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpPropertiesBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanPropertiesBuilder.java index a36cebb01..1d5347405 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpPropertiesBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/plan/PlanPropertiesBuilder.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.builder.dmp; +package org.opencdmp.model.builder.plan; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; @@ -6,11 +6,11 @@ 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.dmp.DmpPropertiesEntity; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; +import org.opencdmp.commons.types.plan.PlanPropertiesEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.dmp.DmpProperties; +import org.opencdmp.model.plan.PlanProperties; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -19,47 +19,47 @@ import org.springframework.stereotype.Component; import java.util.*; -@Component("dmppropertiesbuilder") +@Component("planpropertiesbuilder") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpPropertiesBuilder extends BaseBuilder { +public class PlanPropertiesBuilder extends BaseBuilder { private final BuilderFactory builderFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private DefinitionEntity definition; @Autowired - public DmpPropertiesBuilder( + public PlanPropertiesBuilder( ConventionService conventionService, BuilderFactory builderFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpPropertiesBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanPropertiesBuilder.class))); this.builderFactory = builderFactory; } - public DmpPropertiesBuilder withDefinition(DefinitionEntity definition) { + public PlanPropertiesBuilder withDefinition(DefinitionEntity definition) { this.definition = definition; return this; } - public DmpPropertiesBuilder authorize(EnumSet values) { + public PlanPropertiesBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); //Not Bulk Build because is XML no interaction with db - FieldSet dmpBlueprintValuesFields = fields.extractPrefixed(this.asPrefix(DmpProperties._dmpBlueprintValues)); - FieldSet contactsFields = fields.extractPrefixed(this.asPrefix(DmpProperties._contacts)); + FieldSet dmpBlueprintValuesFields = fields.extractPrefixed(this.asPrefix(PlanProperties._planBlueprintValues)); + FieldSet contactsFields = fields.extractPrefixed(this.asPrefix(PlanProperties._contacts)); - List models = new ArrayList<>(); - for (DmpPropertiesEntity d : data) { - DmpProperties m = new DmpProperties(); - if (!dmpBlueprintValuesFields.isEmpty() && d.getDmpBlueprintValues() != null) m.setDmpBlueprintValues(this.builderFactory.builder(DmpBlueprintValueBuilder.class).withDefinition(definition).authorize(this.authorize).build(dmpBlueprintValuesFields, d.getDmpBlueprintValues())); - if (!contactsFields.isEmpty() && d.getContacts() != null) m.setContacts(this.builderFactory.builder(DmpContactBuilder.class).authorize(this.authorize).build(contactsFields, d.getContacts())); + List models = new ArrayList<>(); + for (PlanPropertiesEntity d : data) { + PlanProperties m = new PlanProperties(); + if (!dmpBlueprintValuesFields.isEmpty() && d.getPlanBlueprintValues() != null) m.setPlanBlueprintValues(this.builderFactory.builder(PlanBlueprintValueBuilder.class).withDefinition(definition).authorize(this.authorize).build(dmpBlueprintValuesFields, d.getPlanBlueprintValues())); + if (!contactsFields.isEmpty() && d.getContacts() != null) m.setContacts(this.builderFactory.builder(PlanContactBuilder.class).authorize(this.authorize).build(contactsFields, d.getContacts())); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DefinitionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/DefinitionBuilder.java similarity index 93% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DefinitionBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/DefinitionBuilder.java index 4f7fe9582..2d263ac45 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DefinitionBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/DefinitionBuilder.java @@ -1,10 +1,10 @@ -package org.opencdmp.model.builder.dmpblueprint; +package org.opencdmp.model.builder.planblueprint; import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.dmpblueprint.Definition; +import org.opencdmp.model.planblueprint.Definition; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/DescriptionTemplateBuilder.java similarity index 93% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DescriptionTemplateBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/DescriptionTemplateBuilder.java index 9fa377322..9440ccba0 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/DescriptionTemplateBuilder.java @@ -1,10 +1,10 @@ -package org.opencdmp.model.builder.dmpblueprint; +package org.opencdmp.model.builder.planblueprint; import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.types.dmpblueprint.DescriptionTemplateEntity; +import org.opencdmp.commons.types.planblueprint.DescriptionTemplateEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.dmpblueprint.DescriptionTemplate; +import org.opencdmp.model.planblueprint.DescriptionTemplate; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ExtraFieldBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/ExtraFieldBuilder.java similarity index 85% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ExtraFieldBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/ExtraFieldBuilder.java index 3d9eb8c3b..a02419fff 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ExtraFieldBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/ExtraFieldBuilder.java @@ -1,8 +1,8 @@ -package org.opencdmp.model.builder.dmpblueprint; +package org.opencdmp.model.builder.planblueprint; -import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity; +import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.dmpblueprint.ExtraField; +import org.opencdmp.model.planblueprint.ExtraField; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/FieldBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/FieldBuilder.java similarity index 94% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/FieldBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/FieldBuilder.java index c9a6e2556..a1ee27494 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/FieldBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/FieldBuilder.java @@ -1,10 +1,10 @@ -package org.opencdmp.model.builder.dmpblueprint; +package org.opencdmp.model.builder.planblueprint; import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.types.dmpblueprint.FieldEntity; +import org.opencdmp.commons.types.planblueprint.FieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.dmpblueprint.Field; +import org.opencdmp.model.planblueprint.Field; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DmpBlueprintBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/PlanBlueprintBuilder.java similarity index 64% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DmpBlueprintBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/PlanBlueprintBuilder.java index c5181f4f6..1085ed905 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/DmpBlueprintBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/PlanBlueprintBuilder.java @@ -1,13 +1,13 @@ -package org.opencdmp.model.builder.dmpblueprint; +package org.opencdmp.model.builder.planblueprint; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.data.PlanBlueprintEntity; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; +import org.opencdmp.model.planblueprint.PlanBlueprint; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; @@ -23,7 +23,7 @@ import java.util.*; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBlueprintBuilder extends BaseBuilder { +public class PlanBlueprintBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -33,52 +33,52 @@ public class DmpBlueprintBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpBlueprintBuilder( + public PlanBlueprintBuilder( ConventionService conventionService, BuilderFactory builderFactory, XmlHandlingService xmlHandlingService, TenantScope tenantScope) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanBlueprintBuilder.class))); this.builderFactory = builderFactory; this.xmlHandlingService = xmlHandlingService; this.tenantScope = tenantScope; } - public DmpBlueprintBuilder authorize(EnumSet values) { + public PlanBlueprintBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(DmpBlueprint._definition)); - List models = new ArrayList<>(); - for (DmpBlueprintEntity d : data) { - DmpBlueprint m = new DmpBlueprint(); - if (fields.hasField(this.asIndexer(DmpBlueprint._id))) + FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(PlanBlueprint._definition)); + List models = new ArrayList<>(); + for (PlanBlueprintEntity d : data) { + PlanBlueprint m = new PlanBlueprint(); + if (fields.hasField(this.asIndexer(PlanBlueprint._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(DmpBlueprint._label))) + if (fields.hasField(this.asIndexer(PlanBlueprint._label))) m.setLabel(d.getLabel()); - if (fields.hasField(this.asIndexer(DmpBlueprint._status))) + if (fields.hasField(this.asIndexer(PlanBlueprint._status))) m.setStatus(d.getStatus()); - if (fields.hasField(this.asIndexer(DmpBlueprint._groupId))) + if (fields.hasField(this.asIndexer(PlanBlueprint._groupId))) m.setGroupId(d.getGroupId()); - if (fields.hasField(this.asIndexer(DmpBlueprint._version))) + if (fields.hasField(this.asIndexer(PlanBlueprint._version))) m.setVersion(d.getVersion()); - if (fields.hasField(this.asIndexer(DmpBlueprint._versionStatus))) + if (fields.hasField(this.asIndexer(PlanBlueprint._versionStatus))) m.setVersionStatus(d.getVersionStatus()); - if (fields.hasField(this.asIndexer(DmpBlueprint._createdAt))) + if (fields.hasField(this.asIndexer(PlanBlueprint._createdAt))) m.setCreatedAt(d.getCreatedAt()); - if (fields.hasField(this.asIndexer(DmpBlueprint._updatedAt))) + if (fields.hasField(this.asIndexer(PlanBlueprint._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if (fields.hasField(this.asIndexer(DmpBlueprint._isActive))) + if (fields.hasField(this.asIndexer(PlanBlueprint._isActive))) m.setIsActive(d.getIsActive()); - if (fields.hasField(this.asIndexer(DmpBlueprint._hash))) + if (fields.hasField(this.asIndexer(PlanBlueprint._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); - if (fields.hasField(this.asIndexer(DmpBlueprint._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); + if (fields.hasField(this.asIndexer(PlanBlueprint._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); if (!definitionFields.isEmpty() && d.getDefinition() != null) { DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition()); m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition)); 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/planblueprint/ReferenceFieldBuilder.java similarity index 91% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ReferenceFieldBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/ReferenceFieldBuilder.java index 3703ced16..c75b426f2 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/ReferenceFieldBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/ReferenceFieldBuilder.java @@ -1,13 +1,13 @@ -package org.opencdmp.model.builder.dmpblueprint; +package org.opencdmp.model.builder.planblueprint; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; -import org.opencdmp.commons.types.dmpblueprint.ReferenceTypeFieldEntity; +import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.referencetype.ReferenceTypeBuilder; -import org.opencdmp.model.dmpblueprint.ReferenceTypeField; +import org.opencdmp.model.planblueprint.ReferenceTypeField; import org.opencdmp.query.ReferenceTypeQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/SectionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/SectionBuilder.java similarity index 85% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/SectionBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/SectionBuilder.java index b82b31a9b..c40c2568a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/SectionBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/SectionBuilder.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.builder.dmpblueprint; +package org.opencdmp.model.builder.planblueprint; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; @@ -7,16 +7,16 @@ 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.enums.DmpBlueprintFieldCategory; -import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.ReferenceTypeFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.SectionEntity; -import org.opencdmp.commons.types.dmpblueprint.SystemFieldEntity; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; +import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity; +import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity; +import org.opencdmp.commons.types.planblueprint.SectionEntity; +import org.opencdmp.commons.types.planblueprint.SystemFieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.PrefillingSourceEntity; import org.opencdmp.model.builder.BaseBuilder; import org.opencdmp.model.builder.prefillingsource.PrefillingSourceBuilder; -import org.opencdmp.model.dmpblueprint.Section; +import org.opencdmp.model.planblueprint.Section; import org.opencdmp.query.PrefillingSourceQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -70,11 +70,11 @@ public class SectionBuilder extends BaseBuilder { if (!descriptionTemplatesFields.isEmpty() && d.getDescriptionTemplates() != null) m.setDescriptionTemplates(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).build(descriptionTemplatesFields, d.getDescriptionTemplates())); if (!fieldsFields.isEmpty() && d.getFields() != null) { m.setFields(new ArrayList<>()); - List systemFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.System.equals(x.getCategory())).map(x-> (SystemFieldEntity)x).toList(); + List systemFieldEntities = d.getFields().stream().filter(x-> PlanBlueprintFieldCategory.System.equals(x.getCategory())).map(x-> (SystemFieldEntity)x).toList(); m.getFields().addAll(this.builderFactory.builder(SystemFieldBuilder.class).authorize(this.authorize).build(fieldsFields, systemFieldEntities)); - List extraFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldEntity)x).toList(); + List extraFieldEntities = d.getFields().stream().filter(x-> PlanBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldEntity)x).toList(); m.getFields().addAll(this.builderFactory.builder(ExtraFieldBuilder.class).authorize(this.authorize).build(fieldsFields, extraFieldEntities)); - List referenceFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldEntity)x).toList(); + List referenceFieldEntities = d.getFields().stream().filter(x-> PlanBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldEntity)x).toList(); m.getFields().addAll(this.builderFactory.builder(ReferenceFieldBuilder.class).authorize(this.authorize).build(fieldsFields, referenceFieldEntities)); } if (!prefillingSourcesFields.isEmpty() && d.getPrefillingSourcesIds() != null) { diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/SystemFieldBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/SystemFieldBuilder.java similarity index 85% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/SystemFieldBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/SystemFieldBuilder.java index 594a2275a..4b2754e24 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpblueprint/SystemFieldBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planblueprint/SystemFieldBuilder.java @@ -1,8 +1,8 @@ -package org.opencdmp.model.builder.dmpblueprint; +package org.opencdmp.model.builder.planblueprint; -import org.opencdmp.commons.types.dmpblueprint.SystemFieldEntity; +import org.opencdmp.commons.types.planblueprint.SystemFieldEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.dmpblueprint.SystemField; +import org.opencdmp.model.planblueprint.SystemField; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; 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/planreference/PlanReferenceBuilder.java similarity index 57% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planreference/PlanReferenceBuilder.java index 50694a364..5785f2f62 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planreference/PlanReferenceBuilder.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.builder.dmpreference; +package org.opencdmp.model.builder.planreference; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; @@ -10,16 +10,16 @@ import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.JsonHandlingService; import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.commons.types.dmpreference.DmpReferenceDataEntity; +import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpReferenceEntity; +import org.opencdmp.data.PlanReferenceEntity; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; import org.opencdmp.model.builder.reference.ReferenceBuilder; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.reference.Reference; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.opencdmp.query.ReferenceQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -32,7 +32,7 @@ import java.util.stream.Collectors; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpReferenceBuilder extends BaseBuilder { +public class PlanReferenceBuilder extends BaseBuilder { private final BuilderFactory builderFactory; @@ -43,49 +43,49 @@ public class DmpReferenceBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpReferenceBuilder( + public PlanReferenceBuilder( ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory, JsonHandlingService jsonHandlingService, TenantScope tenantScope) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanReferenceBuilder.class))); this.builderFactory = builderFactory; this.queryFactory = queryFactory; this.jsonHandlingService = jsonHandlingService; this.tenantScope = tenantScope; } - public DmpReferenceBuilder authorize(EnumSet values) { + public PlanReferenceBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(DmpReference._reference)); + FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(PlanReference._reference)); Map referenceItemsMap = this.collectReferences(referenceFields, data); - FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(DmpReference._dmp)); - Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet planFields = fields.extractPrefixed(this.asPrefix(PlanReference._plan)); + Map planItemsMap = this.collectPlans(planFields, data); - FieldSet dataFields = fields.extractPrefixed(this.asPrefix(DmpReference._data)); - List models = new ArrayList<>(); - for (DmpReferenceEntity d : data) { - DmpReference m = new DmpReference(); - if (fields.hasField(this.asIndexer(DmpReference._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(DmpReference._isActive))) m.setIsActive(d.getIsActive()); - if (fields.hasField(this.asIndexer(DmpReference._createdAt))) m.setCreatedAt(d.getCreatedAt()); - if (fields.hasField(this.asIndexer(DmpReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if (fields.hasField(this.asIndexer(DmpReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); - if (fields.hasField(this.asIndexer(DmpReference._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); + FieldSet dataFields = fields.extractPrefixed(this.asPrefix(PlanReference._data)); + List models = new ArrayList<>(); + for (PlanReferenceEntity d : data) { + PlanReference m = new PlanReference(); + if (fields.hasField(this.asIndexer(PlanReference._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(PlanReference._isActive))) m.setIsActive(d.getIsActive()); + if (fields.hasField(this.asIndexer(PlanReference._createdAt))) m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(PlanReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(PlanReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); + if (fields.hasField(this.asIndexer(PlanReference._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId())); - if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); + if (!planFields.isEmpty() && planItemsMap != null && planItemsMap.containsKey(d.getPlanId())) m.setPlan(planItemsMap.get(d.getPlanId())); if (!dataFields.isEmpty() && d.getData() != null){ - DmpReferenceDataEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(DmpReferenceDataEntity.class, d.getData()); - m.setData(this.builderFactory.builder(DmpReferenceDataBuilder.class).authorize(this.authorize).build(dataFields, propertyDefinition)); + PlanReferenceDataEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PlanReferenceDataEntity.class, d.getData()); + m.setData(this.builderFactory.builder(PlanReferenceDataBuilder.class).authorize(this.authorize).build(dataFields, propertyDefinition)); } models.add(m); } @@ -93,7 +93,7 @@ public class DmpReferenceBuilder extends BaseBuilder collectReferences(FieldSet fields, List data) throws MyApplicationException { + private Map collectReferences(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; this.logger.debug("checking related - {}", Reference.class.getSimpleName()); @@ -101,7 +101,7 @@ public class DmpReferenceBuilder extends BaseBuilder itemMap; if (!fields.hasOtherField(this.asIndexer(Reference._id))) { itemMap = this.asEmpty( - data.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()), + data.stream().map(PlanReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()), x -> { Reference item = new Reference(); item.setId(x); @@ -110,7 +110,7 @@ public class DmpReferenceBuilder extends BaseBuilder collectDmps(FieldSet fields, List data) throws MyApplicationException { + private Map collectPlans(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); + this.logger.debug("checking related - {}", Plan.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(Dmp._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(Plan._id))) { itemMap = this.asEmpty( - data.stream().map(DmpReferenceEntity::getDmpId).distinct().collect(Collectors.toList()), + data.stream().map(PlanReferenceEntity::getPlanId).distinct().collect(Collectors.toList()), x -> { - Dmp item = new Dmp(); + Plan item = new Plan(); item.setId(x); return item; }, - Dmp::getId); + Plan::getId); } else { - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); - DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(DmpReferenceEntity::getDmpId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Plan._id); + PlanQuery q = this.queryFactory.query(PlanQuery.class).authorize(this.authorize).disableTracking().ids(data.stream().map(PlanReferenceEntity::getPlanId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Plan::getId); } - if (!fields.hasField(Dmp._id)) { + if (!fields.hasField(Plan._id)) { itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceDataBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planreference/PlanReferenceDataBuilder.java similarity index 62% rename from backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceDataBuilder.java rename to backend/core/src/main/java/org/opencdmp/model/builder/planreference/PlanReferenceDataBuilder.java index 5e6e6a7e4..2490e62af 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceDataBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planreference/PlanReferenceDataBuilder.java @@ -1,11 +1,10 @@ -package org.opencdmp.model.builder.dmpreference; +package org.opencdmp.model.builder.planreference; import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.types.dmpreference.DmpReferenceDataEntity; +import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.builder.BaseBuilder; -import org.opencdmp.model.dmpreference.DmpReferenceData; -import gr.cite.tools.data.builder.BuilderFactory; +import org.opencdmp.model.planreference.PlanReferenceData; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; @@ -18,25 +17,25 @@ import org.springframework.stereotype.Component; import java.util.*; -@Component("referencedmpreferencedatabuilder") +@Component("referenceplanreferencedatabuilder") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpReferenceDataBuilder extends BaseBuilder { +public class PlanReferenceDataBuilder extends BaseBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DmpReferenceDataBuilder( + public PlanReferenceDataBuilder( ConventionService conventionService) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceDataBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanReferenceDataBuilder.class))); } - public DmpReferenceDataBuilder authorize(EnumSet values) { + public PlanReferenceDataBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) @@ -44,10 +43,10 @@ public class DmpReferenceDataBuilder extends BaseBuilder models = new ArrayList<>(); - for (DmpReferenceDataEntity d : data) { - DmpReferenceData m = new DmpReferenceData(); - if (fields.hasField(this.asIndexer(DmpReferenceData._blueprintFieldId))) m.setBlueprintFieldId(d.getBlueprintFieldId()); + List models = new ArrayList<>(); + for (PlanReferenceDataEntity d : data) { + PlanReferenceData m = new PlanReferenceData(); + if (fields.hasField(this.asIndexer(PlanReferenceData._blueprintFieldId))) m.setBlueprintFieldId(d.getBlueprintFieldId()); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); 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 e625be10d..fa705e4e8 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 @@ -15,13 +15,13 @@ import org.opencdmp.convention.ConventionService; import org.opencdmp.data.ReferenceEntity; import org.opencdmp.model.builder.BaseBuilder; import org.opencdmp.model.builder.UserBuilder; -import org.opencdmp.model.builder.dmpreference.DmpReferenceBuilder; +import org.opencdmp.model.builder.planreference.PlanReferenceBuilder; import org.opencdmp.model.builder.referencetype.ReferenceTypeBuilder; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.reference.Reference; import org.opencdmp.model.referencetype.ReferenceType; import org.opencdmp.model.user.User; -import org.opencdmp.query.DmpReferenceQuery; +import org.opencdmp.query.PlanReferenceQuery; import org.opencdmp.query.ReferenceTypeQuery; import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; @@ -69,8 +69,8 @@ public class ReferenceBuilder extends BaseBuilder { //ToDo FieldSet userInfoFields = fields.extractPrefixed(this.asPrefix(Reference._createdBy)); FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(Reference._definition)); - FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Reference._dmpReferences)); - Map> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data); + FieldSet planReferencesFields = fields.extractPrefixed(this.asPrefix(Reference._planReferences)); + Map> planReferenceMap = this.collectPlanReferences(planReferencesFields, data); FieldSet userFields = fields.extractPrefixed(this.asPrefix(Reference._createdBy)); Map userItemsMap = this.collectUsers(userFields, data); @@ -97,7 +97,7 @@ public class ReferenceBuilder extends BaseBuilder { if (fields.hasField(this.asIndexer(Reference._source))) m.setSource(d.getSource()); if (fields.hasField(this.asIndexer(Reference._sourceType))) m.setSourceType(d.getSourceType()); if (!typeFields.isEmpty() && typeItemsMap != null && typeItemsMap.containsKey(d.getTypeId())) m.setType(typeItemsMap.get(d.getTypeId())); - if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId())); + if (planReferenceMap != null && !planReferenceMap.isEmpty() && planReferenceMap.containsKey(d.getId())) m.setPlanReferences(planReferenceMap.get(d.getId())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatedById())) m.setCreatedBy(userItemsMap.get(d.getCreatedById())); if (fields.hasField(this.asIndexer(Reference._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope)); models.add(m); @@ -166,16 +166,16 @@ public class ReferenceBuilder extends BaseBuilder { return itemMap; } - private Map> collectDmpReferences(FieldSet fields, List data) throws MyApplicationException { + private Map> collectPlanReferences(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; - this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); + this.logger.debug("checking related - {}", PlanReference.class.getSimpleName()); - Map> itemMap = null; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._reference, Reference._id)); - 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()); + Map> itemMap = null; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PlanReference._reference, Reference._id)); + PlanReferenceQuery query = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().authorize(this.authorize).referenceIds(data.stream().map(ReferenceEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(PlanReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getReference().getId()); - if (!fields.hasField(this.asIndexer(DmpReference._reference, Reference._id))) { + if (!fields.hasField(this.asIndexer(PlanReference._reference, Reference._id))) { itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getReference() != null).map(x -> { x.getReference().setId(null); return x; diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/DmpAssociatedUserCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PlanAssociatedUserCensor.java similarity index 77% rename from backend/core/src/main/java/org/opencdmp/model/censorship/DmpAssociatedUserCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/PlanAssociatedUserCensor.java index bd341b0c2..f9d7c50b2 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/DmpAssociatedUserCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PlanAssociatedUserCensor.java @@ -17,14 +17,14 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpAssociatedUserCensor extends BaseCensor { +public class PlanAssociatedUserCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpAssociatedUserCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanAssociatedUserCensor.class)); protected final AuthorizationService authService; - public DmpAssociatedUserCensor(ConventionService conventionService, AuthorizationService authService) { + public PlanAssociatedUserCensor(ConventionService conventionService, AuthorizationService authService) { super(conventionService); this.authService = authService; } @@ -33,7 +33,7 @@ public class DmpAssociatedUserCensor extends BaseCensor { logger.debug(new DataLogEntry("censoring fields", fields)); if (fields == null || fields.isEmpty()) return; - this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseDmpAssociatedUser, Permission.DeferredAffiliation); + this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowsePlanAssociatedUser, Permission.DeferredAffiliation); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/DmpDescriptionTemplateCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PlanDescriptionTemplateCensor.java similarity index 67% rename from backend/core/src/main/java/org/opencdmp/model/censorship/DmpDescriptionTemplateCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/PlanDescriptionTemplateCensor.java index f10c9cbbf..2a4e19f98 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/DmpDescriptionTemplateCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PlanDescriptionTemplateCensor.java @@ -2,14 +2,14 @@ package org.opencdmp.model.censorship; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.model.PlanDescriptionTemplate; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; import org.opencdmp.model.censorship.descriptiontemplate.DescriptionTemplateCensor; -import org.opencdmp.model.censorship.dmp.DmpCensor; +import org.opencdmp.model.censorship.plan.PlanCensor; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -19,17 +19,17 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpDescriptionTemplateCensor extends BaseCensor{ +public class PlanDescriptionTemplateCensor extends BaseCensor{ - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDescriptionTemplateCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanDescriptionTemplateCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public DmpDescriptionTemplateCensor(ConventionService conventionService, - AuthorizationService authService, - CensorFactory censorFactory) { + public PlanDescriptionTemplateCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -41,11 +41,11 @@ public class DmpDescriptionTemplateCensor extends BaseCensor{ return; this.authService.authorizeForce(Permission.BrowseDescription, Permission.DeferredAffiliation); - FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._dmp)); - this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId); - FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._descriptionTemplates)); + FieldSet planFields = fields.extractPrefixed(this.asIndexerPrefix(PlanDescriptionTemplate._plan)); + this.censorFactory.censor(PlanCensor.class).censor(planFields, userId); + FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asIndexerPrefix(PlanDescriptionTemplate._descriptionTemplates)); this.censorFactory.censor(DescriptionTemplateCensor.class).censor(descriptionTemplatesFields, userId); - FieldSet currentDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._currentDescriptionTemplate)); + FieldSet currentDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PlanDescriptionTemplate._currentDescriptionTemplate)); this.censorFactory.censor(DescriptionTemplateCensor.class).censor(currentDescriptionTemplateFields, userId); } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/DmpUserCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PlanUserCensor.java similarity index 68% rename from backend/core/src/main/java/org/opencdmp/model/censorship/DmpUserCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/PlanUserCensor.java index 61a37b93e..5409350b6 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/DmpUserCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PlanUserCensor.java @@ -2,13 +2,13 @@ package org.opencdmp.model.censorship; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.DmpUser; +import org.opencdmp.model.PlanUser; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; -import org.opencdmp.model.censorship.dmp.DmpCensor; +import org.opencdmp.model.censorship.plan.PlanCensor; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -18,14 +18,14 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpUserCensor extends BaseCensor { +public class PlanUserCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpUserCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanUserCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public DmpUserCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) { + public PlanUserCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -36,10 +36,10 @@ public class DmpUserCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmpUser, Permission.DeferredAffiliation); - FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpUser._dmp)); - this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId); - FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(DmpUser._user)); + this.authService.authorizeForce(Permission.BrowsePlanUser, Permission.DeferredAffiliation); + FieldSet planFields = fields.extractPrefixed(this.asIndexerPrefix(PlanUser._plan)); + this.censorFactory.censor(PlanCensor.class).censor(planFields, userId); + FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(PlanUser._user)); this.censorFactory.censor(UserCensor.class).censor(userFields, userId); } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDescriptionCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDescriptionCensor.java index 50ad32f4e..0ef57ff82 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDescriptionCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDescriptionCensor.java @@ -36,8 +36,8 @@ public class PublicDescriptionCensor extends BaseCensor { this.authService.authorizeForce(Permission.PublicBrowseDescription); - FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDescription._dmpDescriptionTemplate)); - this.censorFactory.censor(PublicDmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields); + FieldSet planDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDescription._planDescriptionTemplate)); + this.censorFactory.censor(PublicPlanDescriptionTemplateCensor.class).censor(planDescriptionTemplateFields); FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDescription._descriptionTemplate)); this.censorFactory.censor(PublicDescriptionTemplateCensor.class).censor(descriptionTemplateFields); diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanCensor.java similarity index 55% rename from backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanCensor.java index 7e3a43605..28a9d2766 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanCensor.java @@ -2,7 +2,7 @@ package org.opencdmp.model.censorship; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.PublicDmp; +import org.opencdmp.model.PublicPlan; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -13,21 +13,19 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import java.util.UUID; - @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class PublicDmpCensor extends BaseCensor { +public class PublicPlanCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDmpCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicPlanCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public PublicDmpCensor(ConventionService conventionService, - AuthorizationService authService, - CensorFactory censorFactory) { + public PublicPlanCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -40,12 +38,12 @@ public class PublicDmpCensor extends BaseCensor { this.authService.authorizeForce(Permission.PublicBrowseDmp); - FieldSet dmpDescriptionsFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmp._dmpUsers)); - this.censorFactory.censor(PublicDmpUserCensor.class).censor(dmpDescriptionsFields); - FieldSet dmpReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmp._dmpReferences)); - this.censorFactory.censor(PublicDmpReferenceCensor.class).censor(dmpReferencesFields); - FieldSet otherDmpVersionsFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmp._otherDmpVersions)); - this.censorFactory.censor(PublicDmpCensor.class).censor(otherDmpVersionsFields); + FieldSet planDescriptionsFields = fields.extractPrefixed(this.asIndexerPrefix(PublicPlan._planUsers)); + this.censorFactory.censor(PublicPlanUserCensor.class).censor(planDescriptionsFields); + FieldSet planReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(PublicPlan._planReferences)); + this.censorFactory.censor(PublicPlanReferenceCensor.class).censor(planReferencesFields); + FieldSet otherPlanVersionsFields = fields.extractPrefixed(this.asIndexerPrefix(PublicPlan._otherPlanVersions)); + this.censorFactory.censor(PublicPlanCensor.class).censor(otherPlanVersionsFields); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpDescriptionTemplateCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanDescriptionTemplateCensor.java similarity index 65% rename from backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpDescriptionTemplateCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanDescriptionTemplateCensor.java index 20895c2e2..323896e33 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpDescriptionTemplateCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanDescriptionTemplateCensor.java @@ -2,7 +2,7 @@ package org.opencdmp.model.censorship; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.PublicDmpDescriptionTemplate; +import org.opencdmp.model.PublicPlanDescriptionTemplate; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -15,17 +15,17 @@ import org.springframework.stereotype.Component; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class PublicDmpDescriptionTemplateCensor extends BaseCensor{ +public class PublicPlanDescriptionTemplateCensor extends BaseCensor{ - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDmpDescriptionTemplateCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicPlanDescriptionTemplateCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public PublicDmpDescriptionTemplateCensor(ConventionService conventionService, - AuthorizationService authService, - CensorFactory censorFactory) { + public PublicPlanDescriptionTemplateCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -37,8 +37,8 @@ public class PublicDmpDescriptionTemplateCensor extends BaseCensor{ return; this.authService.authorizeForce(Permission.PublicBrowseDescription); - FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpDescriptionTemplate._dmp)); - this.censorFactory.censor(PublicDmpCensor.class).censor(dmpFields); + FieldSet planFields = fields.extractPrefixed(this.asIndexerPrefix(PublicPlanDescriptionTemplate._plan)); + this.censorFactory.censor(PublicPlanCensor.class).censor(planFields); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpReferenceCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanReferenceCensor.java similarity index 65% rename from backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpReferenceCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanReferenceCensor.java index dbd5129dd..a9ce7f885 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpReferenceCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanReferenceCensor.java @@ -2,9 +2,7 @@ package org.opencdmp.model.censorship; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.DmpDescriptionTemplate; -import org.opencdmp.model.PublicDmpDescriptionTemplate; -import org.opencdmp.model.PublicDmpReference; +import org.opencdmp.model.PublicPlanReference; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -15,20 +13,18 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import java.util.UUID; - @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class PublicDmpReferenceCensor extends BaseCensor { +public class PublicPlanReferenceCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDmpReferenceCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicPlanReferenceCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public PublicDmpReferenceCensor(ConventionService conventionService, - AuthorizationService authService, - CensorFactory censorFactory) { + public PublicPlanReferenceCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -40,9 +36,9 @@ public class PublicDmpReferenceCensor extends BaseCensor { return; this.authService.authorizeForce(Permission.PublicBrowseDmpReference); - FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpReference._dmp)); - this.censorFactory.censor(PublicDmpCensor.class).censor(dmpFields); - FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpReference._reference)); + FieldSet planFields = fields.extractPrefixed(this.asIndexerPrefix(PublicPlanReference._plan)); + this.censorFactory.censor(PublicPlanCensor.class).censor(planFields); + FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicPlanReference._reference)); this.censorFactory.censor(PublicReferenceCensor.class).censor(templateFields); } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpUserCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanUserCensor.java similarity index 73% rename from backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpUserCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanUserCensor.java index cd65aa18e..728a14cec 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicDmpUserCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicPlanUserCensor.java @@ -2,7 +2,7 @@ package org.opencdmp.model.censorship; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.PublicDmpUser; +import org.opencdmp.model.PublicPlanUser; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -15,14 +15,14 @@ import org.springframework.stereotype.Component; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class PublicDmpUserCensor extends BaseCensor { +public class PublicPlanUserCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDmpUserCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicPlanUserCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public PublicDmpUserCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) { + public PublicPlanUserCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -34,9 +34,9 @@ public class PublicDmpUserCensor extends BaseCensor { return; this.authService.authorizeForce(Permission.PublicBrowseDmpUser); - FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpUser._dmp)); - this.censorFactory.censor(PublicDmpCensor.class).censor(dmpFields); - FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpUser._user)); + FieldSet planFields = fields.extractPrefixed(this.asIndexerPrefix(PublicPlanUser._plan)); + this.censorFactory.censor(PublicPlanCensor.class).censor(planFields); + FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(PublicPlanUser._user)); this.censorFactory.censor(PublicUserCensor.class).censor(userFields); } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicReferenceTypeCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicReferenceTypeCensor.java index f5ae8405d..a6923ecae 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/PublicReferenceTypeCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/PublicReferenceTypeCensor.java @@ -2,7 +2,6 @@ package org.opencdmp.model.censorship; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; -import org.opencdmp.model.PublicDmpUser; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/RecentActivityItemCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/RecentActivityItemCensor.java index dd1bbe2a2..0fa73c008 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/RecentActivityItemCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/RecentActivityItemCensor.java @@ -8,7 +8,7 @@ import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; import org.opencdmp.model.censorship.description.DescriptionCensor; -import org.opencdmp.model.censorship.dmp.DmpCensor; +import org.opencdmp.model.censorship.plan.PlanCensor; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -37,8 +37,8 @@ public class RecentActivityItemCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(RecentActivityItem._dmp)); - this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId); + FieldSet planFields = fields.extractPrefixed(this.asIndexerPrefix(RecentActivityItem._plan)); + this.censorFactory.censor(PlanCensor.class).censor(planFields, userId); FieldSet descriptionFields = fields.extractPrefixed(this.asIndexerPrefix(RecentActivityItem._description)); this.censorFactory.censor(DescriptionCensor.class).censor(descriptionFields, userId); diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/description/DescriptionCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/description/DescriptionCensor.java index b25876add..21d7a6568 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/description/DescriptionCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/description/DescriptionCensor.java @@ -5,7 +5,7 @@ import org.opencdmp.convention.ConventionService; import org.opencdmp.model.censorship.*; import org.opencdmp.model.censorship.descriptionreference.DescriptionReferenceCensor; import org.opencdmp.model.censorship.descriptiontemplate.DescriptionTemplateCensor; -import org.opencdmp.model.censorship.dmp.DmpCensor; +import org.opencdmp.model.censorship.plan.PlanCensor; import org.opencdmp.model.description.Description; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; @@ -48,14 +48,14 @@ public class DescriptionCensor extends BaseCensor { FieldSet descriptionTagsFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionTags)); this.censorFactory.censor(DescriptionTagCensor.class).censor(descriptionTagsFields, userId); - FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmpDescriptionTemplate)); - this.censorFactory.censor(DmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields, userId); + FieldSet planDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._planDescriptionTemplate)); + this.censorFactory.censor(PlanDescriptionTemplateCensor.class).censor(planDescriptionTemplateFields, userId); FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionTemplate)); this.censorFactory.censor(DescriptionTemplateCensor.class).censor(descriptionTemplateFields, userId); - FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmp)); - this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId); + FieldSet planFields = fields.extractPrefixed(this.asIndexerPrefix(Description._plan)); + this.censorFactory.censor(PlanCensor.class).censor(planFields, userId); FieldSet propertiesFields = fields.extractPrefixed(this.asIndexerPrefix(Description._properties)); this.censorFactory.censor(PropertyDefinitionCensor.class).censor(propertiesFields, userId); diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpBlueprintValueCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanBlueprintValueCensor.java similarity index 69% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpBlueprintValueCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanBlueprintValueCensor.java index e1335e529..c6b6643dd 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpBlueprintValueCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanBlueprintValueCensor.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.censorship.dmp; +package org.opencdmp.model.censorship.plan; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; @@ -14,16 +14,16 @@ import org.springframework.stereotype.Component; import java.util.UUID; -@Component("dmpblueprintvaluecensor") +@Component("planblueprintvaluecensor") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBlueprintValueCensor extends BaseCensor { +public class PlanBlueprintValueCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintValueCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintValueCensor.class)); protected final AuthorizationService authService; - public DmpBlueprintValueCensor(ConventionService conventionService, - AuthorizationService authService) { + public PlanBlueprintValueCensor(ConventionService conventionService, + AuthorizationService authService) { super(conventionService); this.authService = authService; } @@ -33,7 +33,7 @@ public class DmpBlueprintValueCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmp, Permission.DeferredAffiliation); + this.authService.authorizeForce(Permission.BrowsePlan, Permission.DeferredAffiliation); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanCensor.java similarity index 54% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanCensor.java index 27ae23df5..691d6612f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanCensor.java @@ -1,10 +1,10 @@ -package org.opencdmp.model.censorship.dmp; +package org.opencdmp.model.censorship.plan; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.censorship.*; -import org.opencdmp.model.censorship.dmpreference.DmpReferenceCensor; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.censorship.planreference.PlanReferenceCensor; +import org.opencdmp.model.plan.Plan; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -19,17 +19,17 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpCensor extends BaseCensor { +public class PlanCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public DmpCensor(ConventionService conventionService, - AuthorizationService authService, - CensorFactory censorFactory) { + public PlanCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -40,19 +40,19 @@ public class DmpCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmp, Permission.DeferredAffiliation); + this.authService.authorizeForce(Permission.BrowsePlan, Permission.DeferredAffiliation); - FieldSet dmpUsersFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpUsers)); - this.censorFactory.censor(DmpUserCensor.class).censor(dmpUsersFields, userId); - FieldSet dmpReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpReferences)); - this.censorFactory.censor(DmpReferenceCensor.class).censor(dmpReferencesFields, userId); - FieldSet creatorFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._creator)); + FieldSet planUsersFields = fields.extractPrefixed(this.asIndexerPrefix(Plan._planUsers)); + this.censorFactory.censor(PlanUserCensor.class).censor(planUsersFields, userId); + FieldSet planReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(Plan._planReferences)); + this.censorFactory.censor(PlanReferenceCensor.class).censor(planReferencesFields, userId); + FieldSet creatorFields = fields.extractPrefixed(this.asIndexerPrefix(Plan._creator)); this.censorFactory.censor(UserCensor.class).censor(creatorFields, userId); - FieldSet doisFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._entityDois)); + FieldSet doisFields = fields.extractPrefixed(this.asIndexerPrefix(Plan._entityDois)); this.censorFactory.censor(EntityDoiCensor.class).censor(doisFields, userId); - FieldSet propertiesFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._properties)); - this.censorFactory.censor(DmpPropertiesCensor.class).censor(propertiesFields, userId); - FieldSet otherDmpVersionsFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._otherDmpVersions)); - this.censorFactory.censor(DmpCensor.class).censor(otherDmpVersionsFields, userId); + FieldSet propertiesFields = fields.extractPrefixed(this.asIndexerPrefix(Plan._properties)); + this.censorFactory.censor(PlanPropertiesCensor.class).censor(propertiesFields, userId); + FieldSet otherPlanVersionsFields = fields.extractPrefixed(this.asIndexerPrefix(Plan._otherPlanVersions)); + this.censorFactory.censor(PlanCensor.class).censor(otherPlanVersionsFields, userId); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpContactCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanContactCensor.java similarity index 74% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpContactCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanContactCensor.java index ef8cc07e7..96bcd6427 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpContactCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanContactCensor.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.censorship.dmp; +package org.opencdmp.model.censorship.plan; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; @@ -17,15 +17,15 @@ import java.util.UUID; @Component("dmpcontactcensor") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpContactCensor extends BaseCensor { +public class PlanContactCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpContactCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanContactCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public DmpContactCensor(ConventionService conventionService, - AuthorizationService authService, CensorFactory censorFactory) { + public PlanContactCensor(ConventionService conventionService, + AuthorizationService authService, CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -36,7 +36,7 @@ public class DmpContactCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmp, Permission.DeferredAffiliation); + this.authService.authorizeForce(Permission.BrowsePlan, Permission.DeferredAffiliation); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpPropertiesCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanPropertiesCensor.java similarity index 62% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpPropertiesCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanPropertiesCensor.java index 5435f03c7..14b43ca95 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmp/DmpPropertiesCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/plan/PlanPropertiesCensor.java @@ -1,9 +1,9 @@ -package org.opencdmp.model.censorship.dmp; +package org.opencdmp.model.censorship.plan; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.censorship.BaseCensor; -import org.opencdmp.model.dmp.DmpProperties; +import org.opencdmp.model.plan.PlanProperties; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -18,16 +18,16 @@ import java.util.UUID; @Component("dmppropertiescensor") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpPropertiesCensor extends BaseCensor { +public class PlanPropertiesCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpPropertiesCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanPropertiesCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public DmpPropertiesCensor(ConventionService conventionService, - AuthorizationService authService, - CensorFactory censorFactory) { + public PlanPropertiesCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -38,11 +38,11 @@ public class DmpPropertiesCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmp, Permission.DeferredAffiliation); - FieldSet dmpBlueprintValuesFields = fields.extractPrefixed(this.asIndexerPrefix(DmpProperties._dmpBlueprintValues)); - this.censorFactory.censor(DmpBlueprintValueCensor.class).censor(dmpBlueprintValuesFields, userId); - FieldSet contactsFields = fields.extractPrefixed(this.asIndexerPrefix(DmpProperties._contacts)); - this.censorFactory.censor(DmpContactCensor.class).censor(contactsFields, userId); + this.authService.authorizeForce(Permission.BrowsePlan, Permission.DeferredAffiliation); + FieldSet dmpBlueprintValuesFields = fields.extractPrefixed(this.asIndexerPrefix(PlanProperties._planBlueprintValues)); + this.censorFactory.censor(PlanBlueprintValueCensor.class).censor(dmpBlueprintValuesFields, userId); + FieldSet contactsFields = fields.extractPrefixed(this.asIndexerPrefix(PlanProperties._contacts)); + this.censorFactory.censor(PlanContactCensor.class).censor(contactsFields, userId); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DefinitionCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/DefinitionCensor.java similarity index 90% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DefinitionCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/DefinitionCensor.java index f1e1e74a7..dfcc6a972 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DefinitionCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/DefinitionCensor.java @@ -1,9 +1,9 @@ -package org.opencdmp.model.censorship.dmpblueprint; +package org.opencdmp.model.censorship.planblueprint; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.censorship.BaseCensor; -import org.opencdmp.model.dmpblueprint.Definition; +import org.opencdmp.model.planblueprint.Definition; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -38,7 +38,7 @@ public class DefinitionCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + this.authService.authorizeForce(Permission.BrowsePlanBlueprint); FieldSet sectionsFields = fields.extractPrefixed(this.asIndexerPrefix(Definition._sections)); this.censorFactory.censor(SectionCensor.class).censor(sectionsFields, userId); } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DescriptionTemplatesCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/DescriptionTemplatesCensor.java similarity index 91% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DescriptionTemplatesCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/DescriptionTemplatesCensor.java index d80001199..c45d56710 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DescriptionTemplatesCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/DescriptionTemplatesCensor.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.censorship.dmpblueprint; +package org.opencdmp.model.censorship.planblueprint; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; @@ -33,7 +33,7 @@ public class DescriptionTemplatesCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + this.authService.authorizeForce(Permission.BrowsePlanBlueprint); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/FieldCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/FieldCensor.java similarity index 91% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/FieldCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/FieldCensor.java index 8c09e109e..ec5f824f5 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/FieldCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/FieldCensor.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.censorship.dmpblueprint; +package org.opencdmp.model.censorship.planblueprint; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; @@ -33,7 +33,7 @@ public class FieldCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + this.authService.authorizeForce(Permission.BrowsePlanBlueprint); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DmpBlueprintCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/PlanBlueprintCensor.java similarity index 71% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DmpBlueprintCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/PlanBlueprintCensor.java index 63203ab76..bea7f0a1a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/DmpBlueprintCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/PlanBlueprintCensor.java @@ -1,9 +1,9 @@ -package org.opencdmp.model.censorship.dmpblueprint; +package org.opencdmp.model.censorship.planblueprint; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.censorship.BaseCensor; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; +import org.opencdmp.model.planblueprint.PlanBlueprint; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -18,16 +18,16 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBlueprintCensor extends BaseCensor { +public class PlanBlueprintCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public DmpBlueprintCensor(ConventionService conventionService, - AuthorizationService authService, - CensorFactory censorFactory) { + public PlanBlueprintCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -38,8 +38,8 @@ public class DmpBlueprintCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmpBlueprint); - FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(DmpBlueprint._definition)); + this.authService.authorizeForce(Permission.BrowsePlanBlueprint); + FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(PlanBlueprint._definition)); this.censorFactory.censor(DefinitionCensor.class).censor(definitionFields, userId); } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/SectionCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/SectionCensor.java similarity index 91% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/SectionCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/SectionCensor.java index 5fbb97034..44ec3cde1 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpblueprint/SectionCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/planblueprint/SectionCensor.java @@ -1,9 +1,9 @@ -package org.opencdmp.model.censorship.dmpblueprint; +package org.opencdmp.model.censorship.planblueprint; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.censorship.BaseCensor; -import org.opencdmp.model.dmpblueprint.Section; +import org.opencdmp.model.planblueprint.Section; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -38,7 +38,7 @@ public class SectionCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + this.authService.authorizeForce(Permission.BrowsePlanBlueprint); FieldSet fieldsFields = fields.extractPrefixed(this.asIndexerPrefix(Section._fields)); this.censorFactory.censor(FieldCensor.class).censor(fieldsFields, userId); FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asIndexerPrefix(Section._descriptionTemplates)); diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpreference/DmpReferenceCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/planreference/PlanReferenceCensor.java similarity index 61% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmpreference/DmpReferenceCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/planreference/PlanReferenceCensor.java index d8d6e4df9..9f6832716 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpreference/DmpReferenceCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/planreference/PlanReferenceCensor.java @@ -1,11 +1,11 @@ -package org.opencdmp.model.censorship.dmpreference; +package org.opencdmp.model.censorship.planreference; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; import org.opencdmp.model.censorship.BaseCensor; import org.opencdmp.model.censorship.reference.ReferenceCensor; -import org.opencdmp.model.censorship.dmp.DmpCensor; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.censorship.plan.PlanCensor; +import org.opencdmp.model.planreference.PlanReference; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -20,16 +20,16 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpReferenceCensor extends BaseCensor { +public class PlanReferenceCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpReferenceCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanReferenceCensor.class)); protected final AuthorizationService authService; protected final CensorFactory censorFactory; - public DmpReferenceCensor(ConventionService conventionService, - AuthorizationService authService, - CensorFactory censorFactory) { + public PlanReferenceCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -40,13 +40,13 @@ public class DmpReferenceCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmpDescriptionTemplate, Permission.DeferredAffiliation); - FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._dmp)); - this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId); - FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._reference)); + this.authService.authorizeForce(Permission.BrowsePlanDescriptionTemplate, Permission.DeferredAffiliation); + FieldSet planFields = fields.extractPrefixed(this.asIndexerPrefix(PlanReference._plan)); + this.censorFactory.censor(PlanCensor.class).censor(planFields, userId); + FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(PlanReference._reference)); this.censorFactory.censor(ReferenceCensor.class).censor(templateFields, userId); - FieldSet dataFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._data)); - this.censorFactory.censor(DmpReferenceDataCensor.class).censor(dataFields, userId); + FieldSet dataFields = fields.extractPrefixed(this.asIndexerPrefix(PlanReference._data)); + this.censorFactory.censor(PlanReferenceDataCensor.class).censor(dataFields, userId); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpreference/DmpReferenceDataCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/planreference/PlanReferenceDataCensor.java similarity index 72% rename from backend/core/src/main/java/org/opencdmp/model/censorship/dmpreference/DmpReferenceDataCensor.java rename to backend/core/src/main/java/org/opencdmp/model/censorship/planreference/PlanReferenceDataCensor.java index 706b92ee4..cc053b0fd 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/dmpreference/DmpReferenceDataCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/planreference/PlanReferenceDataCensor.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.censorship.dmpreference; +package org.opencdmp.model.censorship.planreference; import org.opencdmp.authorization.Permission; import org.opencdmp.convention.ConventionService; @@ -17,16 +17,16 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpReferenceDataCensor extends BaseCensor { +public class PlanReferenceDataCensor extends BaseCensor { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpReferenceDataCensor.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanReferenceDataCensor.class)); protected final AuthorizationService authService; @Autowired - public DmpReferenceDataCensor(ConventionService conventionService, - AuthorizationService authService) { + public PlanReferenceDataCensor(ConventionService conventionService, + AuthorizationService authService) { super(conventionService); this.authService = authService; } @@ -36,7 +36,7 @@ public class DmpReferenceDataCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDmpDescriptionTemplate, Permission.DeferredAffiliation); + this.authService.authorizeForce(Permission.BrowsePlanDescriptionTemplate, Permission.DeferredAffiliation); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/censorship/reference/ReferenceCensor.java b/backend/core/src/main/java/org/opencdmp/model/censorship/reference/ReferenceCensor.java index 1930f5bf9..3a15141ac 100644 --- a/backend/core/src/main/java/org/opencdmp/model/censorship/reference/ReferenceCensor.java +++ b/backend/core/src/main/java/org/opencdmp/model/censorship/reference/ReferenceCensor.java @@ -5,7 +5,7 @@ import org.opencdmp.convention.ConventionService; import org.opencdmp.model.censorship.BaseCensor; import org.opencdmp.model.censorship.referencetype.ReferenceTypeCensor; import org.opencdmp.model.censorship.UserCensor; -import org.opencdmp.model.censorship.dmpreference.DmpReferenceCensor; +import org.opencdmp.model.censorship.planreference.PlanReferenceCensor; import org.opencdmp.model.reference.Reference; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; @@ -44,8 +44,8 @@ public class ReferenceCensor extends BaseCensor { this.authService.authorizeForce(Permission.BrowseReference, Permission.DeferredAffiliation); FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(Reference._definition)); this.censorFactory.censor(DefinitionCensor.class).censor(definitionFields, userId); - FieldSet dmpReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(Reference._dmpReferences)); - this.censorFactory.censor(DmpReferenceCensor.class).censor(dmpReferencesFields, userId); + FieldSet planReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(Reference._planReferences)); + this.censorFactory.censor(PlanReferenceCensor.class).censor(planReferencesFields, userId); FieldSet createdByFields = fields.extractPrefixed(this.asIndexerPrefix(Reference._createdBy)); this.censorFactory.censor(UserCensor.class).censor(createdByFields, userId); FieldSet typeFields = fields.extractPrefixed(this.asIndexerPrefix(Reference._type)); diff --git a/backend/core/src/main/java/org/opencdmp/model/deleter/DescriptionTemplateDeleter.java b/backend/core/src/main/java/org/opencdmp/model/deleter/DescriptionTemplateDeleter.java index db54fbeaa..50a568403 100644 --- a/backend/core/src/main/java/org/opencdmp/model/deleter/DescriptionTemplateDeleter.java +++ b/backend/core/src/main/java/org/opencdmp/model/deleter/DescriptionTemplateDeleter.java @@ -1,20 +1,14 @@ package org.opencdmp.model.deleter; -import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus; -import org.opencdmp.commons.enums.DmpVersionStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.data.DescriptionTemplateEntity; -import org.opencdmp.data.DmpDescriptionTemplateEntity; import org.opencdmp.data.TenantEntityManager; import org.opencdmp.data.UserDescriptionTemplateEntity; -import org.opencdmp.query.DescriptionQuery; import org.opencdmp.query.DescriptionTemplateQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; import org.opencdmp.query.UserDescriptionTemplateQuery; import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.query.QueryFactory; -import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; import org.slf4j.LoggerFactory; diff --git a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpBlueprintDeleter.java b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanBlueprintDeleter.java similarity index 80% rename from backend/core/src/main/java/org/opencdmp/model/deleter/DmpBlueprintDeleter.java rename to backend/core/src/main/java/org/opencdmp/model/deleter/PlanBlueprintDeleter.java index e34007725..3f3f2938b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpBlueprintDeleter.java +++ b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanBlueprintDeleter.java @@ -1,9 +1,9 @@ package org.opencdmp.model.deleter; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.data.PlanBlueprintEntity; import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.query.DmpBlueprintQuery; +import org.opencdmp.query.PlanBlueprintQuery; import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.query.QueryFactory; @@ -23,9 +23,9 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBlueprintDeleter implements Deleter { +public class PlanBlueprintDeleter implements Deleter { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintDeleter.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintDeleter.class)); private final TenantEntityManager entityManager; @@ -34,7 +34,7 @@ public class DmpBlueprintDeleter implements Deleter { protected final DeleterFactory deleterFactory; @Autowired - public DmpBlueprintDeleter( + public PlanBlueprintDeleter( TenantEntityManager entityManager, QueryFactory queryFactory, DeleterFactory deleterFactory @@ -46,12 +46,12 @@ public class DmpBlueprintDeleter implements Deleter { public void deleteAndSaveByIds(List ids) throws InvalidApplicationException { logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids)); - List data = this.queryFactory.query(DmpBlueprintQuery.class).ids(ids).collect(); + List data = this.queryFactory.query(PlanBlueprintQuery.class).ids(ids).collect(); logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.deleteAndSave(data); } - public void deleteAndSave(List data) throws InvalidApplicationException { + public void deleteAndSave(List data) throws InvalidApplicationException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.delete(data); logger.trace("saving changes"); @@ -59,14 +59,14 @@ public class DmpBlueprintDeleter implements Deleter { logger.trace("changes saved"); } - public void delete(List data) throws InvalidApplicationException { + public void delete(List data) throws InvalidApplicationException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return; Instant now = Instant.now(); - for (DmpBlueprintEntity item : data) { + for (PlanBlueprintEntity item : data) { logger.trace("deleting item {}", item.getId()); item.setIsActive(IsActive.Inactive); item.setUpdatedAt(now); diff --git a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpDeleter.java b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanDeleter.java similarity index 66% rename from backend/core/src/main/java/org/opencdmp/model/deleter/DmpDeleter.java rename to backend/core/src/main/java/org/opencdmp/model/deleter/PlanDeleter.java index e455fb756..4935b24a5 100644 --- a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpDeleter.java +++ b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanDeleter.java @@ -7,13 +7,13 @@ import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.DmpVersionStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; import org.opencdmp.commons.enums.EntityType; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.data.*; -import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.model.PlanDescriptionTemplate; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.query.*; import org.opencdmp.service.elastic.ElasticService; import org.slf4j.LoggerFactory; @@ -31,9 +31,9 @@ import java.util.UUID; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpDeleter implements Deleter { +public class PlanDeleter implements Deleter { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDeleter.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanDeleter.class)); private final TenantEntityManager entityManager; @@ -43,7 +43,7 @@ public class DmpDeleter implements Deleter { protected final ElasticService elasticService; @Autowired - public DmpDeleter( + public PlanDeleter( TenantEntityManager entityManager, QueryFactory queryFactory, DeleterFactory deleterFactory, @@ -56,12 +56,12 @@ public class DmpDeleter implements Deleter { public void deleteAndSaveByIds(List ids, boolean disableElastic) throws InvalidApplicationException, IOException { logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids)); - List data = this.queryFactory.query(DmpQuery.class).ids(ids).collect(); + List data = this.queryFactory.query(PlanQuery.class).ids(ids).collect(); logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.deleteAndSave(data, disableElastic); } - public void deleteAndSave(List data, boolean disableElastic) throws InvalidApplicationException, IOException { + public void deleteAndSave(List data, boolean disableElastic) throws InvalidApplicationException, IOException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.delete(data, disableElastic); logger.trace("saving changes"); @@ -69,51 +69,51 @@ public class DmpDeleter implements Deleter { logger.trace("changes saved"); } - public void delete(List data, boolean disableElastic) throws InvalidApplicationException, IOException { + public void delete(List data, boolean disableElastic) throws InvalidApplicationException, IOException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return; - List ids = data.stream().map(DmpEntity::getId).distinct().toList(); + List ids = data.stream().map(PlanEntity::getId).distinct().toList(); { - logger.debug("checking related - {}", DmpUserEntity.class.getSimpleName()); - List items = this.queryFactory.query(DmpUserQuery.class).dmpIds(ids).collect(); - DmpUserDeleter deleter = this.deleterFactory.deleter(DmpUserDeleter.class); + logger.debug("checking related - {}", PlanUserEntity.class.getSimpleName()); + List items = this.queryFactory.query(PlanUserQuery.class).planIds(ids).collect(); + PlanUserDeleter deleter = this.deleterFactory.deleter(PlanUserDeleter.class); deleter.delete(items); } { - logger.debug("checking related - {}", DmpDescriptionTemplate.class.getSimpleName()); - List items = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(ids).collect(); - DmpDescriptionTemplateDeleter deleter = this.deleterFactory.deleter(DmpDescriptionTemplateDeleter.class); + logger.debug("checking related - {}", PlanDescriptionTemplate.class.getSimpleName()); + List items = this.queryFactory.query(PlanDescriptionTemplateQuery.class).planIds(ids).collect(); + PlanDescriptionTemplateDeleter deleter = this.deleterFactory.deleter(PlanDescriptionTemplateDeleter.class); deleter.delete(items); } { - logger.debug("checking related - {}", DmpReference.class.getSimpleName()); - List items = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(ids).collect(); - DmpReferenceDeleter deleter = this.deleterFactory.deleter(DmpReferenceDeleter.class); + logger.debug("checking related - {}", PlanReference.class.getSimpleName()); + List items = this.queryFactory.query(PlanReferenceQuery.class).planIds(ids).collect(); + PlanReferenceDeleter deleter = this.deleterFactory.deleter(PlanReferenceDeleter.class); deleter.delete(items); } { logger.debug("checking related - {}", Description.class.getSimpleName()); - List items = this.queryFactory.query(DescriptionQuery.class).dmpIds(ids).collect(); + List items = this.queryFactory.query(DescriptionQuery.class).planIds(ids).collect(); DescriptionDeleter deleter = this.deleterFactory.deleter(DescriptionDeleter.class); deleter.delete(items, false); //We delete elastic entities by bmp deleter } Instant now = Instant.now(); - for (DmpEntity item : data) { + for (PlanEntity item : data) { logger.trace("deleting item {}", item.getId()); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.DMP).entityIds(item.getId()); if (entityDoiQuery.count() > 0) throw new MyApplicationException("DMP is deposited can not deleted"); - if(item.getVersionStatus().equals(DmpVersionStatus.Current)) throw new MyApplicationException("DMP is current can not deleted"); + if(item.getVersionStatus().equals(PlanVersionStatus.Current)) throw new MyApplicationException("DMP is current can not deleted"); item.setIsActive(IsActive.Inactive); item.setUpdatedAt(now); logger.trace("updating item"); this.entityManager.merge(item); logger.trace("updated item"); - if (!disableElastic) this.elasticService.deleteDmp(item); + if (!disableElastic) this.elasticService.deletePlan(item); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpDescriptionTemplateDeleter.java b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanDescriptionTemplateDeleter.java similarity index 78% rename from backend/core/src/main/java/org/opencdmp/model/deleter/DmpDescriptionTemplateDeleter.java rename to backend/core/src/main/java/org/opencdmp/model/deleter/PlanDescriptionTemplateDeleter.java index 84d16b7bb..9d2868ed7 100644 --- a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpDescriptionTemplateDeleter.java +++ b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanDescriptionTemplateDeleter.java @@ -1,9 +1,9 @@ package org.opencdmp.model.deleter; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.DmpDescriptionTemplateEntity; +import org.opencdmp.data.PlanDescriptionTemplateEntity; import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.query.DmpDescriptionTemplateQuery; +import org.opencdmp.query.PlanDescriptionTemplateQuery; import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.query.QueryFactory; @@ -23,9 +23,9 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpDescriptionTemplateDeleter implements Deleter { +public class PlanDescriptionTemplateDeleter implements Deleter { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDescriptionTemplateDeleter.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanDescriptionTemplateDeleter.class)); private final TenantEntityManager entityManager; protected final QueryFactory queryFactory; @@ -33,7 +33,7 @@ public class DmpDescriptionTemplateDeleter implements Deleter { protected final DeleterFactory deleterFactory; @Autowired - public DmpDescriptionTemplateDeleter( + public PlanDescriptionTemplateDeleter( TenantEntityManager entityManager, QueryFactory queryFactory, DeleterFactory deleterFactory @@ -45,12 +45,12 @@ public class DmpDescriptionTemplateDeleter implements Deleter { public void deleteAndSaveByIds(List ids) throws InvalidApplicationException { logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids)); - List data = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(ids).collect(); + List data = this.queryFactory.query(PlanDescriptionTemplateQuery.class).ids(ids).collect(); logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.deleteAndSave(data); } - public void deleteAndSave(List data) throws InvalidApplicationException { + public void deleteAndSave(List data) throws InvalidApplicationException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.delete(data); logger.trace("saving changes"); @@ -58,12 +58,12 @@ public class DmpDescriptionTemplateDeleter implements Deleter { logger.trace("changes saved"); } - public void delete(List data) throws InvalidApplicationException { + public void delete(List data) throws InvalidApplicationException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return; - for (DmpDescriptionTemplateEntity item : data) { + for (PlanDescriptionTemplateEntity item : data) { logger.trace("deleting item {}", item.getId()); logger.trace("updating item"); item.setUpdatedAt(Instant.now()); diff --git a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpReferenceDeleter.java b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanReferenceDeleter.java similarity index 80% rename from backend/core/src/main/java/org/opencdmp/model/deleter/DmpReferenceDeleter.java rename to backend/core/src/main/java/org/opencdmp/model/deleter/PlanReferenceDeleter.java index 9b95d6a4d..6bdffc70a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpReferenceDeleter.java +++ b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanReferenceDeleter.java @@ -1,9 +1,9 @@ package org.opencdmp.model.deleter; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.DmpReferenceEntity; +import org.opencdmp.data.PlanReferenceEntity; import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.query.DmpReferenceQuery; +import org.opencdmp.query.PlanReferenceQuery; import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.query.QueryFactory; @@ -23,9 +23,9 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpReferenceDeleter implements Deleter { +public class PlanReferenceDeleter implements Deleter { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpReferenceDeleter.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanReferenceDeleter.class)); private final TenantEntityManager entityManager; protected final QueryFactory queryFactory; @@ -33,7 +33,7 @@ public class DmpReferenceDeleter implements Deleter { protected final DeleterFactory deleterFactory; @Autowired - public DmpReferenceDeleter( + public PlanReferenceDeleter( TenantEntityManager entityManager, QueryFactory queryFactory, DeleterFactory deleterFactory @@ -45,12 +45,12 @@ public class DmpReferenceDeleter implements Deleter { public void deleteAndSaveByIds(List ids) throws InvalidApplicationException { logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids)); - List data = this.queryFactory.query(DmpReferenceQuery.class).ids(ids).collect(); + List data = this.queryFactory.query(PlanReferenceQuery.class).ids(ids).collect(); logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.deleteAndSave(data); } - public void deleteAndSave(List data) throws InvalidApplicationException { + public void deleteAndSave(List data) throws InvalidApplicationException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.delete(data); logger.trace("saving changes"); @@ -58,12 +58,12 @@ public class DmpReferenceDeleter implements Deleter { logger.trace("changes saved"); } - public void delete(List data) throws InvalidApplicationException { + public void delete(List data) throws InvalidApplicationException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return; - for (DmpReferenceEntity item : data) { + for (PlanReferenceEntity item : data) { logger.trace("deleting item {}", item.getId()); logger.trace("updating item"); item.setUpdatedAt(Instant.now()); diff --git a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpUserDeleter.java b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanUserDeleter.java similarity index 81% rename from backend/core/src/main/java/org/opencdmp/model/deleter/DmpUserDeleter.java rename to backend/core/src/main/java/org/opencdmp/model/deleter/PlanUserDeleter.java index b71b9fd46..44d7631bc 100644 --- a/backend/core/src/main/java/org/opencdmp/model/deleter/DmpUserDeleter.java +++ b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanUserDeleter.java @@ -1,9 +1,9 @@ package org.opencdmp.model.deleter; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.DmpUserEntity; +import org.opencdmp.data.PlanUserEntity; import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.query.DmpUserQuery; +import org.opencdmp.query.PlanUserQuery; import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.query.QueryFactory; @@ -23,9 +23,9 @@ import java.util.UUID; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpUserDeleter implements Deleter { +public class PlanUserDeleter implements Deleter { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpUserDeleter.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanUserDeleter.class)); private final TenantEntityManager entityManager; protected final QueryFactory queryFactory; @@ -33,7 +33,7 @@ public class DmpUserDeleter implements Deleter { protected final DeleterFactory deleterFactory; @Autowired - public DmpUserDeleter( + public PlanUserDeleter( TenantEntityManager entityManager, QueryFactory queryFactory, DeleterFactory deleterFactory @@ -45,12 +45,12 @@ public class DmpUserDeleter implements Deleter { public void deleteAndSaveByIds(List ids) throws InvalidApplicationException { logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids)); - List data = this.queryFactory.query(DmpUserQuery.class).ids(ids).collect(); + List data = this.queryFactory.query(PlanUserQuery.class).ids(ids).collect(); logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.deleteAndSave(data); } - public void deleteAndSave(List data) throws InvalidApplicationException { + public void deleteAndSave(List data) throws InvalidApplicationException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); this.delete(data); logger.trace("saving changes"); @@ -58,12 +58,12 @@ public class DmpUserDeleter implements Deleter { logger.trace("changes saved"); } - public void delete(List data) throws InvalidApplicationException { + public void delete(List data) throws InvalidApplicationException { logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); if (data == null || data.isEmpty()) return; - for (DmpUserEntity item : data) { + for (PlanUserEntity item : data) { logger.trace("deleting item {}", item.getId()); logger.trace("updating item"); item.setUpdatedAt(Instant.now()); diff --git a/backend/core/src/main/java/org/opencdmp/model/deleter/ReferenceDeleter.java b/backend/core/src/main/java/org/opencdmp/model/deleter/ReferenceDeleter.java index f7990bda8..026077c37 100644 --- a/backend/core/src/main/java/org/opencdmp/model/deleter/ReferenceDeleter.java +++ b/backend/core/src/main/java/org/opencdmp/model/deleter/ReferenceDeleter.java @@ -3,7 +3,7 @@ package org.opencdmp.model.deleter; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.data.*; import org.opencdmp.query.DescriptionReferenceQuery; -import org.opencdmp.query.DmpReferenceQuery; +import org.opencdmp.query.PlanReferenceQuery; import org.opencdmp.query.ReferenceQuery; import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.DeleterFactory; @@ -73,9 +73,9 @@ public class ReferenceDeleter implements Deleter { deleter.delete(items); } { - logger.debug("checking related - {}", DmpReferenceEntity.class.getSimpleName()); - List items = this.queryFactory.query(DmpReferenceQuery.class).referenceIds(ids).collect(); - DmpReferenceDeleter deleter = this.deleterFactory.deleter(DmpReferenceDeleter.class); + logger.debug("checking related - {}", PlanReferenceEntity.class.getSimpleName()); + List items = this.queryFactory.query(PlanReferenceQuery.class).referenceIds(ids).collect(); + PlanReferenceDeleter deleter = this.deleterFactory.deleter(PlanReferenceDeleter.class); deleter.delete(items); } Instant now = Instant.now(); diff --git a/backend/core/src/main/java/org/opencdmp/model/description/Description.java b/backend/core/src/main/java/org/opencdmp/model/description/Description.java index 387664094..fcf647fed 100644 --- a/backend/core/src/main/java/org/opencdmp/model/description/Description.java +++ b/backend/core/src/main/java/org/opencdmp/model/description/Description.java @@ -5,7 +5,7 @@ import org.opencdmp.commons.enums.IsActive; import org.opencdmp.model.*; import org.opencdmp.model.descriptionreference.DescriptionReference; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.user.User; import java.time.Instant; @@ -67,9 +67,9 @@ public class Description { public static final String _descriptionTags = "descriptionTags"; - private DmpDescriptionTemplate dmpDescriptionTemplate; + private PlanDescriptionTemplate planDescriptionTemplate; - public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate"; + public static final String _planDescriptionTemplate = "planDescriptionTemplate"; private DescriptionTemplate descriptionTemplate; @@ -78,9 +78,9 @@ public class Description { private List authorizationFlags; public static final String _authorizationFlags = "authorizationFlags"; - private Dmp dmp; + private Plan plan; - public static final String _dmp = "dmp"; + public static final String _plan = "plan"; private Boolean belongsToCurrentTenant; public static final String _belongsToCurrentTenant = "belongsToCurrentTenant"; @@ -182,12 +182,12 @@ public class Description { this.createdAt = createdAt; } - public DmpDescriptionTemplate getDmpDescriptionTemplate() { - return dmpDescriptionTemplate; + public PlanDescriptionTemplate getPlanDescriptionTemplate() { + return planDescriptionTemplate; } - public void setDmpDescriptionTemplate(DmpDescriptionTemplate dmpDescriptionTemplate) { - this.dmpDescriptionTemplate = dmpDescriptionTemplate; + public void setPlanDescriptionTemplate(PlanDescriptionTemplate planDescriptionTemplate) { + this.planDescriptionTemplate = planDescriptionTemplate; } public List getDescriptionTags() { @@ -198,12 +198,12 @@ public class Description { this.descriptionTags = descriptionTags; } - public Dmp getDmp() { - return dmp; + public Plan getPlan() { + return plan; } - public void setDmp(Dmp dmp) { - this.dmp = dmp; + public void setPlan(Plan plan) { + this.plan = plan; } public DescriptionTemplate getDescriptionTemplate() { diff --git a/backend/core/src/main/java/org/opencdmp/model/dmp/DmpProperties.java b/backend/core/src/main/java/org/opencdmp/model/dmp/DmpProperties.java deleted file mode 100644 index db9ebd404..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/dmp/DmpProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.opencdmp.model.dmp; - -import java.util.List; - -public class DmpProperties { - - private List dmpBlueprintValues; - - public static final String _dmpBlueprintValues = "dmpBlueprintValues"; - - private List contacts; - - public static final String _contacts = "contacts"; - - public List getDmpBlueprintValues() { - return dmpBlueprintValues; - } - - public void setDmpBlueprintValues(List dmpBlueprintValues) { - this.dmpBlueprintValues = dmpBlueprintValues; - } - - public List getContacts() { - return contacts; - } - - public void setContacts(List contacts) { - this.contacts = contacts; - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/ExtraField.java b/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/ExtraField.java deleted file mode 100644 index 6dcbb749f..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/ExtraField.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.opencdmp.model.dmpblueprint; - -import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType; - - -public class ExtraField extends Field { - - public final static String _dataType = "dataType"; - private DmpBlueprintExtraFieldDataType dataType; - - public DmpBlueprintExtraFieldDataType getDataType() { - return dataType; - } - - public void setDataType(DmpBlueprintExtraFieldDataType dataType) { - this.dataType = dataType; - } -} - diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/SystemField.java b/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/SystemField.java deleted file mode 100644 index d518dcfb4..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/SystemField.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.opencdmp.model.dmpblueprint; - -import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType; - -public class SystemField extends Field { - - public final static String _systemFieldType = "systemFieldType"; - private DmpBlueprintSystemFieldType systemFieldType; - - public DmpBlueprintSystemFieldType getSystemFieldType() { - return systemFieldType; - } - - public void setSystemFieldType(DmpBlueprintSystemFieldType systemFieldType) { - this.systemFieldType = systemFieldType; - } -} diff --git a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionToPublicApiDatasetListingMapper.java b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionToPublicApiDatasetListingMapper.java index 90aa07a9a..570edf51e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionToPublicApiDatasetListingMapper.java +++ b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionToPublicApiDatasetListingMapper.java @@ -21,8 +21,8 @@ public class DescriptionToPublicApiDatasetListingMapper { model.setDescription(description.getDescription()); model.setVersion(0); - model.setDmp(description.getDmp().getLabel()); - model.setDmpId(description.getDmp().getId().toString()); + model.setDmp(description.getPlan().getLabel()); + model.setDmpId(description.getPlan().getId().toString()); model.setUsers(List.of(UserInfoPublicModel.fromDescriptionCreator(description.getCreatedBy()))); model.setProfile(DatasetProfilePublicModel.fromDataModel(description.getDescriptionTemplate())); model.setGrant(GrantPublicOverviewModel.fromDescriptionReference(description.getDescriptionReferences(), config)); diff --git a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/PlanToPublicApiPlanListingMapper.java b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/PlanToPublicApiPlanListingMapper.java index 5292dc8e0..f1f83e66e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/PlanToPublicApiPlanListingMapper.java +++ b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/PlanToPublicApiPlanListingMapper.java @@ -1,6 +1,6 @@ package org.opencdmp.model.mapper.publicapi; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.publicapi.listingmodels.DataManagementPlanPublicListingModel; import org.opencdmp.model.publicapi.researcher.ResearcherPublicModel; import org.opencdmp.model.publicapi.user.UserInfoPublicModel; @@ -13,19 +13,19 @@ import java.util.Objects; @Component public class PlanToPublicApiPlanListingMapper { - public DataManagementPlanPublicListingModel toPublicListingModel(Dmp dmp, PublicApiProperties.ReferenceTypeMapConfig config) { + public DataManagementPlanPublicListingModel toPublicListingModel(Plan plan, PublicApiProperties.ReferenceTypeMapConfig config) { DataManagementPlanPublicListingModel model = new DataManagementPlanPublicListingModel(); - model.setId(dmp.getId().toString()); - model.setLabel(dmp.getLabel()); - model.setVersion(dmp.getVersion()); - model.setGroupId(dmp.getGroupId()); + model.setId(plan.getId().toString()); + model.setLabel(plan.getLabel()); + model.setVersion(plan.getVersion()); + model.setGroupId(plan.getGroupId()); - model.setUsers(dmp.getDmpUsers().stream().map(UserInfoPublicModel::fromDmpUser).toList()); - model.setResearchers(dmp.getDmpReferences().stream().map(x-> ResearcherPublicModel.fromDmpReference(x, config)).filter(Objects::nonNull).toList()); + model.setUsers(plan.getPlanUsers().stream().map(UserInfoPublicModel::fromDmpUser).toList()); + model.setResearchers(plan.getPlanReferences().stream().map(x-> ResearcherPublicModel.fromDmpReference(x, config)).filter(Objects::nonNull).toList()); - model.setCreatedAt(Date.from(dmp.getCreatedAt())); - model.setModifiedAt(Date.from(dmp.getUpdatedAt())); - model.setFinalizedAt(Date.from(dmp.getFinalizedAt())); + model.setCreatedAt(Date.from(plan.getCreatedAt())); + model.setModifiedAt(Date.from(plan.getUpdatedAt())); + model.setFinalizedAt(Date.from(plan.getFinalizedAt())); model.setPublishedAt(model.getFinalizedAt()); return model; diff --git a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/PlanToPublicApiPlanMapper.java b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/PlanToPublicApiPlanMapper.java index 4db1bf1f0..034e430ca 100644 --- a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/PlanToPublicApiPlanMapper.java +++ b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/PlanToPublicApiPlanMapper.java @@ -1,8 +1,8 @@ package org.opencdmp.model.mapper.publicapi; import org.opencdmp.data.EntityDoiEntity; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.model.PlanDescriptionTemplate; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.publicapi.associatedprofile.AssociatedProfilePublicModel; import org.opencdmp.model.publicapi.doi.DoiPublicModel; import org.opencdmp.model.publicapi.grant.GrantPublicOverviewModel; @@ -27,31 +27,31 @@ public class PlanToPublicApiPlanMapper { this.descriptionToPublicApiDatasetMapper = descriptionToPublicApiDatasetMapper; } - public DataManagementPlanPublicModel toPublicModel(Dmp dmp, List doiEntities, List descriptionTemplates, PublicApiProperties.ReferenceTypeMapConfig config) { + public DataManagementPlanPublicModel toPublicModel(Plan plan, List doiEntities, List descriptionTemplates, PublicApiProperties.ReferenceTypeMapConfig config) { DataManagementPlanPublicModel model = new DataManagementPlanPublicModel(); - model.setId(dmp.getId().toString()); - model.setLabel(dmp.getLabel()); - model.setDescription(dmp.getDescription()); - model.setVersion(dmp.getVersion()); - model.setGroupId(dmp.getGroupId()); - if (dmp.getBlueprint() != null) model.setProfile(dmp.getBlueprint().getLabel()); + model.setId(plan.getId().toString()); + model.setLabel(plan.getLabel()); + model.setDescription(plan.getDescription()); + model.setVersion(plan.getVersion()); + model.setGroupId(plan.getGroupId()); + if (plan.getBlueprint() != null) model.setProfile(plan.getBlueprint().getLabel()); - if (dmp.getDescriptions() != null) { + if (plan.getDescriptions() != null) { DataManagementPlanPublicListingModel publicListingModel = new DataManagementPlanPublicListingModel(); publicListingModel.setId(model.getId()); - model.setDatasets(dmp.getDescriptions().stream().map(x -> descriptionToPublicApiDatasetMapper.toPublicModel(x, publicListingModel, config)).toList()); + model.setDatasets(plan.getDescriptions().stream().map(x -> descriptionToPublicApiDatasetMapper.toPublicModel(x, publicListingModel, config)).toList()); } - model.setUsers(dmp.getDmpUsers().stream().map(UserInfoPublicModel::fromDmpUser).toList()); - model.setResearchers(dmp.getDmpReferences().stream().map(x-> ResearcherPublicModel.fromDmpReference(x, config)).filter(Objects::nonNull).toList()); - model.setGrant(GrantPublicOverviewModel.fromDmpReferences(dmp.getDmpReferences(), config)); - model.setOrganisations(dmp.getDmpReferences().stream().map(x-> OrganizationPublicModel.fromDmpReference(x, config)).filter(Objects::nonNull).toList()); + model.setUsers(plan.getPlanUsers().stream().map(UserInfoPublicModel::fromDmpUser).toList()); + model.setResearchers(plan.getPlanReferences().stream().map(x-> ResearcherPublicModel.fromDmpReference(x, config)).filter(Objects::nonNull).toList()); + model.setGrant(GrantPublicOverviewModel.fromDmpReferences(plan.getPlanReferences(), config)); + model.setOrganisations(plan.getPlanReferences().stream().map(x-> OrganizationPublicModel.fromDmpReference(x, config)).filter(Objects::nonNull).toList()); model.setDois(doiEntities.stream().map(DoiPublicModel::fromDataModel).toList()); - model.setAssociatedProfiles(descriptionTemplates.stream().map(x -> AssociatedProfilePublicModel.fromDmpDescriptionTemplate(x, dmp.getBlueprint())).toList()); + model.setAssociatedProfiles(descriptionTemplates.stream().map(x -> AssociatedProfilePublicModel.fromPlanDescriptionTemplate(x, plan.getBlueprint())).toList()); - model.setCreatedAt(Date.from(dmp.getCreatedAt())); - model.setModifiedAt(Date.from(dmp.getUpdatedAt())); - model.setFinalizedAt(Date.from(dmp.getFinalizedAt())); + model.setCreatedAt(Date.from(plan.getCreatedAt())); + model.setModifiedAt(Date.from(plan.getUpdatedAt())); + model.setFinalizedAt(Date.from(plan.getFinalizedAt())); return model; } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/ActionConfirmationPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/ActionConfirmationPersist.java index ed62e9f83..79e611c0a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/ActionConfirmationPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/ActionConfirmationPersist.java @@ -7,7 +7,7 @@ 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.actionconfirmation.DmpInvitationPersist; +import org.opencdmp.model.persist.actionconfirmation.PlanInvitationPersist; import org.opencdmp.model.persist.actionconfirmation.MergeAccountConfirmationPersist; import org.opencdmp.model.persist.actionconfirmation.RemoveCredentialRequestPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -37,9 +37,9 @@ public class ActionConfirmationPersist { private static final String _token = "token"; - private DmpInvitationPersist dmpInvitation; + private PlanInvitationPersist planInvitation; - private static final String _dmpInvitation = "dmpInvitation"; + private static final String _planInvitation = "planInvitation"; private MergeAccountConfirmationPersist mergeAccountConfirmation; @@ -85,12 +85,12 @@ public class ActionConfirmationPersist { this.status = status; } - public DmpInvitationPersist getDmpInvitation() { - return dmpInvitation; + public PlanInvitationPersist getPlanInvitation() { + return planInvitation; } - public void setDmpInvitation(DmpInvitationPersist dmpInvitation) { - this.dmpInvitation = dmpInvitation; + public void setPlanInvitation(PlanInvitationPersist planInvitation) { + this.planInvitation = planInvitation; } public MergeAccountConfirmationPersist getMergeAccountConfirmation() { @@ -191,9 +191,9 @@ public class ActionConfirmationPersist { .must(() -> !this.isNull(item.getMergeAccountConfirmation())) .failOn(ActionConfirmationPersist._mergeAccountConfirmation).failWith(messageSource.getMessage("Validation_Required", new Object[]{ActionConfirmationPersist._mergeAccountConfirmation}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> ActionConfirmationType.DmpInvitation.equals(item.getType())) - .must(() -> !this.isNull(item.getDmpInvitation())) - .failOn(ActionConfirmationPersist._dmpInvitation).failWith(messageSource.getMessage("Validation_Required", new Object[]{ActionConfirmationPersist._dmpInvitation}, LocaleContextHolder.getLocale())), + .iff(() -> ActionConfirmationType.PlanInvitation.equals(item.getType())) + .must(() -> !this.isNull(item.getPlanInvitation())) + .failOn(ActionConfirmationPersist._planInvitation).failWith(messageSource.getMessage("Validation_Required", new Object[]{ActionConfirmationPersist._planInvitation}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> ActionConfirmationType.RemoveCredential.equals(item.getType())) .must(() -> !this.isNull(item.getRemoveCredentialRequest())) @@ -203,10 +203,10 @@ public class ActionConfirmationPersist { .must(() -> !this.isNull(item.getUserInviteToTenantRequest())) .failOn(ActionConfirmationPersist._userInviteToTenantRequest).failWith(messageSource.getMessage("Validation_Required", new Object[]{ActionConfirmationPersist._userInviteToTenantRequest}, LocaleContextHolder.getLocale())), this.refSpec() - .iff(() -> !this.isNull(item.getDmpInvitation())) - .on(ActionConfirmationPersist._dmpInvitation) - .over(item.getDmpInvitation()) - .using(() -> this.validatorFactory.validator(DmpInvitationPersist.DmpInvitationPersistValidator.class)), + .iff(() -> !this.isNull(item.getPlanInvitation())) + .on(ActionConfirmationPersist._planInvitation) + .over(item.getPlanInvitation()) + .using(() -> this.validatorFactory.validator(PlanInvitationPersist.PlanInvitationPersistValidator.class)), this.refSpec() .iff(() -> !this.isNull(item.getMergeAccountConfirmation())) .on(ActionConfirmationPersist._mergeAccountConfirmation) diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/CloneDmpPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/ClonePlanPersist.java similarity index 66% rename from backend/core/src/main/java/org/opencdmp/model/persist/CloneDmpPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/ClonePlanPersist.java index 957485c6c..26848e8cc 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/CloneDmpPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/ClonePlanPersist.java @@ -15,7 +15,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class CloneDmpPersist { +public class ClonePlanPersist { private UUID id = null; @@ -65,36 +65,36 @@ public class CloneDmpPersist { this.descriptions = descriptions; } - @Component(CloneDmpPersistValidator.ValidatorName) + @Component(ClonePlanPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class CloneDmpPersistValidator extends BaseValidator { + public static class ClonePlanPersistValidator extends BaseValidator { - public static final String ValidatorName = "CloneDmpPersistValidator"; + public static final String ValidatorName = "ClonePlanPersistValidator"; private final MessageSource messageSource; - protected CloneDmpPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + protected ClonePlanPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { super(conventionService, errors); this.messageSource = messageSource; } @Override - protected Class modelClass() { - return CloneDmpPersist.class; + protected Class modelClass() { + return ClonePlanPersist.class; } @Override - protected List specifications(CloneDmpPersist item) { + protected List specifications(ClonePlanPersist item) { return Arrays.asList( this.spec() .must(() -> this.isValidGuid(item.getId())) - .failOn(CloneDmpPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._id}, LocaleContextHolder.getLocale())), + .failOn(ClonePlanPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{ClonePlanPersist._id}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(CloneDmpPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._label}, LocaleContextHolder.getLocale())), + .failOn(ClonePlanPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ClonePlanPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getDescription())) - .failOn(CloneDmpPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._description}, LocaleContextHolder.getLocale())) + .failOn(ClonePlanPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{ClonePlanPersist._description}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java index b37bb69ec..8d83fb872 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java @@ -8,14 +8,14 @@ import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity; -import org.opencdmp.commons.types.dmpblueprint.SectionEntity; +import org.opencdmp.commons.types.planblueprint.SectionEntity; import org.opencdmp.commons.validation.BaseValidator; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.*; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.model.persist.descriptionproperties.PropertyDefinitionPersist; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; +import org.opencdmp.query.PlanDescriptionTemplateQuery; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -35,13 +35,13 @@ public class DescriptionPersist { public static final String _label = "label"; - private UUID dmpId; + private UUID planId; - public static final String _dmpId = "dmpId"; + public static final String _planId = "planId"; - private UUID dmpDescriptionTemplateId; + private UUID planDescriptionTemplateId; - public static final String _dmpDescriptionTemplateId = "dmpDescriptionTemplateId"; + public static final String _planDescriptionTemplateId = "planDescriptionTemplateId"; private UUID descriptionTemplateId; @@ -82,20 +82,20 @@ public class DescriptionPersist { this.label = label; } - public UUID getDmpId() { - return this.dmpId; + public UUID getPlanId() { + return this.planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } - public UUID getDmpDescriptionTemplateId() { - return this.dmpDescriptionTemplateId; + public UUID getPlanDescriptionTemplateId() { + return this.planDescriptionTemplateId; } - public void setDmpDescriptionTemplateId(UUID dmpDescriptionTemplateId) { - this.dmpDescriptionTemplateId = dmpDescriptionTemplateId; + public void setPlanDescriptionTemplateId(UUID planDescriptionTemplateId) { + this.planDescriptionTemplateId = planDescriptionTemplateId; } public DescriptionStatus getStatus() { @@ -177,18 +177,18 @@ public class DescriptionPersist { @Override protected List specifications(DescriptionPersist item) { DescriptionTemplateEntity descriptionTemplate = null; - DmpEntity dmpEntity = null; - DmpBlueprintEntity dmpBlueprintEntity = null; + PlanEntity planEntity = null; + PlanBlueprintEntity planBlueprintEntity = null; try { descriptionTemplate = this.isValidGuid(item.getDescriptionTemplateId()) ? this.entityManager.find(DescriptionTemplateEntity.class, item.getDescriptionTemplateId(), true) : null; - dmpEntity = this.isValidGuid(item.getDmpId()) ? this.entityManager.find(DmpEntity.class, item.getDmpId(), true) : null; - dmpBlueprintEntity = dmpEntity == null ? null : this.entityManager.find(DmpBlueprintEntity.class, dmpEntity.getBlueprintId()); + planEntity = this.isValidGuid(item.getPlanId()) ? this.entityManager.find(PlanEntity.class, item.getPlanId(), true) : null; + planBlueprintEntity = planEntity == null ? null : this.entityManager.find(PlanBlueprintEntity.class, planEntity.getBlueprintId()); } catch (InvalidApplicationException e) { throw new RuntimeException(e); } DefinitionEntity definition = descriptionTemplate == null ? null : this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, descriptionTemplate.getDefinition()); - DmpBlueprintEntity finalDmpBlueprintEntity = dmpBlueprintEntity; + PlanBlueprintEntity finalPlanBlueprintEntity = planBlueprintEntity; return Arrays.asList( this.spec() .iff(() -> this.isValidGuid(item.getId())) @@ -206,14 +206,14 @@ public class DescriptionPersist { .must(() -> this.lessEqualLength(item.getLabel(), DescriptionEntity._labelLength)) .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(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpId}, LocaleContextHolder.getLocale())), + .must(() -> this.isValidGuid(item.getPlanId())) + .failOn(DescriptionPersist._planId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._planId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getDescriptionTemplateId())) .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(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpDescriptionTemplateId}, LocaleContextHolder.getLocale())), + .must(() -> this.isValidGuid(item.getPlanDescriptionTemplateId())) + .failOn(DescriptionPersist._planDescriptionTemplateId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._planDescriptionTemplateId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getStatus())) .failOn(DescriptionPersist._status).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._status}, LocaleContextHolder.getLocale())), @@ -222,7 +222,7 @@ public class DescriptionPersist { .must(() -> !this.isNull(item.getProperties())) .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()))) + .must(() -> this.isDescriptionTemplateMaxMultiplicityValid(finalPlanBlueprintEntity, item.getPlanId(), item.getPlanDescriptionTemplateId(), this.isValidGuid(item.getId()))) .failOn(DescriptionPersist._descriptionTemplateId).failWith(this.messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicity", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> item.getStatus() == DescriptionStatus.Finalized) @@ -237,25 +237,25 @@ public class DescriptionPersist { ); } - private boolean isDescriptionTemplateMaxMultiplicityValid(DmpBlueprintEntity dmpBlueprintEntity, UUID dmpId, UUID dmpDescriptionTemplateId, Boolean isUpdate){ - org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); + private boolean isDescriptionTemplateMaxMultiplicityValid(PlanBlueprintEntity planBlueprintEntity, UUID planId, UUID planDescriptionTemplateId, Boolean isUpdate){ + org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition()); if (definition == null || this.isListNullOrEmpty(definition.getSections())) return true; - DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(dmpDescriptionTemplateId).isActive(IsActive.Active).dmpIds(dmpId).first(); - if (dmpDescriptionTemplateEntity == null) return true; + PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(planDescriptionTemplateId).isActive(IsActive.Active).planIds(planId).first(); + if (planDescriptionTemplateEntity == null) return true; - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).dmpIds(dmpId).dmpDescriptionTemplateIds(dmpDescriptionTemplateId).isActive(IsActive.Active).collect(); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect(); for (SectionEntity section: definition.getSections()) { - if (dmpDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ + if (planDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ int descriptionsCount; if (isUpdate) descriptionsCount = -1; else descriptionsCount = 0; - for (org.opencdmp.commons.types.dmpblueprint.DescriptionTemplateEntity sectionDescriptionTemplate: section.getDescriptionTemplates()) { - if (sectionDescriptionTemplate.getDescriptionTemplateGroupId().equals(dmpDescriptionTemplateEntity.getDescriptionTemplateGroupId())){ + for (org.opencdmp.commons.types.planblueprint.DescriptionTemplateEntity sectionDescriptionTemplate: section.getDescriptionTemplates()) { + if (sectionDescriptionTemplate.getDescriptionTemplateGroupId().equals(planDescriptionTemplateEntity.getDescriptionTemplateGroupId())){ for (DescriptionEntity description: descriptionEntities){ - if (description.getDmpDescriptionTemplateId().equals(dmpDescriptionTemplateEntity.getId())) descriptionsCount++; + if (description.getPlanDescriptionTemplateId().equals(planDescriptionTemplateEntity.getId())) descriptionsCount++; } if (sectionDescriptionTemplate.getMaxMultiplicity() != null && sectionDescriptionTemplate.getMaxMultiplicity() <= descriptionsCount) return false; } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionReferencePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionReferencePersist.java index 6a4633c81..1a916cd32 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionReferencePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionReferencePersist.java @@ -6,7 +6,7 @@ import org.opencdmp.commons.validation.BaseValidator; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.model.persist.descriptionreference.DescriptionReferenceDataPersist; -import org.opencdmp.model.persist.dmpreference.DmpReferenceDataPersist; +import org.opencdmp.model.persist.planreference.PlanReferenceDataPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -83,7 +83,7 @@ public class DescriptionReferencePersist { .iff(() -> !this.isNull(item.getData())) .on(DescriptionReferencePersist._data) .over(item.getData()) - .using(() -> this.validatorFactory.validator(DmpReferenceDataPersist.DmpReferenceDataPersistValidator.class)) + .using(() -> this.validatorFactory.validator(PlanReferenceDataPersist.PlanReferenceDataPersistValidator.class)) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionSectionPermissionResolver.java b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionSectionPermissionResolver.java index c1520635f..fbc49fd44 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionSectionPermissionResolver.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionSectionPermissionResolver.java @@ -16,8 +16,8 @@ import java.util.UUID; public class DescriptionSectionPermissionResolver { - private UUID dmpId; - public static final String _dmpId = "dmpId"; + private UUID planId; + public static final String _planId = "planId"; private List sectionIds; @@ -27,12 +27,12 @@ public class DescriptionSectionPermissionResolver { public static final String _permissions = "permissions"; - public UUID getDmpId() { - return dmpId; + public UUID getPlanId() { + return planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } public List getSectionIds() { @@ -73,8 +73,8 @@ public class DescriptionSectionPermissionResolver { protected List specifications(DescriptionSectionPermissionResolver item) { return Arrays.asList( this.spec() - .must(() -> this.isValidGuid(item.getDmpId())) - .failOn(DescriptionSectionPermissionResolver._dmpId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionSectionPermissionResolver._dmpId}, LocaleContextHolder.getLocale())), + .must(() -> this.isValidGuid(item.getPlanId())) + .failOn(DescriptionSectionPermissionResolver._planId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionSectionPermissionResolver._planId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> item.getPermissions() != null && !item.getPermissions().isEmpty()) .failOn(DescriptionSectionPermissionResolver._permissions).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionSectionPermissionResolver._permissions}, LocaleContextHolder.getLocale())), diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionTemplateTypePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionTemplateTypePersist.java index 2ae65d4e2..d3d0b0dd0 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionTemplateTypePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionTemplateTypePersist.java @@ -4,9 +4,6 @@ package org.opencdmp.model.persist; import org.opencdmp.commons.enums.DescriptionTemplateTypeStatus; import org.opencdmp.commons.validation.*; -import org.opencdmp.model.persist.dmpproperties.DmpBlueprintValuePersist; -import org.opencdmp.model.persist.dmpproperties.DmpPropertiesPersist; -import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.DescriptionTemplateTypeEntity; diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpBlueprintPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanBlueprintPersist.java similarity index 59% rename from backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpBlueprintPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanBlueprintPersist.java index a20ca5c81..b2f21a00c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpBlueprintPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanBlueprintPersist.java @@ -2,10 +2,10 @@ package org.opencdmp.model.persist; import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; -import org.opencdmp.commons.enums.DmpBlueprintStatus; +import org.opencdmp.commons.enums.PlanBlueprintStatus; import org.opencdmp.commons.validation.BaseValidator; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.data.PlanBlueprintEntity; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.model.persist.dmpblueprintdefinition.DefinitionPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -18,7 +18,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class NewVersionDmpBlueprintPersist { +public class NewVersionPlanBlueprintPersist { private UUID id; @@ -30,7 +30,7 @@ public class NewVersionDmpBlueprintPersist { public static final String _definition = "definition"; - private DmpBlueprintStatus status; + private PlanBlueprintStatus status; public static final String _status = "status"; @@ -62,11 +62,11 @@ public class NewVersionDmpBlueprintPersist { this.definition = definition; } - public DmpBlueprintStatus getStatus() { + public PlanBlueprintStatus getStatus() { return this.status; } - public void setStatus(DmpBlueprintStatus status) { + public void setStatus(PlanBlueprintStatus status) { this.status = status; } @@ -78,51 +78,51 @@ public class NewVersionDmpBlueprintPersist { this.hash = hash; } - @Component(NewVersionDmpBlueprintPersistValidator.ValidatorName) + @Component(NewVersionPlanBlueprintPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class NewVersionDmpBlueprintPersistValidator extends BaseValidator { + public static class NewVersionPlanBlueprintPersistValidator extends BaseValidator { - public static final String ValidatorName = "NewVersionDmpBlueprintPersistValidator"; + public static final String ValidatorName = "NewVersionPlanBlueprintPersistValidator"; private final MessageSource messageSource; private final ValidatorFactory validatorFactory; - public NewVersionDmpBlueprintPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + public NewVersionPlanBlueprintPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; } @Override - protected Class modelClass() { - return NewVersionDmpBlueprintPersist.class; + protected Class modelClass() { + return NewVersionPlanBlueprintPersist.class; } @Override - protected List specifications(NewVersionDmpBlueprintPersist item) { + protected List specifications(NewVersionPlanBlueprintPersist item) { return Arrays.asList( this.spec() .iff(() -> this.isValidGuid(item.getId())) .must(() -> this.isValidHash(item.getHash())) - .failOn(NewVersionDmpBlueprintPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpBlueprintPersist._hash}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanBlueprintPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanBlueprintPersist._hash}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(NewVersionDmpBlueprintPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpBlueprintPersist._label}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanBlueprintPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanBlueprintPersist._label}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getLabel())) - .must(() -> this.lessEqualLength(item.getLabel(), DmpBlueprintEntity._labelLength)) - .failOn(NewVersionDmpBlueprintPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionDmpBlueprintPersist._label}, LocaleContextHolder.getLocale())), + .must(() -> this.lessEqualLength(item.getLabel(), PlanBlueprintEntity._labelLength)) + .failOn(NewVersionPlanBlueprintPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionPlanBlueprintPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getStatus())) - .failOn(NewVersionDmpBlueprintPersist._status).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpBlueprintPersist._status}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanBlueprintPersist._status).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanBlueprintPersist._status}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getDefinition())) - .failOn(NewVersionDmpBlueprintPersist._definition).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpBlueprintPersist._definition}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanBlueprintPersist._definition).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanBlueprintPersist._definition}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> !this.isNull(item.getDefinition())) - .on(NewVersionDmpBlueprintPersist._definition) + .on(NewVersionPlanBlueprintPersist._definition) .over(item.getDefinition()) .using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)) ); diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpDescriptionPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanDescriptionPersist.java similarity index 58% rename from backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpDescriptionPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanDescriptionPersist.java index f20b9c02f..a80059b18 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpDescriptionPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanDescriptionPersist.java @@ -14,7 +14,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class NewVersionDmpDescriptionPersist { +public class NewVersionPlanDescriptionPersist { private UUID descriptionId; public static final String _descriptionId = "descriptionId"; @@ -39,33 +39,33 @@ public class NewVersionDmpDescriptionPersist { this.blueprintSectionId = blueprintSectionId; } - @Component(NewVersionDmpDescriptionPersist.NewVersionDmpDescriptionPersistValidator.ValidatorName) + @Component(NewVersionPlanDescriptionPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class NewVersionDmpDescriptionPersistValidator extends BaseValidator { + public static class NewVersionPlanDescriptionPersistValidator extends BaseValidator { - public static final String ValidatorName = "NewVersionDmpDescriptionPersistValidator"; + public static final String ValidatorName = "NewVersionPlanDescriptionPersistValidator"; private final MessageSource messageSource; - protected NewVersionDmpDescriptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + protected NewVersionPlanDescriptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { super(conventionService, errors); this.messageSource = messageSource; } @Override - protected Class modelClass() { - return NewVersionDmpDescriptionPersist.class; + protected Class modelClass() { + return NewVersionPlanDescriptionPersist.class; } @Override - protected List specifications(NewVersionDmpDescriptionPersist item) { + protected List specifications(NewVersionPlanDescriptionPersist item) { return Arrays.asList( this.spec() .must(() -> this.isValidGuid(item.getDescriptionId())) - .failOn(NewVersionDmpDescriptionPersist._descriptionId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpDescriptionPersist._descriptionId}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanDescriptionPersist._descriptionId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanDescriptionPersist._descriptionId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getBlueprintSectionId())) - .failOn(NewVersionDmpDescriptionPersist._blueprintSectionId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpDescriptionPersist._blueprintSectionId}, LocaleContextHolder.getLocale())) + .failOn(NewVersionPlanDescriptionPersist._blueprintSectionId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanDescriptionPersist._blueprintSectionId}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanPersist.java similarity index 61% rename from backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanPersist.java index 5bdf7639c..f39a2accb 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionPlanPersist.java @@ -4,7 +4,7 @@ import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.commons.validation.BaseValidator; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; @@ -16,7 +16,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class NewVersionDmpPersist { +public class NewVersionPlanPersist { private UUID id; public static final String _id = "id"; @@ -33,7 +33,7 @@ public class NewVersionDmpPersist { public static final String _blueprintId = "blueprintId"; - private List descriptions; + private List descriptions; public static final String _descriptions = "descriptions"; @@ -73,11 +73,11 @@ public class NewVersionDmpPersist { this.blueprintId = blueprintId; } - public List getDescriptions() { + public List getDescriptions() { return descriptions; } - public void setDescriptions(List descriptions) { + public void setDescriptions(List descriptions) { this.descriptions = descriptions; } @@ -89,51 +89,51 @@ public class NewVersionDmpPersist { this.hash = hash; } - @Component(NewVersionDmpPersist.NewVersionDmpPersistValidator.ValidatorName) + @Component(NewVersionPlanPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class NewVersionDmpPersistValidator extends BaseValidator { + public static class NewVersionPlanPersistValidator extends BaseValidator { - public static final String ValidatorName = "NewVersionDmpPersistValidator"; + public static final String ValidatorName = "NewVersionPlanPersistValidator"; private final MessageSource messageSource; private final ValidatorFactory validatorFactory; - protected NewVersionDmpPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + protected NewVersionPlanPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; } @Override - protected Class modelClass() { - return NewVersionDmpPersist.class; + protected Class modelClass() { + return NewVersionPlanPersist.class; } @Override - protected List specifications(NewVersionDmpPersist item) { + protected List specifications(NewVersionPlanPersist item) { return Arrays.asList( this.spec() .iff(() -> this.isValidGuid(item.getId())) .must(() -> this.isValidHash(item.getHash())) - .failOn(NewVersionDmpPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._hash}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanPersist._hash}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(NewVersionDmpPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanPersist._label}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getLabel())) - .must(() -> this.lessEqualLength(item.getLabel(), DmpEntity._labelLength)) - .failOn(NewVersionDmpPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())), + .must(() -> this.lessEqualLength(item.getLabel(), PlanEntity._labelLength)) + .failOn(NewVersionPlanPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionPlanPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getDescription())) - .failOn(NewVersionDmpPersist._description).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._description}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanPersist._description).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanPersist._description}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getBlueprintId())) - .failOn(NewVersionDmpPersist._blueprintId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._blueprintId}, LocaleContextHolder.getLocale())), + .failOn(NewVersionPlanPersist._blueprintId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionPlanPersist._blueprintId}, LocaleContextHolder.getLocale())), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getDescriptions())) - .on(NewVersionDmpPersist._descriptions) + .on(NewVersionPlanPersist._descriptions) .over(item.getDescriptions()) - .using((itm) -> this.validatorFactory.validator(NewVersionDmpDescriptionPersist.NewVersionDmpDescriptionPersistValidator.class)) + .using((itm) -> this.validatorFactory.validator(NewVersionPlanDescriptionPersist.NewVersionPlanDescriptionPersistValidator.class)) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpBlueprintPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanBlueprintPersist.java similarity index 61% rename from backend/core/src/main/java/org/opencdmp/model/persist/DmpBlueprintPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/PlanBlueprintPersist.java index deae9dff1..cafb76201 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpBlueprintPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanBlueprintPersist.java @@ -1,11 +1,11 @@ package org.opencdmp.model.persist; -import org.opencdmp.commons.enums.DmpBlueprintStatus; +import org.opencdmp.commons.enums.PlanBlueprintStatus; import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.data.PlanBlueprintEntity; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.model.persist.dmpblueprintdefinition.DefinitionPersist; import jakarta.validation.constraints.Size; @@ -19,13 +19,13 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class DmpBlueprintPersist { +public class PlanBlueprintPersist { private UUID id; public static final String _id = "id"; - @Size(max = DmpBlueprintEntity._labelLength, message = "{validation.largerthanmax}") + @Size(max = PlanBlueprintEntity._labelLength, message = "{validation.largerthanmax}") private String label = null; public static final String _label = "label"; @@ -34,7 +34,7 @@ public class DmpBlueprintPersist { public static final String _definition = "definition"; - private DmpBlueprintStatus status; + private PlanBlueprintStatus status; public static final String _status = "status"; @@ -66,11 +66,11 @@ public class DmpBlueprintPersist { this.definition = definition; } - public DmpBlueprintStatus getStatus() { + public PlanBlueprintStatus getStatus() { return status; } - public void setStatus(DmpBlueprintStatus status) { + public void setStatus(PlanBlueprintStatus status) { this.status = status; } @@ -82,56 +82,56 @@ public class DmpBlueprintPersist { this.hash = hash; } - @Component(DmpBlueprintPersistValidator.ValidatorName) + @Component(PlanBlueprintPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpBlueprintPersistValidator extends BaseValidator { + public static class PlanBlueprintPersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpBlueprintPersistValidator"; + public static final String ValidatorName = "PlanBlueprintPersistValidator"; private final MessageSource messageSource; private final ValidatorFactory validatorFactory; - protected DmpBlueprintPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + protected PlanBlueprintPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; } @Override - protected Class modelClass() { - return DmpBlueprintPersist.class; + protected Class modelClass() { + return PlanBlueprintPersist.class; } @Override - protected List specifications(DmpBlueprintPersist item) { + protected List specifications(PlanBlueprintPersist item) { return Arrays.asList( this.spec() .iff(() -> this.isValidGuid(item.getId())) .must(() -> this.isValidHash(item.getHash())) - .failOn(DmpBlueprintPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintPersist._hash}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanBlueprintPersist._hash}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isValidGuid(item.getId())) .must(() -> !this.isValidHash(item.getHash())) - .failOn(DmpBlueprintPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(DmpBlueprintPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintPersist._label}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanBlueprintPersist._label}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getLabel())) - .must(() -> this.lessEqualLength(item.getLabel(), DmpBlueprintEntity._labelLength)) - .failOn(DmpBlueprintPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DmpBlueprintPersist._label}, LocaleContextHolder.getLocale())), + .must(() -> this.lessEqualLength(item.getLabel(), PlanBlueprintEntity._labelLength)) + .failOn(PlanBlueprintPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{PlanBlueprintPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getStatus())) - .failOn(DmpBlueprintPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintPersist._status}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanBlueprintPersist._status}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> item.getStatus() == DmpBlueprintStatus.Finalized) + .iff(() -> item.getStatus() == PlanBlueprintStatus.Finalized) .must(() -> !this.isNull(item.getDefinition())) - .failOn(DmpBlueprintPersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintPersist._definition}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintPersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanBlueprintPersist._definition}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> !this.isNull(item.getDefinition())) - .on(DmpBlueprintPersist._definition) + .on(PlanBlueprintPersist._definition) .over(item.getDefinition()) .using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)) ); diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpCommonModelConfig.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanCommonModelConfig.java similarity index 64% rename from backend/core/src/main/java/org/opencdmp/model/persist/DmpCommonModelConfig.java rename to backend/core/src/main/java/org/opencdmp/model/persist/PlanCommonModelConfig.java index e7f26a78f..a832db041 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpCommonModelConfig.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanCommonModelConfig.java @@ -4,7 +4,7 @@ import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.commons.validation.BaseValidator; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; @@ -16,7 +16,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class DmpCommonModelConfig { +public class PlanCommonModelConfig { private UUID fileId; public static final String _fileId = "fileId"; @@ -73,52 +73,52 @@ public class DmpCommonModelConfig { this.descriptions = descriptions; } - @Component(DmpCommonModelConfigValidator.ValidatorName) + @Component(PlanCommonModelConfigValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpCommonModelConfigValidator extends BaseValidator { + public static class PlanCommonModelConfigValidator extends BaseValidator { - public static final String ValidatorName = "DmpCommonModelConfigValidator"; + public static final String ValidatorName = "PlanCommonModelConfigValidator"; private final MessageSource messageSource; private final ValidatorFactory validatorFactory; - protected DmpCommonModelConfigValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + protected PlanCommonModelConfigValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; } @Override - protected Class modelClass() { - return DmpCommonModelConfig.class; + protected Class modelClass() { + return PlanCommonModelConfig.class; } @Override - protected List specifications(DmpCommonModelConfig item) { + protected List specifications(PlanCommonModelConfig item) { return Arrays.asList( this.spec() .must(() -> this.isValidGuid(item.getFileId())) - .failOn(DmpCommonModelConfig._fileId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpCommonModelConfig._fileId}, LocaleContextHolder.getLocale())), + .failOn(PlanCommonModelConfig._fileId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanCommonModelConfig._fileId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(DmpCommonModelConfig._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpCommonModelConfig._label}, LocaleContextHolder.getLocale())), + .failOn(PlanCommonModelConfig._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanCommonModelConfig._label}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getLabel())) - .must(() -> this.lessEqualLength(item.getLabel(), DmpEntity._labelLength)) - .failOn(DmpCommonModelConfig._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{DmpCommonModelConfig._label}, LocaleContextHolder.getLocale())), + .must(() -> this.lessEqualLength(item.getLabel(), PlanEntity._labelLength)) + .failOn(PlanCommonModelConfig._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{PlanCommonModelConfig._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getRepositoryId())) - .failOn(DmpCommonModelConfig._repositoryId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpCommonModelConfig._repositoryId}, LocaleContextHolder.getLocale())), + .failOn(PlanCommonModelConfig._repositoryId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanCommonModelConfig._repositoryId}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getRepositoryId())) .must(() -> this.isValidGuid(UUID.fromString(item.getRepositoryId()))) - .failOn(DmpCommonModelConfig._repositoryId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpCommonModelConfig._repositoryId}, LocaleContextHolder.getLocale())), + .failOn(PlanCommonModelConfig._repositoryId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanCommonModelConfig._repositoryId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getBlueprintId())) - .failOn(DmpCommonModelConfig._blueprintId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpCommonModelConfig._blueprintId}, LocaleContextHolder.getLocale())), + .failOn(PlanCommonModelConfig._blueprintId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanCommonModelConfig._blueprintId}, LocaleContextHolder.getLocale())), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getDescriptions())) - .on(DmpCommonModelConfig._descriptions) + .on(PlanCommonModelConfig._descriptions) .over(item.getDescriptions()) .using((itm) -> this.validatorFactory.validator(DescriptionCommonModelConfig.DescriptionCommonModelConfigValidator.class)) ); diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpDescriptionTemplatePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanDescriptionTemplatePersist.java similarity index 58% rename from backend/core/src/main/java/org/opencdmp/model/persist/DmpDescriptionTemplatePersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/PlanDescriptionTemplatePersist.java index c70e08de1..8c7f70b81 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpDescriptionTemplatePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanDescriptionTemplatePersist.java @@ -1,6 +1,6 @@ package org.opencdmp.model.persist; -import org.opencdmp.commons.enums.DmpStatus; +import org.opencdmp.commons.enums.PlanStatus; import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; @@ -15,7 +15,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class DmpDescriptionTemplatePersist { +public class PlanDescriptionTemplatePersist { private UUID descriptionTemplateGroupId; @@ -41,35 +41,35 @@ public class DmpDescriptionTemplatePersist { this.sectionId = sectionId; } - @Component(DmpDescriptionTemplatePersistValidator.ValidatorName) + @Component(PlanDescriptionTemplatePersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpDescriptionTemplatePersistValidator extends BaseValidator { + public static class PlanDescriptionTemplatePersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpDescriptionTemplatePersistValidator"; + public static final String ValidatorName = "PlanDescriptionTemplatePersistValidator"; private final MessageSource messageSource; - private DmpStatus status; + private PlanStatus status; - protected DmpDescriptionTemplatePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + protected PlanDescriptionTemplatePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { super(conventionService, errors); this.messageSource = messageSource; } @Override - protected Class modelClass() { - return DmpDescriptionTemplatePersist.class; + protected Class modelClass() { + return PlanDescriptionTemplatePersist.class; } @Override - protected List specifications(DmpDescriptionTemplatePersist item) { + protected List specifications(PlanDescriptionTemplatePersist item) { return Arrays.asList( this.spec() .must(() -> this.isValidGuid(item.getDescriptionTemplateGroupId())) - .failOn(DmpDescriptionTemplatePersist._descriptionTemplateGroupId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpDescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale())), + .failOn(PlanDescriptionTemplatePersist._descriptionTemplateGroupId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanDescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getSectionId())) - .failOn(DmpDescriptionTemplatePersist._sectionId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpDescriptionTemplatePersist._sectionId}, LocaleContextHolder.getLocale())) + .failOn(PlanDescriptionTemplatePersist._sectionId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanDescriptionTemplatePersist._sectionId}, LocaleContextHolder.getLocale())) ); } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanPersist.java similarity index 56% rename from backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/PlanPersist.java index 25d017c57..96d556118 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanPersist.java @@ -6,17 +6,17 @@ import gr.cite.tools.validation.specification.Specification; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.enums.*; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; -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.types.planblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.FieldEntity; +import org.opencdmp.commons.types.planblueprint.SectionEntity; +import org.opencdmp.commons.types.planblueprint.SystemFieldEntity; import org.opencdmp.commons.validation.BaseValidator; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.*; import org.opencdmp.errorcode.ErrorThesaurusProperties; -import org.opencdmp.model.persist.dmpproperties.DmpPropertiesPersist; +import org.opencdmp.model.persist.planproperties.PlanPropertiesPersist; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; +import org.opencdmp.query.PlanDescriptionTemplateQuery; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -29,7 +29,7 @@ import java.util.List; import java.util.UUID; import java.util.stream.Collectors; -public class DmpPersist { +public class PlanPersist { private UUID id; @@ -37,11 +37,11 @@ public class DmpPersist { public static final String _label = "label"; - private DmpStatus status; + private PlanStatus status; public static final String _status = "status"; - private DmpPropertiesPersist properties; + private PlanPropertiesPersist properties; public static final String _properties = "properties"; @@ -55,18 +55,18 @@ public class DmpPersist { public static final String _blueprint = "blueprint"; - private DmpAccessType accessType; + private PlanAccessType accessType; public static final String _accessType = "accessType"; // private List references; // // public static final String _references = "references"; - private List descriptionTemplates; + private List descriptionTemplates; public static final String _descriptionTemplates = "descriptionTemplates"; - private List users; + private List users; public static final String _users = "users"; private String hash; @@ -89,19 +89,19 @@ public class DmpPersist { this.label = label; } - public DmpStatus getStatus() { + public PlanStatus getStatus() { return this.status; } - public void setStatus(DmpStatus status) { + public void setStatus(PlanStatus status) { this.status = status; } - public DmpPropertiesPersist getProperties() { + public PlanPropertiesPersist getProperties() { return this.properties; } - public void setProperties(DmpPropertiesPersist properties) { + public void setProperties(PlanPropertiesPersist properties) { this.properties = properties; } @@ -129,27 +129,27 @@ public class DmpPersist { this.blueprint = blueprint; } - public DmpAccessType getAccessType() { + public PlanAccessType getAccessType() { return this.accessType; } - public void setAccessType(DmpAccessType accessType) { + public void setAccessType(PlanAccessType accessType) { this.accessType = accessType; } - public List getDescriptionTemplates() { + public List getDescriptionTemplates() { return this.descriptionTemplates; } - public void setDescriptionTemplates(List descriptionTemplates) { + public void setDescriptionTemplates(List descriptionTemplates) { this.descriptionTemplates = descriptionTemplates; } - public List getUsers() { + public List getUsers() { return this.users; } - public void setUsers(List users) { + public void setUsers(List users) { this.users = users; } @@ -161,11 +161,11 @@ public class DmpPersist { this.hash = hash; } - @Component(DmpPersistValidator.ValidatorName) + @Component(PlanPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpPersistValidator extends BaseValidator { + public static class PlanPersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpPersistValidator"; + public static final String ValidatorName = "PlanPersistValidator"; private final MessageSource messageSource; @@ -174,7 +174,7 @@ public class DmpPersist { private final XmlHandlingService xmlHandlingService; private final QueryFactory queryFactory; - protected DmpPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory, TenantEntityManager entityManager, XmlHandlingService xmlHandlingService, QueryFactory queryFactory) { + protected PlanPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory, TenantEntityManager entityManager, XmlHandlingService xmlHandlingService, QueryFactory queryFactory) { super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; @@ -184,116 +184,116 @@ public class DmpPersist { } @Override - protected Class modelClass() { - return DmpPersist.class; + protected Class modelClass() { + return PlanPersist.class; } @Override - protected List specifications(DmpPersist item) { - DmpBlueprintEntity dmpBlueprintEntity = null; + protected List specifications(PlanPersist item) { + PlanBlueprintEntity planBlueprintEntity = null; try { - dmpBlueprintEntity = this.isValidGuid(item.getBlueprint()) ? this.entityManager.find(DmpBlueprintEntity.class, item.getBlueprint(), true) : null; + planBlueprintEntity = this.isValidGuid(item.getBlueprint()) ? this.entityManager.find(PlanBlueprintEntity.class, item.getBlueprint(), true) : null; } catch (InvalidApplicationException e) { throw new RuntimeException(e); } - DmpBlueprintEntity finalDmpBlueprintEntity = dmpBlueprintEntity; - DefinitionEntity definition = dmpBlueprintEntity == null ? null : this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); + PlanBlueprintEntity finalPlanBlueprintEntity = planBlueprintEntity; + DefinitionEntity definition = planBlueprintEntity == null ? null : this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, planBlueprintEntity.getDefinition()); String languageFieldLabel = null; String accessFieldLabel = null; if (definition != null){ - languageFieldLabel = this.getSystemFieldLabel(definition, DmpBlueprintSystemFieldType.Language); - accessFieldLabel = this.getSystemFieldLabel(definition, DmpBlueprintSystemFieldType.AccessRights); + languageFieldLabel = this.getSystemFieldLabel(definition, PlanBlueprintSystemFieldType.Language); + accessFieldLabel = this.getSystemFieldLabel(definition, PlanBlueprintSystemFieldType.AccessRights); } return Arrays.asList( this.spec() .iff(() -> this.isValidGuid(item.getId())) .must(() -> this.isValidHash(item.getHash())) - .failOn(DmpPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._hash}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._hash}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isValidGuid(item.getId())) .must(() -> !this.isValidHash(item.getHash())) - .failOn(DmpPersist._hash).failWith(this.messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._hash).failWith(this.messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(DmpPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._label}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._label}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getLabel())) - .must(() -> this.lessEqualLength(item.getLabel(), DmpEntity._labelLength)) - .failOn(DmpPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{DmpPersist._label}, LocaleContextHolder.getLocale())), + .must(() -> this.lessEqualLength(item.getLabel(), PlanEntity._labelLength)) + .failOn(PlanPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{PlanPersist._label}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> item.getStatus() == DmpStatus.Finalized) + .iff(() -> item.getStatus() == PlanStatus.Finalized) .must(() -> !this.isEmpty(item.getDescription())) - .failOn(DmpPersist._description).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._description}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._description).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._description}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getStatus())) - .failOn(DmpPersist._status).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._status}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._status).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._status}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> item.getStatus() == DmpStatus.Finalized) + .iff(() -> item.getStatus() == PlanStatus.Finalized) .must(() -> this.isValidGuid(item.getBlueprint())) - .failOn(DmpPersist._blueprint).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._blueprint}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._blueprint).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._blueprint}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> item.getStatus() == DmpStatus.Finalized) + .iff(() -> item.getStatus() == PlanStatus.Finalized) .must(() -> !this.isNull(item.getProperties())) - .failOn(DmpPersist._properties).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._properties}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._properties).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._properties}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> item.getStatus() == DmpStatus.Finalized) - .must(() -> this.isDescriptionTemplateMultiplicityValid(finalDmpBlueprintEntity, item.getId())) - .failOn(DmpPersist._descriptionTemplates).failWith(this.messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicityOnDMP", new Object[]{DmpPersist._descriptionTemplates}, LocaleContextHolder.getLocale())), + .iff(() -> item.getStatus() == PlanStatus.Finalized) + .must(() -> this.isDescriptionTemplateMultiplicityValid(finalPlanBlueprintEntity, item.getId())) + .failOn(PlanPersist._descriptionTemplates).failWith(this.messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicityOnDMP", new Object[]{PlanPersist._descriptionTemplates}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> !this.isNull(item.getProperties())) - .on(DmpPersist._properties) + .on(PlanPersist._properties) .over(item.getProperties()) - .using(() -> this.validatorFactory.validator(DmpPropertiesPersist.DmpPropertiesPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition)), + .using(() -> this.validatorFactory.validator(PlanPropertiesPersist.PlanPropertiesPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition)), this.spec() - .iff(() -> item.getStatus() == DmpStatus.Finalized) + .iff(() -> item.getStatus() == PlanStatus.Finalized) .must(() -> !this.isNull(item.getLanguage())) - .failOn(DmpPersist._language).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{languageFieldLabel != null ? languageFieldLabel : DmpBlueprintSystemFieldType.Language.name()}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._language).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{languageFieldLabel != null ? languageFieldLabel : PlanBlueprintSystemFieldType.Language.name()}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> item.getStatus() == DmpStatus.Finalized) + .iff(() -> item.getStatus() == PlanStatus.Finalized) .must(() -> !this.isNull(item.getAccessType())) - .failOn(DmpPersist._accessType).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{accessFieldLabel != null ? accessFieldLabel : DmpBlueprintSystemFieldType.AccessRights.name()}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._accessType).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{accessFieldLabel != null ? accessFieldLabel : PlanBlueprintSystemFieldType.AccessRights.name()}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> item.getStatus() == DmpStatus.Finalized) + .iff(() -> item.getStatus() == PlanStatus.Finalized) .must(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates())) - .failOn(DmpPersist._descriptionTemplates).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._descriptionTemplates}, LocaleContextHolder.getLocale())), + .failOn(PlanPersist._descriptionTemplates).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._descriptionTemplates}, LocaleContextHolder.getLocale())), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates())) - .on(DmpPersist._descriptionTemplates) + .on(PlanPersist._descriptionTemplates) .over(item.getDescriptionTemplates()) - .using((itm) -> this.validatorFactory.validator(DmpDescriptionTemplatePersist.DmpDescriptionTemplatePersistValidator.class)), + .using((itm) -> this.validatorFactory.validator(PlanDescriptionTemplatePersist.PlanDescriptionTemplatePersistValidator.class)), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getUsers())) - .on(DmpPersist._users) + .on(PlanPersist._users) .over(item.getUsers()) - .using((itm) -> this.validatorFactory.validator(DmpUserPersist.DmpUserPersistValidator.class)) + .using((itm) -> this.validatorFactory.validator(PlanUserPersist.PlanUserPersistValidator.class)) ); } - private boolean isDescriptionTemplateMultiplicityValid(DmpBlueprintEntity dmpBlueprintEntity, UUID dmpId){ - org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); + private boolean isDescriptionTemplateMultiplicityValid(PlanBlueprintEntity planBlueprintEntity, UUID planId){ + org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition()); if (definition == null || this.isListNullOrEmpty(definition.getSections())) return true; - List dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).dmpIds(dmpId).collect(); - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).dmpIds(dmpId).isActive(IsActive.Active).collect(); + List planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).planIds(planId).collect(); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(planId).isActive(IsActive.Active).collect(); for (SectionEntity section: definition.getSections()) { if (section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ - for (org.opencdmp.commons.types.dmpblueprint.DescriptionTemplateEntity sectionDescriptionTemplate: section.getDescriptionTemplates()) { + for (org.opencdmp.commons.types.planblueprint.DescriptionTemplateEntity sectionDescriptionTemplate: section.getDescriptionTemplates()) { if (sectionDescriptionTemplate.getMaxMultiplicity() == null && sectionDescriptionTemplate.getMinMultiplicity() == null ) continue; int descriptionsCount = 0; - for (DmpDescriptionTemplateEntity dmpDescriptionTemplate: dmpDescriptionTemplateEntities) { + for (PlanDescriptionTemplateEntity planDescriptionTemplate: planDescriptionTemplateEntities) { - if(dmpDescriptionTemplate.getSectionId().equals(section.getId())) { + if(planDescriptionTemplate.getSectionId().equals(section.getId())) { for (DescriptionEntity description: descriptionEntities){ - if (sectionDescriptionTemplate.getDescriptionTemplateGroupId().equals(dmpDescriptionTemplate.getDescriptionTemplateGroupId())) { - if (description.getDmpDescriptionTemplateId().equals(dmpDescriptionTemplate.getId()) && dmpDescriptionTemplate.getSectionId().equals(section.getId())) + if (sectionDescriptionTemplate.getDescriptionTemplateGroupId().equals(planDescriptionTemplate.getDescriptionTemplateGroupId())) { + if (description.getPlanDescriptionTemplateId().equals(planDescriptionTemplate.getId()) && planDescriptionTemplate.getSectionId().equals(section.getId())) descriptionsCount++; } } @@ -310,12 +310,12 @@ public class DmpPersist { return true; } - private String getSystemFieldLabel(DefinitionEntity definition, DmpBlueprintSystemFieldType type){ + private String getSystemFieldLabel(DefinitionEntity definition, PlanBlueprintSystemFieldType type){ if (this.isListNullOrEmpty(definition.getSections())) return null; for (SectionEntity section: definition.getSections()) { if (!this.isListNullOrEmpty(section.getFields())) { - List fields = section.getFields().stream().filter(x -> x.getCategory().equals(DmpBlueprintFieldCategory.System)).collect(Collectors.toList()); + List fields = section.getFields().stream().filter(x -> x.getCategory().equals(PlanBlueprintFieldCategory.System)).collect(Collectors.toList()); if (!this.isListNullOrEmpty(fields)){ List systemFields = (List)(List) fields; diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpReferencePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanReferencePersist.java similarity index 59% rename from backend/core/src/main/java/org/opencdmp/model/persist/DmpReferencePersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/PlanReferencePersist.java index b834529b2..6140e60f0 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpReferencePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanReferencePersist.java @@ -5,7 +5,7 @@ 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.dmpreference.DmpReferenceDataPersist; +import org.opencdmp.model.persist.planreference.PlanReferenceDataPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -15,14 +15,14 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.List; -public class DmpReferencePersist { +public class PlanReferencePersist { private ReferencePersist reference; public static final String _reference = "reference"; - private DmpReferenceDataPersist data; + private PlanReferenceDataPersist data; public static final String _data = "data"; @@ -35,54 +35,54 @@ public class DmpReferencePersist { this.reference = reference; } - public DmpReferenceDataPersist getData() { + public PlanReferenceDataPersist getData() { return data; } - public void setData(DmpReferenceDataPersist data) { + public void setData(PlanReferenceDataPersist data) { this.data = data; } - @Component(DmpReferencePersistValidator.ValidatorName) + @Component(PlanReferencePersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpReferencePersistValidator extends BaseValidator { + public static class PlanReferencePersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpReferencePersistValidator"; + public static final String ValidatorName = "PlanReferencePersistValidator"; private final MessageSource messageSource; private final ValidatorFactory validatorFactory; - protected DmpReferencePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + protected PlanReferencePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; } @Override - protected Class modelClass() { - return DmpReferencePersist.class; + protected Class modelClass() { + return PlanReferencePersist.class; } @Override - protected List specifications(DmpReferencePersist item) { + protected List specifications(PlanReferencePersist item) { return Arrays.asList( this.spec() .must(() -> !this.isNull(item.getReference())) - .failOn(DmpReferencePersist._reference).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpReferencePersist._reference}, LocaleContextHolder.getLocale())), + .failOn(PlanReferencePersist._reference).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanReferencePersist._reference}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> !this.isNull(item.getReference())) - .on(DmpReferencePersist._reference) + .on(PlanReferencePersist._reference) .over(item.getReference()) .using(() -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class)), this.spec() .must(() -> !this.isNull(item.getData())) - .failOn(DmpReferencePersist._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpReferencePersist._data}, LocaleContextHolder.getLocale())), + .failOn(PlanReferencePersist._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanReferencePersist._data}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> !this.isNull(item.getData())) - .on(DmpReferencePersist._data) + .on(PlanReferencePersist._data) .over(item.getData()) - .using(() -> this.validatorFactory.validator(DmpReferenceDataPersist.DmpReferenceDataPersistValidator.class)) + .using(() -> this.validatorFactory.validator(PlanReferenceDataPersist.PlanReferenceDataPersistValidator.class)) ); } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserInvitePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanUserInvitePersist.java similarity index 57% rename from backend/core/src/main/java/org/opencdmp/model/persist/DmpUserInvitePersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/PlanUserInvitePersist.java index 96d0d2d1b..b1aabf745 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserInvitePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanUserInvitePersist.java @@ -14,52 +14,52 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.List; -public class DmpUserInvitePersist { +public class PlanUserInvitePersist { - private List users; + private List users; public static final String _users = "users"; - public List getUsers() { + public List getUsers() { return users; } - public void setUsers(List users) { + public void setUsers(List users) { this.users = users; } - @Component(DmpUserInvitePersistValidator.ValidatorName) + @Component(PlanUserInvitePersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpUserInvitePersistValidator extends BaseValidator { + public static class PlanUserInvitePersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpUserInvitePersistValidator"; + public static final String ValidatorName = "PlanUserInvitePersistValidator"; private final MessageSource messageSource; private final ValidatorFactory validatorFactory; - protected DmpUserInvitePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + protected PlanUserInvitePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; } @Override - protected Class modelClass() { - return DmpUserInvitePersist.class; + protected Class modelClass() { + return PlanUserInvitePersist.class; } @Override - protected List specifications(DmpUserInvitePersist item) { + protected List specifications(PlanUserInvitePersist item) { return Arrays.asList( this.spec() .must(() -> !this.isListNullOrEmpty(item.getUsers())) - .failOn(DmpUserInvitePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserInvitePersist._users}, LocaleContextHolder.getLocale())), + .failOn(PlanUserInvitePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanUserInvitePersist._users}, LocaleContextHolder.getLocale())), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getUsers())) - .on(DmpUserInvitePersist._users) + .on(PlanUserInvitePersist._users) .over(item.getUsers()) - .using((itm) -> this.validatorFactory.validator(DmpUserPersist.DmpUserPersistValidator.class)) + .using((itm) -> this.validatorFactory.validator(PlanUserPersist.PlanUserPersistValidator.class)) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanUserPersist.java similarity index 60% rename from backend/core/src/main/java/org/opencdmp/model/persist/DmpUserPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/PlanUserPersist.java index cbcca13c7..2f7051ac9 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanUserPersist.java @@ -1,11 +1,10 @@ package org.opencdmp.model.persist; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; -import org.opencdmp.model.persist.dmpproperties.DmpContactPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -16,7 +15,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class DmpUserPersist { +public class PlanUserPersist { private UUID user; @@ -28,7 +27,7 @@ public class DmpUserPersist { private UUID sectionId; public static final String _sectionId = "sectionId"; - private DmpUserRole role; + private PlanUserRole role; public static final String _role = "role"; @@ -56,54 +55,54 @@ public class DmpUserPersist { this.email = email; } - public DmpUserRole getRole() { + public PlanUserRole getRole() { return role; } - public void setRole(DmpUserRole role) { + public void setRole(PlanUserRole role) { this.role = role; } - @Component(DmpUserPersistValidator.ValidatorName) + @Component(PlanUserPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpUserPersistValidator extends BaseValidator { + public static class PlanUserPersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpUserPersistValidator"; + public static final String ValidatorName = "PlanUserPersistValidator"; private final MessageSource messageSource; - protected DmpUserPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + protected PlanUserPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { super(conventionService, errors); this.messageSource = messageSource; } @Override - protected Class modelClass() { - return DmpUserPersist.class; + protected Class modelClass() { + return PlanUserPersist.class; } @Override - protected List specifications(DmpUserPersist item) { + protected List specifications(PlanUserPersist item) { return Arrays.asList( this.spec() .iff(() -> this.isEmpty(item.getEmail())) .must(() -> this.isValidGuid(item.getUser())) - .failOn(DmpUserPersist._user).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserPersist._user}, LocaleContextHolder.getLocale())), + .failOn(PlanUserPersist._user).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanUserPersist._user}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isValidGuid(item.getUser())) .must(() -> !this.isEmpty(item.getEmail())) - .failOn(DmpUserPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserPersist._email}, LocaleContextHolder.getLocale())), + .failOn(PlanUserPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanUserPersist._email}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getRole())) - .failOn(DmpUserPersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserPersist._role}, LocaleContextHolder.getLocale())), + .failOn(PlanUserPersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanUserPersist._role}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isNull(item.getSectionId())) .must(() -> this.isValidGuid(item.getSectionId())) - .failOn(DmpUserPersist._sectionId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserPersist._sectionId}, LocaleContextHolder.getLocale())), + .failOn(PlanUserPersist._sectionId).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanUserPersist._sectionId}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getEmail())) .must(() -> this.isValidEmail(item.getEmail())) - .failOn(DmpUserPersist._email).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DmpUserPersist._email}, LocaleContextHolder.getLocale())) + .failOn(PlanUserPersist._email).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{PlanUserPersist._email}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserRemovePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanUserRemovePersist.java similarity index 51% rename from backend/core/src/main/java/org/opencdmp/model/persist/DmpUserRemovePersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/PlanUserRemovePersist.java index bcea7a86d..62617b8a0 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserRemovePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanUserRemovePersist.java @@ -1,6 +1,6 @@ package org.opencdmp.model.persist; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; @@ -15,17 +15,17 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class DmpUserRemovePersist { +public class PlanUserRemovePersist { private UUID id; public static final String _id = "id"; - private UUID dmpId; + private UUID planId; - public static final String _dmpId = "dmpId"; + public static final String _planId = "planId"; - private DmpUserRole role; + private PlanUserRole role; public static final String _role = "role"; @@ -37,52 +37,52 @@ public class DmpUserRemovePersist { this.id = id; } - public UUID getDmpId() { - return dmpId; + public UUID getPlanId() { + return planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } - public DmpUserRole getRole() { + public PlanUserRole getRole() { return role; } - public void setRole(DmpUserRole role) { + public void setRole(PlanUserRole role) { this.role = role; } - @Component(DmpUserRemovePersistValidator.ValidatorName) + @Component(PlanUserRemovePersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpUserRemovePersistValidator extends BaseValidator { + public static class PlanUserRemovePersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpUserRemovePersistValidator"; + public static final String ValidatorName = "PlanUserRemovePersistValidator"; private final MessageSource messageSource; - protected DmpUserRemovePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + protected PlanUserRemovePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { super(conventionService, errors); this.messageSource = messageSource; } @Override - protected Class modelClass() { - return DmpUserRemovePersist.class; + protected Class modelClass() { + return PlanUserRemovePersist.class; } @Override - protected List specifications(DmpUserRemovePersist item) { + protected List specifications(PlanUserRemovePersist item) { return Arrays.asList( this.spec() .must(() -> this.isValidGuid(item.getId())) - .failOn(DmpUserRemovePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserRemovePersist._id}, LocaleContextHolder.getLocale())), + .failOn(PlanUserRemovePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanUserRemovePersist._id}, LocaleContextHolder.getLocale())), this.spec() - .must(() -> this.isValidGuid(item.getDmpId())) - .failOn(DmpUserRemovePersist._dmpId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserRemovePersist._dmpId}, LocaleContextHolder.getLocale())), + .must(() -> this.isValidGuid(item.getPlanId())) + .failOn(PlanUserRemovePersist._planId).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanUserRemovePersist._planId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getRole())) - .failOn(DmpUserRemovePersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserRemovePersist._role}, LocaleContextHolder.getLocale())) + .failOn(PlanUserRemovePersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanUserRemovePersist._role}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/actionconfirmation/DmpInvitationPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/actionconfirmation/DmpInvitationPersist.java deleted file mode 100644 index fbb880c24..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/persist/actionconfirmation/DmpInvitationPersist.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.opencdmp.model.persist.actionconfirmation; - -import org.opencdmp.commons.enums.DmpUserRole; -import org.opencdmp.commons.validation.BaseValidator; -import gr.cite.tools.validation.specification.Specification; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.errorcode.ErrorThesaurusProperties; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Scope; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.stereotype.Component; - -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - -public class DmpInvitationPersist { - - private String email; - - public static final String _email = "email"; - - private UUID dmpId; - - public static final String _dmpId = "dmpId"; - - private DmpUserRole role; - - public static final String _role = "role"; - - public DmpInvitationPersist(String email, UUID dmpId, DmpUserRole role) { - this.email = email; - this.dmpId = dmpId; - this.role = role; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public UUID getDmpId() { - return dmpId; - } - - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; - } - - public DmpUserRole getRole() { - return role; - } - - public void setRole(DmpUserRole role) { - this.role = role; - } - - @Component(DmpInvitationPersistValidator.ValidatorName) - @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpInvitationPersistValidator extends BaseValidator { - - public static final String ValidatorName = "DmpInvitationPersistValidator"; - - private final MessageSource messageSource; - - protected DmpInvitationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { - super(conventionService, errors); - this.messageSource = messageSource; - } - - @Override - protected Class modelClass() { - return DmpInvitationPersist.class; - } - - @Override - protected List specifications(DmpInvitationPersist item) { - return Arrays.asList( - this.spec() - .must(() -> !this.isEmpty(item.getEmail())) - .failOn(DmpInvitationPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpInvitationPersist._email}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isNull(item.getDmpId())) - .failOn(DmpInvitationPersist._dmpId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpInvitationPersist._dmpId}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isNull(item.getRole())) - .failOn(DmpInvitationPersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpInvitationPersist._role}, LocaleContextHolder.getLocale())) - ); - } - } - -} diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/actionconfirmation/PlanInvitationPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/actionconfirmation/PlanInvitationPersist.java new file mode 100644 index 000000000..2b860e4ce --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/persist/actionconfirmation/PlanInvitationPersist.java @@ -0,0 +1,96 @@ +package org.opencdmp.model.persist.actionconfirmation; + +import org.opencdmp.commons.enums.PlanUserRole; +import org.opencdmp.commons.validation.BaseValidator; +import gr.cite.tools.validation.specification.Specification; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +public class PlanInvitationPersist { + + private String email; + + public static final String _email = "email"; + + private UUID planId; + + public static final String _planId = "planId"; + + private PlanUserRole role; + + public static final String _role = "role"; + + public PlanInvitationPersist(String email, UUID planId, PlanUserRole role) { + this.email = email; + this.planId = planId; + this.role = role; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public UUID getPlanId() { + return planId; + } + + public void setPlanId(UUID planId) { + this.planId = planId; + } + + public PlanUserRole getRole() { + return role; + } + + public void setRole(PlanUserRole role) { + this.role = role; + } + + @Component(PlanInvitationPersistValidator.ValidatorName) + @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class PlanInvitationPersistValidator extends BaseValidator { + + public static final String ValidatorName = "PlanInvitationPersistValidator"; + + private final MessageSource messageSource; + + protected PlanInvitationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return PlanInvitationPersist.class; + } + + @Override + protected List specifications(PlanInvitationPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getEmail())) + .failOn(PlanInvitationPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanInvitationPersist._email}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getPlanId())) + .failOn(PlanInvitationPersist._planId).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanInvitationPersist._planId}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getRole())) + .failOn(PlanInvitationPersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanInvitationPersist._role}, LocaleContextHolder.getLocale())) + ); + } + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/deposit/DepositRequest.java b/backend/core/src/main/java/org/opencdmp/model/persist/deposit/DepositRequest.java index 1bac49f6a..d2e258c71 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/deposit/DepositRequest.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/deposit/DepositRequest.java @@ -21,9 +21,9 @@ public class DepositRequest { public static final String _repositoryId = "repositoryId"; - private UUID dmpId; + private UUID planId; - public static final String _dmpId = "dmpId"; + public static final String _planId = "planId"; private String authorizationCode; @@ -37,12 +37,12 @@ public class DepositRequest { this.repositoryId = repositoryId; } - public UUID getDmpId() { - return this.dmpId; + public UUID getPlanId() { + return this.planId; } - public void setDmpId(UUID dmpId) { - this.dmpId = dmpId; + public void setPlanId(UUID planId) { + this.planId = planId; } public String getAuthorizationCode() { @@ -86,8 +86,8 @@ public class DepositRequest { .must(() -> !this.isEmpty(item.getRepositoryId())) .failOn(DepositRequest._repositoryId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DepositRequest._repositoryId}, LocaleContextHolder.getLocale())), this.spec() - .must(() -> this.isValidGuid(item.getDmpId())) - .failOn(DepositRequest._dmpId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DepositRequest._dmpId}, LocaleContextHolder.getLocale())) + .must(() -> this.isValidGuid(item.getPlanId())) + .failOn(DepositRequest._planId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DepositRequest._planId}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/ExtraFieldPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/ExtraFieldPersist.java index 81b86ba5f..4255192c7 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/ExtraFieldPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/ExtraFieldPersist.java @@ -1,6 +1,6 @@ package org.opencdmp.model.persist.dmpblueprintdefinition; -import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType; +import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; @@ -15,15 +15,15 @@ import java.util.List; public class ExtraFieldPersist extends FieldPersist { - private DmpBlueprintExtraFieldDataType dataType; + private PlanBlueprintExtraFieldDataType dataType; public static final String _dataType = "dataType"; - public DmpBlueprintExtraFieldDataType getDataType() { + public PlanBlueprintExtraFieldDataType getDataType() { return dataType; } - public void setDataType(DmpBlueprintExtraFieldDataType dataType) { + public void setDataType(PlanBlueprintExtraFieldDataType dataType) { this.dataType = dataType; } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/FieldPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/FieldPersist.java index 74707eefb..99f2905e8 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/FieldPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/FieldPersist.java @@ -2,7 +2,7 @@ package org.opencdmp.model.persist.dmpblueprintdefinition; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; @@ -31,7 +31,7 @@ public abstract class FieldPersist { public static final String _id = "id"; - private DmpBlueprintFieldCategory category; + private PlanBlueprintFieldCategory category; public static final String _category = "category"; @@ -64,11 +64,11 @@ public abstract class FieldPersist { this.id = id; } - public DmpBlueprintFieldCategory getCategory() { + public PlanBlueprintFieldCategory getCategory() { return category; } - public void setCategory(DmpBlueprintFieldCategory category) { + public void setCategory(PlanBlueprintFieldCategory category) { this.category = category; } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/SystemFieldPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/SystemFieldPersist.java index 4574e718f..a76e165bd 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/SystemFieldPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/dmpblueprintdefinition/SystemFieldPersist.java @@ -1,6 +1,6 @@ package org.opencdmp.model.persist.dmpblueprintdefinition; -import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType; +import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; @@ -11,19 +11,18 @@ import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Component; import java.util.List; -import java.util.UUID; public class SystemFieldPersist extends FieldPersist { - private DmpBlueprintSystemFieldType systemFieldType; + private PlanBlueprintSystemFieldType systemFieldType; public static final String _systemFieldType = "systemFieldType"; - public DmpBlueprintSystemFieldType getSystemFieldType() { + public PlanBlueprintSystemFieldType getSystemFieldType() { return systemFieldType; } - public void setSystemFieldType(DmpBlueprintSystemFieldType systemFieldType) { + public void setSystemFieldType(PlanBlueprintSystemFieldType systemFieldType) { this.systemFieldType = systemFieldType; } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpPropertiesPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpPropertiesPersist.java deleted file mode 100644 index 358ac2b15..000000000 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpPropertiesPersist.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.opencdmp.model.persist.dmpproperties; - -import gr.cite.tools.validation.ValidatorFactory; -import gr.cite.tools.validation.specification.Specification; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; -import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType; -import org.opencdmp.commons.enums.DmpStatus; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; -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.convention.ConventionService; -import org.opencdmp.errorcode.ErrorThesaurusProperties; -import org.opencdmp.model.persist.validation.StatusAware; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Scope; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.stereotype.Component; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; - -public class DmpPropertiesPersist { - - private Map dmpBlueprintValues; - - public static final String _dmpBlueprintValues = "dmpBlueprintValues"; - - private List contacts; - - public static final String _contacts = "contacts"; - - public Map getDmpBlueprintValues() { - return this.dmpBlueprintValues; - } - - public void setDmpBlueprintValues(Map dmpBlueprintValues) { - this.dmpBlueprintValues = dmpBlueprintValues; - } - - public List getContacts() { - return this.contacts; - } - - public void setContacts(List contacts) { - this.contacts = contacts; - } - - @Component(DmpPropertiesPersistValidator.ValidatorName) - @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpPropertiesPersistValidator extends BaseValidator implements StatusAware { - - public static final String ValidatorName = "DmpPropertiesPersistValidator"; - - private final ValidatorFactory validatorFactory; - private final MessageSource messageSource; - - private DmpStatus status; - private DefinitionEntity definition; - - protected DmpPropertiesPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) { - super(conventionService, errors); - this.validatorFactory = validatorFactory; - this.messageSource = messageSource; - } - - @Override - protected Class modelClass() { - return DmpPropertiesPersist.class; - } - - @Override - protected List specifications(DmpPropertiesPersist item) { - String contactField = this.getContactFieldLabel(); - return Arrays.asList( - this.mapSpec() - .iff(() ->this.status == DmpStatus.Finalized && !this.isNull(item.getDmpBlueprintValues())) - .on(DmpPropertiesPersist._dmpBlueprintValues) - .over(item.getDmpBlueprintValues()) - .mapKey((k) -> ((UUID)k).toString()) - .using((itm) -> this.validatorFactory.validator(DmpBlueprintValuePersist.DmpBlueprintValuePersistValidator.class).withDefinition(this.definition)), - this.spec() - .iff(() -> this.status == DmpStatus.Finalized && contactField != null) - .must(() -> !this.isListNullOrEmpty(item.getContacts())) - .failOn(DmpPropertiesPersist._contacts).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{contactField}, LocaleContextHolder.getLocale())), - this.navSpec() - .iff(() -> this.status == DmpStatus.Finalized && !this.isListNullOrEmpty(item.getContacts())) - .on(DmpPropertiesPersist._contacts) - .over(item.getContacts()) - .using((itm) -> this.validatorFactory.validator(DmpContactPersist.DmpContactPersistValidator.class)) - ); - } - - @Override - public DmpPropertiesPersistValidator setStatus(DmpStatus status) { - this.status = status; - return this; - } - - public DmpPropertiesPersistValidator withDefinition(DefinitionEntity definition) { - this.definition = definition; - return this; - } - - private String getContactFieldLabel(){ - if (this.definition == null || this.isListNullOrEmpty(this.definition.getSections())) return null; - - for (SectionEntity section: this.definition.getSections()) { - if (!this.isListNullOrEmpty(section.getFields())) { - List fields = section.getFields().stream().filter(x -> x.getCategory().equals(DmpBlueprintFieldCategory.System)).collect(Collectors.toList()); - if (!this.isListNullOrEmpty(fields)){ - - List systemFields = (List)(List) fields; - if (!this.isListNullOrEmpty(systemFields)){ - List contactSystemFields = systemFields.stream().filter(x -> x.getType().equals(DmpBlueprintSystemFieldType.Contact) && x.isRequired()).collect(Collectors.toList()); - if(!this.isListNullOrEmpty(contactSystemFields)) { - return contactSystemFields.getFirst().getLabel() != null ? contactSystemFields.getFirst().getLabel() : DmpBlueprintSystemFieldType.Contact.name(); - } - } - - } - } - } - return null; - } - - } - -} 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/planproperties/PlanBlueprintValuePersist.java similarity index 65% rename from backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpBlueprintValuePersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/planproperties/PlanBlueprintValuePersist.java index 8301d62dc..81e3bb73c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpBlueprintValuePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/planproperties/PlanBlueprintValuePersist.java @@ -1,16 +1,16 @@ -package org.opencdmp.model.persist.dmpproperties; +package org.opencdmp.model.persist.planproperties; 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.DmpBlueprintExtraFieldDataType; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; -import org.opencdmp.commons.types.dmpblueprint.DefinitionEntity; -import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.FieldEntity; -import org.opencdmp.commons.types.dmpblueprint.ReferenceTypeFieldEntity; +import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity; +import org.opencdmp.commons.types.planblueprint.FieldEntity; +import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity; import org.opencdmp.commons.validation.BaseValidator; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; @@ -28,7 +28,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class DmpBlueprintValuePersist { +public class PlanBlueprintValuePersist { private UUID fieldId; public static final String _fieldId = "fieldId"; @@ -94,21 +94,21 @@ public class DmpBlueprintValuePersist { this.reference = reference; } - @Component(DmpBlueprintValuePersistValidator.ValidatorName) + @Component(PlanBlueprintValuePersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpBlueprintValuePersistValidator extends BaseValidator { + public static class PlanBlueprintValuePersistValidator extends BaseValidator { private final ValidatorFactory validatorFactory; private final QueryFactory queryFactory; private final MessageSource messageSource; - public static final String ValidatorName = "DmpBlueprintValuePersistValidator"; + public static final String ValidatorName = "PlanBlueprintValuePersistValidator"; private DefinitionEntity definition; private FieldEntity fieldEntity; private ExtraFieldEntity extraFieldEntity; - protected DmpBlueprintValuePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, QueryFactory queryFactory, MessageSource messageSource) { + protected PlanBlueprintValuePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, QueryFactory queryFactory, MessageSource messageSource) { super(conventionService, errors); this.validatorFactory = validatorFactory; this.queryFactory = queryFactory; @@ -116,58 +116,58 @@ public class DmpBlueprintValuePersist { } @Override - protected Class modelClass() { - return DmpBlueprintValuePersist.class; + protected Class modelClass() { + return PlanBlueprintValuePersist.class; } @Override - protected List specifications(DmpBlueprintValuePersist item) { + protected List specifications(PlanBlueprintValuePersist item) { this.fieldEntity = this.definition != null && this.isValidGuid(item.getFieldId())? this.definition.getFieldById(item.getFieldId()).stream().findFirst().orElse(null) : null; boolean required = this.fieldEntity != null && this.fieldEntity.isRequired(); - if (this.fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)) this.extraFieldEntity = (ExtraFieldEntity) this.fieldEntity; + if (this.fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)) this.extraFieldEntity = (ExtraFieldEntity) this.fieldEntity; return Arrays.asList( this.spec() .must(() -> this.isValidGuid(item.getFieldId())) - .failOn(DmpBlueprintValuePersist._fieldId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintValuePersist._fieldId}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintValuePersist._fieldId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanBlueprintValuePersist._fieldId}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> this.extraFieldEntity != null && DmpBlueprintExtraFieldDataType.isTextType(this.extraFieldEntity.getType()) && this.isListNullOrEmpty(item.getReferences()) && required) + .iff(() -> this.extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isTextType(this.extraFieldEntity.getType()) && this.isListNullOrEmpty(item.getReferences()) && required) .must(() -> !this.isEmpty(item.getFieldValue())) - .failOn(DmpBlueprintValuePersist._fieldValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{this.fieldEntity.getLabel()}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintValuePersist._fieldValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{this.fieldEntity.getLabel()}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> this.extraFieldEntity != null && DmpBlueprintExtraFieldDataType.isDateType(this.extraFieldEntity.getType()) && this.isListNullOrEmpty(item.getReferences()) && required) + .iff(() -> this.extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isDateType(this.extraFieldEntity.getType()) && this.isListNullOrEmpty(item.getReferences()) && required) .must(() -> !this.isNull(item.getDateValue())) - .failOn(DmpBlueprintValuePersist._dateValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{this.fieldEntity.getLabel()}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintValuePersist._dateValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{this.fieldEntity.getLabel()}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> this.extraFieldEntity != null && DmpBlueprintExtraFieldDataType.isNumberType(this.extraFieldEntity.getType()) && this.isListNullOrEmpty(item.getReferences()) && required) + .iff(() -> this.extraFieldEntity != null && PlanBlueprintExtraFieldDataType.isNumberType(this.extraFieldEntity.getType()) && this.isListNullOrEmpty(item.getReferences()) && required) .must(() -> !this.isNull(item.getNumberValue())) - .failOn(DmpBlueprintValuePersist._numberValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{this.fieldEntity.getLabel()}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintValuePersist._numberValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{this.fieldEntity.getLabel()}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> this.fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && ((ReferenceTypeFieldEntity) this.fieldEntity).getMultipleSelect() && required) + .iff(() -> this.fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && ((ReferenceTypeFieldEntity) this.fieldEntity).getMultipleSelect() && required) .must(() -> !this.isListNullOrEmpty(item.getReferences())) // TODO: Cast Exception // .failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : this.getReferenceTypeName(fieldEntity)}, LocaleContextHolder.getLocale())), - .failOn(DmpBlueprintValuePersist._references).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(this.fieldEntity.getLabel()) ? this.fieldEntity.getLabel() : DmpBlueprintValuePersist._references}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintValuePersist._references).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(this.fieldEntity.getLabel()) ? this.fieldEntity.getLabel() : PlanBlueprintValuePersist._references}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> this.fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && !((ReferenceTypeFieldEntity) this.fieldEntity).getMultipleSelect() && required) + .iff(() -> this.fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && !((ReferenceTypeFieldEntity) this.fieldEntity).getMultipleSelect() && required) .must(() -> !this.isNull(item.getReference())) // TODO: Cast Exception // .failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : this.getReferenceTypeName(fieldEntity)}, LocaleContextHolder.getLocale())), - .failOn(DmpBlueprintValuePersist._reference).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(this.fieldEntity.getLabel()) ? this.fieldEntity.getLabel() : DmpBlueprintValuePersist._reference}, LocaleContextHolder.getLocale())), + .failOn(PlanBlueprintValuePersist._reference).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(this.fieldEntity.getLabel()) ? this.fieldEntity.getLabel() : PlanBlueprintValuePersist._reference}, LocaleContextHolder.getLocale())), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getReferences())) - .on(DmpBlueprintValuePersist._references) + .on(PlanBlueprintValuePersist._references) .over(item.getReferences()) .using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class)), this.refSpec() .iff(() -> !this.isNull(item.getReference())) - .on(DmpBlueprintValuePersist._reference) + .on(PlanBlueprintValuePersist._reference) .over(item.getReferences()) .using(() -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class)) ); } - public DmpBlueprintValuePersistValidator withDefinition(DefinitionEntity definition) { + public PlanBlueprintValuePersistValidator withDefinition(DefinitionEntity definition) { this.definition = definition; return this; } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpContactPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/planproperties/PlanContactPersist.java similarity index 59% rename from backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpContactPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/planproperties/PlanContactPersist.java index be4adc629..ad677c411 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpContactPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/planproperties/PlanContactPersist.java @@ -1,10 +1,9 @@ -package org.opencdmp.model.persist.dmpproperties; +package org.opencdmp.model.persist.planproperties; import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; -import org.opencdmp.model.persist.UserInviteToTenantRequestPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -14,7 +13,7 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.List; -public class DmpContactPersist { +public class PlanContactPersist { private String firstName; public static final String _firstName = "firstName"; @@ -49,39 +48,39 @@ public class DmpContactPersist { this.email = email; } - @Component(DmpContactPersistValidator.ValidatorName) + @Component(PlanContactPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpContactPersistValidator extends BaseValidator { + public static class PlanContactPersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpContactPersistValidator"; + public static final String ValidatorName = "PlanContactPersistValidator"; private final MessageSource messageSource; - protected DmpContactPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + protected PlanContactPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { super(conventionService, errors); this.messageSource = messageSource; } @Override - protected Class modelClass() { - return DmpContactPersist.class; + protected Class modelClass() { + return PlanContactPersist.class; } @Override - protected List specifications(DmpContactPersist item) { + protected List specifications(PlanContactPersist item) { return Arrays.asList( this.spec() .must(() -> !this.isEmpty(item.getEmail())) - .failOn(DmpContactPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._email}, LocaleContextHolder.getLocale())), + .failOn(PlanContactPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanContactPersist._email}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getEmail())) .must(() -> this.isValidEmail(item.getEmail())) - .failOn(DmpContactPersist._email).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DmpContactPersist._email}, LocaleContextHolder.getLocale())), + .failOn(PlanContactPersist._email).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{PlanContactPersist._email}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getFirstName())) - .failOn(DmpContactPersist._firstName).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._firstName}, LocaleContextHolder.getLocale())), + .failOn(PlanContactPersist._firstName).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanContactPersist._firstName}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLastName())) - .failOn(DmpContactPersist._lastName).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._lastName}, LocaleContextHolder.getLocale())) + .failOn(PlanContactPersist._lastName).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanContactPersist._lastName}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/planproperties/PlanPropertiesPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/planproperties/PlanPropertiesPersist.java new file mode 100644 index 000000000..7c0caae49 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/persist/planproperties/PlanPropertiesPersist.java @@ -0,0 +1,134 @@ +package org.opencdmp.model.persist.planproperties; + +import gr.cite.tools.validation.ValidatorFactory; +import gr.cite.tools.validation.specification.Specification; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; +import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType; +import org.opencdmp.commons.enums.PlanStatus; +import org.opencdmp.commons.types.planblueprint.DefinitionEntity; +import org.opencdmp.commons.types.planblueprint.FieldEntity; +import org.opencdmp.commons.types.planblueprint.SectionEntity; +import org.opencdmp.commons.types.planblueprint.SystemFieldEntity; +import org.opencdmp.commons.validation.BaseValidator; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.errorcode.ErrorThesaurusProperties; +import org.opencdmp.model.persist.validation.StatusAware; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + +public class PlanPropertiesPersist { + + private Map planBlueprintValues; + + public static final String _planBlueprintValues = "planBlueprintValues"; + + private List contacts; + + public static final String _contacts = "contacts"; + + public Map getPlanBlueprintValues() { + return this.planBlueprintValues; + } + + public void setPlanBlueprintValues(Map planBlueprintValues) { + this.planBlueprintValues = planBlueprintValues; + } + + public List getContacts() { + return this.contacts; + } + + public void setContacts(List contacts) { + this.contacts = contacts; + } + + @Component(PlanPropertiesPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class PlanPropertiesPersistValidator extends BaseValidator implements StatusAware { + + public static final String ValidatorName = "PlanPropertiesPersistValidator"; + + private final ValidatorFactory validatorFactory; + private final MessageSource messageSource; + + private PlanStatus status; + private DefinitionEntity definition; + + protected PlanPropertiesPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) { + super(conventionService, errors); + this.validatorFactory = validatorFactory; + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return PlanPropertiesPersist.class; + } + + @Override + protected List specifications(PlanPropertiesPersist item) { + String contactField = this.getContactFieldLabel(); + return Arrays.asList( + this.mapSpec() + .iff(() ->this.status == PlanStatus.Finalized && !this.isNull(item.getPlanBlueprintValues())) + .on(PlanPropertiesPersist._planBlueprintValues) + .over(item.getPlanBlueprintValues()) + .mapKey((k) -> ((UUID)k).toString()) + .using((itm) -> this.validatorFactory.validator(PlanBlueprintValuePersist.PlanBlueprintValuePersistValidator.class).withDefinition(this.definition)), + this.spec() + .iff(() -> this.status == PlanStatus.Finalized && contactField != null) + .must(() -> !this.isListNullOrEmpty(item.getContacts())) + .failOn(PlanPropertiesPersist._contacts).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{contactField}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> this.status == PlanStatus.Finalized && !this.isListNullOrEmpty(item.getContacts())) + .on(PlanPropertiesPersist._contacts) + .over(item.getContacts()) + .using((itm) -> this.validatorFactory.validator(PlanContactPersist.PlanContactPersistValidator.class)) + ); + } + + @Override + public PlanPropertiesPersistValidator setStatus(PlanStatus status) { + this.status = status; + return this; + } + + public PlanPropertiesPersistValidator withDefinition(DefinitionEntity definition) { + this.definition = definition; + return this; + } + + private String getContactFieldLabel(){ + if (this.definition == null || this.isListNullOrEmpty(this.definition.getSections())) return null; + + for (SectionEntity section: this.definition.getSections()) { + if (!this.isListNullOrEmpty(section.getFields())) { + List fields = section.getFields().stream().filter(x -> x.getCategory().equals(PlanBlueprintFieldCategory.System)).collect(Collectors.toList()); + if (!this.isListNullOrEmpty(fields)){ + + List systemFields = (List)(List) fields; + if (!this.isListNullOrEmpty(systemFields)){ + List contactSystemFields = systemFields.stream().filter(x -> x.getType().equals(PlanBlueprintSystemFieldType.Contact) && x.isRequired()).collect(Collectors.toList()); + if(!this.isListNullOrEmpty(contactSystemFields)) { + return contactSystemFields.getFirst().getLabel() != null ? contactSystemFields.getFirst().getLabel() : PlanBlueprintSystemFieldType.Contact.name(); + } + } + + } + } + } + return null; + } + + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/dmpreference/DmpReferenceDataPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/planreference/PlanReferenceDataPersist.java similarity index 57% rename from backend/core/src/main/java/org/opencdmp/model/persist/dmpreference/DmpReferenceDataPersist.java rename to backend/core/src/main/java/org/opencdmp/model/persist/planreference/PlanReferenceDataPersist.java index 55c1525d4..3a6d70375 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpreference/DmpReferenceDataPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/planreference/PlanReferenceDataPersist.java @@ -1,10 +1,9 @@ -package org.opencdmp.model.persist.dmpreference; +package org.opencdmp.model.persist.planreference; import org.opencdmp.commons.validation.BaseValidator; 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.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -15,7 +14,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -public class DmpReferenceDataPersist { +public class PlanReferenceDataPersist { private UUID blueprintFieldId; @@ -29,29 +28,29 @@ public class DmpReferenceDataPersist { this.blueprintFieldId = blueprintFieldId; } - @Component(DmpReferenceDataPersistValidator.ValidatorName) + @Component(PlanReferenceDataPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DmpReferenceDataPersistValidator extends BaseValidator { + public static class PlanReferenceDataPersistValidator extends BaseValidator { - public static final String ValidatorName = "DmpReferenceDataPersistValidator"; + public static final String ValidatorName = "PlanReferenceDataPersistValidator"; private final MessageSource messageSource; - protected DmpReferenceDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + protected PlanReferenceDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { super(conventionService, errors); this.messageSource = messageSource; } @Override - protected Class modelClass() { - return DmpReferenceDataPersist.class; + protected Class modelClass() { + return PlanReferenceDataPersist.class; } @Override - protected List specifications(DmpReferenceDataPersist item) { + protected List specifications(PlanReferenceDataPersist item) { return Arrays.asList( this.spec() .must(() -> !this.isNull(item.getBlueprintFieldId())) - .failOn(DmpReferenceDataPersist._blueprintFieldId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpReferenceDataPersist._blueprintFieldId}, LocaleContextHolder.getLocale())) + .failOn(PlanReferenceDataPersist._blueprintFieldId).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanReferenceDataPersist._blueprintFieldId}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/dmp/Dmp.java b/backend/core/src/main/java/org/opencdmp/model/plan/Plan.java similarity index 70% rename from backend/core/src/main/java/org/opencdmp/model/dmp/Dmp.java rename to backend/core/src/main/java/org/opencdmp/model/plan/Plan.java index 2cf87e636..913f847bd 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmp/Dmp.java +++ b/backend/core/src/main/java/org/opencdmp/model/plan/Plan.java @@ -1,20 +1,20 @@ -package org.opencdmp.model.dmp; +package org.opencdmp.model.plan; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; -import org.opencdmp.commons.enums.DmpVersionStatus; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.model.*; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.planblueprint.PlanBlueprint; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.user.User; import java.time.Instant; import java.util.List; import java.util.UUID; -public class Dmp { +public class Plan { private UUID id; public static final String _id = "id"; @@ -25,13 +25,13 @@ public class Dmp { private Short version; public static final String _version = "version"; - private DmpStatus status; + private PlanStatus status; public static final String _status = "status"; - private DmpVersionStatus versionStatus; + private PlanVersionStatus versionStatus; public static final String _versionStatus = "versionStatus"; - private DmpProperties properties; + private PlanProperties properties; public static final String _properties = "properties"; private UUID groupId; @@ -58,10 +58,10 @@ public class Dmp { private User creator; public static final String _creator = "creator"; - private DmpAccessType accessType; + private PlanAccessType accessType; public static final String _accessType = "accessType"; - private DmpBlueprint blueprint; + private PlanBlueprint blueprint; public static final String _blueprint = "blueprint"; private String language; @@ -73,17 +73,17 @@ public class Dmp { private String hash; public static final String _hash = "hash"; - private List dmpReferences; - public static final String _dmpReferences = "dmpReferences"; + private List planReferences; + public static final String _planReferences = "planReferences"; - private List dmpUsers; - public static final String _dmpUsers = "dmpUsers"; + private List planUsers; + public static final String _planUsers = "planUsers"; private List descriptions; public static final String _descriptions = "descriptions"; - private List dmpDescriptionTemplates; - public static final String _dmpDescriptionTemplates = "dmpDescriptionTemplates"; + private List planDescriptionTemplates; + public static final String _planDescriptionTemplates = "planDescriptionTemplates"; private List entityDois; public static final String _entityDois = "entityDois"; @@ -91,8 +91,8 @@ public class Dmp { private List authorizationFlags; public static final String _authorizationFlags = "authorizationFlags"; - private List otherDmpVersions; - public static final String _otherDmpVersions = "otherDmpVersions"; + private List otherPlanVersions; + public static final String _otherPlanVersions = "otherPlanVersions"; private Boolean belongsToCurrentTenant; @@ -122,19 +122,19 @@ public class Dmp { this.version = version; } - public DmpStatus getStatus() { + public PlanStatus getStatus() { return status; } - public void setStatus(DmpStatus status) { + public void setStatus(PlanStatus status) { this.status = status; } - public DmpProperties getProperties() { + public PlanProperties getProperties() { return properties; } - public void setProperties(DmpProperties properties) { + public void setProperties(PlanProperties properties) { this.properties = properties; } @@ -202,19 +202,19 @@ public class Dmp { this.creator = creator; } - public DmpAccessType getAccessType() { + public PlanAccessType getAccessType() { return accessType; } - public void setAccessType(DmpAccessType accessType) { + public void setAccessType(PlanAccessType accessType) { this.accessType = accessType; } - public DmpBlueprint getBlueprint() { + public PlanBlueprint getBlueprint() { return blueprint; } - public void setBlueprint(DmpBlueprint blueprint) { + public void setBlueprint(PlanBlueprint blueprint) { this.blueprint = blueprint; } @@ -242,27 +242,27 @@ public class Dmp { this.hash = hash; } - public List getDmpReferences() { - return dmpReferences; + public List getPlanReferences() { + return planReferences; } - public void setDmpReferences(List dmpReferences) { - this.dmpReferences = dmpReferences; + public void setPlanReferences(List planReferences) { + this.planReferences = planReferences; } - public List getDmpUsers() { - return dmpUsers; + public List getPlanUsers() { + return planUsers; } - public void setDmpUsers(List dmpUsers) { - this.dmpUsers = dmpUsers; + public void setPlanUsers(List planUsers) { + this.planUsers = planUsers; } - public DmpVersionStatus getVersionStatus() { + public PlanVersionStatus getVersionStatus() { return versionStatus; } - public void setVersionStatus(DmpVersionStatus versionStatus) { + public void setVersionStatus(PlanVersionStatus versionStatus) { this.versionStatus = versionStatus; } @@ -274,12 +274,12 @@ public class Dmp { this.descriptions = descriptions; } - public List getDmpDescriptionTemplates() { - return dmpDescriptionTemplates; + public List getPlanDescriptionTemplates() { + return planDescriptionTemplates; } - public void setDmpDescriptionTemplates(List dmpDescriptionTemplates) { - this.dmpDescriptionTemplates = dmpDescriptionTemplates; + public void setPlanDescriptionTemplates(List planDescriptionTemplates) { + this.planDescriptionTemplates = planDescriptionTemplates; } public List getEntityDois() { @@ -306,11 +306,11 @@ public class Dmp { this.belongsToCurrentTenant = belongsToCurrentTenant; } - public List getOtherDmpVersions() { - return otherDmpVersions; + public List getOtherPlanVersions() { + return otherPlanVersions; } - public void setOtherDmpVersions(List otherDmpVersions) { - this.otherDmpVersions = otherDmpVersions; + public void setOtherPlanVersions(List otherPlanVersions) { + this.otherPlanVersions = otherPlanVersions; } } diff --git a/backend/core/src/main/java/org/opencdmp/model/dmp/DmpBlueprintValue.java b/backend/core/src/main/java/org/opencdmp/model/plan/PlanBlueprintValue.java similarity index 94% rename from backend/core/src/main/java/org/opencdmp/model/dmp/DmpBlueprintValue.java rename to backend/core/src/main/java/org/opencdmp/model/plan/PlanBlueprintValue.java index 3d3ab38a0..b657d8ed3 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmp/DmpBlueprintValue.java +++ b/backend/core/src/main/java/org/opencdmp/model/plan/PlanBlueprintValue.java @@ -1,9 +1,9 @@ -package org.opencdmp.model.dmp; +package org.opencdmp.model.plan; import java.time.Instant; import java.util.UUID; -public class DmpBlueprintValue { +public class PlanBlueprintValue { private UUID fieldId; public static final String _fieldId = "fieldId"; diff --git a/backend/core/src/main/java/org/opencdmp/model/dmp/DmpContact.java b/backend/core/src/main/java/org/opencdmp/model/plan/PlanContact.java similarity index 92% rename from backend/core/src/main/java/org/opencdmp/model/dmp/DmpContact.java rename to backend/core/src/main/java/org/opencdmp/model/plan/PlanContact.java index 50b79a05f..f988c0f04 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmp/DmpContact.java +++ b/backend/core/src/main/java/org/opencdmp/model/plan/PlanContact.java @@ -1,7 +1,7 @@ -package org.opencdmp.model.dmp; +package org.opencdmp.model.plan; -public class DmpContact { +public class PlanContact { private String firstName; diff --git a/backend/core/src/main/java/org/opencdmp/model/plan/PlanProperties.java b/backend/core/src/main/java/org/opencdmp/model/plan/PlanProperties.java new file mode 100644 index 000000000..710f64c2f --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/plan/PlanProperties.java @@ -0,0 +1,31 @@ +package org.opencdmp.model.plan; + +import java.util.List; + +public class PlanProperties { + + private List planBlueprintValues; + + public static final String _planBlueprintValues = "planBlueprintValues"; + + private List contacts; + + public static final String _contacts = "contacts"; + + public List getPlanBlueprintValues() { + return planBlueprintValues; + } + + public void setPlanBlueprintValues(List planBlueprintValues) { + this.planBlueprintValues = planBlueprintValues; + } + + public List getContacts() { + return contacts; + } + + public void setContacts(List contacts) { + this.contacts = contacts; + } + +} diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Definition.java b/backend/core/src/main/java/org/opencdmp/model/planblueprint/Definition.java similarity index 87% rename from backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Definition.java rename to backend/core/src/main/java/org/opencdmp/model/planblueprint/Definition.java index 6f4d941be..093fa8015 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Definition.java +++ b/backend/core/src/main/java/org/opencdmp/model/planblueprint/Definition.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.dmpblueprint; +package org.opencdmp.model.planblueprint; import java.util.List; diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/DescriptionTemplate.java b/backend/core/src/main/java/org/opencdmp/model/planblueprint/DescriptionTemplate.java similarity index 96% rename from backend/core/src/main/java/org/opencdmp/model/dmpblueprint/DescriptionTemplate.java rename to backend/core/src/main/java/org/opencdmp/model/planblueprint/DescriptionTemplate.java index 5f51c4a9e..7515f9e3f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/DescriptionTemplate.java +++ b/backend/core/src/main/java/org/opencdmp/model/planblueprint/DescriptionTemplate.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.dmpblueprint; +package org.opencdmp.model.planblueprint; import java.util.UUID; diff --git a/backend/core/src/main/java/org/opencdmp/model/planblueprint/ExtraField.java b/backend/core/src/main/java/org/opencdmp/model/planblueprint/ExtraField.java new file mode 100644 index 000000000..c4aee326a --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/planblueprint/ExtraField.java @@ -0,0 +1,19 @@ +package org.opencdmp.model.planblueprint; + +import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType; + + +public class ExtraField extends Field { + + public final static String _dataType = "dataType"; + private PlanBlueprintExtraFieldDataType dataType; + + public PlanBlueprintExtraFieldDataType getDataType() { + return dataType; + } + + public void setDataType(PlanBlueprintExtraFieldDataType dataType) { + this.dataType = dataType; + } +} + diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Field.java b/backend/core/src/main/java/org/opencdmp/model/planblueprint/Field.java similarity index 86% rename from backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Field.java rename to backend/core/src/main/java/org/opencdmp/model/planblueprint/Field.java index cc563fc9b..b2c524ef8 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Field.java +++ b/backend/core/src/main/java/org/opencdmp/model/planblueprint/Field.java @@ -1,6 +1,6 @@ -package org.opencdmp.model.dmpblueprint; +package org.opencdmp.model.planblueprint; -import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; +import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; import java.util.List; import java.util.UUID; @@ -11,7 +11,7 @@ public abstract class Field { private UUID id; public final static String _category = "category"; - private DmpBlueprintFieldCategory category; + private PlanBlueprintFieldCategory category; public final static String _label = "label"; private String label; @@ -39,11 +39,11 @@ public abstract class Field { this.id = id; } - public DmpBlueprintFieldCategory getCategory() { + public PlanBlueprintFieldCategory getCategory() { return category; } - public void setCategory(DmpBlueprintFieldCategory category) { + public void setCategory(PlanBlueprintFieldCategory category) { this.category = category; } diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/DmpBlueprint.java b/backend/core/src/main/java/org/opencdmp/model/planblueprint/PlanBlueprint.java similarity index 83% rename from backend/core/src/main/java/org/opencdmp/model/dmpblueprint/DmpBlueprint.java rename to backend/core/src/main/java/org/opencdmp/model/planblueprint/PlanBlueprint.java index a158f9b12..fdaed6d40 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/DmpBlueprint.java +++ b/backend/core/src/main/java/org/opencdmp/model/planblueprint/PlanBlueprint.java @@ -1,14 +1,13 @@ -package org.opencdmp.model.dmpblueprint; +package org.opencdmp.model.planblueprint; -import org.opencdmp.commons.enums.DmpBlueprintStatus; -import org.opencdmp.commons.enums.DmpBlueprintVersionStatus; +import org.opencdmp.commons.enums.PlanBlueprintStatus; +import org.opencdmp.commons.enums.PlanBlueprintVersionStatus; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.model.dmpblueprint.Definition; import java.time.Instant; import java.util.UUID; -public class DmpBlueprint { +public class PlanBlueprint { private UUID id; @@ -22,7 +21,7 @@ public class DmpBlueprint { public static final String _definition = "definition"; - private DmpBlueprintStatus status; + private PlanBlueprintStatus status; public static final String _status = "status"; @@ -34,7 +33,7 @@ public class DmpBlueprint { public static final String _version = "version"; - private DmpBlueprintVersionStatus versionStatus; + private PlanBlueprintVersionStatus versionStatus; public static final String _versionStatus = "versionStatus"; @@ -81,11 +80,11 @@ public class DmpBlueprint { this.definition = definition; } - public DmpBlueprintStatus getStatus() { + public PlanBlueprintStatus getStatus() { return status; } - public void setStatus(DmpBlueprintStatus status) { + public void setStatus(PlanBlueprintStatus status) { this.status = status; } @@ -105,11 +104,11 @@ public class DmpBlueprint { this.version = version; } - public DmpBlueprintVersionStatus getVersionStatus() { + public PlanBlueprintVersionStatus getVersionStatus() { return versionStatus; } - public void setVersionStatus(DmpBlueprintVersionStatus versionStatus) { + public void setVersionStatus(PlanBlueprintVersionStatus versionStatus) { this.versionStatus = versionStatus; } diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/ReferenceTypeField.java b/backend/core/src/main/java/org/opencdmp/model/planblueprint/ReferenceTypeField.java similarity index 93% rename from backend/core/src/main/java/org/opencdmp/model/dmpblueprint/ReferenceTypeField.java rename to backend/core/src/main/java/org/opencdmp/model/planblueprint/ReferenceTypeField.java index df723d0a5..b8224f4c6 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/ReferenceTypeField.java +++ b/backend/core/src/main/java/org/opencdmp/model/planblueprint/ReferenceTypeField.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.dmpblueprint; +package org.opencdmp.model.planblueprint; import org.opencdmp.model.referencetype.ReferenceType; diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Section.java b/backend/core/src/main/java/org/opencdmp/model/planblueprint/Section.java similarity index 98% rename from backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Section.java rename to backend/core/src/main/java/org/opencdmp/model/planblueprint/Section.java index f91850c2a..a97a0320e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmpblueprint/Section.java +++ b/backend/core/src/main/java/org/opencdmp/model/planblueprint/Section.java @@ -1,4 +1,4 @@ -package org.opencdmp.model.dmpblueprint; +package org.opencdmp.model.planblueprint; import org.opencdmp.model.prefillingsource.PrefillingSource; diff --git a/backend/core/src/main/java/org/opencdmp/model/planblueprint/SystemField.java b/backend/core/src/main/java/org/opencdmp/model/planblueprint/SystemField.java new file mode 100644 index 000000000..3a10863ec --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/planblueprint/SystemField.java @@ -0,0 +1,17 @@ +package org.opencdmp.model.planblueprint; + +import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType; + +public class SystemField extends Field { + + public final static String _systemFieldType = "systemFieldType"; + private PlanBlueprintSystemFieldType systemFieldType; + + public PlanBlueprintSystemFieldType getSystemFieldType() { + return systemFieldType; + } + + public void setSystemFieldType(PlanBlueprintSystemFieldType systemFieldType) { + this.systemFieldType = systemFieldType; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpreference/DmpReference.java b/backend/core/src/main/java/org/opencdmp/model/planreference/PlanReference.java similarity index 82% rename from backend/core/src/main/java/org/opencdmp/model/dmpreference/DmpReference.java rename to backend/core/src/main/java/org/opencdmp/model/planreference/PlanReference.java index 795c13b37..2f6d11b97 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmpreference/DmpReference.java +++ b/backend/core/src/main/java/org/opencdmp/model/planreference/PlanReference.java @@ -1,19 +1,19 @@ -package org.opencdmp.model.dmpreference; +package org.opencdmp.model.planreference; import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.reference.Reference; -import org.opencdmp.model.dmp.Dmp; import java.time.Instant; import java.util.UUID; -public class DmpReference { +public class PlanReference { private UUID id; public static final String _id = "id"; - private Dmp dmp; - public static final String _dmp = "dmp"; + private Plan plan; + public static final String _plan = "plan"; private Reference reference; public static final String _reference = "reference"; @@ -34,7 +34,7 @@ public class DmpReference { private Boolean belongsToCurrentTenant; public static final String _belongsToCurrentTenant = "belongsToCurrentTenant"; - private DmpReferenceData data; + private PlanReferenceData data; public static final String _data = "data"; public UUID getId() { @@ -45,12 +45,12 @@ public class DmpReference { this.id = id; } - public Dmp getDmp() { - return dmp; + public Plan getPlan() { + return plan; } - public void setDmp(Dmp dmp) { - this.dmp = dmp; + public void setPlan(Plan plan) { + this.plan = plan; } public Reference getReference() { @@ -85,11 +85,11 @@ public class DmpReference { this.hash = hash; } - public void setData(DmpReferenceData data) { + public void setData(PlanReferenceData data) { this.data = data; } - public DmpReferenceData getData() { + public PlanReferenceData getData() { return data; } diff --git a/backend/core/src/main/java/org/opencdmp/model/dmpreference/DmpReferenceData.java b/backend/core/src/main/java/org/opencdmp/model/planreference/PlanReferenceData.java similarity index 80% rename from backend/core/src/main/java/org/opencdmp/model/dmpreference/DmpReferenceData.java rename to backend/core/src/main/java/org/opencdmp/model/planreference/PlanReferenceData.java index f94cdc11a..93897ff6d 100644 --- a/backend/core/src/main/java/org/opencdmp/model/dmpreference/DmpReferenceData.java +++ b/backend/core/src/main/java/org/opencdmp/model/planreference/PlanReferenceData.java @@ -1,8 +1,8 @@ -package org.opencdmp.model.dmpreference; +package org.opencdmp.model.planreference; import java.util.UUID; -public class DmpReferenceData { +public class PlanReferenceData { private UUID blueprintFieldId; public final static String _blueprintFieldId = "blueprintFieldId"; diff --git a/backend/core/src/main/java/org/opencdmp/model/publicapi/associatedprofile/AssociatedProfilePublicModel.java b/backend/core/src/main/java/org/opencdmp/model/publicapi/associatedprofile/AssociatedProfilePublicModel.java index 2f8135eee..f73184694 100644 --- a/backend/core/src/main/java/org/opencdmp/model/publicapi/associatedprofile/AssociatedProfilePublicModel.java +++ b/backend/core/src/main/java/org/opencdmp/model/publicapi/associatedprofile/AssociatedProfilePublicModel.java @@ -1,8 +1,8 @@ package org.opencdmp.model.publicapi.associatedprofile; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.model.planblueprint.PlanBlueprint; +import org.opencdmp.model.PlanDescriptionTemplate; import jakarta.xml.bind.annotation.*; import java.util.*; @@ -51,24 +51,24 @@ public class AssociatedProfilePublicModel { this.data = data; } - public static AssociatedProfilePublicModel fromDmpDescriptionTemplate(DmpDescriptionTemplate dmpDescriptionTemplate, DmpBlueprint dmpBlueprint) { - DescriptionTemplate currentDescriptionTemplate = dmpDescriptionTemplate.getCurrentDescriptionTemplate(); - UUID sectionId = dmpDescriptionTemplate.getSectionId(); + public static AssociatedProfilePublicModel fromPlanDescriptionTemplate(PlanDescriptionTemplate planDescriptionTemplate, PlanBlueprint planBlueprint) { + DescriptionTemplate currentDescriptionTemplate = planDescriptionTemplate.getCurrentDescriptionTemplate(); + UUID sectionId = planDescriptionTemplate.getSectionId(); AssociatedProfilePublicModel model = new AssociatedProfilePublicModel(); - model.setId(dmpDescriptionTemplate.getId()); + model.setId(planDescriptionTemplate.getId()); model.setDescriptionTemplateId(currentDescriptionTemplate.getId()); model.setLabel(currentDescriptionTemplate.getLabel()); HashMap data = new HashMap<>(); - data.put("dmpSectionIndex", getDmpSectionIndexes(dmpBlueprint, sectionId)); + data.put("dmpSectionIndex", getDmpSectionIndexes(planBlueprint, sectionId)); model.setData(data); return model; } - private static List getDmpSectionIndexes(DmpBlueprint dmpBlueprint, UUID sectionId) { + private static List getDmpSectionIndexes(PlanBlueprint planBlueprint, UUID sectionId) { ArrayList indexes = new ArrayList<>(); - dmpBlueprint.getDefinition().getSections().forEach(x -> { + planBlueprint.getDefinition().getSections().forEach(x -> { if (Objects.equals(sectionId, x.getId())) indexes.add(x.getOrdinal()); }); diff --git a/backend/core/src/main/java/org/opencdmp/model/publicapi/grant/GrantPublicOverviewModel.java b/backend/core/src/main/java/org/opencdmp/model/publicapi/grant/GrantPublicOverviewModel.java index 92e142180..0452c61fd 100644 --- a/backend/core/src/main/java/org/opencdmp/model/publicapi/grant/GrantPublicOverviewModel.java +++ b/backend/core/src/main/java/org/opencdmp/model/publicapi/grant/GrantPublicOverviewModel.java @@ -1,7 +1,7 @@ package org.opencdmp.model.publicapi.grant; import org.opencdmp.model.descriptionreference.DescriptionReference; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.reference.Reference; import org.opencdmp.model.publicapi.funder.FunderPublicOverviewModel; import org.opencdmp.model.reference.Field; @@ -79,20 +79,20 @@ public class GrantPublicOverviewModel { this.funder = funder; } - public static GrantPublicOverviewModel fromDmpReferences(List references, PublicApiProperties.ReferenceTypeMapConfig config) { + public static GrantPublicOverviewModel fromDmpReferences(List references, PublicApiProperties.ReferenceTypeMapConfig config) { FunderPublicOverviewModel funder = null; - for (DmpReference dmpReference : references) { - if (!Objects.equals(dmpReference.getReference().getType().getId(), config.getFunderTypeId())) { + for (PlanReference planReference : references) { + if (!Objects.equals(planReference.getReference().getType().getId(), config.getFunderTypeId())) { funder = new FunderPublicOverviewModel(); - Reference reference = dmpReference.getReference(); + Reference reference = planReference.getReference(); funder.setId(reference.getId()); funder.setLabel(reference.getLabel()); continue; } - if (!Objects.equals(dmpReference.getReference().getType().getId(), config.getGrantTypeId())) + if (!Objects.equals(planReference.getReference().getType().getId(), config.getGrantTypeId())) continue; GrantPublicOverviewModel model = new GrantPublicOverviewModel(); - Reference reference = dmpReference.getReference(); + Reference reference = planReference.getReference(); model.setId(reference.getId()); model.setDescription(reference.getDescription()); model.setAbbreviation(reference.getAbbreviation()); diff --git a/backend/core/src/main/java/org/opencdmp/model/publicapi/organisation/OrganizationPublicModel.java b/backend/core/src/main/java/org/opencdmp/model/publicapi/organisation/OrganizationPublicModel.java index 0cbb1d429..b043794af 100644 --- a/backend/core/src/main/java/org/opencdmp/model/publicapi/organisation/OrganizationPublicModel.java +++ b/backend/core/src/main/java/org/opencdmp/model/publicapi/organisation/OrganizationPublicModel.java @@ -1,6 +1,6 @@ package org.opencdmp.model.publicapi.organisation; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.reference.Reference; import org.opencdmp.service.publicapi.PublicApiProperties; @@ -48,11 +48,11 @@ public class OrganizationPublicModel { this.key = key; } - public static OrganizationPublicModel fromDmpReference(DmpReference dmpReference, PublicApiProperties.ReferenceTypeMapConfig config) { - if (!Objects.equals(dmpReference.getReference().getType().getId(), config.getOrganizationTypeId())) + public static OrganizationPublicModel fromDmpReference(PlanReference planReference, PublicApiProperties.ReferenceTypeMapConfig config) { + if (!Objects.equals(planReference.getReference().getType().getId(), config.getOrganizationTypeId())) return null; OrganizationPublicModel model = new OrganizationPublicModel(); - Reference reference = dmpReference.getReference(); + Reference reference = planReference.getReference(); model.setId(reference.getId().toString()); model.setReference(reference.getReference()); model.setLabel(reference.getLabel()); diff --git a/backend/core/src/main/java/org/opencdmp/model/publicapi/overviewmodels/DataManagementPlanPublicModel.java b/backend/core/src/main/java/org/opencdmp/model/publicapi/overviewmodels/DataManagementPlanPublicModel.java index 0b5cf5927..29d0f3183 100644 --- a/backend/core/src/main/java/org/opencdmp/model/publicapi/overviewmodels/DataManagementPlanPublicModel.java +++ b/backend/core/src/main/java/org/opencdmp/model/publicapi/overviewmodels/DataManagementPlanPublicModel.java @@ -1,6 +1,6 @@ package org.opencdmp.model.publicapi.overviewmodels; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import org.opencdmp.model.publicapi.associatedprofile.AssociatedProfilePublicModel; import org.opencdmp.model.publicapi.doi.DoiPublicModel; import org.opencdmp.model.publicapi.grant.GrantPublicOverviewModel; @@ -151,7 +151,7 @@ public class DataManagementPlanPublicModel { this.dois = dois; } - public DmpEntity toDataModel() { + public PlanEntity toDataModel() { return null; } diff --git a/backend/core/src/main/java/org/opencdmp/model/publicapi/researcher/ResearcherPublicModel.java b/backend/core/src/main/java/org/opencdmp/model/publicapi/researcher/ResearcherPublicModel.java index d1507f326..0036dfce2 100644 --- a/backend/core/src/main/java/org/opencdmp/model/publicapi/researcher/ResearcherPublicModel.java +++ b/backend/core/src/main/java/org/opencdmp/model/publicapi/researcher/ResearcherPublicModel.java @@ -1,7 +1,7 @@ package org.opencdmp.model.publicapi.researcher; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.reference.Reference; import org.opencdmp.service.publicapi.PublicApiProperties; import org.slf4j.Logger; @@ -53,16 +53,16 @@ public class ResearcherPublicModel { this.key = key; } - public static ResearcherPublicModel fromDmpReference(DmpReference dmpReference, PublicApiProperties.ReferenceTypeMapConfig config) { - if (!Objects.equals(dmpReference.getReference().getType().getId(), config.getRegistryTypeId())) + public static ResearcherPublicModel fromDmpReference(PlanReference planReference, PublicApiProperties.ReferenceTypeMapConfig config) { + if (!Objects.equals(planReference.getReference().getType().getId(), config.getRegistryTypeId())) return null; ResearcherPublicModel model = new ResearcherPublicModel(); - Reference reference = dmpReference.getReference(); + Reference reference = planReference.getReference(); model.setId(reference.getId().toString()); model.setReference(reference.getReference()); model.setLabel(reference.getLabel()); model.setName(reference.getLabel()); - String[] refParts = dmpReference.getReference().getReference().split(":"); + String[] refParts = planReference.getReference().getReference().split(":"); String source = refParts[0]; if (source.equals("dmp")) model.setKey("Internal"); diff --git a/backend/core/src/main/java/org/opencdmp/model/publicapi/user/UserInfoPublicModel.java b/backend/core/src/main/java/org/opencdmp/model/publicapi/user/UserInfoPublicModel.java index 66cfea071..fa0ef2965 100644 --- a/backend/core/src/main/java/org/opencdmp/model/publicapi/user/UserInfoPublicModel.java +++ b/backend/core/src/main/java/org/opencdmp/model/publicapi/user/UserInfoPublicModel.java @@ -1,6 +1,6 @@ package org.opencdmp.model.publicapi.user; -import org.opencdmp.model.DmpUser; +import org.opencdmp.model.PlanUser; import org.opencdmp.model.user.User; import java.util.UUID; @@ -31,11 +31,11 @@ public class UserInfoPublicModel { this.role = role; } - public static UserInfoPublicModel fromDmpUser(DmpUser dmpUser) { + public static UserInfoPublicModel fromDmpUser(PlanUser planUser) { UserInfoPublicModel model = new UserInfoPublicModel(); - model.setId(dmpUser.getUser().getId()); - model.setName(dmpUser.getUser().getName()); - model.setRole(dmpUser.getRole().getValue()); + model.setId(planUser.getUser().getId()); + model.setName(planUser.getUser().getName()); + model.setRole(planUser.getRole().getValue()); return model; } diff --git a/backend/core/src/main/java/org/opencdmp/model/reference/Reference.java b/backend/core/src/main/java/org/opencdmp/model/reference/Reference.java index 13e325f2c..f63ccb76b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/reference/Reference.java +++ b/backend/core/src/main/java/org/opencdmp/model/reference/Reference.java @@ -2,8 +2,8 @@ package org.opencdmp.model.reference; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.ReferenceSourceType; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.user.User; -import org.opencdmp.model.dmpreference.DmpReference; import org.opencdmp.model.referencetype.ReferenceType; import java.time.Instant; @@ -51,8 +51,8 @@ public class Reference { private User createdBy; public static final String _createdBy = "createdBy"; - private List dmpReferences; - public static final String _dmpReferences = "dmpReferences"; + private List planReferences; + public static final String _planReferences = "planReferences"; private String hash; public final static String _hash = "hash"; @@ -156,12 +156,12 @@ public class Reference { this.updatedAt = updatedAt; } - public List getDmpReferences() { - return dmpReferences; + public List getPlanReferences() { + return planReferences; } - public void setDmpReferences(List dmpReferences) { - this.dmpReferences = dmpReferences; + public void setPlanReferences(List planReferences) { + this.planReferences = planReferences; } public User getCreatedBy() { 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 2284e8da2..bff0de648 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java @@ -34,9 +34,9 @@ public class DescriptionQuery extends QueryBase { private Collection createdByIds; - private DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery; + private PlanDescriptionTemplateQuery planDescriptionTemplateQuery; - private DmpQuery dmpQuery; + private PlanQuery planQuery; private DescriptionTemplateQuery descriptionTemplateQuery; @@ -58,7 +58,7 @@ public class DescriptionQuery extends QueryBase { private Collection statuses; - private Collection dmpIds; + private Collection planIds; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -68,7 +68,7 @@ public class DescriptionQuery extends QueryBase { private final QueryUtilsService queryUtilsService; - private Collection dmpDescriptionTemplateIds; + private Collection planDescriptionTemplateIds; private final TenantEntityManager tenantEntityManager; public DescriptionQuery(UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) { @@ -113,8 +113,8 @@ public class DescriptionQuery extends QueryBase { return this; } - public DescriptionQuery dmpDescriptionTemplateSubQuery(DmpDescriptionTemplateQuery subQuery) { - this.dmpDescriptionTemplateQuery = subQuery; + public DescriptionQuery dmpDescriptionTemplateSubQuery(PlanDescriptionTemplateQuery subQuery) { + this.planDescriptionTemplateQuery = subQuery; return this; } @@ -128,18 +128,18 @@ public class DescriptionQuery extends QueryBase { return this; } - public DescriptionQuery dmpDescriptionTemplateIds(UUID value) { - this.dmpDescriptionTemplateIds = List.of(value); + public DescriptionQuery planDescriptionTemplateIds(UUID value) { + this.planDescriptionTemplateIds = List.of(value); return this; } - public DescriptionQuery dmpDescriptionTemplateIds(UUID... value) { - this.dmpDescriptionTemplateIds = Arrays.asList(value); + public DescriptionQuery planDescriptionTemplateIds(UUID... value) { + this.planDescriptionTemplateIds = Arrays.asList(value); return this; } - public DescriptionQuery dmpDescriptionTemplateIds(Collection values) { - this.dmpDescriptionTemplateIds = values; + public DescriptionQuery planDescriptionTemplateIds(Collection values) { + this.planDescriptionTemplateIds = values; return this; } @@ -153,8 +153,8 @@ public class DescriptionQuery extends QueryBase { return this; } - public DescriptionQuery dmpSubQuery(DmpQuery subQuery) { - this.dmpQuery = subQuery; + public DescriptionQuery dmpSubQuery(PlanQuery subQuery) { + this.planQuery = subQuery; return this; } @@ -218,13 +218,13 @@ public class DescriptionQuery extends QueryBase { return this; } - public DescriptionQuery dmpIds(Collection values) { - this.dmpIds = values; + public DescriptionQuery planIds(Collection values) { + this.planIds = values; return this; } - public DescriptionQuery dmpIds(UUID value) { - this.dmpIds = List.of(value); + public DescriptionQuery planIds(UUID value) { + this.planIds = List.of(value); return this; } @@ -253,8 +253,8 @@ public class DescriptionQuery extends QueryBase { return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.createdByIds) || - this.isEmpty(this.excludedIds) || this.isFalseQuery(this.dmpQuery) || - this.isEmpty(this.statuses) || this.isFalseQuery(this.dmpDescriptionTemplateQuery); + this.isEmpty(this.excludedIds) || this.isFalseQuery(this.planQuery) || + this.isEmpty(this.statuses) || this.isFalseQuery(this.planDescriptionTemplateQuery); } @Override @@ -326,9 +326,9 @@ public class DescriptionQuery extends QueryBase { notInClause.value(item); predicates.add(notInClause.not()); } - if (this.dmpIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId)); - for (UUID item : this.dmpIds) + if (this.planIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._planId)); + for (UUID item : this.planIds) inClause.value(item); predicates.add(inClause); } @@ -344,13 +344,13 @@ public class DescriptionQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } - if (this.dmpDescriptionTemplateQuery != null) { - QueryContext subQuery = this.applySubQuery(this.dmpDescriptionTemplateQuery, queryContext, UUID.class, dmpDescriptionTemplateEntityRoot -> dmpDescriptionTemplateEntityRoot.get(DmpDescriptionTemplateEntity._id)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)).value(subQuery.Query)); + if (this.planDescriptionTemplateQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planDescriptionTemplateQuery, queryContext, UUID.class, dmpDescriptionTemplateEntityRoot -> dmpDescriptionTemplateEntityRoot.get(PlanDescriptionTemplateEntity._id)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._planDescriptionTemplateId)).value(subQuery.Query)); } - if (this.dmpQuery != null) { - QueryContext subQuery = this.applySubQuery(this.dmpQuery, queryContext, UUID.class, dmpEntityRoot -> dmpEntityRoot.get(DmpEntity._id)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId)).value(subQuery.Query)); + if (this.planQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planQuery, queryContext, UUID.class, dmpEntityRoot -> dmpEntityRoot.get(PlanEntity._id)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._planId)).value(subQuery.Query)); } if (this.descriptionTemplateQuery != null) { QueryContext subQuery = this.applySubQuery(this.descriptionTemplateQuery, queryContext, UUID.class, descriptionTemplateEntityRoot -> descriptionTemplateEntityRoot.get(DescriptionTemplateEntity._id)); @@ -364,9 +364,9 @@ public class DescriptionQuery extends QueryBase { QueryContext subQuery = this.applySubQuery(this.descriptionTagQuery, queryContext, UUID.class, descriptionTagEntityRoot -> descriptionTagEntityRoot.get(DescriptionTagEntity._descriptionId)); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id)).value(subQuery.Query)); } - if (this.dmpDescriptionTemplateIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)); - for (UUID item : this.dmpDescriptionTemplateIds) + if (this.planDescriptionTemplateIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._planDescriptionTemplateId)); + for (UUID item : this.planDescriptionTemplateIds) inClause.value(item); predicates.add(inClause); } @@ -405,18 +405,18 @@ public class DescriptionQuery extends QueryBase { return DescriptionEntity._updatedAt; else if (item.match(Description._finalizedAt) || item.match(PublicDescription._finalizedAt)) return DescriptionEntity._finalizedAt; - else if (item.prefix(Description._dmpDescriptionTemplate) || item.prefix(PublicDescription._dmpDescriptionTemplate)) - return DescriptionEntity._dmpDescriptionTemplateId; - else if (item.match(Description._dmpDescriptionTemplate) || item.match(PublicDescription._dmpDescriptionTemplate)) - return DescriptionEntity._dmpDescriptionTemplateId; + else if (item.prefix(Description._planDescriptionTemplate) || item.prefix(PublicDescription._planDescriptionTemplate)) + return DescriptionEntity._planDescriptionTemplateId; + else if (item.match(Description._planDescriptionTemplate) || item.match(PublicDescription._planDescriptionTemplate)) + return DescriptionEntity._planDescriptionTemplateId; else if (item.prefix(Description._descriptionTemplate) || item.prefix(PublicDescription._descriptionTemplate)) return DescriptionEntity._descriptionTemplateId; else if (item.match(Description._descriptionTemplate) || item.match(PublicDescription._descriptionTemplate)) return DescriptionEntity._descriptionTemplateId; - else if (item.prefix(Description._dmp)) - return DescriptionEntity._dmpId; - else if (item.match(Description._dmp)) - return DescriptionEntity._dmpId; + else if (item.prefix(Description._plan)) + return DescriptionEntity._planId; + else if (item.match(Description._plan)) + return DescriptionEntity._planId; else if (item.match(Description._belongsToCurrentTenant)) return DescriptionEntity._tenantId; else if (item.match(DescriptionEntity._tenantId)) @@ -438,9 +438,9 @@ public class DescriptionQuery extends QueryBase { item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._updatedAt, Instant.class)); item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionEntity._isActive, IsActive.class)); item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._finalizedAt, Instant.class)); - item.setDmpDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpDescriptionTemplateId, UUID.class)); + item.setPlanDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._planDescriptionTemplateId, UUID.class)); item.setDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._descriptionTemplateId, UUID.class)); - item.setDmpId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpId, UUID.class)); + item.setPlanId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._planId, UUID.class)); return item; } 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 b732aa76e..4e16b068b 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java @@ -53,7 +53,7 @@ public class DescriptionTemplateQuery extends QueryBase authorize = EnumSet.of(AuthorizationFlags.None); @@ -207,8 +207,8 @@ public class DescriptionTemplateQuery extends QueryBase predicates = new ArrayList<>(); if (userId != null || usePublic) { Subquery dmpDescriptionTemplateSubquery = this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( - new BuildSubQueryInput.Builder<>(DmpDescriptionTemplateEntity.class, UUID.class, queryContext) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)) + new BuildSubQueryInput.Builder<>(PlanDescriptionTemplateEntity.class, UUID.class, queryContext) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(PlanDescriptionTemplateEntity._descriptionTemplateGroupId)) .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DmpDescriptionTemplateEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) + cb.in(subQueryRoot.get(PlanDescriptionTemplateEntity._planId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) ) )); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._groupId)).value(dmpDescriptionTemplateSubquery)); @@ -352,7 +352,7 @@ public class DescriptionTemplateQuery extends QueryBase subQuery = this.applySubQuery(this.dmpDescriptionTemplateQuery, queryContext, UUID.class, dmpDescriptionTemplateEntityRoot -> dmpDescriptionTemplateEntityRoot.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)); + if (this.planDescriptionTemplateQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planDescriptionTemplateQuery, queryContext, UUID.class, planDescriptionTemplateEntityRoot -> planDescriptionTemplateEntityRoot.get(PlanDescriptionTemplateEntity._descriptionTemplateGroupId)); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._groupId)).value(subQuery.Query)); } 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 bec4b92bc..1da0d8c25 100644 --- a/backend/core/src/main/java/org/opencdmp/query/EntityDoiQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/EntityDoiQuery.java @@ -13,7 +13,7 @@ import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.EntityType; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import org.opencdmp.data.EntityDoiEntity; import org.opencdmp.data.TenantEntityManager; import org.opencdmp.model.EntityDoi; @@ -274,7 +274,7 @@ public class EntityDoiQuery extends QueryBase { predicates.add(inClause); } if (this.after != null) { - Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(DmpEntity._createdAt), this.after); + Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(PlanEntity._createdAt), this.after); predicates.add(afterClause); } diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpBlueprintQuery.java b/backend/core/src/main/java/org/opencdmp/query/PlanBlueprintQuery.java similarity index 52% rename from backend/core/src/main/java/org/opencdmp/query/DmpBlueprintQuery.java rename to backend/core/src/main/java/org/opencdmp/query/PlanBlueprintQuery.java index 044b8ca68..c64975b8c 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpBlueprintQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PlanBlueprintQuery.java @@ -9,12 +9,12 @@ 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.PlanBlueprintStatus; +import org.opencdmp.commons.enums.PlanBlueprintVersionStatus; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.data.PlanBlueprintEntity; import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; +import org.opencdmp.model.planblueprint.PlanBlueprint; import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -25,7 +25,7 @@ import java.util.*; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpBlueprintQuery extends QueryBase { +public class PlanBlueprintQuery extends QueryBase { private String like; @@ -35,137 +35,137 @@ public class DmpBlueprintQuery extends QueryBase { private Collection isActives; - private Collection statuses; + private Collection statuses; private Collection groupIds; private Collection versions; - private Collection versionStatuses; + private Collection versionStatuses; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - public DmpBlueprintQuery like(String value) { + public PlanBlueprintQuery like(String value) { this.like = value; return this; } - public DmpBlueprintQuery ids(UUID value) { + public PlanBlueprintQuery ids(UUID value) { this.ids = List.of(value); return this; } - public DmpBlueprintQuery ids(UUID... value) { + public PlanBlueprintQuery ids(UUID... value) { this.ids = Arrays.asList(value); return this; } - public DmpBlueprintQuery ids(Collection values) { + public PlanBlueprintQuery ids(Collection values) { this.ids = values; return this; } - public DmpBlueprintQuery excludedIds(Collection values) { + public PlanBlueprintQuery excludedIds(Collection values) { this.excludedIds = values; return this; } - public DmpBlueprintQuery excludedIds(UUID value) { + public PlanBlueprintQuery excludedIds(UUID value) { this.excludedIds = List.of(value); return this; } - public DmpBlueprintQuery excludedIds(UUID... value) { + public PlanBlueprintQuery excludedIds(UUID... value) { this.excludedIds = Arrays.asList(value); return this; } - public DmpBlueprintQuery isActive(IsActive value) { + public PlanBlueprintQuery isActive(IsActive value) { this.isActives = List.of(value); return this; } - public DmpBlueprintQuery isActive(IsActive... value) { + public PlanBlueprintQuery isActive(IsActive... value) { this.isActives = Arrays.asList(value); return this; } - public DmpBlueprintQuery isActive(Collection values) { + public PlanBlueprintQuery isActive(Collection values) { this.isActives = values; return this; } - public DmpBlueprintQuery statuses(DmpBlueprintStatus value) { + public PlanBlueprintQuery statuses(PlanBlueprintStatus value) { this.statuses = List.of(value); return this; } - public DmpBlueprintQuery statuses(DmpBlueprintStatus... value) { + public PlanBlueprintQuery statuses(PlanBlueprintStatus... value) { this.statuses = Arrays.asList(value); return this; } - public DmpBlueprintQuery statuses(Collection values) { + public PlanBlueprintQuery statuses(Collection values) { this.statuses = values; return this; } - public DmpBlueprintQuery groupIds(UUID value) { + public PlanBlueprintQuery groupIds(UUID value) { this.groupIds = List.of(value); return this; } - public DmpBlueprintQuery groupIds(UUID... value) { + public PlanBlueprintQuery groupIds(UUID... value) { this.groupIds = Arrays.asList(value); return this; } - public DmpBlueprintQuery groupIds(Collection values) { + public PlanBlueprintQuery groupIds(Collection values) { this.groupIds = values; return this; } - public DmpBlueprintQuery versions(Short value) { + public PlanBlueprintQuery versions(Short value) { this.versions = List.of(value); return this; } - public DmpBlueprintQuery versions(Short... value) { + public PlanBlueprintQuery versions(Short... value) { this.versions = Arrays.asList(value); return this; } - public DmpBlueprintQuery versions(Collection values) { + public PlanBlueprintQuery versions(Collection values) { this.versions = values; return this; } - public DmpBlueprintQuery versionStatuses(DmpBlueprintVersionStatus value) { + public PlanBlueprintQuery versionStatuses(PlanBlueprintVersionStatus value) { this.versionStatuses = List.of(value); return this; } - public DmpBlueprintQuery versionStatuses(DmpBlueprintVersionStatus... value) { + public PlanBlueprintQuery versionStatuses(PlanBlueprintVersionStatus... value) { this.versionStatuses = Arrays.asList(value); return this; } - public DmpBlueprintQuery versionStatuses(Collection values) { + public PlanBlueprintQuery versionStatuses(Collection values) { this.versionStatuses = values; return this; } - public DmpBlueprintQuery authorize(EnumSet values) { + public PlanBlueprintQuery authorize(EnumSet values) { this.authorize = values; return this; } - public DmpBlueprintQuery enableTracking() { + public PlanBlueprintQuery enableTracking() { this.noTracking = false; return this; } - public DmpBlueprintQuery disableTracking() { + public PlanBlueprintQuery disableTracking() { this.noTracking = true; return this; } @@ -177,7 +177,7 @@ public class DmpBlueprintQuery extends QueryBase { private final QueryUtilsService queryUtilsService; private final TenantEntityManager tenantEntityManager; - public DmpBlueprintQuery( + public PlanBlueprintQuery( AuthorizationService authService, QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager ) { this.queryUtilsService = queryUtilsService; @@ -185,8 +185,8 @@ public class DmpBlueprintQuery extends QueryBase { } @Override - protected Class entityClass() { - return DmpBlueprintEntity.class; + protected Class entityClass() { + return PlanBlueprintEntity.class; } @Override @@ -199,54 +199,54 @@ public class DmpBlueprintQuery extends QueryBase { List predicates = new ArrayList<>(); if (this.ids != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._id)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanBlueprintEntity._id)); for (UUID item : this.ids) inClause.value(item); predicates.add(inClause); } if (this.excludedIds != null) { - CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._id)); + CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanBlueprintEntity._id)); for (UUID item : this.excludedIds) notInClause.value(item); predicates.add(notInClause.not()); } if (this.like != null && !this.like.isBlank()) { - predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpBlueprintEntity._label), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PlanBlueprintEntity._label), this.like)); } if (this.isActives != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._isActive)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanBlueprintEntity._isActive)); for (IsActive item : this.isActives) inClause.value(item); predicates.add(inClause); } if (this.statuses != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._status)); - for (DmpBlueprintStatus item : this.statuses) + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanBlueprintEntity._status)); + for (PlanBlueprintStatus item : this.statuses) inClause.value(item); predicates.add(inClause); } if (this.groupIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._groupId)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanBlueprintEntity._groupId)); for (UUID item : this.groupIds) inClause.value(item); predicates.add(inClause); } if (this.versions != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._version)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanBlueprintEntity._version)); for (Short item : this.versions) inClause.value(item); predicates.add(inClause); } if (this.versionStatuses != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._versionStatus)); - for (DmpBlueprintVersionStatus item : this.versionStatuses) + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanBlueprintEntity._versionStatus)); + for (PlanBlueprintVersionStatus item : this.versionStatuses) inClause.value(item); predicates.add(inClause); } @@ -260,50 +260,50 @@ public class DmpBlueprintQuery extends QueryBase { } @Override - protected DmpBlueprintEntity convert(Tuple tuple, Set columns) { - DmpBlueprintEntity item = new DmpBlueprintEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._id, UUID.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._tenantId, UUID.class)); - item.setLabel(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._label, String.class)); - item.setDefinition(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._definition, String.class)); - item.setStatus(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._status, DmpBlueprintStatus.class)); - item.setGroupId(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._groupId, UUID.class)); - item.setVersion(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._version, Short.class)); - item.setVersionStatus(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._versionStatus, DmpBlueprintVersionStatus.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._createdAt, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._updatedAt, Instant.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._isActive, IsActive.class)); + protected PlanBlueprintEntity convert(Tuple tuple, Set columns) { + PlanBlueprintEntity item = new PlanBlueprintEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._id, UUID.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._tenantId, UUID.class)); + item.setLabel(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._label, String.class)); + item.setDefinition(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._definition, String.class)); + item.setStatus(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._status, PlanBlueprintStatus.class)); + item.setGroupId(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._groupId, UUID.class)); + item.setVersion(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._version, Short.class)); + item.setVersionStatus(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._versionStatus, PlanBlueprintVersionStatus.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, PlanBlueprintEntity._isActive, IsActive.class)); return item; } @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(DmpBlueprint._id)) - return DmpBlueprintEntity._id; - else if (item.match(DmpBlueprint._label)) - return DmpBlueprintEntity._label; - else if (item.match(DmpBlueprint._definition)) - return DmpBlueprintEntity._definition; - else if (item.prefix(DmpBlueprint._definition)) - return DmpBlueprintEntity._definition; - else if (item.match(DmpBlueprint._status)) - return DmpBlueprintEntity._status; - else if (item.match(DmpBlueprint._groupId)) - return DmpBlueprintEntity._groupId; - else if (item.match(DmpBlueprint._version)) - return DmpBlueprintEntity._version; - else if (item.match(DmpBlueprint._versionStatus)) - return DmpBlueprintEntity._versionStatus; - else if (item.match(DmpBlueprint._createdAt)) - return DmpBlueprintEntity._createdAt; - else if (item.match(DmpBlueprint._updatedAt)) - return DmpBlueprintEntity._updatedAt; - else if (item.match(DmpBlueprint._isActive)) - return DmpBlueprintEntity._isActive; - else if (item.match(DmpBlueprint._hash)) - return DmpBlueprintEntity._updatedAt; - else if (item.match(DmpBlueprint._belongsToCurrentTenant)) - return DmpBlueprintEntity._tenantId; + if (item.match(PlanBlueprint._id)) + return PlanBlueprintEntity._id; + else if (item.match(PlanBlueprint._label)) + return PlanBlueprintEntity._label; + else if (item.match(PlanBlueprint._definition)) + return PlanBlueprintEntity._definition; + else if (item.prefix(PlanBlueprint._definition)) + return PlanBlueprintEntity._definition; + else if (item.match(PlanBlueprint._status)) + return PlanBlueprintEntity._status; + else if (item.match(PlanBlueprint._groupId)) + return PlanBlueprintEntity._groupId; + else if (item.match(PlanBlueprint._version)) + return PlanBlueprintEntity._version; + else if (item.match(PlanBlueprint._versionStatus)) + return PlanBlueprintEntity._versionStatus; + else if (item.match(PlanBlueprint._createdAt)) + return PlanBlueprintEntity._createdAt; + else if (item.match(PlanBlueprint._updatedAt)) + return PlanBlueprintEntity._updatedAt; + else if (item.match(PlanBlueprint._isActive)) + return PlanBlueprintEntity._isActive; + else if (item.match(PlanBlueprint._hash)) + return PlanBlueprintEntity._updatedAt; + else if (item.match(PlanBlueprint._belongsToCurrentTenant)) + return PlanBlueprintEntity._tenantId; else return null; } diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpDescriptionTemplateQuery.java b/backend/core/src/main/java/org/opencdmp/query/PlanDescriptionTemplateQuery.java similarity index 54% rename from backend/core/src/main/java/org/opencdmp/query/DmpDescriptionTemplateQuery.java rename to backend/core/src/main/java/org/opencdmp/query/PlanDescriptionTemplateQuery.java index c2be75564..45318bf5f 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpDescriptionTemplateQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PlanDescriptionTemplateQuery.java @@ -13,10 +13,10 @@ 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.PlanDescriptionTemplateEntity; import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.model.DmpDescriptionTemplate; -import org.opencdmp.model.PublicDmpDescriptionTemplate; +import org.opencdmp.model.PlanDescriptionTemplate; +import org.opencdmp.model.PublicPlanDescriptionTemplate; import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -27,11 +27,11 @@ import java.util.*; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpDescriptionTemplateQuery extends QueryBase { +public class PlanDescriptionTemplateQuery extends QueryBase { private Collection ids; - private Collection dmpIds; + private Collection planIds; private Collection descriptionTemplateGroupIds; @@ -47,117 +47,117 @@ public class DmpDescriptionTemplateQuery extends QueryBase authorize = EnumSet.of(AuthorizationFlags.None); - public DmpDescriptionTemplateQuery ids(UUID value) { + public PlanDescriptionTemplateQuery ids(UUID value) { this.ids = List.of(value); return this; } - public DmpDescriptionTemplateQuery ids(UUID... value) { + public PlanDescriptionTemplateQuery ids(UUID... value) { this.ids = Arrays.asList(value); return this; } - public DmpDescriptionTemplateQuery ids(Collection values) { + public PlanDescriptionTemplateQuery ids(Collection values) { this.ids = values; return this; } - public DmpDescriptionTemplateQuery excludedIds(Collection values) { + public PlanDescriptionTemplateQuery excludedIds(Collection values) { this.excludedIds = values; return this; } - public DmpDescriptionTemplateQuery excludedIds(UUID value) { + public PlanDescriptionTemplateQuery excludedIds(UUID value) { this.excludedIds = List.of(value); return this; } - public DmpDescriptionTemplateQuery excludedIds(UUID... value) { + public PlanDescriptionTemplateQuery excludedIds(UUID... value) { this.excludedIds = Arrays.asList(value); return this; } - public DmpDescriptionTemplateQuery isActive(IsActive value) { + public PlanDescriptionTemplateQuery isActive(IsActive value) { this.isActives = List.of(value); return this; } - public DmpDescriptionTemplateQuery isActive(IsActive... value) { + public PlanDescriptionTemplateQuery isActive(IsActive... value) { this.isActives = Arrays.asList(value); return this; } - public DmpDescriptionTemplateQuery isActive(Collection values) { + public PlanDescriptionTemplateQuery isActive(Collection values) { this.isActives = values; return this; } - public DmpDescriptionTemplateQuery sectionIds(UUID value) { + public PlanDescriptionTemplateQuery sectionIds(UUID value) { this.sectionIds = List.of(value); return this; } - public DmpDescriptionTemplateQuery sectionIds(UUID... value) { + public PlanDescriptionTemplateQuery sectionIds(UUID... value) { this.sectionIds = Arrays.asList(value); return this; } - public DmpDescriptionTemplateQuery sectionIds(Collection values) { + public PlanDescriptionTemplateQuery sectionIds(Collection values) { this.sectionIds = values; return this; } - public DmpDescriptionTemplateQuery descriptionTemplateGroupIds(UUID value) { + public PlanDescriptionTemplateQuery descriptionTemplateGroupIds(UUID value) { this.descriptionTemplateGroupIds = List.of(value); return this; } - public DmpDescriptionTemplateQuery descriptionTemplateGroupIds(UUID... value) { + public PlanDescriptionTemplateQuery descriptionTemplateGroupIds(UUID... value) { this.descriptionTemplateGroupIds = Arrays.asList(value); return this; } - public DmpDescriptionTemplateQuery descriptionTemplateGroupIds(Collection values) { + public PlanDescriptionTemplateQuery descriptionTemplateGroupIds(Collection values) { this.descriptionTemplateGroupIds = values; return this; } - public DmpDescriptionTemplateQuery dmpIds(UUID value) { - this.dmpIds = List.of(value); + public PlanDescriptionTemplateQuery planIds(UUID value) { + this.planIds = List.of(value); return this; } - public DmpDescriptionTemplateQuery dmpIds(UUID... value) { - this.dmpIds = Arrays.asList(value); + public PlanDescriptionTemplateQuery planIds(UUID... value) { + this.planIds = Arrays.asList(value); return this; } - public DmpDescriptionTemplateQuery dmpIds(Collection values) { - this.dmpIds = values; + public PlanDescriptionTemplateQuery planIds(Collection values) { + this.planIds = values; return this; } - public DmpDescriptionTemplateQuery after(Instant value) { + public PlanDescriptionTemplateQuery after(Instant value) { this.after = value; return this; } - public DmpDescriptionTemplateQuery descriptionTemplateSubQuery(DescriptionTemplateQuery value) { + public PlanDescriptionTemplateQuery descriptionTemplateSubQuery(DescriptionTemplateQuery value) { this.descriptionTemplateQuery = value; return this; } - public DmpDescriptionTemplateQuery authorize(EnumSet values) { + public PlanDescriptionTemplateQuery authorize(EnumSet values) { this.authorize = values; return this; } - public DmpDescriptionTemplateQuery enableTracking() { + public PlanDescriptionTemplateQuery enableTracking() { this.noTracking = false; return this; } - public DmpDescriptionTemplateQuery disableTracking() { + public PlanDescriptionTemplateQuery disableTracking() { this.noTracking = true; return this; } @@ -174,7 +174,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase entityClass() { - return DmpDescriptionTemplateEntity.class; + protected Class entityClass() { + return PlanDescriptionTemplateEntity.class; } @Override protected Boolean isFalseQuery() { - return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) || this.isEmpty(this.dmpIds) || this.isEmpty(this.descriptionTemplateGroupIds); + return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) || this.isEmpty(this.planIds) || this.isEmpty(this.descriptionTemplateGroupIds); } @Override protected Predicate applyAuthZ(QueryContext queryContext) { if (this.authorize.contains(AuthorizationFlags.None)) return null; - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDmpDescriptionTemplate)) + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowsePlanDescriptionTemplate)) return null; UUID userId = null; boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); @@ -205,7 +205,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase predicates = new ArrayList<>(); if (userId != null || usePublic) { - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanDescriptionTemplateEntity._planId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); @@ -219,48 +219,48 @@ public class DmpDescriptionTemplateQuery extends QueryBase Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.ids != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._id)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanDescriptionTemplateEntity._id)); for (UUID item : this.ids) inClause.value(item); predicates.add(inClause); } if (this.excludedIds != null) { - CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._id)); + CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanDescriptionTemplateEntity._id)); for (UUID item : this.excludedIds) notInClause.value(item); predicates.add(notInClause.not()); } - if (this.dmpIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._dmpId)); - for (UUID item : this.dmpIds) + if (this.planIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanDescriptionTemplateEntity._planId)); + for (UUID item : this.planIds) inClause.value(item); predicates.add(inClause); } if (this.descriptionTemplateGroupIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanDescriptionTemplateEntity._descriptionTemplateGroupId)); for (UUID item : this.descriptionTemplateGroupIds) inClause.value(item); predicates.add(inClause); } if (this.sectionIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._sectionId)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanDescriptionTemplateEntity._sectionId)); for (UUID item : this.sectionIds) inClause.value(item); predicates.add(inClause); } if (this.isActives != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._isActive)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanDescriptionTemplateEntity._isActive)); for (IsActive item : this.isActives) inClause.value(item); predicates.add(inClause); } if (this.after != null) { - Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(DmpDescriptionTemplateEntity._createdAt), this.after); + Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(PlanDescriptionTemplateEntity._createdAt), this.after); predicates.add(afterClause); } if (this.descriptionTemplateQuery != null) { QueryContext subQuery = this.applySubQuery(this.descriptionTemplateQuery, queryContext, UUID.class, descriptionTemplateEntityRoot -> descriptionTemplateEntityRoot.get(DescriptionTemplateEntity._groupId)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)).value(subQuery.Query)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanDescriptionTemplateEntity._descriptionTemplateGroupId)).value(subQuery.Query)); } if (!predicates.isEmpty()) { @@ -272,49 +272,49 @@ public class DmpDescriptionTemplateQuery extends QueryBase columns) { - DmpDescriptionTemplateEntity item = new DmpDescriptionTemplateEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._id, UUID.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._tenantId, UUID.class)); - item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._dmpId, UUID.class)); - item.setDescriptionTemplateGroupId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._descriptionTemplateGroupId, UUID.class)); - item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._sectionId, UUID.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._createdAt, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._updatedAt, Instant.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._isActive, IsActive.class)); + protected PlanDescriptionTemplateEntity convert(Tuple tuple, Set columns) { + PlanDescriptionTemplateEntity item = new PlanDescriptionTemplateEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, PlanDescriptionTemplateEntity._id, UUID.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, PlanDescriptionTemplateEntity._tenantId, UUID.class)); + item.setPlanId(QueryBase.convertSafe(tuple, columns, PlanDescriptionTemplateEntity._planId, UUID.class)); + item.setDescriptionTemplateGroupId(QueryBase.convertSafe(tuple, columns, PlanDescriptionTemplateEntity._descriptionTemplateGroupId, UUID.class)); + item.setSectionId(QueryBase.convertSafe(tuple, columns, PlanDescriptionTemplateEntity._sectionId, UUID.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, PlanDescriptionTemplateEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, PlanDescriptionTemplateEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, PlanDescriptionTemplateEntity._isActive, IsActive.class)); return item; } @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(DmpDescriptionTemplate._id) || item.match(PublicDmpDescriptionTemplate._id)) - return DmpDescriptionTemplateEntity._id; - else if (item.prefix(DmpDescriptionTemplate._dmp) || item.prefix(PublicDmpDescriptionTemplate._dmp)) - return DmpDescriptionTemplateEntity._dmpId; - else if (item.match(DmpDescriptionTemplate._dmp) || item.prefix(PublicDmpDescriptionTemplate._dmp)) - return DmpDescriptionTemplateEntity._dmpId; - else if (item.prefix(DmpDescriptionTemplate._currentDescriptionTemplate)) - return DmpDescriptionTemplateEntity._descriptionTemplateGroupId; - else if (item.match(DmpDescriptionTemplate._currentDescriptionTemplate)) - return DmpDescriptionTemplateEntity._descriptionTemplateGroupId; - else if (item.prefix(DmpDescriptionTemplate._descriptionTemplates)) - return DmpDescriptionTemplateEntity._descriptionTemplateGroupId; - else if (item.match(DmpDescriptionTemplate._descriptionTemplates)) - return DmpDescriptionTemplateEntity._descriptionTemplateGroupId; - else if (item.match(DmpDescriptionTemplate._sectionId)) - return DmpDescriptionTemplateEntity._sectionId; - else if (item.match(DmpDescriptionTemplate._descriptionTemplateGroupId)) - return DmpDescriptionTemplateEntity._descriptionTemplateGroupId; - else if (item.match(DmpDescriptionTemplate._hash)) - return DmpDescriptionTemplateEntity._updatedAt; - else if (item.match(DmpDescriptionTemplate._createdAt)) - return DmpDescriptionTemplateEntity._createdAt; - else if (item.match(DmpDescriptionTemplate._updatedAt)) - return DmpDescriptionTemplateEntity._updatedAt; - else if (item.match(DmpDescriptionTemplate._isActive)) - return DmpDescriptionTemplateEntity._isActive; - else if (item.match(DmpDescriptionTemplate._belongsToCurrentTenant)) - return DmpDescriptionTemplateEntity._tenantId; + if (item.match(PlanDescriptionTemplate._id) || item.match(PublicPlanDescriptionTemplate._id)) + return PlanDescriptionTemplateEntity._id; + else if (item.prefix(PlanDescriptionTemplate._plan) || item.prefix(PublicPlanDescriptionTemplate._plan)) + return PlanDescriptionTemplateEntity._planId; + else if (item.match(PlanDescriptionTemplate._plan) || item.prefix(PublicPlanDescriptionTemplate._plan)) + return PlanDescriptionTemplateEntity._planId; + else if (item.prefix(PlanDescriptionTemplate._currentDescriptionTemplate)) + return PlanDescriptionTemplateEntity._descriptionTemplateGroupId; + else if (item.match(PlanDescriptionTemplate._currentDescriptionTemplate)) + return PlanDescriptionTemplateEntity._descriptionTemplateGroupId; + else if (item.prefix(PlanDescriptionTemplate._descriptionTemplates)) + return PlanDescriptionTemplateEntity._descriptionTemplateGroupId; + else if (item.match(PlanDescriptionTemplate._descriptionTemplates)) + return PlanDescriptionTemplateEntity._descriptionTemplateGroupId; + else if (item.match(PlanDescriptionTemplate._sectionId)) + return PlanDescriptionTemplateEntity._sectionId; + else if (item.match(PlanDescriptionTemplate._descriptionTemplateGroupId)) + return PlanDescriptionTemplateEntity._descriptionTemplateGroupId; + else if (item.match(PlanDescriptionTemplate._hash)) + return PlanDescriptionTemplateEntity._updatedAt; + else if (item.match(PlanDescriptionTemplate._createdAt)) + return PlanDescriptionTemplateEntity._createdAt; + else if (item.match(PlanDescriptionTemplate._updatedAt)) + return PlanDescriptionTemplateEntity._updatedAt; + else if (item.match(PlanDescriptionTemplate._isActive)) + return PlanDescriptionTemplateEntity._isActive; + else if (item.match(PlanDescriptionTemplate._belongsToCurrentTenant)) + return PlanDescriptionTemplateEntity._tenantId; else return null; } diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java b/backend/core/src/main/java/org/opencdmp/query/PlanQuery.java similarity index 51% rename from backend/core/src/main/java/org/opencdmp/query/DmpQuery.java rename to backend/core/src/main/java/org/opencdmp/query/PlanQuery.java index b307903a0..dfdcd1ae3 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PlanQuery.java @@ -13,8 +13,8 @@ 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.model.PublicPlan; +import org.opencdmp.model.plan.Plan; import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -25,7 +25,7 @@ import java.util.*; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpQuery extends QueryBase { +public class PlanQuery extends QueryBase { private String like; @@ -37,11 +37,11 @@ public class DmpQuery extends QueryBase { private Collection isActives; - private Collection statuses; + private Collection statuses; - private Collection versionStatuses; + private Collection versionStatuses; - private Collection accessTypes; + private Collection accessTypes; private Collection versions; @@ -49,13 +49,13 @@ public class DmpQuery extends QueryBase { private Instant after; - private DmpUserQuery dmpUserQuery; + private PlanUserQuery planUserQuery; - private DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery; + private PlanDescriptionTemplateQuery planDescriptionTemplateQuery; - private DmpBlueprintQuery dmpBlueprintQuery; + private PlanBlueprintQuery planBlueprintQuery; - private DmpReferenceQuery dmpReferenceQuery; + private PlanReferenceQuery planReferenceQuery; private EntityDoiQuery entityDoiQuery; @@ -68,195 +68,195 @@ public class DmpQuery extends QueryBase { private final QueryUtilsService queryUtilsService; private final TenantEntityManager tenantEntityManager; - public DmpQuery(UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) { + public PlanQuery(UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) { this.userScope = userScope; this.authService = authService; this.queryUtilsService = queryUtilsService; this.tenantEntityManager = tenantEntityManager; } - public DmpQuery like(String value) { + public PlanQuery like(String value) { this.like = value; return this; } - public DmpQuery ids(UUID value) { + public PlanQuery ids(UUID value) { this.ids = List.of(value); return this; } - public DmpQuery ids(UUID... value) { + public PlanQuery ids(UUID... value) { this.ids = Arrays.asList(value); return this; } - public DmpQuery ids(Collection values) { + public PlanQuery ids(Collection values) { this.ids = values; return this; } - public DmpQuery creatorIds(UUID value) { + public PlanQuery creatorIds(UUID value) { this.creatorIds = List.of(value); return this; } - public DmpQuery creatorIds(UUID... value) { + public PlanQuery creatorIds(UUID... value) { this.creatorIds = Arrays.asList(value); return this; } - public DmpQuery creatorIds(Collection values) { + public PlanQuery creatorIds(Collection values) { this.creatorIds = values; return this; } - public DmpQuery excludedIds(Collection values) { + public PlanQuery excludedIds(Collection values) { this.excludedIds = values; return this; } - public DmpQuery excludedIds(UUID value) { + public PlanQuery excludedIds(UUID value) { this.excludedIds = List.of(value); return this; } - public DmpQuery excludedIds(UUID... value) { + public PlanQuery excludedIds(UUID... value) { this.excludedIds = Arrays.asList(value); return this; } - public DmpQuery isActive(IsActive value) { + public PlanQuery isActive(IsActive value) { this.isActives = List.of(value); return this; } - public DmpQuery isActive(IsActive... value) { + public PlanQuery isActive(IsActive... value) { this.isActives = Arrays.asList(value); return this; } - public DmpQuery isActive(Collection values) { + public PlanQuery isActive(Collection values) { this.isActives = values; return this; } - public DmpQuery versionStatuses(DmpVersionStatus value) { + public PlanQuery versionStatuses(PlanVersionStatus value) { this.versionStatuses = List.of(value); return this; } - public DmpQuery versionStatuses(DmpVersionStatus... value) { + public PlanQuery versionStatuses(PlanVersionStatus... value) { this.versionStatuses = Arrays.asList(value); return this; } - public DmpQuery versionStatuses(Collection values) { + public PlanQuery versionStatuses(Collection values) { this.versionStatuses = values; return this; } - public DmpQuery accessTypes(DmpAccessType value) { + public PlanQuery accessTypes(PlanAccessType value) { this.accessTypes = List.of(value); return this; } - public DmpQuery accessTypes(DmpAccessType... value) { + public PlanQuery accessTypes(PlanAccessType... value) { this.accessTypes = Arrays.asList(value); return this; } - public DmpQuery accessTypes(Collection values) { + public PlanQuery accessTypes(Collection values) { this.accessTypes = values; return this; } - public DmpQuery statuses(DmpStatus value) { + public PlanQuery statuses(PlanStatus value) { this.statuses = List.of(value); return this; } - public DmpQuery statuses(DmpStatus... value) { + public PlanQuery statuses(PlanStatus... value) { this.statuses = Arrays.asList(value); return this; } - public DmpQuery statuses(Collection values) { + public PlanQuery statuses(Collection values) { this.statuses = values; return this; } - public DmpQuery versions(Integer value) { + public PlanQuery versions(Integer value) { this.versions = List.of(value); return this; } - public DmpQuery versions(Integer... value) { + public PlanQuery versions(Integer... value) { this.versions = Arrays.asList(value); return this; } - public DmpQuery versions(Collection values) { + public PlanQuery versions(Collection values) { this.versions = values; return this; } - public DmpQuery groupIds(UUID value) { + public PlanQuery groupIds(UUID value) { this.groupIds = List.of(value); return this; } - public DmpQuery groupIds(UUID... value) { + public PlanQuery groupIds(UUID... value) { this.groupIds = Arrays.asList(value); return this; } - public DmpQuery groupIds(Collection values) { + public PlanQuery groupIds(Collection values) { this.groupIds = values; return this; } - public DmpQuery after(Instant value) { + public PlanQuery after(Instant value) { this.after = value; return this; } - public DmpQuery dmpDescriptionTemplateSubQuery(DmpDescriptionTemplateQuery subQuery) { - this.dmpDescriptionTemplateQuery = subQuery; + public PlanQuery planDescriptionTemplateSubQuery(PlanDescriptionTemplateQuery subQuery) { + this.planDescriptionTemplateQuery = subQuery; return this; } - public DmpQuery dmpBlueprintSubQuery(DmpBlueprintQuery subQuery) { - this.dmpBlueprintQuery = subQuery; + public PlanQuery planBlueprintSubQuery(PlanBlueprintQuery subQuery) { + this.planBlueprintQuery = subQuery; return this; } - public DmpQuery dmpUserSubQuery(DmpUserQuery subQuery) { - this.dmpUserQuery = subQuery; + public PlanQuery planUserSubQuery(PlanUserQuery subQuery) { + this.planUserQuery = subQuery; return this; } - public DmpQuery dmpReferenceSubQuery(DmpReferenceQuery subQuery) { - this.dmpReferenceQuery = subQuery; + public PlanQuery planReferenceSubQuery(PlanReferenceQuery subQuery) { + this.planReferenceQuery = subQuery; return this; } - public DmpQuery entityDoiSubQuery(EntityDoiQuery subQuery) { + public PlanQuery entityDoiSubQuery(EntityDoiQuery subQuery) { this.entityDoiQuery = subQuery; this.entityDoiQuery.types(EntityType.DMP); return this; } - public DmpQuery authorize(EnumSet values) { + public PlanQuery authorize(EnumSet values) { this.authorize = values; return this; } - public DmpQuery enableTracking() { + public PlanQuery enableTracking() { this.noTracking = false; return this; } - public DmpQuery disableTracking() { + public PlanQuery disableTracking() { this.noTracking = true; return this; } @@ -268,19 +268,19 @@ public class DmpQuery extends QueryBase { @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); + 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.planDescriptionTemplateQuery) || this.isFalseQuery(this.planUserQuery); } @Override - protected Class entityClass() { - return DmpEntity.class; + protected Class entityClass() { + return PlanEntity.class; } @Override protected Predicate applyAuthZ(QueryContext queryContext) { if (this.authorize.contains(AuthorizationFlags.None)) return null; - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDmp)) + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowsePlan)) return null; UUID userId = null; boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); @@ -291,11 +291,11 @@ public class DmpQuery extends QueryBase { if (userId != null || usePublic) { predicates.add(queryContext.CriteriaBuilder.or( usePublic ? queryContext.CriteriaBuilder.and( - queryContext.CriteriaBuilder.equal(queryContext.Root.get(DmpEntity._status), DmpStatus.Finalized), - queryContext.CriteriaBuilder.equal(queryContext.Root.get(DmpEntity._accessType), DmpAccessType.Public) + queryContext.CriteriaBuilder.equal(queryContext.Root.get(PlanEntity._status), PlanStatus.Finalized), + queryContext.CriteriaBuilder.equal(queryContext.Root.get(PlanEntity._accessType), PlanAccessType.Public) ) : queryContext.CriteriaBuilder.or(), //Creates a false query - userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(this.queryUtilsService.buildDmpUserAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId)) : queryContext.CriteriaBuilder.or() //Creates a false query + userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._id)).value(this.queryUtilsService.buildDmpUserAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId)) : queryContext.CriteriaBuilder.or() //Creates a false query )); } if (!predicates.isEmpty()) { @@ -310,90 +310,90 @@ public class DmpQuery extends QueryBase { protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.like != null && !this.like.isBlank()) { - predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpEntity._label), this.like)); + predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PlanEntity._label), this.like)); } if (this.ids != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._id)); for (UUID item : this.ids) inClause.value(item); predicates.add(inClause); } if (this.creatorIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._creatorId)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._creatorId)); for (UUID item : this.creatorIds) inClause.value(item); predicates.add(inClause); } if (this.excludedIds != null) { - CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)); + CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._id)); for (UUID item : this.excludedIds) notInClause.value(item); predicates.add(notInClause.not()); } if (this.isActives != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._isActive)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._isActive)); for (IsActive item : this.isActives) inClause.value(item); predicates.add(inClause); } if (this.statuses != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._status)); - for (DmpStatus item : this.statuses) + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._status)); + for (PlanStatus item : this.statuses) inClause.value(item); predicates.add(inClause); } if (this.versionStatuses != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._versionStatus)); - for (DmpVersionStatus item : this.versionStatuses) + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._versionStatus)); + for (PlanVersionStatus item : this.versionStatuses) inClause.value(item); predicates.add(inClause); } if (this.accessTypes != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._accessType)); - for (DmpAccessType item : this.accessTypes) + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._accessType)); + for (PlanAccessType item : this.accessTypes) inClause.value(item); predicates.add(inClause); } if (this.versions != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._version)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._version)); for (Integer item : this.versions) inClause.value(item); predicates.add(inClause); } if (this.groupIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._groupId)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._groupId)); for (UUID item : this.groupIds) inClause.value(item); predicates.add(inClause); } if (this.after != null) { - Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(DmpEntity._createdAt), this.after); + Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(PlanEntity._createdAt), this.after); predicates.add(afterClause); } - if (this.dmpUserQuery != null) { - QueryContext subQuery = this.applySubQuery(this.dmpUserQuery, queryContext, UUID.class, root -> root.get(DmpUserEntity._dmpId)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(subQuery.Query)); + if (this.planUserQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planUserQuery, queryContext, UUID.class, root -> root.get(PlanUserEntity._planId)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._id)).value(subQuery.Query)); } - if (this.dmpDescriptionTemplateQuery != null) { - QueryContext subQuery = this.applySubQuery(this.dmpDescriptionTemplateQuery, queryContext, UUID.class, dmpDescriptionTemplateEntityRoot -> dmpDescriptionTemplateEntityRoot.get(DmpDescriptionTemplateEntity._dmpId)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(subQuery.Query)); + if (this.planDescriptionTemplateQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planDescriptionTemplateQuery, queryContext, UUID.class, planDescriptionTemplateEntityRoot -> planDescriptionTemplateEntityRoot.get(PlanDescriptionTemplateEntity._planId)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._id)).value(subQuery.Query)); } - if (this.dmpBlueprintQuery != null) { - QueryContext subQuery = this.applySubQuery(this.dmpBlueprintQuery, queryContext, UUID.class, dmpBlueprintEntityRoot -> dmpBlueprintEntityRoot.get(DmpBlueprintEntity._id)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._blueprintId)).value(subQuery.Query)); + if (this.planBlueprintQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planBlueprintQuery, queryContext, UUID.class, planBlueprintEntityRoot -> planBlueprintEntityRoot.get(PlanBlueprintEntity._id)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._blueprintId)).value(subQuery.Query)); } - if (this.dmpReferenceQuery != null) { - QueryContext subQuery = this.applySubQuery(this.dmpReferenceQuery, queryContext, UUID.class, dmpReferenceEntityRoot -> dmpReferenceEntityRoot.get(DmpReferenceEntity._dmpId)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(subQuery.Query)); + if (this.planReferenceQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planReferenceQuery, queryContext, UUID.class, planReferenceEntityRoot -> planReferenceEntityRoot.get(PlanReferenceEntity._planId)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._id)).value(subQuery.Query)); } if (this.entityDoiQuery != null) { QueryContext subQuery = this.applySubQuery(this.entityDoiQuery, queryContext, UUID.class, entityDoiEntityRoot -> entityDoiEntityRoot.get(EntityDoiEntity._entityId)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(subQuery.Query)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._id)).value(subQuery.Query)); } if (!predicates.isEmpty()) { @@ -406,77 +406,77 @@ public class DmpQuery extends QueryBase { @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(Dmp._id) || item.match(PublicDmp._id)) - return DmpEntity._id; - else if (item.match(Dmp._label) || item.match(PublicDmp._label)) - return DmpEntity._label; - else if (item.match(Dmp._version) || item.match(PublicDmp._version)) - return DmpEntity._version; - else if (item.match(Dmp._status)) - return DmpEntity._status; - else if (item.match(Dmp._properties)) - return DmpEntity._properties; - else if (item.prefix(Dmp._properties)) - return DmpEntity._properties; - else if (item.match(Dmp._groupId)) - return DmpEntity._groupId; - else if (item.match(Dmp._description) || item.match(PublicDmp._description)) - return DmpEntity._description; - else if (item.match(Dmp._createdAt)) - return DmpEntity._createdAt; - else if (item.match(Dmp._updatedAt)) - return DmpEntity._updatedAt; - else if (item.match(Dmp._hash)) - return DmpEntity._updatedAt; - else if (item.match(Dmp._isActive)) - return DmpEntity._isActive; - else if (item.match(Dmp._finalizedAt) || item.match(PublicDmp._finalizedAt)) - return DmpEntity._finalizedAt; - else if (item.match(Dmp._accessType)) - return DmpEntity._accessType; - else if (item.match(Dmp._creator)) - return DmpEntity._creatorId; - else if (item.prefix(Dmp._creator)) - return DmpEntity._blueprintId; - else if (item.match(Dmp._blueprint)) - return DmpEntity._blueprintId; - else if (item.prefix(Dmp._blueprint)) - return DmpEntity._blueprintId; - else if (item.match(Dmp._language)) - return DmpEntity._language; - else if (item.match(Dmp._publicAfter)) - return DmpEntity._publicAfter; - else if (item.match(Dmp._versionStatus)) - return DmpEntity._versionStatus; - else if (item.match(DmpEntity._tenantId)) - return DmpEntity._tenantId; - else if (item.match(Dmp._belongsToCurrentTenant)) - return DmpEntity._tenantId; + if (item.match(Plan._id) || item.match(PublicPlan._id)) + return PlanEntity._id; + else if (item.match(Plan._label) || item.match(PublicPlan._label)) + return PlanEntity._label; + else if (item.match(Plan._version) || item.match(PublicPlan._version)) + return PlanEntity._version; + else if (item.match(Plan._status)) + return PlanEntity._status; + else if (item.match(Plan._properties)) + return PlanEntity._properties; + else if (item.prefix(Plan._properties)) + return PlanEntity._properties; + else if (item.match(Plan._groupId)) + return PlanEntity._groupId; + else if (item.match(Plan._description) || item.match(PublicPlan._description)) + return PlanEntity._description; + else if (item.match(Plan._createdAt)) + return PlanEntity._createdAt; + else if (item.match(Plan._updatedAt)) + return PlanEntity._updatedAt; + else if (item.match(Plan._hash)) + return PlanEntity._updatedAt; + else if (item.match(Plan._isActive)) + return PlanEntity._isActive; + else if (item.match(Plan._finalizedAt) || item.match(PublicPlan._finalizedAt)) + return PlanEntity._finalizedAt; + else if (item.match(Plan._accessType)) + return PlanEntity._accessType; + else if (item.match(Plan._creator)) + return PlanEntity._creatorId; + else if (item.prefix(Plan._creator)) + return PlanEntity._blueprintId; + else if (item.match(Plan._blueprint)) + return PlanEntity._blueprintId; + else if (item.prefix(Plan._blueprint)) + return PlanEntity._blueprintId; + else if (item.match(Plan._language)) + return PlanEntity._language; + else if (item.match(Plan._publicAfter)) + return PlanEntity._publicAfter; + else if (item.match(Plan._versionStatus)) + return PlanEntity._versionStatus; + else if (item.match(PlanEntity._tenantId)) + return PlanEntity._tenantId; + else if (item.match(Plan._belongsToCurrentTenant)) + return PlanEntity._tenantId; else return null; } @Override - protected DmpEntity convert(Tuple tuple, Set columns) { - DmpEntity item = new DmpEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, DmpEntity._id, UUID.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpEntity._tenantId, UUID.class)); - item.setLabel(QueryBase.convertSafe(tuple, columns, DmpEntity._label, String.class)); - item.setVersion(QueryBase.convertSafe(tuple, columns, DmpEntity._version, Short.class)); - item.setStatus(QueryBase.convertSafe(tuple, columns, DmpEntity._status, DmpStatus.class)); - item.setVersionStatus(QueryBase.convertSafe(tuple, columns, DmpEntity._versionStatus, DmpVersionStatus.class)); - item.setProperties(QueryBase.convertSafe(tuple, columns, DmpEntity._properties, String.class)); - item.setGroupId(QueryBase.convertSafe(tuple, columns, DmpEntity._groupId, UUID.class)); - item.setDescription(QueryBase.convertSafe(tuple, columns, DmpEntity._description, String.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpEntity._createdAt, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpEntity._updatedAt, Instant.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpEntity._isActive, IsActive.class)); - item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DmpEntity._finalizedAt, Instant.class)); - item.setAccessType(QueryBase.convertSafe(tuple, columns, DmpEntity._accessType, DmpAccessType.class)); - item.setCreatorId(QueryBase.convertSafe(tuple, columns, DmpEntity._creatorId, UUID.class)); - item.setBlueprintId(QueryBase.convertSafe(tuple, columns, DmpEntity._blueprintId, UUID.class)); - item.setLanguage(QueryBase.convertSafe(tuple, columns, DmpEntity._language, String.class)); - item.setPublicAfter(QueryBase.convertSafe(tuple, columns, DmpEntity._publicAfter, Instant.class)); + protected PlanEntity convert(Tuple tuple, Set columns) { + PlanEntity item = new PlanEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, PlanEntity._id, UUID.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, PlanEntity._tenantId, UUID.class)); + item.setLabel(QueryBase.convertSafe(tuple, columns, PlanEntity._label, String.class)); + item.setVersion(QueryBase.convertSafe(tuple, columns, PlanEntity._version, Short.class)); + item.setStatus(QueryBase.convertSafe(tuple, columns, PlanEntity._status, PlanStatus.class)); + item.setVersionStatus(QueryBase.convertSafe(tuple, columns, PlanEntity._versionStatus, PlanVersionStatus.class)); + item.setProperties(QueryBase.convertSafe(tuple, columns, PlanEntity._properties, String.class)); + item.setGroupId(QueryBase.convertSafe(tuple, columns, PlanEntity._groupId, UUID.class)); + item.setDescription(QueryBase.convertSafe(tuple, columns, PlanEntity._description, String.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, PlanEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, PlanEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, PlanEntity._isActive, IsActive.class)); + item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, PlanEntity._finalizedAt, Instant.class)); + item.setAccessType(QueryBase.convertSafe(tuple, columns, PlanEntity._accessType, PlanAccessType.class)); + item.setCreatorId(QueryBase.convertSafe(tuple, columns, PlanEntity._creatorId, UUID.class)); + item.setBlueprintId(QueryBase.convertSafe(tuple, columns, PlanEntity._blueprintId, UUID.class)); + item.setLanguage(QueryBase.convertSafe(tuple, columns, PlanEntity._language, String.class)); + item.setPublicAfter(QueryBase.convertSafe(tuple, columns, PlanEntity._publicAfter, Instant.class)); return item; } diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpReferenceQuery.java b/backend/core/src/main/java/org/opencdmp/query/PlanReferenceQuery.java similarity index 55% rename from backend/core/src/main/java/org/opencdmp/query/DmpReferenceQuery.java rename to backend/core/src/main/java/org/opencdmp/query/PlanReferenceQuery.java index cc6905390..0dbcd75bc 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpReferenceQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PlanReferenceQuery.java @@ -12,12 +12,12 @@ 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.PlanEntity; +import org.opencdmp.data.PlanReferenceEntity; import org.opencdmp.data.ReferenceEntity; import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.model.PublicDmpReference; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.model.PublicPlanReference; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -28,102 +28,102 @@ import java.util.*; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpReferenceQuery extends QueryBase { +public class PlanReferenceQuery extends QueryBase { private Collection ids; private Collection isActives; - private Collection dmpIds; + private Collection planIds; private Collection referenceIds; - private DmpQuery dmpQuery; + private PlanQuery planQuery; private ReferenceQuery referenceQuery; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - public DmpReferenceQuery ids(UUID value) { + public PlanReferenceQuery ids(UUID value) { this.ids = List.of(value); return this; } - public DmpReferenceQuery ids(UUID... value) { + public PlanReferenceQuery ids(UUID... value) { this.ids = Arrays.asList(value); return this; } - public DmpReferenceQuery ids(Collection values) { + public PlanReferenceQuery ids(Collection values) { this.ids = values; return this; } - public DmpReferenceQuery isActives(IsActive value) { + public PlanReferenceQuery isActives(IsActive value) { this.isActives = List.of(value); return this; } - public DmpReferenceQuery isActives(IsActive... value) { + public PlanReferenceQuery isActives(IsActive... value) { this.isActives = Arrays.asList(value); return this; } - public DmpReferenceQuery isActives(Collection values) { + public PlanReferenceQuery isActives(Collection values) { this.isActives = values; return this; } - public DmpReferenceQuery dmpIds(UUID value) { - this.dmpIds = List.of(value); + public PlanReferenceQuery planIds(UUID value) { + this.planIds = List.of(value); return this; } - public DmpReferenceQuery dmpIds(UUID... value) { - this.dmpIds = Arrays.asList(value); + public PlanReferenceQuery planIds(UUID... value) { + this.planIds = Arrays.asList(value); return this; } - public DmpReferenceQuery dmpIds(Collection values) { - this.dmpIds = values; + public PlanReferenceQuery planIds(Collection values) { + this.planIds = values; return this; } - public DmpReferenceQuery referenceIds(UUID value) { + public PlanReferenceQuery referenceIds(UUID value) { this.referenceIds = List.of(value); return this; } - public DmpReferenceQuery referenceIds(UUID... value) { + public PlanReferenceQuery referenceIds(UUID... value) { this.referenceIds = Arrays.asList(value); return this; } - public DmpReferenceQuery referenceIds(Collection values) { + public PlanReferenceQuery referenceIds(Collection values) { this.referenceIds = values; return this; } - public DmpReferenceQuery dmpSubQuery(DmpQuery value) { - this.dmpQuery = value; + public PlanReferenceQuery dmpSubQuery(PlanQuery value) { + this.planQuery = value; return this; } - public DmpReferenceQuery referenceSubQuery(ReferenceQuery value) { + public PlanReferenceQuery referenceSubQuery(ReferenceQuery value) { this.referenceQuery = value; return this; } - public DmpReferenceQuery authorize(EnumSet values) { + public PlanReferenceQuery authorize(EnumSet values) { this.authorize = values; return this; } - public DmpReferenceQuery enableTracking() { + public PlanReferenceQuery enableTracking() { this.noTracking = false; return this; } - public DmpReferenceQuery disableTracking() { + public PlanReferenceQuery disableTracking() { this.noTracking = true; return this; } @@ -134,7 +134,7 @@ public class DmpReferenceQuery extends QueryBase { private final QueryUtilsService queryUtilsService; private final TenantEntityManager tenantEntityManager; - public DmpReferenceQuery( + public PlanReferenceQuery( UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) { @@ -150,19 +150,19 @@ public class DmpReferenceQuery extends QueryBase { } @Override - protected Class entityClass() { - return DmpReferenceEntity.class; + protected Class entityClass() { + return PlanReferenceEntity.class; } @Override protected Boolean isFalseQuery() { - return this.isEmpty(this.ids) || this.isEmpty(this.dmpIds) || this.isEmpty(this.referenceIds) || this.isFalseQuery(this.dmpQuery) || this.isFalseQuery(this.referenceQuery); + return this.isEmpty(this.ids) || this.isEmpty(this.planIds) || this.isEmpty(this.referenceIds) || this.isFalseQuery(this.planQuery) || this.isFalseQuery(this.referenceQuery); } @Override protected Predicate applyAuthZ(QueryContext queryContext) { if (this.authorize.contains(AuthorizationFlags.None)) return null; - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDmpReference)) return null; + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowsePlanReference)) return null; UUID userId; boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe(); @@ -170,7 +170,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(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanReferenceEntity._planId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); @@ -184,36 +184,36 @@ public class DmpReferenceQuery extends QueryBase { protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.ids != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._id)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanReferenceEntity._id)); for (UUID item : this.ids) inClause.value(item); predicates.add(inClause); } if (this.isActives != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._isActive)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanReferenceEntity._isActive)); for (IsActive item : this.isActives) inClause.value(item); predicates.add(inClause); } - if (this.dmpIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._dmpId)); - for (UUID item : this.dmpIds) + if (this.planIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanReferenceEntity._planId)); + for (UUID item : this.planIds) inClause.value(item); predicates.add(inClause); } if (this.referenceIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._referenceId)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanReferenceEntity._referenceId)); for (UUID item : this.referenceIds) inClause.value(item); predicates.add(inClause); } - if (this.dmpQuery != null) { - QueryContext subQuery = this.applySubQuery(this.dmpQuery, queryContext, UUID.class, dmpEntityRoot -> dmpEntityRoot.get(DmpEntity._id)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._dmpId)).value(subQuery.Query)); + if (this.planQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planQuery, queryContext, UUID.class, dmpEntityRoot -> dmpEntityRoot.get(PlanEntity._id)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanReferenceEntity._planId)).value(subQuery.Query)); } if (this.referenceQuery != null) { QueryContext subQuery = this.applySubQuery(this.referenceQuery, queryContext, UUID.class, root -> root.get(ReferenceEntity._id)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._referenceId)).value(subQuery.Query)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanReferenceEntity._referenceId)).value(subQuery.Query)); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); @@ -224,32 +224,32 @@ public class DmpReferenceQuery extends QueryBase { } @Override - protected DmpReferenceEntity convert(Tuple tuple, Set columns) { - DmpReferenceEntity item = new DmpReferenceEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._id, UUID.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._tenantId, UUID.class)); - item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._dmpId, UUID.class)); - item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._referenceId, UUID.class)); - item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._isActive, IsActive.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._createdAt, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._updatedAt, Instant.class)); + protected PlanReferenceEntity convert(Tuple tuple, Set columns) { + PlanReferenceEntity item = new PlanReferenceEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, PlanReferenceEntity._id, UUID.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, PlanReferenceEntity._tenantId, UUID.class)); + item.setPlanId(QueryBase.convertSafe(tuple, columns, PlanReferenceEntity._planId, UUID.class)); + item.setReferenceId(QueryBase.convertSafe(tuple, columns, PlanReferenceEntity._referenceId, UUID.class)); + item.setData(QueryBase.convertSafe(tuple, columns, PlanReferenceEntity._data, String.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, PlanReferenceEntity._isActive, IsActive.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, PlanReferenceEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, PlanReferenceEntity._updatedAt, Instant.class)); return item; } @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(DmpReference._id) || item.match(PublicDmpReference._id)) return DmpReferenceEntity._id; - else if (item.prefix(DmpReference._dmp) || item.prefix(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId; - else if (item.prefix(DmpReference._reference) || item.prefix(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId; - else if (item.match(DmpReference._dmp) || item.match(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId; - else if (item.match(DmpReference._reference) || item.match(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId; - else if (item.prefix(DmpReference._data)) return DmpReferenceEntity._data; - else if (item.match(DmpReference._isActive)) return DmpReferenceEntity._isActive; - else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt; - else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt; - else if (item.match(DmpReference._hash)) return DmpReferenceEntity._updatedAt; - else if (item.match(DmpReference._belongsToCurrentTenant)) return DmpReferenceEntity._tenantId; + if (item.match(PlanReference._id) || item.match(PublicPlanReference._id)) return PlanReferenceEntity._id; + else if (item.prefix(PlanReference._plan) || item.prefix(PublicPlanReference._plan)) return PlanReferenceEntity._planId; + else if (item.prefix(PlanReference._reference) || item.prefix(PublicPlanReference._reference)) return PlanReferenceEntity._referenceId; + else if (item.match(PlanReference._plan) || item.match(PublicPlanReference._plan)) return PlanReferenceEntity._planId; + else if (item.match(PlanReference._reference) || item.match(PublicPlanReference._reference)) return PlanReferenceEntity._referenceId; + else if (item.prefix(PlanReference._data)) return PlanReferenceEntity._data; + else if (item.match(PlanReference._isActive)) return PlanReferenceEntity._isActive; + else if (item.match(PlanReference._createdAt)) return PlanReferenceEntity._createdAt; + else if (item.match(PlanReference._updatedAt)) return PlanReferenceEntity._updatedAt; + else if (item.match(PlanReference._hash)) return PlanReferenceEntity._updatedAt; + else if (item.match(PlanReference._belongsToCurrentTenant)) return PlanReferenceEntity._tenantId; else return null; } diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpUserQuery.java b/backend/core/src/main/java/org/opencdmp/query/PlanUserQuery.java similarity index 58% rename from backend/core/src/main/java/org/opencdmp/query/DmpUserQuery.java rename to backend/core/src/main/java/org/opencdmp/query/PlanUserQuery.java index c23b3ef19..13776eff4 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpUserQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PlanUserQuery.java @@ -11,14 +11,14 @@ 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.PlanUserRole; 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.data.PlanUserEntity; import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.model.DmpUser; -import org.opencdmp.model.PublicDmpUser; +import org.opencdmp.model.PlanUser; +import org.opencdmp.model.PublicPlanUser; import org.opencdmp.query.utils.BuildSubQueryInput; import org.opencdmp.query.utils.QueryUtilsService; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -30,146 +30,146 @@ import java.util.*; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DmpUserQuery extends QueryBase { +public class PlanUserQuery extends QueryBase { private Collection ids; private Collection isActives; - private Collection dmpIds; + private Collection planIds; private Collection descriptionIds; private Collection userIds; - private Collection userRoles; + private Collection userRoles; private Collection sectionIds; private Boolean sectionIsEmpty; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - public DmpUserQuery ids(UUID value) { + public PlanUserQuery ids(UUID value) { this.ids = List.of(value); return this; } - public DmpUserQuery ids(UUID... value) { + public PlanUserQuery ids(UUID... value) { this.ids = Arrays.asList(value); return this; } - public DmpUserQuery ids(Collection values) { + public PlanUserQuery ids(Collection values) { this.ids = values; return this; } - public DmpUserQuery isActives(IsActive value) { + public PlanUserQuery isActives(IsActive value) { this.isActives = List.of(value); return this; } - public DmpUserQuery isActives(IsActive... value) { + public PlanUserQuery isActives(IsActive... value) { this.isActives = Arrays.asList(value); return this; } - public DmpUserQuery isActives(Collection values) { + public PlanUserQuery isActives(Collection values) { this.isActives = values; return this; } - public DmpUserQuery dmpIds(UUID value) { - this.dmpIds = List.of(value); + public PlanUserQuery planIds(UUID value) { + this.planIds = List.of(value); return this; } - public DmpUserQuery dmpIds(UUID... value) { - this.dmpIds = Arrays.asList(value); + public PlanUserQuery planIds(UUID... value) { + this.planIds = Arrays.asList(value); return this; } - public DmpUserQuery dmpIds(Collection values) { - this.dmpIds = values; + public PlanUserQuery planIds(Collection values) { + this.planIds = values; return this; } - public DmpUserQuery descriptionIds(UUID value) { + public PlanUserQuery descriptionIds(UUID value) { this.descriptionIds = List.of(value); return this; } - public DmpUserQuery descriptionIds(UUID... value) { + public PlanUserQuery descriptionIds(UUID... value) { this.descriptionIds = Arrays.asList(value); return this; } - public DmpUserQuery descriptionIds(Collection values) { + public PlanUserQuery descriptionIds(Collection values) { this.descriptionIds = values; return this; } - public DmpUserQuery userRoles(DmpUserRole value) { + public PlanUserQuery userRoles(PlanUserRole value) { this.userRoles = List.of(value); return this; } - public DmpUserQuery userRoles(DmpUserRole... value) { + public PlanUserQuery userRoles(PlanUserRole... value) { this.userRoles = Arrays.asList(value); return this; } - public DmpUserQuery userRoles(Collection values) { + public PlanUserQuery userRoles(Collection values) { this.userRoles = values; return this; } - public DmpUserQuery userIds(UUID value) { + public PlanUserQuery userIds(UUID value) { this.userIds = List.of(value); return this; } - public DmpUserQuery userIds(UUID... value) { + public PlanUserQuery userIds(UUID... value) { this.userIds = Arrays.asList(value); return this; } - public DmpUserQuery userIds(Collection values) { + public PlanUserQuery userIds(Collection values) { this.userIds = values; return this; } - public DmpUserQuery sectionIds(UUID value) { + public PlanUserQuery sectionIds(UUID value) { this.sectionIds = List.of(value); return this; } - public DmpUserQuery sectionIds(UUID... value) { + public PlanUserQuery sectionIds(UUID... value) { this.sectionIds = Arrays.asList(value); return this; } - public DmpUserQuery sectionIds(Collection values) { + public PlanUserQuery sectionIds(Collection values) { this.sectionIds = values; return this; } - public DmpUserQuery sectionIsEmpty(Boolean sectionIsEmpty) { + public PlanUserQuery sectionIsEmpty(Boolean sectionIsEmpty) { this.sectionIsEmpty = sectionIsEmpty; return this; } - public DmpUserQuery authorize(EnumSet values) { + public PlanUserQuery authorize(EnumSet values) { this.authorize = values; return this; } - public DmpUserQuery enableTracking() { + public PlanUserQuery enableTracking() { this.noTracking = false; return this; } - public DmpUserQuery disableTracking() { + public PlanUserQuery disableTracking() { this.noTracking = true; return this; } @@ -181,7 +181,7 @@ public class DmpUserQuery extends QueryBase { private final QueryUtilsService queryUtilsService; private final TenantEntityManager tenantEntityManager; - public DmpUserQuery( + public PlanUserQuery( UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) { @@ -197,19 +197,19 @@ public class DmpUserQuery extends QueryBase { } @Override - protected Class entityClass() { - return DmpUserEntity.class; + protected Class entityClass() { + return PlanUserEntity.class; } @Override protected Boolean isFalseQuery() { - return this.isEmpty(this.ids) || this.isEmpty(this.dmpIds) || this.isEmpty(this.descriptionIds) || this.isEmpty(this.userIds); + return this.isEmpty(this.ids) || this.isEmpty(this.planIds) || this.isEmpty(this.descriptionIds) || this.isEmpty(this.userIds); } @Override protected Predicate applyAuthZ(QueryContext queryContext) { if (this.authorize.contains(AuthorizationFlags.None)) return null; - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDmp)) return null; + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowsePlan)) return null; UUID userId = null; boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe(); @@ -217,8 +217,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(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 + usePublic ? queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._planId)).value(this.queryUtilsService.buildPublicDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, usePublic)) : queryContext.CriteriaBuilder.or(), //Creates a false query + userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._planId)).value(this.queryUtilsService.buildDmpUserAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId)) : queryContext.CriteriaBuilder.or() //Creates a false query )); } if (!predicates.isEmpty()) { @@ -233,55 +233,55 @@ public class DmpUserQuery extends QueryBase { protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.ids != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._id)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._id)); for (UUID item : this.ids) inClause.value(item); predicates.add(inClause); } if (this.isActives != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._isActive)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._isActive)); for (IsActive item : this.isActives) inClause.value(item); predicates.add(inClause); } - if (this.dmpIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)); - for (UUID item : this.dmpIds) + if (this.planIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._planId)); + for (UUID item : this.planIds) inClause.value(item); predicates.add(inClause); } if (this.sectionIsEmpty != null){ - if(this.sectionIsEmpty) predicates.add(queryContext.CriteriaBuilder.isNull(queryContext.Root.get(DmpUserEntity._sectionId))); - else predicates.add(queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(DmpUserEntity._sectionId))); + if(this.sectionIsEmpty) predicates.add(queryContext.CriteriaBuilder.isNull(queryContext.Root.get(PlanUserEntity._sectionId))); + else predicates.add(queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(PlanUserEntity._sectionId))); } if (this.descriptionIds != null) { Subquery descriptionSubquery = this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( new BuildSubQueryInput.Builder<>(DescriptionEntity.class, UUID.class, queryContext) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DescriptionEntity._dmpId)) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DescriptionEntity._planId)) .filterFunc((subQueryRoot, cb) -> { - CriteriaBuilder.In inClause = cb.in(subQueryRoot.get(DmpUserEntity._id)); + CriteriaBuilder.In inClause = cb.in(subQueryRoot.get(PlanUserEntity._id)); for (UUID item : this.descriptionIds) inClause.value(item); return inClause; }) )); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(descriptionSubquery)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._planId)).value(descriptionSubquery)); } if (this.userIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._userId)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._userId)); for (UUID item : this.userIds) inClause.value(item); predicates.add(inClause); } if (this.sectionIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._sectionId)); + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._sectionId)); for (UUID item : this.sectionIds) inClause.value(item); predicates.add(inClause); } if (this.userRoles != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._role)); - for (DmpUserRole item : this.userRoles) + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanUserEntity._role)); + for (PlanUserRole item : this.userRoles) inClause.value(item); predicates.add(inClause); } @@ -294,34 +294,34 @@ public class DmpUserQuery extends QueryBase { } @Override - protected DmpUserEntity convert(Tuple tuple, Set columns) { - DmpUserEntity item = new DmpUserEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._id, UUID.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._tenantId, UUID.class)); - item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._dmpId, UUID.class)); - item.setUserId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._userId, UUID.class)); - item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._sectionId, UUID.class)); - item.setRole(QueryBase.convertSafe(tuple, columns, DmpUserEntity._role, DmpUserRole.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpUserEntity._createdAt, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpUserEntity._updatedAt, Instant.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpUserEntity._isActive, IsActive.class)); + protected PlanUserEntity convert(Tuple tuple, Set columns) { + PlanUserEntity item = new PlanUserEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, PlanUserEntity._id, UUID.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, PlanUserEntity._tenantId, UUID.class)); + item.setPlanId(QueryBase.convertSafe(tuple, columns, PlanUserEntity._planId, UUID.class)); + item.setUserId(QueryBase.convertSafe(tuple, columns, PlanUserEntity._userId, UUID.class)); + item.setSectionId(QueryBase.convertSafe(tuple, columns, PlanUserEntity._sectionId, UUID.class)); + item.setRole(QueryBase.convertSafe(tuple, columns, PlanUserEntity._role, PlanUserRole.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, PlanUserEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, PlanUserEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, PlanUserEntity._isActive, IsActive.class)); return item; } @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(DmpUser._id) || item.match(PublicDmpUser._id)) return DmpUserEntity._id; - else if (item.prefix(DmpUser._dmp) || item.prefix(PublicDmpUser._dmp)) return DmpUserEntity._dmpId; - else if (item.prefix(DmpUser._user) || item.prefix(PublicDmpUser._user)) return DmpUserEntity._userId; - else if (item.match(DmpUser._role) || item.match(PublicDmpUser._role)) return DmpUserEntity._role; - else if (item.match(DmpUser._sectionId)) return DmpUserEntity._sectionId; - else if (item.match(DmpUser._createdAt)) return DmpUserEntity._createdAt; - else if (item.match(DmpUser._updatedAt)) return DmpUserEntity._updatedAt; - else if (item.match(DmpUser._isActive)) return DmpUserEntity._isActive; - else if (item.match(DmpUser._hash)) return DmpUserEntity._updatedAt; - else if (item.match(DmpUser._dmp)) return DmpUserEntity._dmpId; - else if (item.match(DmpUser._user)) return DmpUserEntity._userId; - else if (item.match(DmpUser._belongsToCurrentTenant)) return DmpUserEntity._tenantId; + if (item.match(PlanUser._id) || item.match(PublicPlanUser._id)) return PlanUserEntity._id; + else if (item.prefix(PlanUser._plan) || item.prefix(PublicPlanUser._plan)) return PlanUserEntity._planId; + else if (item.prefix(PlanUser._user) || item.prefix(PublicPlanUser._user)) return PlanUserEntity._userId; + else if (item.match(PlanUser._role) || item.match(PublicPlanUser._role)) return PlanUserEntity._role; + else if (item.match(PlanUser._sectionId)) return PlanUserEntity._sectionId; + else if (item.match(PlanUser._createdAt)) return PlanUserEntity._createdAt; + else if (item.match(PlanUser._updatedAt)) return PlanUserEntity._updatedAt; + else if (item.match(PlanUser._isActive)) return PlanUserEntity._isActive; + else if (item.match(PlanUser._hash)) return PlanUserEntity._updatedAt; + else if (item.match(PlanUser._plan)) return PlanUserEntity._planId; + else if (item.match(PlanUser._user)) return PlanUserEntity._userId; + else if (item.match(PlanUser._belongsToCurrentTenant)) return PlanUserEntity._tenantId; else return null; } 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 6589e6ca9..7888e0e98 100644 --- a/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java @@ -47,7 +47,7 @@ public class ReferenceQuery extends QueryBase { private Instant after; - private DmpReferenceQuery dmpReferenceQuery; + private PlanReferenceQuery planReferenceQuery; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -166,8 +166,8 @@ public class ReferenceQuery extends QueryBase { return this; } - public ReferenceQuery dmpReferenceSubQuery(DmpReferenceQuery value) { - this.dmpReferenceQuery = value; + public ReferenceQuery dmpReferenceSubQuery(PlanReferenceQuery value) { + this.planReferenceQuery = value; return this; } @@ -213,7 +213,7 @@ public class ReferenceQuery extends QueryBase { @Override protected Boolean isFalseQuery() { - return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.sources) || this.isEmpty(this.excludedIds) || this.isEmpty(this.typeIds) || this.isEmpty(this.referenceSourceTypes) || this.isFalseQuery(this.dmpReferenceQuery); + return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.sources) || this.isEmpty(this.excludedIds) || this.isEmpty(this.typeIds) || this.isEmpty(this.referenceSourceTypes) || this.isFalseQuery(this.planReferenceQuery); } @Override @@ -234,12 +234,12 @@ public class ReferenceQuery extends QueryBase { predicates.add(queryContext.CriteriaBuilder.or( this.authService.authorize(Permission.BrowseExternalReference) ? queryContext.CriteriaBuilder.equal(queryContext.Root.get(ReferenceEntity._sourceType), ReferenceSourceType.External) : queryContext.CriteriaBuilder.or(), userId != null ? queryContext.CriteriaBuilder.equal(queryContext.Root.get(ReferenceEntity._createdById), userId) : queryContext.CriteriaBuilder.or(), //Creates a false query - queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DmpReferenceEntity.class, UUID.class) + queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(PlanReferenceEntity.class, UUID.class) .query(queryContext.Query) .criteriaBuilder(queryContext.CriteriaBuilder) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpReferenceEntity._referenceId)) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(PlanReferenceEntity._referenceId)) .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DmpReferenceEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) + cb.in(subQueryRoot.get(PlanReferenceEntity._planId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) ) ))), queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DescriptionReferenceEntity.class, UUID.class) @@ -312,13 +312,13 @@ public class ReferenceQuery extends QueryBase { predicates.add(notInClause.not()); } if (this.after != null) { - Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(DmpEntity._createdAt), this.after); + Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(PlanEntity._createdAt), this.after); predicates.add(afterClause); } - if (this.dmpReferenceQuery != null) { - QueryContext subQuery = this.applySubQuery(this.dmpReferenceQuery, queryContext, UUID.class, root -> root.get(DmpReferenceEntity._referenceId)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._id)).value(subQuery.Query)); + if (this.planReferenceQuery != null) { + QueryContext subQuery = this.applySubQuery(this.planReferenceQuery, queryContext, UUID.class, root -> root.get(PlanReferenceEntity._referenceId)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanReferenceEntity._id)).value(subQuery.Query)); } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); 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 f40423fd6..3ee6c1dd4 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserContactInfoQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserContactInfoQuery.java @@ -12,7 +12,7 @@ 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.DmpUserEntity; +import org.opencdmp.data.PlanUserEntity; import org.opencdmp.data.TenantEntityManager; import org.opencdmp.data.UserContactInfoEntity; import org.opencdmp.model.UserContactInfo; @@ -183,12 +183,12 @@ public class UserContactInfoQuery extends QueryBase { if (userId != null) { predicates.add(queryContext.CriteriaBuilder.or( queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(userId), //Creates a false query - queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DmpUserEntity.class, UUID.class) + queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(PlanUserEntity.class, UUID.class) .query(queryContext.Query) .criteriaBuilder(queryContext.CriteriaBuilder) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpUserEntity._userId)) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(PlanUserEntity._userId)) .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DmpUserEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, false)) + cb.in(subQueryRoot.get(PlanUserEntity._planId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, false)) ) ))) )); 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 d02b2fc4c..06c6cb0dc 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserQuery.java @@ -30,7 +30,7 @@ import java.util.*; @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserQuery extends QueryBase { private String like; - private Boolean dmpAssociated; + private Boolean planAssociated; private Collection ids; private Collection emails; private Collection excludedIds; @@ -126,8 +126,8 @@ public class UserQuery extends QueryBase { return this; } - public UserQuery dmpAssociated(Boolean dmpAssociated) { - this.dmpAssociated = dmpAssociated; + public UserQuery planAssociated(Boolean planAssociated) { + this.planAssociated = planAssociated; return this; } @@ -183,12 +183,12 @@ public class UserQuery extends QueryBase { UUID finalUserId = userId; predicates.add(queryContext.CriteriaBuilder.or( userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(userId) : queryContext.CriteriaBuilder.or(), //Creates a false query - queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DmpUserEntity.class, UUID.class) + queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(PlanUserEntity.class, UUID.class) .query(queryContext.Query) .criteriaBuilder(queryContext.CriteriaBuilder) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpUserEntity._userId)) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(PlanUserEntity._userId)) .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DmpUserEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, finalUserId, usePublic)) + cb.in(subQueryRoot.get(PlanUserEntity._planId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, finalUserId, usePublic)) ) ))), queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(UserDescriptionTemplateEntity.class, UUID.class) @@ -255,17 +255,17 @@ public class UserQuery extends QueryBase { QueryContext subQuery = this.applySubQuery(this.tenantUserQuery, queryContext, UUID.class, tenantUserEntityRoot -> tenantUserEntityRoot.get(TenantUserEntity._userId)); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(subQuery.Query)); } - if (this.dmpAssociated != null){ + if (this.planAssociated != null){ UUID userId; if (this.userScope.isSet()) userId = this.userScope.getUserIdSafe(); else throw new MyNotFoundException("Only user scoped allowed"); Subquery dmpUserUserQuery = this.queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( - new BuildSubQueryInput.Builder<>(DmpUserEntity.class, UUID.class, queryContext) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpUserEntity._userId)) + new BuildSubQueryInput.Builder<>(PlanUserEntity.class, UUID.class, queryContext) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(PlanUserEntity._userId)) .filterFunc((subQueryRoot, cb) -> cb.and( - cb.in(subQueryRoot.get(DmpUserEntity._dmpId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, false)) , - cb.equal(subQueryRoot.get(DmpUserEntity._isActive), IsActive.Active) + cb.in(subQueryRoot.get(PlanUserEntity._planId)).value(this.queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, false)) , + cb.equal(subQueryRoot.get(PlanUserEntity._isActive), IsActive.Active) )) )); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(dmpUserUserQuery)); diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java index 59867f460..f79f9d5f2 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java @@ -24,7 +24,7 @@ public class DescriptionLookup extends Lookup { private Instant finalizedAfter; private Instant finalizedBefore; - private DmpLookup dmpSubQuery; + private PlanLookup planSubQuery; private DescriptionTemplateLookup descriptionTemplateSubQuery; private DescriptionReferenceLookup descriptionReferenceSubQuery; private DescriptionTagLookup descriptionTagSubQuery; @@ -73,11 +73,11 @@ public class DescriptionLookup extends Lookup { this.statuses = statuses; } - public DmpLookup getDmpSubQuery() { - return this.dmpSubQuery; + public PlanLookup getPlanSubQuery() { + return this.planSubQuery; } - public void setDmpSubQuery(DmpLookup dmpSubQuery) { this.dmpSubQuery = dmpSubQuery; } + public void setPlanSubQuery(PlanLookup planSubQuery) { this.planSubQuery = planSubQuery; } public DescriptionTemplateLookup getDescriptionTemplateSubQuery() { return this.descriptionTemplateSubQuery; } @@ -128,7 +128,7 @@ public class DescriptionLookup extends Lookup { if (this.like != null) query.like(this.like); if (this.ids != null) query.ids(this.ids); if (this.excludedIds != null) query.excludedIds(this.excludedIds); - if (this.dmpSubQuery != null) query.dmpSubQuery(this.dmpSubQuery.enrich(queryFactory)); + if (this.planSubQuery != null) query.dmpSubQuery(this.planSubQuery.enrich(queryFactory)); if (this.descriptionTemplateSubQuery != null) query.descriptionTemplateSubQuery(this.descriptionTemplateSubQuery.enrich(queryFactory)); if (this.descriptionReferenceSubQuery != null) query.descriptionReferenceSubQuery(this.descriptionReferenceSubQuery.enrich(queryFactory)); if (this.descriptionTagSubQuery != null) query.descriptionTagSubQuery(this.descriptionTagSubQuery.enrich(queryFactory)); @@ -154,7 +154,7 @@ public class DescriptionLookup extends Lookup { if (this.createdBefore != null) query.createdBefore(this.createdBefore); if (this.finalizedAfter != null) query.finalizedAfter(this.finalizedAfter); if (this.finalizedBefore != null) query.finalizedBefore(this.finalizedBefore); - if (this.dmpSubQuery != null) query.dmpSubQuery(this.dmpSubQuery.enrichElasticInner(queryFactory)); + if (this.planSubQuery != null) query.planSubQuery(this.planSubQuery.enrichElasticInner(queryFactory)); // TODO: add reference ? this.enrichCommon(query); diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpBlueprintLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanBlueprintLookup.java similarity index 72% rename from backend/core/src/main/java/org/opencdmp/query/lookup/DmpBlueprintLookup.java rename to backend/core/src/main/java/org/opencdmp/query/lookup/PlanBlueprintLookup.java index 414472427..4a614cb29 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpBlueprintLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanBlueprintLookup.java @@ -1,22 +1,22 @@ package org.opencdmp.query.lookup; -import org.opencdmp.commons.enums.DmpBlueprintStatus; -import org.opencdmp.commons.enums.DmpBlueprintVersionStatus; +import org.opencdmp.commons.enums.PlanBlueprintStatus; +import org.opencdmp.commons.enums.PlanBlueprintVersionStatus; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.query.DmpBlueprintQuery; +import org.opencdmp.query.PlanBlueprintQuery; import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.QueryFactory; import java.util.List; import java.util.UUID; -public class DmpBlueprintLookup extends Lookup { +public class PlanBlueprintLookup extends Lookup { private String like; private List isActive; - private List statuses; + private List statuses; private List ids; @@ -24,7 +24,7 @@ public class DmpBlueprintLookup extends Lookup { private List groupIds; - private List versionStatuses; + private List versionStatuses; public String getLike() { return like; @@ -42,11 +42,11 @@ public class DmpBlueprintLookup extends Lookup { this.isActive = isActive; } - public List getStatuses() { + public List getStatuses() { return statuses; } - public void setStatuses(List statuses) { + public void setStatuses(List statuses) { this.statuses = statuses; } @@ -66,11 +66,11 @@ public class DmpBlueprintLookup extends Lookup { this.excludedIds = excludedIds; } - public List getVersionStatuses() { + public List getVersionStatuses() { return versionStatuses; } - public void setVersionStatuses(List versionStatuses) { + public void setVersionStatuses(List versionStatuses) { this.versionStatuses = versionStatuses; } @@ -82,8 +82,8 @@ public class DmpBlueprintLookup extends Lookup { this.groupIds = groupIds; } - public DmpBlueprintQuery enrich(QueryFactory queryFactory) { - DmpBlueprintQuery query = queryFactory.query(DmpBlueprintQuery.class); + public PlanBlueprintQuery enrich(QueryFactory queryFactory) { + PlanBlueprintQuery query = queryFactory.query(PlanBlueprintQuery.class); if (this.like != null) query.like(this.like); if (this.isActive != null) diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpDescriptionTemplateLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanDescriptionTemplateLookup.java similarity index 71% rename from backend/core/src/main/java/org/opencdmp/query/lookup/DmpDescriptionTemplateLookup.java rename to backend/core/src/main/java/org/opencdmp/query/lookup/PlanDescriptionTemplateLookup.java index bac88a1eb..2d456cc6b 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpDescriptionTemplateLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanDescriptionTemplateLookup.java @@ -3,16 +3,16 @@ package org.opencdmp.query.lookup; import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.QueryFactory; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.elastic.query.NestedDmpDescriptionTemplateElasticQuery; -import org.opencdmp.query.DmpDescriptionTemplateQuery; +import org.opencdmp.elastic.query.NestedPlanDescriptionTemplateElasticQuery; +import org.opencdmp.query.PlanDescriptionTemplateQuery; import java.util.List; import java.util.UUID; -public class DmpDescriptionTemplateLookup extends Lookup { +public class PlanDescriptionTemplateLookup extends Lookup { private List ids; - private List dmpIds; + private List planIds; private List descriptionTemplateGroupIds; private List sectionIds; @@ -44,12 +44,12 @@ public class DmpDescriptionTemplateLookup extends Lookup { this.isActive = isActive; } - public List getDmpIds() { - return this.dmpIds; + public List getPlanIds() { + return this.planIds; } - public void setDmpIds(List dmpIds) { - this.dmpIds = dmpIds; + public void setPlanIds(List planIds) { + this.planIds = planIds; } public List getDescriptionTemplateGroupIds() { @@ -68,10 +68,10 @@ public class DmpDescriptionTemplateLookup extends Lookup { this.descriptionTemplateGroupIds = descriptionTemplateGroupIds; } - public DmpDescriptionTemplateQuery enrich(QueryFactory queryFactory) { - DmpDescriptionTemplateQuery query = queryFactory.query(DmpDescriptionTemplateQuery.class); + public PlanDescriptionTemplateQuery enrich(QueryFactory queryFactory) { + PlanDescriptionTemplateQuery query = queryFactory.query(PlanDescriptionTemplateQuery.class); if (this.ids != null) query.ids(this.ids); - if (this.dmpIds != null) query.ids(this.dmpIds); + if (this.planIds != null) query.planIds(this.planIds); if (this.descriptionTemplateGroupIds != null) query.descriptionTemplateGroupIds(this.descriptionTemplateGroupIds); if (this.sectionIds != null) query.sectionIds(this.sectionIds); if (this.excludedIds != null) query.excludedIds(this.excludedIds); @@ -82,10 +82,10 @@ public class DmpDescriptionTemplateLookup extends Lookup { return query; } - public NestedDmpDescriptionTemplateElasticQuery enrichElasticInner(QueryFactory queryFactory) { - NestedDmpDescriptionTemplateElasticQuery query = queryFactory.query(NestedDmpDescriptionTemplateElasticQuery.class); + public NestedPlanDescriptionTemplateElasticQuery enrichElasticInner(QueryFactory queryFactory) { + NestedPlanDescriptionTemplateElasticQuery query = queryFactory.query(NestedPlanDescriptionTemplateElasticQuery.class); if (this.ids != null) query.ids(this.ids); - if (this.dmpIds != null) query.dmpIds(this.dmpIds); + if (this.planIds != null) query.planIds(this.planIds); if (this.descriptionTemplateGroupIds != null) query.descriptionTemplateGroupIds(this.descriptionTemplateGroupIds); if (this.sectionIds != null) query.sectionIds(this.sectionIds); if (this.excludedIds != null) query.descriptionTemplateGroupIds(this.excludedIds); diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanLookup.java similarity index 54% rename from backend/core/src/main/java/org/opencdmp/query/lookup/DmpLookup.java rename to backend/core/src/main/java/org/opencdmp/query/lookup/PlanLookup.java index 8a61e38eb..5417e4d14 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanLookup.java @@ -3,18 +3,18 @@ package org.opencdmp.query.lookup; import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.QueryFactory; import org.apache.commons.lang3.StringUtils; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; -import org.opencdmp.commons.enums.DmpVersionStatus; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; +import org.opencdmp.commons.enums.PlanVersionStatus; import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.elastic.query.DmpElasticQuery; +import org.opencdmp.elastic.query.PlanElasticQuery; import org.opencdmp.elastic.query.InnerObjectDmpElasticQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import java.util.List; import java.util.UUID; -public class DmpLookup extends Lookup { +public class PlanLookup extends Lookup { private String like; @@ -24,17 +24,17 @@ public class DmpLookup extends Lookup { private List groupIds; private List isActive; - private List versionStatuses; + private List versionStatuses; - private List statuses; - private List accessTypes; + private List statuses; + private List accessTypes; private List versions; - private DmpDescriptionTemplateLookup dmpDescriptionTemplateSubQuery; - private DmpUserLookup dmpUserSubQuery; - private DmpBlueprintLookup dmpBlueprintSubQuery; - private DmpReferenceLookup dmpReferenceSubQuery; + private PlanDescriptionTemplateLookup planDescriptionTemplateSubQuery; + private PlanUserLookup planUserSubQuery; + private PlanBlueprintLookup planBlueprintSubQuery; + private PlanReferenceLookup planReferenceSubQuery; public String getLike() { return this.like; @@ -68,11 +68,11 @@ public class DmpLookup extends Lookup { this.isActive = isActive; } - public List getStatuses() { + public List getStatuses() { return this.statuses; } - public void setStatuses(List statuses) { + public void setStatuses(List statuses) { this.statuses = statuses; } @@ -84,28 +84,28 @@ public class DmpLookup extends Lookup { this.versions = versions; } - public List getAccessTypes() { + public List getAccessTypes() { return this.accessTypes; } - public void setAccessTypes(List accessTypes) { + public void setAccessTypes(List accessTypes) { this.accessTypes = accessTypes; } - public List getVersionStatuses() { + public List getVersionStatuses() { return this.versionStatuses; } - public void setVersionStatuses(List versionStatuses) { + public void setVersionStatuses(List versionStatuses) { this.versionStatuses = versionStatuses; } - public DmpDescriptionTemplateLookup getDmpDescriptionTemplateSubQuery() { - return this.dmpDescriptionTemplateSubQuery; + public PlanDescriptionTemplateLookup getPlanDescriptionTemplateSubQuery() { + return this.planDescriptionTemplateSubQuery; } - public void setDmpDescriptionTemplateSubQuery(DmpDescriptionTemplateLookup dmpDescriptionTemplateSubQuery) { - this.dmpDescriptionTemplateSubQuery = dmpDescriptionTemplateSubQuery; + public void setPlanDescriptionTemplateSubQuery(PlanDescriptionTemplateLookup planDescriptionTemplateSubQuery) { + this.planDescriptionTemplateSubQuery = planDescriptionTemplateSubQuery; } public List getGroupIds() { @@ -116,25 +116,25 @@ public class DmpLookup extends Lookup { this.groupIds = groupIds; } - public DmpUserLookup getDmpUserSubQuery() { - return this.dmpUserSubQuery; + public PlanUserLookup getPlanUserSubQuery() { + return this.planUserSubQuery; } - public void setDmpUserSubQuery(DmpUserLookup dmpUserSubQuery) { - this.dmpUserSubQuery = dmpUserSubQuery; + public void setPlanUserSubQuery(PlanUserLookup planUserSubQuery) { + this.planUserSubQuery = planUserSubQuery; } - public DmpBlueprintLookup getDmpBlueprintSubQuery() { return this.dmpBlueprintSubQuery; } + public PlanBlueprintLookup getPlanBlueprintSubQuery() { return this.planBlueprintSubQuery; } - public void setDmpBlueprintLookup(DmpBlueprintLookup dmpBlueprintSubQuery) { this.dmpBlueprintSubQuery = dmpBlueprintSubQuery; } + public void setPlanBlueprintLookup(PlanBlueprintLookup dmpBlueprintSubQuery) { this.planBlueprintSubQuery = dmpBlueprintSubQuery; } - public DmpReferenceLookup getDmpReferenceSubQuery() { return this.dmpReferenceSubQuery; } + public PlanReferenceLookup getPlanReferenceSubQuery() { return this.planReferenceSubQuery; } - public void setDmpReferenceLookup(DmpReferenceLookup dmpReferenceSubQuery) { this.dmpReferenceSubQuery = dmpReferenceSubQuery; } + public void setPlanReferenceLookup(PlanReferenceLookup dmpReferenceSubQuery) { this.planReferenceSubQuery = dmpReferenceSubQuery; } - public DmpQuery enrich(QueryFactory queryFactory) { - DmpQuery query = queryFactory.query(DmpQuery.class); + public PlanQuery enrich(QueryFactory queryFactory) { + PlanQuery query = queryFactory.query(PlanQuery.class); if (this.like != null) query.like(this.like); if (this.ids != null) query.ids(this.ids); if (this.groupIds != null) query.groupIds(this.groupIds); @@ -144,18 +144,18 @@ public class DmpLookup extends Lookup { if (this.statuses != null) query.statuses(this.statuses); if (this.versions != null) query.versions(this.versions); if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses); - if (this.dmpDescriptionTemplateSubQuery != null) query.dmpDescriptionTemplateSubQuery(this.dmpDescriptionTemplateSubQuery.enrich(queryFactory)); - if (this.dmpUserSubQuery != null) query.dmpUserSubQuery(this.dmpUserSubQuery.enrich(queryFactory)); - if (this.dmpBlueprintSubQuery != null) query.dmpBlueprintSubQuery(this.dmpBlueprintSubQuery.enrich(queryFactory)); - if (this.dmpReferenceSubQuery != null) query.dmpReferenceSubQuery(this.dmpReferenceSubQuery.enrich(queryFactory)); + if (this.planDescriptionTemplateSubQuery != null) query.planDescriptionTemplateSubQuery(this.planDescriptionTemplateSubQuery.enrich(queryFactory)); + if (this.planUserSubQuery != null) query.planUserSubQuery(this.planUserSubQuery.enrich(queryFactory)); + if (this.planBlueprintSubQuery != null) query.planBlueprintSubQuery(this.planBlueprintSubQuery.enrich(queryFactory)); + if (this.planReferenceSubQuery != null) query.planReferenceSubQuery(this.planReferenceSubQuery.enrich(queryFactory)); this.enrichCommon(query); return query; } - public DmpElasticQuery enrichElastic(QueryFactory queryFactory) { - DmpElasticQuery query = queryFactory.query(DmpElasticQuery.class); + public PlanElasticQuery enrichElastic(QueryFactory queryFactory) { + PlanElasticQuery query = queryFactory.query(PlanElasticQuery.class); if (this.like != null) query.like(StringUtils.strip(this.like, "%")); if (this.ids != null) query.ids(this.ids); if (this.groupIds != null) query.groupIds(this.groupIds); @@ -164,8 +164,8 @@ public class DmpLookup extends Lookup { if (this.statuses != null) query.statuses(this.statuses); if (this.versions != null) query.versions(this.versions); if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses); - if (this.dmpDescriptionTemplateSubQuery != null) query.dmpDescriptionTemplateSubQuery(this.dmpDescriptionTemplateSubQuery.enrichElasticInner(queryFactory)); - if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory)); + if (this.planDescriptionTemplateSubQuery != null) query.planDescriptionTemplateSubQuery(this.planDescriptionTemplateSubQuery.enrichElasticInner(queryFactory)); + if (this.planUserSubQuery != null) query.planSubQuery(this.planUserSubQuery.enrichElasticInner(queryFactory)); // TODO ?? this.enrichCommon(query); @@ -182,8 +182,8 @@ public class DmpLookup extends Lookup { if (this.statuses != null) query.statuses(this.statuses); if (this.versions != null) query.versions(this.versions); if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses); - if (this.dmpDescriptionTemplateSubQuery != null) throw new UnsupportedOperationException(""); - if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory)); + if (this.planDescriptionTemplateSubQuery != null) throw new UnsupportedOperationException(""); + if (this.planUserSubQuery != null) query.dmpSubQuery(this.planUserSubQuery.enrichElasticInner(queryFactory)); // TODO ?? return query; } diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpReferenceLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanReferenceLookup.java similarity index 60% rename from backend/core/src/main/java/org/opencdmp/query/lookup/DmpReferenceLookup.java rename to backend/core/src/main/java/org/opencdmp/query/lookup/PlanReferenceLookup.java index 3822d378f..60de6bf35 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpReferenceLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanReferenceLookup.java @@ -1,18 +1,17 @@ package org.opencdmp.query.lookup; -import org.opencdmp.query.DmpReferenceQuery; +import org.opencdmp.query.PlanReferenceQuery; import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.QueryFactory; -import java.util.Collection; import java.util.List; import java.util.UUID; -public class DmpReferenceLookup extends Lookup { +public class PlanReferenceLookup extends Lookup { private List ids; - private List dmpIds; + private List planIds; private List referenceIds; @@ -24,12 +23,12 @@ public class DmpReferenceLookup extends Lookup { this.ids = ids; } - public List getDmpIds() { - return dmpIds; + public List getPlanIds() { + return planIds; } - public void setDmpIds(List dmpIds) { - this.dmpIds = dmpIds; + public void setPlanIds(List planIds) { + this.planIds = planIds; } public List getReferenceIds() { @@ -40,10 +39,10 @@ public class DmpReferenceLookup extends Lookup { this.referenceIds = referenceIds; } - public DmpReferenceQuery enrich(QueryFactory queryFactory) { - DmpReferenceQuery query = queryFactory.query(DmpReferenceQuery.class); + public PlanReferenceQuery enrich(QueryFactory queryFactory) { + PlanReferenceQuery query = queryFactory.query(PlanReferenceQuery.class); if (this.ids != null) query.ids(this.ids); - if (this.dmpIds != null) query.dmpIds(this.dmpIds); + if (this.planIds != null) query.planIds(this.planIds); if (this.referenceIds != null) query.referenceIds(this.referenceIds); this.enrichCommon(query); diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpUserLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanUserLookup.java similarity index 75% rename from backend/core/src/main/java/org/opencdmp/query/lookup/DmpUserLookup.java rename to backend/core/src/main/java/org/opencdmp/query/lookup/PlanUserLookup.java index fe10576b5..b2dec8dcd 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpUserLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanUserLookup.java @@ -2,25 +2,25 @@ package org.opencdmp.query.lookup; import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.QueryFactory; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.elastic.query.NestedCollaboratorElasticQuery; -import org.opencdmp.query.DmpUserQuery; +import org.opencdmp.query.PlanUserQuery; import java.util.List; import java.util.UUID; -public class DmpUserLookup extends Lookup { +public class PlanUserLookup extends Lookup { private List ids; - private List dmpIds; + private List planIds; private List userIds; private List sectionIds; private List isActive; - private List userRoles; + private List userRoles; public List getIds() { return this.ids; @@ -30,12 +30,12 @@ public class DmpUserLookup extends Lookup { this.ids = ids; } - public List getDmpIds() { - return this.dmpIds; + public List getPlanIds() { + return this.planIds; } - public void setDmpIds(List dmpIds) { - this.dmpIds = dmpIds; + public void setPlanIds(List planIds) { + this.planIds = planIds; } public List getUserIds() { @@ -62,18 +62,18 @@ public class DmpUserLookup extends Lookup { this.isActive = isActive; } - public List getUserRoles() { + public List getUserRoles() { return this.userRoles; } - public void setUserRoles(List userRoles) { + public void setUserRoles(List userRoles) { this.userRoles = userRoles; } - public DmpUserQuery enrich(QueryFactory queryFactory) { - DmpUserQuery query = queryFactory.query(DmpUserQuery.class); + public PlanUserQuery enrich(QueryFactory queryFactory) { + PlanUserQuery query = queryFactory.query(PlanUserQuery.class); if (this.ids != null) query.ids(this.ids); - if (this.dmpIds != null) query.dmpIds(this.dmpIds); + if (this.planIds != null) query.planIds(this.planIds); if (this.userIds != null) query.userIds(this.userIds); if (this.userRoles != null) query.userRoles(this.userRoles); if (this.sectionIds != null) query.sectionIds(this.sectionIds); diff --git a/backend/core/src/main/java/org/opencdmp/query/utils/QueryUtilsServiceImpl.java b/backend/core/src/main/java/org/opencdmp/query/utils/QueryUtilsServiceImpl.java index e5b338f2e..980930509 100644 --- a/backend/core/src/main/java/org/opencdmp/query/utils/QueryUtilsServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/query/utils/QueryUtilsServiceImpl.java @@ -3,12 +3,12 @@ package org.opencdmp.query.utils; import jakarta.persistence.criteria.*; import org.hibernate.query.criteria.HibernateCriteriaBuilder; import org.opencdmp.commons.enums.DescriptionStatus; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.data.DescriptionEntity; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.data.DmpUserEntity; +import org.opencdmp.data.PlanEntity; +import org.opencdmp.data.PlanUserEntity; import org.opencdmp.data.UserDescriptionTemplateEntity; import org.springframework.stereotype.Component; @@ -28,17 +28,17 @@ public class QueryUtilsServiceImpl implements QueryUtilsService { @Override public Subquery buildDmpAuthZSubQuery(AbstractQuery query, CriteriaBuilder criteriaBuilder, UUID userId, Boolean usePublic){ return this.buildSubQuery(new BuildSubQueryInput<>( - new BuildSubQueryInput.Builder<>(DmpEntity.class, UUID.class) + new BuildSubQueryInput.Builder<>(PlanEntity.class, UUID.class) .query(query) .criteriaBuilder(criteriaBuilder) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpEntity._id)) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(PlanEntity._id)) .filterFunc((subQueryRoot, cb) -> cb.or( usePublic ? cb.and( - cb.equal(subQueryRoot.get(DmpEntity._accessType), DmpAccessType.Public), - cb.equal(subQueryRoot.get(DmpEntity._status), DmpStatus.Finalized), - cb.equal(subQueryRoot.get(DmpEntity._isActive), IsActive.Active) + cb.equal(subQueryRoot.get(PlanEntity._accessType), PlanAccessType.Public), + cb.equal(subQueryRoot.get(PlanEntity._status), PlanStatus.Finalized), + cb.equal(subQueryRoot.get(PlanEntity._isActive), IsActive.Active) ): cb.or(), //Creates a false query - userId != null ? cb.in(subQueryRoot.get(DmpEntity._id)).value(this.buildDmpUserAuthZSubQuery(query, criteriaBuilder, userId)) : cb.or() //Creates a false query + userId != null ? cb.in(subQueryRoot.get(PlanEntity._id)).value(this.buildDmpUserAuthZSubQuery(query, criteriaBuilder, userId)) : cb.or() //Creates a false query ) ) )); @@ -53,8 +53,8 @@ public class QueryUtilsServiceImpl implements QueryUtilsService { .keyPathFunc((subQueryRoot) -> subQueryRoot.get(UserDescriptionTemplateEntity._descriptionTemplateId)) .filterFunc((subQueryRoot, cb) -> userId != null ? cb.and( - cb.equal(subQueryRoot.get(DmpUserEntity._userId), userId), - cb.equal(subQueryRoot.get(DmpUserEntity._isActive), IsActive.Active) + cb.equal(subQueryRoot.get(PlanUserEntity._userId), userId), + cb.equal(subQueryRoot.get(PlanUserEntity._isActive), IsActive.Active) ) : cb.or() //Creates a false query ) )); @@ -71,12 +71,12 @@ public class QueryUtilsServiceImpl implements QueryUtilsService { usePublic ? cb.and( cb.equal(subQueryRoot.get(DescriptionEntity._status), DescriptionStatus.Finalized), cb.equal(subQueryRoot.get(DescriptionEntity._isActive), IsActive.Active), - cb.in(subQueryRoot.get(DescriptionEntity._dmpId)).value(this.buildPublicDmpAuthZSubQuery(query, criteriaBuilder, usePublic)) + cb.in(subQueryRoot.get(DescriptionEntity._planId)).value(this.buildPublicDmpAuthZSubQuery(query, criteriaBuilder, usePublic)) ): cb.or(), //Creates a false query userId != null ? cb.or( cb.equal(subQueryRoot.get(DescriptionEntity._createdById), userId), - cb.in(subQueryRoot.get(DescriptionEntity._dmpId)).value(this.buildDmpUserAuthZSubQuery(query, criteriaBuilder, userId)) + cb.in(subQueryRoot.get(DescriptionEntity._planId)).value(this.buildDmpUserAuthZSubQuery(query, criteriaBuilder, userId)) ) : cb.or() //Creates a false query ) ) @@ -86,15 +86,15 @@ public class QueryUtilsServiceImpl implements QueryUtilsService { @Override public Subquery buildPublicDmpAuthZSubQuery(AbstractQuery query, CriteriaBuilder criteriaBuilder, Boolean usePublic){ return this.buildSubQuery(new BuildSubQueryInput<>( - new BuildSubQueryInput.Builder<>(DmpEntity.class, UUID.class) + new BuildSubQueryInput.Builder<>(PlanEntity.class, UUID.class) .query(query) .criteriaBuilder(criteriaBuilder) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpEntity._id)) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(PlanEntity._id)) .filterFunc((subQueryRoot, cb) -> usePublic ? cb.and( - cb.equal(subQueryRoot.get(DmpEntity._accessType), DmpAccessType.Public), - cb.equal(subQueryRoot.get(DmpEntity._status), DmpStatus.Finalized), - cb.equal(subQueryRoot.get(DmpEntity._isActive), IsActive.Active) + cb.equal(subQueryRoot.get(PlanEntity._accessType), PlanAccessType.Public), + cb.equal(subQueryRoot.get(PlanEntity._status), PlanStatus.Finalized), + cb.equal(subQueryRoot.get(PlanEntity._isActive), IsActive.Active) ): cb.or() //Creates a false query ) )); @@ -102,14 +102,14 @@ public class QueryUtilsServiceImpl implements QueryUtilsService { @Override public Subquery buildDmpUserAuthZSubQuery(AbstractQuery query, CriteriaBuilder criteriaBuilder, UUID userId){ - return this.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DmpUserEntity.class, UUID.class) + return this.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(PlanUserEntity.class, UUID.class) .query(query) .criteriaBuilder(criteriaBuilder) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpUserEntity._dmpId)) + .keyPathFunc((subQueryRoot) -> subQueryRoot.get(PlanUserEntity._planId)) .filterFunc((subQueryRoot, cb) -> userId != null ? cb.and( - cb.equal(subQueryRoot.get(DmpUserEntity._userId), userId), - cb.equal(subQueryRoot.get(DmpUserEntity._isActive), IsActive.Active) + cb.equal(subQueryRoot.get(PlanUserEntity._userId), userId), + cb.equal(subQueryRoot.get(PlanUserEntity._isActive), IsActive.Active) ) : cb.or() //Creates a false query ) )); diff --git a/backend/core/src/main/java/org/opencdmp/service/actionconfirmation/ActionConfirmationServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/actionconfirmation/ActionConfirmationServiceImpl.java index b19c67ed2..d2d2179a2 100644 --- a/backend/core/src/main/java/org/opencdmp/service/actionconfirmation/ActionConfirmationServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/actionconfirmation/ActionConfirmationServiceImpl.java @@ -18,7 +18,7 @@ import org.opencdmp.authorization.Permission; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.commons.types.actionconfirmation.DmpInvitationEntity; +import org.opencdmp.commons.types.actionconfirmation.PlanInvitationEntity; import org.opencdmp.commons.types.actionconfirmation.MergeAccountConfirmationEntity; import org.opencdmp.commons.types.actionconfirmation.RemoveCredentialRequestEntity; import org.opencdmp.commons.types.actionconfirmation.UserInviteToTenantRequestEntity; @@ -31,11 +31,11 @@ import org.opencdmp.model.builder.actionconfirmation.ActionConfirmationBuilder; import org.opencdmp.model.deleter.ActionConfirmationDeleter; import org.opencdmp.model.persist.ActionConfirmationPersist; import org.opencdmp.model.persist.UserInviteToTenantRequestPersist; -import org.opencdmp.model.persist.actionconfirmation.DmpInvitationPersist; +import org.opencdmp.model.persist.actionconfirmation.PlanInvitationPersist; import org.opencdmp.model.persist.actionconfirmation.MergeAccountConfirmationPersist; import org.opencdmp.model.persist.actionconfirmation.RemoveCredentialRequestPersist; import org.opencdmp.model.referencetype.ReferenceType; -import org.opencdmp.service.dmpblueprint.DmpBlueprintServiceImpl; +import org.opencdmp.service.planblueprint.PlanBlueprintServiceImpl; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -50,7 +50,7 @@ import java.util.UUID; @Service public class ActionConfirmationServiceImpl implements ActionConfirmationService { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintServiceImpl.class)); private final TenantEntityManager entityManager; private final AuthorizationService authorizationService; private final DeleterFactory deleterFactory; @@ -104,7 +104,7 @@ public class ActionConfirmationServiceImpl implements ActionConfirmationService data.setExpiresAt(model.getExpiresAt()); switch (model.getType()){ case MergeAccount -> data.setData(this.xmlHandlingService.toXmlSafe(this.buildMergeAccountConfirmationEntity(model.getMergeAccountConfirmation()))); - case DmpInvitation -> data.setData(this.xmlHandlingService.toXmlSafe(this.buildDmpInvitationEntity(model.getDmpInvitation()))); + case PlanInvitation -> data.setData(this.xmlHandlingService.toXmlSafe(this.buildDmpInvitationEntity(model.getPlanInvitation()))); case RemoveCredential -> data.setData(this.xmlHandlingService.toXmlSafe(this.buildMergeAccountConfirmationEntity(model.getRemoveCredentialRequest()))); case UserInviteToTenant -> data.setData(this.xmlHandlingService.toXmlSafe(this.buildUserInviteToTenantRequestEntity(model.getUserInviteToTenantRequest()))); default -> throw new InternalError("unknown type: " + model.getType()); @@ -119,13 +119,13 @@ public class ActionConfirmationServiceImpl implements ActionConfirmationService return this.builderFactory.builder(ActionConfirmationBuilder.class).build(BaseFieldSet.build(fields, ActionConfirmation._id), data); } - private @NotNull DmpInvitationEntity buildDmpInvitationEntity(DmpInvitationPersist persist){ - DmpInvitationEntity data = new DmpInvitationEntity(); + private @NotNull PlanInvitationEntity buildDmpInvitationEntity(PlanInvitationPersist persist){ + PlanInvitationEntity data = new PlanInvitationEntity(); if (persist == null) return data; data.setEmail(persist.getEmail()); data.setRole(persist.getRole()); - data.setDmpId(persist.getDmpId()); + data.setPlanId(persist.getPlanId()); return data; } 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 c70c563d9..1480f655e 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 @@ -18,11 +18,11 @@ import org.opencdmp.model.*; import org.opencdmp.model.builder.PublicReferenceTypeBuilder; import org.opencdmp.model.builder.RecentActivityItemBuilder; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.result.QueryResult; import org.opencdmp.query.*; import org.opencdmp.query.lookup.DescriptionLookup; -import org.opencdmp.query.lookup.DmpLookup; +import org.opencdmp.query.lookup.PlanLookup; import org.opencdmp.service.elastic.ElasticQueryHelperService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -83,14 +83,14 @@ public class DashboardServiceImpl implements DashboardService { } } - DmpLookup dmpLookup = model.asDmpLookup(); - if (dmpLookup != null){ - dmpLookup.getPage().setOffset(0); - dmpLookup.getPage().setSize(model.getPage().getSize()+model.getPage().getOffset()); + PlanLookup planLookup = model.asDmpLookup(); + if (planLookup != null){ + planLookup.getPage().setOffset(0); + planLookup.getPage().setSize(model.getPage().getSize()+model.getPage().getOffset()); - QueryResult dmps = this.elasticQueryHelperService.collect(dmpLookup, AuthorizationFlags.AllExceptPublic, new BaseFieldSet().ensure(Dmp._id).ensure(Dmp._updatedAt).ensure(Dmp._label).ensure(Dmp._status)); + QueryResult dmps = this.elasticQueryHelperService.collect(planLookup, AuthorizationFlags.AllExceptPublic, new BaseFieldSet().ensure(Plan._id).ensure(Plan._updatedAt).ensure(Plan._label).ensure(Plan._status)); if (!this.conventionService.isListNullOrEmpty(dmps.getItems())) { - for (Dmp dmp : dmps.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Dmp, dmp.getId(), dmp.getUpdatedAt(), dmp.getLabel(), dmp.getStatus().getValue())); + for (Plan plan : dmps.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Plan, plan.getId(), plan.getUpdatedAt(), plan.getLabel(), plan.getStatus().getValue())); } } @@ -118,18 +118,18 @@ 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).disableTracking().isActive(IsActive.Active).versionStatuses(DmpVersionStatus.Current).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().isActive(IsActive.Active).versionStatuses(PlanVersionStatus.Current).statuses(PlanStatus.Finalized).accessTypes(PlanAccessType.Public); DashboardStatistics statistics = new DashboardStatistics(); - statistics.setDmpCount(dmpQuery.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.setDmpCount(planQuery.authorize(EnumSet.of(Public)).count()); + statistics.setDescriptionCount(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(planQuery).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).disableTracking().isActive(IsActive.Active).typeIds(typeId).authorize(EnumSet.of(Public)) - .dmpReferenceSubQuery(this.queryFactory.query(DmpReferenceQuery.class).disableTracking().isActives(IsActive.Active) - .dmpSubQuery(dmpQuery)).count()); + .dmpReferenceSubQuery(this.queryFactory.query(PlanReferenceQuery.class).disableTracking().isActives(IsActive.Active) + .dmpSubQuery(planQuery)).count()); 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); } @@ -149,23 +149,23 @@ 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).disableTracking(); + PlanUserQuery dmpUserLookup = this.queryFactory.query(PlanUserQuery.class).disableTracking(); dmpUserLookup.userIds(this.userScope.getUserId()); dmpUserLookup.isActives(IsActive.Active); - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().isActive(IsActive.Active).dmpUserSubQuery(dmpUserLookup).versionStatuses(List.of(DmpVersionStatus.Current, DmpVersionStatus.NotFinalized)); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().isActive(IsActive.Active).planUserSubQuery(dmpUserLookup).versionStatuses(List.of(PlanVersionStatus.Current, PlanVersionStatus.NotFinalized)); DashboardStatistics statistics = new DashboardStatistics(); - statistics.setDmpCount(dmpQuery.authorize(AuthorizationFlags.AllExceptPublic).count()); - statistics.setDescriptionCount(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(dmpQuery).authorize(AuthorizationFlags.AllExceptPublic).count()); + statistics.setDmpCount(planQuery.authorize(AuthorizationFlags.AllExceptPublic).count()); + statistics.setDescriptionCount(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(planQuery).authorize(AuthorizationFlags.AllExceptPublic).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).disableTracking().isActive(IsActive.Active).typeIds(typeId).authorize(AuthorizationFlags.AllExceptPublic) - .dmpReferenceSubQuery(this.queryFactory.query(DmpReferenceQuery.class).disableTracking().isActives(IsActive.Active) - .dmpSubQuery(dmpQuery)).count()); + .dmpReferenceSubQuery(this.queryFactory.query(PlanReferenceQuery.class).disableTracking().isActives(IsActive.Active) + .dmpSubQuery(planQuery)).count()); 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/DepositService.java b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositService.java index 4fc1f6739..da3c14a5d 100644 --- a/backend/core/src/main/java/org/opencdmp/service/deposit/DepositService.java +++ b/backend/core/src/main/java/org/opencdmp/service/deposit/DepositService.java @@ -16,7 +16,7 @@ import java.util.List; public interface DepositService { List getAvailableConfigurations(FieldSet fieldSet) throws InvalidApplicationException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException; - EntityDoi deposit(DepositRequest dmpDepositModel) throws Exception; + EntityDoi deposit(DepositRequest planDepositModel) throws Exception; String getLogo(String repositoryId) throws InvalidApplicationException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException; } 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 980bc4cc2..cf16944dc 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 @@ -31,8 +31,8 @@ import org.opencdmp.commons.types.notification.FieldInfo; import org.opencdmp.commons.types.notification.NotificationFieldData; import org.opencdmp.commons.types.tenantconfiguration.DepositTenantConfigurationEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.data.DmpUserEntity; +import org.opencdmp.data.PlanEntity; +import org.opencdmp.data.PlanUserEntity; import org.opencdmp.data.TenantConfigurationEntity; import org.opencdmp.data.UserEntity; import org.opencdmp.depositbase.repository.DepositClient; @@ -43,14 +43,14 @@ import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventH import org.opencdmp.model.EntityDoi; import org.opencdmp.model.StorageFile; import org.opencdmp.model.builder.commonmodels.DepositConfigurationBuilder; -import org.opencdmp.model.builder.commonmodels.dmp.DmpCommonModelBuilder; +import org.opencdmp.model.builder.commonmodels.plan.PlanCommonModelBuilder; 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.tenantconfiguration.TenantConfiguration; -import org.opencdmp.query.DmpQuery; -import org.opencdmp.query.DmpUserQuery; +import org.opencdmp.query.PlanQuery; +import org.opencdmp.query.PlanUserQuery; import org.opencdmp.query.TenantConfigurationQuery; import org.opencdmp.query.UserQuery; import org.opencdmp.service.encryption.EncryptionService; @@ -269,31 +269,31 @@ public class DepositServiceImpl implements DepositService { } @Override - public EntityDoi deposit(DepositRequest dmpDepositModel) throws Exception { - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(dmpDepositModel.getDmpId())), Permission.DepositDmp); + public EntityDoi deposit(DepositRequest planDepositModel) throws Exception { + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(planDepositModel.getPlanId())), Permission.DepositPlan); //GK: First get the right client - 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())); + DepositClient depositClient = this.getDepositClient(planDepositModel.getRepositoryId()); + if (depositClient == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planDepositModel.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale())); //GK: Second get the Target Data Management Plan - 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())); + PlanEntity planEntity = this.queryFactory.query(PlanQuery.class).disableTracking().ids(planDepositModel.getPlanId()).first(); + if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planDepositModel.getPlanId(), PlanEntity.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(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositSourceEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); + DepositSourceEntity source = this.getDepositSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(planDepositModel.getRepositoryId())).findFirst().orElse(null); + if (source == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planDepositModel.getRepositoryId(), DepositSourceEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); String accessToken = null; - if (!this.conventionService.isNullOrEmpty(dmpDepositModel.getAuthorizationCode())) { + if (!this.conventionService.isNullOrEmpty(planDepositModel.getAuthorizationCode())) { DepositAuthenticateRequest authenticateRequest = new DepositAuthenticateRequest(); - authenticateRequest.setRepositoryId(dmpDepositModel.getRepositoryId()); - authenticateRequest.setCode(dmpDepositModel.getAuthorizationCode()); + authenticateRequest.setRepositoryId(planDepositModel.getRepositoryId()); + authenticateRequest.setCode(planDepositModel.getAuthorizationCode()); accessToken = this.authenticate(authenticateRequest); } - 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"); + org.opencdmp.model.file.FileEnvelope pdfFile = this.fileTransformerService.exportDmp(planEntity.getId(), source.getPdfTransformerId(),"pdf"); + org.opencdmp.model.file.FileEnvelope rda = this.fileTransformerService.exportDmp(planEntity.getId(), source.getRdaTransformerId(),"json"); FileEnvelopeModel pdfEnvelope = new FileEnvelopeModel(); FileEnvelopeModel jsonEnvelope = new FileEnvelopeModel(); @@ -311,8 +311,8 @@ public class DepositServiceImpl implements DepositService { } //GK: Fifth Transform them to the DepositModel - DmpModel depositModel = this.builderFactory.builder(DmpCommonModelBuilder.class).useSharedStorage(depositClient.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.AllExceptPublic) - .setRepositoryId(dmpDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).build(dmpEntity); + DmpModel depositModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(depositClient.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.AllExceptPublic) + .setRepositoryId(planDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).build(planEntity); //GK: Sixth Perform the deposit @@ -321,29 +321,29 @@ public class DepositServiceImpl implements DepositService { if (doi.isEmpty()) return null; //GK: doi is fine store it in database EntityDoiPersist doiPersist = new EntityDoiPersist(); - doiPersist.setRepositoryId(dmpDepositModel.getRepositoryId()); + doiPersist.setRepositoryId(planDepositModel.getRepositoryId()); doiPersist.setDoi(doi); - doiPersist.setEntityId(dmpEntity.getId()); - this.sendNotification(dmpEntity); - return this.doiService.persist(doiPersist, true, dmpDepositModel.getProject()); + doiPersist.setEntityId(planEntity.getId()); + this.sendNotification(planEntity); + return this.doiService.persist(doiPersist, true, planDepositModel.getProject()); } - private void sendNotification(DmpEntity dmpEntity) throws InvalidApplicationException { - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(dmpEntity.getId()).isActives(IsActive.Active).collect(); + private void sendNotification(PlanEntity planEntity) throws InvalidApplicationException { + List dmpUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(planEntity.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).disableTracking().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(PlanUserEntity::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()))){ - this.createDmpDepositNotificationEvent(dmpEntity, user); + this.createDmpDepositNotificationEvent(planEntity, user); } } } - private void createDmpDepositNotificationEvent(DmpEntity dmp, UserEntity user) throws InvalidApplicationException { + private void createDmpDepositNotificationEvent(PlanEntity dmp, UserEntity user) throws InvalidApplicationException { NotifyIntegrationEvent event = new NotifyIntegrationEvent(); event.setUserId(user.getId()); diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java index 9d4cf2eab..2708e7033 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java @@ -52,8 +52,8 @@ public interface DescriptionService { ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException; - Description importXml(DescriptionImportExport descriptionXml, UUID dmpId, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; + Description importXml(DescriptionImportExport descriptionXml, UUID planId, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; - Description importCommonModel(DescriptionModel model, UUID dmpId, FieldSet fields) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException; + Description importCommonModel(DescriptionModel model, UUID planId, FieldSet fields) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException; } diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java index e86ada34a..09d78b75d 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java @@ -50,7 +50,7 @@ import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEnti import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent; import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventHandler; import org.opencdmp.model.DescriptionValidationResult; -import org.opencdmp.model.DmpDescriptionTemplate; +import org.opencdmp.model.PlanDescriptionTemplate; import org.opencdmp.model.StorageFile; import org.opencdmp.model.Tag; import org.opencdmp.model.builder.description.DescriptionBuilder; @@ -59,8 +59,8 @@ import org.opencdmp.model.deleter.DescriptionReferenceDeleter; import org.opencdmp.model.deleter.DescriptionTagDeleter; import org.opencdmp.model.description.Description; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.planblueprint.PlanBlueprint; import org.opencdmp.model.file.FileEnvelope; import org.opencdmp.model.persist.*; import org.opencdmp.model.persist.descriptionproperties.*; @@ -186,7 +186,7 @@ public class DescriptionServiceImpl implements DescriptionService { Map> response = new HashMap<>(); - Map affiliatedResourceMap = this.authorizationContentResolver.descriptionsAffiliationBySections(model.getDmpId(), model.getSectionIds()); + Map affiliatedResourceMap = this.authorizationContentResolver.descriptionsAffiliationBySections(model.getPlanId(), model.getSectionIds()); for (UUID sectionId : model.getSectionIds().stream().distinct().toList()){ AffiliatedResource affiliatedResource = affiliatedResourceMap.getOrDefault(sectionId, null); response.put(sectionId, new ArrayList<>()); @@ -206,11 +206,11 @@ public class DescriptionServiceImpl implements DescriptionService { Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); - DmpDescriptionTemplateEntity dmpDescriptionTemplate = this.entityManager.find(DmpDescriptionTemplateEntity.class, model.getDmpDescriptionTemplateId()); - if (dmpDescriptionTemplate == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanDescriptionTemplateEntity planDescriptionTemplate = this.entityManager.find(PlanDescriptionTemplateEntity.class, model.getPlanDescriptionTemplateId()); + if (planDescriptionTemplate == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPlanDescriptionTemplateId(), PlanDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (isUpdate) this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription); - else this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionsAffiliationBySection(model.getDmpId(), dmpDescriptionTemplate.getSectionId())), Permission.EditDescription); + else this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionsAffiliationBySection(model.getPlanId(), planDescriptionTemplate.getSectionId())), Permission.EditDescription); DescriptionEntity data; if (isUpdate) { @@ -218,27 +218,27 @@ public class DescriptionServiceImpl implements DescriptionService { if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); if (data.getStatus().equals(DescriptionStatus.Finalized)) throw new MyValidationException(this.errors.getDescriptionIsFinalized().getCode(), this.errors.getDescriptionIsFinalized().getMessage()); - if (!data.getDmpId().equals(model.getDmpId())) throw new MyValidationException(this.errors.getDmpCanNotChange().getCode(), this.errors.getDmpCanNotChange().getMessage()); - if (!data.getDmpDescriptionTemplateId().equals(model.getDmpDescriptionTemplateId())) throw new MyValidationException(this.errors.getDmpDescriptionTemplateCanNotChange().getCode(), this.errors.getDmpDescriptionTemplateCanNotChange().getMessage()); + if (!data.getPlanId().equals(model.getPlanId())) throw new MyValidationException(this.errors.getDmpCanNotChange().getCode(), this.errors.getDmpCanNotChange().getMessage()); + if (!data.getPlanDescriptionTemplateId().equals(model.getPlanDescriptionTemplateId())) throw new MyValidationException(this.errors.getDmpDescriptionTemplateCanNotChange().getCode(), this.errors.getDmpDescriptionTemplateCanNotChange().getMessage()); } else { data = new DescriptionEntity(); data.setId(UUID.randomUUID()); data.setIsActive(IsActive.Active); data.setCreatedAt(Instant.now()); data.setCreatedById(this.userScope.getUserId()); - data.setDmpId(model.getDmpId()); - data.setDmpDescriptionTemplateId(model.getDmpDescriptionTemplateId()); + data.setPlanId(model.getPlanId()); + data.setPlanDescriptionTemplateId(model.getPlanDescriptionTemplateId()); } DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId(), true); if (descriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if (!dmpDescriptionTemplate.getDescriptionTemplateGroupId().equals(descriptionTemplateEntity.getGroupId())) throw new MyValidationException(this.errors.getInvalidDescriptionTemplate().getCode(), this.errors.getInvalidDescriptionTemplate().getMessage()); + if (!planDescriptionTemplate.getDescriptionTemplateGroupId().equals(descriptionTemplateEntity.getGroupId())) throw new MyValidationException(this.errors.getInvalidDescriptionTemplate().getCode(), this.errors.getInvalidDescriptionTemplate().getMessage()); - DmpEntity dmp = this.entityManager.find(DmpEntity.class, data.getDmpId(), true); - if (dmp == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanEntity dmp = this.entityManager.find(PlanEntity.class, data.getPlanId(), true); + if (dmp == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getPlanId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if (dmp.getStatus().equals(DmpStatus.Finalized) && isUpdate) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage()); + if (dmp.getStatus().equals(PlanStatus.Finalized) && isUpdate) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage()); data.setLabel(model.getLabel()); data.setStatus(model.getStatus()); @@ -288,8 +288,8 @@ public class DescriptionServiceImpl implements DescriptionService { DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId(), true); if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.entityManager.find(DmpDescriptionTemplateEntity.class, data.getDmpDescriptionTemplateId(), true); - if (dmpDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.entityManager.find(PlanDescriptionTemplateEntity.class, data.getPlanDescriptionTemplateId(), true); + if (planDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getPlanDescriptionTemplateId(), PlanDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); List latestVersionDescriptionTemplates = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking() @@ -326,15 +326,15 @@ public class DescriptionServiceImpl implements DescriptionService { } private void sendNotification(DescriptionEntity description, Boolean isUpdate) throws InvalidApplicationException { - List existingUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking() - .dmpIds(description.getDmpId()) + List existingUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking() + .planIds(description.getPlanId()) .isActives(IsActive.Active) .collect(); if (existingUsers == null || existingUsers.size() <= 1){ return; } - for (DmpUserEntity dmpUser : existingUsers) { + for (PlanUserEntity dmpUser : existingUsers) { if (!dmpUser.getUserId().equals(this.userScope.getUserIdSafe())){ UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpUser.getUserId()).first(); if (user == null || user.getIsActive().equals(IsActive.Inactive)) throw new MyValidationException(this.errors.getDmpInactiveUser().getCode(), this.errors.getDmpInactiveUser().getMessage()); @@ -435,9 +435,9 @@ public class DescriptionServiceImpl implements DescriptionService { if (!data.getStatus().equals(model.getStatus())){ if (data.getStatus().equals(DescriptionStatus.Finalized)){ this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.FinalizeDescription); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, data.getDmpId(), true); - if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpId(), DmpEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if(!dmpEntity.getStatus().equals(DmpStatus.Draft)) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage()); + PlanEntity planEntity = this.entityManager.find(PlanEntity.class, data.getPlanId(), true); + if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getPlanId(), PlanEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if(!planEntity.getStatus().equals(PlanStatus.Draft)) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage()); } data.setStatus(model.getStatus()); @@ -553,9 +553,9 @@ public class DescriptionServiceImpl implements DescriptionService { else if (!this.conventionService.isNullOrEmpty(persist.getTextValue())) ids.add(UUID.fromString(persist.getTextValue())); if (!ids.isEmpty()){ - Set existingIds = this.queryFactory.query(DmpQuery.class).disableTracking().ids(ids).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).collect(Collectors.toSet()); + Set existingIds = this.queryFactory.query(PlanQuery.class).disableTracking().ids(ids).collectAs(new BaseFieldSet().ensure(Plan._id)).stream().map(PlanEntity::getId).collect(Collectors.toSet()); for (UUID id : ids){ - if (!existingIds.contains(id)) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (!existingIds.contains(id)) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); } } @@ -922,15 +922,15 @@ public class DescriptionServiceImpl implements DescriptionService { DescriptionEntity descriptionEntity = this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).ids(descriptionId).first(); if (descriptionEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionId, Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first(); - if (dmpDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionEntity.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(descriptionEntity.getPlanDescriptionTemplateId()).isActive(IsActive.Active).first(); + if (planDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionEntity.getPlanDescriptionTemplateId(), PlanDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpEntity dmpEntity = this.queryFactory.query(DmpQuery.class).ids(dmpDescriptionTemplateEntity.getDmpId()).disableTracking().isActive(IsActive.Active).first(); - if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDescriptionTemplateEntity.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanEntity planEntity = this.queryFactory.query(PlanQuery.class).ids(planDescriptionTemplateEntity.getPlanId()).disableTracking().isActive(IsActive.Active).first(); + if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planDescriptionTemplateEntity.getPlanId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if (!dmpEntity.getAccessType().equals(DmpAccessType.Public)) + if (!planEntity.getAccessType().equals(PlanAccessType.Public)) { - boolean isDmpUser = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmpEntity.getId()).disableTracking().userIds(this.userScope.getUserIdSafe()).isActives(IsActive.Active).count() > 0; + boolean isDmpUser = this.queryFactory.query(PlanUserQuery.class).planIds(planEntity.getId()).disableTracking().userIds(this.userScope.getUserIdSafe()).isActives(IsActive.Active).count() > 0; if (!isDmpUser) throw new MyUnauthorizedException(); } @@ -954,8 +954,8 @@ public class DescriptionServiceImpl implements DescriptionService { persist.setStatus(DescriptionStatus.Finalized); persist.setDescription(data.getDescription()); persist.setDescriptionTemplateId(data.getDescriptionTemplateId()); - persist.setDmpId(data.getDmpId()); - persist.setDmpDescriptionTemplateId(data.getDmpDescriptionTemplateId()); + persist.setPlanId(data.getPlanId()); + persist.setPlanDescriptionTemplateId(data.getPlanDescriptionTemplateId()); org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition()); @@ -1141,8 +1141,8 @@ public class DescriptionServiceImpl implements DescriptionService { xml.setLabel(data.getLabel()); xml.setFinalizedAt(data.getFinalizedAt()); - DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(data.getDmpDescriptionTemplateId()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).first(); - if (dmpDescriptionTemplateEntity != null) xml.setSectionId(dmpDescriptionTemplateEntity.getSectionId()); + PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(data.getPlanDescriptionTemplateId()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).first(); + if (planDescriptionTemplateEntity != null) xml.setSectionId(planDescriptionTemplateEntity.getSectionId()); DescriptionTagQuery descriptionTagQuery = this.queryFactory.query(DescriptionTagQuery.class); descriptionTagQuery.descriptionIds(data.getId()); @@ -1160,17 +1160,17 @@ public class DescriptionServiceImpl implements DescriptionService { xml.setProperties(this.descriptionPropertyDefinitionToExport(propertiesEntity)); } - List dmpReferences = this.queryFactory.query(DescriptionReferenceQuery.class).disableTracking().descriptionIds(data.getId()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); - if (!this.conventionService.isListNullOrEmpty(dmpReferences)) { - List references = this.queryFactory.query(ReferenceQuery.class).disableTracking().ids(dmpReferences.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); + List planReferences = this.queryFactory.query(DescriptionReferenceQuery.class).disableTracking().descriptionIds(data.getId()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); + if (!this.conventionService.isListNullOrEmpty(planReferences)) { + List references = this.queryFactory.query(ReferenceQuery.class).disableTracking().ids(planReferences.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); Map referenceEntityMap = references == null ? new HashMap<>() : references.stream().collect(Collectors.toMap(ReferenceEntity::getId, x-> x)); List referenceTypes = references == null ? new ArrayList<>() : this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(references.stream().map(ReferenceEntity::getTypeId).distinct().toList()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); Map referenceTypeEntityMap = referenceTypes == null ? new HashMap<>() : referenceTypes.stream().collect(Collectors.toMap(ReferenceTypeEntity::getId, x-> x)); - List dmpReferenceImportExports = new LinkedList<>(); - for (DescriptionReferenceEntity descriptionReferenceEntity : dmpReferences) { - dmpReferenceImportExports.add(this.descriptionReferenceToExport(descriptionReferenceEntity, referenceEntityMap, referenceTypeEntityMap)); + List descriptionReferenceImportExports = new LinkedList<>(); + for (DescriptionReferenceEntity descriptionReferenceEntity : planReferences) { + descriptionReferenceImportExports.add(this.descriptionReferenceToExport(descriptionReferenceEntity, referenceEntityMap, referenceTypeEntityMap)); } - xml.setReferences(dmpReferenceImportExports); + xml.setReferences(descriptionReferenceImportExports); } return xml; } @@ -1287,19 +1287,19 @@ public class DescriptionServiceImpl implements DescriptionService { //region Import xml - public Description importXml(DescriptionImportExport descriptionXml, UUID dmpId, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException{ + public Description importXml(DescriptionImportExport descriptionXml, UUID planId, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException{ if (descriptionXml == null) throw new MyNotFoundException("Description xml not found"); - logger.debug(new MapLogEntry("import description").And("dmpId", dmpId).And("fields", fields)); + logger.debug(new MapLogEntry("import description").And("planId", planId).And("fields", fields)); DescriptionPersist persist = new DescriptionPersist(); persist.setLabel(descriptionXml.getLabel()); persist.setDescription(descriptionXml.getDescription()); persist.setStatus(DescriptionStatus.Draft); - persist.setDmpId(dmpId); + persist.setPlanId(planId); persist.setDescriptionTemplateId(this.xmlToDescriptionTemplatePersist(descriptionXml)); - persist.setDmpDescriptionTemplateId(this.xmlToDmpDescriptionTemplatePersist(descriptionXml, dmpId)); + persist.setPlanDescriptionTemplateId(this.xmlToPlanDescriptionTemplatePersist(descriptionXml, planId)); persist.setTags(descriptionXml.getTags()); persist.setProperties(this.xmlToPropertyDefinitionToPersist(descriptionXml)); @@ -1319,7 +1319,7 @@ public class DescriptionServiceImpl implements DescriptionService { if (descriptionTemplateEntity != null){ descriptionTemplateId = descriptionTemplateEntity.getId(); } else { - DescriptionTemplate persisted = this.descriptionTemplateService.importXml(descriptionXml.getDescriptionTemplate(), null, descriptionXml.getDescriptionTemplate().getDescription(), new BaseFieldSet().ensure(DmpBlueprint._label).ensure(DmpBlueprint._hash)); + DescriptionTemplate persisted = this.descriptionTemplateService.importXml(descriptionXml.getDescriptionTemplate(), null, descriptionXml.getDescriptionTemplate().getDescription(), new BaseFieldSet().ensure(PlanBlueprint._label).ensure(PlanBlueprint._hash)); descriptionTemplateId = persisted.getId(); } @@ -1328,20 +1328,20 @@ public class DescriptionServiceImpl implements DescriptionService { return null; } - private UUID xmlToDmpDescriptionTemplatePersist(DescriptionImportExport descriptionXml, UUID dmpId) { + private UUID xmlToPlanDescriptionTemplatePersist(DescriptionImportExport descriptionXml, UUID planId) { if (descriptionXml.getDescriptionTemplate() != null) { - List dmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking() + List planDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking() .isActive(IsActive.Active) - .dmpIds(dmpId) + .planIds(planId) .collect(); - if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplates) && descriptionXml.getSectionId() != null && descriptionXml.getDescriptionTemplate().getGroupId() != null){ - DmpDescriptionTemplateEntity dmpDescriptionTemplate = dmpDescriptionTemplates.stream().filter(x -> + if (!this.conventionService.isListNullOrEmpty(planDescriptionTemplates) && descriptionXml.getSectionId() != null && descriptionXml.getDescriptionTemplate().getGroupId() != null){ + PlanDescriptionTemplateEntity planDescriptionTemplate = planDescriptionTemplates.stream().filter(x -> x.getDescriptionTemplateGroupId().equals(descriptionXml.getDescriptionTemplate().getGroupId()) && x.getSectionId().equals(descriptionXml.getSectionId())).findFirst().orElse(null); - if (dmpDescriptionTemplate == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionXml.getDescriptionTemplate().getGroupId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); - return dmpDescriptionTemplate.getId(); + if (planDescriptionTemplate == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionXml.getDescriptionTemplate().getGroupId(), PlanDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); + return planDescriptionTemplate.getId(); } } return null; @@ -1500,18 +1500,18 @@ public class DescriptionServiceImpl implements DescriptionService { //region Import Common Model @Override - public Description importCommonModel(DescriptionModel model, UUID dmpId, FieldSet fields) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException { - logger.debug(new MapLogEntry("import description").And("dmpId", dmpId).And("fields", fields)); + public Description importCommonModel(DescriptionModel model, UUID planId, FieldSet fields) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException { + logger.debug(new MapLogEntry("import description").And("planId", planId).And("fields", fields)); if (model == null) throw new IllegalArgumentException ("model"); - if (dmpId == null) throw new IllegalArgumentException ("dmpId"); + if (planId == null) throw new IllegalArgumentException ("planId"); DescriptionPersist persist = new DescriptionPersist(); persist.setLabel(model.getLabel()); persist.setDescription(model.getDescription()); persist.setStatus(DescriptionStatus.Draft); - persist.setDmpId(dmpId); + persist.setPlanId(planId); persist.setDescriptionTemplateId(this.commonModelToDescriptionTemplatePersist(model)); - persist.setDmpDescriptionTemplateId(this.commonModelTToDmpDescriptionTemplatePersist(model, dmpId)); + persist.setPlanDescriptionTemplateId(this.commonModelTToPlanDescriptionTemplatePersist(model, planId)); persist.setTags(model.getTags()); persist.setProperties(this.commonModelPropertyDefinitionToPersist(model)); @@ -1529,7 +1529,7 @@ public class DescriptionServiceImpl implements DescriptionService { if (descriptionTemplateEntity != null){ descriptionTemplateId = descriptionTemplateEntity.getId(); } else { - DescriptionTemplate persisted = this.descriptionTemplateService.importCommonModel(commonModel.getDescriptionTemplate(), new BaseFieldSet().ensure(DmpBlueprint._label).ensure(DmpBlueprint._hash)); + DescriptionTemplate persisted = this.descriptionTemplateService.importCommonModel(commonModel.getDescriptionTemplate(), new BaseFieldSet().ensure(PlanBlueprint._label).ensure(PlanBlueprint._hash)); descriptionTemplateId = persisted.getId(); } @@ -1538,20 +1538,20 @@ public class DescriptionServiceImpl implements DescriptionService { return null; } - private UUID commonModelTToDmpDescriptionTemplatePersist(DescriptionModel commonModel, UUID dmpId) { + private UUID commonModelTToPlanDescriptionTemplatePersist(DescriptionModel commonModel, UUID planId) { if (commonModel.getDescriptionTemplate() != null) { - List dmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking() + List planDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking() .isActive(IsActive.Active) - .dmpIds(dmpId) + .planIds(planId) .collect(); - if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplates) && commonModel.getSectionId() != null && commonModel.getDescriptionTemplate().getGroupId() != null){ - DmpDescriptionTemplateEntity dmpDescriptionTemplate = dmpDescriptionTemplates.stream().filter(x -> + if (!this.conventionService.isListNullOrEmpty(planDescriptionTemplates) && commonModel.getSectionId() != null && commonModel.getDescriptionTemplate().getGroupId() != null){ + PlanDescriptionTemplateEntity planDescriptionTemplate = planDescriptionTemplates.stream().filter(x -> x.getDescriptionTemplateGroupId().equals(commonModel.getDescriptionTemplate().getGroupId()) && x.getSectionId().equals(commonModel.getSectionId())).findFirst().orElse(null); - if (dmpDescriptionTemplate == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{commonModel.getDescriptionTemplate().getGroupId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); - return dmpDescriptionTemplate.getId(); + if (planDescriptionTemplate == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{commonModel.getDescriptionTemplate().getGroupId(), PlanDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); + return planDescriptionTemplate.getId(); } } return null; diff --git a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpService.java b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpService.java deleted file mode 100644 index 28d9244d4..000000000 --- a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpService.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.opencdmp.service.dmp; - -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.exception.MyForbiddenException; -import gr.cite.tools.exception.MyNotFoundException; -import gr.cite.tools.exception.MyValidationException; -import gr.cite.tools.fieldset.FieldSet; -import jakarta.xml.bind.JAXBException; -import org.opencdmp.commons.types.dmp.importexport.DmpImportExport; -import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel; -import org.opencdmp.model.DmpUser; -import org.opencdmp.model.DmpValidationResult; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.persist.*; -import org.springframework.http.ResponseEntity; -import org.xml.sax.SAXException; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.management.InvalidApplicationException; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; -import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.List; -import java.util.UUID; - -public interface DmpService { - - Dmp persist(DmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, IOException; - - void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException, IOException; - - void finalize(UUID id, List descriptionIds) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException; - - void undoFinalize(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException; - - DmpValidationResult validate(UUID id) throws InvalidApplicationException; - - Dmp createNewVersion(NewVersionDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, TransformerException; - - Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException; - - List assignUsers(UUID dmp, List model, FieldSet fields, boolean disableDelete) throws InvalidApplicationException, IOException; - Dmp removeUser(DmpUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException; - - ResponseEntity export(UUID id, String transformerId, String exportType) throws InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException; - - void inviteUserOrAssignUsers(UUID id, List users) throws InvalidApplicationException, JAXBException, IOException; - - void dmpInvitationAccept(String token) throws InvalidApplicationException, IOException; - - DmpImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException; - - ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException; - - Dmp importXml(byte[] bytes, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; - - Dmp importJson(DmpCommonModelConfig dmpCommonModelConfig, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException; - - PreprocessingDmpModel preprocessingDmp(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException; -} diff --git a/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintService.java b/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintService.java deleted file mode 100644 index b8d6b04f7..000000000 --- a/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintService.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.opencdmp.service.dmpblueprint; - -import com.fasterxml.jackson.core.JsonProcessingException; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.exception.MyForbiddenException; -import gr.cite.tools.exception.MyNotFoundException; -import gr.cite.tools.exception.MyValidationException; -import gr.cite.tools.fieldset.FieldSet; -import jakarta.xml.bind.JAXBException; -import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel; -import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType; -import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintImportExport; -import org.opencdmp.data.DmpBlueprintEntity; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.model.persist.DmpBlueprintPersist; -import org.opencdmp.model.persist.NewVersionDmpBlueprintPersist; -import org.springframework.http.ResponseEntity; -import org.xml.sax.SAXException; - -import javax.management.InvalidApplicationException; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; -import java.io.IOException; -import java.util.UUID; - -public interface DmpBlueprintService { - - DmpBlueprint persist(DmpBlueprintPersist model, UUID groupId, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException; - - void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; - boolean fieldInBlueprint(DmpBlueprintEntity dmpBlueprintEntity, DmpBlueprintSystemFieldType type); - - boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type) throws InvalidApplicationException; - - DmpBlueprint buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException; - - DmpBlueprint createNewVersion(NewVersionDmpBlueprintPersist model, FieldSet fieldSet) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException; - - BlueprintImportExport getExportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException; - - ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException; - - DmpBlueprint importXml(BlueprintImportExport dmpDefinition, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; - - DmpBlueprint importXml(byte[] bytes, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; - DmpBlueprint importCommonModel(DmpBlueprintModel dmpDefinition, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; -} diff --git a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticQueryHelperService.java b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticQueryHelperService.java index 89e764e67..64a48e26e 100644 --- a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticQueryHelperService.java +++ b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticQueryHelperService.java @@ -3,19 +3,19 @@ package org.opencdmp.service.elastic; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.model.*; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.result.QueryResult; import org.opencdmp.query.lookup.DescriptionLookup; -import org.opencdmp.query.lookup.DmpLookup; +import org.opencdmp.query.lookup.PlanLookup; import gr.cite.tools.fieldset.FieldSet; import java.util.EnumSet; public interface ElasticQueryHelperService { - QueryResult collect(DmpLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet); - QueryResult collectPublic(DmpLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet); - long count(DmpLookup lookup, EnumSet authorizationFlags); + QueryResult collect(PlanLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet); + QueryResult collectPublic(PlanLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet); + long count(PlanLookup lookup, EnumSet authorizationFlags); QueryResult collect(DescriptionLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet); QueryResult collectPublic(DescriptionLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet); long count(DescriptionLookup lookup, EnumSet authorizationFlags); diff --git a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticQueryHelperServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticQueryHelperServiceImpl.java index 2054c2a7f..e71357b9c 100644 --- a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticQueryHelperServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticQueryHelperServiceImpl.java @@ -7,22 +7,22 @@ import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.data.DescriptionEntity; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import org.opencdmp.elastic.data.DescriptionElasticEntity; -import org.opencdmp.elastic.data.DmpElasticEntity; +import org.opencdmp.elastic.data.PlanElasticEntity; import org.opencdmp.model.PublicDescription; -import org.opencdmp.model.PublicDmp; +import org.opencdmp.model.PublicPlan; import org.opencdmp.model.builder.PublicDescriptionBuilder; -import org.opencdmp.model.builder.PublicDmpBuilder; +import org.opencdmp.model.builder.PublicPlanBuilder; import org.opencdmp.model.builder.description.DescriptionBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.result.QueryResult; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.opencdmp.query.lookup.DescriptionLookup; -import org.opencdmp.query.lookup.DmpLookup; +import org.opencdmp.query.lookup.PlanLookup; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -46,25 +46,25 @@ public class ElasticQueryHelperServiceImpl implements ElasticQueryHelperService } @Override - public QueryResult collect(DmpLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet) { + public QueryResult collect(PlanLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet) { EnumSet flags = authorizationFlags == null ? EnumSet.of(AuthorizationFlags.None) : authorizationFlags; - return this.collect(lookup, (d) -> this.builderFactory.builder(DmpBuilder.class).authorize(flags).build(fieldSet != null ? fieldSet : lookup.getProject(), d), flags); + return this.collect(lookup, (d) -> this.builderFactory.builder(PlanBuilder.class).authorize(flags).build(fieldSet != null ? fieldSet : lookup.getProject(), d), flags); } @Override - public QueryResult collectPublic(DmpLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet) { + public QueryResult collectPublic(PlanLookup lookup, EnumSet authorizationFlags, FieldSet fieldSet) { EnumSet flags = authorizationFlags == null ? EnumSet.of(AuthorizationFlags.None) : authorizationFlags; - return this.collect(lookup, (d) -> this.builderFactory.builder(PublicDmpBuilder.class).authorize(flags).build(fieldSet != null ? fieldSet : lookup.getProject(), d), flags); + return this.collect(lookup, (d) -> this.builderFactory.builder(PublicPlanBuilder.class).authorize(flags).build(fieldSet != null ? fieldSet : lookup.getProject(), d), flags); } - private QueryResult collect(DmpLookup lookup, Function, List> buildFunc, EnumSet flags) { - DmpQuery query = null; + private QueryResult collect(PlanLookup lookup, Function, List> buildFunc, EnumSet flags) { + PlanQuery query = null; QueryResult result = new QueryResult<>(); boolean elasticFilterUsed = false; if (lookup.useElastic() && this.elasticService.enabled()){ try { - List elasticResponse = lookup.enrichElastic(this.queryFactory).authorize(flags).collectAs(new BaseFieldSet().ensure(DmpElasticEntity._id)); - query = this.queryFactory.query(DmpQuery.class).authorize(flags).ids(elasticResponse.stream().map(DmpElasticEntity::getId).toList()); + List elasticResponse = lookup.enrichElastic(this.queryFactory).authorize(flags).collectAs(new BaseFieldSet().ensure(PlanElasticEntity._id)); + query = this.queryFactory.query(PlanQuery.class).authorize(flags).ids(elasticResponse.stream().map(PlanElasticEntity::getId).toList()); query.setOrder(lookup.enrich(this.queryFactory).getOrder()); if (lookup.getMetadata() != null && lookup.getMetadata().countAll) result.setCount(lookup.enrichElastic(this.queryFactory).authorize(flags).count()); elasticFilterUsed = true; @@ -89,7 +89,7 @@ public class ElasticQueryHelperServiceImpl implements ElasticQueryHelperService } @Override - public long count(DmpLookup lookup, EnumSet authorizationFlags) { + public long count(PlanLookup lookup, EnumSet authorizationFlags) { EnumSet flags = authorizationFlags == null ? EnumSet.of(AuthorizationFlags.None) : authorizationFlags; if (lookup.useElastic() && this.elasticService.enabled()){ try { diff --git a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticService.java b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticService.java index b60126f3c..a3fdfeaf8 100644 --- a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticService.java +++ b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticService.java @@ -1,36 +1,36 @@ package org.opencdmp.service.elastic; import org.opencdmp.data.DescriptionEntity; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import javax.management.InvalidApplicationException; import java.io.IOException; public interface ElasticService { boolean enabled(); - boolean existsDmpIndex() throws IOException; + boolean existsPlanIndex() throws IOException; boolean existsDescriptionIndex() throws IOException; - void ensureDmpIndex() throws IOException; + void ensurePlanIndex() throws IOException; void ensureDescriptionIndex() throws IOException; void ensureIndexes() throws IOException; - void persistDmp(DmpEntity dmp) throws IOException; + void persistPlan(PlanEntity dmp) throws IOException; - void deleteDmp(DmpEntity dmp) throws IOException; + void deletePlan(PlanEntity dmp) throws IOException; void persistDescription(DescriptionEntity description) throws IOException, InvalidApplicationException; void deleteDescription(DescriptionEntity description) throws IOException, InvalidApplicationException; - void deleteDmpIndex() throws IOException; + void deletePlanIndex() throws IOException; void deleteDescriptionIndex() throws IOException; - void resetDmpIndex() throws IOException, InvalidApplicationException; + void resetPlanIndex() throws IOException, InvalidApplicationException; void resetDescriptionIndex() throws IOException, InvalidApplicationException; } diff --git a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java index 73684f3ad..243456f13 100644 --- a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java @@ -17,18 +17,18 @@ import gr.cite.tools.logging.MapLogEntry; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.data.DescriptionEntity; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import org.opencdmp.data.TenantEntityManager; import org.opencdmp.elastic.data.DescriptionElasticEntity; -import org.opencdmp.elastic.data.DmpElasticEntity; +import org.opencdmp.elastic.data.PlanElasticEntity; import org.opencdmp.elastic.data.nested.*; import org.opencdmp.elastic.elasticbuilder.DescriptionElasticBuilder; -import org.opencdmp.elastic.elasticbuilder.DmpElasticBuilder; +import org.opencdmp.elastic.elasticbuilder.PlanElasticBuilder; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpQuery; -import org.opencdmp.service.dmpblueprint.DmpBlueprintServiceImpl; +import org.opencdmp.query.PlanQuery; +import org.opencdmp.service.planblueprint.PlanBlueprintServiceImpl; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -45,7 +45,7 @@ import java.util.Map; @Service public class ElasticServiceImpl implements ElasticService { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintServiceImpl.class)); public final AppElasticConfiguration appElasticConfiguration; private final ElasticsearchClient restHighLevelClient; private final ElasticsearchTemplate elasticsearchTemplate; @@ -72,7 +72,7 @@ public class ElasticServiceImpl implements ElasticService { } @Override - public boolean existsDmpIndex() throws IOException { + public boolean existsPlanIndex() throws IOException { if (!this.enabled()) return false; return this.restHighLevelClient.indices().exists(new ExistsRequest.Builder().index(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()).includeDefaults(true).build()).value(); } @@ -87,9 +87,9 @@ public class ElasticServiceImpl implements ElasticService { //region ensure index @Override - public void ensureDmpIndex() throws IOException { + public void ensurePlanIndex() throws IOException { if (!this.enabled()) return ; - boolean exists = this.existsDmpIndex(); + boolean exists = this.existsPlanIndex(); if (exists) return ; this.ensureIndex(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName(), this.createDmpTemplatePropertyMap()); @@ -107,7 +107,7 @@ public class ElasticServiceImpl implements ElasticService { public void ensureIndexes() throws IOException { if (!this.enabled()) return ; - this.ensureDmpIndex(); + this.ensurePlanIndex(); this.ensureDescriptionIndex(); } @@ -150,35 +150,35 @@ public class ElasticServiceImpl implements ElasticService { private Map createDmpTemplatePropertyMap(){ Map propertyMap = new HashMap<>(); - propertyMap.put(DmpElasticEntity._id, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(DmpElasticEntity._tenantId, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(DmpElasticEntity._label, this.createElastic(FieldType.Text, true)); - propertyMap.put(DmpElasticEntity._description, this.createElastic(FieldType.Text, false)); - propertyMap.put(DmpElasticEntity._status, this.createElastic(FieldType.Short, false)); - propertyMap.put(DmpElasticEntity._version, this.createElastic(FieldType.Short, false)); - propertyMap.put(DmpElasticEntity._language, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(DmpElasticEntity._blueprintId, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(DmpElasticEntity._accessType, this.createElastic(FieldType.Short, false)); - propertyMap.put(DmpElasticEntity._groupId, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(DmpElasticEntity._finalizedAt, this.createElastic(FieldType.Date, false)); - propertyMap.put(DmpElasticEntity._updatedAt, this.createElastic(FieldType.Date, false)); - propertyMap.put(DmpElasticEntity._createdAt, this.createElastic(FieldType.Date, false)); - propertyMap.put(DmpElasticEntity._versionStatus, this.createElastic(FieldType.Short, false)); + propertyMap.put(PlanElasticEntity._id, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(PlanElasticEntity._tenantId, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(PlanElasticEntity._label, this.createElastic(FieldType.Text, true)); + propertyMap.put(PlanElasticEntity._description, this.createElastic(FieldType.Text, false)); + propertyMap.put(PlanElasticEntity._status, this.createElastic(FieldType.Short, false)); + propertyMap.put(PlanElasticEntity._version, this.createElastic(FieldType.Short, false)); + propertyMap.put(PlanElasticEntity._language, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(PlanElasticEntity._blueprintId, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(PlanElasticEntity._accessType, this.createElastic(FieldType.Short, false)); + propertyMap.put(PlanElasticEntity._groupId, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(PlanElasticEntity._finalizedAt, this.createElastic(FieldType.Date, false)); + propertyMap.put(PlanElasticEntity._updatedAt, this.createElastic(FieldType.Date, false)); + propertyMap.put(PlanElasticEntity._createdAt, this.createElastic(FieldType.Date, false)); + propertyMap.put(PlanElasticEntity._versionStatus, this.createElastic(FieldType.Short, false)); - propertyMap.put(DmpElasticEntity._descriptions, new Property.Builder().nested(x -> x.properties(this.createNestedDescriptionTemplatePropertyMap())).build()); - propertyMap.put(DmpElasticEntity._dmpDescriptionTemplates, new Property.Builder().nested(x -> x.properties(this.createNestedDmpDescriptionTemplateElasticEntityPropertyMap())).build()); - propertyMap.put(DmpElasticEntity._references, new Property.Builder().nested(x -> x.properties(this.createNestedReferencesTemplatePropertyMap())).build()); - propertyMap.put(DmpElasticEntity._collaborators, new Property.Builder().nested(x -> x.properties(this.createNestedCollaboratorTemplatePropertyMap())).build()); - propertyMap.put(DmpElasticEntity._dois, new Property.Builder().nested(x -> x.properties(this.createNestedDoisTemplatePropertyMap())).build()); + propertyMap.put(PlanElasticEntity._descriptions, new Property.Builder().nested(x -> x.properties(this.createNestedDescriptionTemplatePropertyMap())).build()); + propertyMap.put(PlanElasticEntity._dmpDescriptionTemplates, new Property.Builder().nested(x -> x.properties(this.createNestedDmpDescriptionTemplateElasticEntityPropertyMap())).build()); + propertyMap.put(PlanElasticEntity._references, new Property.Builder().nested(x -> x.properties(this.createNestedReferencesTemplatePropertyMap())).build()); + propertyMap.put(PlanElasticEntity._collaborators, new Property.Builder().nested(x -> x.properties(this.createNestedCollaboratorTemplatePropertyMap())).build()); + propertyMap.put(PlanElasticEntity._dois, new Property.Builder().nested(x -> x.properties(this.createNestedDoisTemplatePropertyMap())).build()); return propertyMap; } private Map createNestedDmpDescriptionTemplateElasticEntityPropertyMap(){ Map propertyMap = new HashMap<>(); - propertyMap.put(NestedDmpDescriptionTemplateElasticEntity._id, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(NestedDmpDescriptionTemplateElasticEntity._descriptionTemplateGroupId, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(NestedDmpDescriptionTemplateElasticEntity._sectionId, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(NestedDmpDescriptionTemplateElasticEntity._dmpId, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(NestedPlanDescriptionTemplateElasticEntity._id, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(NestedPlanDescriptionTemplateElasticEntity._descriptionTemplateGroupId, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(NestedPlanDescriptionTemplateElasticEntity._sectionId, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(NestedPlanDescriptionTemplateElasticEntity._dmpId, this.createElastic(FieldType.Keyword, false)); return propertyMap; } @@ -227,21 +227,21 @@ public class ElasticServiceImpl implements ElasticService { private Map createNetsedDmpTemplatePropertyMap(){ Map propertyMap = new HashMap<>(); - propertyMap.put(NestedDmpElasticEntity._id, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(NestedDmpElasticEntity._label, this.createElastic(FieldType.Text, true)); - propertyMap.put(NestedDmpElasticEntity._description, this.createElastic(FieldType.Text, false)); - propertyMap.put(NestedDmpElasticEntity._status, this.createElastic(FieldType.Short, false)); - propertyMap.put(NestedDmpElasticEntity._version, this.createElastic(FieldType.Short, false)); - propertyMap.put(NestedDmpElasticEntity._versionStatus, this.createElastic(FieldType.Short, false)); - propertyMap.put(NestedDmpElasticEntity._language, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(NestedDmpElasticEntity._blueprintId, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(NestedDmpElasticEntity._accessType, this.createElastic(FieldType.Short, false)); - propertyMap.put(NestedDmpElasticEntity._groupId, this.createElastic(FieldType.Keyword, false)); - propertyMap.put(NestedDmpElasticEntity._finalizedAt, this.createElastic(FieldType.Date, false)); + propertyMap.put(NestedPlanElasticEntity._id, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(NestedPlanElasticEntity._label, this.createElastic(FieldType.Text, true)); + propertyMap.put(NestedPlanElasticEntity._description, this.createElastic(FieldType.Text, false)); + propertyMap.put(NestedPlanElasticEntity._status, this.createElastic(FieldType.Short, false)); + propertyMap.put(NestedPlanElasticEntity._version, this.createElastic(FieldType.Short, false)); + propertyMap.put(NestedPlanElasticEntity._versionStatus, this.createElastic(FieldType.Short, false)); + propertyMap.put(NestedPlanElasticEntity._language, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(NestedPlanElasticEntity._blueprintId, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(NestedPlanElasticEntity._accessType, this.createElastic(FieldType.Short, false)); + propertyMap.put(NestedPlanElasticEntity._groupId, this.createElastic(FieldType.Keyword, false)); + propertyMap.put(NestedPlanElasticEntity._finalizedAt, this.createElastic(FieldType.Date, false)); - propertyMap.put(NestedDmpElasticEntity._references, new Property.Builder().nested(x -> x.properties(this.createNestedReferencesTemplatePropertyMap())).build()); - propertyMap.put(NestedDmpElasticEntity._collaborators, new Property.Builder().nested(x -> x.properties(this.createNestedCollaboratorTemplatePropertyMap())).build()); - propertyMap.put(NestedDmpElasticEntity._dois, new Property.Builder().nested(x -> x.properties(this.createNestedDoisTemplatePropertyMap())).build()); + propertyMap.put(NestedPlanElasticEntity._references, new Property.Builder().nested(x -> x.properties(this.createNestedReferencesTemplatePropertyMap())).build()); + propertyMap.put(NestedPlanElasticEntity._collaborators, new Property.Builder().nested(x -> x.properties(this.createNestedCollaboratorTemplatePropertyMap())).build()); + propertyMap.put(NestedPlanElasticEntity._dois, new Property.Builder().nested(x -> x.properties(this.createNestedDoisTemplatePropertyMap())).build()); return propertyMap; } @@ -289,24 +289,24 @@ public class ElasticServiceImpl implements ElasticService { //region persist delete @Override - public void persistDmp(DmpEntity dmp) throws IOException { + public void persistPlan(PlanEntity dmp) throws IOException { if (!this.enabled()) return; this.ensureIndexes(); - DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmp); - this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); - List descriptions = this.builderFactory.builder(DescriptionElasticBuilder.class).build(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(this.queryFactory.query(DmpQuery.class).ids(dmp.getId())).collect()); + PlanElasticEntity planElasticEntity = this.builderFactory.builder(PlanElasticBuilder.class).build(dmp); + this.elasticsearchTemplate.save(planElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); + List descriptions = this.builderFactory.builder(DescriptionElasticBuilder.class).build(this.queryFactory.query(DescriptionQuery.class).disableTracking().isActive(IsActive.Active).dmpSubQuery(this.queryFactory.query(PlanQuery.class).ids(dmp.getId())).collect()); this.elasticsearchTemplate.save(descriptions, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName())); } @Override - public void deleteDmp(DmpEntity dmp) throws IOException { + public void deletePlan(PlanEntity dmp) throws IOException { if (!this.enabled()) return; this.ensureIndexes(); - DmpElasticEntity dmpElasticEntity = this.elasticsearchTemplate.get(dmp.getId().toString(),DmpElasticEntity.class, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); - if (dmpElasticEntity == null) return; - this.elasticsearchTemplate.delete(dmpElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); - List descriptions = this.queryFactory.query(DescriptionQuery.class).dmpSubQuery(this.queryFactory.query(DmpQuery.class).disableTracking().ids(dmp.getId())).collectAs(new BaseFieldSet().ensure(Description._id)); + PlanElasticEntity planElasticEntity = this.elasticsearchTemplate.get(dmp.getId().toString(), PlanElasticEntity.class, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); + if (planElasticEntity == null) return; + this.elasticsearchTemplate.delete(planElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); + List descriptions = this.queryFactory.query(DescriptionQuery.class).dmpSubQuery(this.queryFactory.query(PlanQuery.class).disableTracking().ids(dmp.getId())).collectAs(new BaseFieldSet().ensure(Description._id)); for (DescriptionEntity description: descriptions) { DescriptionElasticEntity descriptionElasticEntity = this.elasticsearchTemplate.get(description.getId().toString(), DescriptionElasticEntity.class, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName())); if (descriptionElasticEntity == null) continue; @@ -321,11 +321,11 @@ public class ElasticServiceImpl implements ElasticService { DescriptionElasticEntity descriptionElasticEntity = this.builderFactory.builder(DescriptionElasticBuilder.class).build(description); this.elasticsearchTemplate.save(descriptionElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName())); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId(), true); - if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if (dmpEntity.getIsActive().equals(IsActive.Active)) { - DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmpEntity); - this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); + PlanEntity planEntity = this.entityManager.find(PlanEntity.class, description.getPlanId(), true); + if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getPlanId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (planEntity.getIsActive().equals(IsActive.Active)) { + PlanElasticEntity planElasticEntity = this.builderFactory.builder(PlanElasticBuilder.class).build(planEntity); + this.elasticsearchTemplate.save(planElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); } } @@ -338,11 +338,11 @@ public class ElasticServiceImpl implements ElasticService { if (descriptionElasticEntity == null) return; this.elasticsearchTemplate.delete(descriptionElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDescriptionIndexName())); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId(), true); - if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if (dmpEntity.getIsActive().equals(IsActive.Active)) { - DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmpEntity); - this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); + PlanEntity planEntity = this.entityManager.find(PlanEntity.class, description.getPlanId(), true); + if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getPlanId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (planEntity.getIsActive().equals(IsActive.Active)) { + PlanElasticEntity planElasticEntity = this.builderFactory.builder(PlanElasticBuilder.class).build(planEntity); + this.elasticsearchTemplate.save(planElasticEntity, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); } } @@ -351,12 +351,12 @@ public class ElasticServiceImpl implements ElasticService { //region manage @Override - public void deleteDmpIndex() throws IOException { + public void deletePlanIndex() throws IOException { logger.debug(new MapLogEntry("delete dmp index")); this.authorizationService.authorizeForce(Permission.ManageElastic); if (!this.enabled()) return; - boolean exists = this.existsDmpIndex(); + boolean exists = this.existsPlanIndex(); if (!exists) return ; this.restHighLevelClient.indices().delete(new DeleteIndexRequest.Builder().index(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName()).build()); @@ -374,27 +374,27 @@ public class ElasticServiceImpl implements ElasticService { } @Override - public void resetDmpIndex() throws IOException, InvalidApplicationException { + public void resetPlanIndex() throws IOException, InvalidApplicationException { logger.debug(new MapLogEntry("reset dmp index")); this.authorizationService.authorizeForce(Permission.ManageElastic); if (!this.enabled()) return; - this.deleteDmpIndex(); - this.ensureDmpIndex(); + this.deletePlanIndex(); + this.ensurePlanIndex(); try { this.entityManager.disableTenantFilters(); int page = 0; int pageSize = this.appElasticConfiguration.getAppElasticProperties().getResetBatchSize(); - List items; + List items; do { - DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking(); - query.setOrder(new Ordering().addAscending(Dmp._createdAt)); + PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking(); + query.setOrder(new Ordering().addAscending(Plan._createdAt)); query.setPage(new Paging(page * pageSize, pageSize)); items = query.collect(); if (items != null && !items.isEmpty()) { - List elasticEntities = this.builderFactory.builder(DmpElasticBuilder.class).build(items); + List elasticEntities = this.builderFactory.builder(PlanElasticBuilder.class).build(items); this.elasticsearchTemplate.save(elasticEntities, IndexCoordinates.of(this.appElasticConfiguration.getAppElasticProperties().getDmpIndexName())); page++; } diff --git a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerService.java b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerService.java index d86214fb7..d7a66e98c 100644 --- a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerService.java +++ b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerService.java @@ -4,7 +4,7 @@ import jakarta.xml.bind.JAXBException; import org.opencdmp.commonmodels.models.dmp.DmpModel; import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel; import org.opencdmp.model.file.RepositoryFileFormat; -import org.opencdmp.model.persist.DmpCommonModelConfig; +import org.opencdmp.model.persist.PlanCommonModelConfig; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; @@ -24,7 +24,7 @@ public interface FileTransformerService { org.opencdmp.model.file.FileEnvelope exportDescription(UUID descriptionId, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException; - DmpModel importDmp(DmpCommonModelConfig dmpCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException; + DmpModel importDmp(PlanCommonModelConfig planCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException; PreprocessingDmpModel preprocessingDmp(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException; } diff --git a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java index a3a268a07..bfdff979f 100644 --- a/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/filetransformer/FileTransformerServiceImpl.java @@ -41,14 +41,14 @@ import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel; import org.opencdmp.model.StorageFile; import org.opencdmp.model.builder.commonmodels.description.DescriptionCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.descriptiontemplate.DescriptionTemplateCommonModelBuilder; -import org.opencdmp.model.builder.commonmodels.dmp.DmpCommonModelBuilder; -import org.opencdmp.model.builder.commonmodels.dmpblueprint.DmpBlueprintCommonModelBuilder; +import org.opencdmp.model.builder.commonmodels.plan.PlanCommonModelBuilder; +import org.opencdmp.model.builder.commonmodels.planblueprint.PlanBlueprintCommonModelBuilder; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.planblueprint.PlanBlueprint; import org.opencdmp.model.file.RepositoryFileFormat; import org.opencdmp.model.persist.DescriptionCommonModelConfig; -import org.opencdmp.model.persist.DmpCommonModelConfig; +import org.opencdmp.model.persist.PlanCommonModelConfig; import org.opencdmp.model.persist.StorageFilePersist; import org.opencdmp.model.tenantconfiguration.TenantConfiguration; import org.opencdmp.query.*; @@ -253,14 +253,14 @@ public class FileTransformerServiceImpl implements FileTransformerService { @Override public org.opencdmp.model.file.FileEnvelope exportDmp(UUID dmpId, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { - this.authorizationService.authorizeForce(Permission.ExportDmp); + this.authorizationService.authorizeForce(Permission.ExportPlan); //GK: First get the right client FileTransformerRepository repository = this.getRepository(repositoryId); if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); //GK: Second get the Target Data Management Plan - DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(dmpId); - DmpModel dmpFileTransformerModel = this.builderFactory.builder(DmpCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.AllExceptPublic).build(query.first()); - if (dmpFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpId, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(dmpId); + DmpModel dmpFileTransformerModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.AllExceptPublic).build(query.first()); + if (dmpFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpId, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); FileEnvelopeModel fileEnvelope = repository.exportDmp(dmpFileTransformerModel, format); org.opencdmp.model.file.FileEnvelope result = new org.opencdmp.model.file.FileEnvelope(); @@ -313,31 +313,31 @@ public class FileTransformerServiceImpl implements FileTransformerService { } @Override - public DmpModel importDmp(DmpCommonModelConfig dmpCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException { - this.authorizationService.authorizeForce(Permission.NewDmp); + public DmpModel importDmp(PlanCommonModelConfig planCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException { + this.authorizationService.authorizeForce(Permission.NewPlan); - StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(dmpCommonModelConfig.getFileId()).first(); + StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getFileId()).first(); - if (tempFile == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpCommonModelConfig.getFileId(), StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (tempFile == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getFileId(), StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale())); //GK: First get the right client - FileTransformerRepository repository = this.getRepository(dmpCommonModelConfig.getRepositoryId()); - if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpCommonModelConfig.getRepositoryId(), FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); + FileTransformerRepository repository = this.getRepository(planCommonModelConfig.getRepositoryId()); + if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getRepositoryId(), FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpBlueprintQuery dmpBlueprintQuery = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(dmpCommonModelConfig.getBlueprintId()); - DmpBlueprintModel dmpBlueprintModel = this.builderFactory.builder(DmpBlueprintCommonModelBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(dmpBlueprintQuery.first()); - if (dmpBlueprintModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpCommonModelConfig.getBlueprintId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanBlueprintQuery planBlueprintQuery = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getBlueprintId()); + DmpBlueprintModel dmpBlueprintModel = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(planBlueprintQuery.first()); + if (dmpBlueprintModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); DmpImportModel dmpImportModel = new DmpImportModel(); dmpImportModel.setBlueprintModel(dmpBlueprintModel); - if (!this.conventionService.isListNullOrEmpty(dmpCommonModelConfig.getDescriptions())){ - List descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(dmpCommonModelConfig.getDescriptions().stream().map(x -> x.getTemplateId()).distinct().collect(Collectors.toList())).collect(); + if (!this.conventionService.isListNullOrEmpty(planCommonModelConfig.getDescriptions())){ + List descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getDescriptions().stream().map(x -> x.getTemplateId()).distinct().collect(Collectors.toList())).collect(); if (descriptionTemplateEntities == null) throw new MyApplicationException("Description Templates Not Exist!"); List descriptionImportModels = new ArrayList<>(); - for (DescriptionCommonModelConfig descriptionCommonModelConfig : dmpCommonModelConfig.getDescriptions()) { + for (DescriptionCommonModelConfig descriptionCommonModelConfig : planCommonModelConfig.getDescriptions()) { DescriptionTemplateEntity descriptionTemplateEntity = descriptionTemplateEntities.stream().filter(x -> x.getId().equals(descriptionCommonModelConfig.getTemplateId())).findFirst().orElse(null); if (descriptionTemplateEntity != null){ DescriptionTemplateModel descriptionTemplateModel = this.builderFactory.builder(DescriptionTemplateCommonModelBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(descriptionTemplateEntity); @@ -358,7 +358,7 @@ public class FileTransformerServiceImpl implements FileTransformerService { String mimeType = URLConnection.guessContentTypeFromName(originalFileName); FileEnvelopeModel fileEnvelope = new FileEnvelopeModel(); - fileEnvelope.setFile(this.storageFileService.readAsBytesSafe(dmpCommonModelConfig.getFileId())); + fileEnvelope.setFile(this.storageFileService.readAsBytesSafe(planCommonModelConfig.getFileId())); fileEnvelope.setMimeType(mimeType); fileEnvelope.setFilename(originalFileName); @@ -381,7 +381,7 @@ public class FileTransformerServiceImpl implements FileTransformerService { @Override public PreprocessingDmpModel preprocessingDmp(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException { - this.authorizationService.authorizeForce(Permission.NewDmp); + this.authorizationService.authorizeForce(Permission.NewPlan); StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(fileId).first(); diff --git a/backend/core/src/main/java/org/opencdmp/service/language/LanguageServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/language/LanguageServiceImpl.java index e4e0931d4..b82fdcd79 100644 --- a/backend/core/src/main/java/org/opencdmp/service/language/LanguageServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/language/LanguageServiceImpl.java @@ -22,7 +22,7 @@ import org.opencdmp.model.Language; import org.opencdmp.model.builder.LanguageBuilder; import org.opencdmp.model.deleter.LanguageDeleter; import org.opencdmp.model.persist.LanguagePersist; -import org.opencdmp.service.dmpblueprint.DmpBlueprintServiceImpl; +import org.opencdmp.service.planblueprint.PlanBlueprintServiceImpl; import org.opencdmp.service.storage.StorageFileService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; @@ -39,7 +39,7 @@ import java.util.UUID; @Service public class LanguageServiceImpl implements LanguageService { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintServiceImpl.class)); private final TenantEntityManager entityManager; private final AuthorizationService authorizationService; private final DeleterFactory deleterFactory; diff --git a/backend/core/src/main/java/org/opencdmp/service/maintenance/MaintenanceServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/maintenance/MaintenanceServiceImpl.java index 5ddaf7cdb..8d39f5daf 100644 --- a/backend/core/src/main/java/org/opencdmp/service/maintenance/MaintenanceServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/maintenance/MaintenanceServiceImpl.java @@ -17,10 +17,10 @@ import org.opencdmp.integrationevent.outbox.userremoval.UserRemovalIntegrationEv import org.opencdmp.integrationevent.outbox.usertouched.UserTouchedIntegrationEventHandler; import org.opencdmp.model.Tenant; import org.opencdmp.model.description.Description; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.user.User; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.opencdmp.query.TenantQuery; import org.opencdmp.query.UserQuery; import org.slf4j.LoggerFactory; @@ -141,9 +141,9 @@ public class MaintenanceServiceImpl implements MaintenanceService { private void sendTenantDmpTouchEvents(UUID tenantId, String tenantCode) throws InvalidApplicationException { try { this.tenantScope.setTempTenant(this.entityManager, tenantId, tenantCode); - List items = this.queryFactory.query(DmpQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(Dmp._id).ensure(Dmp._isActive)); - for (DmpEntity item : items) { - if (item.getIsActive().equals(IsActive.Active)) this.annotationEntityTouchedIntegrationEventHandler.handleDmp(item.getId()); + List items = this.queryFactory.query(PlanQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(Plan._id).ensure(Plan._isActive)); + for (PlanEntity item : items) { + if (item.getIsActive().equals(IsActive.Active)) this.annotationEntityTouchedIntegrationEventHandler.handlePlan(item.getId()); else this.annotationEntityRemovalIntegrationEventHandler.handleDmp(item.getId()); } } finally { diff --git a/backend/core/src/main/java/org/opencdmp/service/metrics/MetricsServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/metrics/MetricsServiceImpl.java index c658c5a2c..d06127c3d 100644 --- a/backend/core/src/main/java/org/opencdmp/service/metrics/MetricsServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/metrics/MetricsServiceImpl.java @@ -8,7 +8,7 @@ import io.prometheus.client.Gauge; import org.opencdmp.commons.enums.*; import org.opencdmp.commons.metrics.MetricLabels; import org.opencdmp.commons.metrics.MetricNames; -import org.opencdmp.data.DmpDescriptionTemplateEntity; +import org.opencdmp.data.PlanDescriptionTemplateEntity; import org.opencdmp.data.TenantEntityManager; import org.opencdmp.query.*; import org.opencdmp.service.keycloak.MyKeycloakAdminRestApi; @@ -325,76 +325,76 @@ public class MetricsServiceImpl implements MetricsService { } private double calculateDraftDmps(boolean forNexus) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().statuses(DmpStatus.Draft).isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().statuses(PlanStatus.Draft).isActive(IsActive.Active); if (forNexus) - dmpQuery.after(this._config.getNexusDate()); - return dmpQuery.count(); + planQuery.after(this._config.getNexusDate()); + return planQuery.count(); } private double calculateFinalizedDmps(boolean forNexus) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().statuses(DmpStatus.Finalized).isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().statuses(PlanStatus.Finalized).isActive(IsActive.Active); if (forNexus) - dmpQuery.after(this._config.getNexusDate()); - return dmpQuery.count(); + planQuery.after(this._config.getNexusDate()); + return planQuery.count(); } private double calculatePublishedDmps(boolean forNexus) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public).isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().statuses(PlanStatus.Finalized).accessTypes(PlanAccessType.Public).isActive(IsActive.Active); if (forNexus) - dmpQuery.after(this._config.getNexusDate()); - return dmpQuery.count(); + planQuery.after(this._config.getNexusDate()); + return planQuery.count(); } private double calculateDoiedDmps(boolean forNexus) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().isActive(IsActive.Active); if (forNexus) - dmpQuery.after(this._config.getNexusDate()); + planQuery.after(this._config.getNexusDate()); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().types(EntityType.DMP).isActive(IsActive.Active); - dmpQuery.entityDoiSubQuery(entityDoiQuery); - dmpQuery.setDistinct(true); - return dmpQuery.count(); + planQuery.entityDoiSubQuery(entityDoiQuery); + planQuery.setDistinct(true); + return planQuery.count(); } private double calculateDraftDmpsWithGrant(boolean forNexus) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).statuses(DmpStatus.Draft).disableTracking().isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).statuses(PlanStatus.Draft).disableTracking().isActive(IsActive.Active); if (forNexus) - dmpQuery.after(this._config.getNexusDate()); + planQuery.after(this._config.getNexusDate()); ReferenceQuery referenceQuery = this.queryFactory.query(ReferenceQuery.class).disableTracking().typeIds(this._config.getReferenceTypes().getGrantIds()).isActive(IsActive.Active); - DmpReferenceQuery dmpReferenceQuery = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().referenceSubQuery(referenceQuery).isActives(IsActive.Active); - dmpQuery.dmpReferenceSubQuery(dmpReferenceQuery); - return dmpQuery.count(); + PlanReferenceQuery planReferenceQuery = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().referenceSubQuery(referenceQuery).isActives(IsActive.Active); + planQuery.planReferenceSubQuery(planReferenceQuery); + return planQuery.count(); } private double calculateFinalizedDmpsWithGrant(boolean forNexus) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().statuses(DmpStatus.Finalized).isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().statuses(PlanStatus.Finalized).isActive(IsActive.Active); if (forNexus) - dmpQuery.after(this._config.getNexusDate()); + planQuery.after(this._config.getNexusDate()); ReferenceQuery referenceQuery = this.queryFactory.query(ReferenceQuery.class).disableTracking().typeIds(this._config.getReferenceTypes().getGrantIds()).isActive(IsActive.Active); - DmpReferenceQuery dmpReferenceQuery = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().referenceSubQuery(referenceQuery).isActives(IsActive.Active); - dmpQuery.dmpReferenceSubQuery(dmpReferenceQuery); - return dmpQuery.count(); + PlanReferenceQuery planReferenceQuery = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().referenceSubQuery(referenceQuery).isActives(IsActive.Active); + planQuery.planReferenceSubQuery(planReferenceQuery); + return planQuery.count(); } private double calculatePublishedDmpsWithGrant(boolean forNexus) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).statuses(DmpStatus.Finalized).disableTracking().accessTypes(DmpAccessType.Public).isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).statuses(PlanStatus.Finalized).disableTracking().accessTypes(PlanAccessType.Public).isActive(IsActive.Active); if (forNexus) - dmpQuery.after(this._config.getNexusDate()); + planQuery.after(this._config.getNexusDate()); ReferenceQuery referenceQuery = this.queryFactory.query(ReferenceQuery.class).disableTracking().typeIds(this._config.getReferenceTypes().getGrantIds()).isActive(IsActive.Active); - DmpReferenceQuery dmpReferenceQuery = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().referenceSubQuery(referenceQuery).isActives(IsActive.Active); - dmpQuery.dmpReferenceSubQuery(dmpReferenceQuery); - return dmpQuery.count(); + PlanReferenceQuery planReferenceQuery = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().referenceSubQuery(referenceQuery).isActives(IsActive.Active); + planQuery.planReferenceSubQuery(planReferenceQuery); + return planQuery.count(); } private double calculateDoiedDmpsWithGrant(boolean forNexus) { - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().isActive(IsActive.Active); if (forNexus) - dmpQuery.after(this._config.getNexusDate()); + planQuery.after(this._config.getNexusDate()); ReferenceQuery referenceQuery = this.queryFactory.query(ReferenceQuery.class).disableTracking().typeIds(this._config.getReferenceTypes().getGrantIds()).isActive(IsActive.Active); - DmpReferenceQuery dmpReferenceQuery = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().referenceSubQuery(referenceQuery).isActives(IsActive.Active); - dmpQuery.dmpReferenceSubQuery(dmpReferenceQuery); + PlanReferenceQuery planReferenceQuery = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().referenceSubQuery(referenceQuery).isActives(IsActive.Active); + planQuery.planReferenceSubQuery(planReferenceQuery); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().isActive(IsActive.Active); - dmpQuery.entityDoiSubQuery(entityDoiQuery); - return dmpQuery.count(); + planQuery.entityDoiSubQuery(entityDoiQuery); + return planQuery.count(); } private double calculateAllFunders(boolean forNexus) { @@ -443,8 +443,8 @@ public class MetricsServiceImpl implements MetricsService { DescriptionQuery descriptionQuery = this.queryFactory.query(DescriptionQuery.class).disableTracking().statuses(DescriptionStatus.Finalized).isActive(IsActive.Active); if (forNexus) descriptionQuery.createdAfter(this._config.getNexusDate()); - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).disableTracking().statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public); - descriptionQuery.dmpSubQuery(dmpQuery); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).isActive(IsActive.Active).disableTracking().statuses(PlanStatus.Finalized).accessTypes(PlanAccessType.Public); + descriptionQuery.dmpSubQuery(planQuery); return descriptionQuery.count(); } @@ -452,10 +452,10 @@ public class MetricsServiceImpl implements MetricsService { DescriptionQuery descriptionQuery = this.queryFactory.query(DescriptionQuery.class).disableTracking().statuses(DescriptionStatus.Finalized).isActive(IsActive.Active); if (forNexus) descriptionQuery.createdAfter(this._config.getNexusDate()); - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).isActive(IsActive.Active); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).types(EntityType.DMP).isActive(IsActive.Active); - dmpQuery.entityDoiSubQuery(entityDoiQuery); - descriptionQuery.dmpSubQuery(dmpQuery); + planQuery.entityDoiSubQuery(entityDoiQuery); + descriptionQuery.dmpSubQuery(planQuery); descriptionQuery.setDistinct(true); return descriptionQuery.count(); } @@ -475,13 +475,13 @@ public class MetricsServiceImpl implements MetricsService { } private double calculateUsedTemplates(boolean forNexus) { - DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active); - dmpDescriptionTemplateQuery.setDistinct(true); + PlanDescriptionTemplateQuery planDescriptionTemplateQuery = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active); + planDescriptionTemplateQuery.setDistinct(true); if (forNexus) { DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).after(this._config.getNexusDate()); - dmpDescriptionTemplateQuery.descriptionTemplateSubQuery(descriptionTemplateQuery); + planDescriptionTemplateQuery.descriptionTemplateSubQuery(descriptionTemplateQuery); } - return dmpDescriptionTemplateQuery.collectAs(new BaseFieldSet().ensure(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)).size(); + return planDescriptionTemplateQuery.collectAs(new BaseFieldSet().ensure(PlanDescriptionTemplateEntity._descriptionTemplateGroupId)).size(); } private double calculateActiveUsers() { diff --git a/backend/core/src/main/java/org/opencdmp/service/plan/PlanService.java b/backend/core/src/main/java/org/opencdmp/service/plan/PlanService.java new file mode 100644 index 000000000..1c4932542 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/service/plan/PlanService.java @@ -0,0 +1,65 @@ +package org.opencdmp.service.plan; + +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.FieldSet; +import jakarta.xml.bind.JAXBException; +import org.opencdmp.commons.types.plan.importexport.PlanImportExport; +import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel; +import org.opencdmp.model.PlanUser; +import org.opencdmp.model.PlanValidationResult; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.persist.*; +import org.springframework.http.ResponseEntity; +import org.xml.sax.SAXException; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.management.InvalidApplicationException; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import java.io.IOException; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.List; +import java.util.UUID; + +public interface PlanService { + + Plan persist(PlanPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, IOException; + + void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException, IOException; + + void finalize(UUID id, List descriptionIds) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException; + + void undoFinalize(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException; + + PlanValidationResult validate(UUID id) throws InvalidApplicationException; + + Plan createNewVersion(NewVersionPlanPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, TransformerException; + + Plan buildClone(ClonePlanPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException; + + List assignUsers(UUID dmp, List model, FieldSet fields, boolean disableDelete) throws InvalidApplicationException, IOException; + Plan removeUser(PlanUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException; + + ResponseEntity export(UUID id, String transformerId, String exportType) throws InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException; + + void inviteUserOrAssignUsers(UUID id, List users) throws InvalidApplicationException, JAXBException, IOException; + + void planInvitationAccept(String token) throws InvalidApplicationException, IOException; + + PlanImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException; + + ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException; + + Plan importXml(byte[] bytes, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; + + Plan importJson(PlanCommonModelConfig planCommonModelConfig, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException; + + PreprocessingDmpModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException; +} diff --git a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java similarity index 55% rename from backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java rename to backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java index ce5c06de0..f09868517 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java @@ -1,4 +1,4 @@ -package org.opencdmp.service.dmp; +package org.opencdmp.service.plan; import com.fasterxml.jackson.core.JsonProcessingException; import gr.cite.commons.web.authz.service.AuthorizationService; @@ -42,51 +42,51 @@ import org.opencdmp.commons.enums.notification.NotificationContactType; import org.opencdmp.commons.notification.NotificationProperties; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.commons.types.actionconfirmation.DmpInvitationEntity; +import org.opencdmp.commons.types.actionconfirmation.PlanInvitationEntity; import org.opencdmp.commons.types.description.importexport.DescriptionImportExport; -import org.opencdmp.commons.types.dmp.DmpBlueprintValueEntity; -import org.opencdmp.commons.types.dmp.DmpContactEntity; -import org.opencdmp.commons.types.dmp.DmpPropertiesEntity; -import org.opencdmp.commons.types.dmp.importexport.*; -import org.opencdmp.commons.types.dmpblueprint.DescriptionTemplateEntity; -import org.opencdmp.commons.types.dmpblueprint.ExtraFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.ReferenceTypeFieldEntity; -import org.opencdmp.commons.types.dmpblueprint.SectionEntity; -import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintExtraFieldImportExport; -import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintReferenceTypeFieldImportExport; -import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintSectionImportExport; -import org.opencdmp.commons.types.dmpreference.DmpReferenceDataEntity; +import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity; +import org.opencdmp.commons.types.plan.PlanContactEntity; +import org.opencdmp.commons.types.plan.PlanPropertiesEntity; +import org.opencdmp.commons.types.plan.importexport.*; +import org.opencdmp.commons.types.planblueprint.DescriptionTemplateEntity; +import org.opencdmp.commons.types.planblueprint.ExtraFieldEntity; +import org.opencdmp.commons.types.planblueprint.ReferenceTypeFieldEntity; +import org.opencdmp.commons.types.planblueprint.SectionEntity; +import org.opencdmp.commons.types.planblueprint.importexport.BlueprintExtraFieldImportExport; +import org.opencdmp.commons.types.planblueprint.importexport.BlueprintReferenceTypeFieldImportExport; +import org.opencdmp.commons.types.planblueprint.importexport.BlueprintSectionImportExport; +import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity; import org.opencdmp.commons.types.notification.*; import org.opencdmp.commons.types.reference.DefinitionEntity; import org.opencdmp.commons.types.reference.FieldEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.*; import org.opencdmp.errorcode.ErrorThesaurusProperties; -import org.opencdmp.event.DmpTouchedEvent; +import org.opencdmp.event.PlanTouchedEvent; import org.opencdmp.event.EventBroker; import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel; import org.opencdmp.integrationevent.outbox.annotationentityremoval.AnnotationEntityRemovalIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent; import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventHandler; -import org.opencdmp.model.DmpUser; -import org.opencdmp.model.DmpValidationResult; -import org.opencdmp.model.builder.DmpUserBuilder; +import org.opencdmp.model.PlanUser; +import org.opencdmp.model.PlanValidationResult; +import org.opencdmp.model.builder.PlanUserBuilder; import org.opencdmp.model.builder.description.DescriptionBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; import org.opencdmp.model.deleter.*; import org.opencdmp.model.description.Description; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.model.dmpreference.DmpReferenceData; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.planblueprint.PlanBlueprint; +import org.opencdmp.model.planreference.PlanReferenceData; import org.opencdmp.model.file.FileEnvelope; import org.opencdmp.model.persist.*; -import org.opencdmp.model.persist.actionconfirmation.DmpInvitationPersist; -import org.opencdmp.model.persist.dmpproperties.DmpBlueprintValuePersist; -import org.opencdmp.model.persist.dmpproperties.DmpContactPersist; -import org.opencdmp.model.persist.dmpproperties.DmpPropertiesPersist; -import org.opencdmp.model.persist.dmpreference.DmpReferenceDataPersist; +import org.opencdmp.model.persist.actionconfirmation.PlanInvitationPersist; +import org.opencdmp.model.persist.planproperties.PlanBlueprintValuePersist; +import org.opencdmp.model.persist.planproperties.PlanContactPersist; +import org.opencdmp.model.persist.planproperties.PlanPropertiesPersist; +import org.opencdmp.model.persist.planreference.PlanReferenceDataPersist; import org.opencdmp.model.persist.referencedefinition.DefinitionPersist; import org.opencdmp.model.persist.referencedefinition.FieldPersist; import org.opencdmp.model.reference.Reference; @@ -95,7 +95,7 @@ import org.opencdmp.query.*; import org.opencdmp.service.actionconfirmation.ActionConfirmationService; import org.opencdmp.service.description.DescriptionService; import org.opencdmp.service.descriptiontemplate.DescriptionTemplateService; -import org.opencdmp.service.dmpblueprint.DmpBlueprintService; +import org.opencdmp.service.planblueprint.PlanBlueprintService; import org.opencdmp.service.elastic.ElasticService; import org.opencdmp.service.filetransformer.FileTransformerService; import org.opencdmp.service.responseutils.ResponseUtilsService; @@ -126,9 +126,9 @@ import java.util.*; import java.util.stream.Collectors; @Service -public class DmpServiceImpl implements DmpService { +public class PlanServiceImpl implements PlanService { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpServiceImpl.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanServiceImpl.class)); private final TenantEntityManager entityManager; @@ -174,10 +174,10 @@ public class DmpServiceImpl implements DmpService { private final AuthorizationContentResolver authorizationContentResolver; private final TenantScope tenantScope; private final ResponseUtilsService responseUtilsService; - private final DmpBlueprintService dmpBlueprintService; + private final PlanBlueprintService planBlueprintService; @Autowired - public DmpServiceImpl( + public PlanServiceImpl( TenantEntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, @@ -197,7 +197,7 @@ public class DmpServiceImpl implements DmpService { FileTransformerService fileTransformerService, ValidatorFactory validatorFactory, ElasticService elasticService, DescriptionTemplateService descriptionTemplateService, - AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler, AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope, ResponseUtilsService responseUtilsService, DmpBlueprintService dmpBlueprintService) { + AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler, AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope, ResponseUtilsService responseUtilsService, PlanBlueprintService planBlueprintService) { this.entityManager = entityManager; this.authorizationService = authorizationService; this.deleterFactory = deleterFactory; @@ -223,23 +223,23 @@ public class DmpServiceImpl implements DmpService { this.authorizationContentResolver = authorizationContentResolver; this.tenantScope = tenantScope; this.responseUtilsService = responseUtilsService; - this.dmpBlueprintService = dmpBlueprintService; + this.planBlueprintService = planBlueprintService; } - public Dmp persist(DmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, IOException { + public Plan persist(PlanPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, IOException { Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); - if (isUpdate) this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(model.getId())), Permission.EditDmp); - else this.authorizationService.authorizeForce(Permission.NewDmp); + if (isUpdate) this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(model.getId())), Permission.EditPlan); + else this.authorizationService.authorizeForce(Permission.NewPlan); - DmpEntity data = this.patchAndSave(model); + PlanEntity data = this.patchAndSave(model); - DmpBlueprintEntity blueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, data.getBlueprintId(), true); - if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); - org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, blueprintEntity.getDefinition()); - if (definition == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanBlueprintEntity blueprintEntity = this.entityManager.find(PlanBlueprintEntity.class, data.getBlueprintId(), true); + if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, blueprintEntity.getDefinition()); + if (definition == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), org.opencdmp.commons.types.planblueprint.DefinitionEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); - this.patchAndSaveReferences(this.buildDmpReferencePersists(model.getProperties()), data.getId(), definition); + this.patchAndSaveReferences(this.buildPlanReferencePersists(model.getProperties()), data.getId(), definition); if (isUpdate) this.checkIfDescriptionTemplateIsUse(model.getDescriptionTemplates(), model.getId()); @@ -248,55 +248,55 @@ public class DmpServiceImpl implements DmpService { if (!isUpdate && this.userScope.isSet()) { this.addOwner(data); if (model.getUsers() == null) model.setUsers(new ArrayList<>()); - if (model.getUsers().stream().noneMatch(x-> x.getUser() != null && x.getUser().equals(this.userScope.getUserIdSafe()) && DmpUserRole.Owner.equals(x.getRole()))) model.getUsers().add(this.createOwnerPersist()); + if (model.getUsers().stream().noneMatch(x-> x.getUser() != null && x.getUser().equals(this.userScope.getUserIdSafe()) && PlanUserRole.Owner.equals(x.getRole()))) model.getUsers().add(this.createOwnerPersist()); } - this.eventBroker.emit(new DmpTouchedEvent(data.getId())); + this.eventBroker.emit(new PlanTouchedEvent(data.getId())); this.sendNotification(data); this.assignUsers(data.getId(), this.inviteUserOrAssignUsers(data.getId(), model.getUsers(), false), null, false); - this.elasticService.persistDmp(data); + this.elasticService.persistPlan(data); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(data.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(data.getId()); - return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data); + return this.builderFactory.builder(PlanBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fields, Plan._id, Plan._hash), data); } - private void checkIfDescriptionTemplateIsUse (List descriptionTemplates, UUID id){ - List existingDmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).dmpIds(id).isActive(IsActive.Active).collect(); + private void checkIfDescriptionTemplateIsUse (List descriptionTemplates, UUID id){ + List existingDmpDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(id).isActive(IsActive.Active).collect(); - List removedDescriptionTemplates = existingDmpDescriptionTemplates.stream().filter(x -> descriptionTemplates.stream().noneMatch(y -> y.getDescriptionTemplateGroupId().equals(x.getDescriptionTemplateGroupId()))).toList(); - DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).dmpIds(id).descriptionTemplateGroupIds(removedDescriptionTemplates.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).collect(Collectors.toList())); - DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).dmpDescriptionTemplateSubQuery(dmpDescriptionTemplateQuery).isActive(IsActive.Active); + List removedDescriptionTemplates = existingDmpDescriptionTemplates.stream().filter(x -> descriptionTemplates.stream().noneMatch(y -> y.getDescriptionTemplateGroupId().equals(x.getDescriptionTemplateGroupId()))).toList(); + PlanDescriptionTemplateQuery planDescriptionTemplateQuery = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).planIds(id).descriptionTemplateGroupIds(removedDescriptionTemplates.stream().map(PlanDescriptionTemplateEntity::getDescriptionTemplateGroupId).collect(Collectors.toList())); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).dmpDescriptionTemplateSubQuery(planDescriptionTemplateQuery).isActive(IsActive.Active); if (query != null && query.count() > 0) throw new MyValidationException(this.errors.getDmpDescriptionTemplateCanNotRemove().getCode(), this.errors.getDmpDescriptionTemplateCanNotRemove().getMessage()); } - private DmpUserPersist createOwnerPersist() { - DmpUserPersist persist = new DmpUserPersist(); - persist.setRole(DmpUserRole.Owner); + private PlanUserPersist createOwnerPersist() { + PlanUserPersist persist = new PlanUserPersist(); + persist.setRole(PlanUserRole.Owner); persist.setUser(this.userScope.getUserIdSafe()); return persist; } - private void addOwner(DmpEntity dmpEntity) throws InvalidApplicationException { - DmpUserEntity data = new DmpUserEntity(); + private void addOwner(PlanEntity planEntity) throws InvalidApplicationException { + PlanUserEntity data = new PlanUserEntity(); data.setId(UUID.randomUUID()); data.setIsActive(IsActive.Active); data.setCreatedAt(Instant.now()); data.setUpdatedAt(Instant.now()); - data.setRole(DmpUserRole.Owner); + data.setRole(PlanUserRole.Owner); data.setUserId(this.userScope.getUserId()); - data.setDmpId(dmpEntity.getId()); + data.setPlanId(planEntity.getId()); this.entityManager.persist(data); } - private void sendNotification(DmpEntity dmp) throws InvalidApplicationException { - List existingUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking() - .dmpIds(dmp.getId()) + private void sendNotification(PlanEntity dmp) throws InvalidApplicationException { + List existingUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking() + .planIds(dmp.getId()) .isActives(IsActive.Active) .collect(); @@ -304,7 +304,7 @@ public class DmpServiceImpl implements DmpService { return; } - for (DmpUserEntity dmpUser : existingUsers) { + for (PlanUserEntity dmpUser : existingUsers) { if (!dmpUser.getUserId().equals(this.userScope.getUserIdSafe())){ UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpUser.getUserId()).first(); if (user == null || user.getIsActive().equals(IsActive.Inactive)) throw new MyValidationException(this.errors.getDmpInactiveUser().getCode(), this.errors.getDmpInactiveUser().getMessage()); @@ -313,7 +313,7 @@ public class DmpServiceImpl implements DmpService { } } - private void createDmpNotificationEvent(DmpEntity dmp, UserEntity user) throws InvalidApplicationException { + private void createDmpNotificationEvent(PlanEntity dmp, UserEntity user) throws InvalidApplicationException { NotifyIntegrationEvent event = new NotifyIntegrationEvent(); event.setUserId(user.getId()); @@ -333,7 +333,7 @@ public class DmpServiceImpl implements DmpService { this.eventHandler.handle(event); } - private void applyNotificationType(DmpStatus status, NotifyIntegrationEvent event) { + private void applyNotificationType(PlanStatus status, NotifyIntegrationEvent event) { switch (status) { case Draft: event.setNotificationType(this.notificationProperties.getDmpModifiedType()); @@ -349,103 +349,103 @@ public class DmpServiceImpl implements DmpService { public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException, IOException { logger.debug("deleting dmp: {}", id); - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(id)), Permission.DeleteDmp); + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(id)), Permission.DeletePlan); - DmpEntity data = this.entityManager.find(DmpEntity.class, id); - if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanEntity data = this.entityManager.find(PlanEntity.class, id); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.DMP).entityIds(data.getId()); if (entityDoiQuery.count() > 0) throw new MyApplicationException("DMP is deposited can not deleted"); - DmpEntity previousDmp = null; - if (!data.getVersionStatus().equals(DmpVersionStatus.Previous)){ - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class) + PlanEntity previousDmp = null; + if (!data.getVersionStatus().equals(PlanVersionStatus.Previous)){ + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class) .excludedIds(data.getId()) .isActive(IsActive.Active) .groupIds(data.getGroupId()); - dmpQuery.setOrder(new Ordering().addDescending(Dmp._version)); - previousDmp = dmpQuery.count() > 0 ? dmpQuery.collect().getFirst() : null; + planQuery.setOrder(new Ordering().addDescending(Plan._version)); + previousDmp = planQuery.count() > 0 ? planQuery.collect().getFirst() : null; if (previousDmp != null){ - if (previousDmp.getStatus().equals(DmpStatus.Finalized)) previousDmp.setVersionStatus(DmpVersionStatus.Current); - else previousDmp.setVersionStatus(DmpVersionStatus.NotFinalized); + if (previousDmp.getStatus().equals(PlanStatus.Finalized)) previousDmp.setVersionStatus(PlanVersionStatus.Current); + else previousDmp.setVersionStatus(PlanVersionStatus.NotFinalized); this.entityManager.merge(previousDmp); } - data.setVersionStatus(DmpVersionStatus.NotFinalized); + data.setVersionStatus(PlanVersionStatus.NotFinalized); this.entityManager.merge(data); this.entityManager.flush(); } - this.deleterFactory.deleter(DmpDeleter.class).deleteAndSaveByIds(List.of(id), false); - if (previousDmp != null) this.elasticService.persistDmp(previousDmp); + this.deleterFactory.deleter(PlanDeleter.class).deleteAndSaveByIds(List.of(id), false); + if (previousDmp != null) this.elasticService.persistPlan(previousDmp); this.annotationEntityRemovalIntegrationEventHandler.handleDmp(data.getId()); } @Override - public Dmp createNewVersion(NewVersionDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException { + public Plan createNewVersion(NewVersionPlanPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException { logger.debug(new MapLogEntry("persisting data bew version").And("model", model).And("fields", fields)); - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation( model.getId())), Permission.CreateNewVersionDmp); + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation( model.getId())), Permission.CreateNewVersionPlan); - DmpEntity oldDmpEntity = this.entityManager.find(DmpEntity.class, model.getId(), true); - if (oldDmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if (!this.conventionService.hashValue(oldDmpEntity.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); + PlanEntity oldPlanEntity = this.entityManager.find(PlanEntity.class, model.getId(), true); + if (oldPlanEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (!this.conventionService.hashValue(oldPlanEntity.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); - List latestVersionDmps = this.queryFactory.query(DmpQuery.class).disableTracking() - .groupIds(oldDmpEntity.getGroupId()) + List latestVersionPlans = this.queryFactory.query(PlanQuery.class).disableTracking() + .groupIds(oldPlanEntity.getGroupId()) .isActive(IsActive.Active) - .versionStatuses(DmpVersionStatus.Current) + .versionStatuses(PlanVersionStatus.Current) .collect(); - if (latestVersionDmps.isEmpty()) throw new MyValidationException(this.errors.getDmpIsNotFinalized().getCode()); - if (latestVersionDmps.size() > 1) throw new MyValidationException(this.errors.getMultipleDmpVersionsNotSupported().getCode()); - if (!latestVersionDmps.getFirst().getVersion().equals(oldDmpEntity.getVersion())){ + if (latestVersionPlans.isEmpty()) throw new MyValidationException(this.errors.getDmpIsNotFinalized().getCode()); + if (latestVersionPlans.size() > 1) throw new MyValidationException(this.errors.getMultipleDmpVersionsNotSupported().getCode()); + if (!latestVersionPlans.getFirst().getVersion().equals(oldPlanEntity.getVersion())){ throw new MyValidationException(this.errors.getDmpNewVersionConflict().getCode(), this.errors.getDmpNewVersionConflict().getMessage()); } - Long notFinalizedCount = this.queryFactory.query(DmpQuery.class).disableTracking() - .versionStatuses(DmpVersionStatus.NotFinalized) - .groupIds(oldDmpEntity.getGroupId()) + Long notFinalizedCount = this.queryFactory.query(PlanQuery.class).disableTracking() + .versionStatuses(PlanVersionStatus.NotFinalized) + .groupIds(oldPlanEntity.getGroupId()) .isActive(IsActive.Active) .count(); if (notFinalizedCount > 0) throw new MyValidationException(this.errors.getDmpNewVersionAlreadyCreatedDraft().getCode(), this.errors.getDmpNewVersionAlreadyCreatedDraft().getMessage()); - DmpEntity newDmp = new DmpEntity(); - newDmp.setId(UUID.randomUUID()); - newDmp.setIsActive(IsActive.Active); - newDmp.setCreatedAt(Instant.now()); - newDmp.setUpdatedAt(Instant.now()); - newDmp.setGroupId(oldDmpEntity.getGroupId()); - newDmp.setVersionStatus(DmpVersionStatus.NotFinalized); - newDmp.setVersion((short)(oldDmpEntity.getVersion() + 1)); - newDmp.setDescription(model.getDescription()); - newDmp.setLabel(model.getLabel()); - newDmp.setLanguage(oldDmpEntity.getLanguage()); - newDmp.setStatus(DmpStatus.Draft); - newDmp.setProperties(oldDmpEntity.getProperties()); - newDmp.setBlueprintId(model.getBlueprintId()); - newDmp.setAccessType(oldDmpEntity.getAccessType()); - newDmp.setCreatorId(this.userScope.getUserId()); + PlanEntity newPlan = new PlanEntity(); + newPlan.setId(UUID.randomUUID()); + newPlan.setIsActive(IsActive.Active); + newPlan.setCreatedAt(Instant.now()); + newPlan.setUpdatedAt(Instant.now()); + newPlan.setGroupId(oldPlanEntity.getGroupId()); + newPlan.setVersionStatus(PlanVersionStatus.NotFinalized); + newPlan.setVersion((short)(oldPlanEntity.getVersion() + 1)); + newPlan.setDescription(model.getDescription()); + newPlan.setLabel(model.getLabel()); + newPlan.setLanguage(oldPlanEntity.getLanguage()); + newPlan.setStatus(PlanStatus.Draft); + newPlan.setProperties(oldPlanEntity.getProperties()); + newPlan.setBlueprintId(model.getBlueprintId()); + newPlan.setAccessType(oldPlanEntity.getAccessType()); + newPlan.setCreatorId(this.userScope.getUserId()); - this.entityManager.persist(newDmp); + this.entityManager.persist(newPlan); - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking() - .dmpIds(model.getId()) + List planUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking() + .planIds(model.getId()) .isActives(IsActive.Active) .collect(); - List dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).disableTracking() - .dmpIds(model.getId()) + List planReferences = this.queryFactory.query(PlanReferenceQuery.class).disableTracking() + .planIds(model.getId()) .isActives(IsActive.Active) .collect(); - List dmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking() - .dmpIds(model.getId()) + List planDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking() + .planIds(model.getId()) .isActive(IsActive.Active) .collect(); - for (DmpUserEntity dmpUser : dmpUsers) { - DmpUserEntity newUser = new DmpUserEntity(); + for (PlanUserEntity planUser : planUsers) { + PlanUserEntity newUser = new PlanUserEntity(); newUser.setId(UUID.randomUUID()); - newUser.setDmpId(newDmp.getId()); - newUser.setUserId(dmpUser.getUserId()); - newUser.setRole(dmpUser.getRole()); + newUser.setPlanId(newPlan.getId()); + newUser.setUserId(planUser.getUserId()); + newUser.setRole(planUser.getRole()); newUser.setCreatedAt(Instant.now()); newUser.setUpdatedAt(Instant.now()); newUser.setIsActive(IsActive.Active); @@ -453,12 +453,12 @@ public class DmpServiceImpl implements DmpService { this.entityManager.persist(newUser); } - for (DmpReferenceEntity dmpReference : dmpReferences) { - DmpReferenceEntity newReference = new DmpReferenceEntity(); + for (PlanReferenceEntity planReference : planReferences) { + PlanReferenceEntity newReference = new PlanReferenceEntity(); newReference.setId(UUID.randomUUID()); - newReference.setDmpId(newDmp.getId()); - newReference.setReferenceId(dmpReference.getReferenceId()); - newReference.setData(dmpReference.getData()); + newReference.setPlanId(newPlan.getId()); + newReference.setReferenceId(planReference.getReferenceId()); + newReference.setData(planReference.getData()); newReference.setCreatedAt(Instant.now()); newReference.setUpdatedAt(Instant.now()); newReference.setIsActive(IsActive.Active); @@ -469,56 +469,56 @@ public class DmpServiceImpl implements DmpService { this.entityManager.flush(); if (model.getDescriptions() != null){ - DmpBlueprintEntity blueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, model.getBlueprintId(), true); - if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getBlueprintId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanBlueprintEntity blueprintEntity = this.entityManager.find(PlanBlueprintEntity.class, model.getBlueprintId(), true); + if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); - org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, blueprintEntity.getDefinition()); + org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, blueprintEntity.getDefinition()); - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(model.getDescriptions().stream().map(NewVersionDmpDescriptionPersist::getDescriptionId).distinct().collect(Collectors.toList())).isActive(IsActive.Active).collect(); + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(model.getDescriptions().stream().map(NewVersionPlanDescriptionPersist::getDescriptionId).distinct().collect(Collectors.toList())).isActive(IsActive.Active).collect(); FieldSet fieldSet = new BaseFieldSet(Description._id, BaseFieldSet.asIndexer(Description._descriptionTemplate, DescriptionTemplate._groupId)); List models = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fieldSet, descriptionEntities); if (!this.conventionService.isListNullOrEmpty(models)){ - for (NewVersionDmpDescriptionPersist newVersionDmpDescriptionPersist : model.getDescriptions()) { - Description description = models.stream().filter(x -> x.getId().equals(newVersionDmpDescriptionPersist.getDescriptionId())).findFirst().orElse(null); + for (NewVersionPlanDescriptionPersist newVersionPlanDescriptionPersist : model.getDescriptions()) { + Description description = models.stream().filter(x -> x.getId().equals(newVersionPlanDescriptionPersist.getDescriptionId())).findFirst().orElse(null); if (description != null){ - DmpDescriptionTemplateEntity existingDmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().dmpIds(newDmp.getId()).isActive(IsActive.Active).sectionIds(newVersionDmpDescriptionPersist.getBlueprintSectionId()).descriptionTemplateGroupIds(description.getDescriptionTemplate().getGroupId()).first(); - if (existingDmpDescriptionTemplateEntity == null){ - DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); + PlanDescriptionTemplateEntity existingPlanDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().planIds(newPlan.getId()).isActive(IsActive.Active).sectionIds(newVersionPlanDescriptionPersist.getBlueprintSectionId()).descriptionTemplateGroupIds(description.getDescriptionTemplate().getGroupId()).first(); + if (existingPlanDescriptionTemplateEntity == null){ + PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity(); newTemplate.setId(UUID.randomUUID()); - newTemplate.setDmpId(newDmp.getId()); + newTemplate.setPlanId(newPlan.getId()); newTemplate.setDescriptionTemplateGroupId(description.getDescriptionTemplate().getGroupId()); - newTemplate.setSectionId(newVersionDmpDescriptionPersist.getBlueprintSectionId()); + newTemplate.setSectionId(newVersionPlanDescriptionPersist.getBlueprintSectionId()); newTemplate.setCreatedAt(Instant.now()); newTemplate.setUpdatedAt(Instant.now()); newTemplate.setIsActive(IsActive.Active); this.entityManager.persist(newTemplate); this.entityManager.flush(); - this.cloneDescription(newDmp.getId(), null, newVersionDmpDescriptionPersist.getDescriptionId(), newTemplate.getId()); + this.cloneDescription(newPlan.getId(), null, newVersionPlanDescriptionPersist.getDescriptionId(), newTemplate.getId()); } else{ - this.cloneDescription(newDmp.getId(), null, newVersionDmpDescriptionPersist.getDescriptionId(), existingDmpDescriptionTemplateEntity.getId()); + this.cloneDescription(newPlan.getId(), null, newVersionPlanDescriptionPersist.getDescriptionId(), existingPlanDescriptionTemplateEntity.getId()); } } } } - List newDmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().dmpIds(newDmp.getId()).isActive(IsActive.Active).collect(); + List newPlanDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().planIds(newPlan.getId()).isActive(IsActive.Active).collect(); - if (!oldDmpEntity.getBlueprintId().equals(blueprintEntity.getId())){ + if (!oldPlanEntity.getBlueprintId().equals(blueprintEntity.getId())){ // add description templates if exists in new blueprint List sections = definition.getSections().stream().filter(SectionEntity::getHasTemplates).collect(Collectors.toList()); - if (!this.conventionService.isListNullOrEmpty(sections) && !this.conventionService.isListNullOrEmpty(newDmpDescriptionTemplateEntities)){ + if (!this.conventionService.isListNullOrEmpty(sections) && !this.conventionService.isListNullOrEmpty(newPlanDescriptionTemplateEntities)){ for (SectionEntity section: sections) { if (!this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){ for (DescriptionTemplateEntity blueprintDescriptionTemplate: section.getDescriptionTemplates()) { - if (model.getDescriptions().stream().map(NewVersionDmpDescriptionPersist::getBlueprintSectionId).toList().contains(section.getId())){ - DmpDescriptionTemplateEntity existingBlueprintDescriptionTemplateEntity = newDmpDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(section.getId()) && x.getDescriptionTemplateGroupId().equals(blueprintDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null); + if (model.getDescriptions().stream().map(NewVersionPlanDescriptionPersist::getBlueprintSectionId).toList().contains(section.getId())){ + PlanDescriptionTemplateEntity existingBlueprintDescriptionTemplateEntity = newPlanDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(section.getId()) && x.getDescriptionTemplateGroupId().equals(blueprintDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null); if (existingBlueprintDescriptionTemplateEntity == null){ - DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); + PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity(); newTemplate.setId(UUID.randomUUID()); - newTemplate.setDmpId(newDmp.getId()); + newTemplate.setPlanId(newPlan.getId()); newTemplate.setDescriptionTemplateGroupId(blueprintDescriptionTemplate.getDescriptionTemplateGroupId()); newTemplate.setSectionId(section.getId()); newTemplate.setCreatedAt(Instant.now()); @@ -534,13 +534,13 @@ public class DmpServiceImpl implements DmpService { } } else { - for (DmpDescriptionTemplateEntity oldDmpDescriptionTemplate : dmpDescriptionTemplates) { - if (newDmpDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(oldDmpDescriptionTemplate.getSectionId()) && x.getDescriptionTemplateGroupId().equals(oldDmpDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null) == null){ - DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); + for (PlanDescriptionTemplateEntity oldPlanDescriptionTemplate : planDescriptionTemplates) { + if (newPlanDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(oldPlanDescriptionTemplate.getSectionId()) && x.getDescriptionTemplateGroupId().equals(oldPlanDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null) == null){ + PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity(); newTemplate.setId(UUID.randomUUID()); - newTemplate.setDmpId(newDmp.getId()); - newTemplate.setDescriptionTemplateGroupId(oldDmpDescriptionTemplate.getDescriptionTemplateGroupId()); - newTemplate.setSectionId(oldDmpDescriptionTemplate.getSectionId()); + newTemplate.setPlanId(newPlan.getId()); + newTemplate.setDescriptionTemplateGroupId(oldPlanDescriptionTemplate.getDescriptionTemplateGroupId()); + newTemplate.setSectionId(oldPlanDescriptionTemplate.getSectionId()); newTemplate.setCreatedAt(Instant.now()); newTemplate.setUpdatedAt(Instant.now()); newTemplate.setIsActive(IsActive.Active); @@ -552,21 +552,21 @@ public class DmpServiceImpl implements DmpService { this.entityManager.flush(); - this.updateVersionStatusAndSave(newDmp, DmpStatus.Draft, newDmp.getStatus()); + this.updateVersionStatusAndSave(newPlan, PlanStatus.Draft, newPlan.getStatus()); this.entityManager.flush(); - this.elasticService.persistDmp(oldDmpEntity); - this.elasticService.persistDmp(newDmp); + this.elasticService.persistPlan(oldPlanEntity); + this.elasticService.persistPlan(newPlan); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(newDmp.getId()); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(oldDmpEntity.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(newPlan.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(oldPlanEntity.getId()); - return this.builderFactory.builder(DmpBuilder.class).build(BaseFieldSet.build(fields, Dmp._id), newDmp); + return this.builderFactory.builder(PlanBuilder.class).build(BaseFieldSet.build(fields, Plan._id), newPlan); } - public void cloneDescription(UUID dmpId, Map dmpDescriptionTemplateRemap, UUID descriptionId, UUID newDmpDescriptionTemplateId) throws InvalidApplicationException, IOException { - logger.debug("cloning description: {} with description: {}", descriptionId, dmpId); + public void cloneDescription(UUID planId, Map planDescriptionTemplateRemap, UUID descriptionId, UUID newPlanDescriptionTemplateId) throws InvalidApplicationException, IOException { + logger.debug("cloning description: {} with description: {}", descriptionId, planId); this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(descriptionId)), Permission.CloneDescription); @@ -578,9 +578,9 @@ public class DmpServiceImpl implements DmpService { newDescription.setDescription(existing.getDescription()); newDescription.setStatus(DescriptionStatus.Draft); newDescription.setProperties(existing.getProperties()); - newDescription.setDmpId(dmpId); - if (newDmpDescriptionTemplateId == null && dmpDescriptionTemplateRemap != null) newDescription.setDmpDescriptionTemplateId(dmpDescriptionTemplateRemap.get(existing.getDmpDescriptionTemplateId())); - else newDescription.setDmpDescriptionTemplateId(newDmpDescriptionTemplateId); + newDescription.setPlanId(planId); + if (newPlanDescriptionTemplateId == null && planDescriptionTemplateRemap != null) newDescription.setPlanDescriptionTemplateId(planDescriptionTemplateRemap.get(existing.getPlanDescriptionTemplateId())); + else newDescription.setPlanDescriptionTemplateId(newPlanDescriptionTemplateId); newDescription.setDescriptionTemplateId(existing.getDescriptionTemplateId()); newDescription.setCreatedById(this.userScope.getUserId()); newDescription.setCreatedAt(Instant.now()); @@ -634,37 +634,37 @@ public class DmpServiceImpl implements DmpService { - private void updateVersionStatusAndSave(DmpEntity data, DmpStatus previousStatus, DmpStatus newStatus) throws InvalidApplicationException { + private void updateVersionStatusAndSave(PlanEntity data, PlanStatus previousStatus, PlanStatus newStatus) throws InvalidApplicationException { if (previousStatus.equals(newStatus)) return; - if (previousStatus.equals(DmpStatus.Finalized) && newStatus.equals(DmpStatus.Draft)){ - boolean alreadyCreatedNewVersion = this.queryFactory.query(DmpQuery.class).disableTracking() - .versionStatuses(DmpVersionStatus.NotFinalized, DmpVersionStatus.Current) + if (previousStatus.equals(PlanStatus.Finalized) && newStatus.equals(PlanStatus.Draft)){ + boolean alreadyCreatedNewVersion = this.queryFactory.query(PlanQuery.class).disableTracking() + .versionStatuses(PlanVersionStatus.NotFinalized, PlanVersionStatus.Current) .excludedIds(data.getId()) .isActive(IsActive.Active) .groupIds(data.getGroupId()) .count() > 0; if (alreadyCreatedNewVersion) throw new MyValidationException("Already new version is created"); - data.setVersionStatus(DmpVersionStatus.NotFinalized); + data.setVersionStatus(PlanVersionStatus.NotFinalized); this.entityManager.merge(data); } - if (newStatus.equals(DmpStatus.Finalized)) { - List latestVersionDmps = this.queryFactory.query(DmpQuery.class) - .versionStatuses(DmpVersionStatus.Current).excludedIds(data.getId()) + if (newStatus.equals(PlanStatus.Finalized)) { + List latestVersionDmps = this.queryFactory.query(PlanQuery.class) + .versionStatuses(PlanVersionStatus.Current).excludedIds(data.getId()) .isActive(IsActive.Active).groupIds(data.getGroupId()).collect(); if (latestVersionDmps.size() > 1) throw new MyValidationException("Multiple previous template found"); - DmpEntity oldDmpEntity = latestVersionDmps.stream().findFirst().orElse(null); + PlanEntity oldPlanEntity = latestVersionDmps.stream().findFirst().orElse(null); - data.setVersionStatus(DmpVersionStatus.Current); + data.setVersionStatus(PlanVersionStatus.Current); - if (oldDmpEntity != null) { - data.setVersion((short) (oldDmpEntity.getVersion() + 1)); + if (oldPlanEntity != null) { + data.setVersion((short) (oldPlanEntity.getVersion() + 1)); - oldDmpEntity.setVersionStatus(DmpVersionStatus.Previous); - this.entityManager.merge(oldDmpEntity); + oldPlanEntity.setVersionStatus(PlanVersionStatus.Previous); + this.entityManager.merge(oldPlanEntity); } else { data.setVersion((short) 1); } @@ -672,51 +672,51 @@ public class DmpServiceImpl implements DmpService { } @Override - public Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException { - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation( model.getId())), Permission.CloneDmp); + public Plan buildClone(ClonePlanPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException { + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation( model.getId())), Permission.ClonePlan); - DmpEntity existingDmpEntity = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(model.getId()).firstAs(fields); - if (!this.conventionService.isValidGuid(model.getId()) || existingDmpEntity == null) - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanEntity existingPlanEntity = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(model.getId()).firstAs(fields); + if (!this.conventionService.isValidGuid(model.getId()) || existingPlanEntity == null) + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpEntity newDmp = new DmpEntity(); - newDmp.setId(UUID.randomUUID()); - newDmp.setIsActive(IsActive.Active); - newDmp.setCreatedAt(Instant.now()); - newDmp.setUpdatedAt(Instant.now()); - newDmp.setGroupId(UUID.randomUUID()); - newDmp.setVersion((short) 1); - newDmp.setVersionStatus(DmpVersionStatus.NotFinalized); - newDmp.setDescription(model.getDescription()); - newDmp.setLabel(model.getLabel()); - newDmp.setLanguage(existingDmpEntity.getLanguage()); - newDmp.setStatus(DmpStatus.Draft); - newDmp.setProperties(existingDmpEntity.getProperties()); - newDmp.setBlueprintId(existingDmpEntity.getBlueprintId()); - newDmp.setAccessType(existingDmpEntity.getAccessType()); - newDmp.setCreatorId(this.userScope.getUserId()); + PlanEntity newPlan = new PlanEntity(); + newPlan.setId(UUID.randomUUID()); + newPlan.setIsActive(IsActive.Active); + newPlan.setCreatedAt(Instant.now()); + newPlan.setUpdatedAt(Instant.now()); + newPlan.setGroupId(UUID.randomUUID()); + newPlan.setVersion((short) 1); + newPlan.setVersionStatus(PlanVersionStatus.NotFinalized); + newPlan.setDescription(model.getDescription()); + newPlan.setLabel(model.getLabel()); + newPlan.setLanguage(existingPlanEntity.getLanguage()); + newPlan.setStatus(PlanStatus.Draft); + newPlan.setProperties(existingPlanEntity.getProperties()); + newPlan.setBlueprintId(existingPlanEntity.getBlueprintId()); + newPlan.setAccessType(existingPlanEntity.getAccessType()); + newPlan.setCreatorId(this.userScope.getUserId()); - this.entityManager.persist(newDmp); + this.entityManager.persist(newPlan); - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking() - .dmpIds(model.getId()) + List planUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking() + .planIds(model.getId()) .isActives(IsActive.Active) .collect(); - List dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).disableTracking() - .dmpIds(model.getId()) + List planReferences = this.queryFactory.query(PlanReferenceQuery.class).disableTracking() + .planIds(model.getId()) .isActives(IsActive.Active) .collect(); - List dmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking() - .dmpIds(model.getId()) + List planDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking() + .planIds(model.getId()) .isActive(IsActive.Active) .collect(); - for (DmpUserEntity dmpUser : dmpUsers) { - DmpUserEntity newUser = new DmpUserEntity(); + for (PlanUserEntity planUser : planUsers) { + PlanUserEntity newUser = new PlanUserEntity(); newUser.setId(UUID.randomUUID()); - newUser.setDmpId(newDmp.getId()); - newUser.setUserId(dmpUser.getUserId()); - newUser.setRole(dmpUser.getRole()); + newUser.setPlanId(newPlan.getId()); + newUser.setUserId(planUser.getUserId()); + newUser.setRole(planUser.getRole()); newUser.setCreatedAt(Instant.now()); newUser.setUpdatedAt(Instant.now()); newUser.setIsActive(IsActive.Active); @@ -724,12 +724,12 @@ public class DmpServiceImpl implements DmpService { this.entityManager.persist(newUser); } - for (DmpReferenceEntity dmpReference : dmpReferences) { - DmpReferenceEntity newReference = new DmpReferenceEntity(); + for (PlanReferenceEntity planReference : planReferences) { + PlanReferenceEntity newReference = new PlanReferenceEntity(); newReference.setId(UUID.randomUUID()); - newReference.setDmpId(newDmp.getId()); - newReference.setReferenceId(dmpReference.getReferenceId()); - newReference.setData(dmpReference.getData()); + newReference.setPlanId(newPlan.getId()); + newReference.setReferenceId(planReference.getReferenceId()); + newReference.setData(planReference.getData()); newReference.setCreatedAt(Instant.now()); newReference.setUpdatedAt(Instant.now()); newReference.setIsActive(IsActive.Active); @@ -737,90 +737,90 @@ public class DmpServiceImpl implements DmpService { this.entityManager.persist(newReference); } - Map dmpDescriptionTemplateRemap = new HashMap<>(); - for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) { - DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); + Map planDescriptionTemplateRemap = new HashMap<>(); + for (PlanDescriptionTemplateEntity planDescriptionTemplate : planDescriptionTemplates) { + PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity(); newTemplate.setId(UUID.randomUUID()); - newTemplate.setDmpId(newDmp.getId()); - newTemplate.setDescriptionTemplateGroupId(dmpDescriptionTemplate.getDescriptionTemplateGroupId()); - newTemplate.setSectionId(dmpDescriptionTemplate.getSectionId()); + newTemplate.setPlanId(newPlan.getId()); + newTemplate.setDescriptionTemplateGroupId(planDescriptionTemplate.getDescriptionTemplateGroupId()); + newTemplate.setSectionId(planDescriptionTemplate.getSectionId()); newTemplate.setCreatedAt(Instant.now()); newTemplate.setUpdatedAt(Instant.now()); newTemplate.setIsActive(IsActive.Active); - dmpDescriptionTemplateRemap.put(dmpDescriptionTemplate.getId(), newTemplate.getId()); + planDescriptionTemplateRemap.put(planDescriptionTemplate.getId(), newTemplate.getId()); this.entityManager.persist(newTemplate); } this.entityManager.flush(); - this.elasticService.persistDmp(newDmp); + this.elasticService.persistPlan(newPlan); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(newDmp.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(newPlan.getId()); - DmpEntity resultingDmpEntity = this.queryFactory.query(DmpQuery.class).disableTracking().ids(newDmp.getId()).firstAs(fields); + PlanEntity resultingPlanEntity = this.queryFactory.query(PlanQuery.class).disableTracking().ids(newPlan.getId()).firstAs(fields); if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){ for (UUID description: model.getDescriptions()) { - this.cloneDescription(newDmp.getId(), dmpDescriptionTemplateRemap, description, null); + this.cloneDescription(newPlan.getId(), planDescriptionTemplateRemap, description, null); } } - return this.builderFactory.builder(DmpBuilder.class).build(fields, resultingDmpEntity); + return this.builderFactory.builder(PlanBuilder.class).build(fields, resultingPlanEntity); } @Override - public List assignUsers(UUID dmpId, List model, FieldSet fieldSet, boolean disableDelete) throws InvalidApplicationException, IOException { - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(dmpId)), Permission.AssignDmpUsers); + public List assignUsers(UUID planId, List model, FieldSet fieldSet, boolean disableDelete) throws InvalidApplicationException, IOException { + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(planId)), Permission.AssignPlanUsers); - if (!disableDelete && (model == null || model.stream().noneMatch(x-> x.getUser() != null && DmpUserRole.Owner.equals(x.getRole())))) throw new MyApplicationException("At least one owner required"); + if (!disableDelete && (model == null || model.stream().noneMatch(x-> x.getUser() != null && PlanUserRole.Owner.equals(x.getRole())))) throw new MyApplicationException("At least one owner required"); this.checkDuplicateDmpUser(model); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, dmpId, true); - if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpId, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanEntity planEntity = this.entityManager.find(PlanEntity.class, planId, true); + if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planId, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - List existingUsers = this.queryFactory.query(DmpUserQuery.class) - .dmpIds(dmpId) + List existingUsers = this.queryFactory.query(PlanUserQuery.class) + .planIds(planId) .isActives(IsActive.Active) .collect(); List updatedCreatedIds = new ArrayList<>(); - for (DmpUserPersist dmpUser : model) { - DmpUserEntity dmpUserEntity = existingUsers.stream().filter(x-> x.getDmpId().equals(dmpId) && x.getUserId().equals(dmpUser.getUser()) && x.getRole().equals(dmpUser.getRole()) && Objects.equals(dmpUser.getSectionId(), x.getSectionId())).findFirst().orElse(null); - if (dmpUserEntity == null){ - dmpUserEntity = new DmpUserEntity(); - dmpUserEntity.setId(UUID.randomUUID()); - dmpUserEntity.setDmpId(dmpId); - dmpUserEntity.setUserId(dmpUser.getUser()); - dmpUserEntity.setRole(dmpUser.getRole()); - dmpUserEntity.setSectionId(dmpUser.getSectionId()); - dmpUserEntity.setCreatedAt(Instant.now()); - dmpUserEntity.setUpdatedAt(Instant.now()); - dmpUserEntity.setIsActive(IsActive.Active); - this.entityManager.persist(dmpUserEntity); + for (PlanUserPersist dmpUser : model) { + PlanUserEntity planUserEntity = existingUsers.stream().filter(x-> x.getPlanId().equals(planId) && x.getUserId().equals(dmpUser.getUser()) && x.getRole().equals(dmpUser.getRole()) && Objects.equals(dmpUser.getSectionId(), x.getSectionId())).findFirst().orElse(null); + if (planUserEntity == null){ + planUserEntity = new PlanUserEntity(); + planUserEntity.setId(UUID.randomUUID()); + planUserEntity.setPlanId(planId); + planUserEntity.setUserId(dmpUser.getUser()); + planUserEntity.setRole(dmpUser.getRole()); + planUserEntity.setSectionId(dmpUser.getSectionId()); + planUserEntity.setCreatedAt(Instant.now()); + planUserEntity.setUpdatedAt(Instant.now()); + planUserEntity.setIsActive(IsActive.Active); + this.entityManager.persist(planUserEntity); } - updatedCreatedIds.add(dmpUserEntity.getId()); + updatedCreatedIds.add(planUserEntity.getId()); } - List toDelete = existingUsers.stream().filter(x-> updatedCreatedIds.stream().noneMatch(y-> y.equals(x.getId()))).collect(Collectors.toList()); - if (!toDelete.isEmpty() && !disableDelete) this.deleterFactory.deleter(DmpUserDeleter.class).delete(toDelete); + List toDelete = existingUsers.stream().filter(x-> updatedCreatedIds.stream().noneMatch(y-> y.equals(x.getId()))).collect(Collectors.toList()); + if (!toDelete.isEmpty() && !disableDelete) this.deleterFactory.deleter(PlanUserDeleter.class).delete(toDelete); this.entityManager.flush(); - List persisted = this.queryFactory.query(DmpUserQuery.class) - .dmpIds(dmpId) + List persisted = this.queryFactory.query(PlanUserQuery.class) + .planIds(planId) .isActives(IsActive.Active) .collect(); - this.elasticService.persistDmp(dmpEntity); + this.elasticService.persistPlan(planEntity); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(dmpEntity.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(planEntity.getId()); - return this.builderFactory.builder(DmpUserBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fieldSet, DmpUser._id, DmpUser._hash), persisted); + return this.builderFactory.builder(PlanUserBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fieldSet, PlanUser._id, PlanUser._hash), persisted); } - private void checkDuplicateDmpUser(List model){ - for (DmpUserPersist user: model) { - List duplicateUser; + private void checkDuplicateDmpUser(List model){ + for (PlanUserPersist user: model) { + List duplicateUser; if (user.getUser() != null){ duplicateUser = model.stream().filter(x -> x.getUser().equals(user.getUser()) && x.getRole().equals(user.getRole()) && Objects.equals(user.getSectionId(), x.getSectionId())).collect(Collectors.toList()); } else { @@ -833,26 +833,26 @@ public class DmpServiceImpl implements DmpService { } @Override - public Dmp removeUser(DmpUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException { - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(model.getDmpId())), Permission.AssignDmpUsers); - DmpEntity data = this.entityManager.find(DmpEntity.class, model.getDmpId(), true); - if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + public Plan removeUser(PlanUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException { + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(model.getPlanId())), Permission.AssignPlanUsers); + PlanEntity data = this.entityManager.find(PlanEntity.class, model.getPlanId(), true); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - List existingUsers = this.queryFactory.query(DmpUserQuery.class) - .dmpIds(model.getDmpId()).ids(model.getId()).userRoles(model.getRole()) + List existingUsers = this.queryFactory.query(PlanUserQuery.class) + .planIds(model.getPlanId()).ids(model.getId()).userRoles(model.getRole()) .collect(); - if (!existingUsers.isEmpty()) this.deleterFactory.deleter(DmpUserDeleter.class).delete(existingUsers); + if (!existingUsers.isEmpty()) this.deleterFactory.deleter(PlanUserDeleter.class).delete(existingUsers); this.entityManager.flush(); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, model.getDmpId()); - if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); - this.elasticService.persistDmp(dmpEntity); + PlanEntity planEntity = this.entityManager.find(PlanEntity.class, model.getPlanId()); + if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPlanId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); + this.elasticService.persistPlan(planEntity); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(dmpEntity.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(planEntity.getId()); - return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data); + return this.builderFactory.builder(PlanBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fields, Plan._id, Plan._hash), data); } @Override @@ -866,37 +866,37 @@ public class DmpServiceImpl implements DmpService { return new ResponseEntity<>(data, headers, HttpStatus.OK); } - private DmpEntity patchAndSave(DmpPersist model) throws JsonProcessingException, InvalidApplicationException { + private PlanEntity patchAndSave(PlanPersist model) throws JsonProcessingException, InvalidApplicationException { Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); - DmpEntity data; + PlanEntity data; if (isUpdate) { - data = this.entityManager.find(DmpEntity.class, model.getId()); - if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + data = this.entityManager.find(PlanEntity.class, model.getId()); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); - if (model.getStatus() != null && model.getStatus() == DmpStatus.Finalized && data.getStatus() != DmpStatus.Finalized) { - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(model.getId())), Permission.FinalizeDmp); + if (model.getStatus() != null && model.getStatus() == PlanStatus.Finalized && data.getStatus() != PlanStatus.Finalized) { + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(model.getId())), Permission.FinalizePlan); data.setStatus(model.getStatus()); data.setFinalizedAt(Instant.now()); } } else { - data = new DmpEntity(); + data = new PlanEntity(); data.setId(UUID.randomUUID()); data.setGroupId(UUID.randomUUID()); data.setVersion((short) 1); - data.setStatus(DmpStatus.Draft); - data.setVersionStatus(DmpVersionStatus.NotFinalized); + data.setStatus(PlanStatus.Draft); + data.setVersionStatus(PlanVersionStatus.NotFinalized); data.setCreatorId(this.userScope.getUserId()); data.setBlueprintId(model.getBlueprint()); data.setIsActive(IsActive.Active); data.setCreatedAt(Instant.now()); } - DmpStatus previousStatus = data.getStatus(); + PlanStatus previousStatus = data.getStatus(); - DmpBlueprintEntity dmpBlueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, model.getBlueprint(), true); - if (dmpBlueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getBlueprint(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanBlueprintEntity planBlueprintEntity = this.entityManager.find(PlanBlueprintEntity.class, model.getBlueprint(), true); + if (planBlueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getBlueprint(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); - org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); + org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition()); data.setLabel(model.getLabel()); data.setLanguage(model.getLanguage()); @@ -919,26 +919,26 @@ public class DmpServiceImpl implements DmpService { return data; } - private @NotNull DmpPropertiesEntity buildDmpPropertiesEntity(DmpPropertiesPersist persist, org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition){ - DmpPropertiesEntity data = new DmpPropertiesEntity(); + private @NotNull PlanPropertiesEntity buildDmpPropertiesEntity(PlanPropertiesPersist persist, org.opencdmp.commons.types.planblueprint.DefinitionEntity definition){ + PlanPropertiesEntity data = new PlanPropertiesEntity(); if (persist == null) return data; if (!this.conventionService.isListNullOrEmpty(persist.getContacts())){ data.setContacts(new ArrayList<>()); - for (DmpContactPersist contactPersist: persist.getContacts()) { + for (PlanContactPersist contactPersist: persist.getContacts()) { data.getContacts().add(this.buildDmpContactEntity(contactPersist)); } } - if (persist.getDmpBlueprintValues() != null && !persist.getDmpBlueprintValues().isEmpty()){ - data.setDmpBlueprintValues(new ArrayList<>()); - for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues().values()) { - if (!this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) || fieldValuePersist.getDateValue() != null || fieldValuePersist.getNumberValue() != null) data.getDmpBlueprintValues().add(this.buildDmpBlueprintValueEntity(fieldValuePersist, definition)); + if (persist.getPlanBlueprintValues() != null && !persist.getPlanBlueprintValues().isEmpty()){ + data.setPlanBlueprintValues(new ArrayList<>()); + for (PlanBlueprintValuePersist fieldValuePersist: persist.getPlanBlueprintValues().values()) { + if (!this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) || fieldValuePersist.getDateValue() != null || fieldValuePersist.getNumberValue() != null) data.getPlanBlueprintValues().add(this.buildDmpBlueprintValueEntity(fieldValuePersist, definition)); } } return data; } - private @NotNull DmpContactEntity buildDmpContactEntity(DmpContactPersist persist){ - DmpContactEntity data = new DmpContactEntity(); + private @NotNull PlanContactEntity buildDmpContactEntity(PlanContactPersist persist){ + PlanContactEntity data = new PlanContactEntity(); if (persist == null) return data; data.setEmail(persist.getEmail()); @@ -947,18 +947,18 @@ public class DmpServiceImpl implements DmpService { return data; } - private @NotNull DmpBlueprintValueEntity buildDmpBlueprintValueEntity(DmpBlueprintValuePersist persist, org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition){ - DmpBlueprintValueEntity data = new DmpBlueprintValueEntity(); + private @NotNull PlanBlueprintValueEntity buildDmpBlueprintValueEntity(PlanBlueprintValuePersist persist, org.opencdmp.commons.types.planblueprint.DefinitionEntity definition){ + PlanBlueprintValueEntity data = new PlanBlueprintValueEntity(); if (persist == null || definition == null) return data; - org.opencdmp.commons.types.dmpblueprint.FieldEntity fieldEntity = definition.getFieldById(persist.getFieldId()).stream().findFirst().orElse(null); + org.opencdmp.commons.types.planblueprint.FieldEntity fieldEntity = definition.getFieldById(persist.getFieldId()).stream().findFirst().orElse(null); if (fieldEntity == null) return data; - if (fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)) { + if (fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)) { ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity; - if (DmpBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){ + if (PlanBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){ data.setDateValue(persist.getDateValue()); - } else if (DmpBlueprintExtraFieldDataType.isNumberType(extraFieldEntity.getType())){ + } else if (PlanBlueprintExtraFieldDataType.isNumberType(extraFieldEntity.getType())){ data.setNumberValue(persist.getNumberValue()); } else { data.setValue(persist.getFieldValue()); @@ -969,56 +969,56 @@ public class DmpServiceImpl implements DmpService { return data; } - private @NotNull List buildDmpReferencePersists(DmpPropertiesPersist persist){ - List dmpReferencePersists = new ArrayList<>(); - if (persist.getDmpBlueprintValues() != null && !persist.getDmpBlueprintValues().isEmpty()){ - for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues().values()) { + private @NotNull List buildPlanReferencePersists(PlanPropertiesPersist persist){ + List planReferencePersists = new ArrayList<>(); + if (persist.getPlanBlueprintValues() != null && !persist.getPlanBlueprintValues().isEmpty()){ + for (PlanBlueprintValuePersist fieldValuePersist: persist.getPlanBlueprintValues().values()) { if (fieldValuePersist.getReference() != null) { if (fieldValuePersist.getReferences() == null) fieldValuePersist.setReferences(new ArrayList<>()); fieldValuePersist.getReferences().add(fieldValuePersist.getReference()); } if (this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) && fieldValuePersist.getDateValue() == null && fieldValuePersist.getNumberValue() == null && !this.conventionService.isListNullOrEmpty( fieldValuePersist.getReferences())) { for (ReferencePersist referencePersist : fieldValuePersist.getReferences()) { - DmpReferencePersist dmpReferencePersist = new DmpReferencePersist(); - dmpReferencePersist.setData(new DmpReferenceDataPersist()); - dmpReferencePersist.getData().setBlueprintFieldId(fieldValuePersist.getFieldId()); - dmpReferencePersist.setReference(referencePersist); - dmpReferencePersists.add(dmpReferencePersist); + PlanReferencePersist planReferencePersist = new PlanReferencePersist(); + planReferencePersist.setData(new PlanReferenceDataPersist()); + planReferencePersist.getData().setBlueprintFieldId(fieldValuePersist.getFieldId()); + planReferencePersist.setReference(referencePersist); + planReferencePersists.add(planReferencePersist); } } } } - return dmpReferencePersists; + return planReferencePersists; } - private void patchAndSaveReferences(List models, UUID dmpId, org.opencdmp.commons.types.dmpblueprint.DefinitionEntity blueprintDefinition) throws InvalidApplicationException { + private void patchAndSaveReferences(List models, UUID planId, org.opencdmp.commons.types.planblueprint.DefinitionEntity blueprintDefinition) throws InvalidApplicationException { if (models == null) models = new ArrayList<>(); - List dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(dmpId).isActives(IsActive.Active).collect(); - Map> dmpReferenceEntityByReferenceId = new HashMap<>(); - for (DmpReferenceEntity dmpReferenceEntity : dmpReferences){ - List dmpReferenceEntities = dmpReferenceEntityByReferenceId.getOrDefault(dmpReferenceEntity.getReferenceId(), null); - if (dmpReferenceEntities == null) { - dmpReferenceEntities = new ArrayList<>(); - dmpReferenceEntityByReferenceId.put(dmpReferenceEntity.getReferenceId(), dmpReferenceEntities); + List planReferences = this.queryFactory.query(PlanReferenceQuery.class).planIds(planId).isActives(IsActive.Active).collect(); + Map> planReferenceEntityByReferenceId = new HashMap<>(); + for (PlanReferenceEntity planReferenceEntity : planReferences){ + List planReferenceEntities = planReferenceEntityByReferenceId.getOrDefault(planReferenceEntity.getReferenceId(), null); + if (planReferenceEntities == null) { + planReferenceEntities = new ArrayList<>(); + planReferenceEntityByReferenceId.put(planReferenceEntity.getReferenceId(), planReferenceEntities); } - dmpReferenceEntities.add(dmpReferenceEntity); + planReferenceEntities.add(planReferenceEntity); } - Map dmpReferenceDataEntityMap = new HashMap<>(); - for (DmpReferenceEntity dmpReferenceEntity : dmpReferences){ - dmpReferenceDataEntityMap.put(dmpReferenceEntity.getId(), this.jsonHandlingService.fromJsonSafe(DmpReferenceDataEntity.class, dmpReferenceEntity.getData())); + Map planReferenceDataEntityMap = new HashMap<>(); + for (PlanReferenceEntity planReferenceEntity : planReferences){ + planReferenceDataEntityMap.put(planReferenceEntity.getId(), this.jsonHandlingService.fromJsonSafe(PlanReferenceDataEntity.class, planReferenceEntity.getData())); } List updatedCreatedIds = new ArrayList<>(); - for (DmpReferencePersist model : models) { + for (PlanReferencePersist model : models) { ReferencePersist referencePersist = model.getReference(); ReferenceEntity referenceEntity; if (this.conventionService.isValidGuid(referencePersist.getId())){ referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId()); if (referenceEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale())); } else { - ReferenceTypeFieldEntity fieldEntity = blueprintDefinition.getFieldById(model.getData().getBlueprintFieldId()).stream().filter(x-> x.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType)).map(x-> (ReferenceTypeFieldEntity)x).findFirst().orElse(null); + ReferenceTypeFieldEntity fieldEntity = blueprintDefinition.getFieldById(model.getData().getBlueprintFieldId()).stream().filter(x-> x.getCategory().equals(PlanBlueprintFieldCategory.ReferenceType)).map(x-> (ReferenceTypeFieldEntity)x).findFirst().orElse(null); if (fieldEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getData().getBlueprintFieldId(), ReferenceTypeFieldEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).typeIds(fieldEntity.getReferenceTypeId()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first(); @@ -1050,25 +1050,25 @@ public class DmpServiceImpl implements DmpService { } } - DmpReferenceEntity data = null; - List dmpReferenceEntities = dmpReferenceEntityByReferenceId.getOrDefault(referenceEntity.getId(), new ArrayList<>()); - for (DmpReferenceEntity dmpReferenceEntity : dmpReferenceEntities){ - DmpReferenceDataEntity dmpReferenceDataEntity = dmpReferenceDataEntityMap.getOrDefault(dmpReferenceEntity.getId(), new DmpReferenceDataEntity()); - if (Objects.equals(dmpReferenceDataEntity.getBlueprintFieldId(), model.getData().getBlueprintFieldId())){ - data = dmpReferenceEntity; + PlanReferenceEntity data = null; + List planReferenceEntities = planReferenceEntityByReferenceId.getOrDefault(referenceEntity.getId(), new ArrayList<>()); + for (PlanReferenceEntity planReferenceEntity : planReferenceEntities){ + PlanReferenceDataEntity planReferenceDataEntity = planReferenceDataEntityMap.getOrDefault(planReferenceEntity.getId(), new PlanReferenceDataEntity()); + if (Objects.equals(planReferenceDataEntity.getBlueprintFieldId(), model.getData().getBlueprintFieldId())){ + data = planReferenceEntity; break; } } boolean isUpdate = data != null; if (!isUpdate) { - data = new DmpReferenceEntity(); + data = new PlanReferenceEntity(); data.setId(UUID.randomUUID()); data.setReferenceId(referenceEntity.getId()); - data.setDmpId(dmpId); + data.setPlanId(planId); data.setCreatedAt(Instant.now()); data.setIsActive(IsActive.Active); - data.setData(this.jsonHandlingService.toJsonSafe(this.buildDmpReferenceDataEntity(model.getData()))); + data.setData(this.jsonHandlingService.toJsonSafe(this.buildPlanReferenceDataEntity(model.getData()))); } updatedCreatedIds.add(data.getId()); @@ -1077,33 +1077,33 @@ public class DmpServiceImpl implements DmpService { if (isUpdate) this.entityManager.merge(data); else this.entityManager.persist(data); } - List toDelete = dmpReferences.stream().filter(x-> updatedCreatedIds.stream().noneMatch(y-> y.equals(x.getId()))).collect(Collectors.toList()); - this.deleterFactory.deleter(DmpReferenceDeleter.class).delete(toDelete); + List toDelete = planReferences.stream().filter(x-> updatedCreatedIds.stream().noneMatch(y-> y.equals(x.getId()))).collect(Collectors.toList()); + this.deleterFactory.deleter(PlanReferenceDeleter.class).delete(toDelete); this.entityManager.flush(); } - private void patchAndSaveTemplates(UUID id, List models) throws InvalidApplicationException { + private void patchAndSaveTemplates(UUID id, List models) throws InvalidApplicationException { if (models == null) models = new ArrayList<>(); - List items = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active).dmpIds(id).collect(); + List items = this.queryFactory.query(PlanDescriptionTemplateQuery.class).isActive(IsActive.Active).planIds(id).collect(); List updatedCreatedIds = new ArrayList<>(); - for (DmpDescriptionTemplatePersist model : models) { - DmpDescriptionTemplateEntity data = items.stream().filter(x -> x.getDescriptionTemplateGroupId().equals(model.getDescriptionTemplateGroupId()) && x.getSectionId().equals(model.getSectionId())).findFirst().orElse(null); + for (PlanDescriptionTemplatePersist model : models) { + PlanDescriptionTemplateEntity data = items.stream().filter(x -> x.getDescriptionTemplateGroupId().equals(model.getDescriptionTemplateGroupId()) && x.getSectionId().equals(model.getSectionId())).findFirst().orElse(null); if (data == null){ - data = new DmpDescriptionTemplateEntity(); + data = new PlanDescriptionTemplateEntity(); data.setId(UUID.randomUUID()); data.setIsActive(IsActive.Active); data.setCreatedAt(Instant.now()); data.setUpdatedAt(Instant.now()); - data.setDmpId(id); + data.setPlanId(id); data.setSectionId(model.getSectionId()); data.setDescriptionTemplateGroupId(model.getDescriptionTemplateGroupId()); this.entityManager.persist(data); } updatedCreatedIds.add(data.getId()); } - List toDelete = items.stream().filter(x-> updatedCreatedIds.stream().noneMatch(y-> y.equals(x.getId()))).collect(Collectors.toList()); + List toDelete = items.stream().filter(x-> updatedCreatedIds.stream().noneMatch(y-> y.equals(x.getId()))).collect(Collectors.toList()); - this.deleterFactory.deleter(DmpDescriptionTemplateDeleter.class).delete(toDelete); + this.deleterFactory.deleter(PlanDescriptionTemplateDeleter.class).delete(toDelete); } private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist){ @@ -1119,8 +1119,8 @@ public class DmpServiceImpl implements DmpService { return data; } - private @NotNull DmpReferenceDataEntity buildDmpReferenceDataEntity(DmpReferenceDataPersist persist){ - DmpReferenceDataEntity data = new DmpReferenceDataEntity(); + private @NotNull PlanReferenceDataEntity buildPlanReferenceDataEntity(PlanReferenceDataPersist persist){ + PlanReferenceDataEntity data = new PlanReferenceDataEntity(); if (persist == null) return data; data.setBlueprintFieldId(persist.getBlueprintFieldId()); return data; @@ -1138,23 +1138,23 @@ public class DmpServiceImpl implements DmpService { } public void finalize(UUID id, List descriptionIds) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException { - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(id)), Permission.FinalizeDmp); - DmpEntity dmp = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.AllExceptPublic).ids(id).isActive(IsActive.Active).first(); + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(id)), Permission.FinalizePlan); + PlanEntity dmp = this.queryFactory.query(PlanQuery.class).authorize(AuthorizationFlags.AllExceptPublic).ids(id).isActive(IsActive.Active).first(); if (dmp == null){ - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); } - if (dmp.getStatus().equals(DmpStatus.Finalized)){ + if (dmp.getStatus().equals(PlanStatus.Finalized)){ throw new MyApplicationException("DMP is already finalized"); } - if (this.validate(id).getResult().equals(DmpValidationOutput.Invalid)){ + if (this.validate(id).getResult().equals(PlanValidationOutput.Invalid)){ throw new MyApplicationException("Dmp is invalid"); } List descriptions = this.queryFactory.query(DescriptionQuery.class) - .authorize(AuthorizationFlags.AllExceptPublic).dmpIds(id).isActive(IsActive.Active).collect(); + .authorize(AuthorizationFlags.AllExceptPublic).planIds(id).isActive(IsActive.Active).collect(); for (DescriptionEntity description: descriptions) { if (descriptionIds.contains(description.getId())){ @@ -1176,187 +1176,187 @@ public class DmpServiceImpl implements DmpService { } } - DmpStatus previousStatus = dmp.getStatus(); - dmp.setStatus(DmpStatus.Finalized); + PlanStatus previousStatus = dmp.getStatus(); + dmp.setStatus(PlanStatus.Finalized); dmp.setUpdatedAt(Instant.now()); dmp.setFinalizedAt(Instant.now()); this.updateVersionStatusAndSave(dmp, previousStatus, dmp.getStatus()); - dmp.setVersionStatus(DmpVersionStatus.Current); + dmp.setVersionStatus(PlanVersionStatus.Current); this.entityManager.merge(dmp); this.entityManager.flush(); - this.elasticService.persistDmp(dmp); + this.elasticService.persistPlan(dmp); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(dmp.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(dmp.getId()); this.sendNotification(dmp); } public void undoFinalize(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException { - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(id)), Permission.UndoFinalizeDmp); - DmpEntity dmp = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.AllExceptPublic).ids(id).isActive(IsActive.Active).firstAs(fields); + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(id)), Permission.UndoFinalizePlan); + PlanEntity dmp = this.queryFactory.query(PlanQuery.class).authorize(AuthorizationFlags.AllExceptPublic).ids(id).isActive(IsActive.Active).firstAs(fields); - if (dmp == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (dmp == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if (!dmp.getStatus().equals(DmpStatus.Finalized)) throw new MyApplicationException("DMP is already drafted"); + if (!dmp.getStatus().equals(PlanStatus.Finalized)) throw new MyApplicationException("DMP is already drafted"); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.DMP).entityIds(dmp.getId()).isActive(IsActive.Active); if (entityDoiQuery.count() > 0) throw new MyApplicationException("DMP is deposited"); - dmp.setStatus(DmpStatus.Draft); + dmp.setStatus(PlanStatus.Draft); dmp.setUpdatedAt(Instant.now()); this.entityManager.merge(dmp); this.entityManager.flush(); - this.updateVersionStatusAndSave(dmp, DmpStatus.Finalized, dmp.getStatus()); + this.updateVersionStatusAndSave(dmp, PlanStatus.Finalized, dmp.getStatus()); this.entityManager.flush(); - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking() - .versionStatuses(DmpVersionStatus.Previous) + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking() + .versionStatuses(PlanVersionStatus.Previous) .excludedIds(dmp.getId()) .isActive(IsActive.Active) .groupIds(dmp.getGroupId()); - dmpQuery.setOrder(new Ordering().addDescending(Dmp._version)); - DmpEntity previousDmp = dmpQuery.count() > 0 ? dmpQuery.collect().getFirst() : null; + planQuery.setOrder(new Ordering().addDescending(Plan._version)); + PlanEntity previousDmp = planQuery.count() > 0 ? planQuery.collect().getFirst() : null; if (previousDmp != null){ - if (previousDmp.getStatus().equals(DmpStatus.Finalized)) previousDmp.setVersionStatus(DmpVersionStatus.Current); - else previousDmp.setVersionStatus(DmpVersionStatus.NotFinalized); + if (previousDmp.getStatus().equals(PlanStatus.Finalized)) previousDmp.setVersionStatus(PlanVersionStatus.Current); + else previousDmp.setVersionStatus(PlanVersionStatus.NotFinalized); this.entityManager.merge(previousDmp); } this.entityManager.flush(); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(dmp.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(dmp.getId()); this.sendNotification(dmp); } - public DmpValidationResult validate(UUID id) throws InvalidApplicationException { + public PlanValidationResult validate(UUID id) throws InvalidApplicationException { - DmpEntity dmp = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id).isActive(IsActive.Active).first(); + PlanEntity dmp = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id).isActive(IsActive.Active).first(); - if (dmp == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (dmp == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpValidationResult dmpValidationResult = new DmpValidationResult(dmp.getId(), DmpValidationOutput.Invalid); + PlanValidationResult planValidationResult = new PlanValidationResult(dmp.getId(), PlanValidationOutput.Invalid); - DmpPersist.DmpPersistValidator validator = this.validatorFactory.validator(DmpPersist.DmpPersistValidator.class); + PlanPersist.PlanPersistValidator validator = this.validatorFactory.validator(PlanPersist.PlanPersistValidator.class); validator.validate(this.buildDmpPersist(dmp)); - if (validator.result().isValid()) dmpValidationResult.setResult(DmpValidationOutput.Valid); - else dmpValidationResult.setErrors(validator.result().getErrors().stream().map(ValidationFailure::getErrorMessage).collect(Collectors.toList())); + if (validator.result().isValid()) planValidationResult.setResult(PlanValidationOutput.Valid); + else planValidationResult.setErrors(validator.result().getErrors().stream().map(ValidationFailure::getErrorMessage).collect(Collectors.toList())); - return dmpValidationResult; + return planValidationResult; } // build persist - private @NotNull DmpPersist buildDmpPersist(DmpEntity data) throws InvalidApplicationException { - DmpPersist persist = new DmpPersist(); + private @NotNull PlanPersist buildDmpPersist(PlanEntity data) throws InvalidApplicationException { + PlanPersist persist = new PlanPersist(); if (data == null) return persist; - DmpBlueprintEntity dmpBlueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, data.getBlueprintId(), true); - if (dmpBlueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanBlueprintEntity planBlueprintEntity = this.entityManager.find(PlanBlueprintEntity.class, data.getBlueprintId(), true); + if (planBlueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); persist.setId(data.getId()); persist.setHash(data.getId().toString()); persist.setLabel(data.getLabel()); - persist.setStatus(DmpStatus.Finalized); + persist.setStatus(PlanStatus.Finalized); persist.setDescription(data.getDescription()); persist.setBlueprint(data.getBlueprintId()); persist.setAccessType(data.getAccessType()); persist.setLanguage(data.getLanguage()); - List dmpUserEntities = this.queryFactory.query(DmpUserQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).dmpIds(data.getId()).isActives(IsActive.Active).collect(); + List dmpUserEntities = this.queryFactory.query(PlanUserQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActives(IsActive.Active).collect(); if (!this.conventionService.isListNullOrEmpty(dmpUserEntities)){ persist.setUsers(new ArrayList<>()); - for (DmpUserEntity user: dmpUserEntities) { - persist.getUsers().add(this.buildDmpUserPersist(user)); + for (PlanUserEntity user: dmpUserEntities) { + persist.getUsers().add(this.buildPlanUserPersist(user)); } } - List dmpReferenceEntities = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).dmpIds(data.getId()).isActives(IsActive.Active).collect(); + List planReferenceEntities = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActives(IsActive.Active).collect(); - org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); + org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition()); - List dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).dmpIds(data.getId()).isActive(IsActive.Active).collect(); + List dmpDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(data.getId()).isActive(IsActive.Active).collect(); if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)){ persist.setDescriptionTemplates(new ArrayList<>()); - for (DmpDescriptionTemplateEntity descriptionTemplateEntity: dmpDescriptionTemplateEntities) { - persist.getDescriptionTemplates().add(this.buildDmpDescriptionTemplatePersists(descriptionTemplateEntity)); + for (PlanDescriptionTemplateEntity descriptionTemplateEntity: dmpDescriptionTemplateEntities) { + persist.getDescriptionTemplates().add(this.buildPlanDescriptionTemplatePersists(descriptionTemplateEntity)); } } - persist.setProperties(this.buildDmpPropertyDefinitionPersist( this.jsonHandlingService.fromJsonSafe(DmpPropertiesEntity.class, data.getProperties()), dmpReferenceEntities, definition.getSections())); + persist.setProperties(this.buildPlanPropertyDefinitionPersist( this.jsonHandlingService.fromJsonSafe(PlanPropertiesEntity.class, data.getProperties()), planReferenceEntities, definition.getSections())); return persist; } - private @NotNull DmpPropertiesPersist buildDmpPropertyDefinitionPersist(DmpPropertiesEntity data, List dmpReferenceEntities, List sectionEntities){ - DmpPropertiesPersist persist = new DmpPropertiesPersist(); + private @NotNull PlanPropertiesPersist buildPlanPropertyDefinitionPersist(PlanPropertiesEntity data, List planReferenceEntities, List sectionEntities){ + PlanPropertiesPersist persist = new PlanPropertiesPersist(); if (data == null) return persist; if (!this.conventionService.isListNullOrEmpty(data.getContacts())){ persist.setContacts(new ArrayList<>()); - for (DmpContactEntity contact: data.getContacts()) { - persist.getContacts().add(this.buildDmpContactPersist(contact)); + for (PlanContactEntity contact: data.getContacts()) { + persist.getContacts().add(this.buildPlanContactPersist(contact)); } } List referencesFromAllFields = new ArrayList<>(); - if (!this.conventionService.isListNullOrEmpty(dmpReferenceEntities)) { - referencesFromAllFields = this.queryFactory.query(ReferenceQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(dmpReferenceEntities.stream().map(DmpReferenceEntity::getReferenceId).collect(Collectors.toList())).isActive(IsActive.Active).collect(); + if (!this.conventionService.isListNullOrEmpty(planReferenceEntities)) { + referencesFromAllFields = this.queryFactory.query(ReferenceQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planReferenceEntities.stream().map(PlanReferenceEntity::getReferenceId).collect(Collectors.toList())).isActive(IsActive.Active).collect(); } - Map dmpBlueprintValues = new HashMap<>(); + Map planBlueprintValues = new HashMap<>(); if (!this.conventionService.isListNullOrEmpty(sectionEntities)){ for (SectionEntity sectionEntity: sectionEntities) { if (!this.conventionService.isListNullOrEmpty(sectionEntity.getFields())){ - for (org.opencdmp.commons.types.dmpblueprint.FieldEntity fieldEntity: sectionEntity.getFields()) { + for (org.opencdmp.commons.types.planblueprint.FieldEntity fieldEntity: sectionEntity.getFields()) { - if (!this.conventionService.isListNullOrEmpty(dmpReferenceEntities) && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType)) { + if (!this.conventionService.isListNullOrEmpty(planReferenceEntities) && fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.ReferenceType)) { List referencePersists = new ArrayList<>(); - for (DmpReferenceEntity dmpReferenceEntity : dmpReferenceEntities) { - DmpReferenceData referenceData = this.jsonHandlingService.fromJsonSafe(DmpReferenceData.class, dmpReferenceEntity.getData()); + for (PlanReferenceEntity planReferenceEntity : planReferenceEntities) { + PlanReferenceData referenceData = this.jsonHandlingService.fromJsonSafe(PlanReferenceData.class, planReferenceEntity.getData()); - ReferenceEntity reference = referencesFromAllFields.stream().filter(x -> x.getId().equals(dmpReferenceEntity.getReferenceId())).toList().getFirst(); + ReferenceEntity reference = referencesFromAllFields.stream().filter(x -> x.getId().equals(planReferenceEntity.getReferenceId())).toList().getFirst(); if (referenceData.getBlueprintFieldId().equals(fieldEntity.getId()) && reference != null) { referencePersists.add(this.buildReferencePersist(reference)); } // put references - dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null, null, referencePersists, ((ReferenceTypeFieldEntity)fieldEntity).getMultipleSelect())); + planBlueprintValues.put(fieldEntity.getId(), this.buildPlanBlueprintValuePersist(fieldEntity.getId(), null, null, null, referencePersists, ((ReferenceTypeFieldEntity)fieldEntity).getMultipleSelect())); } - } else if (!this.conventionService.isListNullOrEmpty(data.getDmpBlueprintValues())) { - for (DmpBlueprintValueEntity value : data.getDmpBlueprintValues()) { + } else if (!this.conventionService.isListNullOrEmpty(data.getPlanBlueprintValues())) { + for (PlanBlueprintValueEntity value : data.getPlanBlueprintValues()) { if (value.getFieldId().equals(fieldEntity.getId())) { if (value.getDateValue() != null) { - dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, value.getDateValue(), null, null,null)); + planBlueprintValues.put(fieldEntity.getId(), this.buildPlanBlueprintValuePersist(fieldEntity.getId(), null, value.getDateValue(), null, null,null)); } else if (value.getNumberValue() != null) { - dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null, value.getNumberValue(), null,null)); + planBlueprintValues.put(fieldEntity.getId(), this.buildPlanBlueprintValuePersist(fieldEntity.getId(), null, null, value.getNumberValue(), null,null)); } else if (!this.conventionService.isNullOrEmpty(value.getValue())) { - dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), value.getValue(), null,null,null,null)); + planBlueprintValues.put(fieldEntity.getId(), this.buildPlanBlueprintValuePersist(fieldEntity.getId(), value.getValue(), null,null,null,null)); } else { - dmpBlueprintValues.put(fieldEntity.getId(), null); + planBlueprintValues.put(fieldEntity.getId(), null); } } } } // fill fields with no values - if (dmpBlueprintValues.get(fieldEntity.getId()) == null){ - dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null, null,null,null)); + if (planBlueprintValues.get(fieldEntity.getId()) == null){ + planBlueprintValues.put(fieldEntity.getId(), this.buildPlanBlueprintValuePersist(fieldEntity.getId(), null, null, null,null,null)); } } } } - persist.setDmpBlueprintValues(dmpBlueprintValues); + persist.setPlanBlueprintValues(planBlueprintValues); } return persist; } - private @NotNull DmpContactPersist buildDmpContactPersist(DmpContactEntity data){ - DmpContactPersist persist = new DmpContactPersist(); + private @NotNull PlanContactPersist buildPlanContactPersist(PlanContactEntity data){ + PlanContactPersist persist = new PlanContactPersist(); if (data == null) return persist; persist.setEmail(data.getEmail()); @@ -1365,8 +1365,8 @@ public class DmpServiceImpl implements DmpService { return persist; } - private @NotNull DmpUserPersist buildDmpUserPersist(DmpUserEntity data){ - DmpUserPersist persist = new DmpUserPersist(); + private @NotNull PlanUserPersist buildPlanUserPersist(PlanUserEntity data){ + PlanUserPersist persist = new PlanUserPersist(); if (data == null) return persist; persist.setUser(data.getUserId()); @@ -1376,8 +1376,8 @@ public class DmpServiceImpl implements DmpService { return persist; } - private @NotNull DmpDescriptionTemplatePersist buildDmpDescriptionTemplatePersists(DmpDescriptionTemplateEntity data){ - DmpDescriptionTemplatePersist persist = new DmpDescriptionTemplatePersist(); + private @NotNull PlanDescriptionTemplatePersist buildPlanDescriptionTemplatePersists(PlanDescriptionTemplateEntity data){ + PlanDescriptionTemplatePersist persist = new PlanDescriptionTemplatePersist(); if (data == null) return persist; persist.setSectionId(data.getSectionId()); @@ -1402,8 +1402,8 @@ public class DmpServiceImpl implements DmpService { return persist; } - private @NotNull DmpBlueprintValuePersist buildDmpBlueprintValuePersist(UUID fieldId, String fieldValue, Instant dateValue, Double numberValue, List referencePersists, Boolean multipleSelect){ - DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist(); + private @NotNull PlanBlueprintValuePersist buildPlanBlueprintValuePersist(UUID fieldId, String fieldValue, Instant dateValue, Double numberValue, List referencePersists, Boolean multipleSelect){ + PlanBlueprintValuePersist persist = new PlanBlueprintValuePersist(); persist.setFieldId(fieldId); @@ -1423,24 +1423,24 @@ public class DmpServiceImpl implements DmpService { } // invites - public void inviteUserOrAssignUsers(UUID id, List users) throws InvalidApplicationException, JAXBException, IOException { + public void inviteUserOrAssignUsers(UUID id, List users) throws InvalidApplicationException, JAXBException, IOException { this.inviteUserOrAssignUsers(id, users, true); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(id); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(id); } - private List inviteUserOrAssignUsers(UUID id, List users, boolean persistUsers) throws InvalidApplicationException, JAXBException, IOException { - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(id)), Permission.InviteDmpUsers); + private List inviteUserOrAssignUsers(UUID id, List users, boolean persistUsers) throws InvalidApplicationException, JAXBException, IOException { + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(id)), Permission.InvitePlanUsers); - DmpEntity dmp = this.queryFactory.query(DmpQuery.class).disableTracking().ids(id).first(); + PlanEntity dmp = this.queryFactory.query(PlanQuery.class).disableTracking().ids(id).first(); if (dmp == null){ throw new InvalidApplicationException("Dmp does not exist!"); } - List existingUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking() - .dmpIds(dmp.getId()) + List existingUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking() + .planIds(dmp.getId()) .isActives(IsActive.Active) .collect(); @@ -1448,8 +1448,8 @@ public class DmpServiceImpl implements DmpService { throw new InvalidApplicationException("Dmp does not have users!"); } - List usersToAssign = new ArrayList<>(); - for (DmpUserPersist user :users) { + List usersToAssign = new ArrayList<>(); + for (PlanUserPersist user :users) { UUID userId = null; if (user.getUser() != null){ userId = user.getUser(); @@ -1462,11 +1462,11 @@ public class DmpServiceImpl implements DmpService { if (userId != null){ user.setUser(userId); usersToAssign.add(user); - if (this.userScope.getUserId() != userId && !existingUsers.stream().map(DmpUserEntity::getUserId).toList().contains(userId)){ - this.sendDmpInvitationExistingUser(user.getUser(), dmp, user.getRole()); + if (this.userScope.getUserId() != userId && !existingUsers.stream().map(PlanUserEntity::getUserId).toList().contains(userId)){ + this.sendPlanInvitationExistingUser(user.getUser(), dmp, user.getRole()); } }else if (user.getEmail() != null) { - this.sendDmpInvitationExternalUser(user.getEmail(),dmp, user.getRole()); + this.sendPlanInvitationExternalUser(user.getEmail(),dmp, user.getRole()); } } @@ -1474,14 +1474,14 @@ public class DmpServiceImpl implements DmpService { return usersToAssign; } - private void sendDmpInvitationExistingUser(UUID userId, DmpEntity dmp, DmpUserRole role) throws InvalidApplicationException { + private void sendPlanInvitationExistingUser(UUID userId, PlanEntity dmp, PlanUserRole role) throws InvalidApplicationException { UserEntity recipient = this.queryFactory.query(UserQuery.class).disableTracking().ids(userId).isActive(IsActive.Active).first(); if (recipient == null) throw new MyValidationException(this.errors.getDmpInactiveUser().getCode(), this.errors.getDmpInactiveUser().getMessage()); String email = this.queryFactory.query(UserContactInfoQuery.class).disableTracking().userIds(recipient.getId()).first().getValue(); - this.createDmpInvitationExistingUserEvent(recipient, dmp, role, email); + this.createPlanInvitationExistingUserEvent(recipient, dmp, role, email); } - private void createDmpInvitationExistingUserEvent(UserEntity recipient, DmpEntity dmp, DmpUserRole role, String email) throws InvalidApplicationException { + private void createPlanInvitationExistingUserEvent(UserEntity recipient, PlanEntity dmp, PlanUserRole role, String email) throws InvalidApplicationException { if (email == null) throw new MyValidationException(this.errors.getDmpMissingUserContactInfo().getCode(), this.errors.getDmpMissingUserContactInfo().getMessage()); @@ -1504,7 +1504,7 @@ public class DmpServiceImpl implements DmpService { this.eventHandler.handle(event); } - private void sendDmpInvitationExternalUser(String email, DmpEntity dmp, DmpUserRole role) throws JAXBException, InvalidApplicationException { + private void sendPlanInvitationExternalUser(String email, PlanEntity dmp, PlanUserRole role) throws JAXBException, InvalidApplicationException { String token = this.createActionConfirmation(email, dmp, role); NotifyIntegrationEvent event = new NotifyIntegrationEvent(); @@ -1529,12 +1529,12 @@ public class DmpServiceImpl implements DmpService { this.eventHandler.handle(event); } - private String createActionConfirmation(String email, DmpEntity dmp, DmpUserRole role) throws JAXBException, InvalidApplicationException { + private String createActionConfirmation(String email, PlanEntity dmp, PlanUserRole role) throws JAXBException, InvalidApplicationException { ActionConfirmationPersist persist = new ActionConfirmationPersist(); - persist.setType(ActionConfirmationType.DmpInvitation); + persist.setType(ActionConfirmationType.PlanInvitation); persist.setStatus(ActionConfirmationStatus.Requested); persist.setToken(UUID.randomUUID().toString()); - persist.setDmpInvitation(new DmpInvitationPersist(email, dmp.getId(), role)); + persist.setPlanInvitation(new PlanInvitationPersist(email, dmp.getId(), role)); persist.setExpiresAt(Instant.now().plusSeconds(this.notificationProperties.getEmailExpirationTimeSeconds())); this.validatorFactory.validator(ActionConfirmationPersist.ActionConfirmationPersistValidator.class).validateForce(persist); this.actionConfirmationService.persist(persist, null); @@ -1542,8 +1542,8 @@ public class DmpServiceImpl implements DmpService { return persist.getToken(); } - public void dmpInvitationAccept(String token) throws InvalidApplicationException { - ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.DmpInvitation).isActive(IsActive.Active).first(); + public void planInvitationAccept(String token) throws InvalidApplicationException { + ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.PlanInvitation).isActive(IsActive.Active).first(); if (action == null){ throw new MyApplicationException("Token does not exist!"); @@ -1555,35 +1555,35 @@ public class DmpServiceImpl implements DmpService { throw new MyApplicationException("Token has expired!"); } - DmpInvitationEntity dmpInvitation = this.xmlHandlingService.fromXmlSafe(DmpInvitationEntity.class, action.getData()); + PlanInvitationEntity planInvitation = this.xmlHandlingService.fromXmlSafe(PlanInvitationEntity.class, action.getData()); - DmpUserEntity data = new DmpUserEntity(); + PlanUserEntity data = new PlanUserEntity(); data.setId(UUID.randomUUID()); data.setIsActive(IsActive.Active); data.setCreatedAt(Instant.now()); data.setUpdatedAt(Instant.now()); - data.setRole(dmpInvitation.getRole()); + data.setRole(planInvitation.getRole()); data.setUserId(this.userScope.getUserIdSafe()); - data.setDmpId(dmpInvitation.getDmpId()); + data.setPlanId(planInvitation.getPlanId()); this.entityManager.persist(data); action.setStatus(ActionConfirmationStatus.Accepted); this.entityManager.merge(action); - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(dmpInvitation.getDmpId()); + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(planInvitation.getPlanId()); } //region Export @Override - public DmpImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { + public PlanImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { logger.debug(new MapLogEntry("export xml").And("id", id)); - if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDmp); - DmpEntity data = this.queryFactory.query(DmpQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.All).isActive(IsActive.Active).first(); - if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportPlan); + PlanEntity data = this.queryFactory.query(PlanQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.All).isActive(IsActive.Active).first(); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpPropertiesEntity definition = this.jsonHandlingService.fromJson(DmpPropertiesEntity.class, data.getProperties()); + PlanPropertiesEntity definition = this.jsonHandlingService.fromJson(PlanPropertiesEntity.class, data.getProperties()); return this.definitionXmlToExport(data, definition); } @@ -1591,19 +1591,19 @@ public class DmpServiceImpl implements DmpService { public ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { logger.debug(new MapLogEntry("export xml").And("id", id)); - this.authorizationService.authorizeForce(Permission.ExportDmp); - DmpEntity data = this.queryFactory.query(DmpQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.All).isActive(IsActive.Active).first(); - if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + this.authorizationService.authorizeForce(Permission.ExportPlan); + PlanEntity data = this.queryFactory.query(PlanQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.All).isActive(IsActive.Active).first(); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); String xml = this.xmlHandlingService.toXml(this.exportXmlEntity(data.getId(), false)); return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml"); } - private DmpImportExport definitionXmlToExport(DmpEntity data, DmpPropertiesEntity propertiesEntity) throws InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { - DmpBlueprintEntity blueprintEntity = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().ids(data.getBlueprintId()).authorize(AuthorizationFlags.All).first(); - if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + private PlanImportExport definitionXmlToExport(PlanEntity data, PlanPropertiesEntity propertiesEntity) throws InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { + PlanBlueprintEntity blueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(data.getBlueprintId()).authorize(AuthorizationFlags.All).first(); + if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpImportExport xml = new DmpImportExport(); + PlanImportExport xml = new PlanImportExport(); xml.setId(data.getId()); xml.setDescription(data.getDescription()); xml.setTitle(data.getLabel()); @@ -1612,19 +1612,19 @@ public class DmpServiceImpl implements DmpService { xml.setFinalizedAt(data.getFinalizedAt()); xml.setPublicAfter(data.getPublicAfter()); xml.setVersion(data.getVersion()); - xml.setContacts(this.dmpContactsToExport(propertiesEntity)); - xml.setUsers(this.dmpUsersToExport(data)); - xml.setBlueprint(this.dmpBlueprintService.getExportXmlEntity(blueprintEntity.getId(), true)); - xml.setDescriptionTemplates(this.dmpDescriptionTemplatesToExport(data)); - xml.setBlueprintValues(this.dmpBlueprintValuesToExport(propertiesEntity, blueprintEntity)); - xml.setReferences(this.dmpReferencesToExport(data)); + xml.setContacts(this.planContactsToExport(propertiesEntity)); + xml.setUsers(this.planUsersToExport(data)); + xml.setBlueprint(this.planBlueprintService.getExportXmlEntity(blueprintEntity.getId(), true)); + xml.setDescriptionTemplates(this.planDescriptionTemplatesToExport(data)); + xml.setBlueprintValues(this.planBlueprintValuesToExport(propertiesEntity, blueprintEntity)); + xml.setReferences(this.planReferencesToExport(data)); xml.setDescriptions(this.descriptionsToExport(data)); return xml; } - private List descriptionsToExport(DmpEntity data) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { - List descriptions = this.queryFactory.query(DescriptionQuery.class).disableTracking().dmpIds(data.getId()).authorize(AuthorizationFlags.All).dmpIds(data.getId()).isActive(IsActive.Active).collect(); + private List descriptionsToExport(PlanEntity data) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { + List descriptions = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(data.getId()).authorize(AuthorizationFlags.All).planIds(data.getId()).isActive(IsActive.Active).collect(); if (!this.conventionService.isListNullOrEmpty(descriptions)) { List descriptionImportExports = new LinkedList<>(); for (DescriptionEntity description : descriptions) { @@ -1635,26 +1635,26 @@ public class DmpServiceImpl implements DmpService { return null; } - private List dmpReferencesToExport(DmpEntity data){ - List dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).disableTracking().dmpIds(data.getId()).authorize(AuthorizationFlags.All).isActives(IsActive.Active).collect(); - if (!this.conventionService.isListNullOrEmpty(dmpReferences)) { - List references = this.queryFactory.query(ReferenceQuery.class).disableTracking().ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); + private List planReferencesToExport(PlanEntity data){ + List planReferences = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().planIds(data.getId()).authorize(AuthorizationFlags.All).isActives(IsActive.Active).collect(); + if (!this.conventionService.isListNullOrEmpty(planReferences)) { + List references = this.queryFactory.query(ReferenceQuery.class).disableTracking().ids(planReferences.stream().map(PlanReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); Map referenceEntityMap = references == null ? new HashMap<>() : references.stream().collect(Collectors.toMap(ReferenceEntity::getId, x-> x)); List referenceTypes = references == null ? new ArrayList<>() : this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(references.stream().map(ReferenceEntity::getTypeId).distinct().toList()).authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).collect(); Map referenceTypeEntityMap = referenceTypes == null ? new HashMap<>() : referenceTypes.stream().collect(Collectors.toMap(ReferenceTypeEntity::getId, x-> x)); - List dmpReferenceImportExports = new LinkedList<>(); - for (DmpReferenceEntity descriptionTemplateEntity : dmpReferences) { - dmpReferenceImportExports.add(this.dmpReferenceToExport(descriptionTemplateEntity, referenceEntityMap, referenceTypeEntityMap)); + List planReferenceImportExports = new LinkedList<>(); + for (PlanReferenceEntity descriptionTemplateEntity : planReferences) { + planReferenceImportExports.add(this.planReferenceToExport(descriptionTemplateEntity, referenceEntityMap, referenceTypeEntityMap)); } - return dmpReferenceImportExports; + return planReferenceImportExports; } return null; } - private DmpReferenceImportExport dmpReferenceToExport(DmpReferenceEntity entity, Map referenceEntityMap, Map referenceTypeEntityMap) { - DmpReferenceImportExport xml = new DmpReferenceImportExport(); + private PlanReferenceImportExport planReferenceToExport(PlanReferenceEntity entity, Map referenceEntityMap, Map referenceTypeEntityMap) { + PlanReferenceImportExport xml = new PlanReferenceImportExport(); if (entity == null) return xml; - DmpReferenceDataEntity referenceData = this.jsonHandlingService.fromJsonSafe(DmpReferenceDataEntity.class, entity.getData()); + PlanReferenceDataEntity referenceData = this.jsonHandlingService.fromJsonSafe(PlanReferenceDataEntity.class, entity.getData()); if (referenceData != null) xml.setFieldId(referenceData.getBlueprintFieldId()); ReferenceEntity reference = referenceEntityMap.getOrDefault(entity.getReferenceId(), null); @@ -1665,14 +1665,14 @@ public class DmpServiceImpl implements DmpService { xml.setSourceType(reference.getSourceType()); xml.setReference(reference.getReference()); ReferenceTypeEntity referenceType = referenceTypeEntityMap.getOrDefault(reference.getTypeId(), null); - if (referenceType != null) xml.setType(this.dmpReferenceTypeToExport(referenceType)); + if (referenceType != null) xml.setType(this.planReferenceTypeToExport(referenceType)); } return xml; } - private DmpReferenceTypeImportExport dmpReferenceTypeToExport(ReferenceTypeEntity entity) { - DmpReferenceTypeImportExport xml = new DmpReferenceTypeImportExport(); + private PlanReferenceTypeImportExport planReferenceTypeToExport(ReferenceTypeEntity entity) { + PlanReferenceTypeImportExport xml = new PlanReferenceTypeImportExport(); if (entity == null) return xml; xml.setId(entity.getId()); xml.setCode(entity.getCode()); @@ -1681,30 +1681,30 @@ public class DmpServiceImpl implements DmpService { return xml; } - private List dmpBlueprintValuesToExport(DmpPropertiesEntity propertiesEntity, DmpBlueprintEntity blueprintEntity){ - if (propertiesEntity != null && !this.conventionService.isListNullOrEmpty(propertiesEntity.getDmpBlueprintValues())) { - List dmpBlueprintValueImportExports = new LinkedList<>(); - org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, blueprintEntity.getDefinition()); - for (DmpBlueprintValueEntity dmpBlueprintValueEntity : propertiesEntity.getDmpBlueprintValues()) { - dmpBlueprintValueImportExports.add(this.dmpBlueprintValueToExport(dmpBlueprintValueEntity, definition)); + private List planBlueprintValuesToExport(PlanPropertiesEntity propertiesEntity, PlanBlueprintEntity blueprintEntity){ + if (propertiesEntity != null && !this.conventionService.isListNullOrEmpty(propertiesEntity.getPlanBlueprintValues())) { + List planBlueprintValueImportExports = new LinkedList<>(); + org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, blueprintEntity.getDefinition()); + for (PlanBlueprintValueEntity planBlueprintValueEntity : propertiesEntity.getPlanBlueprintValues()) { + planBlueprintValueImportExports.add(this.planBlueprintValueToExport(planBlueprintValueEntity, definition)); } - return dmpBlueprintValueImportExports; + return planBlueprintValueImportExports; } return null; } - private DmpBlueprintValueImportExport dmpBlueprintValueToExport(DmpBlueprintValueEntity entity, org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition) { - DmpBlueprintValueImportExport xml = new DmpBlueprintValueImportExport(); + private PlanBlueprintValueImportExport planBlueprintValueToExport(PlanBlueprintValueEntity entity, org.opencdmp.commons.types.planblueprint.DefinitionEntity definition) { + PlanBlueprintValueImportExport xml = new PlanBlueprintValueImportExport(); if (entity == null) return xml; - org.opencdmp.commons.types.dmpblueprint.FieldEntity fieldEntity = definition.getFieldById(entity.getFieldId()).stream().findFirst().orElse(null); + org.opencdmp.commons.types.planblueprint.FieldEntity fieldEntity = definition.getFieldById(entity.getFieldId()).stream().findFirst().orElse(null); if (fieldEntity == null) return xml; - if (fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)) { + if (fieldEntity.getCategory().equals(PlanBlueprintFieldCategory.Extra)) { ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity; - if (DmpBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){ + if (PlanBlueprintExtraFieldDataType.isDateType(extraFieldEntity.getType())){ xml.setDateValue(entity.getDateValue()); - } else if (DmpBlueprintExtraFieldDataType.isNumberType(extraFieldEntity.getType())){ + } else if (PlanBlueprintExtraFieldDataType.isNumberType(extraFieldEntity.getType())){ xml.setNumberValue(entity.getNumberValue()); } else { xml.setValue(entity.getValue()); @@ -1716,20 +1716,20 @@ public class DmpServiceImpl implements DmpService { } - private List dmpDescriptionTemplatesToExport(DmpEntity data){ - List dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.All).dmpIds(data.getId()).isActive(IsActive.Active).collect(); + private List planDescriptionTemplatesToExport(PlanEntity data){ + List dmpDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.All).planIds(data.getId()).isActive(IsActive.Active).collect(); if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)) { - List dmpDescriptionTemplateImportExports = new LinkedList<>(); - for (DmpDescriptionTemplateEntity descriptionTemplateEntity : dmpDescriptionTemplateEntities) { - dmpDescriptionTemplateImportExports.add(this.dmpDescriptionTemplateToExport(descriptionTemplateEntity)); + List planDescriptionTemplateImportExports = new LinkedList<>(); + for (PlanDescriptionTemplateEntity descriptionTemplateEntity : dmpDescriptionTemplateEntities) { + planDescriptionTemplateImportExports.add(this.planDescriptionTemplateToExport(descriptionTemplateEntity)); } - return dmpDescriptionTemplateImportExports; + return planDescriptionTemplateImportExports; } return null; } - private DmpDescriptionTemplateImportExport dmpDescriptionTemplateToExport(DmpDescriptionTemplateEntity entity) { - DmpDescriptionTemplateImportExport xml = new DmpDescriptionTemplateImportExport(); + private PlanDescriptionTemplateImportExport planDescriptionTemplateToExport(PlanDescriptionTemplateEntity entity) { + PlanDescriptionTemplateImportExport xml = new PlanDescriptionTemplateImportExport(); if (entity == null) return xml; xml.setDescriptionTemplateGroupId(entity.getDescriptionTemplateGroupId()); @@ -1738,22 +1738,22 @@ public class DmpServiceImpl implements DmpService { return xml; } - private ListdmpUsersToExport(DmpEntity data){ - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking().dmpIds(data.getId()).authorize(AuthorizationFlags.All).isActives(IsActive.Active).collect(); + private List planUsersToExport(PlanEntity data){ + List dmpUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(data.getId()).authorize(AuthorizationFlags.All).isActives(IsActive.Active).collect(); if (!this.conventionService.isListNullOrEmpty(dmpUsers)) { - List users = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpUsers.stream().map(DmpUserEntity::getUserId).distinct().toList()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); + List users = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpUsers.stream().map(PlanUserEntity::getUserId).distinct().toList()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).collect(); Map usersMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, x -> x)); - List dmpUserImportExports = new LinkedList<>(); - for (DmpUserEntity dmpUserEntity : dmpUsers) { - dmpUserImportExports.add(this.dmpUserToExport(dmpUserEntity, usersMap)); + List planUserImportExports = new LinkedList<>(); + for (PlanUserEntity planUserEntity : dmpUsers) { + planUserImportExports.add(this.planUserToExport(planUserEntity, usersMap)); } - return dmpUserImportExports; + return planUserImportExports; } return null; } - private DmpUserImportExport dmpUserToExport(DmpUserEntity entity, Map usersMap) { - DmpUserImportExport xml = new DmpUserImportExport(); + private PlanUserImportExport planUserToExport(PlanUserEntity entity, Map usersMap) { + PlanUserImportExport xml = new PlanUserImportExport(); if (entity == null) return xml; xml.setId(entity.getUserId()); @@ -1767,19 +1767,19 @@ public class DmpServiceImpl implements DmpService { return xml; } - private List dmpContactsToExport(DmpPropertiesEntity propertiesEntity){ + private List planContactsToExport(PlanPropertiesEntity propertiesEntity){ if (propertiesEntity != null && !this.conventionService.isListNullOrEmpty(propertiesEntity.getContacts())) { - List dmpContactImportExports = new LinkedList<>(); - for (DmpContactEntity contactEntity : propertiesEntity.getContacts()) { - dmpContactImportExports.add(this.dmpContactToExport(contactEntity)); + List planContactImportExports = new LinkedList<>(); + for (PlanContactEntity contactEntity : propertiesEntity.getContacts()) { + planContactImportExports.add(this.planContactToExport(contactEntity)); } - return dmpContactImportExports; + return planContactImportExports; } return null; } - private DmpContactImportExport dmpContactToExport(DmpContactEntity entity) { - DmpContactImportExport xml = new DmpContactImportExport(); + private PlanContactImportExport planContactToExport(PlanContactEntity entity) { + PlanContactImportExport xml = new PlanContactImportExport(); if (entity == null) return xml; xml.setEmail(entity.getEmail()); @@ -1794,149 +1794,149 @@ public class DmpServiceImpl implements DmpService { //region Import Xml - public Dmp importXml(byte[] bytes, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException { + public Plan importXml(byte[] bytes, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException { logger.debug(new MapLogEntry("import data").And("bytes", bytes).And("label", label).And("fields", fields)); - this.authorizationService.authorizeForce(Permission.NewDmp); - DmpImportExport dmpXml = this.xmlHandlingService.fromXml(DmpImportExport.class, new String(bytes, StandardCharsets.UTF_8)); + this.authorizationService.authorizeForce(Permission.NewPlan); + PlanImportExport planXml = this.xmlHandlingService.fromXml(PlanImportExport.class, new String(bytes, StandardCharsets.UTF_8)); - this.xmlEnsureDescriptionTemplates(dmpXml); + this.xmlEnsureDescriptionTemplates(planXml); - DmpPersist persist = new DmpPersist(); + PlanPersist persist = new PlanPersist(); persist.setLabel(label); - persist.setStatus(DmpStatus.Draft); - persist.setDescription(dmpXml.getDescription()); - persist.setAccessType(dmpXml.getAccess()); - persist.setLanguage(dmpXml.getLanguage()); - persist.setUsers(this.xmlToDmpUsersPersist(dmpXml)); //TODO ignore users not exists. by id betters solution - persist.setProperties(this.xmlToDmpPropertiesPersist(dmpXml)); - persist.setDescriptionTemplates(this.xmlDmpDescriptionTemplatesToPersist(dmpXml)); //TODO maybe we should create templates if not exists - persist.setBlueprint(this.xmlDmpBlueprintToPersist(dmpXml)); + persist.setStatus(PlanStatus.Draft); + persist.setDescription(planXml.getDescription()); + persist.setAccessType(planXml.getAccess()); + persist.setLanguage(planXml.getLanguage()); + persist.setUsers(this.xmlToPlanUsersPersist(planXml)); //TODO ignore users not exists. by id betters solution + persist.setProperties(this.xmlToPlanPropertiesPersist(planXml)); + persist.setDescriptionTemplates(this.xmlPlanDescriptionTemplatesToPersist(planXml)); //TODO maybe we should create templates if not exists + persist.setBlueprint(this.xmlPlanBlueprintToPersist(planXml)); - this.validatorFactory.validator(DmpPersist.DmpPersistValidator.class).validateForce(persist); + this.validatorFactory.validator(PlanPersist.PlanPersistValidator.class).validateForce(persist); - Dmp dmp = this.persist(persist, BaseFieldSet.build(fields, Dmp._id, Dmp._hash)); - if (dmp == null) throw new MyApplicationException("Error creating dmp"); + Plan plan = this.persist(persist, BaseFieldSet.build(fields, Plan._id, Plan._hash)); + if (plan == null) throw new MyApplicationException("Error creating dmp"); - if (!this.conventionService.isListNullOrEmpty(dmpXml.getDescriptions())){ - for (DescriptionImportExport description: dmpXml.getDescriptions()){ - this.descriptionService.importXml(description, dmp.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Dmp._description)) : null); + if (!this.conventionService.isListNullOrEmpty(planXml.getDescriptions())){ + for (DescriptionImportExport description: planXml.getDescriptions()){ + this.descriptionService.importXml(description, plan.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Plan._description)) : null); } } - return dmp; + return plan; } - private void xmlEnsureDescriptionTemplates(DmpImportExport dmpImportExport) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException { - if (!this.conventionService.isListNullOrEmpty(dmpImportExport.getDescriptions())){ - for (DescriptionImportExport descriptionXml: dmpImportExport.getDescriptions()) { + private void xmlEnsureDescriptionTemplates(PlanImportExport planImportExport) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException { + if (!this.conventionService.isListNullOrEmpty(planImportExport.getDescriptions())){ + for (DescriptionImportExport descriptionXml: planImportExport.getDescriptions()) { if (descriptionXml.getDescriptionTemplate() != null) { org.opencdmp.data.DescriptionTemplateEntity descriptionTemplateEntity = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(descriptionXml.getDescriptionTemplate().getId()).first(); if (descriptionTemplateEntity == null) descriptionTemplateEntity = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().groupIds(descriptionXml.getDescriptionTemplate().getGroupId()).versionStatuses(DescriptionTemplateVersionStatus.Current).isActive(IsActive.Active).statuses(DescriptionTemplateStatus.Finalized).first(); if (descriptionTemplateEntity == null) { - this.descriptionTemplateService.importXml(descriptionXml.getDescriptionTemplate(), null, descriptionXml.getDescriptionTemplate().getDescription(), new BaseFieldSet().ensure(DmpBlueprint._label).ensure(DmpBlueprint._hash)); + this.descriptionTemplateService.importXml(descriptionXml.getDescriptionTemplate(), null, descriptionXml.getDescriptionTemplate().getDescription(), new BaseFieldSet().ensure(PlanBlueprint._label).ensure(PlanBlueprint._hash)); } } } } } - private UUID xmlDmpBlueprintToPersist(DmpImportExport dmpXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException { - if (dmpXml.getBlueprint() != null){ - DmpBlueprintEntity dmpBlueprintEntity = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().ids(dmpXml.getBlueprint().getId()).first(); - if (dmpBlueprintEntity == null) dmpBlueprintEntity = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().groupIds(dmpXml.getBlueprint().getGroupId()).versionStatuses(DmpBlueprintVersionStatus.Current).isActive(IsActive.Active).statuses(DmpBlueprintStatus.Finalized).first(); - if (dmpBlueprintEntity != null){ - return dmpBlueprintEntity.getId(); + private UUID xmlPlanBlueprintToPersist(PlanImportExport planXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException { + if (planXml.getBlueprint() != null){ + PlanBlueprintEntity planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(planXml.getBlueprint().getId()).first(); + if (planBlueprintEntity == null) planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().groupIds(planXml.getBlueprint().getGroupId()).versionStatuses(PlanBlueprintVersionStatus.Current).isActive(IsActive.Active).statuses(PlanBlueprintStatus.Finalized).first(); + if (planBlueprintEntity != null){ + return planBlueprintEntity.getId(); } else { - DmpBlueprint persisted = this.dmpBlueprintService.importXml(dmpXml.getBlueprint(), null, dmpXml.getBlueprint().getLabel(), new BaseFieldSet().ensure(DmpBlueprint._label).ensure(DmpBlueprint._hash)); + PlanBlueprint persisted = this.planBlueprintService.importXml(planXml.getBlueprint(), null, planXml.getBlueprint().getLabel(), new BaseFieldSet().ensure(PlanBlueprint._label).ensure(PlanBlueprint._hash)); return persisted.getId(); } } return null; } - private DmpPropertiesPersist xmlToDmpPropertiesPersist(DmpImportExport importXml) { + private PlanPropertiesPersist xmlToPlanPropertiesPersist(PlanImportExport importXml) { if (importXml == null) return null; - DmpPropertiesPersist persist = new DmpPropertiesPersist(); - persist.setContacts(this.xmlToDmpContactPersist(importXml)); - persist.setDmpBlueprintValues(this.xmlToDmpBlueprintValuePersist(importXml)); + PlanPropertiesPersist persist = new PlanPropertiesPersist(); + persist.setContacts(this.xmlToPlanContactPersist(importXml)); + persist.setPlanBlueprintValues(this.xmlToPlanBlueprintValuePersist(importXml)); return persist; } - private Map xmlToDmpBlueprintValuePersist(DmpImportExport importXml){ - if (importXml.getBlueprint() != null && importXml.getBlueprint().getDmpBlueprintDefinition() != null && !this.conventionService.isListNullOrEmpty(importXml.getBlueprint().getDmpBlueprintDefinition().getSections())) { - Map dmpBlueprintValues = new HashMap<>(); - List sections = importXml.getBlueprint().getDmpBlueprintDefinition().getSections(); + private Map xmlToPlanBlueprintValuePersist(PlanImportExport importXml){ + if (importXml.getBlueprint() != null && importXml.getBlueprint().getPlanBlueprintDefinition() != null && !this.conventionService.isListNullOrEmpty(importXml.getBlueprint().getPlanBlueprintDefinition().getSections())) { + Map planBlueprintValues = new HashMap<>(); + List sections = importXml.getBlueprint().getPlanBlueprintDefinition().getSections(); if (!this.conventionService.isListNullOrEmpty(sections)){ - for (BlueprintSectionImportExport section : importXml.getBlueprint().getDmpBlueprintDefinition().getSections()) { - this.xmlToDmpBlueprintExtraFieldValuePersist(importXml, section, dmpBlueprintValues); - this.xmlToDmpBlueprintReferenceFieldValuePersist(importXml, section, dmpBlueprintValues); + for (BlueprintSectionImportExport section : importXml.getBlueprint().getPlanBlueprintDefinition().getSections()) { + this.xmlToPlanBlueprintExtraFieldValuePersist(importXml, section, planBlueprintValues); + this.xmlToPlanBlueprintReferenceFieldValuePersist(importXml, section, planBlueprintValues); } } - return dmpBlueprintValues; + return planBlueprintValues; } return null; } - private void xmlToDmpBlueprintExtraFieldValuePersist(DmpImportExport importXml, BlueprintSectionImportExport section, Map dmpBlueprintValues){ + private void xmlToPlanBlueprintExtraFieldValuePersist(PlanImportExport importXml, BlueprintSectionImportExport section, Map planBlueprintValues){ if (!this.conventionService.isListNullOrEmpty(section.getExtraFields()) && !this.conventionService.isListNullOrEmpty(importXml.getBlueprintValues())){ - for (DmpBlueprintValueImportExport value : importXml.getBlueprintValues()) { + for (PlanBlueprintValueImportExport value : importXml.getBlueprintValues()) { if (value.getFieldId() != null ) { - section.getExtraFields().stream().filter(x -> x.getId().equals(value.getFieldId())).findFirst().ifPresent(extraFieldImportExport -> dmpBlueprintValues.put(value.getFieldId(), this.xmlDmpBlueprintValueToPersist(value, extraFieldImportExport))); + section.getExtraFields().stream().filter(x -> x.getId().equals(value.getFieldId())).findFirst().ifPresent(extraFieldImportExport -> planBlueprintValues.put(value.getFieldId(), this.xmlPlanBlueprintValueToPersist(value, extraFieldImportExport))); } } } } - private void xmlToDmpBlueprintReferenceFieldValuePersist(DmpImportExport importXml, BlueprintSectionImportExport section, Map dmpBlueprintValues){ + private void xmlToPlanBlueprintReferenceFieldValuePersist(PlanImportExport importXml, BlueprintSectionImportExport section, Map planBlueprintValues){ if (!this.conventionService.isListNullOrEmpty(section.getReferenceFields()) && !this.conventionService.isListNullOrEmpty(importXml.getReferences())){ for (BlueprintReferenceTypeFieldImportExport blueprintReferenceTypeField : section.getReferenceFields()) { - List dmpReferencesByField = importXml.getReferences().stream().filter(x -> x.getFieldId().equals(blueprintReferenceTypeField.getId())).collect(Collectors.toList()); - if (!this.conventionService.isListNullOrEmpty(dmpReferencesByField)){ - dmpBlueprintValues.put(blueprintReferenceTypeField.getId(), this.xmlReferenceFieldToDmpBlueprintValuePersist(blueprintReferenceTypeField, dmpReferencesByField)); + List planReferencesByField = importXml.getReferences().stream().filter(x -> x.getFieldId().equals(blueprintReferenceTypeField.getId())).collect(Collectors.toList()); + if (!this.conventionService.isListNullOrEmpty(planReferencesByField)){ + planBlueprintValues.put(blueprintReferenceTypeField.getId(), this.xmlReferenceFieldToPlanBlueprintValuePersist(blueprintReferenceTypeField, planReferencesByField)); } } } } - private List xmlToDmpContactPersist(DmpImportExport importXml){ + private List xmlToPlanContactPersist(PlanImportExport importXml){ if (!this.conventionService.isListNullOrEmpty(importXml.getContacts())) { - List contacts = new ArrayList<>(); - for (DmpContactImportExport contact : importXml.getContacts()) { - contacts.add(this.xmlDmpContactToPersist(contact)); + List contacts = new ArrayList<>(); + for (PlanContactImportExport contact : importXml.getContacts()) { + contacts.add(this.xmlPlanContactToPersist(contact)); } return contacts; } return null; } - private DmpBlueprintValuePersist xmlReferenceFieldToDmpBlueprintValuePersist(BlueprintReferenceTypeFieldImportExport blueprintReferenceTypeFieldImportXml, List dmpReferencesImportXml) { - if (blueprintReferenceTypeFieldImportXml == null || this.conventionService.isListNullOrEmpty(dmpReferencesImportXml)) + private PlanBlueprintValuePersist xmlReferenceFieldToPlanBlueprintValuePersist(BlueprintReferenceTypeFieldImportExport blueprintReferenceTypeFieldImportXml, List planReferencesImportXml) { + if (blueprintReferenceTypeFieldImportXml == null || this.conventionService.isListNullOrEmpty(planReferencesImportXml)) return null; ReferenceTypeEntity referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).ids(blueprintReferenceTypeFieldImportXml.getReferenceTypeId()).first();//TODO: optimize if (referenceTypeEntity == null) referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).codes(blueprintReferenceTypeFieldImportXml.getReferenceTypeCode()).first(); if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{blueprintReferenceTypeFieldImportXml.getReferenceTypeCode(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist(); + PlanBlueprintValuePersist persist = new PlanBlueprintValuePersist(); persist.setFieldId(blueprintReferenceTypeFieldImportXml.getId()); if (blueprintReferenceTypeFieldImportXml.getMultipleSelect()){ List references = new ArrayList<>(); - for (DmpReferenceImportExport dmpReference : dmpReferencesImportXml) { - references.add(this.xmlDmpReferenceToReferencePersist(dmpReference, referenceTypeEntity)); + for (PlanReferenceImportExport planReference : planReferencesImportXml) { + references.add(this.xmlPlanReferenceToReferencePersist(planReference, referenceTypeEntity)); } persist.setReferences(references); } else { - persist.setReference(this.xmlDmpReferenceToReferencePersist(dmpReferencesImportXml.stream().findFirst().orElse(null), referenceTypeEntity)); + persist.setReference(this.xmlPlanReferenceToReferencePersist(planReferencesImportXml.stream().findFirst().orElse(null), referenceTypeEntity)); } return persist; } - private ReferencePersist xmlDmpReferenceToReferencePersist(DmpReferenceImportExport importXml, ReferenceTypeEntity referenceTypeEntity) { + private ReferencePersist xmlPlanReferenceToReferencePersist(PlanReferenceImportExport importXml, ReferenceTypeEntity referenceTypeEntity) { if (importXml == null) return null; @@ -1966,11 +1966,11 @@ public class DmpServiceImpl implements DmpService { return persist; } - private DmpBlueprintValuePersist xmlDmpBlueprintValueToPersist(DmpBlueprintValueImportExport importXml, BlueprintExtraFieldImportExport extraFieldImportExport) { + private PlanBlueprintValuePersist xmlPlanBlueprintValueToPersist(PlanBlueprintValueImportExport importXml, BlueprintExtraFieldImportExport extraFieldImportExport) { if (importXml == null || extraFieldImportExport == null) return null; - DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist(); + PlanBlueprintValuePersist persist = new PlanBlueprintValuePersist(); persist.setFieldId(importXml.getFieldId()); switch (extraFieldImportExport.getType()){ @@ -1983,22 +1983,22 @@ public class DmpServiceImpl implements DmpService { return persist; } - private List xmlDmpDescriptionTemplatesToPersist(DmpImportExport dmpXml){ - if (!this.conventionService.isListNullOrEmpty(dmpXml.getDescriptionTemplates())) { - List descriptionTemplates = new ArrayList<>(); - for (DmpDescriptionTemplateImportExport descriptionTemplate : dmpXml.getDescriptionTemplates()) { - descriptionTemplates.add(this.xmlDmpDescriptionTemplateToPersist(descriptionTemplate)); + private List xmlPlanDescriptionTemplatesToPersist(PlanImportExport planXml){ + if (!this.conventionService.isListNullOrEmpty(planXml.getDescriptionTemplates())) { + List descriptionTemplates = new ArrayList<>(); + for (PlanDescriptionTemplateImportExport descriptionTemplate : planXml.getDescriptionTemplates()) { + descriptionTemplates.add(this.xmlPlanDescriptionTemplateToPersist(descriptionTemplate)); } return descriptionTemplates.stream().filter(Objects::nonNull).toList(); } return null; } - private DmpDescriptionTemplatePersist xmlDmpDescriptionTemplateToPersist(DmpDescriptionTemplateImportExport importXml) { + private PlanDescriptionTemplatePersist xmlPlanDescriptionTemplateToPersist(PlanDescriptionTemplateImportExport importXml) { if (importXml == null) return null; - DmpDescriptionTemplatePersist persist = new DmpDescriptionTemplatePersist(); + PlanDescriptionTemplatePersist persist = new PlanDescriptionTemplatePersist(); persist.setDescriptionTemplateGroupId(importXml.getDescriptionTemplateGroupId()); persist.setSectionId(importXml.getSectionId()); @@ -2006,26 +2006,26 @@ public class DmpServiceImpl implements DmpService { return persist; } - private List xmlToDmpUsersPersist(DmpImportExport dmpXml){ - if (!this.conventionService.isListNullOrEmpty(dmpXml.getUsers())) { - List users = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpXml.getUsers().stream().map(DmpUserImportExport::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect(); + private List xmlToPlanUsersPersist(PlanImportExport planXml){ + if (!this.conventionService.isListNullOrEmpty(planXml.getUsers())) { + List users = this.queryFactory.query(UserQuery.class).disableTracking().ids(planXml.getUsers().stream().map(PlanUserImportExport::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect(); List userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList()); - List dmpUsers = new ArrayList<>(); - for (DmpUserImportExport user : dmpXml.getUsers()) { - dmpUsers.add(this.xmlDmpUserToPersist(user, userIds)); + List dmpUsers = new ArrayList<>(); + for (PlanUserImportExport user : planXml.getUsers()) { + dmpUsers.add(this.xmlPlanUserToPersist(user, userIds)); } return dmpUsers.stream().filter(Objects::nonNull).collect(Collectors.toList()); } return null; } - private DmpUserPersist xmlDmpUserToPersist(DmpUserImportExport importXml, List userIds) { + private PlanUserPersist xmlPlanUserToPersist(PlanUserImportExport importXml, List userIds) { if (importXml == null) return null; if (importXml.getId() != null && !userIds.isEmpty() && userIds.contains(importXml.getId())) { - DmpUserPersist persist = new DmpUserPersist(); + PlanUserPersist persist = new PlanUserPersist(); persist.setUser(importXml.getId()); persist.setRole(importXml.getRole()); @@ -2036,11 +2036,11 @@ public class DmpServiceImpl implements DmpService { return null; } - private DmpContactPersist xmlDmpContactToPersist(DmpContactImportExport importXml) { + private PlanContactPersist xmlPlanContactToPersist(PlanContactImportExport importXml) { if (importXml == null) return null; - DmpContactPersist persist = new DmpContactPersist(); + PlanContactPersist persist = new PlanContactPersist(); persist.setEmail(importXml.getEmail()); persist.setFirstName(importXml.getEmail()); @@ -2053,62 +2053,62 @@ public class DmpServiceImpl implements DmpService { //region Import RDA JSON - public PreprocessingDmpModel preprocessingDmp(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException { + public PreprocessingDmpModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException { return this.fileTransformerService.preprocessingDmp(fileId, repositoryId); } - public Dmp importJson(DmpCommonModelConfig dmpCommonModelConfig, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException { - logger.debug(new MapLogEntry("import data").And("file id", dmpCommonModelConfig.getFileId()).And("label", dmpCommonModelConfig.getLabel()).And("fields", fields)); + public Plan importJson(PlanCommonModelConfig planCommonModelConfig, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException { + logger.debug(new MapLogEntry("import data").And("file id", planCommonModelConfig.getFileId()).And("label", planCommonModelConfig.getLabel()).And("fields", fields)); - DmpModel model = this.fileTransformerService.importDmp(dmpCommonModelConfig); + DmpModel model = this.fileTransformerService.importDmp(planCommonModelConfig); if (model == null) throw new MyNotFoundException("Plan Import Error"); - DmpPersist persist = new DmpPersist(); + PlanPersist persist = new PlanPersist(); - persist.setLabel(dmpCommonModelConfig.getLabel()); - persist.setStatus(DmpStatus.Draft); + persist.setLabel(planCommonModelConfig.getLabel()); + persist.setStatus(PlanStatus.Draft); persist.setDescription(model.getDescription()); switch (model.getAccessType()) { - case Public -> persist.setAccessType(DmpAccessType.Public); - case Restricted -> persist.setAccessType(DmpAccessType.Restricted); + case Public -> persist.setAccessType(PlanAccessType.Public); + case Restricted -> persist.setAccessType(PlanAccessType.Restricted); default -> throw new MyApplicationException("Unrecognized Type " + model.getAccessType().getValue()); } persist.setLanguage(model.getLanguage()); persist.setUsers(this.commonModelToDmpUsersPersist(model)); persist.setBlueprint(this.commonModelDmpBlueprintToPersist(model)); - persist.setDescriptionTemplates(this.commonModelDmpDescriptionTemplatesToPersist(model)); //TODO maybe we should create templates if not exists + persist.setDescriptionTemplates(this.commonModelPlanDescriptionTemplatesToPersist(model)); //TODO maybe we should create templates if not exists persist.setProperties(this.commonModelDmpPropertiesToPersist(model)); - this.validatorFactory.validator(DmpPersist.DmpPersistValidator.class).validateForce(persist); - Dmp dmp = this.persist(persist, BaseFieldSet.build(fields, Dmp._id, Dmp._hash)); - if (dmp == null) throw new MyApplicationException("Error creating dmp"); + this.validatorFactory.validator(PlanPersist.PlanPersistValidator.class).validateForce(persist); + Plan plan = this.persist(persist, BaseFieldSet.build(fields, Plan._id, Plan._hash)); + if (plan == null) throw new MyApplicationException("Error creating dmp"); if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){ for (DescriptionModel description: model.getDescriptions()){ - this.descriptionService.importCommonModel(description, dmp.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Dmp._description)) : null); + this.descriptionService.importCommonModel(description, plan.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Plan._description)) : null); } } - return dmp; + return plan; } - private List commonModelDmpDescriptionTemplatesToPersist(DmpModel commonModel){ + private List commonModelPlanDescriptionTemplatesToPersist(DmpModel commonModel){ if (!this.conventionService.isListNullOrEmpty(commonModel.getDescriptionTemplates())) { - List descriptionTemplates = new ArrayList<>(); + List descriptionTemplates = new ArrayList<>(); for (DmpDescriptionTemplateModel descriptionTemplate : commonModel.getDescriptionTemplates()) { - descriptionTemplates.add(this.commonModelDmpDescriptionTemplateToPersist(descriptionTemplate)); + descriptionTemplates.add(this.commonModelPlanDescriptionTemplateToPersist(descriptionTemplate)); } return descriptionTemplates.stream().filter(Objects::nonNull).toList(); } return null; } - private DmpDescriptionTemplatePersist commonModelDmpDescriptionTemplateToPersist(DmpDescriptionTemplateModel commonModel) { + private PlanDescriptionTemplatePersist commonModelPlanDescriptionTemplateToPersist(DmpDescriptionTemplateModel commonModel) { if (commonModel == null) return null; - DmpDescriptionTemplatePersist persist = new DmpDescriptionTemplatePersist(); + PlanDescriptionTemplatePersist persist = new PlanDescriptionTemplatePersist(); persist.setDescriptionTemplateGroupId(commonModel.getDescriptionTemplateGroupId()); persist.setSectionId(commonModel.getSectionId()); @@ -2116,33 +2116,33 @@ public class DmpServiceImpl implements DmpService { return persist; } - private UUID commonModelDmpBlueprintToPersist(DmpModel dmpXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException { - if (dmpXml.getDmpBlueprint() != null){ - DmpBlueprintEntity dmpBlueprintEntity = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().ids(dmpXml.getDmpBlueprint().getId()).first(); - if (dmpBlueprintEntity == null) dmpBlueprintEntity = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().groupIds(dmpXml.getDmpBlueprint().getGroupId()).versionStatuses(DmpBlueprintVersionStatus.Current).isActive(IsActive.Active).statuses(DmpBlueprintStatus.Finalized).first(); - if (dmpBlueprintEntity != null){ - return dmpBlueprintEntity.getId(); + private UUID commonModelDmpBlueprintToPersist(DmpModel planXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException { + if (planXml.getDmpBlueprint() != null){ + PlanBlueprintEntity planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(planXml.getDmpBlueprint().getId()).first(); + if (planBlueprintEntity == null) planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().groupIds(planXml.getDmpBlueprint().getGroupId()).versionStatuses(PlanBlueprintVersionStatus.Current).isActive(IsActive.Active).statuses(PlanBlueprintStatus.Finalized).first(); + if (planBlueprintEntity != null){ + return planBlueprintEntity.getId(); } else { - DmpBlueprint persisted = this.dmpBlueprintService.importCommonModel(dmpXml.getDmpBlueprint(), new BaseFieldSet().ensure(DmpBlueprint._label).ensure(DmpBlueprint._hash)); + PlanBlueprint persisted = this.planBlueprintService.importCommonModel(planXml.getDmpBlueprint(), new BaseFieldSet().ensure(PlanBlueprint._label).ensure(PlanBlueprint._hash)); return persisted.getId(); } } return null; } - private DmpPropertiesPersist commonModelDmpPropertiesToPersist(DmpModel commonModel) { + private PlanPropertiesPersist commonModelDmpPropertiesToPersist(DmpModel commonModel) { if (commonModel == null || commonModel.getProperties() == null) return null; - DmpPropertiesPersist persist = new DmpPropertiesPersist(); + PlanPropertiesPersist persist = new PlanPropertiesPersist(); persist.setContacts(this.commonModelToDmpContactPersist(commonModel.getProperties())); - persist.setDmpBlueprintValues(this.commonModelToDmpBlueprintValuePersist(commonModel)); + persist.setPlanBlueprintValues(this.commonModelToDmpBlueprintValuePersist(commonModel)); return persist; } - private List commonModelToDmpContactPersist(DmpPropertiesModel commonModel){ + private List commonModelToDmpContactPersist(DmpPropertiesModel commonModel){ if (!this.conventionService.isListNullOrEmpty(commonModel.getContacts())) { - List contacts = new ArrayList<>(); + List contacts = new ArrayList<>(); for (DmpContactModel contact : commonModel.getContacts()) { contacts.add(this.commonModelDmpContactToPersist(contact)); } @@ -2151,9 +2151,9 @@ public class DmpServiceImpl implements DmpService { return null; } - private Map commonModelToDmpBlueprintValuePersist(DmpModel commonModel){ + private Map commonModelToDmpBlueprintValuePersist(DmpModel commonModel){ if (commonModel.getDmpBlueprint() != null && commonModel.getDmpBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(commonModel.getDmpBlueprint().getDefinition().getSections())) { - Map dmpBlueprintValues = new HashMap<>(); + Map dmpBlueprintValues = new HashMap<>(); List sections = commonModel.getDmpBlueprint().getDefinition().getSections(); if (!this.conventionService.isListNullOrEmpty(sections)){ for (SectionModel section : sections) { @@ -2183,7 +2183,7 @@ public class DmpServiceImpl implements DmpService { return null; } - private DmpBlueprintValuePersist commonModelDmpReferenceFieldToDmpBlueprintValuePersist(ReferenceTypeFieldModel model, List dmpReferences) { + private PlanBlueprintValuePersist commonModelDmpReferenceFieldToDmpBlueprintValuePersist(ReferenceTypeFieldModel model, List dmpReferences) { if (model == null || this.conventionService.isListNullOrEmpty(dmpReferences) || model.getReferenceType() == null) return null; @@ -2191,7 +2191,7 @@ public class DmpServiceImpl implements DmpService { if (referenceTypeEntity == null) referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).codes(model.getReferenceType().getCode()).first(); if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getReferenceType().getCode(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist(); + PlanBlueprintValuePersist persist = new PlanBlueprintValuePersist(); persist.setFieldId(model.getId()); if (model.getMultipleSelect()){ @@ -2239,10 +2239,10 @@ public class DmpServiceImpl implements DmpService { return persist; } - private DmpBlueprintValuePersist commonModelDmpBlueprintValueToPersist(DmpBlueprintValueModel commonModel, ExtraFieldModel extraFieldModel) { + private PlanBlueprintValuePersist commonModelDmpBlueprintValueToPersist(DmpBlueprintValueModel commonModel, ExtraFieldModel extraFieldModel) { if (commonModel == null || extraFieldModel == null) return null; - DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist(); + PlanBlueprintValuePersist persist = new PlanBlueprintValuePersist(); persist.setFieldId(commonModel.getFieldId()); switch (extraFieldModel.getDataType()){ @@ -2255,12 +2255,12 @@ public class DmpServiceImpl implements DmpService { return persist; } - private List commonModelToDmpUsersPersist(DmpModel commonModel){ + private List commonModelToDmpUsersPersist(DmpModel commonModel){ if (!this.conventionService.isListNullOrEmpty(commonModel.getUsers())) { List users = this.queryFactory.query(UserQuery.class).disableTracking().ids(commonModel.getUsers().stream().map(DmpUserModel::getUser).filter(Objects::nonNull).map(UserModel::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect(); List userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList()); - List dmpUsers = new ArrayList<>(); + List dmpUsers = new ArrayList<>(); for (DmpUserModel user : commonModel.getUsers()) { dmpUsers.add(this.commonModelDmpUserToPersist(user, userIds)); } @@ -2270,20 +2270,20 @@ public class DmpServiceImpl implements DmpService { } - private DmpUserPersist commonModelDmpUserToPersist(DmpUserModel commonModel, List userIds) { + private PlanUserPersist commonModelDmpUserToPersist(DmpUserModel commonModel, List userIds) { if (commonModel == null) return null; if (commonModel.getUser() != null && commonModel.getUser().getId() != null && !userIds.isEmpty() && userIds.contains(commonModel.getUser().getId())) { - DmpUserPersist persist = new DmpUserPersist(); + PlanUserPersist persist = new PlanUserPersist(); persist.setUser(commonModel.getUser().getId()); switch (commonModel.getRole()){ - case Owner -> persist.setRole(DmpUserRole.Owner); - case Viewer -> persist.setRole(DmpUserRole.Viewer); - case DescriptionContributor -> persist.setRole(DmpUserRole.DescriptionContributor); - case Reviewer -> persist.setRole(DmpUserRole.Reviewer); + case Owner -> persist.setRole(PlanUserRole.Owner); + case Viewer -> persist.setRole(PlanUserRole.Viewer); + case DescriptionContributor -> persist.setRole(PlanUserRole.DescriptionContributor); + case Reviewer -> persist.setRole(PlanUserRole.Reviewer); default -> throw new MyApplicationException("Unrecognized Type " + commonModel.getRole().getValue()); } persist.setSectionId(commonModel.getSectionId()); @@ -2293,11 +2293,11 @@ public class DmpServiceImpl implements DmpService { return null; } - private DmpContactPersist commonModelDmpContactToPersist(DmpContactModel commonModel) { + private PlanContactPersist commonModelDmpContactToPersist(DmpContactModel commonModel) { if (commonModel == null) return null; - DmpContactPersist persist = new DmpContactPersist(); + PlanContactPersist persist = new PlanContactPersist(); persist.setEmail(commonModel.getEmail()); persist.setFirstName(commonModel.getEmail()); diff --git a/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintService.java b/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintService.java new file mode 100644 index 000000000..ceb24ad6c --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintService.java @@ -0,0 +1,47 @@ +package org.opencdmp.service.planblueprint; + +import com.fasterxml.jackson.core.JsonProcessingException; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.FieldSet; +import jakarta.xml.bind.JAXBException; +import org.opencdmp.commonmodels.models.dmpblueprint.DmpBlueprintModel; +import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType; +import org.opencdmp.commons.types.planblueprint.importexport.BlueprintImportExport; +import org.opencdmp.data.PlanBlueprintEntity; +import org.opencdmp.model.planblueprint.PlanBlueprint; +import org.opencdmp.model.persist.PlanBlueprintPersist; +import org.opencdmp.model.persist.NewVersionPlanBlueprintPersist; +import org.springframework.http.ResponseEntity; +import org.xml.sax.SAXException; + +import javax.management.InvalidApplicationException; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import java.io.IOException; +import java.util.UUID; + +public interface PlanBlueprintService { + + PlanBlueprint persist(PlanBlueprintPersist model, UUID groupId, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException; + + void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; + boolean fieldInBlueprint(PlanBlueprintEntity planBlueprintEntity, PlanBlueprintSystemFieldType type); + + boolean fieldInBlueprint(UUID id, PlanBlueprintSystemFieldType type) throws InvalidApplicationException; + + PlanBlueprint buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException; + + PlanBlueprint createNewVersion(NewVersionPlanBlueprintPersist model, FieldSet fieldSet) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException; + + BlueprintImportExport getExportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException; + + ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException; + + PlanBlueprint importXml(BlueprintImportExport dmpDefinition, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; + + PlanBlueprint importXml(byte[] bytes, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; + PlanBlueprint importCommonModel(DmpBlueprintModel planDefinition, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; +} diff --git a/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintServiceImpl.java similarity index 75% rename from backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintServiceImpl.java rename to backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintServiceImpl.java index f51ec06d1..fcf2b01de 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/planblueprint/PlanBlueprintServiceImpl.java @@ -1,4 +1,4 @@ -package org.opencdmp.service.dmpblueprint; +package org.opencdmp.service.planblueprint; import com.fasterxml.jackson.core.JsonProcessingException; import gr.cite.commons.web.authz.service.AuthorizationService; @@ -22,28 +22,28 @@ import org.opencdmp.commonmodels.models.dmpblueprint.*; import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.enums.*; import org.opencdmp.commons.scope.tenant.TenantScope; -import org.opencdmp.commons.types.dmpblueprint.*; -import org.opencdmp.commons.types.dmpblueprint.importexport.*; +import org.opencdmp.commons.types.planblueprint.*; +import org.opencdmp.commons.types.planblueprint.importexport.*; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.DmpBlueprintEntity; +import org.opencdmp.data.PlanBlueprintEntity; import org.opencdmp.data.PrefillingSourceEntity; import org.opencdmp.data.ReferenceTypeEntity; import org.opencdmp.data.TenantEntityManager; import org.opencdmp.errorcode.ErrorThesaurusProperties; -import org.opencdmp.model.builder.dmpblueprint.DmpBlueprintBuilder; -import org.opencdmp.model.deleter.DmpBlueprintDeleter; +import org.opencdmp.model.builder.planblueprint.PlanBlueprintBuilder; +import org.opencdmp.model.deleter.PlanBlueprintDeleter; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmpblueprint.Definition; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; -import org.opencdmp.model.dmpblueprint.Field; -import org.opencdmp.model.dmpblueprint.Section; -import org.opencdmp.model.persist.DmpBlueprintPersist; -import org.opencdmp.model.persist.NewVersionDmpBlueprintPersist; +import org.opencdmp.model.planblueprint.Definition; +import org.opencdmp.model.planblueprint.PlanBlueprint; +import org.opencdmp.model.planblueprint.Field; +import org.opencdmp.model.planblueprint.Section; +import org.opencdmp.model.persist.PlanBlueprintPersist; +import org.opencdmp.model.persist.NewVersionPlanBlueprintPersist; import org.opencdmp.model.persist.dmpblueprintdefinition.*; import org.opencdmp.model.prefillingsource.PrefillingSource; import org.opencdmp.model.referencetype.ReferenceType; import org.opencdmp.query.DescriptionTemplateQuery; -import org.opencdmp.query.DmpBlueprintQuery; +import org.opencdmp.query.PlanBlueprintQuery; import org.opencdmp.query.PrefillingSourceQuery; import org.opencdmp.query.ReferenceTypeQuery; import org.opencdmp.service.responseutils.ResponseUtilsService; @@ -64,9 +64,9 @@ import java.time.Instant; import java.util.*; @Service -public class DmpBlueprintServiceImpl implements DmpBlueprintService { +public class PlanBlueprintServiceImpl implements PlanBlueprintService { - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintServiceImpl.class)); private final TenantEntityManager entityManager; @@ -91,7 +91,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { private final ValidatorFactory validatorFactory; private final TenantScope tenantScope; @Autowired - public DmpBlueprintServiceImpl( + public PlanBlueprintServiceImpl( TenantEntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, @@ -118,29 +118,29 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { //region Persist - public DmpBlueprint persist(DmpBlueprintPersist model, UUID groupId, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException { + public PlanBlueprint persist(PlanBlueprintPersist model, UUID groupId, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException { logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields)); - this.authorizationService.authorizeForce(Permission.EditDmpBlueprint); + this.authorizationService.authorizeForce(Permission.EditPlanBlueprint); Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); - DmpBlueprintEntity data; + PlanBlueprintEntity data; if (isUpdate) { - data = this.entityManager.find(DmpBlueprintEntity.class, model.getId()); + data = this.entityManager.find(PlanBlueprintEntity.class, model.getId()); if (data == null) - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); - if (data.getStatus().equals(DmpBlueprintStatus.Finalized)) + if (data.getStatus().equals(PlanBlueprintStatus.Finalized)) throw new MyForbiddenException("Cannot update finalized blueprint"); } else { - data = new DmpBlueprintEntity(); + data = new PlanBlueprintEntity(); data.setId(UUID.randomUUID()); - data.setStatus(DmpBlueprintStatus.Draft); + data.setStatus(PlanBlueprintStatus.Draft); data.setGroupId(groupId != null ? groupId : UUID.randomUUID()); data.setVersion((short) 1); - data.setVersionStatus(DmpBlueprintVersionStatus.NotFinalized); + data.setVersionStatus(PlanBlueprintVersionStatus.NotFinalized); data.setCreatedAt(Instant.now()); data.setIsActive(IsActive.Active); long activeDescriptionTemplatesForTheGroup = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking() @@ -151,7 +151,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { } if (groupId != null && !data.getGroupId().equals(groupId)) throw new MyApplicationException("Can not change description template group id"); - DmpBlueprintStatus previousStatus = data.getStatus(); + PlanBlueprintStatus previousStatus = data.getStatus(); if (model.getDefinition() != null && model.getDefinition().getSections().stream().noneMatch(SectionPersist::getHasTemplates)) { throw new MyValidationException(this.errors.getDmpBlueprintHasNoDescriptionTemplates().getCode(), this.errors.getDmpBlueprintHasNoDescriptionTemplates().getMessage()); @@ -173,32 +173,32 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { this.entityManager.flush(); - return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fields, DmpBlueprint._id), data); + return this.builderFactory.builder(PlanBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fields, PlanBlueprint._id), data); } - private void updateVersionStatusAndSave(DmpBlueprintEntity data, DmpBlueprintStatus previousStatus, DmpBlueprintStatus newStatus) throws InvalidApplicationException { + private void updateVersionStatusAndSave(PlanBlueprintEntity data, PlanBlueprintStatus previousStatus, PlanBlueprintStatus newStatus) throws InvalidApplicationException { if (previousStatus.equals(newStatus)) return; - if (previousStatus.equals(DmpBlueprintStatus.Finalized)) + if (previousStatus.equals(PlanBlueprintStatus.Finalized)) throw new MyForbiddenException("Can not update finalized blueprint"); - if (newStatus.equals(DmpBlueprintStatus.Finalized)) { - List latestVersionDmpBlueprints = this.queryFactory.query(DmpBlueprintQuery.class) + if (newStatus.equals(PlanBlueprintStatus.Finalized)) { + List latestVersionDmpBlueprints = this.queryFactory.query(PlanBlueprintQuery.class) .disableTracking() - .versionStatuses(DmpBlueprintVersionStatus.Current) + .versionStatuses(PlanBlueprintVersionStatus.Current) .isActive(IsActive.Active) .groupIds(data.getGroupId()) .collect(); if (latestVersionDmpBlueprints.size() > 1) throw new MyValidationException(this.errors.getMultipleDmpVersionsNotSupported().getCode(), this.errors.getMultipleDmpVersionsNotSupported().getMessage()); - DmpBlueprintEntity oldDmpBlueprintEntity = latestVersionDmpBlueprints.stream().findFirst().orElse(null); + PlanBlueprintEntity oldPlanBlueprintEntity = latestVersionDmpBlueprints.stream().findFirst().orElse(null); - data.setVersionStatus(DmpBlueprintVersionStatus.Current); + data.setVersionStatus(PlanBlueprintVersionStatus.Current); - if (oldDmpBlueprintEntity != null) { - data.setVersion((short) (oldDmpBlueprintEntity.getVersion() + 1)); + if (oldPlanBlueprintEntity != null) { + data.setVersion((short) (oldPlanBlueprintEntity.getVersion() + 1)); - oldDmpBlueprintEntity.setVersionStatus(DmpBlueprintVersionStatus.Previous); - this.entityManager.merge(oldDmpBlueprintEntity); + oldPlanBlueprintEntity.setVersionStatus(PlanBlueprintVersionStatus.Previous); + this.entityManager.merge(oldPlanBlueprintEntity); } else { data.setVersion((short) 1); } @@ -305,18 +305,18 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { logger.debug("deleting : {}", id); - this.authorizationService.authorizeForce(Permission.DeleteDmpBlueprint); + this.authorizationService.authorizeForce(Permission.DeletePlanBlueprint); - this.deleterFactory.deleter(DmpBlueprintDeleter.class).deleteAndSaveByIds(List.of(id)); + this.deleterFactory.deleter(PlanBlueprintDeleter.class).deleteAndSaveByIds(List.of(id)); } //endregion //region FieldInBlueprint - public boolean fieldInBlueprint(DmpBlueprintEntity dmpBlueprintEntity, DmpBlueprintSystemFieldType type) { + public boolean fieldInBlueprint(PlanBlueprintEntity planBlueprintEntity, PlanBlueprintSystemFieldType type) { - DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); + DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, planBlueprintEntity.getDefinition()); if (definition == null || definition.getSections() == null) return false; @@ -324,7 +324,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { if (section.getFields() == null) continue; for (FieldEntity field : section.getFields()) { - if (field.getCategory().equals(DmpBlueprintFieldCategory.System)) { + if (field.getCategory().equals(PlanBlueprintFieldCategory.System)) { SystemFieldEntity systemField = (SystemFieldEntity) field; if (systemField.getType().equals(type)) { return true; @@ -335,10 +335,10 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { return false; } - public boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type) throws InvalidApplicationException { - DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, id, true); + public boolean fieldInBlueprint(UUID id, PlanBlueprintSystemFieldType type) throws InvalidApplicationException { + PlanBlueprintEntity data = this.entityManager.find(PlanBlueprintEntity.class, id, true); if (data == null) - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); return this.fieldInBlueprint(data, type); } @@ -346,20 +346,20 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { //region Clone - public DmpBlueprint buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException { + public PlanBlueprint buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException { logger.debug(new MapLogEntry("persisting data").And("id", id).And("fields", fields)); - this.authorizationService.authorizeForce(Permission.CloneDmpBlueprint); + this.authorizationService.authorizeForce(Permission.ClonePlanBlueprint); - DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id); - DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fields, query.firstAs(fields)); + PlanBlueprintQuery query = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id); + PlanBlueprint model = this.builderFactory.builder(PlanBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fields, query.firstAs(fields)); if (model == null) - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); model.setLabel(model.getLabel() + " new "); model.setId(null); model.setHash(null); - model.setStatus(DmpBlueprintStatus.Draft); + model.setStatus(PlanBlueprintStatus.Draft); this.reassignDefinition(model.getDefinition()); return model; @@ -399,45 +399,45 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { //region NewVersion @Override - public DmpBlueprint createNewVersion(NewVersionDmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException { + public PlanBlueprint createNewVersion(NewVersionPlanBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException { logger.debug(new MapLogEntry("persisting data dmpBlueprint").And("model", model).And("fields", fields)); - this.authorizationService.authorizeForce(Permission.CreateNewVersionDmpBlueprint); + this.authorizationService.authorizeForce(Permission.CreateNewVersionPlanBlueprint); - DmpBlueprintEntity oldDmpBlueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, model.getId(), true); - if (oldDmpBlueprintEntity == null) - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); - if (!this.conventionService.hashValue(oldDmpBlueprintEntity.getUpdatedAt()).equals(model.getHash())) + PlanBlueprintEntity oldPlanBlueprintEntity = this.entityManager.find(PlanBlueprintEntity.class, model.getId(), true); + if (oldPlanBlueprintEntity == null) + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (!this.conventionService.hashValue(oldPlanBlueprintEntity.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); - if (!this.tenantScope.isSet() || !Objects.equals(oldDmpBlueprintEntity.getTenantId(), this.tenantScope.getTenant())) throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage()); + if (!this.tenantScope.isSet() || !Objects.equals(oldPlanBlueprintEntity.getTenantId(), this.tenantScope.getTenant())) throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage()); - List latestVersionDmpBlueprints = this.queryFactory.query(DmpBlueprintQuery.class) + List latestVersionDmpBlueprints = this.queryFactory.query(PlanBlueprintQuery.class) .disableTracking() - .versionStatuses(DmpBlueprintVersionStatus.Current) + .versionStatuses(PlanBlueprintVersionStatus.Current) .isActive(IsActive.Active) - .statuses(DmpBlueprintStatus.Finalized) - .groupIds(oldDmpBlueprintEntity.getGroupId()) + .statuses(PlanBlueprintStatus.Finalized) + .groupIds(oldPlanBlueprintEntity.getGroupId()) .collect(); if (latestVersionDmpBlueprints.isEmpty()) throw new MyValidationException(this.errors.getDmpIsNotFinalized().getCode(), this.errors.getDmpIsNotFinalized().getMessage()); if (latestVersionDmpBlueprints.size() > 1) throw new MyValidationException(this.errors.getMultipleDmpVersionsNotSupported().getCode(), this.errors.getMultipleDmpVersionsNotSupported().getMessage()); - if (!latestVersionDmpBlueprints.getFirst().getVersion().equals(oldDmpBlueprintEntity.getVersion())) throw new MyValidationException(this.errors.getDmpBlueprintNewVersionConflict().getCode(), this.errors.getDmpBlueprintNewVersionConflict().getMessage()); - Long notFinalizedCount = this.queryFactory.query(DmpBlueprintQuery.class) + if (!latestVersionDmpBlueprints.getFirst().getVersion().equals(oldPlanBlueprintEntity.getVersion())) throw new MyValidationException(this.errors.getDmpBlueprintNewVersionConflict().getCode(), this.errors.getDmpBlueprintNewVersionConflict().getMessage()); + Long notFinalizedCount = this.queryFactory.query(PlanBlueprintQuery.class) .disableTracking() - .versionStatuses(DmpBlueprintVersionStatus.NotFinalized) - .groupIds(oldDmpBlueprintEntity.getGroupId()) + .versionStatuses(PlanBlueprintVersionStatus.NotFinalized) + .groupIds(oldPlanBlueprintEntity.getGroupId()) .isActive(IsActive.Active) .count(); if (notFinalizedCount > 0) throw new MyValidationException(this.errors.getDmpBlueprintNewVersionAlreadyCreatedDraft().getCode(), this.errors.getDmpBlueprintNewVersionAlreadyCreatedDraft().getMessage()); - DmpBlueprintEntity data = new DmpBlueprintEntity(); + PlanBlueprintEntity data = new PlanBlueprintEntity(); data.setId(UUID.randomUUID()); data.setLabel(model.getLabel()); - data.setStatus(DmpBlueprintStatus.Draft); + data.setStatus(PlanBlueprintStatus.Draft); data.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(model.getDefinition()))); - data.setGroupId(oldDmpBlueprintEntity.getGroupId()); - data.setVersion((short) (oldDmpBlueprintEntity.getVersion() + 1)); - data.setVersionStatus(DmpBlueprintVersionStatus.NotFinalized); + data.setGroupId(oldPlanBlueprintEntity.getGroupId()); + data.setVersion((short) (oldPlanBlueprintEntity.getVersion() + 1)); + data.setVersionStatus(PlanBlueprintVersionStatus.NotFinalized); data.setCreatedAt(Instant.now()); data.setUpdatedAt(Instant.now()); data.setIsActive(IsActive.Active); @@ -446,11 +446,11 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { this.entityManager.flush(); - this.updateVersionStatusAndSave(data, DmpBlueprintStatus.Draft, data.getStatus()); + this.updateVersionStatusAndSave(data, PlanBlueprintStatus.Draft, data.getStatus()); this.entityManager.flush(); - return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fields, DmpBlueprint._id), data); + return this.builderFactory.builder(PlanBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(BaseFieldSet.build(fields, PlanBlueprint._id), data); } //endregion @@ -462,9 +462,9 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { public BlueprintImportExport getExportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { logger.debug(new MapLogEntry("export xml").And("id", id)); - if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDmpBlueprint); - DmpBlueprintEntity data = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).first(); - if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportPlanBlueprint); + PlanBlueprintEntity data = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).first(); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); return this.definitionXmlToExport(data); } @@ -473,22 +473,22 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { @Override public ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException { logger.debug(new MapLogEntry("export xml").And("id", id)); - DmpBlueprintEntity data = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).first(); - if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + PlanBlueprintEntity data = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).first(); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); String xml = this.xmlHandlingService.toXml(this.getExportXmlEntity(id, false)); return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml"); } - private BlueprintImportExport definitionXmlToExport(DmpBlueprintEntity entity) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { + private BlueprintImportExport definitionXmlToExport(PlanBlueprintEntity entity) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { if (entity == null) return null; BlueprintImportExport xml = new BlueprintImportExport(); xml.setId(entity.getId()); xml.setLabel(entity.getLabel()); xml.setGroupId(entity.getGroupId()); - DefinitionEntity dmpDefinition = this.xmlHandlingService.fromXml(DefinitionEntity.class, entity.getDefinition()); - xml.setDmpBlueprintDefinition(this.definitionXmlToExport(dmpDefinition)); + DefinitionEntity planBlueprintDefinition = this.xmlHandlingService.fromXml(DefinitionEntity.class, entity.getDefinition()); + xml.setPlanBlueprintDefinition(this.definitionXmlToExport(planBlueprintDefinition)); return xml; } @@ -515,7 +515,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { xml.setHasTemplates(entity.getHasTemplates()); List dmpBlueprintSystemFieldModels = new LinkedList<>(); if (!this.conventionService.isListNullOrEmpty(entity.getFields())) { - for (SystemFieldEntity systemField : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.System).map(x -> (SystemFieldEntity) x).toList()) { + for (SystemFieldEntity systemField : entity.getFields().stream().filter(x -> x.getCategory() == PlanBlueprintFieldCategory.System).map(x -> (SystemFieldEntity) x).toList()) { dmpBlueprintSystemFieldModels.add(this.systemFieldXmlToExport(systemField)); } } @@ -523,7 +523,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { List dmpBlueprintExtraFieldModels = new LinkedList<>(); if (!this.conventionService.isListNullOrEmpty(entity.getFields())) { - for (ExtraFieldEntity systemField : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.Extra).map(x -> (ExtraFieldEntity) x).toList()) { + for (ExtraFieldEntity systemField : entity.getFields().stream().filter(x -> x.getCategory() == PlanBlueprintFieldCategory.Extra).map(x -> (ExtraFieldEntity) x).toList()) { dmpBlueprintExtraFieldModels.add(this.extraFieldXmlToExport(systemField)); } } @@ -531,7 +531,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { List dmpBlueprintReferenceFieldModels = new LinkedList<>(); if (!this.conventionService.isListNullOrEmpty(entity.getFields())) { - for (ReferenceTypeFieldEntity referenceTypeFieldEntity : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.ReferenceType).map(x -> (ReferenceTypeFieldEntity) x).toList()) { + for (ReferenceTypeFieldEntity referenceTypeFieldEntity : entity.getFields().stream().filter(x -> x.getCategory() == PlanBlueprintFieldCategory.ReferenceType).map(x -> (ReferenceTypeFieldEntity) x).toList()) { dmpBlueprintReferenceFieldModels.add(this.referenceFieldXmlToExport(referenceTypeFieldEntity)); } } @@ -623,57 +623,57 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { //region Import @Override - public DmpBlueprint importXml(BlueprintImportExport dmpDefinition, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException { - logger.debug(new MapLogEntry("import data").And("dmpDefinition", dmpDefinition).And("label", label).And("fields", fields)); + public PlanBlueprint importXml(BlueprintImportExport planBlueprintDefinition, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException { + logger.debug(new MapLogEntry("import data").And("planBlueprintDefinition", planBlueprintDefinition).And("label", label).And("fields", fields)); - this.authorizationService.authorizeForce(Permission.ImportDmpBlueprint); + this.authorizationService.authorizeForce(Permission.ImportPlanBlueprint); - if (groupId == null) groupId = dmpDefinition.getGroupId(); + if (groupId == null) groupId = planBlueprintDefinition.getGroupId(); - long activeBlueprintForTheGroup = groupId != null ? this.queryFactory.query(DmpBlueprintQuery.class).disableTracking() + long activeBlueprintForTheGroup = groupId != null ? this.queryFactory.query(PlanBlueprintQuery.class).disableTracking() .isActive(IsActive.Active) .groupIds(groupId) .count() : 0; if (activeBlueprintForTheGroup == 0) { - DmpBlueprintPersist persist = new DmpBlueprintPersist(); + PlanBlueprintPersist persist = new PlanBlueprintPersist(); persist.setLabel(label); - persist.setStatus(DmpBlueprintStatus.Draft); - persist.setDefinition(this.xmlDefinitionToPersist(dmpDefinition.getDmpBlueprintDefinition())); + persist.setStatus(PlanBlueprintStatus.Draft); + persist.setDefinition(this.xmlDefinitionToPersist(planBlueprintDefinition.getPlanBlueprintDefinition())); - this.validatorFactory.validator(DmpBlueprintPersist.DmpBlueprintPersistValidator.class).validateForce(persist); + this.validatorFactory.validator(PlanBlueprintPersist.PlanBlueprintPersistValidator.class).validateForce(persist); return this.persist(persist, groupId, fields); } else { - DmpBlueprintEntity latestVersionDmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class) + PlanBlueprintEntity latestVersionDmpBlueprint = this.queryFactory.query(PlanBlueprintQuery.class) .disableTracking() - .versionStatuses(DmpBlueprintVersionStatus.Current) + .versionStatuses(PlanBlueprintVersionStatus.Current) .isActive(IsActive.Active) - .statuses(DmpBlueprintStatus.Finalized) + .statuses(PlanBlueprintStatus.Finalized) .groupIds(groupId) .first(); if (latestVersionDmpBlueprint == null) throw new MyValidationException(this.errors.getDmpIsNotFinalized().getCode(), this.errors.getDmpIsNotFinalized().getMessage()); - NewVersionDmpBlueprintPersist persist = new NewVersionDmpBlueprintPersist(); + NewVersionPlanBlueprintPersist persist = new NewVersionPlanBlueprintPersist(); persist.setId(latestVersionDmpBlueprint.getId()); persist.setLabel(label); - persist.setStatus(DmpBlueprintStatus.Draft); - persist.setDefinition(this.xmlDefinitionToPersist(dmpDefinition.getDmpBlueprintDefinition())); + persist.setStatus(PlanBlueprintStatus.Draft); + persist.setDefinition(this.xmlDefinitionToPersist(planBlueprintDefinition.getPlanBlueprintDefinition())); persist.setHash(this.conventionService.hashValue(latestVersionDmpBlueprint.getUpdatedAt())); - this.validatorFactory.validator(NewVersionDmpBlueprintPersist.NewVersionDmpBlueprintPersistValidator.class).validateForce(persist); + this.validatorFactory.validator(NewVersionPlanBlueprintPersist.NewVersionPlanBlueprintPersistValidator.class).validateForce(persist); return this.createNewVersion(persist, fields); } } @Override - public DmpBlueprint importXml(byte[] bytes, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException { + public PlanBlueprint importXml(byte[] bytes, UUID groupId, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException { logger.debug(new MapLogEntry("import data").And("bytes", bytes).And("label", label).And("fields", fields)); - this.authorizationService.authorizeForce(Permission.ImportDmpBlueprint); + this.authorizationService.authorizeForce(Permission.ImportPlanBlueprint); - BlueprintImportExport dmpDefinition = this.xmlHandlingService.fromXml(BlueprintImportExport.class, new String(bytes, StandardCharsets.UTF_8)); + BlueprintImportExport planBlueprintDefinition = this.xmlHandlingService.fromXml(BlueprintImportExport.class, new String(bytes, StandardCharsets.UTF_8)); - return this.importXml(dmpDefinition, groupId, label, fields); + return this.importXml(planBlueprintDefinition, groupId, label, fields); } private DefinitionPersist xmlDefinitionToPersist(BlueprintDefinitionImportExport importXml) { @@ -757,7 +757,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { private FieldPersist xmlExtraFieldToPersist(BlueprintExtraFieldImportExport importXml) { ExtraFieldPersist persist = new ExtraFieldPersist(); persist.setId(importXml.getId()); - persist.setCategory(DmpBlueprintFieldCategory.Extra); + persist.setCategory(PlanBlueprintFieldCategory.Extra); persist.setDataType(importXml.getType()); persist.setLabel(importXml.getLabel()); persist.setPlaceholder(importXml.getPlaceholder()); @@ -771,7 +771,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { private FieldPersist xmlSystemFieldToPersist(BlueprintSystemFieldImportExport importXml) { SystemFieldPersist persist = new SystemFieldPersist(); persist.setId(importXml.getId()); - persist.setCategory(DmpBlueprintFieldCategory.System); + persist.setCategory(PlanBlueprintFieldCategory.System); persist.setSystemFieldType(importXml.getType()); persist.setLabel(importXml.getLabel()); persist.setPlaceholder(importXml.getPlaceholder()); @@ -792,7 +792,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { ReferenceTypeFieldPersist persist = new ReferenceTypeFieldPersist(); persist.setId(importXml.getId()); - persist.setCategory(DmpBlueprintFieldCategory.ReferenceType); + persist.setCategory(PlanBlueprintFieldCategory.ReferenceType); persist.setReferenceTypeId(data.getId()); persist.setLabel(importXml.getLabel()); persist.setPlaceholder(importXml.getPlaceholder()); @@ -809,42 +809,42 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { //region Import Common Model @Override - public DmpBlueprint importCommonModel(DmpBlueprintModel dmpDefinition, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException { - logger.debug(new MapLogEntry("import data").And("dmpDefinition", dmpDefinition).And("fields", fields)); + public PlanBlueprint importCommonModel(DmpBlueprintModel planDefinition, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException { + logger.debug(new MapLogEntry("import data").And("planDefinition", planDefinition).And("fields", fields)); - this.authorizationService.authorizeForce(Permission.ImportDmpBlueprint); + this.authorizationService.authorizeForce(Permission.ImportPlanBlueprint); - long activeBlueprintForTheGroup = dmpDefinition.getGroupId() != null ? this.queryFactory.query(DmpBlueprintQuery.class).disableTracking() + long activeBlueprintForTheGroup = planDefinition.getGroupId() != null ? this.queryFactory.query(PlanBlueprintQuery.class).disableTracking() .isActive(IsActive.Active) - .groupIds(dmpDefinition.getGroupId()) + .groupIds(planDefinition.getGroupId()) .count() : 0; if (activeBlueprintForTheGroup == 0) { - DmpBlueprintPersist persist = new DmpBlueprintPersist(); + PlanBlueprintPersist persist = new PlanBlueprintPersist(); - persist.setLabel(dmpDefinition.getLabel()); - persist.setStatus(DmpBlueprintStatus.Draft); - persist.setDefinition(this.commonModelDefinitionToPersist(dmpDefinition.getDefinition())); + persist.setLabel(planDefinition.getLabel()); + persist.setStatus(PlanBlueprintStatus.Draft); + persist.setDefinition(this.commonModelDefinitionToPersist(planDefinition.getDefinition())); - this.validatorFactory.validator(DmpBlueprintPersist.DmpBlueprintPersistValidator.class).validateForce(persist); - return this.persist(persist, dmpDefinition.getGroupId(), fields); + this.validatorFactory.validator(PlanBlueprintPersist.PlanBlueprintPersistValidator.class).validateForce(persist); + return this.persist(persist, planDefinition.getGroupId(), fields); } else { - DmpBlueprintEntity latestVersionDmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class) + PlanBlueprintEntity latestVersionDmpBlueprint = this.queryFactory.query(PlanBlueprintQuery.class) .disableTracking() - .versionStatuses(DmpBlueprintVersionStatus.Current) + .versionStatuses(PlanBlueprintVersionStatus.Current) .isActive(IsActive.Active) - .statuses(DmpBlueprintStatus.Finalized) - .groupIds(dmpDefinition.getGroupId()) + .statuses(PlanBlueprintStatus.Finalized) + .groupIds(planDefinition.getGroupId()) .first(); if (latestVersionDmpBlueprint == null) throw new MyValidationException(this.errors.getDmpIsNotFinalized().getCode(), this.errors.getDmpIsNotFinalized().getMessage()); - NewVersionDmpBlueprintPersist persist = new NewVersionDmpBlueprintPersist(); + NewVersionPlanBlueprintPersist persist = new NewVersionPlanBlueprintPersist(); persist.setId(latestVersionDmpBlueprint.getId()); - persist.setLabel(dmpDefinition.getLabel()); - persist.setStatus(DmpBlueprintStatus.Draft); - persist.setDefinition(this.commonModelDefinitionToPersist(dmpDefinition.getDefinition())); + persist.setLabel(planDefinition.getLabel()); + persist.setStatus(PlanBlueprintStatus.Draft); + persist.setDefinition(this.commonModelDefinitionToPersist(planDefinition.getDefinition())); persist.setHash(this.conventionService.hashValue(latestVersionDmpBlueprint.getUpdatedAt())); - this.validatorFactory.validator(NewVersionDmpBlueprintPersist.NewVersionDmpBlueprintPersistValidator.class).validateForce(persist); + this.validatorFactory.validator(NewVersionPlanBlueprintPersist.NewVersionPlanBlueprintPersistValidator.class).validateForce(persist); return this.createNewVersion(persist, fields); } } @@ -926,12 +926,12 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { private FieldPersist commonExtraFieldToPersist(ExtraFieldModel commonModel) { ExtraFieldPersist persist = new ExtraFieldPersist(); persist.setId(commonModel.getId()); - persist.setCategory(DmpBlueprintFieldCategory.Extra); + persist.setCategory(PlanBlueprintFieldCategory.Extra); switch (commonModel.getDataType()){ - case Text -> persist.setDataType(DmpBlueprintExtraFieldDataType.Text); - case Date -> persist.setDataType(DmpBlueprintExtraFieldDataType.Date); - case Number -> persist.setDataType(DmpBlueprintExtraFieldDataType.Number); - case RichTex -> persist.setDataType(DmpBlueprintExtraFieldDataType.RichTex); + case Text -> persist.setDataType(PlanBlueprintExtraFieldDataType.Text); + case Date -> persist.setDataType(PlanBlueprintExtraFieldDataType.Date); + case Number -> persist.setDataType(PlanBlueprintExtraFieldDataType.Number); + case RichTex -> persist.setDataType(PlanBlueprintExtraFieldDataType.RichTex); default -> throw new InternalError("unknown type: " + commonModel.getDataType()); } persist.setLabel(commonModel.getLabel()); @@ -946,14 +946,14 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { private FieldPersist commonModelSystemFieldToPersist(SystemFieldModel commonModel) { SystemFieldPersist persist = new SystemFieldPersist(); persist.setId(commonModel.getId()); - persist.setCategory(DmpBlueprintFieldCategory.System); + persist.setCategory(PlanBlueprintFieldCategory.System); switch (commonModel.getSystemFieldType()){ - case User -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.User); - case AccessRights -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.AccessRights); - case Contact -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.Contact); - case Description -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.Description); - case Language -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.Language); - case Title -> persist.setSystemFieldType(DmpBlueprintSystemFieldType.Title); + case User -> persist.setSystemFieldType(PlanBlueprintSystemFieldType.User); + case AccessRights -> persist.setSystemFieldType(PlanBlueprintSystemFieldType.AccessRights); + case Contact -> persist.setSystemFieldType(PlanBlueprintSystemFieldType.Contact); + case Description -> persist.setSystemFieldType(PlanBlueprintSystemFieldType.Description); + case Language -> persist.setSystemFieldType(PlanBlueprintSystemFieldType.Language); + case Title -> persist.setSystemFieldType(PlanBlueprintSystemFieldType.Title); default -> throw new InternalError("unknown type: " + commonModel.getSystemFieldType()); } persist.setLabel(commonModel.getLabel()); @@ -975,7 +975,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { ReferenceTypeFieldPersist persist = new ReferenceTypeFieldPersist(); persist.setId(commonModel.getId()); - persist.setCategory(DmpBlueprintFieldCategory.ReferenceType); + persist.setCategory(PlanBlueprintFieldCategory.ReferenceType); persist.setReferenceTypeId(data.getId()); persist.setLabel(commonModel.getLabel()); persist.setPlaceholder(commonModel.getPlaceholder()); diff --git a/backend/core/src/main/java/org/opencdmp/service/supportivematerial/SupportiveMaterialServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/supportivematerial/SupportiveMaterialServiceImpl.java index 2fa163b22..e730e75e0 100644 --- a/backend/core/src/main/java/org/opencdmp/service/supportivematerial/SupportiveMaterialServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/supportivematerial/SupportiveMaterialServiceImpl.java @@ -25,7 +25,7 @@ import org.opencdmp.model.builder.SupportiveMaterialBuilder; import org.opencdmp.model.deleter.SupportiveMaterialDeleter; import org.opencdmp.model.persist.SupportiveMaterialPersist; import org.opencdmp.query.SupportiveMaterialQuery; -import org.opencdmp.service.dmpblueprint.DmpBlueprintServiceImpl; +import org.opencdmp.service.planblueprint.PlanBlueprintServiceImpl; import org.opencdmp.service.storage.StorageFileService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; @@ -41,7 +41,7 @@ import java.util.UUID; @Service public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{ - private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class)); + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanBlueprintServiceImpl.class)); private final TenantEntityManager entityManager; private final AuthorizationService authorizationService; private final DeleterFactory deleterFactory; diff --git a/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java index 685f2eab9..56511a810 100644 --- a/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java @@ -804,8 +804,8 @@ public class UserServiceImpl implements UserService { this.entityManager.merge(lock); } - List dmpUsers = this.queryFactory.query(DmpUserQuery.class).userIds(oldUser.getId()).collect(); - for (DmpUserEntity dmpUser : dmpUsers) { + List dmpUsers = this.queryFactory.query(PlanUserQuery.class).userIds(oldUser.getId()).collect(); + for (PlanUserEntity dmpUser : dmpUsers) { dmpUser.setUserId(newUser.getId()); this.entityManager.merge(dmpUser); } @@ -816,8 +816,8 @@ public class UserServiceImpl implements UserService { this.entityManager.merge(userDescriptionTemplate); } - List dmps = this.queryFactory.query(DmpQuery.class).creatorIds(oldUser.getId()).collect(); - for (DmpEntity dmp : dmps) { + List dmps = this.queryFactory.query(PlanQuery.class).creatorIds(oldUser.getId()).collect(); + for (PlanEntity dmp : dmps) { dmp.setCreatorId(newUser.getId()); this.entityManager.merge(dmp); } @@ -834,16 +834,16 @@ public class UserServiceImpl implements UserService { this.entityManager.flush(); - for (DmpEntity dmp : dmps) { - this.elasticService.persistDmp(dmp); + for (PlanEntity dmp : dmps) { + this.elasticService.persistPlan(dmp); } for (DescriptionEntity description : descriptions) { this.elasticService.persistDescription(description); } - for (DmpEntity dmp : dmps) { - this.annotationEntityTouchedIntegrationEventHandler.handleDmp(dmp.getId()); + for (PlanEntity dmp : dmps) { + this.annotationEntityTouchedIntegrationEventHandler.handlePlan(dmp.getId()); } for (DescriptionEntity description : descriptions) { diff --git a/backend/web/src/main/java/org/opencdmp/authorization/AffiliatedAuthorizationHandler.java b/backend/web/src/main/java/org/opencdmp/authorization/AffiliatedAuthorizationHandler.java index b12ed64d6..4b9a8cd20 100644 --- a/backend/web/src/main/java/org/opencdmp/authorization/AffiliatedAuthorizationHandler.java +++ b/backend/web/src/main/java/org/opencdmp/authorization/AffiliatedAuthorizationHandler.java @@ -4,7 +4,7 @@ import gr.cite.commons.web.authz.handler.AuthorizationHandler; import gr.cite.commons.web.authz.handler.AuthorizationHandlerContext; import gr.cite.commons.web.authz.policy.AuthorizationRequirement; import gr.cite.commons.web.oidc.principal.MyPrincipal; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.opencdmp.commons.enums.UserDescriptionTemplateRole; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -37,14 +37,14 @@ public class AffiliatedAuthorizationHandler extends AuthorizationHandler dmpUserRoles = rs != null && rs.getDmpUserRoles() != null ? rs.getDmpUserRoles() : null; + HashSet planUserRoles = rs != null && rs.getPlanUserRoles() != null ? rs.getPlanUserRoles() : null; HashSet userDescriptionTemplateRoles = rs != null && rs.getUserDescriptionTemplateRoles() != null ? rs.getUserDescriptionTemplateRoles() : null; for (String permission : req.getRequiredPermissions()) { CustomPermissionAttributesProperties.MyPermission policy = this.myConfiguration.getMyPolicies().get(permission); - boolean hasDmpPermission = policy != null && this.hasPermission(policy.getDmp(), dmpUserRoles); + boolean hasPlanPermission = policy != null && this.hasPermission(policy.getDmp(), planUserRoles); boolean hasDescriptionTemplatePermission = policy != null && this.hasPermission(policy.getDescriptionTemplate(), userDescriptionTemplateRoles); - if (hasDmpPermission || hasDescriptionTemplatePermission) hits += 1; + if (hasPlanPermission || hasDescriptionTemplatePermission) hits += 1; } if ((req.getMatchAll() && req.getRequiredPermissions().size() == hits) || (!req.getMatchAll() && hits > 0)) return ACCESS_GRANTED; @@ -64,12 +64,12 @@ public class AffiliatedAuthorizationHandler extends AuthorizationHandler roles) { + private Boolean hasPermission(PlanRole planRole, HashSet roles) { if (roles == null) return Boolean.FALSE; - if (dmpRole == null || dmpRole.getRoles() == null) + if (planRole == null || planRole.getRoles() == null) return Boolean.FALSE; - for (DmpUserRole role : dmpRole.getRoles()) { + for (PlanUserRole role : planRole.getRoles()) { if (roles.contains(role)) return Boolean.TRUE; } diff --git a/backend/web/src/main/java/org/opencdmp/authorization/CustomPermissionAttributesProperties.java b/backend/web/src/main/java/org/opencdmp/authorization/CustomPermissionAttributesProperties.java index 5e6474aa3..66772bc55 100644 --- a/backend/web/src/main/java/org/opencdmp/authorization/CustomPermissionAttributesProperties.java +++ b/backend/web/src/main/java/org/opencdmp/authorization/CustomPermissionAttributesProperties.java @@ -23,17 +23,17 @@ public class CustomPermissionAttributesProperties { public static class MyPermission { - private final DmpRole dmp; + private final PlanRole dmp; private final DescriptionTemplateRole descriptionTemplate; @ConstructorBinding - public MyPermission(DmpRole dmp, DescriptionTemplateRole descriptionTemplate) { + public MyPermission(PlanRole dmp, DescriptionTemplateRole descriptionTemplate) { this.dmp = dmp; this.descriptionTemplate = descriptionTemplate; } - public DmpRole getDmp() { + public PlanRole getDmp() { return this.dmp; } diff --git a/backend/web/src/main/java/org/opencdmp/authorization/OwnedAuthorizationHandler.java b/backend/web/src/main/java/org/opencdmp/authorization/OwnedAuthorizationHandler.java index e998719c7..be75c42bb 100644 --- a/backend/web/src/main/java/org/opencdmp/authorization/OwnedAuthorizationHandler.java +++ b/backend/web/src/main/java/org/opencdmp/authorization/OwnedAuthorizationHandler.java @@ -1,6 +1,5 @@ package org.opencdmp.authorization; -import org.opencdmp.commons.enums.DmpUserRole; import org.opencdmp.commons.scope.user.UserScope; import gr.cite.commons.web.authz.handler.AuthorizationHandler; import gr.cite.commons.web.authz.handler.AuthorizationHandlerContext; @@ -9,9 +8,6 @@ import gr.cite.commons.web.oidc.principal.MyPrincipal; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.HashSet; -import java.util.List; - @Component("ownedAuthorizationHandler") public class OwnedAuthorizationHandler extends AuthorizationHandler { diff --git a/backend/web/src/main/java/org/opencdmp/authorization/DmpRole.java b/backend/web/src/main/java/org/opencdmp/authorization/PlanRole.java similarity index 52% rename from backend/web/src/main/java/org/opencdmp/authorization/DmpRole.java rename to backend/web/src/main/java/org/opencdmp/authorization/PlanRole.java index 7e65e09fd..803104e31 100644 --- a/backend/web/src/main/java/org/opencdmp/authorization/DmpRole.java +++ b/backend/web/src/main/java/org/opencdmp/authorization/PlanRole.java @@ -1,20 +1,20 @@ package org.opencdmp.authorization; -import org.opencdmp.commons.enums.DmpUserRole; +import org.opencdmp.commons.enums.PlanUserRole; import org.springframework.boot.context.properties.bind.ConstructorBinding; import java.util.Set; -public class DmpRole { - private final Set roles; +public class PlanRole { + private final Set roles; @ConstructorBinding - public DmpRole(Set roles) { + public PlanRole(Set roles) { this.roles = roles; } - public Set getRoles() { + public Set getRoles() { return this.roles; } 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 c6a25ae60..f89d8d0e8 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java @@ -22,8 +22,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.xml.bind.JAXBException; import org.opencdmp.audit.AuditableAction; import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; import org.opencdmp.commons.enums.IsActive; import org.opencdmp.controllers.swagger.SwaggerHelpers; import org.opencdmp.controllers.swagger.annotation.OperationWithTenantHeader; @@ -40,11 +40,11 @@ import org.opencdmp.model.builder.description.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.planblueprint.PlanBlueprint; import org.opencdmp.model.persist.*; import org.opencdmp.model.result.QueryResult; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.opencdmp.query.lookup.DescriptionLookup; import org.opencdmp.service.description.DescriptionService; import org.opencdmp.service.elastic.ElasticQueryHelperService; @@ -148,7 +148,7 @@ public class DescriptionController { this.censorFactory.censor(PublicDescriptionCensor.class).censor(fieldSet); - 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)); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(EnumSet.of(Public)).ids(id).dmpSubQuery(this.queryFactory.query(PlanQuery.class).isActive(IsActive.Active).statuses(PlanStatus.Finalized).accessTypes(PlanAccessType.Public)); PublicDescription model = this.builderFactory.builder(PublicDescriptionBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet)); if (model == null) @@ -424,11 +424,11 @@ public class DescriptionController { public @ResponseBody ResponseEntity getXml( @Parameter(name = "id", description = "The id of a description to export", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable UUID id ) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { - logger.debug(new MapLogEntry("export" + DmpBlueprint.class.getSimpleName()).And("id", id)); + logger.debug(new MapLogEntry("export" + PlanBlueprint.class.getSimpleName()).And("id", id)); ResponseEntity response = this.descriptionService.exportXml(id); - this.auditService.track(AuditableAction.DmpBlueprint_GetXml, Map.ofEntries( + this.auditService.track(AuditableAction.PlanBlueprint_GetXml, Map.ofEntries( new AbstractMap.SimpleEntry("id", id) )); return response; 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 0dcc5e3c6..dc82bdf75 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionTemplateController.java @@ -31,9 +31,9 @@ import org.opencdmp.controllers.swagger.annotation.SwaggerCommonErrorResponses; import org.opencdmp.data.DescriptionTemplateEntity; 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.censorship.planblueprint.PlanBlueprintCensor; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; -import org.opencdmp.model.dmpblueprint.DmpBlueprint; +import org.opencdmp.model.planblueprint.PlanBlueprint; import org.opencdmp.model.persist.DescriptionTemplatePersist; import org.opencdmp.model.persist.NewVersionDescriptionTemplatePersist; import org.opencdmp.model.result.QueryResult; @@ -218,10 +218,10 @@ public class DescriptionTemplateController { @Parameter(name = "id", description = "The id of a description template to clone", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException { - logger.debug(new MapLogEntry("clone" + DmpBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet)); + logger.debug(new MapLogEntry("clone" + PlanBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet)); fieldSet = this.fieldSetExpanderService.expand(fieldSet); - this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null); + this.censorFactory.censor(PlanBlueprintCensor.class).censor(fieldSet, null); DescriptionTemplate model = this.descriptionTemplateTypeService.buildClone(id, fieldSet); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/MaintenanceController.java b/backend/web/src/main/java/org/opencdmp/controllers/MaintenanceController.java index d2e103a8b..1d2e34875 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/MaintenanceController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/MaintenanceController.java @@ -45,7 +45,7 @@ public class MaintenanceController { logger.debug("generate elastic "); this.authorizationService.authorizeForce(Permission.ManageElastic); - this.elasticService.resetDmpIndex(); + this.elasticService.resetPlanIndex(); this.elasticService.resetDescriptionIndex(); this.auditService.track(AuditableAction.Maintenance_GenerateElastic); @@ -57,7 +57,7 @@ public class MaintenanceController { this.authorizationService.authorizeForce(Permission.ManageElastic); this.elasticService.deleteDescriptionIndex(); - this.elasticService.deleteDmpIndex(); + this.elasticService.deletePlanIndex(); this.auditService.track(AuditableAction.Maintenance_ClearElastic); } @@ -89,7 +89,7 @@ public class MaintenanceController { this.maintenanceService.sendDmpTouchEvents(); - this.auditService.track(AuditableAction.Maintenance_SendDmpTouchEvents); + this.auditService.track(AuditableAction.Maintenance_SendPlanTouchEvents); } @RequestMapping(method = RequestMethod.POST, value = "/events/descriptions/touch") diff --git a/backend/web/src/main/java/org/opencdmp/controllers/PlanBlueprintController.java b/backend/web/src/main/java/org/opencdmp/controllers/PlanBlueprintController.java index 90fa400f0..8ec72dc52 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/PlanBlueprintController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/PlanBlueprintController.java @@ -28,16 +28,16 @@ import org.opencdmp.controllers.swagger.annotation.OperationWithTenantHeader; import org.opencdmp.controllers.swagger.annotation.Swagger400; import org.opencdmp.controllers.swagger.annotation.Swagger404; import org.opencdmp.controllers.swagger.annotation.SwaggerCommonErrorResponses; -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.data.PlanBlueprintEntity; +import org.opencdmp.model.builder.planblueprint.PlanBlueprintBuilder; +import org.opencdmp.model.censorship.planblueprint.PlanBlueprintCensor; +import org.opencdmp.model.persist.NewVersionPlanBlueprintPersist; +import org.opencdmp.model.persist.PlanBlueprintPersist; +import org.opencdmp.model.planblueprint.PlanBlueprint; 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.opencdmp.query.PlanBlueprintQuery; +import org.opencdmp.query.lookup.PlanBlueprintLookup; +import org.opencdmp.service.planblueprint.PlanBlueprintService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -56,7 +56,7 @@ import java.util.Map; import java.util.UUID; @RestController -@RequestMapping(path = "api/dmp-blueprint") +@RequestMapping(path = "api/plan-blueprint") @Tag(name = "Plan Blueprints", description = "Manage plan blueprints") @SwaggerCommonErrorResponses public class PlanBlueprintController { @@ -67,7 +67,7 @@ public class PlanBlueprintController { private final AuditService auditService; - private final DmpBlueprintService dmpBlueprintService; + private final PlanBlueprintService planBlueprintService; private final CensorFactory censorFactory; @@ -78,13 +78,13 @@ public class PlanBlueprintController { public PlanBlueprintController( BuilderFactory builderFactory, AuditService auditService, - DmpBlueprintService dmpBlueprintService, + PlanBlueprintService planBlueprintService, CensorFactory censorFactory, QueryFactory queryFactory, MessageSource messageSource) { this.builderFactory = builderFactory; this.auditService = auditService; - this.dmpBlueprintService = dmpBlueprintService; + this.planBlueprintService = planBlueprintService; this.censorFactory = censorFactory; this.queryFactory = queryFactory; this.messageSource = messageSource; @@ -102,7 +102,7 @@ public class PlanBlueprintController { )), responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( array = @ArraySchema( schema = @Schema( - implementation = DmpBlueprint.class + implementation = PlanBlueprint.class ) ), examples = @ExampleObject( @@ -110,17 +110,17 @@ public class PlanBlueprintController { description = "Example with the first page of paginated results", value = SwaggerHelpers.PlanBlueprint.endpoint_query_response_example )))) - public QueryResult query(@RequestBody DmpBlueprintLookup lookup) throws MyApplicationException, MyForbiddenException { - logger.debug("querying {}", DmpBlueprint.class.getSimpleName()); + public QueryResult query(@RequestBody PlanBlueprintLookup lookup) throws MyApplicationException, MyForbiddenException { + logger.debug("querying {}", PlanBlueprint.class.getSimpleName()); - this.censorFactory.censor(DmpBlueprintCensor.class).censor(lookup.getProject(), null); - DmpBlueprintQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.AllExceptPublic); + this.censorFactory.censor(PlanBlueprintCensor.class).censor(lookup.getProject(), null); + PlanBlueprintQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.AllExceptPublic); - List data = query.collectAs(lookup.getProject()); - List models = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(lookup.getProject(), data); + List data = query.collectAs(lookup.getProject()); + List models = this.builderFactory.builder(PlanBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(lookup.getProject(), data); long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size(); - this.auditService.track(AuditableAction.DmpBlueprint_Query, "lookup", lookup); + this.auditService.track(AuditableAction.PlanBlueprint_Query, "lookup", lookup); return new QueryResult<>(models, count); } @@ -129,24 +129,24 @@ public class PlanBlueprintController { @OperationWithTenantHeader(summary = "Fetch a specific plan blueprint by id", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = DmpBlueprint.class + implementation = PlanBlueprint.class )) )) @Swagger404 - public DmpBlueprint get( + public PlanBlueprint get( @Parameter(name = "id", description = "The id of a plan blueprint to fetch", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException { - logger.debug(new MapLogEntry("retrieving" + DmpBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet)); + logger.debug(new MapLogEntry("retrieving" + PlanBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet)); - this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null); + this.censorFactory.censor(PlanBlueprintCensor.class).censor(fieldSet, null); - DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id); - DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fieldSet, query.firstAs(fieldSet)); + PlanBlueprintQuery query = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id); + PlanBlueprint model = this.builderFactory.builder(PlanBlueprintBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); - this.auditService.track(AuditableAction.DmpBlueprint_Lookup, Map.ofEntries( + this.auditService.track(AuditableAction.PlanBlueprint_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -158,23 +158,23 @@ public class PlanBlueprintController { @OperationWithTenantHeader(summary = "Create a new or update an existing plan blueprint", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = DmpBlueprint.class + implementation = PlanBlueprint.class )) )) @Swagger400 @Swagger404 @Transactional - @ValidationFilterAnnotation(validator = DmpBlueprintPersist.DmpBlueprintPersistValidator.ValidatorName, argumentName = "model") - public DmpBlueprint persist( - @RequestBody DmpBlueprintPersist model, + @ValidationFilterAnnotation(validator = PlanBlueprintPersist.PlanBlueprintPersistValidator.ValidatorName, argumentName = "model") + public PlanBlueprint persist( + @RequestBody PlanBlueprintPersist model, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException { - logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); - this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null); + logger.debug(new MapLogEntry("persisting" + PlanBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); + this.censorFactory.censor(PlanBlueprintCensor.class).censor(fieldSet, null); - DmpBlueprint persisted = this.dmpBlueprintService.persist(model, null, fieldSet); + PlanBlueprint persisted = this.planBlueprintService.persist(model, null, fieldSet); - this.auditService.track(AuditableAction.DmpBlueprint_Persist, Map.ofEntries( + this.auditService.track(AuditableAction.PlanBlueprint_Persist, Map.ofEntries( new AbstractMap.SimpleEntry("model", model), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -190,32 +190,32 @@ public class PlanBlueprintController { public void delete( @Parameter(name = "id", description = "The id of a plan blueprint to delete", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id ) throws MyForbiddenException, InvalidApplicationException { - logger.debug(new MapLogEntry("retrieving" + DmpBlueprint.class.getSimpleName()).And("id", id)); + logger.debug(new MapLogEntry("retrieving" + PlanBlueprint.class.getSimpleName()).And("id", id)); - this.dmpBlueprintService.deleteAndSave(id); + this.planBlueprintService.deleteAndSave(id); - this.auditService.track(AuditableAction.DmpBlueprint_Delete, "id", id); + this.auditService.track(AuditableAction.PlanBlueprint_Delete, "id", id); } @GetMapping("clone/{id}") @OperationWithTenantHeader(summary = "Clone a plan blueprint by id", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = DmpBlueprint.class + implementation = PlanBlueprint.class )) )) @Swagger404 - public DmpBlueprint buildClone( + public PlanBlueprint buildClone( @Parameter(name = "id", description = "The id of a plan blueprint to clone", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException { - logger.debug(new MapLogEntry("clone" + DmpBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet)); + logger.debug(new MapLogEntry("clone" + PlanBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet)); - this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null); + this.censorFactory.censor(PlanBlueprintCensor.class).censor(fieldSet, null); - DmpBlueprint model = this.dmpBlueprintService.buildClone(id, fieldSet); + PlanBlueprint model = this.planBlueprintService.buildClone(id, fieldSet); - this.auditService.track(AuditableAction.DmpBlueprint_Clone, Map.ofEntries( + this.auditService.track(AuditableAction.PlanBlueprint_Clone, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -227,21 +227,21 @@ public class PlanBlueprintController { @OperationWithTenantHeader(summary = "Create a new version of an existing plan blueprint", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = DmpBlueprint.class + implementation = PlanBlueprint.class )) )) @Swagger400 @Swagger404 @Transactional - @ValidationFilterAnnotation(validator = NewVersionDmpBlueprintPersist.NewVersionDmpBlueprintPersistValidator.ValidatorName, argumentName = "model") - public DmpBlueprint createNewVersion( - @RequestBody NewVersionDmpBlueprintPersist model, + @ValidationFilterAnnotation(validator = NewVersionPlanBlueprintPersist.NewVersionPlanBlueprintPersistValidator.ValidatorName, argumentName = "model") + public PlanBlueprint createNewVersion( + @RequestBody NewVersionPlanBlueprintPersist model, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws JAXBException, InvalidApplicationException, ParserConfigurationException, JsonProcessingException, TransformerException { - logger.debug(new MapLogEntry("persisting" + NewVersionDmpBlueprintPersist.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); - DmpBlueprint persisted = this.dmpBlueprintService.createNewVersion(model, fieldSet); + logger.debug(new MapLogEntry("persisting" + NewVersionPlanBlueprintPersist.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); + PlanBlueprint persisted = this.planBlueprintService.createNewVersion(model, fieldSet); - this.auditService.track(AuditableAction.DmpBlueprint_PersistNewVersion, Map.ofEntries( + this.auditService.track(AuditableAction.PlanBlueprint_PersistNewVersion, Map.ofEntries( new AbstractMap.SimpleEntry("model", model), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -256,11 +256,11 @@ public class PlanBlueprintController { public @ResponseBody ResponseEntity getXml( @Parameter(name = "id", description = "The id of a plan blueprint to export", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable UUID id ) throws JAXBException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { - logger.debug(new MapLogEntry("export" + DmpBlueprint.class.getSimpleName()).And("id", id)); + logger.debug(new MapLogEntry("export" + PlanBlueprint.class.getSimpleName()).And("id", id)); - ResponseEntity response = this.dmpBlueprintService.exportXml(id); + ResponseEntity response = this.planBlueprintService.exportXml(id); - this.auditService.track(AuditableAction.DmpBlueprint_GetXml, Map.ofEntries( + this.auditService.track(AuditableAction.PlanBlueprint_GetXml, Map.ofEntries( new AbstractMap.SimpleEntry("id", id) )); return response; @@ -270,22 +270,22 @@ public class PlanBlueprintController { @OperationWithTenantHeader(summary = "Import a plan blueprint from an xml file", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = DmpBlueprint.class + implementation = PlanBlueprint.class )) )) @Transactional - public DmpBlueprint importXml( + public PlanBlueprint importXml( @RequestParam("file") MultipartFile file, @Parameter(name = "groupId", description = "The group id of a plan blueprint to import. This is optional.", example = "c0c163dc-2965-45a5-9608-f76030578609") @PathVariable(value = "groupId", required = false) UUID groupId, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws IOException, JAXBException, InvalidApplicationException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException { - logger.debug(new MapLogEntry("clone" + DmpBlueprint.class.getSimpleName()).And("file", file)); + logger.debug(new MapLogEntry("clone" + PlanBlueprint.class.getSimpleName()).And("file", file)); - this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null); + this.censorFactory.censor(PlanBlueprintCensor.class).censor(fieldSet, null); - DmpBlueprint model = this.dmpBlueprintService.importXml(file.getBytes(), groupId, file.getOriginalFilename(), fieldSet); + PlanBlueprint model = this.planBlueprintService.importXml(file.getBytes(), groupId, file.getOriginalFilename(), fieldSet); - this.auditService.track(AuditableAction.DmpBlueprint_Import, Map.ofEntries( + this.auditService.track(AuditableAction.PlanBlueprint_Import, Map.ofEntries( new AbstractMap.SimpleEntry("file", file), new AbstractMap.SimpleEntry("fields", fieldSet) )); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/PlanController.java b/backend/web/src/main/java/org/opencdmp/controllers/PlanController.java index f0111f630..e182809c7 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/PlanController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/PlanController.java @@ -22,9 +22,9 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.xml.bind.JAXBException; import org.opencdmp.audit.AuditableAction; import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.commons.enums.DmpAccessType; -import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.enums.PlanAccessType; +import org.opencdmp.commons.enums.PlanStatus; import org.opencdmp.controllers.swagger.SwaggerHelpers; import org.opencdmp.controllers.swagger.annotation.OperationWithTenantHeader; import org.opencdmp.controllers.swagger.annotation.Swagger400; @@ -32,20 +32,20 @@ import org.opencdmp.controllers.swagger.annotation.Swagger404; import org.opencdmp.controllers.swagger.annotation.SwaggerCommonErrorResponses; import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel; import org.opencdmp.model.DescriptionsToBeFinalized; -import org.opencdmp.model.DmpUser; -import org.opencdmp.model.DmpValidationResult; -import org.opencdmp.model.PublicDmp; -import org.opencdmp.model.builder.PublicDmpBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; -import org.opencdmp.model.censorship.PublicDmpCensor; -import org.opencdmp.model.censorship.dmp.DmpCensor; -import org.opencdmp.model.dmp.Dmp; +import org.opencdmp.model.PlanUser; +import org.opencdmp.model.PlanValidationResult; +import org.opencdmp.model.PublicPlan; +import org.opencdmp.model.builder.PublicPlanBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; +import org.opencdmp.model.censorship.PublicPlanCensor; +import org.opencdmp.model.censorship.plan.PlanCensor; import org.opencdmp.model.persist.*; +import org.opencdmp.model.plan.Plan; import org.opencdmp.model.result.QueryResult; -import org.opencdmp.query.DmpQuery; -import org.opencdmp.query.lookup.DmpLookup; -import org.opencdmp.service.dmp.DmpService; +import org.opencdmp.query.PlanQuery; +import org.opencdmp.query.lookup.PlanLookup; import org.opencdmp.service.elastic.ElasticQueryHelperService; +import org.opencdmp.service.plan.PlanService; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -70,7 +70,7 @@ import java.util.*; import static org.opencdmp.authorization.AuthorizationFlags.Public; @RestController -@RequestMapping(path = "api/dmp") +@RequestMapping(path = "api/plan") @Tag(name = "Plans", description = "Manage plans") @SwaggerCommonErrorResponses public class PlanController { @@ -81,7 +81,7 @@ public class PlanController { private final AuditService auditService; - private final DmpService dmpService; + private final PlanService planService; private final CensorFactory censorFactory; @@ -94,14 +94,14 @@ public class PlanController { public PlanController( BuilderFactory builderFactory, AuditService auditService, - DmpService dmpService, + PlanService planService, CensorFactory censorFactory, QueryFactory queryFactory, MessageSource messageSource, ElasticQueryHelperService elasticQueryHelperService) { this.builderFactory = builderFactory; this.auditService = auditService; - this.dmpService = dmpService; + this.planService = planService; this.censorFactory = censorFactory; this.queryFactory = queryFactory; this.messageSource = messageSource; @@ -111,15 +111,15 @@ public class PlanController { @PostMapping("public/query") @OperationWithTenantHeader(summary = "Query public published plans") @Hidden - public QueryResult publicQuery(@RequestBody DmpLookup lookup) throws MyApplicationException, MyForbiddenException { - logger.debug("querying {}", Dmp.class.getSimpleName()); + public QueryResult publicQuery(@RequestBody PlanLookup lookup) throws MyApplicationException, MyForbiddenException { + logger.debug("querying {}", Plan.class.getSimpleName()); - this.censorFactory.censor(PublicDmpCensor.class).censor(lookup.getProject()); + this.censorFactory.censor(PublicPlanCensor.class).censor(lookup.getProject()); //DmpQuery query = lookup.enrich(this.queryFactory).authorize(EnumSet.of(Public)).dmpSubQuery(this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public)); - QueryResult queryResult = this.elasticQueryHelperService.collectPublic(lookup, EnumSet.of(Public), null); + QueryResult queryResult = this.elasticQueryHelperService.collectPublic(lookup, EnumSet.of(Public), null); - this.auditService.track(AuditableAction.Dmp_PublicQuery, "lookup", lookup); + this.auditService.track(AuditableAction.Plan_PublicQuery, "lookup", lookup); return queryResult; } @@ -127,18 +127,18 @@ public class PlanController { @GetMapping("public/{id}") @OperationWithTenantHeader(summary = "Fetch a specific public published plan by id") @Hidden - public PublicDmp publicGet(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { - logger.debug(new MapLogEntry("retrieving" + Dmp.class.getSimpleName()).And("id", id).And("fields", fieldSet)); + public PublicPlan publicGet(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { + logger.debug(new MapLogEntry("retrieving" + Plan.class.getSimpleName()).And("id", id).And("fields", fieldSet)); - this.censorFactory.censor(PublicDmpCensor.class).censor(fieldSet); + this.censorFactory.censor(PublicPlanCensor.class).censor(fieldSet); - DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(EnumSet.of(Public)).ids(id).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public); + PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(EnumSet.of(Public)).ids(id).isActive(IsActive.Active).statuses(PlanStatus.Finalized).accessTypes(PlanAccessType.Public); - PublicDmp model = this.builderFactory.builder(PublicDmpBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet)); + PublicPlan model = this.builderFactory.builder(PublicPlanBuilder.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())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - this.auditService.track(AuditableAction.Dmp_PublicLookup, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_PublicLookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -158,7 +158,7 @@ public class PlanController { )), responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( array = @ArraySchema( schema = @Schema( - implementation = Dmp.class + implementation = Plan.class ) ), examples = @ExampleObject( @@ -166,14 +166,14 @@ public class PlanController { description = "Example with the first page of paginated results", value = SwaggerHelpers.Plan.endpoint_query_response_example )))) - public QueryResult Query(@RequestBody DmpLookup lookup) throws MyApplicationException, MyForbiddenException { - logger.debug("querying {}", Dmp.class.getSimpleName()); + public QueryResult Query(@RequestBody PlanLookup lookup) throws MyApplicationException, MyForbiddenException { + logger.debug("querying {}", Plan.class.getSimpleName()); - this.censorFactory.censor(DmpCensor.class).censor(lookup.getProject(), null); + this.censorFactory.censor(PlanCensor.class).censor(lookup.getProject(), null); - QueryResult queryResult = this.elasticQueryHelperService.collect(lookup, AuthorizationFlags.AllExceptPublic, null); + QueryResult queryResult = this.elasticQueryHelperService.collect(lookup, AuthorizationFlags.AllExceptPublic, null); - this.auditService.track(AuditableAction.Dmp_Query, "lookup", lookup); + this.auditService.track(AuditableAction.Plan_Query, "lookup", lookup); return queryResult; } @@ -182,25 +182,25 @@ public class PlanController { @OperationWithTenantHeader(summary = "Fetch a specific plan by id", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = Dmp.class + implementation = Plan.class )) )) @Swagger404 - public Dmp Get( + public Plan Get( @Parameter(name = "id", description = "The id of a plan to fetch", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet, Locale locale ) throws MyApplicationException, MyForbiddenException, MyNotFoundException { - logger.debug(new MapLogEntry("retrieving" + Dmp.class.getSimpleName()).And("id", id).And("fields", fieldSet)); + logger.debug(new MapLogEntry("retrieving" + Plan.class.getSimpleName()).And("id", id).And("fields", fieldSet)); - this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); + this.censorFactory.censor(PlanCensor.class).censor(fieldSet, null); - DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id); - Dmp model = this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fieldSet, query.firstAs(fieldSet)); + PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id); + Plan model = this.builderFactory.builder(PlanBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fieldSet, query.firstAs(fieldSet)); if (model == null) - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); - this.auditService.track(AuditableAction.Dmp_Lookup, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Lookup, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -212,22 +212,22 @@ public class PlanController { @OperationWithTenantHeader(summary = "Create a new or update an existing plan", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = Dmp.class + implementation = Plan.class )) )) @Swagger400 @Swagger404 @Transactional - @ValidationFilterAnnotation(validator = DmpPersist.DmpPersistValidator.ValidatorName, argumentName = "model") - public Dmp Persist( - @RequestBody DmpPersist model, + @ValidationFilterAnnotation(validator = PlanPersist.PlanPersistValidator.ValidatorName, argumentName = "model") + public Plan Persist( + @RequestBody PlanPersist model, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException { - logger.debug(new MapLogEntry("persisting" + Dmp.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); + logger.debug(new MapLogEntry("persisting" + Plan.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); - Dmp persisted = this.dmpService.persist(model, fieldSet); + Plan persisted = this.planService.persist(model, fieldSet); - this.auditService.track(AuditableAction.Dmp_Persist, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Persist, Map.ofEntries( new AbstractMap.SimpleEntry("model", model), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -243,11 +243,11 @@ public class PlanController { public void Delete( @Parameter(name = "id", description = "The id of a plan to delete", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id ) throws MyForbiddenException, InvalidApplicationException, IOException { - logger.debug(new MapLogEntry("retrieving" + Dmp.class.getSimpleName()).And("id", id)); + logger.debug(new MapLogEntry("retrieving" + Plan.class.getSimpleName()).And("id", id)); - this.dmpService.deleteAndSave(id); + this.planService.deleteAndSave(id); - this.auditService.track(AuditableAction.Dmp_Delete, "id", id); + this.auditService.track(AuditableAction.Plan_Delete, "id", id); } @PostMapping("finalize/{id}") @@ -259,11 +259,11 @@ public class PlanController { @Parameter(name = "id", description = "The id of a plan to finalize", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, @RequestBody DescriptionsToBeFinalized descriptions ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException { - logger.debug(new MapLogEntry("finalizing" + Dmp.class.getSimpleName()).And("id", id).And("descriptionIds", descriptions.getDescriptionIds())); + logger.debug(new MapLogEntry("finalizing" + Plan.class.getSimpleName()).And("id", id).And("descriptionIds", descriptions.getDescriptionIds())); - this.dmpService.finalize(id, descriptions.getDescriptionIds()); + this.planService.finalize(id, descriptions.getDescriptionIds()); - this.auditService.track(AuditableAction.Dmp_Finalize, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Finalize, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), new AbstractMap.SimpleEntry("descriptionIds", descriptions.getDescriptionIds()) )); @@ -280,13 +280,13 @@ public class PlanController { @Parameter(name = "id", description = "The id of a plan to revert the finalization", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException { - logger.debug(new MapLogEntry("undo-finalizing" + Dmp.class.getSimpleName()).And("id", id)); + logger.debug(new MapLogEntry("undo-finalizing" + Plan.class.getSimpleName()).And("id", id)); - this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); + this.censorFactory.censor(PlanCensor.class).censor(fieldSet, null); - this.dmpService.undoFinalize(id, fieldSet); + this.planService.undoFinalize(id, fieldSet); - this.auditService.track(AuditableAction.Dmp_Undo_Finalize, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Undo_Finalize, Map.ofEntries( new AbstractMap.SimpleEntry("id", id) )); @@ -296,14 +296,14 @@ public class PlanController { @GetMapping("validate/{id}") @OperationWithTenantHeader(summary = "Validate if a plan is ready for finalization by id") @Hidden - public DmpValidationResult validate(@PathVariable("id") UUID id) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException { - logger.debug(new MapLogEntry("validating" + Dmp.class.getSimpleName()).And("id", id)); + public PlanValidationResult validate(@PathVariable("id") UUID id) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException { + logger.debug(new MapLogEntry("validating" + Plan.class.getSimpleName()).And("id", id)); - this.censorFactory.censor(DmpCensor.class).censor(null, null); + this.censorFactory.censor(PlanCensor.class).censor(null, null); - DmpValidationResult result = this.dmpService.validate(id); + PlanValidationResult result = this.planService.validate(id); - this.auditService.track(AuditableAction.Dmp_Validate, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Validate, Map.ofEntries( new AbstractMap.SimpleEntry("id", id) )); @@ -314,24 +314,24 @@ public class PlanController { @OperationWithTenantHeader(summary = "Create a clone of an existing plan", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = Dmp.class + implementation = Plan.class )) )) @Swagger400 @Swagger404 @Transactional - @ValidationFilterAnnotation(validator = CloneDmpPersist.CloneDmpPersistValidator.ValidatorName, argumentName = "model") - public Dmp buildClone( - @RequestBody CloneDmpPersist model, + @ValidationFilterAnnotation(validator = ClonePlanPersist.ClonePlanPersistValidator.ValidatorName, argumentName = "model") + public Plan buildClone( + @RequestBody ClonePlanPersist model, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException, InvalidApplicationException { - logger.debug(new MapLogEntry("clone" + Dmp.class.getSimpleName()).And("model", model).And("fields", fieldSet)); + logger.debug(new MapLogEntry("clone" + Plan.class.getSimpleName()).And("model", model).And("fields", fieldSet)); - this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); + this.censorFactory.censor(PlanCensor.class).censor(fieldSet, null); - Dmp clone = this.dmpService.buildClone(model, fieldSet); + Plan clone = this.planService.buildClone(model, fieldSet); - this.auditService.track(AuditableAction.Dmp_Clone, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Clone, Map.ofEntries( new AbstractMap.SimpleEntry("model", model), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -343,22 +343,22 @@ public class PlanController { @OperationWithTenantHeader(summary = "Create a new version of an existing plan", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = Dmp.class + implementation = Plan.class )) )) @Swagger400 @Swagger404 @Transactional - @ValidationFilterAnnotation(validator = NewVersionDmpPersist.NewVersionDmpPersistValidator.ValidatorName, argumentName = "model") - public Dmp createNewVersion( - @RequestBody NewVersionDmpPersist model, + @ValidationFilterAnnotation(validator = NewVersionPlanPersist.NewVersionPlanPersistValidator.ValidatorName, argumentName = "model") + public Plan createNewVersion( + @RequestBody NewVersionPlanPersist model, @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, IOException, TransformerException, InvalidApplicationException, ParserConfigurationException { - logger.debug(new MapLogEntry("persisting" + NewVersionDmpPersist.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); + logger.debug(new MapLogEntry("persisting" + NewVersionPlanPersist.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); - Dmp persisted = this.dmpService.createNewVersion(model, fieldSet); + Plan persisted = this.planService.createNewVersion(model, fieldSet); - this.auditService.track(AuditableAction.Dmp_PersistNewVersion, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_PersistNewVersion, Map.ofEntries( new AbstractMap.SimpleEntry("model", model), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -369,14 +369,14 @@ public class PlanController { @PostMapping("{id}/assign-users") @OperationWithTenantHeader(summary = "Assign users to the plan by id") @Transactional - @ValidationFilterAnnotation(validator = DmpUserPersist.DmpUserPersistValidator.ValidatorName, argumentName = "model") + @ValidationFilterAnnotation(validator = PlanUserPersist.PlanUserPersistValidator.ValidatorName, argumentName = "model") @Hidden - public QueryResult assignUsers(@PathVariable("id") UUID id, @RequestBody List model, FieldSet fieldSet) throws InvalidApplicationException, IOException { - logger.debug(new MapLogEntry("assigning users to dmp").And("model", model).And("fieldSet", fieldSet)); + public QueryResult assignUsers(@PathVariable("id") UUID id, @RequestBody List model, FieldSet fieldSet) throws InvalidApplicationException, IOException { + logger.debug(new MapLogEntry("assigning users to plan").And("model", model).And("fieldSet", fieldSet)); - List persisted = this.dmpService.assignUsers(id, model, fieldSet, false); + List persisted = this.planService.assignUsers(id, model, fieldSet, false); - this.auditService.track(AuditableAction.Dmp_Assign_Users, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Assign_Users, Map.ofEntries( new AbstractMap.SimpleEntry("model", model), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -387,14 +387,14 @@ public class PlanController { @PostMapping("remove-user") @OperationWithTenantHeader(summary = "Remove a user association with the plan") @Transactional - @ValidationFilterAnnotation(validator = DmpUserRemovePersist.DmpUserRemovePersistValidator.ValidatorName, argumentName = "model") + @ValidationFilterAnnotation(validator = PlanUserRemovePersist.PlanUserRemovePersistValidator.ValidatorName, argumentName = "model") @Hidden - public QueryResult removeUser(@RequestBody DmpUserRemovePersist model, FieldSet fieldSet) throws InvalidApplicationException, IOException { - logger.debug(new MapLogEntry("remove user from dmp").And("model", model).And("fieldSet", fieldSet)); + public QueryResult removeUser(@RequestBody PlanUserRemovePersist model, FieldSet fieldSet) throws InvalidApplicationException, IOException { + logger.debug(new MapLogEntry("remove user from plan").And("model", model).And("fieldSet", fieldSet)); - Dmp persisted = this.dmpService.removeUser(model, fieldSet); + Plan persisted = this.planService.removeUser(model, fieldSet); - this.auditService.track(AuditableAction.Dmp_RemoveUser, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_RemoveUser, Map.ofEntries( new AbstractMap.SimpleEntry("model", model), new AbstractMap.SimpleEntry("fields", fieldSet) )); @@ -411,10 +411,10 @@ public class PlanController { @PathVariable("transformerId") String transformerId, @PathVariable("type") String exportType ) throws InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { - logger.debug(new MapLogEntry("exporting dmp").And("id", id).And("transformerId", transformerId).And("exportType", exportType)); + logger.debug(new MapLogEntry("exporting plan").And("id", id).And("transformerId", transformerId).And("exportType", exportType)); - ResponseEntity bytes = this.dmpService.export(id, transformerId, exportType); - this.auditService.track(AuditableAction.Dmp_Export, Map.ofEntries( + ResponseEntity bytes = this.planService.export(id, transformerId, exportType); + this.auditService.track(AuditableAction.Plan_Export, Map.ofEntries( new AbstractMap.SimpleEntry("id", id), new AbstractMap.SimpleEntry("transformerId", transformerId), new AbstractMap.SimpleEntry("exportType", exportType) @@ -425,14 +425,14 @@ public class PlanController { @PostMapping("{id}/invite-users") @OperationWithTenantHeader(summary = "Send user invitations for the plan by id") @Transactional - @ValidationFilterAnnotation(validator = DmpUserInvitePersist.DmpUserInvitePersistValidator.ValidatorName, argumentName = "model") + @ValidationFilterAnnotation(validator = PlanUserInvitePersist.PlanUserInvitePersistValidator.ValidatorName, argumentName = "model") @Hidden - public boolean inviteUsers(@PathVariable("id") UUID id, @RequestBody DmpUserInvitePersist model) throws InvalidApplicationException, JAXBException, IOException { - logger.debug(new MapLogEntry("inviting users to dmp").And("model", model)); + public boolean inviteUsers(@PathVariable("id") UUID id, @RequestBody PlanUserInvitePersist model) throws InvalidApplicationException, JAXBException, IOException { + logger.debug(new MapLogEntry("inviting users to plan").And("model", model)); - this.dmpService.inviteUserOrAssignUsers(id, model.getUsers()); + this.planService.inviteUserOrAssignUsers(id, model.getUsers()); - this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Invite_Users, Map.ofEntries( new AbstractMap.SimpleEntry("model", model) )); @@ -444,11 +444,11 @@ public class PlanController { @Transactional @Hidden public boolean acceptInvitation(@PathVariable("id") UUID id, @PathVariable("token") String token) throws InvalidApplicationException, JAXBException, IOException { - logger.debug(new MapLogEntry("inviting users to dmp").And("id", id)); + logger.debug(new MapLogEntry("inviting users to plan").And("id", id)); - this.dmpService.dmpInvitationAccept(token); + this.planService.planInvitationAccept(token); - this.auditService.track(AuditableAction.Dmp_Invite_Accept, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Invite_Accept, Map.ofEntries( new AbstractMap.SimpleEntry("token", token) )); @@ -462,11 +462,11 @@ public class PlanController { public @ResponseBody ResponseEntity getXml( @Parameter(name = "id", description = "The id of a plan to export", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable UUID id ) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { - logger.debug(new MapLogEntry("export" + Dmp.class.getSimpleName()).And("id", id)); + logger.debug(new MapLogEntry("export" + Plan.class.getSimpleName()).And("id", id)); - ResponseEntity response = this.dmpService.exportXml(id); + ResponseEntity response = this.planService.exportXml(id); - this.auditService.track(AuditableAction.Dmp_GetXml, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_GetXml, Map.ofEntries( new AbstractMap.SimpleEntry("id", id) )); return response; @@ -476,20 +476,20 @@ public class PlanController { @OperationWithTenantHeader(summary = "Import a plan from an xml file", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = Dmp.class + implementation = Plan.class )) )) @Transactional - public Dmp importXml( + public Plan importXml( @RequestParam("file") MultipartFile file, @RequestParam("label") String label, @Parameter(name = "fields", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fields ) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException, TransformerException { - logger.debug(new MapLogEntry("import xml" + Dmp.class.getSimpleName()).And("file", file).And("label", label)); + logger.debug(new MapLogEntry("import xml" + Plan.class.getSimpleName()).And("file", file).And("label", label)); - Dmp model = this.dmpService.importXml(file.getBytes(), label, fields); + Plan model = this.planService.importXml(file.getBytes(), label, fields); - this.auditService.track(AuditableAction.Dmp_Import, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Import, Map.ofEntries( new AbstractMap.SimpleEntry("file", file), new AbstractMap.SimpleEntry("fields", fields) )); @@ -508,11 +508,11 @@ public class PlanController { @RequestParam("fileId") UUID fileId, @RequestParam("repositoryId") String repositoryId ) throws InvalidAlgorithmParameterException, JAXBException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, IOException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { - logger.debug(new MapLogEntry("preprocessing dmp" + Dmp.class.getSimpleName()).And("transformerId", repositoryId).And("fileId", fileId)); + logger.debug(new MapLogEntry("preprocessing dmp" + Plan.class.getSimpleName()).And("transformerId", repositoryId).And("fileId", fileId)); - PreprocessingDmpModel model = this.dmpService.preprocessingDmp(fileId, repositoryId); + PreprocessingDmpModel model = this.planService.preprocessingPlan(fileId, repositoryId); - this.auditService.track(AuditableAction.Dmp_Import, Map.ofEntries( + this.auditService.track(AuditableAction.Plan_Import, Map.ofEntries( new AbstractMap.SimpleEntry("transformerId", repositoryId), new AbstractMap.SimpleEntry("fileId", fileId) )); @@ -524,22 +524,22 @@ public class PlanController { @OperationWithTenantHeader(summary = "Import a plan from an json file", description = "", responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content( schema = @Schema( - implementation = Dmp.class + implementation = Plan.class )) )) - @ValidationFilterAnnotation(validator = DmpCommonModelConfig.DmpCommonModelConfigValidator.ValidatorName, argumentName = "model") + @ValidationFilterAnnotation(validator = PlanCommonModelConfig.PlanCommonModelConfigValidator.ValidatorName, argumentName = "model") @Transactional - public Dmp importJson( - @RequestBody DmpCommonModelConfig dmpCommonModelConfig, + public Plan importJson( + @RequestBody PlanCommonModelConfig planCommonModelConfig, @Parameter(name = "fields", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fields ) throws InvalidAlgorithmParameterException, JAXBException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, IOException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException { - logger.debug(new MapLogEntry("import json" + Dmp.class.getSimpleName()).And("transformerId", dmpCommonModelConfig.getRepositoryId()).And("file id", dmpCommonModelConfig.getFileId()).And("label", dmpCommonModelConfig.getLabel())); + logger.debug(new MapLogEntry("import json" + Plan.class.getSimpleName()).And("transformerId", planCommonModelConfig.getRepositoryId()).And("file id", planCommonModelConfig.getFileId()).And("label", planCommonModelConfig.getLabel())); - Dmp model = this.dmpService.importJson(dmpCommonModelConfig, fields); + Plan model = this.planService.importJson(planCommonModelConfig, fields); - this.auditService.track(AuditableAction.Dmp_Import, Map.ofEntries( - new AbstractMap.SimpleEntry("transformerId", dmpCommonModelConfig.getRepositoryId()), - new AbstractMap.SimpleEntry("file id", dmpCommonModelConfig.getFileId()), + this.auditService.track(AuditableAction.Plan_Import, Map.ofEntries( + new AbstractMap.SimpleEntry("transformerId", planCommonModelConfig.getRepositoryId()), + new AbstractMap.SimpleEntry("file id", planCommonModelConfig.getFileId()), new AbstractMap.SimpleEntry("fields", fields) )); 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 6bb91ff1c..720752ad9 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/UserController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/UserController.java @@ -18,11 +18,11 @@ 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.PlanAssociatedUser; import org.opencdmp.model.UserRole; -import org.opencdmp.model.builder.DmpAssociatedUserBuilder; +import org.opencdmp.model.builder.PlanAssociatedUserBuilder; import org.opencdmp.model.builder.UserBuilder; -import org.opencdmp.model.censorship.DmpAssociatedUserCensor; +import org.opencdmp.model.censorship.PlanAssociatedUserCensor; import org.opencdmp.model.censorship.UserCensor; import org.opencdmp.model.persist.*; import org.opencdmp.model.persist.actionconfirmation.RemoveCredentialRequestPersist; @@ -107,19 +107,19 @@ public class UserController { return new QueryResult<>(models, count); } - @PostMapping("dmp-associated/query") - public QueryResult queryDmpAssociated(@RequestBody UserLookup lookup) throws MyApplicationException, MyForbiddenException { + @PostMapping("plan-associated/query") + public QueryResult queryDmpAssociated(@RequestBody UserLookup lookup) throws MyApplicationException, MyForbiddenException { logger.debug("querying {}", User.class.getSimpleName()); - this.censorFactory.censor(DmpAssociatedUserCensor.class).censor(lookup.getProject(), null); + this.censorFactory.censor(PlanAssociatedUserCensor.class).censor(lookup.getProject(), null); - UserQuery query = lookup.enrich(this.queryFactory).dmpAssociated(true).isActive(IsActive.Active); + UserQuery query = lookup.enrich(this.queryFactory).planAssociated(true).isActive(IsActive.Active); List data = query.collectAs(lookup.getProject()); - List models = this.builderFactory.builder(DmpAssociatedUserBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(lookup.getProject(), data); + List models = this.builderFactory.builder(PlanAssociatedUserBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(lookup.getProject(), data); long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size(); - this.auditService.track(AuditableAction.User_DmpAssociatedQuery, "lookup", lookup); + this.auditService.track(AuditableAction.User_PlanAssociatedQuery, "lookup", lookup); return new QueryResult<>(models, count); } 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 ace5bb0c9..2e5f89c96 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 @@ -19,26 +19,26 @@ import org.opencdmp.controllers.publicapi.response.DataTableData; import org.opencdmp.controllers.publicapi.types.ApiMessageCode; import org.opencdmp.controllers.publicapi.types.ResponseItem; import org.opencdmp.data.DescriptionEntity; -import org.opencdmp.model.DmpUser; +import org.opencdmp.model.PlanUser; import org.opencdmp.model.builder.description.DescriptionBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; import org.opencdmp.model.description.Description; import org.opencdmp.model.descriptionreference.DescriptionReference; import org.opencdmp.model.descriptiontemplate.*; import org.opencdmp.model.descriptiontemplate.fielddata.BaseFieldData; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.dmpreference.DmpReference; import org.opencdmp.model.mapper.publicapi.DescriptionToPublicApiDatasetListingMapper; import org.opencdmp.model.mapper.publicapi.DescriptionToPublicApiDatasetMapper; import org.opencdmp.model.mapper.publicapi.PlanToPublicApiPlanListingMapper; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.publicapi.listingmodels.DatasetPublicListingModel; import org.opencdmp.model.publicapi.overviewmodels.DatasetPublicModel; import org.opencdmp.model.reference.Reference; import org.opencdmp.model.user.User; import org.opencdmp.query.DescriptionQuery; -import org.opencdmp.query.DmpQuery; +import org.opencdmp.query.PlanQuery; import org.opencdmp.query.lookup.DescriptionLookup; -import org.opencdmp.query.lookup.DmpLookup; +import org.opencdmp.query.lookup.PlanLookup; import org.opencdmp.service.publicapi.PublicApiProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -132,9 +132,9 @@ public class PublicDatasetsDescriptionDocumentation { if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpQuery planQuery = this.queryFactory.query(DmpQuery.class).disableTracking().ids(model.getDmp().getId()).isActive(IsActive.Active); - DmpLookup planLookup = getDmpLookup(); - Dmp plan = this.builderFactory.builder(DmpBuilder.class).build(planLookup.getProject(), planQuery.firstAs(planLookup.getProject())); + PlanQuery planQuery = this.queryFactory.query(PlanQuery.class).disableTracking().ids(model.getPlan().getId()).isActive(IsActive.Active); + PlanLookup planLookup = getDmpLookup(); + Plan plan = this.builderFactory.builder(PlanBuilder.class).build(planLookup.getProject(), planQuery.firstAs(planLookup.getProject())); DatasetPublicModel dataset = this.descriptionToPublicApiDatasetMapper.toPublicModel(model, this.planToPublicApiPlanListingMapper.toPublicListingModel(plan, this.config.getReferenceTypeMap()), this.config.getReferenceTypeMap()); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); @@ -148,8 +148,8 @@ public class PublicDatasetsDescriptionDocumentation { Description._label, Description._description, Description._status, - String.join(".", Description._dmp, Dmp._id), - String.join(".", Description._dmp, Dmp._label), + String.join(".", Description._plan, Plan._id), + String.join(".", Description._plan, Plan._label), String.join(".", Description._createdBy, User._id), String.join(".", Description._createdBy, User._name), String.join(".", Description._descriptionReferences, DescriptionReference._reference, Reference._id), @@ -208,27 +208,27 @@ public class PublicDatasetsDescriptionDocumentation { } @NotNull - private static DmpLookup getDmpLookup() { + private static PlanLookup getDmpLookup() { BaseFieldSet fieldSet = new BaseFieldSet(); Set fields = Set.of( - Dmp._id, - Dmp._label, - Dmp._description, - Dmp._version, - Dmp._groupId, - String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._id)), - String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._name)), - String.join(".", Dmp._dmpUsers, DmpUser._role), - String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._id)), - String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._reference)), - String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._label)), - Dmp._dmpReferences, - Dmp._createdAt, - Dmp._updatedAt, - Dmp._finalizedAt + Plan._id, + Plan._label, + Plan._description, + Plan._version, + Plan._groupId, + String.join(".", Plan._planUsers, String.join(".", PlanUser._user, User._id)), + String.join(".", Plan._planUsers, String.join(".", PlanUser._user, User._name)), + String.join(".", Plan._planUsers, PlanUser._role), + String.join(".", Plan._planReferences, String.join(".", PlanReference._reference, Reference._id)), + String.join(".", Plan._planReferences, String.join(".", PlanReference._reference, Reference._reference)), + String.join(".", Plan._planReferences, String.join(".", PlanReference._reference, Reference._label)), + Plan._planReferences, + Plan._createdAt, + Plan._updatedAt, + Plan._finalizedAt ); fieldSet.setFields(fields); - DmpLookup lookup = new DmpLookup(); + PlanLookup lookup = new PlanLookup(); lookup.setProject(fieldSet); return lookup; } diff --git a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicPlansDocumentation.java b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicPlansDocumentation.java index 73c256508..14d2830d6 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicPlansDocumentation.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicPlansDocumentation.java @@ -18,16 +18,16 @@ import org.opencdmp.controllers.publicapi.request.plan.DataManagmentPlanPublicTa import org.opencdmp.controllers.publicapi.response.DataTableData; import org.opencdmp.controllers.publicapi.types.ApiMessageCode; import org.opencdmp.controllers.publicapi.types.ResponseItem; -import org.opencdmp.data.DmpEntity; -import org.opencdmp.model.DmpDescriptionTemplate; -import org.opencdmp.model.DmpUser; -import org.opencdmp.model.builder.DmpDescriptionTemplateBuilder; -import org.opencdmp.model.builder.dmp.DmpBuilder; -import org.opencdmp.model.dmp.Dmp; -import org.opencdmp.model.dmpblueprint.Section; -import org.opencdmp.model.dmpreference.DmpReference; +import org.opencdmp.data.PlanEntity; +import org.opencdmp.model.PlanDescriptionTemplate; +import org.opencdmp.model.PlanUser; +import org.opencdmp.model.builder.PlanDescriptionTemplateBuilder; +import org.opencdmp.model.builder.plan.PlanBuilder; import org.opencdmp.model.mapper.publicapi.PlanToPublicApiPlanListingMapper; import org.opencdmp.model.mapper.publicapi.PlanToPublicApiPlanMapper; +import org.opencdmp.model.plan.Plan; +import org.opencdmp.model.planblueprint.Section; +import org.opencdmp.model.planreference.PlanReference; import org.opencdmp.model.publicapi.listingmodels.DataManagementPlanPublicListingModel; import org.opencdmp.model.publicapi.overviewmodels.DataManagementPlanPublicModel; import org.opencdmp.model.reference.Definition; @@ -35,10 +35,10 @@ import org.opencdmp.model.reference.Field; import org.opencdmp.model.reference.Reference; import org.opencdmp.model.referencetype.ReferenceType; import org.opencdmp.model.user.User; -import org.opencdmp.query.DmpDescriptionTemplateQuery; -import org.opencdmp.query.DmpQuery; import org.opencdmp.query.EntityDoiQuery; -import org.opencdmp.query.lookup.DmpLookup; +import org.opencdmp.query.PlanDescriptionTemplateQuery; +import org.opencdmp.query.PlanQuery; +import org.opencdmp.query.lookup.PlanLookup; import org.opencdmp.service.publicapi.PublicApiProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -104,12 +104,12 @@ public class PublicPlansDocumentation { @Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Plan.getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest planTableRequest, @RequestParam @Parameter(description = PublicApiStaticHelpers.Plan.getPagedRequestParamDescription, example = "listing") String fieldsGroup ) throws Exception { - DmpLookup lookup = getPlanLookup(fieldsGroup, planTableRequest); - DmpQuery query = lookup.enrich(this.queryFactory).authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active); - long count = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active).count(); + PlanLookup lookup = getPlanLookup(fieldsGroup, planTableRequest); + PlanQuery query = lookup.enrich(this.queryFactory).authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active); + long count = this.queryFactory.query(PlanQuery.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); + List data = query.collectAs(lookup.getProject()); + List models = this.builderFactory.builder(PlanBuilder.class).build(lookup.getProject(), data); DataTableData dataTableData = new DataTableData<>(); dataTableData.setData(models.stream().map(x-> this.planToPublicApiPlanListingMapper.toPublicListingModel(x, this.config.getReferenceTypeMap())).toList()); dataTableData.setTotalCount(count); @@ -117,42 +117,42 @@ public class PublicPlansDocumentation { } @NotNull - private static DmpLookup getPlanLookup(String fieldsGroup, DataManagmentPlanPublicTableRequest request) { + private static PlanLookup getPlanLookup(String fieldsGroup, DataManagmentPlanPublicTableRequest request) { BaseFieldSet fieldSet = new BaseFieldSet(); Set fields; if ("listing".equals(fieldsGroup)) { fields = Set.of( - Dmp._id, - Dmp._label, - Dmp._description, - Dmp._version, - Dmp._groupId, - String.join(".", Dmp._dmpUsers, DmpUser._user, User._id), - String.join(".", Dmp._dmpUsers, DmpUser._user, User._name), - String.join(".", Dmp._dmpUsers, DmpUser._role), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._id), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._type), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._type), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._type, ReferenceType._id), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._label), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._definition, Definition._fields, Field._code), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._definition, Definition._fields, Field._dataType), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._definition, Definition._fields, Field._value), - Dmp._dmpReferences, - Dmp._createdAt, - Dmp._updatedAt, - Dmp._finalizedAt + Plan._id, + Plan._label, + Plan._description, + Plan._version, + Plan._groupId, + String.join(".", Plan._planUsers, PlanUser._user, User._id), + String.join(".", Plan._planUsers, PlanUser._user, User._name), + String.join(".", Plan._planUsers, PlanUser._role), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._id), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._type), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._type), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._type, ReferenceType._id), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._label), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._definition, Definition._fields, Field._code), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._definition, Definition._fields, Field._dataType), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._definition, Definition._fields, Field._value), + Plan._planReferences, + Plan._createdAt, + Plan._updatedAt, + Plan._finalizedAt ); } else { fields = Set.of( - Dmp._id, - Dmp._label, - Dmp._groupId, - Dmp._createdAt + Plan._id, + Plan._label, + Plan._groupId, + Plan._createdAt ); } fieldSet.setFields(fields); - DmpLookup lookup = new DmpLookup(); + PlanLookup lookup = new PlanLookup(); lookup.setProject(fieldSet); return lookup; } @@ -169,37 +169,37 @@ public class PublicPlansDocumentation { ) { BaseFieldSet planFieldSet = new BaseFieldSet(); Set planFields = Set.of( - Dmp._id, - Dmp._label, - Dmp._description, - Dmp._version, - Dmp._groupId, - String.join(".", Dmp._dmpUsers, DmpUser._user, User._id), - String.join(".", Dmp._dmpUsers, DmpUser._user, User._name), - String.join(".", Dmp._dmpUsers, DmpUser._role), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._id), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._type), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._type, ReferenceType._id), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._reference), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._label), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._abbreviation), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._description), - String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._definition), - String.join(".", Dmp._blueprint, org.opencdmp.model.dmpblueprint.Definition._sections, Section._id), - String.join(".", Dmp._blueprint, org.opencdmp.model.dmpblueprint.Definition._sections, Section._ordinal), - Dmp._createdAt, - Dmp._updatedAt, - Dmp._finalizedAt + Plan._id, + Plan._label, + Plan._description, + Plan._version, + Plan._groupId, + String.join(".", Plan._planUsers, PlanUser._user, User._id), + String.join(".", Plan._planUsers, PlanUser._user, User._name), + String.join(".", Plan._planUsers, PlanUser._role), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._id), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._type), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._type, ReferenceType._id), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._reference), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._label), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._abbreviation), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._description), + String.join(".", Plan._planReferences, PlanReference._reference, Reference._definition), + String.join(".", Plan._blueprint, org.opencdmp.model.planblueprint.Definition._sections, Section._id), + String.join(".", Plan._blueprint, org.opencdmp.model.planblueprint.Definition._sections, Section._ordinal), + Plan._createdAt, + Plan._updatedAt, + Plan._finalizedAt ); planFieldSet.setFields(planFields); - 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(planFieldSet, query.firstAs(planFieldSet)); + PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(EnumSet.of(AuthorizationFlags.Public)).ids(UUID.fromString(id)).isActive(IsActive.Active); + Plan model = this.builderFactory.builder(PlanBuilder.class).build(planFieldSet, query.firstAs(planFieldSet)); if (model == null) - throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().entityIds(UUID.fromString(id)).isActive(IsActive.Active); BaseFieldSet templateFieldSet = new BaseFieldSet(); - DmpDescriptionTemplateQuery planDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().dmpIds(UUID.fromString(id)).isActive(IsActive.Active); - List planDescriptionTemplates = this.builderFactory.builder(DmpDescriptionTemplateBuilder.class).build(templateFieldSet, planDescriptionTemplateQuery.collectAs(templateFieldSet)); + PlanDescriptionTemplateQuery planDescriptionTemplateQuery = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().planIds(UUID.fromString(id)).isActive(IsActive.Active); + List planDescriptionTemplates = this.builderFactory.builder(PlanDescriptionTemplateBuilder.class).build(templateFieldSet, planDescriptionTemplateQuery.collectAs(templateFieldSet)); DataManagementPlanPublicModel dataManagementPlan = this.planToPublicApiPlanMapper.toPublicModel(model, entityDoiQuery.collect(), planDescriptionTemplates, this.config.getReferenceTypeMap()); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan)); } diff --git a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/criteria/plan/DataManagementPlanPublicCriteria.java b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/criteria/plan/DataManagementPlanPublicCriteria.java index 2e3b86942..492170359 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/criteria/plan/DataManagementPlanPublicCriteria.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/criteria/plan/DataManagementPlanPublicCriteria.java @@ -1,14 +1,14 @@ package org.opencdmp.controllers.publicapi.criteria.plan; import org.opencdmp.controllers.publicapi.criteria.Criteria; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import io.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.List; import java.util.UUID; -public class DataManagementPlanPublicCriteria extends Criteria { +public class DataManagementPlanPublicCriteria extends Criteria { @ApiModelProperty(value = "periodStart", name = "periodStart", dataType = "Date", example = "2022-01-01T13:19:42.210Z") private Date periodStart; @ApiModelProperty(value = "periodEnd", name = "periodEnd", dataType = "Date", example = "2022-12-31T13:19:42.210Z") diff --git a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/request/plan/DataManagmentPlanPublicTableRequest.java b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/request/plan/DataManagmentPlanPublicTableRequest.java index 75f1d4c9e..62f0c2ad9 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/request/plan/DataManagmentPlanPublicTableRequest.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/request/plan/DataManagmentPlanPublicTableRequest.java @@ -7,15 +7,15 @@ import org.opencdmp.controllers.publicapi.query.PaginationService; import org.opencdmp.controllers.publicapi.query.definition.TableQuery; import org.opencdmp.controllers.publicapi.types.FieldSelectionType; import org.opencdmp.controllers.publicapi.types.SelectionField; -import org.opencdmp.data.DmpEntity; +import org.opencdmp.data.PlanEntity; import jakarta.persistence.criteria.Predicate; import java.util.*; -public class DataManagmentPlanPublicTableRequest extends TableQuery { +public class DataManagmentPlanPublicTableRequest extends TableQuery { - public QueryableList applyCriteria() { - QueryableList query = this.getQuery(); + public QueryableList applyCriteria() { + QueryableList query = this.getQuery(); query.where((builder, root) -> builder.equal(root.get("isPublic"), true)); if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) query.where((builder, root) -> builder.or( @@ -95,7 +95,7 @@ public class DataManagmentPlanPublicTableRequest extends TableQuery applyPaging(QueryableList items) { + public QueryableList applyPaging(QueryableList items) { return PaginationService.applyPaging(items, this); } } diff --git a/backend/web/src/main/resources/config/permissions.yml b/backend/web/src/main/resources/config/permissions.yml index a872ce4b7..f5926df64 100644 --- a/backend/web/src/main/resources/config/permissions.yml +++ b/backend/web/src/main/resources/config/permissions.yml @@ -333,7 +333,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - BrowseDmpAssociatedUser: + BrowsePlanAssociatedUser: roles: - Admin - TenantAdmin @@ -475,8 +475,8 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - # Dmp - BrowseDmp: + # Plan + BrowsePlan: roles: - Admin - TenantAdmin @@ -489,7 +489,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - EditDmp: + EditPlan: roles: - Admin - TenantAdmin @@ -499,7 +499,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - NewDmp: + NewPlan: roles: - Admin - InstallationAdmin @@ -510,7 +510,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - DeleteDmp: + DeletePlan: roles: - Admin - TenantAdmin @@ -521,7 +521,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - DepositDmp: + DepositPlan: roles: - Admin - TenantAdmin @@ -532,7 +532,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - CloneDmp: + ClonePlan: roles: - Admin - TenantAdmin @@ -543,13 +543,13 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - ExportDmp: + ExportPlan: roles: [ ] claims: [ ] clients: [ ] allowAnonymous: false allowAuthenticated: true - CreateNewVersionDmp: + CreateNewVersionPlan: roles: - Admin - TenantAdmin @@ -560,7 +560,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - FinalizeDmp: + FinalizePlan: roles: - Admin - TenantAdmin @@ -571,7 +571,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - UndoFinalizeDmp: + UndoFinalizePlan: roles: - Admin - TenantAdmin @@ -582,7 +582,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - AssignDmpUsers: + AssignPlanUsers: roles: - Admin - TenantAdmin @@ -593,7 +593,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - InviteDmpUsers: + InvitePlanUsers: roles: - Admin - TenantAdmin @@ -604,8 +604,8 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - # DmpBlueprint - BrowseDmpBlueprint: + # PlanBlueprint + BrowsePlanBlueprint: roles: - Admin - InstallationAdmin @@ -616,7 +616,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - EditDmpBlueprint: + EditPlanBlueprint: roles: - Admin - TenantAdmin @@ -624,7 +624,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - CloneDmpBlueprint: + ClonePlanBlueprint: roles: - Admin - TenantAdmin @@ -632,7 +632,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - CreateNewVersionDmpBlueprint: + CreateNewVersionPlanBlueprint: roles: - Admin - TenantAdmin @@ -640,7 +640,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - ExportDmpBlueprint: + ExportPlanBlueprint: roles: - TenantAdmin - TenantPlanManager @@ -648,7 +648,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - ImportDmpBlueprint: + ImportPlanBlueprint: roles: - Admin - TenantAdmin @@ -657,7 +657,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - DeleteDmpBlueprint: + DeletePlanBlueprint: roles: - Admin - TenantAdmin @@ -718,22 +718,22 @@ permissions: allowAnonymous: false allowAuthenticated: false - # DmpReference Permissions - BrowseDmpReference: + # PlanReference Permissions + BrowsePlanReference: roles: - Admin - TenantAdmin clients: [ ] allowAnonymous: false allowAuthenticated: false - EditDmpReference: + EditPlanReference: roles: - Admin - TenantAdmin clients: [ ] allowAnonymous: false allowAuthenticated: false - DeleteDmpReference: + DeletePlanReference: roles: - Admin - TenantAdmin @@ -742,22 +742,22 @@ permissions: allowAnonymous: false allowAuthenticated: false - # DmpUser Permissions - BrowseDmpUser: + # PlanUser Permissions + BrowsePlanUser: roles: - Admin - TenantAdmin clients: [ ] allowAnonymous: false allowAuthenticated: false - EditDmpUser: + EditPlanUser: roles: - Admin - TenantAdmin clients: [ ] allowAnonymous: false allowAuthenticated: false - DeleteDmpUser: + DeletePlanUser: roles: - Admin - TenantAdmin @@ -873,22 +873,22 @@ permissions: allowAnonymous: false allowAuthenticated: false - # DmpDescriptionTemplate Permissions - BrowseDmpDescriptionTemplate: + # PlanDescriptionTemplate Permissions + BrowsePlanDescriptionTemplate: roles: - Admin - TenantAdmin clients: [ ] allowAnonymous: false allowAuthenticated: false - EditDmpDescriptionTemplate: + EditPlanDescriptionTemplate: roles: - Admin - TenantAdmin clients: [ ] allowAnonymous: false allowAuthenticated: false - DeleteDmpDescriptionTemplate: + DeletePlanDescriptionTemplate: roles: - Admin - TenantAdmin @@ -1187,7 +1187,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - ViewDmpBlueprintPage: + ViewPlanBlueprintPage: roles: - Admin - TenantAdmin @@ -1213,7 +1213,7 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false - ViewMyDmpPage: + ViewMyPlanPage: roles: - Admin - TenantAdmin