|
|
|
@ -1476,7 +1476,7 @@ public class DataManagementPlanManager {
|
|
|
|
|
* Data Import
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
public List<DmpImportModel> createDmpFromXml(ApiContext apiContext, MultipartFile[] files, Principal principal) throws IOException, JAXBException, Exception {
|
|
|
|
|
public List<DmpImportModel> createDmpFromXml(MultipartFile[] files, Principal principal, String[] profiles) throws IOException, JAXBException, Exception {
|
|
|
|
|
List<DmpImportModel> dataManagementPlans = new ArrayList<>();
|
|
|
|
|
// Jaxb approach.
|
|
|
|
|
JAXBContext jaxbContext;
|
|
|
|
@ -1532,16 +1532,26 @@ public class DataManagementPlanManager {
|
|
|
|
|
projectEditor.setExistProject(project);
|
|
|
|
|
|
|
|
|
|
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
|
|
|
|
|
if (profiles != null && profiles.length > 0) {
|
|
|
|
|
for (String profile : profiles) {
|
|
|
|
|
DatasetProfile 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()) {
|
|
|
|
|
AssociatedProfile associatedProfile = new AssociatedProfile();
|
|
|
|
|
associatedProfile.setId(a.getId());
|
|
|
|
|
associatedProfile.setLabel(a.getLabel());
|
|
|
|
|
associatedProfiles.add(associatedProfile);
|
|
|
|
|
try {
|
|
|
|
|
DatasetProfile exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(a.getId());
|
|
|
|
|
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
|
|
|
|
|
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();
|
|
|
|
|
organisation.setLabel(org.getOrganaisationNameImport());
|
|
|
|
|
organisation.setName(org.getOrganaisationNameImport());
|
|
|
|
|
organisation.setReference(org.getOrganaisationReferenceImport());
|
|
|
|
|
organisation.setKey(organisation.getReference().split(":")[0]);
|
|
|
|
|
organisations.add(organisation);
|
|
|
|
@ -1593,7 +1603,11 @@ 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.setProfile(databaseRepository.getDatasetProfileDao().find(das.getProfile()));
|
|
|
|
|
try {
|
|
|
|
|
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(das.getProfile()));
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(associatedProfiles.get(0).getId()));
|
|
|
|
|
}
|
|
|
|
|
dataset.setProperties(new ObjectMapper().writeValueAsString(das.getFieldImportModels()));
|
|
|
|
|
dataset.setStatus((short) 0);
|
|
|
|
|
dataset.setRegistries(new HashSet<>());
|
|
|
|
@ -1972,6 +1986,9 @@ public class DataManagementPlanManager {
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
dataBuilder.append("],\n");
|
|
|
|
|
if (dmp.getGrant().getReference() == null) {
|
|
|
|
|
dmp.getGrant().setReference("dmp:" + dmp.getGrant().getId());
|
|
|
|
|
}
|
|
|
|
|
String grantReferenceHead = dmp.getGrant().getReference().split(":")[0];
|
|
|
|
|
if (grantReferenceHead.equals("openaire")) {
|
|
|
|
|
String grantReferenceTail = dmp.getGrant().getReference().split(":")[3];
|
|
|
|
@ -1980,6 +1997,7 @@ public class DataManagementPlanManager {
|
|
|
|
|
dataBuilder.append(" \"grants\": [{\n");
|
|
|
|
|
dataBuilder.append(" \t\t\"id\": \"").append(finalId).append("\"\n}],\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dataBuilder.append(" \"creators\": [{\n");
|
|
|
|
|
dataBuilder.append(" \t\t\"name\": \"").append(dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser().getName()).append("\",\n");
|
|
|
|
|
if (dmp.getOrganisations() != null && !dmp.getOrganisations().isEmpty()) {
|
|
|
|
|