fix issues in dmp xml export

This commit is contained in:
Bernaldo Mihasi 2023-03-27 15:21:12 +03:00
parent 376bb2ca53
commit a90f21b6aa
2 changed files with 71 additions and 4 deletions

View File

@ -1453,6 +1453,40 @@ public class DataManagementPlanManager {
}
dmpElement.appendChild(dmpProfileElement);
Element dmpContactElement = xmlDoc.createElement("contact");
Element dmpContactName = xmlDoc.createElement("name");
Element dmpContactEmail = xmlDoc.createElement("email");
if(dmp.getCreator() != null){
dmpContactName.setTextContent(dmp.getCreator().getName());
dmpContactEmail.setTextContent(dmp.getCreator().getEmail());
}
else{
Iterator<UserDMP> users = dmp.getUsers().iterator();
if(users.hasNext()){
UserDMP creator = users.next();
dmpContactName.setTextContent(creator.getUser().getName());
dmpContactEmail.setTextContent(creator.getUser().getEmail());
}
}
dmpContactElement.appendChild(dmpContactName);
dmpContactElement.appendChild(dmpContactEmail);
dmpElement.appendChild(dmpContactElement);
Element dmpContributorsElement = xmlDoc.createElement("contributors");
Iterator<UserDMP> users = dmp.getUsers().iterator();
while(users.hasNext()){
Element dmpContributorElement = xmlDoc.createElement("contributor");
Element dmpContributorName = xmlDoc.createElement("name");
Element dmpContributorEmail= xmlDoc.createElement("email");
UserDMP contributor = users.next();
dmpContributorName.setTextContent(contributor.getUser().getName());
dmpContributorEmail.setTextContent(contributor.getUser().getEmail());
dmpContributorElement.appendChild(dmpContributorName);
dmpContributorElement.appendChild(dmpContributorEmail);
dmpContributorsElement.appendChild(dmpContributorElement);
}
dmpElement.appendChild(dmpContributorsElement);
// Funder.
Element funder = xmlDoc.createElement("funder");
Element funderLabel = xmlDoc.createElement("label");
@ -1461,6 +1495,13 @@ public class DataManagementPlanManager {
funderId.setTextContent(dmp.getGrant().getFunder().getId().toString());
funder.appendChild(funderLabel);
funder.appendChild(funderId);
if(dmp.getGrant().getFunder().getReference() != null){
String referencePrefix = dmp.getGrant().getFunder().getReference().split(":")[0];
String shortReference = dmp.getGrant().getFunder().getReference().substring(referencePrefix.length() + 1);
Element funderReference = xmlDoc.createElement("reference");
funderReference.setTextContent(shortReference);
funder.appendChild(funderReference);
}
dmpElement.appendChild(funder);
// Grant.
Element grant = xmlDoc.createElement("grant");
@ -1470,15 +1511,31 @@ public class DataManagementPlanManager {
grantId.setTextContent(dmp.getGrant().getId().toString());
grant.appendChild(grantLabel);
grant.appendChild(grantId);
if(dmp.getGrant().getReference() != null) {
String referencePrefix = dmp.getGrant().getReference().split(":")[0];
String shortReference = dmp.getGrant().getReference().substring(referencePrefix.length() + 1);
Element grantReference = xmlDoc.createElement("reference");
grantReference.setTextContent(shortReference);
grant.appendChild(grantReference);
}
dmpElement.appendChild(grant);
// Project.
Element project = xmlDoc.createElement("project");
Element projectLabel = xmlDoc.createElement("label");
Element projectId = xmlDoc.createElement("id");
projectLabel.setTextContent(dmp.getProject().getLabel());
Element projectLabel = xmlDoc.createElement("label");
Element projectDescription = xmlDoc.createElement("description");
Element projectStartDate = xmlDoc.createElement("start");
Element projectEndDate = xmlDoc.createElement("end");
projectId.setTextContent(dmp.getProject().getId().toString());
project.appendChild(projectLabel);
projectLabel.setTextContent(dmp.getProject().getLabel());
projectDescription.setTextContent(dmp.getProject().getDescription());
projectStartDate.setTextContent(dmp.getProject().getStartdate().toString());
projectEndDate.setTextContent(dmp.getProject().getEnddate().toString());
project.appendChild(projectId);
project.appendChild(projectLabel);
project.appendChild(projectDescription);
project.appendChild(projectStartDate);
project.appendChild(projectEndDate);
dmpElement.appendChild(project);
Element organisationsElement = xmlDoc.createElement("organisations");
@ -1510,8 +1567,13 @@ public class DataManagementPlanManager {
for (Dataset dataset : datasets) {
Element datasetElement = xmlDoc.createElement("dataset");
Element datsetProfileElement = xmlDoc.createElement("profile");
datasetElement.setAttribute("name", dataset.getLabel());
Element datasetDescriptionElement = xmlDoc.createElement("description");
datasetElement.appendChild(datasetDescriptionElement);
datasetDescriptionElement.setTextContent(dataset.getDescription());
Element datsetProfileElement = xmlDoc.createElement("profile");
datasetElement.appendChild(datsetProfileElement);
datsetProfileElement.setTextContent(dataset.getProfile().getId().toString());

View File

@ -86,6 +86,11 @@ public class ExportXmlBuilder {
composite.appendChild(title);
}
composite.appendChild(createFields(compositeField.getFields(), visibilityRuleService, element));
if(compositeField.getHasCommentField()){
Element comment = element.createElement("comment");
comment.setTextContent(compositeField.getCommentFieldValue());
composite.appendChild(comment);
}
elementComposites.appendChild(composite);
}