rename dmp to plan
This commit is contained in:
parent
099e8707e3
commit
158764a974
|
@ -5,12 +5,12 @@ import gr.cite.tools.logging.EventId;
|
||||||
|
|
||||||
public class AuditableAction {
|
public class AuditableAction {
|
||||||
|
|
||||||
public static final EventId FileTransformer_ExportDmp = new EventId(1000, "FileTransformer_ExportDmp");
|
public static final EventId FileTransformer_ExportPlan = new EventId(1000, "FileTransformer_ExportPlan");
|
||||||
public static final EventId FileTransformer_ExportDescription = new EventId(1001, "FileTransformer_ExportDescription");
|
public static final EventId FileTransformer_ExportDescription = new EventId(1001, "FileTransformer_ExportDescription");
|
||||||
public static final EventId FileTransformer_ImportFileToDmp = new EventId(1002, "FileTransformer_ImportFileToDmp");
|
public static final EventId FileTransformer_ImportFileToPlan = new EventId(1002, "FileTransformer_ImportFileToPlan");
|
||||||
public static final EventId FileTransformer_ImportFileToDescription = new EventId(1003, "FileTransformer_ImportFileToDescription");
|
public static final EventId FileTransformer_ImportFileToDescription = new EventId(1003, "FileTransformer_ImportFileToDescription");
|
||||||
public static final EventId FileTransformer_GetSupportedFormats = new EventId(1004, "FileTransformer_GetSupportedFormats");
|
public static final EventId FileTransformer_GetSupportedFormats = new EventId(1004, "FileTransformer_GetSupportedFormats");
|
||||||
public static final EventId FileTransformer_PreprocessingDmp = new EventId(1005, "FileTransformer_PreprocessingDmp");
|
public static final EventId FileTransformer_PreprocessingPlan = new EventId(1005, "FileTransformer_PreprocessingPlan");
|
||||||
public static final EventId FileTransformer_PreprocessingDescription = new EventId(1006, "FileTransformer_PreprocessingDescription");
|
public static final EventId FileTransformer_PreprocessingDescription = new EventId(1006, "FileTransformer_PreprocessingDescription");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
package org.opencdmp.filetransformer.docx.service.wordfiletransformer;
|
package org.opencdmp.filetransformer.docx.service.wordfiletransformer;
|
||||||
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.commonmodels.enums.*;
|
import org.opencdmp.commonmodels.enums.*;
|
||||||
import org.opencdmp.commonmodels.models.UserContactInfoModel;
|
import org.opencdmp.commonmodels.models.plan.PlanBlueprintValueModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel;
|
import org.opencdmp.commonmodels.models.plan.PlanContactModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpContactModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
|
||||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||||
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpblueprint.*;
|
import org.opencdmp.commonmodels.models.planblueprint.*;
|
||||||
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
|
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
|
||||||
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
||||||
import org.opencdmp.filetransformerbase.enums.FileTransformerEntityType;
|
import org.opencdmp.filetransformerbase.enums.FileTransformerEntityType;
|
||||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
|
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
|
||||||
|
@ -29,9 +27,7 @@ import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.ResourceUtils;
|
import org.springframework.util.ResourceUtils;
|
||||||
|
@ -56,7 +52,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
new FileFormat(FileFormats.DOCX.getValue(), true, "fa-file-word-o"));
|
new FileFormat(FileFormats.DOCX.getValue(), true, "fa-file-word-o"));
|
||||||
|
|
||||||
private final static List<FileTransformerEntityType> FILE_TRANSFORMER_ENTITY_TYPES = List.of(
|
private final static List<FileTransformerEntityType> FILE_TRANSFORMER_ENTITY_TYPES = List.of(
|
||||||
FileTransformerEntityType.Dmp, FileTransformerEntityType.Description);
|
FileTransformerEntityType.Plan, FileTransformerEntityType.Description);
|
||||||
|
|
||||||
private final WordFileTransformerServiceProperties wordFileTransformerServiceProperties;
|
private final WordFileTransformerServiceProperties wordFileTransformerServiceProperties;
|
||||||
private final PdfService pdfService;
|
private final PdfService pdfService;
|
||||||
|
@ -75,14 +71,14 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileEnvelopeModel exportDmp(DmpModel dmp, String variant) throws IOException, InvalidApplicationException {
|
public FileEnvelopeModel exportPlan(PlanModel plan, String variant) throws IOException, InvalidApplicationException {
|
||||||
FileFormats fileFormat = FileFormats.of(variant);
|
FileFormats fileFormat = FileFormats.of(variant);
|
||||||
byte[] bytes = this.buildDmpWordDocument(dmp);
|
byte[] bytes = this.buildPlanWordDocument(plan);
|
||||||
String filename = switch (fileFormat) {
|
String filename = switch (fileFormat) {
|
||||||
case DOCX -> this.getDmpFileName(dmp, ".docx");
|
case DOCX -> this.getPlanFileName(plan, ".docx");
|
||||||
case PDF -> {
|
case PDF -> {
|
||||||
bytes = this.pdfService.convertToPDF(bytes);
|
bytes = this.pdfService.convertToPDF(bytes);
|
||||||
yield this.getDmpFileName(dmp, ".pdf");
|
yield this.getPlanFileName(plan, ".pdf");
|
||||||
}
|
}
|
||||||
default -> throw new MyApplicationException("Invalid type " + fileFormat);
|
default -> throw new MyApplicationException("Invalid type " + fileFormat);
|
||||||
};
|
};
|
||||||
|
@ -124,7 +120,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DmpModel importDmp(DmpImportModel dmpImportModel) {
|
public PlanModel importPlan(PlanImportModel planImportModel) {
|
||||||
throw new MyApplicationException("import not supported");
|
throw new MyApplicationException("import not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +141,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreprocessingDmpModel preprocessingDmp(FileEnvelopeModel fileEnvelopeModel) {
|
public PreprocessingPlanModel preprocessingPlan(FileEnvelopeModel fileEnvelopeModel) {
|
||||||
throw new MyApplicationException("preprocessing not supported");
|
throw new MyApplicationException("preprocessing not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,12 +150,12 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
throw new MyApplicationException("preprocessing not supported");
|
throw new MyApplicationException("preprocessing not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ReferenceModel> getReferenceModelOfTypeCode(DmpModel dmp, String code, UUID blueprintId){
|
private List<ReferenceModel> getReferenceModelOfTypeCode(PlanModel plan, String code, UUID blueprintId){
|
||||||
List<ReferenceModel> response = new ArrayList<>();
|
List<ReferenceModel> response = new ArrayList<>();
|
||||||
if (dmp.getReferences() == null) return response;
|
if (plan.getReferences() == null) return response;
|
||||||
for (DmpReferenceModel dmpReferenceModel : dmp.getReferences()){
|
for (PlanReferenceModel planReferenceModel : plan.getReferences()){
|
||||||
if (dmpReferenceModel.getReference() != null && dmpReferenceModel.getReference().getType() != null && dmpReferenceModel.getReference().getType().getCode() != null && dmpReferenceModel.getReference().getType().getCode().equals(code)){
|
if (planReferenceModel.getReference() != null && planReferenceModel.getReference().getType() != null && planReferenceModel.getReference().getType().getCode() != null && planReferenceModel.getReference().getType().getCode().equals(code)){
|
||||||
if (blueprintId == null || (dmpReferenceModel.getData() != null && blueprintId.equals(dmpReferenceModel.getData().getBlueprintFieldId()))) response.add(dmpReferenceModel.getReference());
|
if (blueprintId == null || (planReferenceModel.getData() != null && blueprintId.equals(planReferenceModel.getData().getBlueprintFieldId()))) response.add(planReferenceModel.getReference());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,16 +163,16 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private byte[] buildDmpWordDocument(DmpModel dmpEntity) throws IOException, InvalidApplicationException {
|
private byte[] buildPlanWordDocument(PlanModel planEntity) throws IOException, InvalidApplicationException {
|
||||||
if (dmpEntity == null) throw new MyApplicationException("DmpEntity required");
|
if (planEntity == null) throw new MyApplicationException("planEntity required");
|
||||||
DmpBlueprintModel dmpBlueprintModel = dmpEntity.getDmpBlueprint();
|
PlanBlueprintModel planBlueprintModel = planEntity.getPlanBlueprint();
|
||||||
if (dmpBlueprintModel == null) throw new MyApplicationException("DmpBlueprint required");
|
if (planBlueprintModel == null) throw new MyApplicationException("PlanBlueprint required");
|
||||||
if (dmpBlueprintModel.getDefinition() == null) throw new MyApplicationException("DmpBlueprint Definition required");
|
if (planBlueprintModel.getDefinition() == null) throw new MyApplicationException("PlanBlueprint Definition required");
|
||||||
if (dmpBlueprintModel.getDefinition().getSections() == null) throw new MyApplicationException("DmpBlueprint Section required");
|
if (planBlueprintModel.getDefinition().getSections() == null) throw new MyApplicationException("PlanBlueprint Section required");
|
||||||
|
|
||||||
XWPFDocument document = new XWPFDocument(new FileInputStream(ResourceUtils.getFile(this.wordFileTransformerServiceProperties.getWordDmpTemplate())));
|
XWPFDocument document = new XWPFDocument(new FileInputStream(ResourceUtils.getFile(this.wordFileTransformerServiceProperties.getWordPlanTemplate())));
|
||||||
|
|
||||||
this.wordBuilder.fillFirstPage(dmpEntity, null, document, false);
|
this.wordBuilder.fillFirstPage(planEntity, null, document, false);
|
||||||
|
|
||||||
int powered_pos = this.wordBuilder.findPosOfPoweredBy(document);
|
int powered_pos = this.wordBuilder.findPosOfPoweredBy(document);
|
||||||
XWPFParagraph powered_par = null;
|
XWPFParagraph powered_par = null;
|
||||||
|
@ -186,8 +182,8 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
argos_img_par = document.getParagraphArray(powered_pos + 1);
|
argos_img_par = document.getParagraphArray(powered_pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SectionModel sectionModel : dmpBlueprintModel.getDefinition().getSections()) {
|
for (SectionModel sectionModel : planBlueprintModel.getDefinition().getSections()) {
|
||||||
buildDmpSection(dmpEntity, sectionModel, document);
|
buildPlanSection(planEntity, sectionModel, document);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (powered_pos != -1) {
|
if (powered_pos != -1) {
|
||||||
|
@ -202,7 +198,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
document.removeBodyElement(powered_pos + 1);
|
document.removeBodyElement(powered_pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.wordBuilder.fillFooter(dmpEntity, null, document);
|
this.wordBuilder.fillFooter(planEntity, null, document);
|
||||||
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
document.write(out);
|
document.write(out);
|
||||||
|
@ -212,20 +208,20 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildDmpSection(DmpModel dmpEntity, SectionModel sectionModel, XWPFDocument document) throws InvalidApplicationException {
|
private void buildPlanSection(PlanModel planEntity, SectionModel sectionModel, XWPFDocument document) throws InvalidApplicationException {
|
||||||
this.wordBuilder.addParagraphContent(sectionModel.getOrdinal() + ". " + sectionModel.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
|
this.wordBuilder.addParagraphContent(sectionModel.getOrdinal() + ". " + sectionModel.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
|
||||||
|
|
||||||
if (sectionModel.getFields() != null) {
|
if (sectionModel.getFields() != null) {
|
||||||
sectionModel.getFields().sort(Comparator.comparingInt(FieldModel::getOrdinal));
|
sectionModel.getFields().sort(Comparator.comparingInt(FieldModel::getOrdinal));
|
||||||
for (FieldModel fieldModel : sectionModel.getFields()) {
|
for (FieldModel fieldModel : sectionModel.getFields()) {
|
||||||
buildDmpSectionField(dmpEntity, document, fieldModel);
|
buildPlanSectionField(planEntity, document, fieldModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isFinalized = dmpEntity.getStatus() != null && dmpEntity.getStatus().equals(DmpStatus.Finalized);
|
final boolean isFinalized = planEntity.getStatus() != null && planEntity.getStatus().equals(PlanStatus.Finalized);
|
||||||
final boolean isPublic = dmpEntity.getPublicAfter() != null && dmpEntity.getPublicAfter().isAfter(Instant.now());
|
final boolean isPublic = planEntity.getPublicAfter() != null && planEntity.getPublicAfter().isAfter(Instant.now());
|
||||||
|
|
||||||
List<DescriptionModel> descriptions = dmpEntity.getDescriptions() == null ? new ArrayList<>() : dmpEntity.getDescriptions().stream()
|
List<DescriptionModel> descriptions = planEntity.getDescriptions() == null ? new ArrayList<>() : planEntity.getDescriptions().stream()
|
||||||
.filter(item -> item.getStatus() != DescriptionStatus.Canceled)
|
.filter(item -> item.getStatus() != DescriptionStatus.Canceled)
|
||||||
.filter(item -> !isPublic && !isFinalized || item.getStatus() == DescriptionStatus.Finalized)
|
.filter(item -> !isPublic && !isFinalized || item.getStatus() == DescriptionStatus.Finalized)
|
||||||
.filter(item -> item.getSectionId().equals(sectionModel.getId()))
|
.filter(item -> item.getSectionId().equals(sectionModel.getId()))
|
||||||
|
@ -304,24 +300,24 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void buildDmpSectionField(DmpModel dmpEntity, XWPFDocument document, FieldModel fieldModel) throws InvalidApplicationException {
|
private void buildPlanSectionField(PlanModel planEntity, XWPFDocument document, FieldModel fieldModel) throws InvalidApplicationException {
|
||||||
if (fieldModel == null) throw new MyApplicationException("Field required");
|
if (fieldModel == null) throw new MyApplicationException("Field required");
|
||||||
if (fieldModel.getCategory() == null) throw new MyApplicationException("Field is required" + fieldModel.getId() + " " + fieldModel.getLabel());
|
if (fieldModel.getCategory() == null) throw new MyApplicationException("Field is required" + fieldModel.getId() + " " + fieldModel.getLabel());
|
||||||
switch (fieldModel.getCategory()){
|
switch (fieldModel.getCategory()){
|
||||||
case System -> {
|
case System -> {
|
||||||
buildDmpSectionSystemField(dmpEntity, document, (SystemFieldModel) fieldModel);
|
buildPlanSectionSystemField(planEntity, document, (SystemFieldModel) fieldModel);
|
||||||
}
|
}
|
||||||
case Extra -> buildDmpSectionExtraField(dmpEntity, document, (ExtraFieldModel) fieldModel);
|
case Extra -> buildPlanSectionExtraField(planEntity, document, (ExtraFieldModel) fieldModel);
|
||||||
case ReferenceType -> {
|
case ReferenceType -> {
|
||||||
buildDmpSectionReferenceTypeField(dmpEntity, document, (ReferenceTypeFieldModel) fieldModel);
|
buildPlanSectionReferenceTypeField(planEntity, document, (ReferenceTypeFieldModel) fieldModel);
|
||||||
}
|
}
|
||||||
default -> throw new MyApplicationException("Invalid type " + fieldModel.getCategory());
|
default -> throw new MyApplicationException("Invalid type " + fieldModel.getCategory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildDmpSectionReferenceTypeField(DmpModel dmpEntity, XWPFDocument document, ReferenceTypeFieldModel referenceField) {
|
private void buildPlanSectionReferenceTypeField(PlanModel planEntity, XWPFDocument document, ReferenceTypeFieldModel referenceField) {
|
||||||
if (referenceField == null) throw new MyApplicationException("ReferenceField required");
|
if (referenceField == null) throw new MyApplicationException("ReferenceField required");
|
||||||
if (dmpEntity == null) throw new MyApplicationException("DmpEntity required");
|
if (planEntity == null) throw new MyApplicationException("planEntity required");
|
||||||
if (document == null) throw new MyApplicationException("Document required");
|
if (document == null) throw new MyApplicationException("Document required");
|
||||||
if (referenceField.getReferenceType() == null) throw new MyApplicationException("ReferenceField type required");
|
if (referenceField.getReferenceType() == null) throw new MyApplicationException("ReferenceField type required");
|
||||||
if (referenceField.getReferenceType().getCode() == null && !referenceField.getReferenceType().getCode().isBlank()) throw new IllegalArgumentException("ReferenceField type code required");
|
if (referenceField.getReferenceType().getCode() == null && !referenceField.getReferenceType().getCode().isBlank()) throw new IllegalArgumentException("ReferenceField type code required");
|
||||||
|
@ -331,7 +327,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
runSyStemFieldTitle.setText(this.getReferenceFieldLabel(referenceField) + ": ");
|
runSyStemFieldTitle.setText(this.getReferenceFieldLabel(referenceField) + ": ");
|
||||||
runSyStemFieldTitle.setColor("000000");
|
runSyStemFieldTitle.setColor("000000");
|
||||||
|
|
||||||
List<ReferenceModel> referenceModels = this.getReferenceModelOfTypeCode(dmpEntity, referenceField.getReferenceType().getCode(), referenceField.getId());
|
List<ReferenceModel> referenceModels = this.getReferenceModelOfTypeCode(planEntity, referenceField.getReferenceType().getCode(), referenceField.getId());
|
||||||
for (ReferenceModel reference : referenceModels) {
|
for (ReferenceModel reference : referenceModels) {
|
||||||
XWPFRun runResearcher = systemFieldParagraph.createRun();
|
XWPFRun runResearcher = systemFieldParagraph.createRun();
|
||||||
if (this.wordFileTransformerServiceProperties.getResearcherReferenceCode().equalsIgnoreCase(referenceField.getReferenceType().getCode()) ||
|
if (this.wordFileTransformerServiceProperties.getResearcherReferenceCode().equalsIgnoreCase(referenceField.getReferenceType().getCode()) ||
|
||||||
|
@ -350,12 +346,12 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
return referenceTypeField.getReferenceType().getName();
|
return referenceTypeField.getReferenceType().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildDmpSectionSystemField(DmpModel dmpEntity, XWPFDocument document, SystemFieldModel systemField) {
|
private void buildPlanSectionSystemField(PlanModel planEntity, XWPFDocument document, SystemFieldModel systemField) {
|
||||||
if (systemField == null) throw new MyApplicationException("SystemField required");
|
if (systemField == null) throw new MyApplicationException("SystemField required");
|
||||||
if (dmpEntity == null) throw new MyApplicationException("DmpEntity required");
|
if (planEntity == null) throw new MyApplicationException("planEntity required");
|
||||||
if (document == null) throw new MyApplicationException("Document required");
|
if (document == null) throw new MyApplicationException("Document required");
|
||||||
|
|
||||||
if (DmpBlueprintSystemFieldType.Language.equals(systemField.getSystemFieldType()) || DmpBlueprintSystemFieldType.User.equals(systemField.getSystemFieldType())) return;
|
if (PlanBlueprintSystemFieldType.Language.equals(systemField.getSystemFieldType()) || PlanBlueprintSystemFieldType.User.equals(systemField.getSystemFieldType())) return;
|
||||||
|
|
||||||
|
|
||||||
XWPFParagraph systemFieldParagraph = document.createParagraph();
|
XWPFParagraph systemFieldParagraph = document.createParagraph();
|
||||||
|
@ -366,24 +362,24 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
switch (systemField.getSystemFieldType()) {
|
switch (systemField.getSystemFieldType()) {
|
||||||
case Title:
|
case Title:
|
||||||
XWPFRun runTitle = systemFieldParagraph.createRun();
|
XWPFRun runTitle = systemFieldParagraph.createRun();
|
||||||
runTitle.setText(dmpEntity.getLabel());
|
runTitle.setText(planEntity.getLabel());
|
||||||
runTitle.setColor("116a78");
|
runTitle.setColor("116a78");
|
||||||
break;
|
break;
|
||||||
case Description:
|
case Description:
|
||||||
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
wordBuilder.addParagraphContent(planEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
break;
|
break;
|
||||||
case AccessRights:
|
case AccessRights:
|
||||||
if (dmpEntity.getAccessType() != null) {
|
if (planEntity.getAccessType() != null) {
|
||||||
XWPFRun runAccessRights = systemFieldParagraph.createRun();
|
XWPFRun runAccessRights = systemFieldParagraph.createRun();
|
||||||
runAccessRights.setText(dmpEntity.getAccessType().equals(DmpAccessType.Public) ? "Public" : "Restricted"); //TODO
|
runAccessRights.setText(planEntity.getAccessType().equals(PlanAccessType.Public) ? "Public" : "Restricted"); //TODO
|
||||||
runAccessRights.setColor("116a78");
|
runAccessRights.setColor("116a78");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Contact:
|
case Contact:
|
||||||
List<String> contacts = new ArrayList<>();
|
List<String> contacts = new ArrayList<>();
|
||||||
|
|
||||||
if (dmpEntity.getProperties() != null && dmpEntity.getProperties().getContacts() != null && !dmpEntity.getProperties().getContacts().isEmpty()) {
|
if (planEntity.getProperties() != null && planEntity.getProperties().getContacts() != null && !planEntity.getProperties().getContacts().isEmpty()) {
|
||||||
for (DmpContactModel contactModel : dmpEntity.getProperties().getContacts()){
|
for (PlanContactModel contactModel : planEntity.getProperties().getContacts()){
|
||||||
String contact;
|
String contact;
|
||||||
contact = (contactModel.getLastName() == null ? "" : contactModel.getLastName()) + " " + (contactModel.getFirstName() == null ? "" : contactModel.getFirstName());
|
contact = (contactModel.getLastName() == null ? "" : contactModel.getLastName()) + " " + (contactModel.getFirstName() == null ? "" : contactModel.getFirstName());
|
||||||
if (contactModel.getEmail() != null && !contactModel.getEmail().isEmpty()) contact = contact + " (" + contactModel.getEmail() +")";
|
if (contactModel.getEmail() != null && !contactModel.getEmail().isEmpty()) contact = contact + " (" + contactModel.getEmail() +")";
|
||||||
|
@ -420,7 +416,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildDmpSectionExtraField(DmpModel dmpEntity, XWPFDocument document, ExtraFieldModel extraFieldModel) {
|
private void buildPlanSectionExtraField(PlanModel planEntity, XWPFDocument document, ExtraFieldModel extraFieldModel) {
|
||||||
if (extraFieldModel == null) throw new MyApplicationException("ExtraFieldModel required");
|
if (extraFieldModel == null) throw new MyApplicationException("ExtraFieldModel required");
|
||||||
XWPFParagraph extraFieldParagraph = document.createParagraph();
|
XWPFParagraph extraFieldParagraph = document.createParagraph();
|
||||||
extraFieldParagraph.setSpacingBetween(1.0);
|
extraFieldParagraph.setSpacingBetween(1.0);
|
||||||
|
@ -429,27 +425,27 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
runExtraFieldLabel.setColor("000000");
|
runExtraFieldLabel.setColor("000000");
|
||||||
|
|
||||||
XWPFRun runExtraFieldInput = extraFieldParagraph.createRun();
|
XWPFRun runExtraFieldInput = extraFieldParagraph.createRun();
|
||||||
DmpBlueprintValueModel dmpBlueprintValueModel = dmpEntity.getProperties() != null && dmpEntity.getProperties().getDmpBlueprintValues() != null ? dmpEntity.getProperties().getDmpBlueprintValues().stream().filter(x -> extraFieldModel.getId().equals(x.getFieldId())).findFirst().orElse(null) : null;
|
PlanBlueprintValueModel planBlueprintValueModel = planEntity.getProperties() != null && planEntity.getProperties().getPlanBlueprintValues() != null ? planEntity.getProperties().getPlanBlueprintValues().stream().filter(x -> extraFieldModel.getId().equals(x.getFieldId())).findFirst().orElse(null) : null;
|
||||||
if (dmpBlueprintValueModel != null) {
|
if (planBlueprintValueModel != null) {
|
||||||
switch (extraFieldModel.getDataType()) {
|
switch (extraFieldModel.getDataType()) {
|
||||||
case RichTex:
|
case RichTex:
|
||||||
if(dmpBlueprintValueModel.getValue() != null && !dmpBlueprintValueModel.getValue().isBlank()) wordBuilder.addParagraphContent(dmpBlueprintValueModel.getValue(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
if(planBlueprintValueModel.getValue() != null && !planBlueprintValueModel.getValue().isBlank()) wordBuilder.addParagraphContent(planBlueprintValueModel.getValue(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
break;
|
break;
|
||||||
case Number:
|
case Number:
|
||||||
if(dmpBlueprintValueModel.getNumberValue() != null) {
|
if(planBlueprintValueModel.getNumberValue() != null) {
|
||||||
runExtraFieldInput.setText(DecimalFormat.getNumberInstance().format(dmpBlueprintValueModel.getNumberValue()));
|
runExtraFieldInput.setText(DecimalFormat.getNumberInstance().format(planBlueprintValueModel.getNumberValue()));
|
||||||
runExtraFieldInput.setColor("116a78");
|
runExtraFieldInput.setColor("116a78");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Date:
|
case Date:
|
||||||
if(dmpBlueprintValueModel.getDateValue() != null){
|
if(planBlueprintValueModel.getDateValue() != null){
|
||||||
runExtraFieldInput.setText(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(dmpBlueprintValueModel.getDateValue()));
|
runExtraFieldInput.setText(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(planBlueprintValueModel.getDateValue()));
|
||||||
runExtraFieldInput.setColor("116a78");
|
runExtraFieldInput.setColor("116a78");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Text:
|
case Text:
|
||||||
if(dmpBlueprintValueModel.getValue() != null && !dmpBlueprintValueModel.getValue().isBlank()) {
|
if(planBlueprintValueModel.getValue() != null && !planBlueprintValueModel.getValue().isBlank()) {
|
||||||
runExtraFieldInput.setText(dmpBlueprintValueModel.getValue());
|
runExtraFieldInput.setText(planBlueprintValueModel.getValue());
|
||||||
runExtraFieldInput.setColor("116a78");
|
runExtraFieldInput.setColor("116a78");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -459,17 +455,17 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDmpFileName(DmpModel dmpModel, String extension){
|
private String getPlanFileName(PlanModel planModel, String extension){
|
||||||
if (dmpModel == null) throw new MyApplicationException("DmpEntity required");
|
if (planModel == null) throw new MyApplicationException("PlanEntity required");
|
||||||
|
|
||||||
List<ReferenceModel> grants = this.getReferenceModelOfTypeCode(dmpModel, this.wordFileTransformerServiceProperties.getGrantReferenceCode(), null);
|
List<ReferenceModel> grants = this.getReferenceModelOfTypeCode(planModel, this.wordFileTransformerServiceProperties.getGrantReferenceCode(), null);
|
||||||
String fileName = null;
|
String fileName = null;
|
||||||
if (dmpModel.getLabel() != null){
|
if (planModel.getLabel() != null){
|
||||||
return dmpModel.getLabel() + extension;
|
return planModel.getLabel() + extension;
|
||||||
}
|
}
|
||||||
if (!grants.isEmpty() && grants.getFirst().getLabel() != null) {
|
if (!grants.isEmpty() && grants.getFirst().getLabel() != null) {
|
||||||
fileName = "DMP_" + grants.getFirst().getLabel();
|
fileName = "PLAN_" + grants.getFirst().getLabel();
|
||||||
fileName += "_" + dmpModel.getVersion();
|
fileName += "_" + planModel.getVersion();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,13 +473,13 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] buildDescriptionWordDocument(DescriptionModel descriptionModel) throws IOException {
|
private byte[] buildDescriptionWordDocument(DescriptionModel descriptionModel) throws IOException {
|
||||||
if (descriptionModel == null) throw new MyApplicationException("DmpEntity required");
|
if (descriptionModel == null) throw new MyApplicationException("DescriptionEntity required");
|
||||||
DmpModel dmpEntity = descriptionModel.getDmp();
|
PlanModel planEntity = descriptionModel.getPlan();
|
||||||
if (dmpEntity == null) throw new MyApplicationException("Dmp is invalid");
|
if (planEntity == null) throw new MyApplicationException("plan is invalid");
|
||||||
XWPFDocument document = new XWPFDocument(new FileInputStream(ResourceUtils.getFile(this.wordFileTransformerServiceProperties.getWordDescriptionTemplate())));
|
XWPFDocument document = new XWPFDocument(new FileInputStream(ResourceUtils.getFile(this.wordFileTransformerServiceProperties.getWordDescriptionTemplate())));
|
||||||
|
|
||||||
this.wordBuilder.fillFirstPage(dmpEntity, descriptionModel, document, true);
|
this.wordBuilder.fillFirstPage(planEntity, descriptionModel, document, true);
|
||||||
this.wordBuilder.fillFooter(dmpEntity, descriptionModel, document);
|
this.wordBuilder.fillFooter(planEntity, descriptionModel, document);
|
||||||
|
|
||||||
int powered_pos = this.wordBuilder.findPosOfPoweredBy(document);
|
int powered_pos = this.wordBuilder.findPosOfPoweredBy(document);
|
||||||
XWPFParagraph powered_par = null;
|
XWPFParagraph powered_par = null;
|
||||||
|
@ -516,7 +512,7 @@ public class WordFileTransformerService implements FileTransformerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDescriptionFileName(DescriptionModel descriptionModel, String extension){
|
private String getDescriptionFileName(DescriptionModel descriptionModel, String extension){
|
||||||
if (descriptionModel == null) throw new MyApplicationException("DmpEntity required");
|
if (descriptionModel == null) throw new MyApplicationException("DescriptionEntity required");
|
||||||
String fileName = descriptionModel.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
String fileName = descriptionModel.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||||
|
|
||||||
return fileName + extension;
|
return fileName + extension;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
public class WordFileTransformerServiceProperties {
|
public class WordFileTransformerServiceProperties {
|
||||||
private String transformerId;
|
private String transformerId;
|
||||||
private boolean useSharedStorage;
|
private boolean useSharedStorage;
|
||||||
private String wordDmpTemplate;
|
private String wordPlanTemplate;
|
||||||
private String pidTemplate;
|
private String pidTemplate;
|
||||||
private String wordDescriptionTemplate;
|
private String wordDescriptionTemplate;
|
||||||
private String organizationReferenceCode;
|
private String organizationReferenceCode;
|
||||||
|
@ -90,12 +90,12 @@ public class WordFileTransformerServiceProperties {
|
||||||
this.publicationReferenceCode = publicationReferenceCode;
|
this.publicationReferenceCode = publicationReferenceCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWordDmpTemplate() {
|
public String getWordPlanTemplate() {
|
||||||
return wordDmpTemplate;
|
return wordPlanTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWordDmpTemplate(String wordDmpTemplate) {
|
public void setWordPlanTemplate(String wordPlanTemplate) {
|
||||||
this.wordDmpTemplate = wordDmpTemplate;
|
this.wordPlanTemplate = wordPlanTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPidTemplate() {
|
public String getPidTemplate() {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.opencdmp.filetransformer.docx.service.wordfiletransformer.word;
|
||||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||||
import org.opencdmp.commonmodels.models.description.PropertyDefinitionModel;
|
import org.opencdmp.commonmodels.models.description.PropertyDefinitionModel;
|
||||||
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.filetransformer.docx.model.enums.ParagraphStyle;
|
import org.opencdmp.filetransformer.docx.model.enums.ParagraphStyle;
|
||||||
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.visibility.VisibilityService;
|
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.visibility.VisibilityService;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
|
@ -19,7 +19,7 @@ public interface WordBuilder {
|
||||||
|
|
||||||
int findPosOfPoweredBy(XWPFDocument document);
|
int findPosOfPoweredBy(XWPFDocument document);
|
||||||
|
|
||||||
void fillFirstPage(DmpModel dmpEntity, DescriptionModel descriptionModel, XWPFDocument document, boolean isDescription);
|
void fillFirstPage(PlanModel planEntity, DescriptionModel descriptionModel, XWPFDocument document, boolean isDescription);
|
||||||
|
|
||||||
void fillFooter(DmpModel dmpEntity, DescriptionModel descriptionModel, XWPFDocument document);
|
void fillFooter(PlanModel planEntity, DescriptionModel descriptionModel, XWPFDocument document);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ import org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetMo
|
||||||
import org.opencdmp.commonmodels.models.description.PropertyDefinitionModel;
|
import org.opencdmp.commonmodels.models.description.PropertyDefinitionModel;
|
||||||
import org.opencdmp.commonmodels.models.descriptiotemplate.*;
|
import org.opencdmp.commonmodels.models.descriptiotemplate.*;
|
||||||
import org.opencdmp.commonmodels.models.descriptiotemplate.fielddata.*;
|
import org.opencdmp.commonmodels.models.descriptiotemplate.fielddata.*;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
|
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
|
||||||
import org.opencdmp.commonmodels.models.reference.ReferenceFieldModel;
|
import org.opencdmp.commonmodels.models.reference.ReferenceFieldModel;
|
||||||
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
|
||||||
import org.opencdmp.filetransformer.docx.service.storage.FileStorageService;
|
import org.opencdmp.filetransformer.docx.service.storage.FileStorageService;
|
||||||
|
@ -833,7 +833,7 @@ public class WordBuilderImpl implements WordBuilder {
|
||||||
}
|
}
|
||||||
case UPLOAD:
|
case UPLOAD:
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS:
|
case INTERNAL_ENTRIES_DESCRIPTIONS:
|
||||||
case INTERNAL_ENTRIES_DMPS:
|
case INTERNAL_ENTRIES_PlANS:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new MyApplicationException("Invalid type " + field.getData().getFieldType());
|
throw new MyApplicationException("Invalid type " + field.getData().getFieldType());
|
||||||
|
@ -863,34 +863,34 @@ public class WordBuilderImpl implements WordBuilder {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ReferenceModel> getReferenceModelOfTypeCode(DmpModel dmp, String code) {
|
private List<ReferenceModel> getReferenceModelOfTypeCode(PlanModel plan, String code) {
|
||||||
List<ReferenceModel> response = new ArrayList<>();
|
List<ReferenceModel> response = new ArrayList<>();
|
||||||
if (dmp.getReferences() == null) return response;
|
if (plan.getReferences() == null) return response;
|
||||||
for (DmpReferenceModel dmpReferenceModel : dmp.getReferences()) {
|
for (PlanReferenceModel planReferenceModel : plan.getReferences()) {
|
||||||
if (dmpReferenceModel.getReference() != null && dmpReferenceModel.getReference().getType() != null && dmpReferenceModel.getReference().getType().getCode() != null && dmpReferenceModel.getReference().getType().getCode().equals(code)) {
|
if (planReferenceModel.getReference() != null && planReferenceModel.getReference().getType() != null && planReferenceModel.getReference().getType().getCode() != null && planReferenceModel.getReference().getType().getCode().equals(code)) {
|
||||||
response.add(dmpReferenceModel.getReference());
|
response.add(planReferenceModel.getReference());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillFirstPage(DmpModel dmpEntity, DescriptionModel descriptionModel, XWPFDocument document, boolean isDescription) {
|
public void fillFirstPage(PlanModel planEntity, DescriptionModel descriptionModel, XWPFDocument document, boolean isDescription) {
|
||||||
if (dmpEntity == null) throw new MyApplicationException("DmpEntity required");
|
if (planEntity == null) throw new MyApplicationException("planEntity required");
|
||||||
if (document == null) throw new MyApplicationException("Document required");
|
if (document == null) throw new MyApplicationException("Document required");
|
||||||
|
|
||||||
int parPos = 0;
|
int parPos = 0;
|
||||||
int descrParPos = -1;
|
int descrParPos = -1;
|
||||||
List<ReferenceModel> grants = this.getReferenceModelOfTypeCode(dmpEntity, this.wordFileTransformerServiceProperties.getGrantReferenceCode());
|
List<ReferenceModel> grants = this.getReferenceModelOfTypeCode(planEntity, this.wordFileTransformerServiceProperties.getGrantReferenceCode());
|
||||||
List<ReferenceModel> researchers = this.getReferenceModelOfTypeCode(dmpEntity, this.wordFileTransformerServiceProperties.getResearcherReferenceCode());
|
List<ReferenceModel> researchers = this.getReferenceModelOfTypeCode(planEntity, this.wordFileTransformerServiceProperties.getResearcherReferenceCode());
|
||||||
List<ReferenceModel> organizations = this.getReferenceModelOfTypeCode(dmpEntity, this.wordFileTransformerServiceProperties.getOrganizationReferenceCode());
|
List<ReferenceModel> organizations = this.getReferenceModelOfTypeCode(planEntity, this.wordFileTransformerServiceProperties.getOrganizationReferenceCode());
|
||||||
List<ReferenceModel> funders = this.getReferenceModelOfTypeCode(dmpEntity, this.wordFileTransformerServiceProperties.getFunderReferenceCode());
|
List<ReferenceModel> funders = this.getReferenceModelOfTypeCode(planEntity, this.wordFileTransformerServiceProperties.getFunderReferenceCode());
|
||||||
|
|
||||||
XWPFParagraph descrPar = null;
|
XWPFParagraph descrPar = null;
|
||||||
for (XWPFParagraph p : document.getParagraphs()) {
|
for (XWPFParagraph p : document.getParagraphs()) {
|
||||||
|
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.TITLE}'", dmpEntity.getLabel());
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.TITLE}'", planEntity.getLabel());
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.VERSION}'", "Version " + dmpEntity.getVersion());
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.VERSION}'", "Version " + planEntity.getVersion());
|
||||||
if (descriptionModel != null) {
|
if (descriptionModel != null) {
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", descriptionModel.getLabel());
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", descriptionModel.getLabel());
|
||||||
}
|
}
|
||||||
|
@ -901,7 +901,7 @@ public class WordBuilderImpl implements WordBuilder {
|
||||||
i++;
|
i++;
|
||||||
researchersNames.append(researcher.getLabel()).append(i < researchers.size() ? ", " : "");
|
researchersNames.append(researcher.getLabel()).append(i < researchers.size() ? ", " : "");
|
||||||
}
|
}
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.RESEARCHERS}'", researchersNames.toString(), 15);
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.RESEARCHERS}'", researchersNames.toString(), 15);
|
||||||
|
|
||||||
StringBuilder organisationsNames = new StringBuilder();
|
StringBuilder organisationsNames = new StringBuilder();
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -909,12 +909,12 @@ public class WordBuilderImpl implements WordBuilder {
|
||||||
i++;
|
i++;
|
||||||
organisationsNames.append(organisation.getLabel()).append(i < organizations.size() ? ", " : "");
|
organisationsNames.append(organisation.getLabel()).append(i < organizations.size() ? ", " : "");
|
||||||
}
|
}
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.ORGANIZATIONS}'", organisationsNames.toString(), 15);
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.ORGANIZATIONS}'", organisationsNames.toString(), 15);
|
||||||
|
|
||||||
if (this.textSegmentExists(p, "'{ARGOS.DMP.DESCRIPTION}'")) {
|
if (this.textSegmentExists(p, "'{ARGOS.PLAN.DESCRIPTION}'")) {
|
||||||
descrParPos = parPos;
|
descrParPos = parPos;
|
||||||
descrPar = p;
|
descrPar = p;
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.DESCRIPTION}'", "");
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.DESCRIPTION}'", "");
|
||||||
}
|
}
|
||||||
if (this.textSegmentExists(p, "'{ARGOS.DATASET.DESCRIPTION}'")) {
|
if (this.textSegmentExists(p, "'{ARGOS.DATASET.DESCRIPTION}'")) {
|
||||||
descrParPos = parPos;
|
descrParPos = parPos;
|
||||||
|
@ -922,10 +922,10 @@ public class WordBuilderImpl implements WordBuilder {
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DATASET.DESCRIPTION}'", "");
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.DESCRIPTION}'", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((descrParPos != -1) && (dmpEntity.getDescription() != null) && !isDescription) {
|
if ((descrParPos != -1) && (planEntity.getDescription() != null) && !isDescription) {
|
||||||
XmlCursor cursor = descrPar.getCTP().newCursor();
|
XmlCursor cursor = descrPar.getCTP().newCursor();
|
||||||
cursor.toNextSibling();
|
cursor.toNextSibling();
|
||||||
Document htmlDoc = Jsoup.parse((dmpEntity.getDescription()).replaceAll("\n", "<br>"));
|
Document htmlDoc = Jsoup.parse((planEntity.getDescription()).replaceAll("\n", "<br>"));
|
||||||
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
|
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
|
||||||
NodeTraversor.traverse(htmlToWorldBuilder, htmlDoc);
|
NodeTraversor.traverse(htmlToWorldBuilder, htmlDoc);
|
||||||
}
|
}
|
||||||
|
@ -1083,29 +1083,29 @@ public class WordBuilderImpl implements WordBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillFooter(DmpModel dmpEntity, DescriptionModel descriptionModel, XWPFDocument document) {
|
public void fillFooter(PlanModel planEntity, DescriptionModel descriptionModel, XWPFDocument document) {
|
||||||
if (dmpEntity == null) throw new MyApplicationException("DmpEntity required");
|
if (planEntity == null) throw new MyApplicationException("planEntity required");
|
||||||
|
|
||||||
List<ReferenceModel> licences = this.getReferenceModelOfTypeCode(dmpEntity, this.wordFileTransformerServiceProperties.getLicenceReferenceCode());
|
List<ReferenceModel> licences = this.getReferenceModelOfTypeCode(planEntity, this.wordFileTransformerServiceProperties.getLicenceReferenceCode());
|
||||||
document.getFooterList().forEach(xwpfFooter -> {
|
document.getFooterList().forEach(xwpfFooter -> {
|
||||||
for (XWPFParagraph p : xwpfFooter.getParagraphs()) {
|
for (XWPFParagraph p : xwpfFooter.getParagraphs()) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.TITLE}'", dmpEntity.getLabel());
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.TITLE}'", planEntity.getLabel());
|
||||||
if (descriptionModel != null) {
|
if (descriptionModel != null) {
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", descriptionModel.getLabel());
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", descriptionModel.getLabel());
|
||||||
}
|
}
|
||||||
if (!licences.isEmpty() && licences.getFirst().getReference() != null && !licences.getFirst().getReference().isBlank()) {
|
if (!licences.isEmpty() && licences.getFirst().getReference() != null && !licences.getFirst().getReference().isBlank()) {
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", licences.getFirst().getReference());
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.LICENSE}'", licences.getFirst().getReference());
|
||||||
} else {
|
} else {
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", "License: -");
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.LICENSE}'", "License: -");
|
||||||
}
|
}
|
||||||
if (dmpEntity.getEntityDois() != null && !dmpEntity.getEntityDois().isEmpty()) {
|
if (planEntity.getEntityDois() != null && !planEntity.getEntityDois().isEmpty()) {
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.DOI}'", dmpEntity.getEntityDois().getFirst().getDoi());
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.DOI}'", planEntity.getEntityDois().getFirst().getDoi());
|
||||||
} else {
|
} else {
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.DOI}'", "-");
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.DOI}'", "-");
|
||||||
}
|
}
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy").withZone(ZoneId.systemDefault());
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy").withZone(ZoneId.systemDefault());
|
||||||
this.replaceTextSegment(p, "'{ARGOS.DMP.LAST_MODIFIED}'", formatter.format(dmpEntity.getUpdatedAt()));
|
this.replaceTextSegment(p, "'{ARGOS.PLAN.LAST_MODIFIED}'", formatter.format(planEntity.getUpdatedAt()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -27,7 +27,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.opencdmp</groupId>
|
<groupId>org.opencdmp</groupId>
|
||||||
<artifactId>file-transformer-base</artifactId>
|
<artifactId>file-transformer-base</artifactId>
|
||||||
<version>0.0.23</version>
|
<version>0.0.24</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
|
|
|
@ -5,15 +5,14 @@ import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||||
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
import org.opencdmp.commonmodels.models.description.DescriptionModel;
|
||||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
import org.opencdmp.commonmodels.models.plan.PlanModel;
|
||||||
import org.opencdmp.filetransformer.docx.audit.AuditableAction;
|
import org.opencdmp.filetransformer.docx.audit.AuditableAction;
|
||||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
|
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
|
||||||
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
|
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
|
||||||
import org.opencdmp.filetransformer.docx.service.wordfiletransformer.WordFileTransformerService;
|
|
||||||
import org.opencdmp.filetransformerbase.models.misc.DescriptionImportModel;
|
import org.opencdmp.filetransformerbase.models.misc.DescriptionImportModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.DmpImportModel;
|
import org.opencdmp.filetransformerbase.models.misc.PlanImportModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDescriptionModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDescriptionModel;
|
||||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel;
|
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -36,13 +35,13 @@ public class FileTransformerController implements org.opencdmp.filetransformerba
|
||||||
this.auditService = auditService;
|
this.auditService = auditService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileEnvelopeModel exportDmp(@RequestBody DmpModel dmpDepositModel, @RequestParam(value = "format",required = false)String format) throws Exception {
|
public FileEnvelopeModel exportPlan(@RequestBody PlanModel planDepositModel, @RequestParam(value = "format",required = false)String format) throws Exception {
|
||||||
logger.debug(new MapLogEntry("exportDmp " + DmpModel.class.getSimpleName()).And("dmpDepositModel", dmpDepositModel).And("format", format));
|
logger.debug(new MapLogEntry("exportPlan " + PlanModel.class.getSimpleName()).And("planDepositModel", planDepositModel).And("format", format));
|
||||||
|
|
||||||
FileEnvelopeModel model = fileTransformerExecutor.exportDmp(dmpDepositModel, format);
|
FileEnvelopeModel model = fileTransformerExecutor.exportPlan(planDepositModel, format);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.FileTransformer_ExportDmp, Map.ofEntries(
|
this.auditService.track(AuditableAction.FileTransformer_ExportPlan, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("dmpDepositModel", dmpDepositModel),
|
new AbstractMap.SimpleEntry<String, Object>("planDepositModel", planDepositModel),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("format", format)
|
new AbstractMap.SimpleEntry<String, Object>("format", format)
|
||||||
));
|
));
|
||||||
return model;
|
return model;
|
||||||
|
@ -60,14 +59,14 @@ public class FileTransformerController implements org.opencdmp.filetransformerba
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpModel importFileToDmp(@RequestBody DmpImportModel dmpImportModel) {
|
public PlanModel importFileToPlan(@RequestBody PlanImportModel planImportModel) {
|
||||||
|
|
||||||
logger.debug(new MapLogEntry("importFileToDmp " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", dmpImportModel.getFile()));
|
logger.debug(new MapLogEntry("importFileToPlan " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", planImportModel.getFile()));
|
||||||
|
|
||||||
DmpModel model = fileTransformerExecutor.importDmp(dmpImportModel);
|
PlanModel model = fileTransformerExecutor.importPlan(planImportModel);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.FileTransformer_ImportFileToDmp, Map.ofEntries(
|
this.auditService.track(AuditableAction.FileTransformer_ImportFileToPlan, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fileEnvelope", dmpImportModel.getFile())
|
new AbstractMap.SimpleEntry<String, Object>("fileEnvelope", planImportModel.getFile())
|
||||||
));
|
));
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@ -83,13 +82,13 @@ public class FileTransformerController implements org.opencdmp.filetransformerba
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreprocessingDmpModel preprocessingDmp(FileEnvelopeModel fileEnvelopeModel) {
|
public PreprocessingPlanModel preprocessingPlan(FileEnvelopeModel fileEnvelopeModel) {
|
||||||
logger.debug(new MapLogEntry("PreprocessingDmpModel " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelopeModel));
|
logger.debug(new MapLogEntry("PreprocessingPlanModel " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelopeModel));
|
||||||
|
|
||||||
PreprocessingDmpModel model = fileTransformerExecutor.preprocessingDmp(fileEnvelopeModel);
|
PreprocessingPlanModel model = fileTransformerExecutor.preprocessingPlan(fileEnvelopeModel);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.FileTransformer_PreprocessingDmp, Map.ofEntries(
|
this.auditService.track(AuditableAction.FileTransformer_PreprocessingPlan, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("importFileToDescription ", fileEnvelopeModel)
|
new AbstractMap.SimpleEntry<String, Object>("importFileToPlan ", fileEnvelopeModel)
|
||||||
));
|
));
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
word-file-transformer:
|
word-file-transformer:
|
||||||
word-dmp-template: classpath:documents/h2020.docx
|
word-plan-template: classpath:documents/h2020.docx
|
||||||
pid-template: classpath:pidLinks.json
|
pid-template: classpath:pidLinks.json
|
||||||
word-description-template: classpath:documents/h2020_dataset.docx
|
word-description-template: classpath:documents/h2020_dataset.docx
|
||||||
useSharedStorage: false
|
useSharedStorage: false
|
||||||
|
|
|
@ -14,7 +14,6 @@ Validation.LessThenEqual= value {0} must be equal or less than {1}
|
||||||
Validation.LargerThenEqual= value {0} must be equal or larger than {1}
|
Validation.LargerThenEqual= value {0} must be equal or larger than {1}
|
||||||
Validation.MissingFields= missing fields: {0}
|
Validation.MissingFields= missing fields: {0}
|
||||||
Validation.InvalidDescriptionTemplateMultiplicity= {0} can not be used
|
Validation.InvalidDescriptionTemplateMultiplicity= {0} can not be used
|
||||||
Validation.InvalidDescriptionTemplateMultiplicityOnDMP= Description Templates has multiplicity errors
|
|
||||||
Validation_UrlRequired={0} is not valid url
|
Validation_UrlRequired={0} is not valid url
|
||||||
|
|
||||||
SystemField_Title_Label=Title
|
SystemField_Title_Label=Title
|
||||||
|
|
|
@ -14,5 +14,4 @@ Validation.LessThenEqual= value {0} must be equal or less than {1}
|
||||||
Validation.LargerThenEqual= value {0} must be equal or larger than {1}
|
Validation.LargerThenEqual= value {0} must be equal or larger than {1}
|
||||||
Validation.MissingFields= missing fields: {0}
|
Validation.MissingFields= missing fields: {0}
|
||||||
Validation.InvalidDescriptionTemplateMultiplicity= {0} can not be used
|
Validation.InvalidDescriptionTemplateMultiplicity= {0} can not be used
|
||||||
Validation.InvalidDescriptionTemplateMultiplicityOnDMP= Description Templates has multiplicity errors
|
|
||||||
Validation_UrlRequired={0} is not valid url
|
Validation_UrlRequired={0} is not valid url
|
Loading…
Reference in New Issue