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

This commit is contained in:
Sofia Papacharalampous 2024-06-04 14:54:21 +03:00
commit e665cbdfc6
8 changed files with 95 additions and 183 deletions

View File

@ -56,9 +56,6 @@ permissions:
BrowseAnnotation:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
entityAffiliated: true
clients: [ ]
@ -67,9 +64,6 @@ permissions:
NewAnnotation:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
entityAffiliated: true
clients: [ ]
@ -78,9 +72,6 @@ permissions:
EditAnnotation:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: true
@ -88,9 +79,6 @@ permissions:
DeleteAnnotation:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
entityAffiliated: false
clients: [ ]

View File

@ -9,6 +9,7 @@ import java.util.List;
public class AuthorizationProperties {
private List<String> globalAdminRoles;
private String adminRole;
private String tenantAdminRole;
private String globalUserRole;
private String tenantUserRole;
@ -24,6 +25,14 @@ public class AuthorizationProperties {
this.globalAdminRoles = globalAdminRoles;
}
public String getAdminRole() {
return adminRole;
}
public void setAdminRole(String adminRole) {
this.adminRole = adminRole;
}
public String getTenantAdminRole() {
return this.tenantAdminRole;
}

View File

@ -185,7 +185,11 @@ public class TenantServiceImpl implements TenantService {
item.setId(UUID.randomUUID());
item.setUserId(userId);
item.setTenantId(tenant.getId());
item.setRole(this.authorizationProperties.getTenantAdminRole());
if (existingItems.stream().filter(x -> x.getUserId().equals(userId) && x.getRole().equals(this.authorizationProperties.getAdminRole())).findFirst().orElse(null) != null){
item.setRole(this.authorizationProperties.getTenantAdminRole()); // admin
} else {
item.setRole(this.authorizationProperties.getTenantUserRole()); // installation admin
}
item.setCreatedAt(Instant.now());
this.entityManager.persist(item);
keycloakIdsToAddToTenantGroup.add(userCredential.getExternalId());

View File

@ -2,6 +2,7 @@ authorization:
globalAdminRoles:
- Admin
- InstallationAdmin
adminRole: Admin
tenantAdminRole: TenantAdmin
globalUserRole: User
tenantUserRole: TenantUser

View File

@ -6,8 +6,8 @@ permissions:
roles:
- TenantAdmin
- TenantUser
- TenantManager
- TenantDescriptionTemplateEditor
- TenantPlanManager
- TenantConfigManager
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
@ -94,9 +94,6 @@ permissions:
BrowseDeposit:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -104,9 +101,6 @@ permissions:
EditDeposit:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -120,6 +114,7 @@ permissions:
EditNotificationTemplate:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -127,6 +122,7 @@ permissions:
DeleteNotificationTemplate:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
claims: [ ]
clients: [ ]
@ -164,6 +160,7 @@ permissions:
EditLanguage:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -171,6 +168,7 @@ permissions:
DeleteLanguage:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
claims: [ ]
clients: [ ]
@ -186,9 +184,6 @@ permissions:
BrowseDescription:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -202,9 +197,6 @@ permissions:
ReviewDescription:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -217,9 +209,6 @@ permissions:
EditDescription:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -231,9 +220,6 @@ permissions:
FinalizeDescription:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -245,9 +231,6 @@ permissions:
DeleteDescription:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -260,9 +243,6 @@ permissions:
CloneDescription:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -281,9 +261,6 @@ permissions:
BrowseTag:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -291,9 +268,6 @@ permissions:
EditTag:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -301,9 +275,6 @@ permissions:
DeleteTag:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
claims: [ ]
clients: [ ]
@ -314,9 +285,8 @@ permissions:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
@ -346,9 +316,6 @@ permissions:
BrowseDmpAssociatedUser:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -364,9 +331,7 @@ permissions:
BrowseDescriptionTemplateType:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantUser
clients: [ ]
@ -375,6 +340,7 @@ permissions:
EditDescriptionTemplateType:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
@ -382,6 +348,7 @@ permissions:
DeleteDescriptionTemplateType:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
claims: [ ]
clients: [ ]
@ -431,6 +398,7 @@ permissions:
EditDescriptionTemplate:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
@ -438,6 +406,7 @@ permissions:
DeleteDescriptionTemplate:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
claims: [ ]
clients: [ ]
@ -446,6 +415,7 @@ permissions:
CloneDescriptionTemplate:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
claims: [ ]
clients: [ ]
@ -454,6 +424,7 @@ permissions:
CreateNewVersionDescriptionTemplate:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
claims: [ ]
clients: [ ]
@ -462,6 +433,7 @@ permissions:
ImportDescriptionTemplate:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
claims: [ ]
clients: [ ]
@ -470,6 +442,7 @@ permissions:
ExportDescriptionTemplate:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
claims: [ ]
clients: [ ]
@ -479,9 +452,6 @@ permissions:
BrowseDmp:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -495,9 +465,6 @@ permissions:
EditDmp:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -519,9 +486,6 @@ permissions:
DeleteDmp:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -533,9 +497,6 @@ permissions:
DepositDmp:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -547,9 +508,6 @@ permissions:
CloneDmp:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -567,9 +525,6 @@ permissions:
CreateNewVersionDmp:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -581,9 +536,6 @@ permissions:
FinalizeDmp:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -595,9 +547,6 @@ permissions:
UndoFinalizeDmp:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -609,9 +558,6 @@ permissions:
AssignDmpUsers:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -623,9 +569,6 @@ permissions:
InviteDmpUsers:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
dmp:
roles:
@ -649,6 +592,7 @@ permissions:
EditDmpBlueprint:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
@ -656,6 +600,7 @@ permissions:
CloneDmpBlueprint:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
@ -663,12 +608,14 @@ permissions:
CreateNewVersionDmpBlueprint:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
ExportDmpBlueprint:
roles:
- TenantAdmin
- TenantPlanManager
- Admin
clients: [ ]
@ -677,6 +624,7 @@ permissions:
ImportDmpBlueprint:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
claims: [ ]
clients: [ ]
@ -685,6 +633,7 @@ permissions:
DeleteDmpBlueprint:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
claims: [ ]
clients: [ ]
@ -694,9 +643,6 @@ permissions:
BrowseEntityDoi:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -704,9 +650,6 @@ permissions:
EditEntityDoi:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -714,9 +657,6 @@ permissions:
DeleteEntityDoi:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
claims: [ ]
clients: [ ]
@ -728,9 +668,6 @@ permissions:
BrowseReference:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -753,9 +690,6 @@ permissions:
BrowseDmpReference:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -763,9 +697,6 @@ permissions:
EditDmpReference:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -773,9 +704,6 @@ permissions:
DeleteDmpReference:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
claims: [ ]
clients: [ ]
@ -786,9 +714,6 @@ permissions:
BrowseDmpUser:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -796,9 +721,6 @@ permissions:
EditDmpUser:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -806,9 +728,6 @@ permissions:
DeleteDmpUser:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
claims: [ ]
clients: [ ]
@ -824,12 +743,14 @@ permissions:
- TenantConfigManager
- TenantAdmin
- TenantUser
- User
clients: [ ]
allowAnonymous: yes
allowAuthenticated: yes
EditSupportiveMaterial:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -837,6 +758,7 @@ permissions:
DeleteSupportiveMaterial:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
claims: [ ]
clients: [ ]
@ -858,14 +780,14 @@ permissions:
EditReferenceType:
roles:
- Admin
- TenantPlanManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
DeleteReferenceType:
roles:
- Admin
- TenantPlanManager
- TenantAdmin
claims: [ ]
clients: [ ]
allowAnonymous: false
@ -923,9 +845,6 @@ permissions:
BrowseDmpDescriptionTemplate:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -933,9 +852,6 @@ permissions:
EditDmpDescriptionTemplate:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -943,9 +859,6 @@ permissions:
DeleteDmpDescriptionTemplate:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
claims: [ ]
clients: [ ]
@ -956,9 +869,6 @@ permissions:
BrowseDescriptionReference:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -966,9 +876,6 @@ permissions:
EditDescriptionReference:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -976,9 +883,6 @@ permissions:
DeleteDescriptionReference:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
claims: [ ]
clients: [ ]
@ -989,9 +893,6 @@ permissions:
BrowseDescriptionTag:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -999,9 +900,6 @@ permissions:
EditDescriptionTag:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
clients: [ ]
allowAnonymous: false
@ -1009,9 +907,6 @@ permissions:
DeleteDescriptionTag:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
claims: [ ]
clients: [ ]
@ -1046,11 +941,6 @@ permissions:
EditLock:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantUser
dmp:
roles:
- Owner
@ -1063,11 +953,6 @@ permissions:
DeleteLock:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantUser
dmp:
roles:
- Owner
@ -1089,33 +974,21 @@ permissions:
BrowseActionConfirmation:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantUser
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
EditActionConfirmation:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantUser
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
DeleteActionConfirmation:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantUser
claims: [ ]
clients: [ ]
allowAnonymous: false
@ -1153,6 +1026,7 @@ permissions:
ViewDescriptionTemplateTypePage:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
@ -1172,6 +1046,7 @@ permissions:
ViewNotificationTemplatePage:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -1179,6 +1054,7 @@ permissions:
ViewSupportiveMaterialPage:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -1186,6 +1062,7 @@ permissions:
ViewLanguagePage:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -1233,6 +1110,7 @@ permissions:
ViewDescriptionTemplatePage:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
@ -1240,6 +1118,7 @@ permissions:
ViewDmpBlueprintPage:
roles:
- Admin
- TenantAdmin
- TenantPlanManager
clients: [ ]
allowAnonymous: false
@ -1257,9 +1136,6 @@ permissions:
ViewMyDescriptionPage:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantUser
clients: [ ]
@ -1268,9 +1144,6 @@ permissions:
ViewMyDmpPage:
roles:
- Admin
- InstallationAdmin
- TenantPlanManager
- TenantConfigManager
- TenantAdmin
- TenantUser
clients: [ ]

View File

@ -41,6 +41,7 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
public class DatasetMigrationService {
@ -97,16 +98,41 @@ public class DatasetMigrationService {
DefinitionEntity definitionEntity = this.xmlHandlingService.fromXml(DefinitionEntity.class, dmpBlueprint.getDefinition());
dmpBlueprintsMap.put(dmpBlueprint.getId(), definitionEntity);
}
List<UUID> changeTemplateToH2020 = Stream.of("0c82f2ce-5ff7-4ca9-a500-9f3062adf550",
"7acd3b36-e598-459c-8170-87c51ac80efb",
"64e7969a-6d0e-4895-ad4a-a382b6efb279",
"b4f3e186-98e7-424e-983e-c6f5c911e3be",
"8266cb3e-ef0e-4c19-b9fc-c33e44cebd03",
"dc7a7fbb-2a94-4e62-88b7-461a7b7411e1",
"7c16ef72-8728-41aa-9154-8f0f2105c75c",
"6382ffd2-0e13-45b7-9e4f-3bd2a695d394",
"4648c912-d514-460a-b6bf-fa9d3150438b",
"b6208df9-baef-4fa4-b483-9332e77ba3e5",
"28520240-c8bd-4272-a822-150cf23ca2e3",
"d243e090-aa83-4349-b64c-166cb132f4c8").map(UUID::fromString).toList();
UUID horizon2020UUID = UUID.fromString("6ddde24b-e7a0-477f-a2cd-0a8fad915dc8");
UUID horizonGroupId = UUID.fromString("3689bcce-405a-4d55-9854-669597b79c0a");
List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(items.stream().map(x-> x.getDmp().getId()).distinct().toList()).collect();
List<DescriptionTemplateEntity> descriptionTemplates = this.queryFactory.query(DescriptionTemplateQuery.class).ids(items.stream().map(x-> x.getProfile().getId()).distinct().toList()).collect();
Map<UUID, UUID> creatorsByDmp = this.queryFactory.query(DmpQuery.class).ids(items.stream().map(x-> x.getDmp().getId()).distinct().toList()).collectAs(new BaseFieldSet().ensure(Dmp._id).ensure(Dmp._creator)).stream().collect(Collectors.toMap(DmpEntity::getId, DmpEntity::getCreatorId));
List<UUID> profileIds = new ArrayList<>(items.stream().map(x -> x.getProfile().getId()).distinct().toList());
profileIds.add(horizon2020UUID);
List<DescriptionTemplateEntity> descriptionTemplates = this.queryFactory.query(DescriptionTemplateQuery.class).ids(profileIds).collect();
Map<UUID, org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity> descriptionTemplateDefinitionMap = new HashMap<>();
for (DescriptionTemplateEntity descriptionTemplateEntity : descriptionTemplates){
descriptionTemplateDefinitionMap.put(descriptionTemplateEntity.getId(), this.xmlHandlingService.fromXml(org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition()));
}
for (Dataset item : items) {
UUID profileId = item.getProfile().getId();
UUID profileGroupId = item.getProfile().getGroupId();
if (changeTemplateToH2020.contains(item.getId())) {
profileId = horizon2020UUID;
profileGroupId = horizonGroupId;
}
DefinitionEntity definition = dmpBlueprintsMap.getOrDefault(item.getDmp().getProfile().getId(), null);
if (definition == null || definition.getSections() == null || definition.getSections().size() <= item.getDmpSectionIndex()) {
@ -117,7 +143,7 @@ public class DatasetMigrationService {
throw new MyApplicationException("Migrate Dataset " + item.getId() + " cannot found section id for section " + item.getDmpSectionIndex());
}
List<DmpDescriptionTemplateEntity> itemDescriptionTemplates = this.getOrCreateDmpDescriptionTemplateEntity(item, sectionId, dmpDescriptionTemplateEntities);
List<DmpDescriptionTemplateEntity> itemDescriptionTemplates = this.getOrCreateDmpDescriptionTemplateEntity(item, sectionId, profileGroupId, dmpDescriptionTemplateEntities);
if (itemDescriptionTemplates.size() > 1) {
throw new MyApplicationException("Migrate Dataset " + item.getId() + " multiple DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
@ -134,7 +160,7 @@ public class DatasetMigrationService {
data.setDmpId(item.getDmp().getId());
data.setLabel(item.getLabel());
data.setDmpDescriptionTemplateId(itemDescriptionTemplates.getFirst().getId());
data.setDescriptionTemplateId(item.getProfile().getId());
data.setDescriptionTemplateId(profileId);
data.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
data.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
if (item.getFinalizedAt() != null)
@ -149,7 +175,8 @@ public class DatasetMigrationService {
if (data.getCreatedById() == null){
throw new MyApplicationException("Migration skipped creator not found " + item.getId());
}
org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinitionEntity = descriptionTemplateDefinitionMap.getOrDefault(item.getProfile().getId(), null);
org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinitionEntity = descriptionTemplateDefinitionMap.getOrDefault(profileId, null);
this.entityManager.persist(data);
this.entityManager.flush();
@ -164,20 +191,21 @@ public class DatasetMigrationService {
} while (items != null && !items.isEmpty() && !TestMode);
}
private List<DmpDescriptionTemplateEntity> getOrCreateDmpDescriptionTemplateEntity(Dataset item, UUID sectionId, List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities){
List<DmpDescriptionTemplateEntity> itemDescriptionTemplates = dmpDescriptionTemplateEntities.stream().filter(x-> x.getDescriptionTemplateGroupId().equals(item.getProfile().getGroupId()) && x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId)).toList();
private List<DmpDescriptionTemplateEntity> getOrCreateDmpDescriptionTemplateEntity(Dataset item, UUID sectionId, UUID groupId, List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities){
List<DmpDescriptionTemplateEntity> itemDescriptionTemplates = dmpDescriptionTemplateEntities.stream().filter(x-> x.getDescriptionTemplateGroupId().equals(groupId) && x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId)).toList();
if (itemDescriptionTemplates.isEmpty()) {
if (!item.getStatus().equals(Dataset.Status.DELETED.getValue())) logger.warn("Migrate Dataset " + item.getId() + " cannot found DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex());
if (dmpDescriptionTemplateEntities.stream().anyMatch(x -> x.getDmpId().equals(item.getDmp().getId()) && x.getSectionId().equals(sectionId))) {
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = new DmpDescriptionTemplateEntity();
dmpDescriptionTemplateEntity.setId(UUID.randomUUID());
dmpDescriptionTemplateEntity.setDescriptionTemplateGroupId(item.getProfile().getGroupId());
dmpDescriptionTemplateEntity.setDescriptionTemplateGroupId(groupId);
dmpDescriptionTemplateEntity.setDmpId(item.getDmp().getId());
dmpDescriptionTemplateEntity.setCreatedAt(item.getCreated() != null ? item.getCreated().toInstant() : Instant.now());
dmpDescriptionTemplateEntity.setUpdatedAt(item.getModified() != null ? item.getModified().toInstant() : Instant.now());
dmpDescriptionTemplateEntity.setSectionId(sectionId);
dmpDescriptionTemplateEntity.setIsActive(!item.getStatus().equals(Dataset.Status.DELETED.getValue()) ? IsActive.Active : IsActive.Inactive);
this.entityManager.persist(dmpDescriptionTemplateEntity);
this.entityManager.flush();
itemDescriptionTemplates = List.of(dmpDescriptionTemplateEntity);
} else {
throw new MyApplicationException("Migrate Dataset " + item.getId() + " " + item.getLabel() + " cannot found DmpDescriptionTemplateEntity for section " + item.getDmpSectionIndex());

View File

@ -1,6 +1,7 @@
package eu.old.eudat.migration;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import eu.old.eudat.data.entities.DMP;
import org.opencdmp.commons.JsonHandlingService;
import org.opencdmp.commons.XmlHandlingService;
import org.opencdmp.commons.enums.IsActive;
@ -103,9 +104,9 @@ public class DmpDatasetProfileMigrationService {
DmpDescriptionTemplateEntity data = new DmpDescriptionTemplateEntity();
data.setId(UUID.randomUUID());
data.setDescriptionTemplateGroupId(item.getDatasetprofile().getGroupId());
data.setDmpId(item.getDmp().getId());
data.setCreatedAt(Instant.now());
data.setUpdatedAt(Instant.now());
data.setDmpId(getDmp(item).getId());
data.setCreatedAt(item.getDmp().getCreated() != null ? item.getDmp().getCreated().toInstant() : Instant.now());
data.setUpdatedAt(item.getDmp().getModified() != null ? item.getDmp().getModified().toInstant() : Instant.now());
data.setSectionId(sectionId);
data.setIsActive(IsActive.Active);
this.entityManager.persist(data);
@ -120,6 +121,10 @@ public class DmpDatasetProfileMigrationService {
removeDuplicates();
}
private DMP getDmp(DMPDatasetProfile item) {
return item.getDmp();
}
private void removeDuplicates() {
logger.debug("Checking for duplicates on DmpDescriptionTemplate table after migration");

View File

@ -146,6 +146,7 @@ permissions:
ViewNotificationTemplatePage:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -155,6 +156,7 @@ permissions:
BrowseNotificationTemplate:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -162,6 +164,7 @@ permissions:
EditNotificationTemplate:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
@ -169,6 +172,7 @@ permissions:
DeleteNotificationTemplate:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false