Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
42c7712763
|
@ -5,6 +5,7 @@ import org.opencdmp.commons.validation.BaseValidator;
|
||||||
import gr.cite.tools.validation.specification.Specification;
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||||
|
import org.opencdmp.model.persist.dmpproperties.DmpContactPersist;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
@ -98,8 +99,12 @@ public class DmpUserPersist {
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> !this.isNull(item.getSectionId()))
|
.iff(() -> !this.isNull(item.getSectionId()))
|
||||||
.must(() -> this.isValidGuid(item.getSectionId()))
|
.must(() -> this.isValidGuid(item.getSectionId()))
|
||||||
.failOn(DmpUserPersist._sectionId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserPersist._sectionId}, LocaleContextHolder.getLocale()))
|
.failOn(DmpUserPersist._sectionId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserPersist._sectionId}, LocaleContextHolder.getLocale())),
|
||||||
);
|
this.spec()
|
||||||
|
.iff(() -> !this.isEmpty(item.getEmail()))
|
||||||
|
.must(() -> this.isValidEmail(item.getEmail()))
|
||||||
|
.failOn(DmpUserPersist._email).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DmpUserPersist._email}, LocaleContextHolder.getLocale()))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,9 +75,6 @@ public class UserInviteToTenantRequestPersist {
|
||||||
this.spec()
|
this.spec()
|
||||||
.must(() -> !this.isEmpty(item.getEmail()))
|
.must(() -> !this.isEmpty(item.getEmail()))
|
||||||
.failOn(UserInviteToTenantRequestPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserInviteToTenantRequestPersist._email}, LocaleContextHolder.getLocale())),
|
.failOn(UserInviteToTenantRequestPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserInviteToTenantRequestPersist._email}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
|
||||||
.must(() -> !this.isEmpty(item.getTenantCode()))
|
|
||||||
.failOn(UserInviteToTenantRequestPersist._tenantCode).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserInviteToTenantRequestPersist._tenantCode}, LocaleContextHolder.getLocale())),
|
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> !this.isEmpty(item.getEmail()))
|
.iff(() -> !this.isEmpty(item.getEmail()))
|
||||||
.must(() -> this.isValidEmail(item.getEmail()))
|
.must(() -> this.isValidEmail(item.getEmail()))
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.opencdmp.commons.validation.BaseValidator;
|
||||||
import gr.cite.tools.validation.specification.Specification;
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||||
|
import org.opencdmp.model.persist.UserInviteToTenantRequestPersist;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
@ -71,6 +72,10 @@ public class DmpContactPersist {
|
||||||
this.spec()
|
this.spec()
|
||||||
.must(() -> !this.isEmpty(item.getEmail()))
|
.must(() -> !this.isEmpty(item.getEmail()))
|
||||||
.failOn(DmpContactPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._email}, LocaleContextHolder.getLocale())),
|
.failOn(DmpContactPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._email}, LocaleContextHolder.getLocale())),
|
||||||
|
this.spec()
|
||||||
|
.iff(() -> !this.isEmpty(item.getEmail()))
|
||||||
|
.must(() -> this.isValidEmail(item.getEmail()))
|
||||||
|
.failOn(DmpContactPersist._email).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DmpContactPersist._email}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.must(() -> !this.isEmpty(item.getFirstName()))
|
.must(() -> !this.isEmpty(item.getFirstName()))
|
||||||
.failOn(DmpContactPersist._firstName).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._firstName}, LocaleContextHolder.getLocale())),
|
.failOn(DmpContactPersist._firstName).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._firstName}, LocaleContextHolder.getLocale())),
|
||||||
|
|
|
@ -923,6 +923,8 @@ public class UserServiceImpl implements UserService {
|
||||||
public void sendUserToTenantInvitation(UserTenantUsersInviteRequest users) throws InvalidApplicationException, JAXBException {
|
public void sendUserToTenantInvitation(UserTenantUsersInviteRequest users) throws InvalidApplicationException, JAXBException {
|
||||||
this.authorizationService.authorizeForce(Permission.InviteTenantUser);
|
this.authorizationService.authorizeForce(Permission.InviteTenantUser);
|
||||||
|
|
||||||
|
this.validatorFactory.validator(UserTenantUsersInviteRequest.UserTenantUsersInviteRequestValidator.class).validateForce(users);
|
||||||
|
|
||||||
TenantEntity tenantEntity = null;
|
TenantEntity tenantEntity = null;
|
||||||
String tenantName = null;
|
String tenantName = null;
|
||||||
String tenantCode;
|
String tenantCode;
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
DO $$DECLARE
|
||||||
|
this_version CONSTANT varchar := '00.02.000';
|
||||||
|
BEGIN
|
||||||
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
|
DROP TABLE public."DatasetDataRepository";
|
||||||
|
DROP TABLE public."DatasetExternalDataset";
|
||||||
|
DROP TABLE public."DatasetRegistry";
|
||||||
|
DROP TABLE public."DatasetService";
|
||||||
|
DROP TABLE public."Dataset";
|
||||||
|
|
||||||
|
DROP TABLE public."DMPDatasetProfile";
|
||||||
|
DROP TABLE public."DMPOrganisation";
|
||||||
|
DROP TABLE public."DMPResearcher";
|
||||||
|
DROP TABLE public."UserDMP";
|
||||||
|
DROP TABLE public."Invitation";
|
||||||
|
DROP TABLE public."DMP";
|
||||||
|
|
||||||
|
DROP TABLE public."DoiFunder";
|
||||||
|
|
||||||
|
DROP TABLE public."DataRepository";
|
||||||
|
DROP TABLE public."ExternalDataset";
|
||||||
|
DROP TABLE public."Project";
|
||||||
|
DROP TABLE public."Funder";
|
||||||
|
DROP TABLE public."Grant";
|
||||||
|
DROP TABLE public."Organisation";
|
||||||
|
DROP TABLE public."Registry";
|
||||||
|
DROP TABLE public."Researcher";
|
||||||
|
DROP TABLE public."Service";
|
||||||
|
|
||||||
|
DROP TABLE public."Content";
|
||||||
|
DROP TABLE public."Credential";
|
||||||
|
DROP TABLE public."EmailConfirmation";
|
||||||
|
DROP TABLE public."FileUpload";
|
||||||
|
DROP TABLE public."NotificationLegacy";
|
||||||
|
DROP TABLE public."UserAssociation";
|
||||||
|
DROP TABLE public."UserToken";
|
||||||
|
DROP TABLE public."UserInfo";
|
||||||
|
|
||||||
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.02.000', '2024-06-26 12:00:00.000000+02', now(), 'Remove unused tables.');
|
||||||
|
|
||||||
|
END$$;
|
|
@ -19,7 +19,7 @@ export class UserTenantUsersInviteRequestEditorModel implements UserTenantUsersI
|
||||||
users: this.formBuilder.array(
|
users: this.formBuilder.array(
|
||||||
(this.users ?? []).map(
|
(this.users ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `userInviteToTenantRequest[${index}].`,
|
rootPath: `users[${index}].`,
|
||||||
disabled: disabled
|
disabled: disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('users').validators
|
), context.getValidation('users').validators
|
||||||
|
@ -30,7 +30,7 @@ export class UserTenantUsersInviteRequestEditorModel implements UserTenantUsersI
|
||||||
createValidationContext(): ValidationContext {
|
createValidationContext(): ValidationContext {
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'users', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'userInviteToTenantRequest')] });
|
baseValidationArray.push({ key: 'users', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'users')] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
@ -44,7 +44,7 @@ export class UserTenantUsersInviteRequestEditorModel implements UserTenantUsersI
|
||||||
formArray?.controls?.forEach(
|
formArray?.controls?.forEach(
|
||||||
(control, index) => UserInviteToTenantRequestEditorModel.reapplyValidators({
|
(control, index) => UserInviteToTenantRequestEditorModel.reapplyValidators({
|
||||||
formGroup: control as UntypedFormGroup,
|
formGroup: control as UntypedFormGroup,
|
||||||
rootPath: `userInviteToTenantRequest[${index}].`,
|
rootPath: `users[${index}].`,
|
||||||
validationErrorModel: validationErrorModel
|
validationErrorModel: validationErrorModel
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -53,7 +53,7 @@ export class UserInviteToTenantDialogComponent extends BaseComponent implements
|
||||||
addUser(): void {
|
addUser(): void {
|
||||||
const formArray = this.formGroup.get("users") as UntypedFormArray;
|
const formArray = this.formGroup.get("users") as UntypedFormArray;
|
||||||
const user: UserInviteToTenantRequestEditorModel = new UserInviteToTenantRequestEditorModel(this.editorModel.validationErrorModel);
|
const user: UserInviteToTenantRequestEditorModel = new UserInviteToTenantRequestEditorModel(this.editorModel.validationErrorModel);
|
||||||
formArray.push(user.buildForm({ rootPath: "userInviteToTenantRequest[" + formArray.length + "]." }));
|
formArray.push(user.buildForm({ rootPath: "users[" + formArray.length + "]." }));
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUser(userIndex: number): void {
|
removeUser(userIndex: number): void {
|
||||||
|
@ -92,13 +92,13 @@ export class UserInviteToTenantDialogComponent extends BaseComponent implements
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
onCallbackSuccess(): void {
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-USER-INVITATION-DIALOG.SUCCESS'), SnackBarNotificationLevel.Success);
|
this.uiNotificationService.snackBarNotification(this.language.instant('USER-INVITE-TO-TENANT-DIALOG.SUCCESS'), SnackBarNotificationLevel.Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackError(errorResponse: HttpErrorResponse) {
|
onCallbackError(errorResponse: HttpErrorResponse) {
|
||||||
this.inProgressSendButton = false;
|
this.inProgressSendButton = false;
|
||||||
let errorOverrides = new Map<number, string>();
|
let errorOverrides = new Map<number, string>();
|
||||||
errorOverrides.set(-1, this.language.instant('DMP-USER-INVITATION-DIALOG.ERROR'));
|
errorOverrides.set(-1, this.language.instant('USER-INVITE-TO-TENANT-DIALOG.ERROR'));
|
||||||
this.httpErrorHandlingService.handleBackedRequestError(errorResponse, errorOverrides, SnackBarNotificationLevel.Error);
|
this.httpErrorHandlingService.handleBackedRequestError(errorResponse, errorOverrides, SnackBarNotificationLevel.Error);
|
||||||
|
|
||||||
const error: HttpError = this.httpErrorHandlingService.getError(errorResponse);
|
const error: HttpError = this.httpErrorHandlingService.getError(errorResponse);
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -2110,7 +2110,9 @@
|
||||||
"REMOVE-USER": "Remove User",
|
"REMOVE-USER": "Remove User",
|
||||||
"INVITE": "Invite"
|
"INVITE": "Invite"
|
||||||
},
|
},
|
||||||
"USERS-REQUIRED": "Required at leat on user"
|
"USERS-REQUIRED": "Required at leat on user",
|
||||||
|
"SUCCESS": "Invitation Success",
|
||||||
|
"ERROR": "Invitation Error"
|
||||||
},
|
},
|
||||||
"USER-PROFILE": {
|
"USER-PROFILE": {
|
||||||
"MERGING-EMAILS-DIALOG": {
|
"MERGING-EMAILS-DIALOG": {
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
logger.error("Migrate DescriptionTemplate " + item.getId() + " failed read xml");
|
logger.error("Migrate DescriptionTemplate " + item.getId() + " failed read xml");
|
||||||
throw new MyApplicationException("Migrate DescriptionTemplate " + item.getId() + " failed read xml");
|
throw new MyApplicationException("Migrate DescriptionTemplate " + item.getId() + " failed read xml");
|
||||||
}
|
}
|
||||||
item.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(viewStyleModel, referenceTypeEntityMap, knownReferenceEntities)));
|
item.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(viewStyleModel, referenceTypeEntityMap, knownReferenceEntities, item.getId())));
|
||||||
this.entityManager.merge(item);
|
this.entityManager.merge(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,22 +118,22 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull DefinitionEntity buildDefinitionEntity(ViewStyleModel persist, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities) throws URISyntaxException {
|
private @NotNull DefinitionEntity buildDefinitionEntity(ViewStyleModel persist, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException {
|
||||||
DefinitionEntity data = new DefinitionEntity();
|
DefinitionEntity data = new DefinitionEntity();
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getPages())) {
|
if (!this.conventionService.isListNullOrEmpty(persist.getPages())) {
|
||||||
Map<String, List<Section>> sectionPerPage = mapSectionsToPage(persist);
|
Map<String, List<Section>> sectionPerPage = mapSectionsToPage(persist, descriptionTemplateId);
|
||||||
data.setPages(new ArrayList<>());
|
data.setPages(new ArrayList<>());
|
||||||
for (Page pagePersist : persist.getPages()) {
|
for (Page pagePersist : persist.getPages()) {
|
||||||
data.getPages().add(this.buildPageEntity(pagePersist, sectionPerPage.get(pagePersist.getId().trim()), referenceTypeEntityMap, knownReferenceEntities));
|
data.getPages().add(this.buildPageEntity(pagePersist, sectionPerPage.get(pagePersist.getId().trim()), referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull SectionEntity buildSectionEntity(Section persist, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities) throws URISyntaxException {
|
private @NotNull SectionEntity buildSectionEntity(Section persist, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException {
|
||||||
SectionEntity data = new SectionEntity();
|
SectionEntity data = new SectionEntity();
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
@ -147,21 +147,21 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(persist.getSections())) {
|
||||||
data.setSections(new ArrayList<>());
|
data.setSections(new ArrayList<>());
|
||||||
for (Section sectionPersist : persist.getSections()) {
|
for (Section sectionPersist : persist.getSections()) {
|
||||||
data.getSections().add(this.buildSectionEntity(sectionPersist, referenceTypeEntityMap, knownReferenceEntities));
|
data.getSections().add(this.buildSectionEntity(sectionPersist, referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getFieldSets())) {
|
if (!this.conventionService.isListNullOrEmpty(persist.getFieldSets())) {
|
||||||
data.setFieldSets(new ArrayList<>());
|
data.setFieldSets(new ArrayList<>());
|
||||||
for (FieldSet fieldSetPersist : persist.getFieldSets()) {
|
for (FieldSet fieldSetPersist : persist.getFieldSets()) {
|
||||||
data.getFieldSets().add(this.buildFieldSetEntity(fieldSetPersist, referenceTypeEntityMap, knownReferenceEntities));
|
data.getFieldSets().add(this.buildFieldSetEntity(fieldSetPersist, referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull FieldSetEntity buildFieldSetEntity(FieldSet persist, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities) throws URISyntaxException {
|
private @NotNull FieldSetEntity buildFieldSetEntity(FieldSet persist, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException {
|
||||||
FieldSetEntity data = new FieldSetEntity();
|
FieldSetEntity data = new FieldSetEntity();
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
@ -180,13 +180,13 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
|
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
|
||||||
data.setFields(new ArrayList<>());
|
data.setFields(new ArrayList<>());
|
||||||
for (Field fieldPersist : persist.getFields()) {
|
for (Field fieldPersist : persist.getFields()) {
|
||||||
data.getFields().add(this.buildFieldEntity(fieldPersist, referenceTypeEntityMap, knownReferenceEntities));
|
data.getFields().add(this.buildFieldEntity(fieldPersist, referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull FieldEntity buildFieldEntity(Field persist, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities) throws URISyntaxException {
|
private @NotNull FieldEntity buildFieldEntity(Field persist, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException {
|
||||||
FieldEntity data = new FieldEntity();
|
FieldEntity data = new FieldEntity();
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
@ -230,7 +230,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persist.getDefaultValue() != null) data.setDefaultValue(this.buildDefaultValueEntity(persist.getDefaultValue(), data.getData().getFieldType()));
|
if (persist.getDefaultValue() != null) data.setDefaultValue(this.buildDefaultValueEntity(persist.getDefaultValue(), data.getData().getFieldType(), descriptionTemplateId));
|
||||||
if (persist.getVisible() != null && !this.conventionService.isListNullOrEmpty(persist.getVisible().getRules())) {
|
if (persist.getVisible() != null && !this.conventionService.isListNullOrEmpty(persist.getVisible().getRules())) {
|
||||||
data.setVisibilityRules(new ArrayList<>());
|
data.setVisibilityRules(new ArrayList<>());
|
||||||
for (Rule fieldPersist : persist.getVisible().getRules()) {
|
for (Rule fieldPersist : persist.getVisible().getRules()) {
|
||||||
|
@ -402,7 +402,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull DefaultValueEntity buildDefaultValueEntity(DefaultValue persist, FieldType fieldType) {
|
private @NotNull DefaultValueEntity buildDefaultValueEntity(DefaultValue persist, FieldType fieldType, UUID descriptionTemplateId) {
|
||||||
DefaultValueEntity data = new DefaultValueEntity();
|
DefaultValueEntity data = new DefaultValueEntity();
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
@ -439,9 +439,9 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
case UPLOAD -> throw new NotSupportedException("Upload validator not supported");
|
case UPLOAD -> throw new NotSupportedException("Upload validator not supported");
|
||||||
case TAGS -> throw new NotSupportedException("Tags validator not supported");
|
case TAGS -> throw new NotSupportedException("Tags validator not supported");
|
||||||
|
|
||||||
case INTERNAL_ENTRIES_DMPS -> throw new NotSupportedException("INTERNAL_ENTRIES_DMPS validator not supported");
|
case INTERNAL_ENTRIES_DMPS -> throw new NotSupportedException("INTERNAL_ENTRIES_DMPS validator not supported for description template " + descriptionTemplateId);
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new NotSupportedException("INTERNAL_ENTRIES_DESCRIPTIONS validator not supported");
|
case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new NotSupportedException("INTERNAL_ENTRIES_DESCRIPTIONS validator not supported for description template " + descriptionTemplateId);
|
||||||
case REFERENCE_TYPES -> throw new NotSupportedException("REFERENCE_TYPES validator not supported");
|
case REFERENCE_TYPES -> throw new NotSupportedException("REFERENCE_TYPES validator not supported for description template " + descriptionTemplateId);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + fieldType);
|
default -> throw new MyApplicationException("unrecognized type " + fieldType);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -514,7 +514,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private @NotNull PageEntity buildPageEntity(Page persist, List<Section> sections, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities) throws URISyntaxException {
|
private @NotNull PageEntity buildPageEntity(Page persist, List<Section> sections, Map<String, ReferenceTypeEntity> referenceTypeEntityMap, Map<UUID, ReferenceTypeEntity> knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException {
|
||||||
PageEntity data = new PageEntity();
|
PageEntity data = new PageEntity();
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
@ -526,14 +526,14 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (!this.conventionService.isListNullOrEmpty(sections)) {
|
if (!this.conventionService.isListNullOrEmpty(sections)) {
|
||||||
data.setSections(new ArrayList<>());
|
data.setSections(new ArrayList<>());
|
||||||
for (Section sectionPersist : sections) {
|
for (Section sectionPersist : sections) {
|
||||||
data.getSections().add(this.buildSectionEntity(sectionPersist, referenceTypeEntityMap, knownReferenceEntities));
|
data.getSections().add(this.buildSectionEntity(sectionPersist, referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, List<Section>> mapSectionsToPage(ViewStyleModel persist){
|
private Map<String, List<Section>> mapSectionsToPage(ViewStyleModel persist, UUID descriptionTemplateId){
|
||||||
List<String> mappedSectionsIds = new ArrayList<>();
|
List<String> mappedSectionsIds = new ArrayList<>();
|
||||||
Map<String, List<Section>> sectionPerPage = new HashMap<>();
|
Map<String, List<Section>> sectionPerPage = new HashMap<>();
|
||||||
if (persist == null || persist.getPages() == null || persist.getSections() == null) return sectionPerPage;
|
if (persist == null || persist.getPages() == null || persist.getSections() == null) return sectionPerPage;
|
||||||
|
@ -550,7 +550,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Section section : persist.getSections()){
|
for (Section section : persist.getSections()){
|
||||||
if (!mappedSectionsIds.contains(section.getId().trim())) throw new MyApplicationException("Orphan section found " + section.getId().trim());
|
if (!mappedSectionsIds.contains(section.getId().trim())) throw new MyApplicationException("Orphan section found " + section.getId().trim() + " for description template " + descriptionTemplateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sectionPerPage;
|
return sectionPerPage;
|
||||||
|
@ -664,12 +664,12 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
String source = persist.getAutoCompleteOptions() != null ? persist.getAutoCompleteOptions().getSource() : null;
|
String source = persist.getAutoCompleteOptions() != null ? persist.getAutoCompleteOptions().getSource() : null;
|
||||||
|
|
||||||
if ( source == null || source.isEmpty()) {
|
if ( source == null || source.isEmpty()) {
|
||||||
URI uri;
|
URI uri;
|
||||||
if (persist.getUrl().contains("?")) {
|
if (persist.getUrl().contains("?")) {
|
||||||
uri = new URI(persist.getUrl().substring(0, persist.getUrl().trim().lastIndexOf("?")));
|
uri = new URI(persist.getUrl().substring(0, persist.getUrl().trim().lastIndexOf("?")));
|
||||||
} else {
|
} else {
|
||||||
uri = new URI(persist.getUrl().trim());
|
uri = new URI(persist.getUrl().trim());
|
||||||
}
|
}
|
||||||
source = uri.getHost();
|
source = uri.getHost();
|
||||||
}
|
}
|
||||||
String parsedUrl = persist.getUrl().trim();
|
String parsedUrl = persist.getUrl().trim();
|
||||||
|
|
|
@ -39,6 +39,9 @@ import org.xml.sax.SAXException;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -105,7 +108,7 @@ public class DmpMigrationService {
|
||||||
|
|
||||||
for (DMP item : items) {
|
for (DMP item : items) {
|
||||||
//entityManager.detach(item);
|
//entityManager.detach(item);
|
||||||
org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definitionEntity = blueprintDefinitionMap.get(item.getId());
|
org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definitionEntity = blueprintDefinitionMap.get(item.getProfile().getId());
|
||||||
DataManagementPlan model = new DataManagementPlan();
|
DataManagementPlan model = new DataManagementPlan();
|
||||||
model.fromDataModel(item);
|
model.fromDataModel(item);
|
||||||
List<DMP> itemGroupDmps = groupDmpMap.get(item.getGroupId());
|
List<DMP> itemGroupDmps = groupDmpMap.get(item.getGroupId());
|
||||||
|
@ -180,10 +183,16 @@ public class DmpMigrationService {
|
||||||
DmpBlueprintValueEntity valueEntity = new DmpBlueprintValueEntity();
|
DmpBlueprintValueEntity valueEntity = new DmpBlueprintValueEntity();
|
||||||
valueEntity.setFieldId(UUID.fromString(key));
|
valueEntity.setFieldId(UUID.fromString(key));
|
||||||
org.opencdmp.commons.types.dmpblueprint.FieldEntity fieldEntity = this.getFieldOfId(definitionEntity, valueEntity.getFieldId());
|
org.opencdmp.commons.types.dmpblueprint.FieldEntity fieldEntity = this.getFieldOfId(definitionEntity, valueEntity.getFieldId());
|
||||||
if (fieldEntity != null && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)){
|
if (fieldEntity != null && val != null && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)){
|
||||||
ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity;
|
ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity;
|
||||||
switch (extraFieldEntity.getType()){
|
switch (extraFieldEntity.getType()){
|
||||||
case Date -> valueEntity.setDateValue(Instant.parse((String) val));
|
case Date -> {
|
||||||
|
try {
|
||||||
|
valueEntity.setDateValue(Instant.parse((String) val));
|
||||||
|
} catch (DateTimeParseException ex) {
|
||||||
|
valueEntity.setDateValue(LocalDate.parse((String) val).atStartOfDay().toInstant(ZoneOffset.UTC));
|
||||||
|
}
|
||||||
|
}
|
||||||
case RichTex, Text -> valueEntity.setValue((String) val);
|
case RichTex, Text -> valueEntity.setValue((String) val);
|
||||||
case Number -> valueEntity.setNumberValue(Double.parseDouble((String) val));
|
case Number -> valueEntity.setNumberValue(Double.parseDouble((String) val));
|
||||||
default -> throw new MyApplicationException("unrecognized type " + extraFieldEntity.getType().getValue());
|
default -> throw new MyApplicationException("unrecognized type " + extraFieldEntity.getType().getValue());
|
||||||
|
|
Loading…
Reference in New Issue