use dmp label in export file names if grant does not exist

This commit is contained in:
Bernaldo Mihasi 2023-09-22 09:29:51 +03:00
parent 9cc42c57e9
commit fbad63ee76
1 changed files with 20 additions and 3 deletions

View File

@ -1633,7 +1633,13 @@ public class DataManagementPlanManager {
wordBuilder.fillFooter(dmpEntity, null, document, false); wordBuilder.fillFooter(dmpEntity, null, document, false);
String fileName = "DMP_" + dmpEntity.getGrant().getLabel(); String fileName;
if (dmpEntity.getGrant() != null && dmpEntity.getGrant().getLabel() != null) {
fileName = "DMP_" + dmpEntity.getGrant().getLabel();
}
else {
fileName = "DMP_" + dmpEntity.getLabel();
}
if (versioned) { if (versioned) {
fileName += "_" + dmpEntity.getVersion(); fileName += "_" + dmpEntity.getVersion();
} }
@ -1882,7 +1888,12 @@ public class DataManagementPlanManager {
writer.close(); writer.close();
FileEnvelope fileEnvelope = new FileEnvelope(); FileEnvelope fileEnvelope = new FileEnvelope();
fileEnvelope.setFile(xmlFile); fileEnvelope.setFile(xmlFile);
if (dmp.getGrant() != null && dmp.getGrant().getLabel() != null) {
fileEnvelope.setFilename("DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion() + ".xml"); fileEnvelope.setFilename("DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion() + ".xml");
}
else {
fileEnvelope.setFilename("DMP_" + dmp.getLabel() + "_" + dmp.getVersion() + ".xml");
}
return fileEnvelope; return fileEnvelope;
} }
@ -1900,7 +1911,13 @@ public class DataManagementPlanManager {
.collect(Collectors.toSet())); .collect(Collectors.toSet()));
String result = rdaManager.convertToRDA(dmp); String result = rdaManager.convertToRDA(dmp);
String fileName = "DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion(); String fileName;
if (dmp.getGrant() != null && dmp.getGrant().getLabel() != null) {
fileName = "DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion();
}
else {
fileName = "DMP_" + dmp.getLabel() + "_" + dmp.getVersion();
}
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "").replace(" ", "_").replace(",", "_"); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "").replace(" ", "_").replace(",", "_");
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
File file = new File(this.environment.getProperty("temp.temp") + uuid + ".json"); File file = new File(this.environment.getProperty("temp.temp") + uuid + ".json");