|
|
|
@ -27,6 +27,7 @@ import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmp.DmpContactModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmp.DmpPropertiesModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmpblueprint.ExtraFieldModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmpblueprint.FieldModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmpblueprint.ReferenceTypeFieldModel;
|
|
|
|
@ -2070,50 +2071,46 @@ public class DmpServiceImpl implements DmpService {
|
|
|
|
|
persist.setLanguage(model.getLanguage());
|
|
|
|
|
persist.setUsers(this.commonModelToDmpUsersPersist(model));
|
|
|
|
|
persist.setBlueprint(this.commonModelDmpBlueprintToPersist(model));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
persist.setProperties(this.commonDmpPropertiesToPersist(model));
|
|
|
|
|
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(model.getDescriptionTemplates())) {
|
|
|
|
|
List<DmpDescriptionTemplatePersist> descriptionTemplates = new ArrayList<>();
|
|
|
|
|
for (DmpDescriptionTemplateModel descriptionTemplate : model.getDescriptionTemplates()) {
|
|
|
|
|
descriptionTemplates.add(this.commonDmpDescriptionTemplateToPersist(descriptionTemplate));
|
|
|
|
|
}
|
|
|
|
|
persist.setDescriptionTemplates(descriptionTemplates);
|
|
|
|
|
}
|
|
|
|
|
persist.setDescriptionTemplates(this.commonModelDmpDescriptionTemplatesToPersist(model)); //TODO maybe we should create templates if not exists
|
|
|
|
|
persist.setProperties(this.commonModelDmpPropertiesToPersist(model));
|
|
|
|
|
|
|
|
|
|
this.validatorFactory.validator(DmpPersist.DmpPersistValidator.class).validateForce(persist);
|
|
|
|
|
Dmp dmp = this.persist(persist, BaseFieldSet.build(fields, Dmp._id, Dmp._hash));
|
|
|
|
|
if (dmp == null) throw new MyApplicationException("Error creating dmp");
|
|
|
|
|
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())) {
|
|
|
|
|
List<DmpDescriptionTemplateEntity> dmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking()
|
|
|
|
|
.isActive(IsActive.Active)
|
|
|
|
|
.dmpIds(dmp.getId())
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){
|
|
|
|
|
for (DescriptionModel description: model.getDescriptions()){
|
|
|
|
|
this.descriptionService.importCommonModel(description, dmp.getId(), dmpDescriptionTemplates, fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Dmp._description)) : null);
|
|
|
|
|
this.descriptionService.importCommonModel(description, dmp.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Dmp._description)) : null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<DmpUserPersist> commonModelToDmpUsersPersist(DmpModel model){
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(model.getUsers())) {
|
|
|
|
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).disableTracking().ids(model.getUsers().stream().map(DmpUserModel::getUser).toList().stream().map(UserModel::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect();
|
|
|
|
|
List<UUID> userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<DmpUserPersist> dmpUsers = new ArrayList<>();
|
|
|
|
|
for (DmpUserModel user : model.getUsers()) {
|
|
|
|
|
dmpUsers.add(this.commonDmpUserToPersist(user, userIds));
|
|
|
|
|
private List<DmpDescriptionTemplatePersist> commonModelDmpDescriptionTemplatesToPersist(DmpModel commonModel){
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getDescriptionTemplates())) {
|
|
|
|
|
List<DmpDescriptionTemplatePersist> descriptionTemplates = new ArrayList<>();
|
|
|
|
|
for (DmpDescriptionTemplateModel descriptionTemplate : commonModel.getDescriptionTemplates()) {
|
|
|
|
|
descriptionTemplates.add(this.commonModelDmpDescriptionTemplateToPersist(descriptionTemplate));
|
|
|
|
|
}
|
|
|
|
|
return dmpUsers;
|
|
|
|
|
return descriptionTemplates.stream().filter(Objects::nonNull).toList();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DmpDescriptionTemplatePersist commonModelDmpDescriptionTemplateToPersist(DmpDescriptionTemplateModel commonModel) {
|
|
|
|
|
if (commonModel == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
DmpDescriptionTemplatePersist persist = new DmpDescriptionTemplatePersist();
|
|
|
|
|
|
|
|
|
|
persist.setDescriptionTemplateGroupId(commonModel.getDescriptionTemplateGroupId());
|
|
|
|
|
persist.setSectionId(commonModel.getSectionId());
|
|
|
|
|
|
|
|
|
|
return persist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private UUID commonModelDmpBlueprintToPersist(DmpModel dmpXml) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
|
|
|
|
|
if (dmpXml.getDmpBlueprint() != null){
|
|
|
|
|
DmpBlueprintEntity dmpBlueprintEntity = this.queryFactory.query(DmpBlueprintQuery.class).disableTracking().ids(dmpXml.getDmpBlueprint().getId()).first();
|
|
|
|
@ -2128,158 +2125,175 @@ public class DmpServiceImpl implements DmpService {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DmpPropertiesPersist commonDmpPropertiesToPersist(DmpModel model) {
|
|
|
|
|
if (model == null)
|
|
|
|
|
return null;
|
|
|
|
|
private DmpPropertiesPersist commonModelDmpPropertiesToPersist(DmpModel commonModel) {
|
|
|
|
|
if (commonModel == null || commonModel.getProperties() == null) return null;
|
|
|
|
|
|
|
|
|
|
DmpPropertiesPersist persist = new DmpPropertiesPersist();
|
|
|
|
|
persist.setContacts(this.commonModelToDmpContactPersist(commonModel.getProperties()));
|
|
|
|
|
persist.setDmpBlueprintValues(this.commonModelToDmpBlueprintValuePersist(commonModel));
|
|
|
|
|
|
|
|
|
|
List<DmpContactPersist> contacts = new ArrayList<>();
|
|
|
|
|
if (model.getProperties() != null && !this.conventionService.isListNullOrEmpty(model.getProperties().getContacts())) {
|
|
|
|
|
for (DmpContactModel contact : model.getProperties().getContacts()) {
|
|
|
|
|
contacts.add(this.commonDmpContactToPersist(contact));
|
|
|
|
|
return persist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<DmpContactPersist> commonModelToDmpContactPersist(DmpPropertiesModel commonModel){
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getContacts())) {
|
|
|
|
|
List<DmpContactPersist> contacts = new ArrayList<>();
|
|
|
|
|
for (DmpContactModel contact : commonModel.getContacts()) {
|
|
|
|
|
contacts.add(this.commonModelDmpContactToPersist(contact));
|
|
|
|
|
}
|
|
|
|
|
return contacts;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<UUID, DmpBlueprintValuePersist> dmpBlueprintValues = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
if (model.getDmpBlueprint() != null && model.getDmpBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(model.getDmpBlueprint().getDefinition().getSections())) {
|
|
|
|
|
List<SectionModel> sections = model.getDmpBlueprint().getDefinition().getSections();
|
|
|
|
|
private Map<UUID, DmpBlueprintValuePersist> commonModelToDmpBlueprintValuePersist(DmpModel commonModel){
|
|
|
|
|
if (commonModel.getDmpBlueprint() != null && commonModel.getDmpBlueprint().getDefinition() != null && !this.conventionService.isListNullOrEmpty(commonModel.getDmpBlueprint().getDefinition().getSections())) {
|
|
|
|
|
Map<UUID, DmpBlueprintValuePersist> dmpBlueprintValues = new HashMap<>();
|
|
|
|
|
List<SectionModel> sections = commonModel.getDmpBlueprint().getDefinition().getSections();
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(sections)){
|
|
|
|
|
for (SectionModel section : model.getDmpBlueprint().getDefinition().getSections()) {
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(section.getFields()) && !this.conventionService.isListNullOrEmpty(model.getReferences())){
|
|
|
|
|
for (SectionModel section : sections) {
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(section.getFields())){
|
|
|
|
|
for (FieldModel field : section.getFields()) {
|
|
|
|
|
// reference
|
|
|
|
|
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.ReferenceType)){
|
|
|
|
|
ReferenceTypeFieldModel referenceField = (ReferenceTypeFieldModel) field;
|
|
|
|
|
List<DmpReferenceModel> dmpReferencesByField = model.getReferences().stream().filter(x -> x.getData() != null && x.getData().getBlueprintFieldId().equals(referenceField.getId())).collect(Collectors.toList());
|
|
|
|
|
List<DmpReferenceModel> dmpReferencesByField = commonModel.getReferences().stream().filter(x -> x.getData() != null && x.getData().getBlueprintFieldId().equals(referenceField.getId())).collect(Collectors.toList());
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(dmpReferencesByField)){
|
|
|
|
|
dmpBlueprintValues.put(referenceField.getId(), this.commonDmpReferenceFieldToDmpBlueprintValuePersist(referenceField, dmpReferencesByField));
|
|
|
|
|
dmpBlueprintValues.put(referenceField.getId(), this.commonModelDmpReferenceFieldToDmpBlueprintValuePersist(referenceField, dmpReferencesByField));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// custom fields
|
|
|
|
|
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.Extra) && model.getProperties() != null && this.conventionService.isListNullOrEmpty(model.getProperties().getDmpBlueprintValues())){
|
|
|
|
|
DmpBlueprintValueModel dmpBlueprintValueModel = model.getProperties().getDmpBlueprintValues().stream().filter(x -> x.getFieldId().equals(field.getId())).findFirst().orElse(null);
|
|
|
|
|
if (field.getCategory().equals(org.opencdmp.commonmodels.enums.DmpBlueprintFieldCategory.Extra) && commonModel.getProperties() != null && this.conventionService.isListNullOrEmpty(commonModel.getProperties().getDmpBlueprintValues())){
|
|
|
|
|
DmpBlueprintValueModel dmpBlueprintValueModel = commonModel.getProperties().getDmpBlueprintValues().stream().filter(x -> x.getFieldId().equals(field.getId())).findFirst().orElse(null);
|
|
|
|
|
ExtraFieldModel extraFieldModel = (ExtraFieldModel) field;
|
|
|
|
|
if (dmpBlueprintValueModel != null) dmpBlueprintValues.put(dmpBlueprintValueModel.getFieldId(), this.commonDmpBlueprintValueToPersist(dmpBlueprintValueModel, extraFieldModel));
|
|
|
|
|
if (dmpBlueprintValueModel != null) dmpBlueprintValues.put(dmpBlueprintValueModel.getFieldId(), this.commonModelDmpBlueprintValueToPersist(dmpBlueprintValueModel, extraFieldModel));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dmpBlueprintValues;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
persist.setContacts(contacts);
|
|
|
|
|
persist.setDmpBlueprintValues(dmpBlueprintValues);
|
|
|
|
|
|
|
|
|
|
return persist;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DmpBlueprintValuePersist commonDmpReferenceFieldToDmpBlueprintValuePersist(ReferenceTypeFieldModel model, List<DmpReferenceModel> dmpReferences) {
|
|
|
|
|
if (model == null || this.conventionService.isListNullOrEmpty(dmpReferences))
|
|
|
|
|
private DmpBlueprintValuePersist commonModelDmpReferenceFieldToDmpBlueprintValuePersist(ReferenceTypeFieldModel model, List<DmpReferenceModel> dmpReferences) {
|
|
|
|
|
if (model == null || this.conventionService.isListNullOrEmpty(dmpReferences) || model.getReferenceType() == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
ReferenceTypeEntity referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).ids(model.getReferenceType().getId()).first();//TODO: optimize
|
|
|
|
|
if (referenceTypeEntity == null) referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).codes(model.getReferenceType().getCode()).first();
|
|
|
|
|
if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getReferenceType().getCode(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
|
|
|
|
|
|
DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist();
|
|
|
|
|
|
|
|
|
|
persist.setFieldId(model.getId());
|
|
|
|
|
if (model.getMultipleSelect()){
|
|
|
|
|
List<ReferencePersist> references = new ArrayList<>();
|
|
|
|
|
for (DmpReferenceModel dmpReference : dmpReferences) {
|
|
|
|
|
references.add(this.commonDmpReferenceToReferencePersist(dmpReference.getReference()));
|
|
|
|
|
references.add(this.commonDmpReferenceToReferencePersist(dmpReference.getReference(), referenceTypeEntity));
|
|
|
|
|
}
|
|
|
|
|
persist.setReferences(references);
|
|
|
|
|
} else {
|
|
|
|
|
persist.setReference(this.commonDmpReferenceToReferencePersist(dmpReferences.getFirst().getReference()));
|
|
|
|
|
persist.setReference(this.commonDmpReferenceToReferencePersist(dmpReferences.getFirst().getReference(), referenceTypeEntity));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return persist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ReferencePersist commonDmpReferenceToReferencePersist(ReferenceModel model) {
|
|
|
|
|
if (model == null)
|
|
|
|
|
return null;
|
|
|
|
|
private ReferencePersist commonDmpReferenceToReferencePersist(ReferenceModel model, ReferenceTypeEntity referenceTypeEntity) {
|
|
|
|
|
if (!referenceTypeEntity.getCode().equals(model.getType().getCode())) throw new MyApplicationException("Invalid reference for field " + model.getId());
|
|
|
|
|
|
|
|
|
|
if (this.conventionService.isNullOrEmpty(model.getLabel()) && this.conventionService.isNullOrEmpty(model.getReference())) throw new MyApplicationException("Dmp Reference without label and reference id ");
|
|
|
|
|
|
|
|
|
|
ReferenceEntity referenceEntity = this.queryFactory.query(ReferenceQuery.class).ids(model.getId()).first(); //TODO: optimize
|
|
|
|
|
if (referenceEntity == null) referenceEntity = this.queryFactory.query(ReferenceQuery.class).references(model.getReference()).typeIds(referenceTypeEntity.getId()).sources(model.getSource()).first();
|
|
|
|
|
|
|
|
|
|
ReferencePersist persist = new ReferencePersist();
|
|
|
|
|
|
|
|
|
|
persist.setId(model.getId());
|
|
|
|
|
persist.setLabel(model.getLabel());
|
|
|
|
|
persist.setDescription(model.getDescription());
|
|
|
|
|
persist.setReference(model.getReference());
|
|
|
|
|
persist.setAbbreviation(model.getAbbreviation());
|
|
|
|
|
persist.setSource(model.getSource());
|
|
|
|
|
switch (model.getSourceType()){
|
|
|
|
|
case Internal -> persist.setSourceType(ReferenceSourceType.Internal);
|
|
|
|
|
case External -> persist.setSourceType(ReferenceSourceType.External);
|
|
|
|
|
default -> throw new MyApplicationException("Unrecognized Type " + model.getSourceType().getValue());
|
|
|
|
|
persist.setTypeId(referenceTypeEntity.getId());
|
|
|
|
|
if (referenceEntity == null) {
|
|
|
|
|
persist.setLabel(model.getLabel());
|
|
|
|
|
persist.setReference(model.getReference());
|
|
|
|
|
persist.setSource("internal");
|
|
|
|
|
persist.setSourceType(ReferenceSourceType.Internal);
|
|
|
|
|
} else {
|
|
|
|
|
persist.setId(referenceEntity.getId());
|
|
|
|
|
persist.setLabel(referenceEntity.getLabel());
|
|
|
|
|
persist.setReference(referenceEntity.getReference());
|
|
|
|
|
persist.setSource(referenceEntity.getSource());
|
|
|
|
|
persist.setSourceType(referenceEntity.getSourceType());
|
|
|
|
|
persist.setAbbreviation(referenceEntity.getAbbreviation());
|
|
|
|
|
persist.setDescription(referenceEntity.getDescription());
|
|
|
|
|
persist.setHash(this.conventionService.hashValue(referenceEntity.getUpdatedAt()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return persist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DmpBlueprintValuePersist commonDmpBlueprintValueToPersist(DmpBlueprintValueModel model, ExtraFieldModel extraFieldModel) {
|
|
|
|
|
if (model == null || extraFieldModel == null)
|
|
|
|
|
private DmpBlueprintValuePersist commonModelDmpBlueprintValueToPersist(DmpBlueprintValueModel commonModel, ExtraFieldModel extraFieldModel) {
|
|
|
|
|
if (commonModel == null || extraFieldModel == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist();
|
|
|
|
|
|
|
|
|
|
persist.setFieldId(model.getFieldId());
|
|
|
|
|
if (extraFieldModel.getDataType().equals(org.opencdmp.commonmodels.enums.DmpBlueprintExtraFieldDataType.Date)){
|
|
|
|
|
persist.setDateValue(model.getDateValue());
|
|
|
|
|
} else if (extraFieldModel.getDataType().equals(org.opencdmp.commonmodels.enums.DmpBlueprintExtraFieldDataType.Number)){
|
|
|
|
|
persist.setNumberValue(model.getNumberValue());
|
|
|
|
|
} else {
|
|
|
|
|
persist.setFieldValue(model.getValue());
|
|
|
|
|
persist.setFieldId(commonModel.getFieldId());
|
|
|
|
|
switch (extraFieldModel.getDataType()){
|
|
|
|
|
case Date -> persist.setDateValue(commonModel.getDateValue());
|
|
|
|
|
case Number -> persist.setNumberValue(commonModel.getNumberValue());
|
|
|
|
|
case Text, RichTex -> persist.setFieldValue(commonModel.getValue());
|
|
|
|
|
default -> throw new MyApplicationException("unrecognized type " + extraFieldModel.getDataType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return persist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DmpDescriptionTemplatePersist commonDmpDescriptionTemplateToPersist(DmpDescriptionTemplateModel model) {
|
|
|
|
|
if (model == null)
|
|
|
|
|
return null;
|
|
|
|
|
private List<DmpUserPersist> commonModelToDmpUsersPersist(DmpModel commonModel){
|
|
|
|
|
if (!this.conventionService.isListNullOrEmpty(commonModel.getUsers())) {
|
|
|
|
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).disableTracking().ids(commonModel.getUsers().stream().map(DmpUserModel::getUser).filter(Objects::nonNull).map(UserModel::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect();
|
|
|
|
|
List<UUID> userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
DmpDescriptionTemplatePersist persist = new DmpDescriptionTemplatePersist();
|
|
|
|
|
|
|
|
|
|
persist.setDescriptionTemplateGroupId(model.getDescriptionTemplateGroupId());
|
|
|
|
|
persist.setSectionId(model.getSectionId());
|
|
|
|
|
|
|
|
|
|
return persist;
|
|
|
|
|
List<DmpUserPersist> dmpUsers = new ArrayList<>();
|
|
|
|
|
for (DmpUserModel user : commonModel.getUsers()) {
|
|
|
|
|
dmpUsers.add(this.commonModelDmpUserToPersist(user, userIds));
|
|
|
|
|
}
|
|
|
|
|
return dmpUsers;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DmpUserPersist commonDmpUserToPersist(DmpUserModel model, List<UUID> userIds) {
|
|
|
|
|
if (model == null)
|
|
|
|
|
|
|
|
|
|
private DmpUserPersist commonModelDmpUserToPersist(DmpUserModel commonModel, List<UUID> userIds) {
|
|
|
|
|
if (commonModel == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
if (model.getUser() != null && model.getUser().getId() != null && !userIds.isEmpty() && userIds.contains(model.getUser().getId())) {
|
|
|
|
|
if (commonModel.getUser() != null && commonModel.getUser().getId() != null && !userIds.isEmpty() && userIds.contains(commonModel.getUser().getId())) {
|
|
|
|
|
DmpUserPersist persist = new DmpUserPersist();
|
|
|
|
|
|
|
|
|
|
persist.setUser(model.getUser().getId());
|
|
|
|
|
persist.setUser(commonModel.getUser().getId());
|
|
|
|
|
|
|
|
|
|
switch (model.getRole()){
|
|
|
|
|
switch (commonModel.getRole()){
|
|
|
|
|
case Owner -> persist.setRole(DmpUserRole.Owner);
|
|
|
|
|
case Viewer -> persist.setRole(DmpUserRole.Viewer);
|
|
|
|
|
case DescriptionContributor -> persist.setRole(DmpUserRole.DescriptionContributor);
|
|
|
|
|
case Reviewer -> persist.setRole(DmpUserRole.Reviewer);
|
|
|
|
|
default -> throw new MyApplicationException("Unrecognized Type " + model.getRole().getValue());
|
|
|
|
|
default -> throw new MyApplicationException("Unrecognized Type " + commonModel.getRole().getValue());
|
|
|
|
|
}
|
|
|
|
|
persist.setSectionId(model.getSectionId());
|
|
|
|
|
persist.setSectionId(commonModel.getSectionId());
|
|
|
|
|
return persist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DmpContactPersist commonDmpContactToPersist(DmpContactModel model) {
|
|
|
|
|
if (model == null)
|
|
|
|
|
private DmpContactPersist commonModelDmpContactToPersist(DmpContactModel commonModel) {
|
|
|
|
|
if (commonModel == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
DmpContactPersist persist = new DmpContactPersist();
|
|
|
|
|
|
|
|
|
|
persist.setEmail(model.getEmail());
|
|
|
|
|
persist.setFirstName(model.getEmail());
|
|
|
|
|
persist.setLastName(model.getLastName());
|
|
|
|
|
persist.setEmail(commonModel.getEmail());
|
|
|
|
|
persist.setFirstName(commonModel.getEmail());
|
|
|
|
|
persist.setLastName(commonModel.getLastName());
|
|
|
|
|
|
|
|
|
|
return persist;
|
|
|
|
|
}
|
|
|
|
|