dmp changes

This commit is contained in:
Efstratios Giannopoulos 2023-11-21 14:26:14 +02:00
parent f92b0c238a
commit 8536d8d03a
5 changed files with 103 additions and 30 deletions

View File

@ -0,0 +1,25 @@
package eu.eudat.commons.types.dmp;
public class DmpBlueprintValueEntity {
private String fieldId;
private String value;
public String getFieldId() {
return fieldId;
}
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -1,6 +1,6 @@
package eu.eudat.model.persist.dmpproperties; package eu.eudat.commons.types.dmp;
public class DmpContact { public class DmpContactEntity {
String userId; String userId;

View File

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

View File

@ -1,25 +0,0 @@
package eu.eudat.model.persist.dmpproperties;
public class DmpBlueprintValue {
private String fieldId;
private String fieldValue;
public String getFieldId() {
return fieldId;
}
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
}

View File

@ -7,6 +7,9 @@ import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.*; import eu.eudat.commons.enums.*;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.dmp.DmpBlueprintValueEntity;
import eu.eudat.commons.types.dmp.DmpContactEntity;
import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
import eu.eudat.commons.types.reference.DefinitionEntity; import eu.eudat.commons.types.reference.DefinitionEntity;
import eu.eudat.commons.types.reference.FieldEntity; import eu.eudat.commons.types.reference.FieldEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
@ -22,6 +25,9 @@ import eu.eudat.model.deleter.DmpDescriptionTemplateDeleter;
import eu.eudat.model.deleter.DmpReferenceDeleter; import eu.eudat.model.deleter.DmpReferenceDeleter;
import eu.eudat.model.deleter.DmpUserDeleter; import eu.eudat.model.deleter.DmpUserDeleter;
import eu.eudat.model.persist.*; import eu.eudat.model.persist.*;
import eu.eudat.model.persist.dmpproperties.DmpBlueprintValuePersist;
import eu.eudat.model.persist.dmpproperties.DmpContactPersist;
import eu.eudat.model.persist.dmpproperties.DmpPropertiesPersist;
import eu.eudat.model.persist.referencedefinition.DefinitionPersist; import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
import eu.eudat.model.persist.referencedefinition.FieldPersist; import eu.eudat.model.persist.referencedefinition.FieldPersist;
import eu.eudat.query.*; import eu.eudat.query.*;
@ -408,7 +414,7 @@ public class DmpServiceImpl implements DmpService {
} }
data.setLabel(model.getLabel()); data.setLabel(model.getLabel());
data.setProperties(this.jsonHandlingService.toJson(model.getProperties())); data.setProperties(this.jsonHandlingService.toJson(this.buildDmpPropertiesEntity(model.getProperties())));
data.setDescription(model.getDescription()); data.setDescription(model.getDescription());
data.setAccessType(model.getAccessType()); data.setAccessType(model.getAccessType());
data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());
@ -424,6 +430,46 @@ public class DmpServiceImpl implements DmpService {
return data; return data;
} }
private @NotNull DmpPropertiesEntity buildDmpPropertiesEntity(DmpPropertiesPersist persist){
DmpPropertiesEntity data = new DmpPropertiesEntity();
if (persist == null) return data;
if (!this.conventionService.isListNullOrEmpty(persist.getContacts())){
data.setContacts(new ArrayList<>());
for (DmpContactPersist contactPersist: persist.getContacts()) {
data.getContacts().add(this.buildDmpContactEntity(contactPersist));
}
}
if (!this.conventionService.isListNullOrEmpty(persist.getDmpBlueprintValues())){
data.setDmpBlueprintValues(new ArrayList<>());
for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues()) {
data.getDmpBlueprintValues().add(this.buildDmpBlueprintValueEntity(fieldValuePersist));
}
}
return data;
}
private @NotNull DmpContactEntity buildDmpContactEntity(DmpContactPersist persist){
DmpContactEntity data = new DmpContactEntity();
if (persist == null) return data;
data.setEmail(persist.getEmail());
data.setLastName(persist.getLastName());
data.setFirstName(persist.getFirstName());
data.setUserId(persist.getUserId());
return data;
}
private @NotNull DmpBlueprintValueEntity buildDmpBlueprintValueEntity(DmpBlueprintValuePersist persist){
DmpBlueprintValueEntity data = new DmpBlueprintValueEntity();
if (persist == null) return data;
data.setValue(persist.getFieldValue());
data.setFieldId(persist.getFieldId());
return data;
}
private void patchAndSaveReferences(List<DmpReferencePersist> models, UUID dmpId) throws InvalidApplicationException { private void patchAndSaveReferences(List<DmpReferencePersist> models, UUID dmpId) throws InvalidApplicationException {
if (models == null || models.isEmpty()) if (models == null || models.isEmpty())
return; return;
@ -532,14 +578,14 @@ public class DmpServiceImpl implements DmpService {
if (!this.conventionService.isListNullOrEmpty(persist.getFields())){ if (!this.conventionService.isListNullOrEmpty(persist.getFields())){
data.setFields(new ArrayList<>()); data.setFields(new ArrayList<>());
for (FieldPersist fieldPersist: persist.getFields()) { for (FieldPersist fieldPersist: persist.getFields()) {
data.getFields().add(this.buildFieldEntity(fieldPersist)); data.getFields().add(this.buildDmpContactEntity(fieldPersist));
} }
} }
return data; return data;
} }
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist){ private @NotNull FieldEntity buildDmpContactEntity(FieldPersist persist){
FieldEntity data = new FieldEntity(); FieldEntity data = new FieldEntity();
if (persist == null) return data; if (persist == null) return data;