|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package eu.eudat.logic.managers;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
|
|
|
|
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
|
|
|
@ -1708,9 +1709,9 @@ public class DataManagementPlanManager {
|
|
|
|
|
Element dmpProfileId = xmlDoc.createElement("dmpProfileId");
|
|
|
|
|
dmpProfileId.setTextContent(dmpProfile.getId().toString());
|
|
|
|
|
dmpProfileElement.appendChild(dmpProfileId);
|
|
|
|
|
Element values = xmlDoc.createElement("values");
|
|
|
|
|
values.setTextContent(dmpProfile.getDefinition());
|
|
|
|
|
dmpProfileElement.appendChild(values);
|
|
|
|
|
// Element values = xmlDoc.createElement("values");
|
|
|
|
|
// values.setTextContent(dmpProfile.getDefinition());
|
|
|
|
|
// dmpProfileElement.appendChild(values);
|
|
|
|
|
}
|
|
|
|
|
dmpElement.appendChild(dmpProfileElement);
|
|
|
|
|
|
|
|
|
@ -1830,8 +1831,33 @@ public class DataManagementPlanManager {
|
|
|
|
|
researchersElement.appendChild(researcherElement);
|
|
|
|
|
}
|
|
|
|
|
dmpElement.appendChild(researchersElement);
|
|
|
|
|
Element datasetsElement = xmlDoc.createElement("datasets");
|
|
|
|
|
|
|
|
|
|
Element extraFields = xmlDoc.createElement("extraFields");
|
|
|
|
|
Map<String, Object> dmpProperties = new ObjectMapper().readValue(dmp.getProperties(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
DataManagementPlanBlueprint blueprint = this.dataManagementProfileManager.getSingleBlueprint(dmp.getProfile().getId().toString(), principal).getDefinition();
|
|
|
|
|
blueprint.getSections().forEach(section -> {
|
|
|
|
|
section.getFields().forEach(fieldModel -> {
|
|
|
|
|
if (fieldModel.getCategory() == FieldCategory.EXTRA) {
|
|
|
|
|
Element extraField = xmlDoc.createElement("extraField");
|
|
|
|
|
Element extraFieldId = xmlDoc.createElement("id");
|
|
|
|
|
extraFieldId.setTextContent(fieldModel.getId().toString());
|
|
|
|
|
Element extraFieldLabel = xmlDoc.createElement("label");
|
|
|
|
|
extraFieldLabel.setTextContent(fieldModel.getLabel());
|
|
|
|
|
Element extraFieldValue = xmlDoc.createElement("value");
|
|
|
|
|
Object value = dmpProperties.get(fieldModel.getId().toString());
|
|
|
|
|
if (value != null) {
|
|
|
|
|
extraFieldValue.setTextContent((String) value);
|
|
|
|
|
}
|
|
|
|
|
extraField.appendChild(extraFieldId);
|
|
|
|
|
extraField.appendChild(extraFieldLabel);
|
|
|
|
|
extraField.appendChild(extraFieldValue);
|
|
|
|
|
extraFields.appendChild(extraField);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
dmpElement.appendChild(extraFields);
|
|
|
|
|
|
|
|
|
|
Element datasetsElement = xmlDoc.createElement("datasets");
|
|
|
|
|
for (Dataset dataset : datasets) {
|
|
|
|
|
Element datasetElement = xmlDoc.createElement("dataset");
|
|
|
|
|
datasetElement.setAttribute("name", dataset.getLabel());
|
|
|
|
@ -1840,6 +1866,10 @@ public class DataManagementPlanManager {
|
|
|
|
|
datasetElement.appendChild(datasetDescriptionElement);
|
|
|
|
|
datasetDescriptionElement.setTextContent(dataset.getDescription());
|
|
|
|
|
|
|
|
|
|
Element datasetDmpSectionIndex = xmlDoc.createElement("dmpSectionIndex");
|
|
|
|
|
datasetElement.appendChild(datasetDmpSectionIndex);
|
|
|
|
|
datasetDmpSectionIndex.setTextContent(String.valueOf(dataset.getDmpSectionIndex()));
|
|
|
|
|
|
|
|
|
|
Element datsetProfileElement = xmlDoc.createElement("profile-id");
|
|
|
|
|
datasetElement.appendChild(datsetProfileElement);
|
|
|
|
|
datsetProfileElement.setTextContent(dataset.getProfile().getId().toString());
|
|
|
|
@ -1860,8 +1890,8 @@ public class DataManagementPlanManager {
|
|
|
|
|
datasetElement.appendChild(xmlBuilder.createPages(pagedDatasetProfile.getPages(), visibilityRuleService, xmlDoc));
|
|
|
|
|
datasetsElement.appendChild(datasetElement);
|
|
|
|
|
}
|
|
|
|
|
Element profiles = xmlDoc.createElement("profiles");
|
|
|
|
|
|
|
|
|
|
Element profiles = xmlDoc.createElement("profiles");
|
|
|
|
|
// Get DatasetProfiles from DMP to add to XML.
|
|
|
|
|
for (DMPDatasetProfile dmpDescriptionProfile : dmp.getAssociatedDmps()) {
|
|
|
|
|
DescriptionTemplate descriptionTemplate = dmpDescriptionProfile.getDatasetprofile();
|
|
|
|
@ -1878,6 +1908,15 @@ public class DataManagementPlanManager {
|
|
|
|
|
Element profileVersion = xmlDoc.createElement("profileVersion");
|
|
|
|
|
profileVersion.setTextContent(String.valueOf(descriptionTemplate.getVersion()));
|
|
|
|
|
profile.appendChild(profileVersion);
|
|
|
|
|
Element profileInSections = xmlDoc.createElement("profileInSections");
|
|
|
|
|
Map<String, Object> data = new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
List<Integer> sections = (List<Integer>) data.get("dmpSectionIndex");
|
|
|
|
|
for(int section: sections) {
|
|
|
|
|
Element profileInSection = xmlDoc.createElement("section");
|
|
|
|
|
profileInSection.setTextContent(String.valueOf(section));
|
|
|
|
|
profileInSections.appendChild(profileInSection);
|
|
|
|
|
}
|
|
|
|
|
profile.appendChild(profileInSections);
|
|
|
|
|
profiles.appendChild(profile);
|
|
|
|
|
}
|
|
|
|
|
dmpElement.appendChild(profiles);
|
|
|
|
@ -1988,59 +2027,85 @@ public class DataManagementPlanManager {
|
|
|
|
|
// Creates new dataManagementPlan to fill it with the data model that was parsed from the xml.
|
|
|
|
|
// Creates properties.
|
|
|
|
|
DataManagementPlanEditorModel dm = new DataManagementPlanEditorModel();
|
|
|
|
|
// DataManagementPlanProfile dmpProfile = new DataManagementPlanProfile();
|
|
|
|
|
//
|
|
|
|
|
// List<Field> fieldList = new LinkedList<>();
|
|
|
|
|
// Field field = new Field();
|
|
|
|
|
// field.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());
|
|
|
|
|
// field.setId(dataManagementPlans.get(0).getDmpProfile().getDmpProfileId());
|
|
|
|
|
//
|
|
|
|
|
// fieldList.add(field);
|
|
|
|
|
// dmpProfile.setFields(fieldList);
|
|
|
|
|
|
|
|
|
|
/*Tuple tuple = new Tuple();
|
|
|
|
|
tuple.setId(dataManagementPlans.get(0).getDmpProfile().getDmpProfileId());
|
|
|
|
|
tuple.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());*/
|
|
|
|
|
eu.eudat.models.data.funder.Funder funder = new eu.eudat.models.data.funder.Funder();
|
|
|
|
|
FunderImportModels funderImport = dataManagementPlans.get(0).getFunderImportModels();
|
|
|
|
|
funder.setId(funderImport.getId());
|
|
|
|
|
funder.setLabel(funderImport.getLabel());
|
|
|
|
|
FunderDMPEditorModel funderEditor = new FunderDMPEditorModel();
|
|
|
|
|
funderEditor.setExistFunder(funder);
|
|
|
|
|
DmpProfileImportModel dmpProfileImportModel = dataManagementPlans.get(0).getDmpProfile();
|
|
|
|
|
Tuple<UUID, String> tupleProfile = new Tuple<>();
|
|
|
|
|
if (dmpProfileImportModel != null) {
|
|
|
|
|
tupleProfile.setId(dmpProfileImportModel.getDmpProfileId());
|
|
|
|
|
tupleProfile.setLabel(dmpProfileImportModel.getDmpProfileName());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
tupleProfile.setId(UUID.fromString("86635178-36a6-484f-9057-a934e4eeecd5"));
|
|
|
|
|
tupleProfile.setLabel("Dmp Default Blueprint");
|
|
|
|
|
}
|
|
|
|
|
dm.setProfile(tupleProfile);
|
|
|
|
|
|
|
|
|
|
eu.eudat.models.data.grant.Grant grant = new eu.eudat.models.data.grant.Grant();
|
|
|
|
|
GrantImportModels grantImport = dataManagementPlans.get(0).getGrantImport();
|
|
|
|
|
grant.setId(grantImport.getId());
|
|
|
|
|
grant.setLabel(grantImport.getLabel());
|
|
|
|
|
grant.setAbbreviation(grantImport.getAbbreviation());
|
|
|
|
|
grant.setDescription(grantImport.getDescription());
|
|
|
|
|
GrantDMPEditorModel grantEditor = new GrantDMPEditorModel();
|
|
|
|
|
grantEditor.setExistGrant(grant);
|
|
|
|
|
|
|
|
|
|
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
|
|
|
|
ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImportModels();
|
|
|
|
|
project.setId(projectImport.getId());
|
|
|
|
|
project.setLabel(projectImport.getLabel());
|
|
|
|
|
ProjectDMPEditorModel projectEditor = new ProjectDMPEditorModel();
|
|
|
|
|
projectEditor.setExistProject(project);
|
|
|
|
|
|
|
|
|
|
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
|
|
|
|
|
if (profiles != null && profiles.length > 0) {
|
|
|
|
|
for (String profile : profiles) {
|
|
|
|
|
DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(profile));
|
|
|
|
|
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
|
|
|
|
|
associatedProfiles.add(associatedProfile);
|
|
|
|
|
Map<String, Object> dmpPropertiesMap = new HashMap<>();
|
|
|
|
|
if (dataManagementPlans.get(0).getExtraFieldsImportModels() != null) {
|
|
|
|
|
for (ExtraFieldsImportModels extraField: dataManagementPlans.get(0).getExtraFieldsImportModels()) {
|
|
|
|
|
dmpPropertiesMap.put(extraField.getId(), extraField.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dm.setProperties(dmpPropertiesMap);
|
|
|
|
|
|
|
|
|
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.FUNDER, principal)) {
|
|
|
|
|
eu.eudat.models.data.funder.Funder funder = new eu.eudat.models.data.funder.Funder();
|
|
|
|
|
FunderImportModels funderImport = dataManagementPlans.get(0).getFunderImportModels();
|
|
|
|
|
funder.setId(funderImport.getId());
|
|
|
|
|
funder.setLabel(funderImport.getLabel());
|
|
|
|
|
FunderDMPEditorModel funderEditor = new FunderDMPEditorModel();
|
|
|
|
|
funderEditor.setExistFunder(funder);
|
|
|
|
|
|
|
|
|
|
dm.setFunder(funderEditor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.GRANT, principal)) {
|
|
|
|
|
eu.eudat.models.data.grant.Grant grant = new eu.eudat.models.data.grant.Grant();
|
|
|
|
|
GrantImportModels grantImport = dataManagementPlans.get(0).getGrantImport();
|
|
|
|
|
grant.setId(grantImport.getId());
|
|
|
|
|
grant.setLabel(grantImport.getLabel());
|
|
|
|
|
grant.setAbbreviation(grantImport.getAbbreviation());
|
|
|
|
|
grant.setDescription(grantImport.getDescription());
|
|
|
|
|
GrantDMPEditorModel grantEditor = new GrantDMPEditorModel();
|
|
|
|
|
grantEditor.setExistGrant(grant);
|
|
|
|
|
|
|
|
|
|
dm.setGrant(grantEditor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.PROJECT, principal)) {
|
|
|
|
|
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
|
|
|
|
ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImportModels();
|
|
|
|
|
project.setId(projectImport.getId());
|
|
|
|
|
project.setLabel(projectImport.getLabel());
|
|
|
|
|
ProjectDMPEditorModel projectEditor = new ProjectDMPEditorModel();
|
|
|
|
|
projectEditor.setExistProject(project);
|
|
|
|
|
|
|
|
|
|
dm.setProject(projectEditor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
|
|
|
|
|
// if (profiles != null && profiles.length > 0) {
|
|
|
|
|
// for (String profile : profiles) {
|
|
|
|
|
// DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(profile));
|
|
|
|
|
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
|
|
|
|
|
// associatedProfiles.add(associatedProfile);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
for (AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) {
|
|
|
|
|
try {
|
|
|
|
|
DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(a.getId());
|
|
|
|
|
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
|
|
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
|
|
List<Integer> sections = new ArrayList<>(a.getSection());
|
|
|
|
|
data.put("dmpSectionIndex", sections);
|
|
|
|
|
associatedProfile.setData(data);
|
|
|
|
|
associatedProfiles.add(associatedProfile);
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<eu.eudat.models.data.dmp.Organisation> organisations = new ArrayList<>();
|
|
|
|
|
for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) {
|
|
|
|
|
eu.eudat.models.data.dmp.Organisation organisation = new eu.eudat.models.data.dmp.Organisation();
|
|
|
|
@ -2049,6 +2114,7 @@ public class DataManagementPlanManager {
|
|
|
|
|
organisation.setKey(organisation.getReference().split(":")[0]);
|
|
|
|
|
organisations.add(organisation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<eu.eudat.models.data.dmp.Researcher> researchers = new LinkedList<>();
|
|
|
|
|
for (ResearcherImportModels res : dataManagementPlans.get(0).getResearchersImportModels()) {
|
|
|
|
|
eu.eudat.models.data.dmp.Researcher researcher = new eu.eudat.models.data.dmp.Researcher();
|
|
|
|
@ -2064,9 +2130,6 @@ public class DataManagementPlanManager {
|
|
|
|
|
|
|
|
|
|
// Sets properties.
|
|
|
|
|
dm.setLabel(files[0].getOriginalFilename()); // Sets label.
|
|
|
|
|
dm.setGrant(grantEditor); //Sets grant property.
|
|
|
|
|
dm.setFunder(funderEditor);
|
|
|
|
|
dm.setProject(projectEditor);
|
|
|
|
|
dm.setDescription(dataManagementPlans.get(0).getDescriptionImport()); // Sets description property.
|
|
|
|
|
dm.setProfiles(associatedProfiles);
|
|
|
|
|
dm.setOrganisations(organisations); // Sets organisations property.
|
|
|
|
@ -2112,6 +2175,7 @@ public class DataManagementPlanManager {
|
|
|
|
|
for (DatasetImportModels das: dataManagementPlans.get(0).getDatasetImportModels()) {
|
|
|
|
|
eu.eudat.data.entities.Dataset dataset = new eu.eudat.data.entities.Dataset();
|
|
|
|
|
dataset.setLabel(das.getName());
|
|
|
|
|
dataset.setDmpSectionIndex(das.getDmpSectionIndex());
|
|
|
|
|
try {
|
|
|
|
|
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(das.getProfile()));
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|