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

# Conflicts:
#	dmp-frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html
This commit is contained in:
Sofia Papacharalampous 2024-07-04 18:00:45 +03:00
commit caa40cc907
473 changed files with 9986 additions and 9398 deletions

View File

@ -14,39 +14,39 @@ public class AuditableAction {
public static final EventId EntityDoi_Persist = new EventId(2002, "EntityDoi_Persist"); 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 EntityDoi_Delete = new EventId(2003, "EntityDoi_Delete");
public static final EventId DmpBlueprint_Query = new EventId(3000, "DmpBlueprint_Query"); public static final EventId PlanBlueprint_Query = new EventId(3000, "PlanBlueprint_Query");
public static final EventId DmpBlueprint_Lookup = new EventId(3001, "DmpBlueprint_Lookup"); public static final EventId PlanBlueprint_Lookup = new EventId(3001, "PlanBlueprint_Lookup");
public static final EventId DmpBlueprint_Persist = new EventId(3002, "DmpBlueprint_Persist"); public static final EventId PlanBlueprint_Persist = new EventId(3002, "PlanBlueprint_Persist");
public static final EventId DmpBlueprint_Delete = new EventId(3003, "DmpBlueprint_Delete"); public static final EventId PlanBlueprint_Delete = new EventId(3003, "PlanBlueprint_Delete");
public static final EventId DmpBlueprint_Clone = new EventId(3004, "DmpBlueprint_Clone"); 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 PlanBlueprint_PersistNewVersion = new EventId(3005, "PlanBlueprint_PersistNewVersion");
public static final EventId DmpBlueprint_GetXml = new EventId(3006, "DmpBlueprint_GetXml"); public static final EventId PlanBlueprint_GetXml = new EventId(3006, "PlanBlueprint_GetXml");
public static final EventId DmpBlueprint_Import = new EventId(3007, "DmpBlueprint_Import"); 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_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_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_Persist = new EventId(4002, "User_Settings_Persist");
public static final EventId User_Settings_Delete = new EventId(4003, "User_Settings_Delete"); 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 Plan_Query = new EventId(5000, "Plan_Query");
public static final EventId Dmp_Lookup = new EventId(5001, "Dmp_Lookup"); public static final EventId Plan_Lookup = new EventId(5001, "Plan_Lookup");
public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist"); public static final EventId Plan_Persist = new EventId(5002, "Plan_Persist");
public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete"); public static final EventId Plan_Delete = new EventId(5003, "Plan_Delete");
public static final EventId Dmp_Clone = new EventId(5004, "Dmp_Clone"); public static final EventId Plan_Clone = new EventId(5004, "Plan_Clone");
public static final EventId Dmp_PersistNewVersion = new EventId(5005, "Dmp_PersistNewVersion"); public static final EventId Plan_PersistNewVersion = new EventId(5005, "Plan_PersistNewVersion");
public static final EventId Dmp_Assign_Users = new EventId(5006, "Dmp_Assign_Users"); public static final EventId Plan_Assign_Users = new EventId(5006, "Plan_Assign_Users");
public static final EventId Dmp_RemoveUser = new EventId(5007, "Dmp_RemoveUser"); public static final EventId Plan_RemoveUser = new EventId(5007, "Plan_RemoveUser");
public static final EventId Dmp_Invite_Users = new EventId(5008, "Dmp_Invite_Users"); public static final EventId Plan_Invite_Users = new EventId(5008, "Plan_Invite_Users");
public static final EventId Dmp_Invite_Accept = new EventId(5009, "Dmp_Invite_Accept"); public static final EventId Plan_Invite_Accept = new EventId(5009, "Plan_Invite_Accept");
public static final EventId Dmp_PublicQuery = new EventId(5010, "Dmp_PublicQuery"); public static final EventId Plan_PublicQuery = new EventId(5010, "Plan_PublicQuery");
public static final EventId Dmp_Export = new EventId(5011, "Dmp_Export"); public static final EventId Plan_Export = new EventId(5011, "Plan_Export");
public static final EventId Dmp_PublicLookup = new EventId(5012, "Dmp_PublicLookup"); public static final EventId Plan_PublicLookup = new EventId(5012, "Plan_PublicLookup");
public static final EventId Dmp_Finalize = new EventId(5013, "Dmp_Finalize"); public static final EventId Plan_Finalize = new EventId(5013, "Plan_Finalize");
public static final EventId Dmp_Undo_Finalize = new EventId(5014, "Dmp_Undo_Finalize"); public static final EventId Plan_Undo_Finalize = new EventId(5014, "Plan_Undo_Finalize");
public static final EventId Dmp_Validate = new EventId(5015, "Dmp_Validate"); public static final EventId Plan_Validate = new EventId(5015, "Plan_Validate");
public static final EventId Dmp_GetXml = new EventId(5016, "Dmp_GetXml"); public static final EventId Plan_GetXml = new EventId(5016, "Plan_GetXml");
public static final EventId Dmp_Import = new EventId(5017, "Dmp_Import"); public static final EventId Plan_Import = new EventId(5017, "Plan_Import");
public static final EventId Description_Query = new EventId(6000, "Description_Query"); 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_MergeConfirm = new EventId(11011, "User_MergeConfirm");
public static final EventId User_RemoveCredentialRequest = new EventId(11012, "User_RemoveCredentialRequest"); 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_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_AllowMergeAccount = new EventId(11015, "User_AllowMergeAccount");
public static final EventId User_InviteToTenant = new EventId(11016, "User_InviteToTenant"); public static final EventId User_InviteToTenant = new EventId(11016, "User_InviteToTenant");
public static final EventId User_InviteToTenantConfirm = new EventId(11017, "User_InviteToTenantConfirm"); 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_ClearElastic = new EventId(230000, "Maintenance_ClearElastic");
public static final EventId Maintenance_SendUserTouchEvents = new EventId(230001, "Maintenance_SendUserTouchEvents"); 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_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 Maintenance_SendDescriptionTouchEvents = new EventId(230004, "Maintenance_SendDescriptionTouchEvents");
public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup"); public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");

View File

@ -1,26 +1,26 @@
package org.opencdmp.authorization; package org.opencdmp.authorization;
import gr.cite.commons.web.authz.policy.AuthorizationResource; 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 org.opencdmp.commons.enums.UserDescriptionTemplateRole;
import java.util.HashSet; import java.util.HashSet;
public class AffiliatedResource extends AuthorizationResource { public class AffiliatedResource extends AuthorizationResource {
private HashSet<DmpUserRole> dmpUserRoles; private HashSet<PlanUserRole> planUserRoles;
private HashSet<UserDescriptionTemplateRole> userDescriptionTemplateRoles; private HashSet<UserDescriptionTemplateRole> userDescriptionTemplateRoles;
public AffiliatedResource() { public AffiliatedResource() {
this.dmpUserRoles = new HashSet<>(); this.planUserRoles = new HashSet<>();
this.userDescriptionTemplateRoles = new HashSet<>(); this.userDescriptionTemplateRoles = new HashSet<>();
} }
public HashSet<DmpUserRole> getDmpUserRoles() { public HashSet<PlanUserRole> getPlanUserRoles() {
return this.dmpUserRoles; return this.planUserRoles;
} }
public void setDmpUserRoles(HashSet<DmpUserRole> dmpUserRoles) { public void setPlanUserRoles(HashSet<PlanUserRole> planUserRoles) {
this.dmpUserRoles = dmpUserRoles; this.planUserRoles = planUserRoles;
} }
public HashSet<UserDescriptionTemplateRole> getUserDescriptionTemplateRoles() { public HashSet<UserDescriptionTemplateRole> getUserDescriptionTemplateRoles() {

View File

@ -59,7 +59,7 @@ public final class Permission {
public static String ExportUsers = "ExportUsers"; public static String ExportUsers = "ExportUsers";
public static String EditTenantUserRole = "EditTenantUserRole"; public static String EditTenantUserRole = "EditTenantUserRole";
public static String InviteTenantUser = "InviteTenantUser"; public static String InviteTenantUser = "InviteTenantUser";
public static String BrowseDmpAssociatedUser = "BrowseDmpAssociatedUser"; public static String BrowsePlanAssociatedUser = "BrowsePlanAssociatedUser";
//StorageFile //StorageFile
@ -72,38 +72,38 @@ public final class Permission {
public static String EditDescriptionTemplateType = "EditDescriptionTemplateType"; public static String EditDescriptionTemplateType = "EditDescriptionTemplateType";
public static String DeleteDescriptionTemplateType = "DeleteDescriptionTemplateType"; public static String DeleteDescriptionTemplateType = "DeleteDescriptionTemplateType";
//Dmp //Plan
public static String BrowseDmp = "BrowseDmp"; public static String BrowsePlan = "BrowsePlan";
public static String EditDmp = "EditDmp"; public static String EditPlan = "EditPlan";
public static String NewDmp = "NewDmp"; public static String NewPlan = "NewPlan";
public static String DepositDmp = "DepositDmp"; public static String DepositPlan = "DepositPlan";
public static String DeleteDmp = "DeleteDmp"; public static String DeletePlan = "DeletePlan";
public static String CloneDmp = "CloneDmp"; public static String ClonePlan = "ClonePlan";
public static String ExportDmp = "ExportDmp"; public static String ExportPlan = "ExportPlan";
public static String CreateNewVersionDmp = "CreateNewVersionDmp"; public static String CreateNewVersionPlan = "CreateNewVersionPlan";
public static String FinalizeDmp = "FinalizeDmp"; public static String FinalizePlan = "FinalizePlan";
public static String UndoFinalizeDmp = "UndoFinalizeDmp"; public static String UndoFinalizePlan = "UndoFinalizePlan";
public static String AssignDmpUsers = "AssignDmpUsers"; public static String AssignPlanUsers = "AssignPlanUsers";
public static String InviteDmpUsers = "InviteDmpUsers"; public static String InvitePlanUsers = "InvitePlanUsers";
//DmpBlueprint //PlanBlueprint
public static String BrowseDmpBlueprint = "BrowseDmpBlueprint"; public static String BrowsePlanBlueprint = "BrowsePlanBlueprint";
public static String EditDmpBlueprint = "EditDmpBlueprint"; public static String EditPlanBlueprint = "EditPlanBlueprint";
public static String DeleteDmpBlueprint = "DeleteDmpBlueprint"; public static String DeletePlanBlueprint = "DeletePlanBlueprint";
public static String CloneDmpBlueprint = "CloneDmpBlueprint"; public static String ClonePlanBlueprint = "ClonePlanBlueprint";
public static String CreateNewVersionDmpBlueprint = "CreateNewVersionDmpBlueprint"; public static String CreateNewVersionPlanBlueprint = "CreateNewVersionPlanBlueprint";
public static String ExportDmpBlueprint = "ExportDmpBlueprint"; public static String ExportPlanBlueprint = "ExportPlanBlueprint";
public static String ImportDmpBlueprint = "ImportDmpBlueprint"; public static String ImportPlanBlueprint = "ImportPlanBlueprint";
//DmpDescriptionTemplate //PlanDescriptionTemplate
public static String BrowseDmpDescriptionTemplate = "BrowseDmpDescriptionTemplate"; public static String BrowsePlanDescriptionTemplate = "BrowsePlanDescriptionTemplate";
public static String EditDmpDescriptionTemplate = "EditDmpDescriptionTemplate"; public static String EditPlanDescriptionTemplate = "EditPlanDescriptionTemplate";
public static String DeleteDmpDescriptionTemplate = "DeleteDmpDescriptionTemplate"; public static String DeletePlanDescriptionTemplate = "DeletePlanDescriptionTemplate";
//DmpUser //PlanUser
public static String BrowseDmpUser = "BrowseDmpUser"; public static String BrowsePlanUser = "BrowsePlanUser";
public static String EditDmpUser = "EditDmpUser"; public static String EditPlanUser = "EditPlanUser";
public static String DeleteDmpUser = "DeleteDmpUser"; public static String DeletePlanUser = "DeletePlanUser";
//Description //Description
public static String BrowseDescription = "BrowseDescription"; public static String BrowseDescription = "BrowseDescription";
@ -142,10 +142,10 @@ public final class Permission {
public static String EditTag = "EditTag"; public static String EditTag = "EditTag";
public static String DeleteTag = "DeleteTag"; public static String DeleteTag = "DeleteTag";
//DmpReference //PlanReference
public static String BrowseDmpReference = "BrowseDmpReference"; public static String BrowsePlanReference = "BrowsePlanReference";
public static String EditDmpReference = "EditDmpReference"; public static String EditPlanReference = "EditPlanReference";
public static String DeleteDmpReference = "DeleteDmpReference"; public static String DeletePlanReference = "DeletePlanReference";
//DescriptionReference //DescriptionReference
public static String BrowseDescriptionReference = "BrowseDescriptionReference"; public static String BrowseDescriptionReference = "BrowseDescriptionReference";
@ -218,14 +218,14 @@ public final class Permission {
public static String ViewTenantPage = "ViewTenantPage"; public static String ViewTenantPage = "ViewTenantPage";
public static String ViewPrefillingSourcePage = "ViewPrefillingSourcePage"; public static String ViewPrefillingSourcePage = "ViewPrefillingSourcePage";
public static String ViewReferenceTypePage = "ViewReferenceTypePage"; public static String ViewReferenceTypePage = "ViewReferenceTypePage";
public static String ViewReferencePage = "ViewReferencePage"; public static String ViewReferencePaPlge = "ViewReferencePage";
public static String ViewEntityLockPage = "ViewEntityLockPage"; public static String ViewEntityLockPage = "ViewEntityLockPage";
public static String ViewDescriptionTemplatePage = "ViewDescriptionTemplatePage"; public static String ViewDescriptionTemplatePage = "ViewDescriptionTemplatePage";
public static String ViewDmpBlueprintPage = "ViewDmpBlueprintPage"; public static String ViewPlanBlueprintPage = "ViewPlanBlueprintPage";
public static String ViewPublicDescriptionPage = "ViewPublicDescriptionPage"; public static String ViewPublicDescriptionPage = "ViewPublicDescriptionPage";
public static String ViewPublicDmpPage = "ViewPublicDmpPage"; public static String ViewPublicDmpPage = "ViewPublicDmpPage";
public static String ViewMyDescriptionPage = "ViewMyDescriptionPage"; public static String ViewMyDescriptionPage = "ViewMyDescriptionPage";
public static String ViewMyDmpPage = "ViewMyDmpPage"; public static String ViewMyPlanPage = "ViewMyPlanPage";
public static String ViewHomePage = "ViewHomePage"; public static String ViewHomePage = "ViewHomePage";
public static String ViewMineInAppNotificationPage = "ViewMineInAppNotificationPage"; public static String ViewMineInAppNotificationPage = "ViewMineInAppNotificationPage";
public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage"; public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage";

View File

@ -23,7 +23,7 @@ public interface AuthorizationContentResolver {
Map<UUID, AffiliatedResource> descriptionsAffiliation(List<UUID> ids); Map<UUID, AffiliatedResource> descriptionsAffiliation(List<UUID> ids);
AffiliatedResource descriptionsAffiliationBySection(UUID dmpId, UUID sectionId); AffiliatedResource descriptionsAffiliationBySection(UUID planId, UUID sectionId);
Map<UUID, AffiliatedResource> descriptionsAffiliationBySections(UUID dmpId, List<UUID> sectionIds); Map<UUID, AffiliatedResource> descriptionsAffiliationBySections(UUID planId, List<UUID> sectionIds);
} }

View File

@ -10,13 +10,13 @@ import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.data.*; import org.opencdmp.data.*;
import org.opencdmp.model.DmpDescriptionTemplate; import org.opencdmp.model.PlanDescriptionTemplate;
import org.opencdmp.model.DmpUser; import org.opencdmp.model.PlanUser;
import org.opencdmp.model.UserDescriptionTemplate; import org.opencdmp.model.UserDescriptionTemplate;
import org.opencdmp.model.description.Description; import org.opencdmp.model.description.Description;
import org.opencdmp.query.DescriptionQuery; import org.opencdmp.query.DescriptionQuery;
import org.opencdmp.query.DmpDescriptionTemplateQuery; import org.opencdmp.query.PlanDescriptionTemplateQuery;
import org.opencdmp.query.DmpUserQuery; import org.opencdmp.query.PlanUserQuery;
import org.opencdmp.query.UserDescriptionTemplateQuery; import org.opencdmp.query.UserDescriptionTemplateQuery;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -65,12 +65,12 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
} }
if (userId == null || !this.userScope.isSet()) return affiliatedResources; if (userId == null || !this.userScope.isSet()) return affiliatedResources;
List<UUID> idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DmpEntity.class.getSimpleName()); List<UUID> idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, PlanEntity.class.getSimpleName());
if (idsToResolve.isEmpty()) return affiliatedResources; if (idsToResolve.isEmpty()) return affiliatedResources;
List<DmpUserEntity> dmpUsers; List<PlanUserEntity> dmpUsers;
try { try {
this.tenantEntityManager.loadExplictTenantFilters(); 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) { } catch (InvalidApplicationException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
throw new MyApplicationException(e.getMessage()); throw new MyApplicationException(e.getMessage());
@ -82,11 +82,11 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
throw new MyApplicationException(e.getMessage()); throw new MyApplicationException(e.getMessage());
} }
} }
for (DmpUserEntity dmpUser : dmpUsers){ for (PlanUserEntity dmpUser : dmpUsers){
affiliatedResources.get(dmpUser.getDmpId()).getDmpUserRoles().add(dmpUser.getRole()); 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; return affiliatedResources;
} }
@ -172,14 +172,14 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
List<UUID> idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DescriptionEntity.class.getSimpleName()); List<UUID> idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DescriptionEntity.class.getSimpleName());
if (idsToResolve.isEmpty()) return affiliatedResources; if (idsToResolve.isEmpty()) return affiliatedResources;
List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities; List<PlanDescriptionTemplateEntity> planDescriptionTemplateEntities;
List<DmpUserEntity> dmpUsers; List<PlanUserEntity> planUsers;
List<DescriptionEntity> descriptionEntities; List<DescriptionEntity> descriptionEntities;
try { try {
this.tenantEntityManager.loadExplictTenantFilters(); this.tenantEntityManager.loadExplictTenantFilters();
descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(ids).collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._dmpDescriptionTemplate).ensure(Description._dmp)); descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(ids).collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._planDescriptionTemplate).ensure(Description._plan));
dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(descriptionEntities.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().toList()).collectAs(new BaseFieldSet().ensure(DmpDescriptionTemplate._id).ensure(DmpDescriptionTemplate._sectionId)); planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(descriptionEntities.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().toList()).collectAs(new BaseFieldSet().ensure(PlanDescriptionTemplate._id).ensure(PlanDescriptionTemplate._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)); 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) { } catch (InvalidApplicationException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@ -195,17 +195,17 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
Map<UUID, DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntityMap = dmpDescriptionTemplateEntities == null ? new HashMap<>() : dmpDescriptionTemplateEntities.stream().collect(Collectors.toMap(DmpDescriptionTemplateEntity::getId, x-> x)); Map<UUID, PlanDescriptionTemplateEntity> planDescriptionTemplateEntityMap = planDescriptionTemplateEntities == null ? new HashMap<>() : planDescriptionTemplateEntities.stream().collect(Collectors.toMap(PlanDescriptionTemplateEntity::getId, x-> x));
Map<UUID, List<DmpUserEntity>> dmpUsersMap = dmpUsers.stream().collect(Collectors.groupingBy(DmpUserEntity::getDmpId)); Map<UUID, List<PlanUserEntity>> planUsersMap = planUsers.stream().collect(Collectors.groupingBy(PlanUserEntity::getPlanId));
for (DescriptionEntity description : descriptionEntities){ for (DescriptionEntity description : descriptionEntities){
List<DmpUserEntity> dmpDescriptionUsers = dmpUsersMap.getOrDefault(description.getDmpId(), new ArrayList<>()); List<PlanUserEntity> dmpDescriptionUsers = planUsersMap.getOrDefault(description.getPlanId(), new ArrayList<>());
for (DmpUserEntity dmpUser : dmpDescriptionUsers) { for (PlanUserEntity dmpUser : dmpDescriptionUsers) {
if (dmpUser.getSectionId() == null) affiliatedResources.get(description.getId()).getDmpUserRoles().add(dmpUser.getRole()); if (dmpUser.getSectionId() == null) affiliatedResources.get(description.getId()).getPlanUserRoles().add(dmpUser.getRole());
else { else {
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = dmpDescriptionTemplateEntityMap.getOrDefault(description.getDmpDescriptionTemplateId(), null); PlanDescriptionTemplateEntity planDescriptionTemplateEntity = planDescriptionTemplateEntityMap.getOrDefault(description.getPlanDescriptionTemplateId(), null);
if (dmpDescriptionTemplateEntity != null && dmpUser.getSectionId().equals(dmpDescriptionTemplateEntity.getSectionId())){ if (planDescriptionTemplateEntity != null && dmpUser.getSectionId().equals(planDescriptionTemplateEntity.getSectionId())){
affiliatedResources.get(description.getId()).getDmpUserRoles().add(dmpUser.getRole()); affiliatedResources.get(description.getId()).getPlanUserRoles().add(dmpUser.getRole());
} }
} }
} }
@ -216,12 +216,12 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
} }
@Override @Override
public AffiliatedResource descriptionsAffiliationBySection(UUID dmpId, UUID sectionId){ public AffiliatedResource descriptionsAffiliationBySection(UUID planId, UUID sectionId){
return this.descriptionsAffiliationBySections(dmpId, List.of(sectionId)).getOrDefault(sectionId, new AffiliatedResource()); return this.descriptionsAffiliationBySections(planId, List.of(sectionId)).getOrDefault(sectionId, new AffiliatedResource());
} }
@Override @Override
public Map<UUID, AffiliatedResource> descriptionsAffiliationBySections(UUID dmpId, List<UUID> sectionIds){ public Map<UUID, AffiliatedResource> descriptionsAffiliationBySections(UUID planId, List<UUID> sectionIds){
UUID userId = this.userScope.getUserIdSafe(); UUID userId = this.userScope.getUserIdSafe();
Map<UUID, AffiliatedResource> affiliatedResources = new HashMap<>(); Map<UUID, AffiliatedResource> affiliatedResources = new HashMap<>();
for (UUID id : sectionIds){ for (UUID id : sectionIds){
@ -230,10 +230,10 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
if (userId == null || !this.userScope.isSet()) return affiliatedResources; if (userId == null || !this.userScope.isSet()) return affiliatedResources;
List<DmpUserEntity> dmpUsers; List<PlanUserEntity> dmpUsers;
try { try {
this.tenantEntityManager.loadExplictTenantFilters(); 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) { } catch (InvalidApplicationException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
throw new MyApplicationException(e.getMessage()); throw new MyApplicationException(e.getMessage());
@ -247,12 +247,12 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
} }
for (UUID sectionId : sectionIds.stream().distinct().toList()){ for (UUID sectionId : sectionIds.stream().distinct().toList()){
List<DmpUserEntity> dmpSectionUsers = dmpUsers.stream().filter(x-> x.getSectionId() == null || x.getSectionId().equals(sectionId)).toList(); List<PlanUserEntity> dmpSectionUsers = dmpUsers.stream().filter(x-> x.getSectionId() == null || x.getSectionId().equals(sectionId)).toList();
for (DmpUserEntity dmpUser : dmpSectionUsers) { for (PlanUserEntity dmpUser : dmpSectionUsers) {
if (dmpUser.getSectionId() == null) affiliatedResources.get(sectionId).getDmpUserRoles().add(dmpUser.getRole()); if (dmpUser.getSectionId() == null) affiliatedResources.get(sectionId).getPlanUserRoles().add(dmpUser.getRole());
else { else {
if (dmpUser.getSectionId().equals(sectionId)){ if (dmpUser.getSectionId().equals(sectionId)){
affiliatedResources.get(sectionId).getDmpUserRoles().add(dmpUser.getRole()); affiliatedResources.get(sectionId).getPlanUserRoles().add(dmpUser.getRole());
} }
} }
} }

View File

@ -9,7 +9,7 @@ public enum ActionConfirmationType implements DatabaseEnum<Short> {
MergeAccount((short) 0), MergeAccount((short) 0),
RemoveCredential((short) 1), RemoveCredential((short) 1),
DmpInvitation((short) 2), PlanInvitation((short) 2),
UserInviteToTenant ((short) 3); UserInviteToTenant ((short) 3);
private final Short value; private final Short value;

View File

@ -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<Short> {
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<Short, DmpBlueprintExtraFieldDataType> 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);
}
}

View File

@ -5,13 +5,13 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpAccessType implements DatabaseEnum<Short> { public enum PlanAccessType implements DatabaseEnum<Short> {
Public((short) 0), Restricted((short) 1); Public((short) 0), Restricted((short) 1);
private final Short value; private final Short value;
DmpAccessType(Short value) { PlanAccessType(Short value) {
this.value = value; this.value = value;
} }
@ -21,9 +21,9 @@ public enum DmpAccessType implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DmpAccessType> map = EnumUtils.getEnumValueMap(DmpAccessType.class); private static final Map<Short, PlanAccessType> map = EnumUtils.getEnumValueMap(PlanAccessType.class);
public static DmpAccessType of(Short i) { public static PlanAccessType of(Short i) {
return map.get(i); return map.get(i);
} }

View File

@ -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<Short> {
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<Short, PlanBlueprintExtraFieldDataType> 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);
}
}

View File

@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> { public enum PlanBlueprintFieldCategory implements DatabaseEnum<Short> {
System((short) 0), System((short) 0),
Extra((short) 1), Extra((short) 1),
ReferenceType((short) 2); ReferenceType((short) 2);
@ -18,7 +18,7 @@ public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
private final Short value; private final Short value;
DmpBlueprintFieldCategory(Short value) { PlanBlueprintFieldCategory(Short value) {
this.value = value; this.value = value;
} }
@ -27,9 +27,9 @@ public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DmpBlueprintFieldCategory> map = EnumUtils.getEnumValueMap(DmpBlueprintFieldCategory.class); private static final Map<Short, PlanBlueprintFieldCategory> map = EnumUtils.getEnumValueMap(PlanBlueprintFieldCategory.class);
public static DmpBlueprintFieldCategory of(Short i) { public static PlanBlueprintFieldCategory of(Short i) {
return map.get(i); return map.get(i);
} }
} }

View File

@ -5,14 +5,14 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpBlueprintStatus implements DatabaseEnum<Short> { public enum PlanBlueprintStatus implements DatabaseEnum<Short> {
Draft((short) 0), Draft((short) 0),
Finalized((short) 1); Finalized((short) 1);
private final Short value; private final Short value;
DmpBlueprintStatus(Short value) { PlanBlueprintStatus(Short value) {
this.value = value; this.value = value;
} }
@ -21,9 +21,9 @@ public enum DmpBlueprintStatus implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DmpBlueprintStatus> map = EnumUtils.getEnumValueMap(DmpBlueprintStatus.class); private static final Map<Short, PlanBlueprintStatus> map = EnumUtils.getEnumValueMap(PlanBlueprintStatus.class);
public static DmpBlueprintStatus of(Short i) { public static PlanBlueprintStatus of(Short i) {
return map.get(i); return map.get(i);
} }

View File

@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpBlueprintSystemFieldType implements DatabaseEnum<Short> { public enum PlanBlueprintSystemFieldType implements DatabaseEnum<Short> {
Title((short)0), Title((short)0),
Description((short)1), Description((short)1),
@ -15,7 +15,7 @@ public enum DmpBlueprintSystemFieldType implements DatabaseEnum<Short> {
User((short)5); User((short)5);
private final Short value; private final Short value;
DmpBlueprintSystemFieldType(Short value) { PlanBlueprintSystemFieldType(Short value) {
this.value = value; this.value = value;
} }
@ -24,9 +24,9 @@ public enum DmpBlueprintSystemFieldType implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DmpBlueprintSystemFieldType> map = EnumUtils.getEnumValueMap(DmpBlueprintSystemFieldType.class); private static final Map<Short, PlanBlueprintSystemFieldType> map = EnumUtils.getEnumValueMap(PlanBlueprintSystemFieldType.class);
public static DmpBlueprintSystemFieldType of(Short i) { public static PlanBlueprintSystemFieldType of(Short i) {
return map.get(i); return map.get(i);
} }
} }

View File

@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpBlueprintVersionStatus implements DatabaseEnum<Short> { public enum PlanBlueprintVersionStatus implements DatabaseEnum<Short> {
Current((short) 0), Current((short) 0),
Previous((short) 1), Previous((short) 1),
@ -13,7 +13,7 @@ public enum DmpBlueprintVersionStatus implements DatabaseEnum<Short> {
private final Short value; private final Short value;
DmpBlueprintVersionStatus(Short value) { PlanBlueprintVersionStatus(Short value) {
this.value = value; this.value = value;
} }
@ -23,9 +23,9 @@ public enum DmpBlueprintVersionStatus implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DmpBlueprintVersionStatus> map = EnumUtils.getEnumValueMap(DmpBlueprintVersionStatus.class); private static final Map<Short, PlanBlueprintVersionStatus> map = EnumUtils.getEnumValueMap(PlanBlueprintVersionStatus.class);
public static DmpBlueprintVersionStatus of(Short i) { public static PlanBlueprintVersionStatus of(Short i) {
return map.get(i); return map.get(i);
} }

View File

@ -5,13 +5,13 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpStatus implements DatabaseEnum<Short> { public enum PlanStatus implements DatabaseEnum<Short> {
Draft((short) 0), Finalized((short) 1); Draft((short) 0), Finalized((short) 1);
private final Short value; private final Short value;
DmpStatus(Short value) { PlanStatus(Short value) {
this.value = value; this.value = value;
} }
@ -21,9 +21,9 @@ public enum DmpStatus implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DmpStatus> map = EnumUtils.getEnumValueMap(DmpStatus.class); private static final Map<Short, PlanStatus> map = EnumUtils.getEnumValueMap(PlanStatus.class);
public static DmpStatus of(Short i) { public static PlanStatus of(Short i) {
return map.get(i); return map.get(i);
} }

View File

@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpUserRole implements DatabaseEnum<Short> { public enum PlanUserRole implements DatabaseEnum<Short> {
Owner((short) 0), Owner((short) 0),
Viewer((short) 1), Viewer((short) 1),
@ -14,7 +14,7 @@ public enum DmpUserRole implements DatabaseEnum<Short> {
private final Short value; private final Short value;
DmpUserRole(Short value) { PlanUserRole(Short value) {
this.value = value; this.value = value;
} }
@ -24,9 +24,9 @@ public enum DmpUserRole implements DatabaseEnum<Short> {
return this.value; return this.value;
} }
private static final Map<Short, DmpUserRole> map = EnumUtils.getEnumValueMap(DmpUserRole.class); private static final Map<Short, PlanUserRole> map = EnumUtils.getEnumValueMap(PlanUserRole.class);
public static DmpUserRole of(Short i) { public static PlanUserRole of(Short i) {
return map.get(i); return map.get(i);
} }

View File

@ -5,14 +5,14 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpValidationOutput implements DatabaseEnum<Short> { public enum PlanValidationOutput implements DatabaseEnum<Short> {
Valid((short) 1), Valid((short) 1),
Invalid((short) 2); Invalid((short) 2);
private final Short value; private final Short value;
DmpValidationOutput(Short value) { PlanValidationOutput(Short value) {
this.value = value; this.value = value;
} }
@ -21,9 +21,9 @@ public enum DmpValidationOutput implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DmpValidationOutput> map = EnumUtils.getEnumValueMap(DmpValidationOutput.class); private static final Map<Short, PlanValidationOutput> map = EnumUtils.getEnumValueMap(PlanValidationOutput.class);
public static DmpValidationOutput of(Short i) { public static PlanValidationOutput of(Short i) {
return map.get(i); return map.get(i);
} }

View File

@ -5,7 +5,7 @@ import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DmpVersionStatus implements DatabaseEnum<Short> { public enum PlanVersionStatus implements DatabaseEnum<Short> {
Current((short) 0), Current((short) 0),
Previous((short) 1), Previous((short) 1),
@ -13,7 +13,7 @@ public enum DmpVersionStatus implements DatabaseEnum<Short> {
private final Short value; private final Short value;
DmpVersionStatus(Short value) { PlanVersionStatus(Short value) {
this.value = value; this.value = value;
} }
@ -23,9 +23,9 @@ public enum DmpVersionStatus implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DmpVersionStatus> map = EnumUtils.getEnumValueMap(DmpVersionStatus.class); private static final Map<Short, PlanVersionStatus> map = EnumUtils.getEnumValueMap(PlanVersionStatus.class);
public static DmpVersionStatus of(Short i) { public static PlanVersionStatus of(Short i) {
return map.get(i); return map.get(i);
} }

View File

@ -7,7 +7,7 @@ import java.util.Map;
public enum RecentActivityItemType implements DatabaseEnum<Short> { public enum RecentActivityItemType implements DatabaseEnum<Short> {
Dmp((short) 0), Plan((short) 0),
Description((short) 1); Description((short) 1);
private final Short value; private final Short value;

View File

@ -1,22 +1,22 @@
package org.opencdmp.commons.types.actionconfirmation; package org.opencdmp.commons.types.actionconfirmation;
import org.opencdmp.commons.enums.DmpUserRole; import org.opencdmp.commons.enums.PlanUserRole;
import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;
import java.util.UUID; import java.util.UUID;
@XmlRootElement(name = "dmp-invitation") @XmlRootElement(name = "dmp-invitation")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DmpInvitationEntity { public class PlanInvitationEntity {
@XmlAttribute(name = "email") @XmlAttribute(name = "email")
private String email; private String email;
@XmlAttribute(name = "dmp") @XmlAttribute(name = "dmp")
private UUID dmpId; private UUID planId;
@XmlAttribute(name = "dmp-role") @XmlAttribute(name = "dmp-role")
private DmpUserRole role; private PlanUserRole role;
public String getEmail() { public String getEmail() {
return email; return email;
@ -26,19 +26,19 @@ public class DmpInvitationEntity {
this.email = email; this.email = email;
} }
public UUID getDmpId() { public UUID getPlanId() {
return dmpId; return planId;
} }
public void setDmpId(UUID dmpId) { public void setPlanId(UUID planId) {
this.dmpId = dmpId; this.planId = planId;
} }
public DmpUserRole getRole() { public PlanUserRole getRole() {
return role; return role;
} }
public void setRole(DmpUserRole role) { public void setRole(PlanUserRole role) {
this.role = role; this.role = role;
} }
} }

View File

@ -1,27 +0,0 @@
package org.opencdmp.commons.types.dmp;
import java.util.List;
public class DmpPropertiesEntity {
private List<DmpBlueprintValueEntity> dmpBlueprintValues;
private List<DmpContactEntity> contacts;
public List<DmpBlueprintValueEntity> getDmpBlueprintValues() {
return this.dmpBlueprintValues;
}
public void setDmpBlueprintValues(List<DmpBlueprintValueEntity> dmpBlueprintValues) {
this.dmpBlueprintValues = dmpBlueprintValues;
}
public List<DmpContactEntity> getContacts() {
return this.contacts;
}
public void setContacts(List<DmpContactEntity> contacts) {
this.contacts = contacts;
}
}

View File

@ -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;
}
}

View File

@ -1,9 +1,9 @@
package org.opencdmp.commons.types.dmp; package org.opencdmp.commons.types.plan;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
public class DmpBlueprintValueEntity { public class PlanBlueprintValueEntity {
private UUID fieldId; private UUID fieldId;

View File

@ -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; private String firstName;

View File

@ -0,0 +1,27 @@
package org.opencdmp.commons.types.plan;
import java.util.List;
public class PlanPropertiesEntity {
private List<PlanBlueprintValueEntity> planBlueprintValues;
private List<PlanContactEntity> contacts;
public List<PlanBlueprintValueEntity> getPlanBlueprintValues() {
return this.planBlueprintValues;
}
public void setPlanBlueprintValues(List<PlanBlueprintValueEntity> planBlueprintValues) {
this.planBlueprintValues = planBlueprintValues;
}
public List<PlanContactEntity> getContacts() {
return this.contacts;
}
public void setContacts(List<PlanContactEntity> contacts) {
this.contacts = contacts;
}
}

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
@ -11,7 +11,7 @@ import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DmpBlueprintValueImportExport { public class PlanBlueprintValueImportExport {
@XmlElement(name = "fieldId") @XmlElement(name = "fieldId")
private UUID fieldId; private UUID fieldId;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
@ -6,7 +6,7 @@ import jakarta.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DmpContactImportExport { public class PlanContactImportExport {
@XmlElement(name = "name") @XmlElement(name = "name")
private String name; private String name;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
@ -7,7 +7,7 @@ import jakarta.xml.bind.annotation.XmlElement;
import java.util.UUID; import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DmpDescriptionTemplateImportExport { public class PlanDescriptionTemplateImportExport {
@XmlElement(name = "descriptionTemplateGroupId") @XmlElement(name = "descriptionTemplateGroupId")
private UUID descriptionTemplateGroupId; private UUID descriptionTemplateGroupId;

View File

@ -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.*;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 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.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 org.opencdmp.commons.xmladapter.InstantXmlAdapter;
import java.time.Instant; import java.time.Instant;
@ -13,7 +13,7 @@ import java.util.UUID;
@XmlRootElement(name = "dmp") @XmlRootElement(name = "dmp")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DmpImportExport { public class PlanImportExport {
@XmlElement(name = "id") @XmlElement(name = "id")
private UUID id; private UUID id;
@ -28,18 +28,18 @@ public class DmpImportExport {
private String language; private String language;
@XmlElement(name = "access") @XmlElement(name = "access")
private DmpAccessType access; private PlanAccessType access;
@XmlElement(name = "version") @XmlElement(name = "version")
private Short version; private Short version;
@XmlElementWrapper(name = "contacts") @XmlElementWrapper(name = "contacts")
@XmlElement(name = "contact") @XmlElement(name = "contact")
private List<DmpContactImportExport> contacts; private List<PlanContactImportExport> contacts;
@XmlElementWrapper(name = "users") @XmlElementWrapper(name = "users")
@XmlElement(name = "user") @XmlElement(name = "user")
private List<DmpUserImportExport> users; private List<PlanUserImportExport> users;
@XmlElement(name = "finalizedAt") @XmlElement(name = "finalizedAt")
@XmlJavaTypeAdapter(InstantXmlAdapter.class) @XmlJavaTypeAdapter(InstantXmlAdapter.class)
@ -54,15 +54,15 @@ public class DmpImportExport {
@XmlElementWrapper(name = "blueprintValues") @XmlElementWrapper(name = "blueprintValues")
@XmlElement(name = "blueprintValue") @XmlElement(name = "blueprintValue")
private List<DmpBlueprintValueImportExport> blueprintValues; private List<PlanBlueprintValueImportExport> blueprintValues;
@XmlElementWrapper(name = "descriptionTemplates") @XmlElementWrapper(name = "descriptionTemplates")
@XmlElement(name = "descriptionTemplate") @XmlElement(name = "descriptionTemplate")
private List<DmpDescriptionTemplateImportExport> descriptionTemplates; private List<PlanDescriptionTemplateImportExport> descriptionTemplates;
@XmlElementWrapper(name = "references") @XmlElementWrapper(name = "references")
@XmlElement(name = "reference") @XmlElement(name = "reference")
private List<DmpReferenceImportExport> references; private List<PlanReferenceImportExport> references;
@XmlElementWrapper(name = "descriptions") @XmlElementWrapper(name = "descriptions")
@XmlElement(name = "description") @XmlElement(name = "description")
@ -101,27 +101,27 @@ public class DmpImportExport {
} }
public DmpAccessType getAccess() { public PlanAccessType getAccess() {
return this.access; return this.access;
} }
public void setAccess(DmpAccessType access) { public void setAccess(PlanAccessType access) {
this.access = access; this.access = access;
} }
public List<DmpContactImportExport> getContacts() { public List<PlanContactImportExport> getContacts() {
return this.contacts; return this.contacts;
} }
public void setContacts(List<DmpContactImportExport> contacts) { public void setContacts(List<PlanContactImportExport> contacts) {
this.contacts = contacts; this.contacts = contacts;
} }
public List<DmpUserImportExport> getUsers() { public List<PlanUserImportExport> getUsers() {
return this.users; return this.users;
} }
public void setUsers(List<DmpUserImportExport> users) { public void setUsers(List<PlanUserImportExport> users) {
this.users = users; this.users = users;
} }
@ -149,27 +149,27 @@ public class DmpImportExport {
this.blueprint = blueprint; this.blueprint = blueprint;
} }
public List<DmpBlueprintValueImportExport> getBlueprintValues() { public List<PlanBlueprintValueImportExport> getBlueprintValues() {
return this.blueprintValues; return this.blueprintValues;
} }
public void setBlueprintValues(List<DmpBlueprintValueImportExport> blueprintValues) { public void setBlueprintValues(List<PlanBlueprintValueImportExport> blueprintValues) {
this.blueprintValues = blueprintValues; this.blueprintValues = blueprintValues;
} }
public List<DmpDescriptionTemplateImportExport> getDescriptionTemplates() { public List<PlanDescriptionTemplateImportExport> getDescriptionTemplates() {
return this.descriptionTemplates; return this.descriptionTemplates;
} }
public void setDescriptionTemplates(List<DmpDescriptionTemplateImportExport> descriptionTemplates) { public void setDescriptionTemplates(List<PlanDescriptionTemplateImportExport> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates; this.descriptionTemplates = descriptionTemplates;
} }
public List<DmpReferenceImportExport> getReferences() { public List<PlanReferenceImportExport> getReferences() {
return this.references; return this.references;
} }
public void setReferences(List<DmpReferenceImportExport> references) { public void setReferences(List<PlanReferenceImportExport> references) {
this.references = references; this.references = references;
} }

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
@ -8,7 +8,7 @@ import org.opencdmp.commons.enums.ReferenceSourceType;
import java.util.UUID; import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DmpReferenceImportExport { public class PlanReferenceImportExport {
@XmlElement(name = "id") @XmlElement(name = "id")
private UUID id; private UUID id;
@ -19,7 +19,7 @@ public class DmpReferenceImportExport {
@XmlElement(name = "fieldId") @XmlElement(name = "fieldId")
private UUID fieldId; private UUID fieldId;
@XmlElement(name = "type") @XmlElement(name = "type")
private DmpReferenceTypeImportExport type; private PlanReferenceTypeImportExport type;
@XmlElement(name = "source") @XmlElement(name = "source")
private String source; private String source;
@XmlElement(name = "sourceType") @XmlElement(name = "sourceType")
@ -49,11 +49,11 @@ public class DmpReferenceImportExport {
this.reference = reference; this.reference = reference;
} }
public DmpReferenceTypeImportExport getType() { public PlanReferenceTypeImportExport getType() {
return this.type; return this.type;
} }
public void setType(DmpReferenceTypeImportExport type) { public void setType(PlanReferenceTypeImportExport type) {
this.type = type; this.type = type;
} }

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import org.opencdmp.commons.enums.DmpUserRole;
import java.util.UUID; import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DmpReferenceTypeImportExport { public class PlanReferenceTypeImportExport {
@XmlElement(name = "id") @XmlElement(name = "id")
private UUID id; private UUID id;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import org.opencdmp.commons.enums.DmpUserRole; import org.opencdmp.commons.enums.PlanUserRole;
import java.util.UUID; import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DmpUserImportExport { public class PlanUserImportExport {
@XmlElement(name = "id") @XmlElement(name = "id")
private UUID id; private UUID id;
@ -17,7 +17,7 @@ public class DmpUserImportExport {
private String name; private String name;
@XmlElement(name = "role") @XmlElement(name = "role")
private DmpUserRole role; private PlanUserRole role;
@XmlElement(name = "sectionId") @XmlElement(name = "sectionId")
private UUID sectionId; private UUID sectionId;
@ -38,11 +38,11 @@ public class DmpUserImportExport {
this.name = name; this.name = name;
} }
public DmpUserRole getRole() { public PlanUserRole getRole() {
return this.role; return this.role;
} }
public void setRole(DmpUserRole role) { public void setRole(PlanUserRole role) {
this.role = role; this.role = role;
} }

View File

@ -1,4 +1,4 @@
package org.opencdmp.commons.types.dmpblueprint; package org.opencdmp.commons.types.planblueprint;
import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;

View File

@ -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;
}
}

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute; 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.List;
import java.util.UUID; import java.util.UUID;
@ -14,7 +14,7 @@ public abstract class FieldEntity {
private UUID id; private UUID id;
@XmlAttribute(name="category") @XmlAttribute(name="category")
private DmpBlueprintFieldCategory category; private PlanBlueprintFieldCategory category;
@XmlAttribute(name="label") @XmlAttribute(name="label")
private String label; private String label;
@ -41,10 +41,10 @@ public abstract class FieldEntity {
this.id = id; this.id = id;
} }
public DmpBlueprintFieldCategory getCategory() { public PlanBlueprintFieldCategory getCategory() {
return this.category; return this.category;
} }
public void setCategory(DmpBlueprintFieldCategory category) { public void setCategory(PlanBlueprintFieldCategory category) {
this.category = category; this.category = category;
} }

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;

View File

@ -1,7 +1,7 @@
package org.opencdmp.commons.types.dmpblueprint; package org.opencdmp.commons.types.planblueprint;
import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;
import org.opencdmp.commons.enums.DmpBlueprintFieldCategory; import org.opencdmp.commons.enums.PlanBlueprintFieldCategory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -24,9 +24,9 @@ public class SectionEntity {
@XmlElementWrapper(name = "fields") @XmlElementWrapper(name = "fields")
@XmlElements({ @XmlElements({
@XmlElement(name = DmpBlueprintFieldCategory.Names.Extra, type = ExtraFieldEntity.class), @XmlElement(name = PlanBlueprintFieldCategory.Names.Extra, type = ExtraFieldEntity.class),
@XmlElement(name = DmpBlueprintFieldCategory.Names.System, type = SystemFieldEntity.class), @XmlElement(name = PlanBlueprintFieldCategory.Names.System, type = SystemFieldEntity.class),
@XmlElement(name = DmpBlueprintFieldCategory.Names.ReferenceType, type = ReferenceTypeFieldEntity.class), @XmlElement(name = PlanBlueprintFieldCategory.Names.ReferenceType, type = ReferenceTypeFieldEntity.class),
}) })
private List<FieldEntity> fields; private List<FieldEntity> fields;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType; import org.opencdmp.commons.enums.PlanBlueprintSystemFieldType;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class SystemFieldEntity extends FieldEntity { public class SystemFieldEntity extends FieldEntity {
@XmlAttribute(name="type") @XmlAttribute(name="type")
private DmpBlueprintSystemFieldType type; private PlanBlueprintSystemFieldType type;
public DmpBlueprintSystemFieldType getType() { public PlanBlueprintSystemFieldType getType() {
return this.type; return this.type;
} }
public void setType(DmpBlueprintSystemFieldType type) { public void setType(PlanBlueprintSystemFieldType type) {
this.type = type; this.type = type;
} }
} }

View File

@ -1,4 +1,4 @@
package org.opencdmp.commons.types.dmpblueprint.importexport; package org.opencdmp.commons.types.planblueprint.importexport;
import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; 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.List;
import java.util.UUID; import java.util.UUID;
@ -15,7 +15,7 @@ public class BlueprintExtraFieldImportExport {
@XmlElement(name = "id") @XmlElement(name = "id")
private UUID id; private UUID id;
@XmlElement(name = "type") @XmlElement(name = "type")
private DmpBlueprintExtraFieldDataType type; private PlanBlueprintExtraFieldDataType type;
@XmlElement(name = "label") @XmlElement(name = "label")
private String label; private String label;
@XmlElement(name = "placeholder") @XmlElement(name = "placeholder")
@ -37,11 +37,11 @@ public class BlueprintExtraFieldImportExport {
this.id = id; this.id = id;
} }
public DmpBlueprintExtraFieldDataType getType() { public PlanBlueprintExtraFieldDataType getType() {
return this.type; return this.type;
} }
public void setType(DmpBlueprintExtraFieldDataType type) { public void setType(PlanBlueprintExtraFieldDataType type) {
this.type = type; this.type = type;
} }

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
@ -18,7 +18,7 @@ public class BlueprintImportExport {
private String label; private String label;
@XmlElement(name = "definition") @XmlElement(name = "definition")
private BlueprintDefinitionImportExport dmpBlueprintDefinition; private BlueprintDefinitionImportExport planBlueprintDefinition;
@XmlElement(name = "groupId") @XmlElement(name = "groupId")
private UUID groupId; private UUID groupId;
@ -39,12 +39,12 @@ public class BlueprintImportExport {
this.label = label; this.label = label;
} }
public BlueprintDefinitionImportExport getDmpBlueprintDefinition() { public BlueprintDefinitionImportExport getPlanBlueprintDefinition() {
return this.dmpBlueprintDefinition; return this.planBlueprintDefinition;
} }
public void setDmpBlueprintDefinition(BlueprintDefinitionImportExport dmpBlueprintDefinition) { public void setPlanBlueprintDefinition(BlueprintDefinitionImportExport planBlueprintDefinition) {
this.dmpBlueprintDefinition = dmpBlueprintDefinition; this.planBlueprintDefinition = planBlueprintDefinition;
} }
public UUID getGroupId() { public UUID getGroupId() {

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;

View File

@ -1,4 +1,4 @@
package org.opencdmp.commons.types.dmpblueprint.importexport; package org.opencdmp.commons.types.planblueprint.importexport;
import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;

View File

@ -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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; 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.List;
import java.util.UUID; import java.util.UUID;
@ -15,7 +15,7 @@ public class BlueprintSystemFieldImportExport {
@XmlElement(name = "id") @XmlElement(name = "id")
private UUID id; private UUID id;
@XmlElement(name = "type") @XmlElement(name = "type")
private DmpBlueprintSystemFieldType type; private PlanBlueprintSystemFieldType type;
@XmlElement(name = "label") @XmlElement(name = "label")
private String label; private String label;
@XmlElement(name = "placeholder") @XmlElement(name = "placeholder")
@ -37,11 +37,11 @@ public class BlueprintSystemFieldImportExport {
this.id = id; this.id = id;
} }
public DmpBlueprintSystemFieldType getType() { public PlanBlueprintSystemFieldType getType() {
return this.type; return this.type;
} }
public void setType(DmpBlueprintSystemFieldType type) { public void setType(PlanBlueprintSystemFieldType type) {
this.type = type; this.type = type;
} }

View File

@ -1,8 +1,8 @@
package org.opencdmp.commons.types.dmpreference; package org.opencdmp.commons.types.planreference;
import java.util.UUID; import java.util.UUID;
public class DmpReferenceDataEntity { public class PlanReferenceDataEntity {
private UUID blueprintFieldId; private UUID blueprintFieldId;
public UUID getBlueprintFieldId() { public UUID getBlueprintFieldId() {

View File

@ -71,12 +71,12 @@ public class DescriptionEntity extends TenantScopedBaseEntity {
public static final String _createdById = "createdById"; public static final String _createdById = "createdById";
@Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false) @Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false)
private UUID dmpDescriptionTemplateId; private UUID planDescriptionTemplateId;
public static final String _dmpDescriptionTemplateId = "dmpDescriptionTemplateId"; public static final String _planDescriptionTemplateId = "planDescriptionTemplateId";
@Column(name = "dmp", columnDefinition = "uuid", nullable = false) @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", columnDefinition = "uuid", nullable = false) @Column(name = "description_template", columnDefinition = "uuid", nullable = false)
private UUID descriptionTemplateId; private UUID descriptionTemplateId;
@ -164,20 +164,20 @@ public class DescriptionEntity extends TenantScopedBaseEntity {
this.createdById = createdById; this.createdById = createdById;
} }
public UUID getDmpDescriptionTemplateId() { public UUID getPlanDescriptionTemplateId() {
return this.dmpDescriptionTemplateId; return this.planDescriptionTemplateId;
} }
public void setDmpDescriptionTemplateId(UUID dmpDescriptionTemplateId) { public void setPlanDescriptionTemplateId(UUID planDescriptionTemplateId) {
this.dmpDescriptionTemplateId = dmpDescriptionTemplateId; this.planDescriptionTemplateId = planDescriptionTemplateId;
} }
public UUID getDmpId() { public UUID getPlanId() {
return this.dmpId; return this.planId;
} }
public void setDmpId(UUID dmpId) { public void setPlanId(UUID planId) {
this.dmpId = dmpId; this.planId = planId;
} }
public UUID getDescriptionTemplateId() { public UUID getDescriptionTemplateId() {

View File

@ -1,10 +1,10 @@
package org.opencdmp.data; package org.opencdmp.data;
import org.opencdmp.commons.enums.DmpBlueprintStatus; import org.opencdmp.commons.enums.PlanBlueprintStatus;
import org.opencdmp.commons.enums.DmpBlueprintVersionStatus; import org.opencdmp.commons.enums.PlanBlueprintVersionStatus;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.data.converters.DmpBlueprintVersionStatusConverter; import org.opencdmp.data.converters.PlanBlueprintVersionStatusConverter;
import org.opencdmp.data.converters.enums.DmpBlueprintStatusConverter; import org.opencdmp.data.converters.enums.PlanBlueprintStatusConverter;
import org.opencdmp.data.converters.enums.IsActiveConverter; import org.opencdmp.data.converters.enums.IsActiveConverter;
import org.opencdmp.data.tenant.TenantScopedBaseEntity; import org.opencdmp.data.tenant.TenantScopedBaseEntity;
import org.opencdmp.data.types.SQLXMLType; import org.opencdmp.data.types.SQLXMLType;
@ -16,7 +16,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"DmpBlueprint\"") @Table(name = "\"DmpBlueprint\"")
public class DmpBlueprintEntity extends TenantScopedBaseEntity { public class PlanBlueprintEntity extends TenantScopedBaseEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
@ -24,7 +24,7 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity {
public static final String _id = "id"; 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; private String label;
public static final String _label = "label"; public static final String _label = "label";
@ -38,8 +38,8 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity {
public static final String _definition = "definition"; public static final String _definition = "definition";
@Column(name = "status", nullable = false) @Column(name = "status", nullable = false)
@Convert(converter = DmpBlueprintStatusConverter.class) @Convert(converter = PlanBlueprintStatusConverter.class)
private DmpBlueprintStatus status; private PlanBlueprintStatus status;
public static final String _status = "status"; public static final String _status = "status";
@ -54,8 +54,8 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity {
public static final String _version = "version"; public static final String _version = "version";
@Column(name = "version_status", nullable = false) @Column(name = "version_status", nullable = false)
@Convert(converter = DmpBlueprintVersionStatusConverter.class) @Convert(converter = PlanBlueprintVersionStatusConverter.class)
private DmpBlueprintVersionStatus versionStatus; private PlanBlueprintVersionStatus versionStatus;
public static final String _versionStatus = "versionStatus"; public static final String _versionStatus = "versionStatus";
@ -99,11 +99,11 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity {
this.definition = definition; this.definition = definition;
} }
public DmpBlueprintStatus getStatus() { public PlanBlueprintStatus getStatus() {
return status; return status;
} }
public void setStatus(DmpBlueprintStatus status) { public void setStatus(PlanBlueprintStatus status) {
this.status = status; this.status = status;
} }
@ -123,11 +123,11 @@ public class DmpBlueprintEntity extends TenantScopedBaseEntity {
this.version = version; this.version = version;
} }
public DmpBlueprintVersionStatus getVersionStatus() { public PlanBlueprintVersionStatus getVersionStatus() {
return versionStatus; return versionStatus;
} }
public void setVersionStatus(DmpBlueprintVersionStatus versionStatus) { public void setVersionStatus(PlanBlueprintVersionStatus versionStatus) {
this.versionStatus = versionStatus; this.versionStatus = versionStatus;
} }

View File

@ -10,7 +10,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"DmpDescriptionTemplate\"") @Table(name = "\"DmpDescriptionTemplate\"")
public class DmpDescriptionTemplateEntity extends TenantScopedBaseEntity { public class PlanDescriptionTemplateEntity extends TenantScopedBaseEntity {
@Id @Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @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"; public static final String _id = "id";
@Column(name = "dmp", columnDefinition = "uuid", nullable = false) @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) @Column(name = "description_template_group", columnDefinition = "uuid", nullable = false)
private UUID descriptionTemplateGroupId; private UUID descriptionTemplateGroupId;
@ -57,12 +57,12 @@ public class DmpDescriptionTemplateEntity extends TenantScopedBaseEntity {
this.id = id; this.id = id;
} }
public UUID getDmpId() { public UUID getPlanId() {
return this.dmpId; return this.planId;
} }
public void setDmpId(UUID dmpId) { public void setPlanId(UUID planId) {
this.dmpId = dmpId; this.planId = planId;
} }
public UUID getDescriptionTemplateGroupId() { public UUID getDescriptionTemplateGroupId() {

View File

@ -1,13 +1,13 @@
package org.opencdmp.data; package org.opencdmp.data;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.opencdmp.commons.enums.DmpAccessType; import org.opencdmp.commons.enums.PlanAccessType;
import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.commons.enums.DmpVersionStatus; import org.opencdmp.commons.enums.PlanVersionStatus;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.data.converters.enums.DmpAccessTypeNullableConverter; import org.opencdmp.data.converters.enums.PlanAccessTypeNullableConverter;
import org.opencdmp.data.converters.enums.DmpStatusConverter; import org.opencdmp.data.converters.enums.PlanStatusConverter;
import org.opencdmp.data.converters.enums.DmpVersionStatusConverter; import org.opencdmp.data.converters.enums.PlanVersionStatusConverter;
import org.opencdmp.data.converters.enums.IsActiveConverter; import org.opencdmp.data.converters.enums.IsActiveConverter;
import org.opencdmp.data.tenant.TenantScopedBaseEntity; import org.opencdmp.data.tenant.TenantScopedBaseEntity;
@ -16,7 +16,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"Dmp\"") @Table(name = "\"Dmp\"")
public class DmpEntity extends TenantScopedBaseEntity { public class PlanEntity extends TenantScopedBaseEntity {
@Id @Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @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"; public static final String _version = "version";
@Column(name = "version_status", nullable = false) @Column(name = "version_status", nullable = false)
@Convert(converter = DmpVersionStatusConverter.class) @Convert(converter = PlanVersionStatusConverter.class)
private DmpVersionStatus versionStatus; private PlanVersionStatus versionStatus;
public static final String _versionStatus = "versionStatus"; public static final String _versionStatus = "versionStatus";
@Column(name = "status", nullable = false) @Column(name = "status", nullable = false)
@Convert(converter = DmpStatusConverter.class) @Convert(converter = PlanStatusConverter.class)
private DmpStatus status; private PlanStatus status;
public static final String _status = "status"; public static final String _status = "status";
@ -89,8 +89,8 @@ public class DmpEntity extends TenantScopedBaseEntity {
public static final String _creatorId = "creatorId"; public static final String _creatorId = "creatorId";
@Column(name = "access_type", nullable = true) @Column(name = "access_type", nullable = true)
@Convert(converter = DmpAccessTypeNullableConverter.class) @Convert(converter = PlanAccessTypeNullableConverter.class)
private DmpAccessType accessType; private PlanAccessType accessType;
public static final String _accessType = "accessType"; public static final String _accessType = "accessType";
@ -133,11 +133,11 @@ public class DmpEntity extends TenantScopedBaseEntity {
this.version = version; this.version = version;
} }
public DmpStatus getStatus() { public PlanStatus getStatus() {
return this.status; return this.status;
} }
public void setStatus(DmpStatus status) { public void setStatus(PlanStatus status) {
this.status = status; this.status = status;
} }
@ -205,11 +205,11 @@ public class DmpEntity extends TenantScopedBaseEntity {
this.creatorId = creatorId; this.creatorId = creatorId;
} }
public DmpAccessType getAccessType() { public PlanAccessType getAccessType() {
return this.accessType; return this.accessType;
} }
public void setAccessType(DmpAccessType accessType) { public void setAccessType(PlanAccessType accessType) {
this.accessType = accessType; this.accessType = accessType;
} }
@ -237,11 +237,11 @@ public class DmpEntity extends TenantScopedBaseEntity {
this.publicAfter = publicAfter; this.publicAfter = publicAfter;
} }
public DmpVersionStatus getVersionStatus() { public PlanVersionStatus getVersionStatus() {
return this.versionStatus; return this.versionStatus;
} }
public void setVersionStatus(DmpVersionStatus versionStatus) { public void setVersionStatus(PlanVersionStatus versionStatus) {
this.versionStatus = versionStatus; this.versionStatus = versionStatus;
} }
} }

View File

@ -10,7 +10,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"DmpReference\"") @Table(name = "\"DmpReference\"")
public class DmpReferenceEntity extends TenantScopedBaseEntity { public class PlanReferenceEntity extends TenantScopedBaseEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
@ -18,8 +18,8 @@ public class DmpReferenceEntity extends TenantScopedBaseEntity {
public static final String _id = "id"; public static final String _id = "id";
@Column(name = "dmp_id", columnDefinition = "uuid", nullable = false) @Column(name = "dmp_id", columnDefinition = "uuid", nullable = false)
private UUID dmpId; private UUID planId;
public static final String _dmpId = "dmpId"; public static final String _planId = "planId";
@Column(name = "reference_id", columnDefinition = "uuid", nullable = false) @Column(name = "reference_id", columnDefinition = "uuid", nullable = false)
private UUID referenceId; private UUID referenceId;
@ -50,12 +50,12 @@ public class DmpReferenceEntity extends TenantScopedBaseEntity {
this.id = id; this.id = id;
} }
public UUID getDmpId() { public UUID getPlanId() {
return dmpId; return planId;
} }
public void setDmpId(UUID dmpId) { public void setPlanId(UUID planId) {
this.dmpId = dmpId; this.planId = planId;
} }
public UUID getReferenceId() { public UUID getReferenceId() {

View File

@ -1,9 +1,9 @@
package org.opencdmp.data; package org.opencdmp.data;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.opencdmp.commons.enums.DmpUserRole; import org.opencdmp.commons.enums.PlanUserRole;
import org.opencdmp.commons.enums.IsActive; 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.converters.enums.IsActiveConverter;
import org.opencdmp.data.tenant.TenantScopedBaseEntity; import org.opencdmp.data.tenant.TenantScopedBaseEntity;
@ -12,7 +12,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"DmpUser\"") @Table(name = "\"DmpUser\"")
public class DmpUserEntity extends TenantScopedBaseEntity { public class PlanUserEntity extends TenantScopedBaseEntity {
@Id @Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @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"; public static final String _id = "id";
@Column(name = "dmp", columnDefinition = "uuid", nullable = false) @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) @Column(name = "\"user\"", columnDefinition = "uuid", nullable = false)
private UUID userId; private UUID userId;
@ -31,8 +31,8 @@ public class DmpUserEntity extends TenantScopedBaseEntity {
public static final String _userId = "userId"; public static final String _userId = "userId";
@Column(name = "role", nullable = false) @Column(name = "role", nullable = false)
@Convert(converter = DmpUserRoleConverter.class) @Convert(converter = PlanUserRoleConverter.class)
private DmpUserRole role; private PlanUserRole role;
public static final String _role = "role"; public static final String _role = "role";
@ -64,12 +64,12 @@ public class DmpUserEntity extends TenantScopedBaseEntity {
this.id = id; this.id = id;
} }
public UUID getDmpId() { public UUID getPlanId() {
return this.dmpId; return this.planId;
} }
public void setDmpId(UUID dmpId) { public void setPlanId(UUID planId) {
this.dmpId = dmpId; this.planId = planId;
} }
public UUID getUserId() { public UUID getUserId() {
@ -80,11 +80,11 @@ public class DmpUserEntity extends TenantScopedBaseEntity {
this.userId = userId; this.userId = userId;
} }
public DmpUserRole getRole() { public PlanUserRole getRole() {
return this.role; return this.role;
} }
public void setRole(DmpUserRole role) { public void setRole(PlanUserRole role) {
this.role = role; this.role = role;
} }

View File

@ -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<DmpBlueprintVersionStatus, Short> {
@Override
protected DmpBlueprintVersionStatus of(Short i) {
return DmpBlueprintVersionStatus.of(i);
}
}

View File

@ -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<PlanBlueprintVersionStatus, Short> {
@Override
protected PlanBlueprintVersionStatus of(Short i) {
return PlanBlueprintVersionStatus.of(i);
}
}

View File

@ -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<DmpAccessType, Short> {
@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);
}
}

View File

@ -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<DmpBlueprintStatus, Short> {
public DmpBlueprintStatus of(Short i) {
return DmpBlueprintStatus.of(i);
}
}

View File

@ -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<DmpStatus, Short> {
@Override
protected DmpStatus of(Short i) {
return DmpStatus.of(i);
}
}

View File

@ -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<DmpUserRole, Short> {
@Override
protected DmpUserRole of(Short i) {
return DmpUserRole.of(i);
}
}

View File

@ -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<DmpVersionStatus, Short> {
@Override
protected DmpVersionStatus of(Short i) {
return DmpVersionStatus.of(i);
}
}

View File

@ -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<PlanAccessType, Short> {
@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);
}
}

View File

@ -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<PlanBlueprintStatus, Short> {
public PlanBlueprintStatus of(Short i) {
return PlanBlueprintStatus.of(i);
}
}

View File

@ -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<PlanStatus, Short> {
@Override
protected PlanStatus of(Short i) {
return PlanStatus.of(i);
}
}

View File

@ -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<PlanUserRole, Short> {
@Override
protected PlanUserRole of(Short i) {
return PlanUserRole.of(i);
}
}

View File

@ -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<PlanVersionStatus, Short> {
@Override
protected PlanVersionStatus of(Short i) {
return PlanVersionStatus.of(i);
}
}

View File

@ -7,7 +7,6 @@ import gr.cite.tools.elastic.configuration.ElasticCertificateProvider;
import gr.cite.tools.elastic.configuration.ElasticProperties; import gr.cite.tools.elastic.configuration.ElasticProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchCustomConversions; import org.springframework.data.elasticsearch.core.convert.ElasticsearchCustomConversions;
@ -28,22 +27,22 @@ public class ElasticConfiguration extends AbstractElasticConfiguration {
public ElasticsearchCustomConversions elasticsearchCustomConversions() { public ElasticsearchCustomConversions elasticsearchCustomConversions() {
return new ElasticsearchCustomConversions( return new ElasticsearchCustomConversions(
List.of( List.of(
new DmpUserRoleToShortConverter(), new PlanUserRoleToShortConverter(),
new DescriptionTemplateVersionStatusToShortConverter(), new DescriptionTemplateVersionStatusToShortConverter(),
new DmpStatusToShortConverter(), new PlanStatusToShortConverter(),
new DescriptionStatusToShortConverter(), new DescriptionStatusToShortConverter(),
new IsActiveToShortConverter(), new IsActiveToShortConverter(),
new DmpVersionStatusToShortConverter(), new PlanVersionStatusToShortConverter(),
new DmpAccessTypeToShortConverter(), new PlanAccessTypeToShortConverter(),
new ShortToDmpStatusConverter(), new ShortToPlanStatusConverter(),
new ShortToDmpUserRoleConverter(), new ShortToPlanUserRoleConverter(),
new ShortToDescriptionTemplateVersionStatusConverter(), new ShortToDescriptionTemplateVersionStatusConverter(),
new ShortToDmpStatusConverter(), new ShortToPlanStatusConverter(),
new ShortToDescriptionStatusConverter(), new ShortToDescriptionStatusConverter(),
new ShortToIsActiveConverter(), new ShortToIsActiveConverter(),
new ShortToDmpVersionStatusConverter(), new ShortToPlanVersionStatusConverter(),
new ShortToDmpAccessTypeConverter() new ShortToPlanAccessTypeConverter()
)); ));
} }
} }

View File

@ -1,7 +1,6 @@
package org.opencdmp.elastic.converter; package org.opencdmp.elastic.converter;
import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.commons.enums.DmpStatus;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter; import org.springframework.data.convert.WritingConverter;

View File

@ -1,6 +1,5 @@
package org.opencdmp.elastic.converter; package org.opencdmp.elastic.converter;
import org.opencdmp.commons.enums.DmpStatus;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter; import org.springframework.data.convert.WritingConverter;

View File

@ -1,13 +1,13 @@
package org.opencdmp.elastic.converter; 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.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter; import org.springframework.data.convert.WritingConverter;
@WritingConverter @WritingConverter
public class DmpAccessTypeToShortConverter implements Converter<DmpAccessType, Short> { public class PlanAccessTypeToShortConverter implements Converter<PlanAccessType, Short> {
@Override @Override
public Short convert(DmpAccessType source) { public Short convert(PlanAccessType source) {
return source.getValue(); return source.getValue();
} }
} }

View File

@ -1,13 +1,13 @@
package org.opencdmp.elastic.converter; 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.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter; import org.springframework.data.convert.WritingConverter;
@WritingConverter @WritingConverter
public class DmpStatusToShortConverter implements Converter<DmpStatus, Short> { public class PlanStatusToShortConverter implements Converter<PlanStatus, Short> {
@Override @Override
public Short convert(DmpStatus source) { public Short convert(PlanStatus source) {
return source.getValue(); return source.getValue();
} }
} }

View File

@ -1,13 +1,13 @@
package org.opencdmp.elastic.converter; 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.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter; import org.springframework.data.convert.WritingConverter;
@WritingConverter @WritingConverter
public class DmpUserRoleToShortConverter implements Converter<DmpUserRole, Short> { public class PlanUserRoleToShortConverter implements Converter<PlanUserRole, Short> {
@Override @Override
public Short convert(DmpUserRole source) { public Short convert(PlanUserRole source) {
return source.getValue(); return source.getValue();
} }
} }

View File

@ -1,13 +1,13 @@
package org.opencdmp.elastic.converter; 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.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter; import org.springframework.data.convert.WritingConverter;
@WritingConverter @WritingConverter
public class DmpVersionStatusToShortConverter implements Converter<DmpVersionStatus, Short> { public class PlanVersionStatusToShortConverter implements Converter<PlanVersionStatus, Short> {
@Override @Override
public Short convert(DmpVersionStatus source) { public Short convert(PlanVersionStatus source) {
return source.getValue(); return source.getValue();
} }
} }

View File

@ -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<Integer, DmpAccessType> {
@Override
public DmpAccessType convert(Integer source) {
return DmpAccessType.of(source.shortValue());
}
}

View File

@ -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<Integer, DmpUserRole> {
@Override
public DmpUserRole convert(Integer source) {
return DmpUserRole.of(source.shortValue());
}
}

View File

@ -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<Integer, DmpVersionStatus> {
@Override
public DmpVersionStatus convert(Integer source) {
return DmpVersionStatus.of(source.shortValue());
}
}

View File

@ -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<Integer, PlanAccessType> {
@Override
public PlanAccessType convert(Integer source) {
return PlanAccessType.of(source.shortValue());
}
}

View File

@ -5,10 +5,10 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter; import org.springframework.data.convert.ReadingConverter;
@ReadingConverter @ReadingConverter
public class ShortToDmpStatusConverter implements Converter<Integer, DmpStatus> { public class ShortToPlanStatusConverter implements Converter<Integer, PlanStatus> {
@Override @Override
public DmpStatus convert(Integer source) { public PlanStatus convert(Integer source) {
return DmpStatus.of(source.shortValue()); return PlanStatus.of(source.shortValue());
} }
} }

View File

@ -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<Integer, PlanUserRole> {
@Override
public PlanUserRole convert(Integer source) {
return PlanUserRole.of(source.shortValue());
}
}

View File

@ -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<Integer, PlanVersionStatus> {
@Override
public PlanVersionStatus convert(Integer source) {
return PlanVersionStatus.of(source.shortValue());
}
}

View File

@ -3,7 +3,7 @@ package org.opencdmp.elastic.data;
import gr.cite.tools.elastic.ElasticConstants; import gr.cite.tools.elastic.ElasticConstants;
import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; 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.NestedReferenceElasticEntity;
import org.opencdmp.elastic.data.nested.NestedTagElasticEntity; import org.opencdmp.elastic.data.nested.NestedTagElasticEntity;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
@ -50,7 +50,7 @@ public class DescriptionElasticEntity {
public final static String _descriptionTemplate = "descriptionTemplate"; public final static String _descriptionTemplate = "descriptionTemplate";
@Field(value = DescriptionElasticEntity._dmp, type = FieldType.Object) @Field(value = DescriptionElasticEntity._dmp, type = FieldType.Object)
private NestedDmpElasticEntity dmp; private NestedPlanElasticEntity dmp;
public final static String _dmp = "dmp"; public final static String _dmp = "dmp";
@Field(value = DescriptionElasticEntity._references, type = FieldType.Nested) @Field(value = DescriptionElasticEntity._references, type = FieldType.Nested)
@ -129,11 +129,11 @@ public class DescriptionElasticEntity {
this.descriptionTemplate = descriptionTemplate; this.descriptionTemplate = descriptionTemplate;
} }
public NestedDmpElasticEntity getDmp() { public NestedPlanElasticEntity getDmp() {
return this.dmp; return this.dmp;
} }
public void setDmp(NestedDmpElasticEntity dmp) { public void setDmp(NestedPlanElasticEntity dmp) {
this.dmp = dmp; this.dmp = dmp;
} }

View File

@ -1,9 +1,9 @@
package org.opencdmp.elastic.data; package org.opencdmp.elastic.data;
import gr.cite.tools.elastic.ElasticConstants; import gr.cite.tools.elastic.ElasticConstants;
import org.opencdmp.commons.enums.DmpAccessType; import org.opencdmp.commons.enums.PlanAccessType;
import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.commons.enums.DmpVersionStatus; import org.opencdmp.commons.enums.PlanVersionStatus;
import org.opencdmp.elastic.data.nested.*; import org.opencdmp.elastic.data.nested.*;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*; import org.springframework.data.elasticsearch.annotations.*;
@ -13,80 +13,80 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
@Document(indexName = "dmp") @Document(indexName = "dmp")
public class DmpElasticEntity { public class PlanElasticEntity {
@Id @Id
@Field(value = DmpElasticEntity._id, type = FieldType.Keyword) @Field(value = PlanElasticEntity._id, type = FieldType.Keyword)
private UUID id; private UUID id;
public final static String _id = "id"; public final static String _id = "id";
@Field(value = DmpElasticEntity._tenantId, type = FieldType.Keyword) @Field(value = PlanElasticEntity._tenantId, type = FieldType.Keyword)
private UUID tenantId; private UUID tenantId;
public final static String _tenantId = "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; private String label;
public final static String _label = "label"; public final static String _label = "label";
@Field(value = DmpElasticEntity._description, type = FieldType.Text) @Field(value = PlanElasticEntity._description, type = FieldType.Text)
private String description; private String description;
public final static String _description = "description"; public final static String _description = "description";
@Field(value = DmpElasticEntity._version, type = FieldType.Keyword) @Field(value = PlanElasticEntity._version, type = FieldType.Keyword)
private Short version; private Short version;
public final static String _version = "version"; public final static String _version = "version";
@Field(value = DmpElasticEntity._status, type = FieldType.Short) @Field(value = PlanElasticEntity._status, type = FieldType.Short)
private DmpStatus status; private PlanStatus status;
public final static String _status = "status"; public final static String _status = "status";
@Field(value = DmpElasticEntity._accessType, type = FieldType.Short) @Field(value = PlanElasticEntity._accessType, type = FieldType.Short)
private DmpAccessType accessType; private PlanAccessType accessType;
public final static String _accessType = "accessType"; public final static String _accessType = "accessType";
@Field(value = DmpElasticEntity._versionStatus, type = FieldType.Short) @Field(value = PlanElasticEntity._versionStatus, type = FieldType.Short)
private DmpVersionStatus versionStatus; private PlanVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus"; public final static String _versionStatus = "versionStatus";
@Field(value = DmpElasticEntity._language, type = FieldType.Keyword) @Field(value = PlanElasticEntity._language, type = FieldType.Keyword)
private String language; private String language;
public final static String _language = "language"; public final static String _language = "language";
@Field(value = DmpElasticEntity._blueprintId, type = FieldType.Keyword) @Field(value = PlanElasticEntity._blueprintId, type = FieldType.Keyword)
private UUID blueprintId; private UUID blueprintId;
public final static String _blueprintId = "blueprintId"; public final static String _blueprintId = "blueprintId";
@Field(value = DmpElasticEntity._groupId, type = FieldType.Keyword) @Field(value = PlanElasticEntity._groupId, type = FieldType.Keyword)
private UUID groupId; private UUID groupId;
public final static String _groupId = "groupId"; public final static String _groupId = "groupId";
@Field(value = DmpElasticEntity._finalizedAt, type = FieldType.Date) @Field(value = PlanElasticEntity._finalizedAt, type = FieldType.Date)
private Date finalizedAt; private Date finalizedAt;
public final static String _finalizedAt = "finalizedAt"; public final static String _finalizedAt = "finalizedAt";
@Field(value = DmpElasticEntity._references, type = FieldType.Nested) @Field(value = PlanElasticEntity._references, type = FieldType.Nested)
private List<NestedReferenceElasticEntity> references; private List<NestedReferenceElasticEntity> references;
public final static String _references = "references"; public final static String _references = "references";
@Field(value = DmpElasticEntity._collaborators, type = FieldType.Nested) @Field(value = PlanElasticEntity._collaborators, type = FieldType.Nested)
private List<NestedCollaboratorElasticEntity> collaborators; private List<NestedCollaboratorElasticEntity> collaborators;
public final static String _collaborators = "collaborators"; public final static String _collaborators = "collaborators";
@Field(value = DmpElasticEntity._descriptions, type = FieldType.Nested) @Field(value = PlanElasticEntity._descriptions, type = FieldType.Nested)
private List<NestedDescriptionElasticEntity> descriptions; private List<NestedDescriptionElasticEntity> descriptions;
public final static String _descriptions = "descriptions"; public final static String _descriptions = "descriptions";
@Field(value = DmpElasticEntity._dmpDescriptionTemplates, type = FieldType.Nested) @Field(value = PlanElasticEntity._dmpDescriptionTemplates, type = FieldType.Nested)
private List<NestedDmpDescriptionTemplateElasticEntity> dmpDescriptionTemplates; private List<NestedPlanDescriptionTemplateElasticEntity> planDescriptionTemplates;
public final static String _dmpDescriptionTemplates = "dmpDescriptionTemplates"; public final static String _dmpDescriptionTemplates = "dmpDescriptionTemplates";
@Field(value = DmpElasticEntity._dois, type = FieldType.Nested) @Field(value = PlanElasticEntity._dois, type = FieldType.Nested)
private List<NestedDoiElasticEntity> dois; private List<NestedDoiElasticEntity> dois;
public final static String _dois = "dois"; public final static String _dois = "dois";
@Field(value = DmpElasticEntity._updatedAt, type = FieldType.Date) @Field(value = PlanElasticEntity._updatedAt, type = FieldType.Date)
private Date updatedAt; private Date updatedAt;
public final static String _updatedAt = "updatedAt"; public final static String _updatedAt = "updatedAt";
@Field(value = DmpElasticEntity._createdAt, type = FieldType.Date) @Field(value = PlanElasticEntity._createdAt, type = FieldType.Date)
private Date createdAt; private Date createdAt;
public final static String _createdAt = "createdAt"; public final static String _createdAt = "createdAt";
@ -130,19 +130,19 @@ public class DmpElasticEntity {
this.version = version; this.version = version;
} }
public DmpStatus getStatus() { public PlanStatus getStatus() {
return this.status; return this.status;
} }
public void setStatus(DmpStatus status) { public void setStatus(PlanStatus status) {
this.status = status; this.status = status;
} }
public DmpAccessType getAccessType() { public PlanAccessType getAccessType() {
return this.accessType; return this.accessType;
} }
public void setAccessType(DmpAccessType accessType) { public void setAccessType(PlanAccessType accessType) {
this.accessType = accessType; this.accessType = accessType;
} }
@ -210,20 +210,20 @@ public class DmpElasticEntity {
this.dois = dois; this.dois = dois;
} }
public DmpVersionStatus getVersionStatus() { public PlanVersionStatus getVersionStatus() {
return this.versionStatus; return this.versionStatus;
} }
public void setVersionStatus(DmpVersionStatus versionStatus) { public void setVersionStatus(PlanVersionStatus versionStatus) {
this.versionStatus = versionStatus; this.versionStatus = versionStatus;
} }
public List<NestedDmpDescriptionTemplateElasticEntity> getDmpDescriptionTemplates() { public List<NestedPlanDescriptionTemplateElasticEntity> getPlanDescriptionTemplates() {
return this.dmpDescriptionTemplates; return this.planDescriptionTemplates;
} }
public void setDmpDescriptionTemplates(List<NestedDmpDescriptionTemplateElasticEntity> dmpDescriptionTemplates) { public void setPlanDescriptionTemplates(List<NestedPlanDescriptionTemplateElasticEntity> planDescriptionTemplates) {
this.dmpDescriptionTemplates = dmpDescriptionTemplates; this.planDescriptionTemplates = planDescriptionTemplates;
} }
public Date getCreatedAt() { public Date getCreatedAt() {

View File

@ -1,7 +1,7 @@
package org.opencdmp.elastic.data.nested; package org.opencdmp.elastic.data.nested;
import gr.cite.tools.elastic.ElasticConstants; 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.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
@ -25,7 +25,7 @@ public class NestedCollaboratorElasticEntity {
public final static String _name = "name"; public final static String _name = "name";
@Field(value = NestedCollaboratorElasticEntity._role, type = FieldType.Short) @Field(value = NestedCollaboratorElasticEntity._role, type = FieldType.Short)
private DmpUserRole role; private PlanUserRole role;
public final static String _role = "role"; public final static String _role = "role";
public UUID getId() { public UUID getId() {
@ -44,11 +44,11 @@ public class NestedCollaboratorElasticEntity {
this.name = name; this.name = name;
} }
public DmpUserRole getRole() { public PlanUserRole getRole() {
return this.role; return this.role;
} }
public void setRole(DmpUserRole role) { public void setRole(PlanUserRole role) {
this.role = role; this.role = role;
} }

View File

@ -21,7 +21,7 @@ public class NestedDescriptionElasticEntity {
public final static String _id = "id"; public final static String _id = "id";
@Field(value = NestedDescriptionElasticEntity._dmpId, type = FieldType.Keyword) @Field(value = NestedDescriptionElasticEntity._dmpId, type = FieldType.Keyword)
private UUID dmpId; private UUID planId;
public final static String _dmpId = "dmpId"; public final static String _dmpId = "dmpId";
@MultiField(mainField = @Field(value = NestedDescriptionElasticEntity._label, type = FieldType.Text), otherFields = @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)) @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; this.id = id;
} }
public UUID getDmpId() { public UUID getPlanId() {
return this.dmpId; return this.planId;
} }
public void setDmpId(UUID dmpId) { public void setPlanId(UUID planId) {
this.dmpId = dmpId; this.planId = planId;
} }
public String getLabel() { public String getLabel() {

View File

@ -6,22 +6,22 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.UUID; import java.util.UUID;
public class NestedDmpDescriptionTemplateElasticEntity { public class NestedPlanDescriptionTemplateElasticEntity {
@Id @Id
@Field(value = NestedDmpDescriptionTemplateElasticEntity._id, type = FieldType.Keyword) @Field(value = NestedPlanDescriptionTemplateElasticEntity._id, type = FieldType.Keyword)
private UUID id; private UUID id;
public final static String _id = "id"; public final static String _id = "id";
@Field(value = NestedDescriptionElasticEntity._dmpId, type = FieldType.Keyword) @Field(value = NestedDescriptionElasticEntity._dmpId, type = FieldType.Keyword)
private UUID dmpId; private UUID planId;
public final static String _dmpId = "dmpId"; public final static String _dmpId = "dmpId";
@Field(value = NestedDmpDescriptionTemplateElasticEntity._descriptionTemplateGroupId, type = FieldType.Keyword) @Field(value = NestedPlanDescriptionTemplateElasticEntity._descriptionTemplateGroupId, type = FieldType.Keyword)
private UUID descriptionTemplateGroupId; private UUID descriptionTemplateGroupId;
public final static String _descriptionTemplateGroupId = "descriptionTemplateGroupId"; public final static String _descriptionTemplateGroupId = "descriptionTemplateGroupId";
@Field(value = NestedDmpDescriptionTemplateElasticEntity._sectionId, type = FieldType.Keyword) @Field(value = NestedPlanDescriptionTemplateElasticEntity._sectionId, type = FieldType.Keyword)
private UUID sectionId; private UUID sectionId;
public final static String _sectionId = "sectionId"; public final static String _sectionId = "sectionId";
@ -50,11 +50,11 @@ public class NestedDmpDescriptionTemplateElasticEntity {
this.sectionId = sectionId; this.sectionId = sectionId;
} }
public UUID getDmpId() { public UUID getPlanId() {
return this.dmpId; return this.planId;
} }
public void setDmpId(UUID dmpId) { public void setPlanId(UUID planId) {
this.dmpId = dmpId; this.planId = planId;
} }
} }

View File

@ -1,9 +1,8 @@
package org.opencdmp.elastic.data.nested; package org.opencdmp.elastic.data.nested;
import org.opencdmp.commons.enums.DmpAccessType; import org.opencdmp.commons.enums.PlanAccessType;
import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.commons.enums.DmpVersionStatus; import org.opencdmp.commons.enums.PlanVersionStatus;
import org.opencdmp.elastic.data.DmpElasticEntity;
import gr.cite.tools.elastic.ElasticConstants; import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*; import org.springframework.data.elasticsearch.annotations.*;
@ -12,63 +11,63 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class NestedDmpElasticEntity { public class NestedPlanElasticEntity {
@Id @Id
@Field(value = NestedDmpElasticEntity._id, type = FieldType.Keyword) @Field(value = NestedPlanElasticEntity._id, type = FieldType.Keyword)
private UUID id; private UUID id;
public final static String _id = "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) @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
}) })
private String label; private String label;
public final static String _label = "label"; public final static String _label = "label";
@Field(value = NestedDmpElasticEntity._description, type = FieldType.Text) @Field(value = NestedPlanElasticEntity._description, type = FieldType.Text)
private String description; private String description;
public final static String _description = "description"; public final static String _description = "description";
@Field(value = NestedDmpElasticEntity._version, type = FieldType.Keyword) @Field(value = NestedPlanElasticEntity._version, type = FieldType.Keyword)
private Short version; private Short version;
public final static String _version = "version"; public final static String _version = "version";
@Field(value = NestedDmpElasticEntity._versionStatus, type = FieldType.Short) @Field(value = NestedPlanElasticEntity._versionStatus, type = FieldType.Short)
private DmpVersionStatus versionStatus; private PlanVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus"; public final static String _versionStatus = "versionStatus";
@Field(value = NestedDmpElasticEntity._status, type = FieldType.Short) @Field(value = NestedPlanElasticEntity._status, type = FieldType.Short)
private DmpStatus status; private PlanStatus status;
public final static String _status = "status"; public final static String _status = "status";
@Field(value = NestedDmpElasticEntity._accessType, type = FieldType.Short) @Field(value = NestedPlanElasticEntity._accessType, type = FieldType.Short)
private DmpAccessType accessType; private PlanAccessType accessType;
public final static String _accessType = "accessType"; public final static String _accessType = "accessType";
@Field(value = NestedDmpElasticEntity._language, type = FieldType.Keyword) @Field(value = NestedPlanElasticEntity._language, type = FieldType.Keyword)
private String language; private String language;
public final static String _language = "language"; public final static String _language = "language";
@Field(value = NestedDmpElasticEntity._blueprintId, type = FieldType.Keyword) @Field(value = NestedPlanElasticEntity._blueprintId, type = FieldType.Keyword)
private UUID blueprintId; private UUID blueprintId;
public final static String _blueprintId = "blueprintId"; public final static String _blueprintId = "blueprintId";
@Field(value = NestedDmpElasticEntity._groupId, type = FieldType.Keyword) @Field(value = NestedPlanElasticEntity._groupId, type = FieldType.Keyword)
private UUID groupId; private UUID groupId;
public final static String _groupId = "groupId"; public final static String _groupId = "groupId";
@Field(value = NestedDmpElasticEntity._finalizedAt, type = FieldType.Date) @Field(value = NestedPlanElasticEntity._finalizedAt, type = FieldType.Date)
private Date finalizedAt; private Date finalizedAt;
public final static String _finalizedAt = "finalizedAt"; public final static String _finalizedAt = "finalizedAt";
@Field(value = NestedDmpElasticEntity._references, type = FieldType.Nested) @Field(value = NestedPlanElasticEntity._references, type = FieldType.Nested)
private List<NestedReferenceElasticEntity> references; private List<NestedReferenceElasticEntity> references;
public final static String _references = "references"; public final static String _references = "references";
@Field(value = NestedDmpElasticEntity._collaborators, type = FieldType.Nested) @Field(value = NestedPlanElasticEntity._collaborators, type = FieldType.Nested)
private List<NestedCollaboratorElasticEntity> collaborators; private List<NestedCollaboratorElasticEntity> collaborators;
public final static String _collaborators = "collaborators"; public final static String _collaborators = "collaborators";
@Field(value = NestedDmpElasticEntity._dois, type = FieldType.Nested) @Field(value = NestedPlanElasticEntity._dois, type = FieldType.Nested)
private List<NestedDoiElasticEntity> dois; private List<NestedDoiElasticEntity> dois;
public final static String _dois = "dois"; public final static String _dois = "dois";
@ -104,19 +103,19 @@ public class NestedDmpElasticEntity {
this.version = version; this.version = version;
} }
public DmpStatus getStatus() { public PlanStatus getStatus() {
return status; return status;
} }
public void setStatus(DmpStatus status) { public void setStatus(PlanStatus status) {
this.status = status; this.status = status;
} }
public DmpAccessType getAccessType() { public PlanAccessType getAccessType() {
return accessType; return accessType;
} }
public void setAccessType(DmpAccessType accessType) { public void setAccessType(PlanAccessType accessType) {
this.accessType = accessType; this.accessType = accessType;
} }
@ -176,11 +175,11 @@ public class NestedDmpElasticEntity {
this.dois = dois; this.dois = dois;
} }
public DmpVersionStatus getVersionStatus() { public PlanVersionStatus getVersionStatus() {
return versionStatus; return versionStatus;
} }
public void setVersionStatus(DmpVersionStatus versionStatus) { public void setVersionStatus(PlanVersionStatus versionStatus) {
this.versionStatus = versionStatus; this.versionStatus = versionStatus;
} }
} }

View File

@ -11,17 +11,17 @@ import org.opencdmp.data.DescriptionReferenceEntity;
import org.opencdmp.data.DescriptionTagEntity; import org.opencdmp.data.DescriptionTagEntity;
import org.opencdmp.elastic.data.DescriptionElasticEntity; import org.opencdmp.elastic.data.DescriptionElasticEntity;
import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; 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.NestedReferenceElasticEntity;
import org.opencdmp.elastic.data.nested.NestedTagElasticEntity; import org.opencdmp.elastic.data.nested.NestedTagElasticEntity;
import org.opencdmp.elastic.elasticbuilder.nested.NestedDescriptionTemplateElasticBuilder; 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.NestedReferenceElasticBuilder;
import org.opencdmp.elastic.elasticbuilder.nested.NestedTagElasticBuilder; import org.opencdmp.elastic.elasticbuilder.nested.NestedTagElasticBuilder;
import org.opencdmp.model.DescriptionTag; import org.opencdmp.model.DescriptionTag;
import org.opencdmp.model.descriptionreference.DescriptionReference; import org.opencdmp.model.descriptionreference.DescriptionReference;
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
import org.opencdmp.model.dmp.Dmp; import org.opencdmp.model.plan.Plan;
import org.opencdmp.query.*; import org.opencdmp.query.*;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -54,7 +54,7 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder<DescriptionEla
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDescriptionReferences(data); Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDescriptionReferences(data);
Map<UUID, List<NestedTagElasticEntity>> tagElasticEntityMap = this.collectDescriptionTags(data); Map<UUID, List<NestedTagElasticEntity>> tagElasticEntityMap = this.collectDescriptionTags(data);
Map<UUID, NestedDmpElasticEntity> dmpElasticEntityMap = this.collectDmps(data); Map<UUID, NestedPlanElasticEntity> planElasticEntityMap = this.collectPlans(data);
Map<UUID, NestedDescriptionTemplateElasticEntity> descriptionTemplateElasticEntityMap = this.collectDescriptionTemplates(data); Map<UUID, NestedDescriptionTemplateElasticEntity> descriptionTemplateElasticEntityMap = this.collectDescriptionTemplates(data);
List<DescriptionElasticEntity> models = new ArrayList<>(); List<DescriptionElasticEntity> models = new ArrayList<>();
@ -74,8 +74,8 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder<DescriptionEla
} }
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null)); if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (tagElasticEntityMap != null) m.setTags(tagElasticEntityMap.getOrDefault(d.getId(), null)); if (tagElasticEntityMap != null) m.setTags(tagElasticEntityMap.getOrDefault(d.getId(), null));
if (dmpElasticEntityMap != null) m.setDmp(dmpElasticEntityMap.getOrDefault(d.getDmpId(), null)); if (planElasticEntityMap != null) m.setDmp(planElasticEntityMap.getOrDefault(d.getPlanId(), null));
if (descriptionTemplateElasticEntityMap != null) m.setDescriptionTemplate(descriptionTemplateElasticEntityMap.getOrDefault(d.getDmpId(), null)); if (descriptionTemplateElasticEntityMap != null) m.setDescriptionTemplate(descriptionTemplateElasticEntityMap.getOrDefault(d.getPlanId(), null));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
@ -122,14 +122,14 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder<DescriptionEla
return itemMap; return itemMap;
} }
private Map<UUID, NestedDmpElasticEntity> collectDmps(List<DescriptionEntity> data) throws MyApplicationException { private Map<UUID, NestedPlanElasticEntity> collectPlans(List<DescriptionEntity> data) throws MyApplicationException {
if (data.isEmpty()) if (data.isEmpty())
return null; return null;
this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); this.logger.debug("checking related - {}", Plan.class.getSimpleName());
Map<UUID, NestedDmpElasticEntity> itemMap; Map<UUID, NestedPlanElasticEntity> itemMap;
DmpQuery q = this.queryFactory.query(DmpQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList())); 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(NestedDmpElasticBuilder.class).asForeignKey(q, NestedDmpElasticEntity::getId); itemMap = this.builderFactory.builder(NestedPlanElasticBuilder.class).asForeignKey(q, NestedPlanElasticEntity::getId);
return itemMap; return itemMap;
} }

View File

@ -7,10 +7,10 @@ import gr.cite.tools.logging.LoggerService;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.*; 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.data.nested.*;
import org.opencdmp.elastic.elasticbuilder.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.opencdmp.query.*;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -23,33 +23,33 @@ import java.util.stream.Collectors;
@Component @Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpEntity> { public class PlanElasticBuilder extends BaseElasticBuilder<PlanElasticEntity, PlanEntity> {
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@Autowired @Autowired
public DmpElasticBuilder( public PlanElasticBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) { 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.queryFactory = queryFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
} }
@Override @Override
public List<DmpElasticEntity> build(List<DmpEntity> data) throws MyApplicationException { public List<PlanElasticEntity> build(List<PlanEntity> data) throws MyApplicationException {
if (data == null) if (data == null)
return new ArrayList<>(); return new ArrayList<>();
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDmpReferences(data); Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectPlanReferences(data);
Map<UUID, List<NestedDescriptionElasticEntity>> descriptionElasticEntityMap = this.collectDescriptions(data); Map<UUID, List<NestedDescriptionElasticEntity>> descriptionElasticEntityMap = this.collectDescriptions(data);
Map<UUID, List<NestedCollaboratorElasticEntity>> collaboratorElasticEntityMap = this.collectCollaborators(data); Map<UUID, List<NestedCollaboratorElasticEntity>> collaboratorElasticEntityMap = this.collectCollaborators(data);
Map<UUID, List<NestedDoiElasticEntity>> doiElasticEntityMap = this.collectDois(data); Map<UUID, List<NestedDoiElasticEntity>> doiElasticEntityMap = this.collectDois(data);
Map<UUID, List<NestedDmpDescriptionTemplateElasticEntity>> dmpDescriptionTemplateElasticEntityMap = this.collectDmpDescriptionTemplates(data); Map<UUID, List<NestedPlanDescriptionTemplateElasticEntity>> planDescriptionTemplateElasticEntityMap = this.collectPlanDescriptionTemplates(data);
List<DmpElasticEntity> models = new ArrayList<>(); List<PlanElasticEntity> models = new ArrayList<>();
for (DmpEntity d : data) { for (PlanEntity d : data) {
DmpElasticEntity m = new DmpElasticEntity(); PlanElasticEntity m = new PlanElasticEntity();
m.setId(d.getId()); m.setId(d.getId());
m.setLabel(d.getLabel()); m.setLabel(d.getLabel());
m.setDescription(d.getDescription()); m.setDescription(d.getDescription());
@ -71,7 +71,7 @@ public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpE
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null)); if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (descriptionElasticEntityMap != null) m.setDescriptions(descriptionElasticEntityMap.getOrDefault(d.getId(), null)); if (descriptionElasticEntityMap != null) m.setDescriptions(descriptionElasticEntityMap.getOrDefault(d.getId(), null));
if (dmpDescriptionTemplateElasticEntityMap != null) m.setDmpDescriptionTemplates(dmpDescriptionTemplateElasticEntityMap.getOrDefault(d.getId(), null)); if (planDescriptionTemplateElasticEntityMap != null) m.setPlanDescriptionTemplates(planDescriptionTemplateElasticEntityMap.getOrDefault(d.getId(), null));
if (collaboratorElasticEntityMap != null) m.setCollaborators(collaboratorElasticEntityMap.getOrDefault(d.getId(), null)); if (collaboratorElasticEntityMap != null) m.setCollaborators(collaboratorElasticEntityMap.getOrDefault(d.getId(), null));
if (doiElasticEntityMap != null) m.setDois(doiElasticEntityMap.getOrDefault(d.getId(), null)); if (doiElasticEntityMap != null) m.setDois(doiElasticEntityMap.getOrDefault(d.getId(), null));
models.add(m); models.add(m);
@ -80,75 +80,75 @@ public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpE
return models; return models;
} }
private Map<UUID, List<NestedReferenceElasticEntity>> collectDmpReferences(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedReferenceElasticEntity>> collectPlanReferences(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null; 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); PlanReferenceQuery associationQuery = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().planIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active);
List<DmpReferenceEntity> associationEntities = associationQuery.collect(); List<PlanReferenceEntity> 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<UUID, NestedReferenceElasticEntity> itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId); Map<UUID, NestedReferenceElasticEntity> itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId);
Map<UUID, List<NestedReferenceElasticEntity>> itemMap = new HashMap<>(); Map<UUID, List<NestedReferenceElasticEntity>> itemMap = new HashMap<>();
for (DmpReferenceEntity associationEntity : associationEntities){ for (PlanReferenceEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>()); if (!itemMap.containsKey(associationEntity.getPlanId())) itemMap.put(associationEntity.getPlanId(), new ArrayList<>());
NestedReferenceElasticEntity item = itemMapById.getOrDefault(associationEntity.getReferenceId(), null); 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; return itemMap;
} }
private Map<UUID, List<NestedDescriptionElasticEntity>> collectDescriptions(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedDescriptionElasticEntity>> collectDescriptions(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty()) if (data.isEmpty())
return null; return null;
this.logger.debug("checking related - {}", DescriptionEntity.class.getSimpleName()); this.logger.debug("checking related - {}", DescriptionEntity.class.getSimpleName());
Map<UUID, List<NestedDescriptionElasticEntity>> itemMap; Map<UUID, List<NestedDescriptionElasticEntity>> 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()))); 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::getDmpId); itemMap = this.builderFactory.builder(NestedDescriptionElasticBuilder.class).asMasterKey(q, NestedDescriptionElasticEntity::getPlanId);
return itemMap; return itemMap;
} }
private Map<UUID, List<NestedDmpDescriptionTemplateElasticEntity>> collectDmpDescriptionTemplates(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedPlanDescriptionTemplateElasticEntity>> collectPlanDescriptionTemplates(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty()) if (data.isEmpty())
return null; return null;
this.logger.debug("checking related - {}", DmpDescriptionTemplateEntity.class.getSimpleName()); this.logger.debug("checking related - {}", PlanDescriptionTemplateEntity.class.getSimpleName());
Map<UUID, List<NestedDmpDescriptionTemplateElasticEntity>> itemMap; Map<UUID, List<NestedPlanDescriptionTemplateElasticEntity>> itemMap;
DmpDescriptionTemplateQuery q = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); 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(NestedDmpDescriptionTemplateElasticBuilder.class).asMasterKey(q, NestedDmpDescriptionTemplateElasticEntity::getDmpId); itemMap = this.builderFactory.builder(NestedPlanDescriptionTemplateElasticBuilder.class).asMasterKey(q, NestedPlanDescriptionTemplateElasticEntity::getPlanId);
return itemMap; return itemMap;
} }
private Map<UUID, List<NestedCollaboratorElasticEntity>> collectCollaborators(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedCollaboratorElasticEntity>> collectCollaborators(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty()) if (data.isEmpty())
return null; 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); PlanUserQuery associationQuery = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active);
List<DmpUserEntity> associationEntities = associationQuery.collect(); List<PlanUserEntity> associationEntities = associationQuery.collect();
Map<UUID, NestedCollaboratorElasticEntity> itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId); Map<UUID, NestedCollaboratorElasticEntity> itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId);
Map<UUID, List<NestedCollaboratorElasticEntity>> itemMap = new HashMap<>(); Map<UUID, List<NestedCollaboratorElasticEntity>> itemMap = new HashMap<>();
for (DmpUserEntity associationEntity : associationEntities){ for (PlanUserEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>()); if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getPlanId(), new ArrayList<>());
NestedCollaboratorElasticEntity item = itemMapById.getOrDefault(associationEntity.getId(), null); 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; return itemMap;
} }
private Map<UUID, List<NestedDoiElasticEntity>> collectDois(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedDoiElasticEntity>> collectDois(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty()) if (data.isEmpty())
return null; return null;
this.logger.debug("checking related - {}", EntityDoiEntity.class.getSimpleName()); 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<EntityDoiEntity> associationEntities = associationQuery.collect(); List<EntityDoiEntity> associationEntities = associationQuery.collect();
Map<UUID, NestedDoiElasticEntity> itemMapById = this.builderFactory.builder(NestedDoiElasticBuilder.class).asForeignKey(associationEntities, NestedDoiElasticEntity::getId); Map<UUID, NestedDoiElasticEntity> itemMapById = this.builderFactory.builder(NestedDoiElasticBuilder.class).asForeignKey(associationEntities, NestedDoiElasticEntity::getId);

View File

@ -6,7 +6,7 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DmpUserEntity; import org.opencdmp.data.PlanUserEntity;
import org.opencdmp.data.UserEntity; import org.opencdmp.data.UserEntity;
import org.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity; import org.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity;
import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder; import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder;
@ -23,7 +23,7 @@ import java.util.stream.Collectors;
@Component @Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder<NestedCollaboratorElasticEntity, DmpUserEntity> { public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder<NestedCollaboratorElasticEntity, PlanUserEntity> {
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
@Autowired @Autowired
@ -34,14 +34,14 @@ public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder<NestedC
} }
@Override @Override
public List<NestedCollaboratorElasticEntity> build(List<DmpUserEntity> data) throws MyApplicationException { public List<NestedCollaboratorElasticEntity> build(List<PlanUserEntity> data) throws MyApplicationException {
if (data == null) if (data == null)
return new ArrayList<>(); return new ArrayList<>();
List<NestedCollaboratorElasticEntity> models = new ArrayList<>(); List<NestedCollaboratorElasticEntity> models = new ArrayList<>();
List<UserEntity> 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<UserEntity> 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<UUID, String> userNameMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, UserEntity::getName)); Map<UUID, String> 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(); NestedCollaboratorElasticEntity m = new NestedCollaboratorElasticEntity();
m.setId(d.getId()); m.setId(d.getId());
m.setUserId(d.getUserId()); m.setUserId(d.getUserId());

View File

@ -55,7 +55,7 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder<NestedDe
for (DescriptionEntity d : data) { for (DescriptionEntity d : data) {
NestedDescriptionElasticEntity m = new NestedDescriptionElasticEntity(); NestedDescriptionElasticEntity m = new NestedDescriptionElasticEntity();
m.setId(d.getId()); m.setId(d.getId());
m.setDmpId(d.getDmpId()); m.setPlanId(d.getPlanId());
m.setLabel(d.getLabel()); m.setLabel(d.getLabel());
m.setDescription(d.getDescription()); m.setDescription(d.getDescription());
m.setStatus(d.getStatus()); m.setStatus(d.getStatus());

View File

@ -3,8 +3,8 @@ package org.opencdmp.elastic.elasticbuilder.nested;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DmpDescriptionTemplateEntity; import org.opencdmp.data.PlanDescriptionTemplateEntity;
import org.opencdmp.elastic.data.nested.NestedDmpDescriptionTemplateElasticEntity; import org.opencdmp.elastic.data.nested.NestedPlanDescriptionTemplateElasticEntity;
import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder; import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -18,24 +18,24 @@ import java.util.Optional;
@Component @Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDmpDescriptionTemplateElasticBuilder extends BaseElasticBuilder<NestedDmpDescriptionTemplateElasticEntity, DmpDescriptionTemplateEntity> { public class NestedPlanDescriptionTemplateElasticBuilder extends BaseElasticBuilder<NestedPlanDescriptionTemplateElasticEntity, PlanDescriptionTemplateEntity> {
@Autowired @Autowired
public NestedDmpDescriptionTemplateElasticBuilder( public NestedPlanDescriptionTemplateElasticBuilder(
ConventionService conventionService) { ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedDmpDescriptionTemplateElasticBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedPlanDescriptionTemplateElasticBuilder.class)));
} }
@Override @Override
public List<NestedDmpDescriptionTemplateElasticEntity> build(List<DmpDescriptionTemplateEntity> data) throws MyApplicationException { public List<NestedPlanDescriptionTemplateElasticEntity> build(List<PlanDescriptionTemplateEntity> data) throws MyApplicationException {
if (data == null) if (data == null)
return new ArrayList<>(); return new ArrayList<>();
List<NestedDmpDescriptionTemplateElasticEntity> models = new ArrayList<>(); List<NestedPlanDescriptionTemplateElasticEntity> models = new ArrayList<>();
for (DmpDescriptionTemplateEntity d : data) { for (PlanDescriptionTemplateEntity d : data) {
NestedDmpDescriptionTemplateElasticEntity m = new NestedDmpDescriptionTemplateElasticEntity(); NestedPlanDescriptionTemplateElasticEntity m = new NestedPlanDescriptionTemplateElasticEntity();
m.setId(d.getId()); m.setId(d.getId());
m.setDmpId(d.getDmpId()); m.setPlanId(d.getPlanId());
m.setSectionId(d.getSectionId()); m.setSectionId(d.getSectionId());
m.setDescriptionTemplateGroupId(d.getDescriptionTemplateGroupId()); m.setDescriptionTemplateGroupId(d.getDescriptionTemplateGroupId());
models.add(m); models.add(m);

View File

@ -6,18 +6,18 @@ import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DmpEntity; import org.opencdmp.data.PlanEntity;
import org.opencdmp.data.DmpReferenceEntity; import org.opencdmp.data.PlanReferenceEntity;
import org.opencdmp.data.DmpUserEntity; import org.opencdmp.data.PlanUserEntity;
import org.opencdmp.data.EntityDoiEntity; import org.opencdmp.data.EntityDoiEntity;
import org.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity; 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.NestedDoiElasticEntity;
import org.opencdmp.elastic.data.nested.NestedReferenceElasticEntity; import org.opencdmp.elastic.data.nested.NestedReferenceElasticEntity;
import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder; import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder;
import org.opencdmp.model.dmpreference.DmpReference; import org.opencdmp.model.planreference.PlanReference;
import org.opencdmp.query.DmpReferenceQuery; import org.opencdmp.query.PlanReferenceQuery;
import org.opencdmp.query.DmpUserQuery; import org.opencdmp.query.PlanUserQuery;
import org.opencdmp.query.EntityDoiQuery; import org.opencdmp.query.EntityDoiQuery;
import org.opencdmp.query.ReferenceQuery; import org.opencdmp.query.ReferenceQuery;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -31,31 +31,31 @@ import java.util.stream.Collectors;
@Component @Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDmpElasticBuilder extends BaseElasticBuilder<NestedDmpElasticEntity, DmpEntity> { public class NestedPlanElasticBuilder extends BaseElasticBuilder<NestedPlanElasticEntity, PlanEntity> {
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
@Autowired @Autowired
public NestedDmpElasticBuilder( public NestedPlanElasticBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) { 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.queryFactory = queryFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
} }
@Override @Override
public List<NestedDmpElasticEntity> build(List<DmpEntity> data) throws MyApplicationException { public List<NestedPlanElasticEntity> build(List<PlanEntity> data) throws MyApplicationException {
if (data == null) if (data == null)
return new ArrayList<>(); return new ArrayList<>();
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDmpReferences(data); Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectPlanReferences(data);
Map<UUID, List<NestedCollaboratorElasticEntity>> collaboratorElasticEntityMap = this.collectCollaborators(data); Map<UUID, List<NestedCollaboratorElasticEntity>> collaboratorElasticEntityMap = this.collectCollaborators(data);
Map<UUID, List<NestedDoiElasticEntity>> doiElasticEntityMap = this.collectDois(data); Map<UUID, List<NestedDoiElasticEntity>> doiElasticEntityMap = this.collectDois(data);
List<NestedDmpElasticEntity> models = new ArrayList<>(); List<NestedPlanElasticEntity> models = new ArrayList<>();
for (DmpEntity d : data) { for (PlanEntity d : data) {
NestedDmpElasticEntity m = new NestedDmpElasticEntity(); NestedPlanElasticEntity m = new NestedPlanElasticEntity();
m.setId(d.getId()); m.setId(d.getId());
m.setLabel(d.getLabel()); m.setLabel(d.getLabel());
m.setDescription(d.getDescription()); m.setDescription(d.getDescription());
@ -79,51 +79,51 @@ public class NestedDmpElasticBuilder extends BaseElasticBuilder<NestedDmpElastic
return models; return models;
} }
private Map<UUID, List<NestedReferenceElasticEntity>> collectDmpReferences(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedReferenceElasticEntity>> collectPlanReferences(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null; 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); PlanReferenceQuery associationQuery = this.queryFactory.query(PlanReferenceQuery.class).disableTracking().planIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active);
List<DmpReferenceEntity> associationEntities = associationQuery.collect(); List<PlanReferenceEntity> 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<UUID, NestedReferenceElasticEntity> itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId); Map<UUID, NestedReferenceElasticEntity> itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId);
Map<UUID, List<NestedReferenceElasticEntity>> itemMap = new HashMap<>(); Map<UUID, List<NestedReferenceElasticEntity>> itemMap = new HashMap<>();
for (DmpReferenceEntity associationEntity : associationEntities){ for (PlanReferenceEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>()); if (!itemMap.containsKey(associationEntity.getPlanId())) itemMap.put(associationEntity.getPlanId(), new ArrayList<>());
NestedReferenceElasticEntity item = itemMapById.getOrDefault(associationEntity.getReferenceId(), null); 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; return itemMap;
} }
private Map<UUID, List<NestedCollaboratorElasticEntity>> collectCollaborators(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedCollaboratorElasticEntity>> collectCollaborators(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty()) if (data.isEmpty())
return null; 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); PlanUserQuery associationQuery = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active);
List<DmpUserEntity> associationEntities = associationQuery.collect(); List<PlanUserEntity> associationEntities = associationQuery.collect();
Map<UUID, NestedCollaboratorElasticEntity> itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId); Map<UUID, NestedCollaboratorElasticEntity> itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId);
Map<UUID, List<NestedCollaboratorElasticEntity>> itemMap = new HashMap<>(); Map<UUID, List<NestedCollaboratorElasticEntity>> itemMap = new HashMap<>();
for (DmpUserEntity associationEntity : associationEntities){ for (PlanUserEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>()); if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getPlanId(), new ArrayList<>());
NestedCollaboratorElasticEntity item = itemMapById.getOrDefault(associationEntity.getId(), null); 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; return itemMap;
} }
private Map<UUID, List<NestedDoiElasticEntity>> collectDois(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedDoiElasticEntity>> collectDois(List<PlanEntity> data) throws MyApplicationException {
if (data.isEmpty()) if (data.isEmpty())
return null; return null;
this.logger.debug("checking related - {}", EntityDoiEntity.class.getSimpleName()); 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<EntityDoiEntity> associationEntities = associationQuery.collect(); List<EntityDoiEntity> associationEntities = associationQuery.collect();
Map<UUID, NestedDoiElasticEntity> itemMapById = this.builderFactory.builder(NestedDoiElasticBuilder.class).asForeignKey(associationEntities, NestedDoiElasticEntity::getId); Map<UUID, NestedDoiElasticEntity> itemMapById = this.builderFactory.builder(NestedDoiElasticBuilder.class).asForeignKey(associationEntities, NestedDoiElasticEntity::getId);

View File

@ -16,13 +16,13 @@ import gr.cite.tools.elastic.query.ElasticQuery;
import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.Permission; import org.opencdmp.authorization.Permission;
import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.commons.enums.DmpAccessType; import org.opencdmp.commons.enums.PlanAccessType;
import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.elastic.data.DescriptionElasticEntity; import org.opencdmp.elastic.data.DescriptionElasticEntity;
import org.opencdmp.elastic.data.DmpElasticEntity; import org.opencdmp.elastic.data.PlanElasticEntity;
import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; import org.opencdmp.elastic.data.nested.NestedPlanElasticEntity;
import org.opencdmp.service.elastic.AppElasticConfiguration; import org.opencdmp.service.elastic.AppElasticConfiguration;
import org.opencdmp.service.elastic.ElasticService; import org.opencdmp.service.elastic.ElasticService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -43,7 +43,7 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
private Collection<UUID> ids; private Collection<UUID> ids;
private String like; private String like;
private InnerObjectDmpElasticQuery dmpSubQuery; private InnerObjectDmpElasticQuery planSubQuery;
private Instant createdAfter; private Instant createdAfter;
private Instant createdBefore; private Instant createdBefore;
private Instant finalizedAfter; private Instant finalizedAfter;
@ -72,8 +72,8 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
return this; return this;
} }
public DescriptionElasticQuery dmpSubQuery(InnerObjectDmpElasticQuery subQuery) { public DescriptionElasticQuery planSubQuery(InnerObjectDmpElasticQuery subQuery) {
this.dmpSubQuery = subQuery; this.planSubQuery = subQuery;
return this; return this;
} }
@ -196,12 +196,12 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
List<Query> predicates = new ArrayList<>(); List<Query> predicates = new ArrayList<>();
if (usePublic ) { if (usePublic ) {
predicates.add(this.and( 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 + "." + PlanElasticEntity._status, this.entityClass()).disableInfer(true), PlanStatus.Finalized.getValue()),
this.equals(new ElasticField(DescriptionElasticEntity._dmp + "." + DmpElasticEntity._accessType, this.entityClass()).disableInfer(true), DmpAccessType.Public.getValue()) this.equals(new ElasticField(DescriptionElasticEntity._dmp + "." + PlanElasticEntity._accessType, this.entityClass()).disableInfer(true), PlanAccessType.Public.getValue())
)); ));
} }
if (userId != null) { 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); query.userIds(userId);
predicates.add(this.nestedQuery(query).build()._toQuery()); predicates.add(this.nestedQuery(query).build()._toQuery());
} }
@ -230,13 +230,13 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
QueryBuilders.nested().path(DescriptionElasticEntity._references).query( QueryBuilders.nested().path(DescriptionElasticEntity._references).query(
this.like(elasticFields, List.of(this.like))._toQuery() this.like(elasticFields, List.of(this.like))._toQuery()
).build()._toQuery(), ).build()._toQuery(),
QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._references).query( QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedPlanElasticEntity._references).query(
this.like(elasticFields, List.of(this.like))._toQuery() this.like(elasticFields, List.of(this.like))._toQuery()
).build()._toQuery(), ).build()._toQuery(),
QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._collaborators).query( QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedPlanElasticEntity._collaborators).query(
this.like(elasticFields, List.of(this.like))._toQuery() this.like(elasticFields, List.of(this.like))._toQuery()
).build()._toQuery(), ).build()._toQuery(),
QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._dois).query( QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedPlanElasticEntity._dois).query(
this.like(elasticFields, List.of(this.like))._toQuery() this.like(elasticFields, List.of(this.like))._toQuery()
).build()._toQuery() ).build()._toQuery()
)._toQuery()); )._toQuery());
@ -262,8 +262,8 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
if (this.createdBefore != null) { if (this.createdBefore != null) {
predicates.add(this.dateLessThanQuery(this.elasticFieldOf(DescriptionElasticEntity._createdAt), this.createdBefore)._toQuery()); predicates.add(this.dateLessThanQuery(this.elasticFieldOf(DescriptionElasticEntity._createdAt), this.createdBefore)._toQuery());
} }
if (this.dmpSubQuery != null) { if (this.planSubQuery != null) {
predicates.add(this.dmpSubQuery.innerPath(DescriptionElasticEntity._dmp).applyFilters()); predicates.add(this.planSubQuery.innerPath(DescriptionElasticEntity._dmp).applyFilters());
} }
if (!predicates.isEmpty()) { if (!predicates.isEmpty()) {
return this.and(predicates); return this.and(predicates);

View File

@ -1,403 +0,0 @@
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.DmpAccessType;
import org.opencdmp.commons.enums.DmpStatus;
import org.opencdmp.commons.enums.DmpVersionStatus;
import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.elastic.data.DmpElasticEntity;
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 DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
private String like;
private Collection<UUID> ids;
private Collection<UUID> excludedIds;
private Collection<DmpStatus> statuses;
private Collection<DmpVersionStatus> versionStatuses;
private Collection<DmpAccessType> accessTypes;
private Collection<Integer> versions;
private Collection<UUID> groupIds;
private NestedCollaboratorElasticQuery dmpUserSubQuery;
private NestedDescriptionElasticQuery descriptionSubQuery;
private NestedDmpDescriptionTemplateElasticQuery dmpDescriptionTemplateSubQuery;
private EnumSet<AuthorizationFlags> 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<UUID> values) {
this.ids = values;
return this;
}
public DmpElasticQuery excludedIds(Collection<UUID> 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<DmpVersionStatus> 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<DmpAccessType> 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<DmpStatus> 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<Integer> 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<UUID> values) {
this.groupIds = values;
return this;
}
public DmpElasticQuery authorize(EnumSet<AuthorizationFlags> 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<DmpElasticEntity> entityClass() {
return DmpElasticEntity.class;
}
private Query applyTenant(List<Query> 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<Query> 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<Query> 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<String, Object> rawData, Set<String> 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<String> 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;
}
}

View File

@ -9,11 +9,11 @@ import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticFields; import gr.cite.tools.elastic.query.ElasticFields;
import gr.cite.tools.elastic.query.ElasticInnerObjectQuery; import gr.cite.tools.elastic.query.ElasticInnerObjectQuery;
import gr.cite.tools.elastic.query.ElasticNestedQuery; import gr.cite.tools.elastic.query.ElasticNestedQuery;
import org.opencdmp.commons.enums.DmpAccessType; import org.opencdmp.commons.enums.PlanAccessType;
import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.commons.enums.DmpVersionStatus; import org.opencdmp.commons.enums.PlanVersionStatus;
import org.opencdmp.elastic.data.DescriptionElasticEntity; 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.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -26,13 +26,13 @@ import java.util.stream.Collectors;
@Component @Component
//Like in C# make it Transient //Like in C# make it Transient
@Scope(BeanDefinition.SCOPE_PROTOTYPE) @Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObjectDmpElasticQuery, NestedDmpElasticEntity, UUID> { public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObjectDmpElasticQuery, NestedPlanElasticEntity, UUID> {
private String like; private String like;
private Collection<UUID> ids; private Collection<UUID> ids;
private Collection<UUID> excludedIds; private Collection<UUID> excludedIds;
private Collection<DmpStatus> statuses; private Collection<PlanStatus> statuses;
private Collection<DmpVersionStatus> versionStatuses; private Collection<PlanVersionStatus> versionStatuses;
private Collection<DmpAccessType> accessTypes; private Collection<PlanAccessType> accessTypes;
private Collection<Integer> versions; private Collection<Integer> versions;
private Collection<UUID> groupIds; private Collection<UUID> groupIds;
private NestedCollaboratorElasticQuery dmpUserSubQuery; private NestedCollaboratorElasticQuery dmpUserSubQuery;
@ -78,47 +78,47 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObj
return this; return this;
} }
public InnerObjectDmpElasticQuery versionStatuses(DmpVersionStatus value) { public InnerObjectDmpElasticQuery versionStatuses(PlanVersionStatus value) {
this.versionStatuses = List.of(value); this.versionStatuses = List.of(value);
return this; return this;
} }
public InnerObjectDmpElasticQuery versionStatuses(DmpVersionStatus... value) { public InnerObjectDmpElasticQuery versionStatuses(PlanVersionStatus... value) {
this.versionStatuses = Arrays.asList(value); this.versionStatuses = Arrays.asList(value);
return this; return this;
} }
public InnerObjectDmpElasticQuery versionStatuses(Collection<DmpVersionStatus> values) { public InnerObjectDmpElasticQuery versionStatuses(Collection<PlanVersionStatus> values) {
this.versionStatuses = values; this.versionStatuses = values;
return this; return this;
} }
public InnerObjectDmpElasticQuery accessTypes(DmpAccessType value) { public InnerObjectDmpElasticQuery accessTypes(PlanAccessType value) {
this.accessTypes = List.of(value); this.accessTypes = List.of(value);
return this; return this;
} }
public InnerObjectDmpElasticQuery accessTypes(DmpAccessType... value) { public InnerObjectDmpElasticQuery accessTypes(PlanAccessType... value) {
this.accessTypes = Arrays.asList(value); this.accessTypes = Arrays.asList(value);
return this; return this;
} }
public InnerObjectDmpElasticQuery accessTypes(Collection<DmpAccessType> values) { public InnerObjectDmpElasticQuery accessTypes(Collection<PlanAccessType> values) {
this.accessTypes = values; this.accessTypes = values;
return this; return this;
} }
public InnerObjectDmpElasticQuery statuses(DmpStatus value) { public InnerObjectDmpElasticQuery statuses(PlanStatus value) {
this.statuses = List.of(value); this.statuses = List.of(value);
return this; return this;
} }
public InnerObjectDmpElasticQuery statuses(DmpStatus... value) { public InnerObjectDmpElasticQuery statuses(PlanStatus... value) {
this.statuses = Arrays.asList(value); this.statuses = Arrays.asList(value);
return this; return this;
} }
public InnerObjectDmpElasticQuery statuses(Collection<DmpStatus> values) { public InnerObjectDmpElasticQuery statuses(Collection<PlanStatus> values) {
this.statuses = values; this.statuses = values;
return this; return this;
} }
@ -170,8 +170,8 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObj
} }
@Override @Override
protected Class<NestedDmpElasticEntity> entityClass() { protected Class<NestedPlanElasticEntity> entityClass() {
return NestedDmpElasticEntity.class; return NestedPlanElasticEntity.class;
} }
@Override @Override
@ -187,33 +187,33 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObj
if (!this.like.startsWith("*")) this.like = "*" + this.like; if (!this.like.startsWith("*")) this.like = "*" + this.like;
if (!this.like.endsWith("*")) this.like = this.like + "*"; if (!this.like.endsWith("*")) this.like = this.like + "*";
ElasticFields elasticFields = new ElasticFields(this.entityClass(), List.of(this.getInnerPath())); ElasticFields elasticFields = new ElasticFields(this.entityClass(), List.of(this.getInnerPath()));
elasticFields.add(NestedDmpElasticEntity._label, true); elasticFields.add(NestedPlanElasticEntity._label, true);
elasticFields.add(NestedDmpElasticEntity._description, true); elasticFields.add(NestedPlanElasticEntity._description, true);
predicates.add(this.like(elasticFields, List.of(this.like))._toQuery()); predicates.add(this.like(elasticFields, List.of(this.like))._toQuery());
} }
if (this.ids != null) { if (this.ids != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(NestedDmpElasticEntity._id).disableInfer(true), this.ids)._toQuery()); predicates.add(this.containsUUID(this.elasticFieldOf(NestedPlanElasticEntity._id).disableInfer(true), this.ids)._toQuery());
} }
if (this.groupIds != null) { if (this.groupIds != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(NestedDmpElasticEntity._groupId).disableInfer(true), this.groupIds)._toQuery()); predicates.add(this.containsUUID(this.elasticFieldOf(NestedPlanElasticEntity._groupId).disableInfer(true), this.groupIds)._toQuery());
} }
if (this.versions != null) { if (this.versions != null) {
predicates.add(this.contains(this.elasticFieldOf(NestedDmpElasticEntity._version).disableInfer(true), this.versions.toArray(new Integer[this.versions.size()]))._toQuery()); predicates.add(this.contains(this.elasticFieldOf(NestedPlanElasticEntity._version).disableInfer(true), this.versions.toArray(new Integer[this.versions.size()]))._toQuery());
} }
if (this.excludedIds != null) { if (this.excludedIds != null) {
predicates.add(this.not(this.containsUUID(this.elasticFieldOf(NestedDmpElasticEntity._id).disableInfer(true), this.excludedIds)._toQuery())._toQuery()); predicates.add(this.not(this.containsUUID(this.elasticFieldOf(NestedPlanElasticEntity._id).disableInfer(true), this.excludedIds)._toQuery())._toQuery());
} }
if (this.statuses != null) { if (this.statuses != null) {
predicates.add(this.contains(this.elasticFieldOf(NestedDmpElasticEntity._status).disableInfer(true), this.statuses.stream().map(x-> 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) { 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) { 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) { 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()) { if (!predicates.isEmpty()) {
@ -224,35 +224,35 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObj
} }
@Override @Override
public NestedDmpElasticEntity convert(Map<String, Object> rawData, Set<String> columns) { public NestedPlanElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
NestedDmpElasticEntity mocDoc = new NestedDmpElasticEntity(); NestedPlanElasticEntity mocDoc = new NestedPlanElasticEntity();
if (columns.contains(NestedDmpElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._id), UUID.class)); if (columns.contains(NestedPlanElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._id), UUID.class));
if (columns.contains(NestedDmpElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._label), String.class)); if (columns.contains(NestedPlanElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._label), String.class));
if (columns.contains(NestedDmpElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._description), String.class)); if (columns.contains(NestedPlanElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._description), String.class));
if (columns.contains(NestedDmpElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._status), DmpStatus.class)); if (columns.contains(NestedPlanElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._status), PlanStatus.class));
if (columns.contains(NestedDmpElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._versionStatus), DmpVersionStatus.class)); if (columns.contains(NestedPlanElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._versionStatus), PlanVersionStatus.class));
if (columns.contains(NestedDmpElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._version), Short.class)); if (columns.contains(NestedPlanElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._version), Short.class));
if (columns.contains(NestedDmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._groupId), UUID.class)); if (columns.contains(NestedPlanElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._groupId), UUID.class));
if (columns.contains(NestedDmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._accessType), DmpAccessType.class)); if (columns.contains(NestedPlanElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedPlanElasticEntity._accessType), PlanAccessType.class));
if (columns.contains(NestedDmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._finalizedAt), Date.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), NestedDmpElasticEntity._collaborators, null)); 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), NestedDmpElasticEntity._references, null)); mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), NestedPlanElasticEntity._references, null));
return mocDoc; return mocDoc;
} }
@Override @Override
protected ElasticField fieldNameOf(FieldResolver item) { protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedDmpElasticEntity._id)) return this.elasticFieldOf(NestedDmpElasticEntity._id); if (item.match(NestedPlanElasticEntity._id)) return this.elasticFieldOf(NestedPlanElasticEntity._id);
else if (item.match(NestedDmpElasticEntity._label)) return this.elasticFieldOf(NestedDmpElasticEntity._label); else if (item.match(NestedPlanElasticEntity._label)) return this.elasticFieldOf(NestedPlanElasticEntity._label);
else if (item.match(NestedDmpElasticEntity._description)) return this.elasticFieldOf(NestedDmpElasticEntity._description); else if (item.match(NestedPlanElasticEntity._description)) return this.elasticFieldOf(NestedPlanElasticEntity._description);
else if (item.match(NestedDmpElasticEntity._status)) return this.elasticFieldOf(NestedDmpElasticEntity._status); else if (item.match(NestedPlanElasticEntity._status)) return this.elasticFieldOf(NestedPlanElasticEntity._status);
else if (item.match(NestedDmpElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDmpElasticEntity._versionStatus); else if (item.match(NestedPlanElasticEntity._versionStatus)) return this.elasticFieldOf(NestedPlanElasticEntity._versionStatus);
else if (item.match(NestedDmpElasticEntity._version)) return this.elasticFieldOf(NestedDmpElasticEntity._version); else if (item.match(NestedPlanElasticEntity._version)) return this.elasticFieldOf(NestedPlanElasticEntity._version);
else if (item.match(NestedDmpElasticEntity._groupId)) return this.elasticFieldOf(NestedDmpElasticEntity._groupId); else if (item.match(NestedPlanElasticEntity._groupId)) return this.elasticFieldOf(NestedPlanElasticEntity._groupId);
else if (item.match(NestedDmpElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedDmpElasticEntity._finalizedAt); else if (item.match(NestedPlanElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedPlanElasticEntity._finalizedAt);
else if (item.match(NestedDmpElasticEntity._accessType)) return this.elasticFieldOf(NestedDmpElasticEntity._accessType); else if (item.match(NestedPlanElasticEntity._accessType)) return this.elasticFieldOf(NestedPlanElasticEntity._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(NestedPlanElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedPlanElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, NestedPlanElasticEntity._collaborators));
else if (item.prefix(NestedDmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedDmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, NestedDmpElasticEntity._references)); else if (item.prefix(NestedPlanElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedPlanElasticEntity._references).fieldNameOf(this.extractPrefixed(item, NestedPlanElasticEntity._references));
else return null; else return null;
} }
@ -268,13 +268,13 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObj
@Override @Override
protected ElasticField getKeyField() { protected ElasticField getKeyField() {
return this.elasticFieldOf(NestedDmpElasticEntity._id); return this.elasticFieldOf(NestedPlanElasticEntity._id);
} }
@Override @Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) { protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
if (item.prefix(NestedDmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedDmpElasticEntity._collaborators); if (item.prefix(NestedPlanElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedPlanElasticEntity._collaborators);
else if (item.prefix(NestedDmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedDmpElasticEntity._references); else if (item.prefix(NestedPlanElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedPlanElasticEntity._references);
else return null; else return null;
} }
} }

View File

@ -6,7 +6,7 @@ import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper; import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField; import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticNestedQuery; 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.opencdmp.elastic.data.nested.NestedCollaboratorElasticEntity;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -22,7 +22,7 @@ public class NestedCollaboratorElasticQuery extends ElasticNestedQuery<NestedCol
private Collection<UUID> userIds; private Collection<UUID> userIds;
private Collection<DmpUserRole> userRoles; private Collection<PlanUserRole> userRoles;
public NestedCollaboratorElasticQuery ids(UUID value) { public NestedCollaboratorElasticQuery ids(UUID value) {
this.ids = List.of(value); this.ids = List.of(value);
@ -54,17 +54,17 @@ public class NestedCollaboratorElasticQuery extends ElasticNestedQuery<NestedCol
return this; return this;
} }
public NestedCollaboratorElasticQuery userRoles(DmpUserRole value) { public NestedCollaboratorElasticQuery userRoles(PlanUserRole value) {
this.userRoles = List.of(value); this.userRoles = List.of(value);
return this; return this;
} }
public NestedCollaboratorElasticQuery userRoles(DmpUserRole... value) { public NestedCollaboratorElasticQuery userRoles(PlanUserRole... value) {
this.userRoles = Arrays.asList(value); this.userRoles = Arrays.asList(value);
return this; return this;
} }
public NestedCollaboratorElasticQuery userRoles(Collection<DmpUserRole> values) { public NestedCollaboratorElasticQuery userRoles(Collection<PlanUserRole> values) {
this.userRoles = values; this.userRoles = values;
return this; return this;
} }
@ -110,7 +110,7 @@ public class NestedCollaboratorElasticQuery extends ElasticNestedQuery<NestedCol
} }
if (this.userRoles != null) { if (this.userRoles != null) {
predicates.add(this.contains(this.elasticFieldOf(NestedCollaboratorElasticEntity._role), this.userRoles.stream().map(DmpUserRole::getValue).toList().toArray(new Short[this.userRoles.size()]))._toQuery()); predicates.add(this.contains(this.elasticFieldOf(NestedCollaboratorElasticEntity._role), this.userRoles.stream().map(PlanUserRole::getValue).toList().toArray(new Short[this.userRoles.size()]))._toQuery());
} }
if (!predicates.isEmpty()) { if (!predicates.isEmpty()) {
@ -126,7 +126,7 @@ public class NestedCollaboratorElasticQuery extends ElasticNestedQuery<NestedCol
if (columns.contains(NestedCollaboratorElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._id), UUID.class)); if (columns.contains(NestedCollaboratorElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._id), UUID.class));
if (columns.contains(NestedCollaboratorElasticEntity._userId)) mocDoc.setUserId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._userId), UUID.class)); if (columns.contains(NestedCollaboratorElasticEntity._userId)) mocDoc.setUserId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._userId), UUID.class));
if (columns.contains(NestedCollaboratorElasticEntity._name)) mocDoc.setName(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._name), String.class)); if (columns.contains(NestedCollaboratorElasticEntity._name)) mocDoc.setName(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._name), String.class));
if (columns.contains(NestedCollaboratorElasticEntity._role)) mocDoc.setRole(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._role), DmpUserRole.class)); if (columns.contains(NestedCollaboratorElasticEntity._role)) mocDoc.setRole(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._role), PlanUserRole.class));
return mocDoc; return mocDoc;
} }

View File

@ -83,7 +83,7 @@ public class NestedDescriptionElasticQuery extends ElasticNestedQuery<NestedDesc
NestedDescriptionElasticEntity mocDoc = new NestedDescriptionElasticEntity(); NestedDescriptionElasticEntity mocDoc = new NestedDescriptionElasticEntity();
if (columns.contains(NestedDescriptionElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._id), UUID.class)); if (columns.contains(NestedDescriptionElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._id), UUID.class));
if (columns.contains(NestedDescriptionElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._label), String.class)); if (columns.contains(NestedDescriptionElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._label), String.class));
if (columns.contains(NestedDescriptionElasticEntity._dmpId)) mocDoc.setDmpId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._dmpId), UUID.class)); if (columns.contains(NestedDescriptionElasticEntity._dmpId)) mocDoc.setPlanId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._dmpId), UUID.class));
if (columns.contains(NestedDescriptionElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._description), String.class)); if (columns.contains(NestedDescriptionElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._description), String.class));
if (columns.contains(NestedDescriptionElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._status), DescriptionStatus.class)); if (columns.contains(NestedDescriptionElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._status), DescriptionStatus.class));
if (columns.contains(NestedDescriptionElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._finalizedAt), Date.class)); if (columns.contains(NestedDescriptionElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._finalizedAt), Date.class));

View File

@ -1,199 +0,0 @@
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.NestedDmpDescriptionTemplateElasticEntity;
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 NestedDmpDescriptionTemplateElasticQuery extends ElasticNestedQuery<NestedDmpDescriptionTemplateElasticQuery, NestedDmpDescriptionTemplateElasticEntity, UUID> {
private Collection<UUID> ids;
private Collection<UUID> excludedIds;
private Collection<UUID> descriptionTemplateGroupIds;
private Collection<UUID> dmpIds;
private Collection<UUID> 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<UUID> 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<UUID> 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<UUID> 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<UUID> 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<UUID> 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<NestedDmpDescriptionTemplateElasticEntity> entityClass() {
return NestedDmpDescriptionTemplateElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return false;
}
@Override
protected Query applyAuthZ() {
return null;
}
@Override
protected Query applyFilters() {
List<Query> 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<String, Object> rawData, Set<String> 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;
}
}

View File

@ -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<NestedPlanDescriptionTemplateElasticQuery, NestedPlanDescriptionTemplateElasticEntity, UUID> {
private Collection<UUID> ids;
private Collection<UUID> excludedIds;
private Collection<UUID> descriptionTemplateGroupIds;
private Collection<UUID> planIds;
private Collection<UUID> 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<UUID> 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<UUID> 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<UUID> 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<UUID> 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<UUID> 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<NestedPlanDescriptionTemplateElasticEntity> entityClass() {
return NestedPlanDescriptionTemplateElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return false;
}
@Override
protected Query applyAuthZ() {
return null;
}
@Override
protected Query applyFilters() {
List<Query> 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<String, Object> rawData, Set<String> 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;
}
}

View File

@ -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<PlanElasticEntity, UUID> {
private String like;
private Collection<UUID> ids;
private Collection<UUID> excludedIds;
private Collection<PlanStatus> statuses;
private Collection<PlanVersionStatus> versionStatuses;
private Collection<PlanAccessType> accessTypes;
private Collection<Integer> versions;
private Collection<UUID> groupIds;
private NestedCollaboratorElasticQuery planUserSubQuery;
private NestedDescriptionElasticQuery descriptionSubQuery;
private NestedPlanDescriptionTemplateElasticQuery planDescriptionTemplateSubQuery;
private EnumSet<AuthorizationFlags> 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<UUID> values) {
this.ids = values;
return this;
}
public PlanElasticQuery excludedIds(Collection<UUID> 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<PlanVersionStatus> 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<PlanAccessType> 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<PlanStatus> 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<Integer> 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<UUID> values) {
this.groupIds = values;
return this;
}
public PlanElasticQuery authorize(EnumSet<AuthorizationFlags> 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<PlanElasticEntity> entityClass() {
return PlanElasticEntity.class;
}
private Query applyTenant(List<Query> 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<Query> 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<Query> 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<String, Object> rawData, Set<String> 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<String> 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;
}
}

View File

@ -49,7 +49,7 @@ public class EventBroker {
this.applicationEventPublisher.publishEvent(event); this.applicationEventPublisher.publishEvent(event);
} }
public void emit(DmpTouchedEvent event) { public void emit(PlanTouchedEvent event) {
this.applicationEventPublisher.publishEvent(event); this.applicationEventPublisher.publishEvent(event);
} }

Some files were not shown because too many files have changed in this diff Show More