Change the filename of the exported DMP (also affects DOI generation) (ref #288)

This commit is contained in:
George Kalampokis 2020-09-03 18:08:53 +03:00
parent b12261b50b
commit 072a1c8a18
1 changed files with 5 additions and 7 deletions

View File

@ -973,7 +973,7 @@ public class DataManagementPlanManager {
* */ * */
public FileEnvelope getWordDocument(String id, Principal principal, ConfigLoader configLoader) throws IOException { public FileEnvelope getWordDocument(String id, Principal principal, ConfigLoader configLoader) throws IOException {
return this.getWordDocument(id, principal, configLoader, false); return this.getWordDocument(id, principal, configLoader, true);
} }
public FileEnvelope getWordDocument(String id, Principal principal, ConfigLoader configLoader, Boolean versioned) throws IOException { public FileEnvelope getWordDocument(String id, Principal principal, ConfigLoader configLoader, Boolean versioned) throws IOException {
@ -1122,11 +1122,9 @@ public class DataManagementPlanManager {
document.removeBodyElement(0); document.removeBodyElement(0);
} }
String fileName = ""; String fileName = "DMP_" + dmpEntity.getGrant().getLabel();
if (versioned) { if (versioned) {
fileName = dmpEntity.getLabel() + " v" + dmpEntity.getVersion(); fileName += "_" + dmpEntity.getVersion();
} else {
fileName = dmpEntity.getLabel();
} }
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");
FileEnvelope exportEnvelope = new FileEnvelope(); FileEnvelope exportEnvelope = new FileEnvelope();
@ -1272,7 +1270,7 @@ public class DataManagementPlanManager {
writer.close(); writer.close();
FileEnvelope fileEnvelope = new FileEnvelope(); FileEnvelope fileEnvelope = new FileEnvelope();
fileEnvelope.setFile(xmlFile); fileEnvelope.setFile(xmlFile);
fileEnvelope.setFilename(dmp.getLabel() + ".xml"); fileEnvelope.setFilename("DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion() + ".xml");
return fileEnvelope; return fileEnvelope;
} }
@ -1286,7 +1284,7 @@ public class DataManagementPlanManager {
/*ObjectMapper mapper = new ObjectMapper(); /*ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);*/ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);*/
String fileName = dmp.getLabel(); String fileName = "DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion();//dmp.getLabel();
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");
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");