parent
536ba9b900
commit
65cdb3b6ea
|
@ -1537,7 +1537,7 @@ public class DataManagementPlanManager {
|
||||||
.sorted(Comparator.comparing(Dataset::getCreated)).collect(Collectors.toList());
|
.sorted(Comparator.comparing(Dataset::getCreated)).collect(Collectors.toList());
|
||||||
|
|
||||||
if (datasets.size() > 0)
|
if (datasets.size() > 0)
|
||||||
wordBuilder.addParagraphContent("Section descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
wordBuilder.addParagraphContent("Descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
||||||
for (Dataset datasetEntity : datasets) {
|
for (Dataset datasetEntity : datasets) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -1559,7 +1559,7 @@ public class DataManagementPlanManager {
|
||||||
datasetDescriptionParagraph.setStyle("Heading4");
|
datasetDescriptionParagraph.setStyle("Heading4");
|
||||||
datasetDescriptionParagraph.setSpacingBetween(1.5);
|
datasetDescriptionParagraph.setSpacingBetween(1.5);
|
||||||
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
|
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
|
||||||
datasetDescriptionRun.setText("Description");
|
datasetDescriptionRun.setText(datasetEntity.getLabel());
|
||||||
//datasetDescriptionRun.setColor("2E75B6");
|
//datasetDescriptionRun.setColor("2E75B6");
|
||||||
//datasetDescriptionRun.setBold(true);
|
//datasetDescriptionRun.setBold(true);
|
||||||
datasetDescriptionRun.setFontSize(15);
|
datasetDescriptionRun.setFontSize(15);
|
||||||
|
@ -1567,24 +1567,24 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
// Custom style for the Dataset title.
|
// Custom style for the Dataset title.
|
||||||
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||||
XWPFParagraph datasetLabelParagraph = document.createParagraph();
|
// XWPFParagraph datasetLabelParagraph = document.createParagraph();
|
||||||
// datasetLabelParagraph.setStyle("Heading2");
|
//// datasetLabelParagraph.setStyle("Heading2");
|
||||||
datasetLabelParagraph.setSpacingBetween(1.0);
|
// datasetLabelParagraph.setSpacingBetween(1.0);
|
||||||
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
// XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
||||||
runDatasetTitle1.setText("Title: ");
|
// runDatasetTitle1.setText("Title: ");
|
||||||
runDatasetTitle1.setColor("000000");
|
// runDatasetTitle1.setColor("000000");
|
||||||
//runDatasetTitle1.setBold(true);
|
// //runDatasetTitle1.setBold(true);
|
||||||
//runDatasetTitle1.setFontSize(12);
|
// //runDatasetTitle1.setFontSize(12);
|
||||||
XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
|
// XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
|
||||||
runDatasetTitle.setText(datasetEntity.getLabel());
|
// runDatasetTitle.setText(datasetEntity.getLabel());
|
||||||
runDatasetTitle.setColor("116a78");
|
// runDatasetTitle.setColor("116a78");
|
||||||
//runDatasetTitle.setBold(true);
|
//runDatasetTitle.setBold(true);
|
||||||
//runDatasetTitle.setFontSize(12);
|
//runDatasetTitle.setFontSize(12);
|
||||||
|
|
||||||
XWPFParagraph descriptionParagraph = document.createParagraph();
|
XWPFParagraph descriptionParagraph = document.createParagraph();
|
||||||
XWPFRun descriptionParagraphRun = descriptionParagraph.createRun();
|
// XWPFRun descriptionParagraphRun = descriptionParagraph.createRun();
|
||||||
descriptionParagraphRun.setText("Description: ");
|
// descriptionParagraphRun.setText("Description: ");
|
||||||
descriptionParagraphRun.setColor("000000");
|
// descriptionParagraphRun.setColor("000000");
|
||||||
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
|
|
||||||
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
import org.apache.poi.xwpf.usermodel.*;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
import org.apache.xmlbeans.XmlCursor;
|
import org.apache.xmlbeans.XmlCursor;
|
||||||
|
import org.apache.xmlbeans.XmlObject;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
@ -1019,32 +1020,15 @@ public class WordBuilder {
|
||||||
int descrParPos = -1;
|
int descrParPos = -1;
|
||||||
XWPFParagraph descrPar = null;
|
XWPFParagraph descrPar = null;
|
||||||
for(XWPFParagraph p: document.getParagraphs()){
|
for(XWPFParagraph p: document.getParagraphs()){
|
||||||
List<XWPFRun> runs = p.getRuns();
|
|
||||||
if(runs != null){
|
if( dmpEntity != null) {
|
||||||
for(XWPFRun r : runs){
|
this.replaceTextSegment(p, "'{ARGOS.DMP.TITLE}'", dmpEntity.getLabel());
|
||||||
String text = r.getText(0);
|
this.replaceTextSegment(p, "'{ARGOS.DMP.VERSION}'", "Version " + dmpEntity.getVersion());
|
||||||
if(text != null){
|
|
||||||
if(text.contains("{ARGOS.DMP.TITLE}")) {
|
|
||||||
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
} else if(text.contains("{ARGOS.DMP.VERSION}")) {
|
|
||||||
text = text.replace("{ARGOS.DMP.VERSION}", "Version " + dmpEntity.getVersion());
|
|
||||||
r.setText(text, 0);
|
|
||||||
} else if(datasetEntity != null && text.contains("{ARGOS.DATASET.TITLE}")) {
|
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
// } else if(text.equals("Description") && ((!isDataset && (dmpEntity == null || dmpEntity.getDescription() != null)) || (isDataset && (datasetEntity == null || datasetEntity.getDescription() == null)))) {
|
|
||||||
// r.setText("", 0);
|
|
||||||
} else if((dmpEntity != null && text.contains("{ARGOS.DMP.DESCRIPTION}") && !isDataset) || (datasetEntity != null && text.contains("{ARGOS.DATASET.DESCRIPTION}") && isDataset)) {
|
|
||||||
descrParPos = parPos;
|
|
||||||
descrPar = p;
|
|
||||||
if(dmpEntity != null && !isDataset) {
|
|
||||||
text = text.replace("{ARGOS.DMP.DESCRIPTION}", "");
|
|
||||||
} else if(datasetEntity != null && isDataset) {
|
|
||||||
text = text.replace("{ARGOS.DATASET.DESCRIPTION}", "");
|
|
||||||
}
|
}
|
||||||
r.setText(text, 0);
|
if( datasetEntity != null) {
|
||||||
} else if(text.equals("{ARGOS.DMP.RESEARCHERS}")) {
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", datasetEntity.getLabel());
|
||||||
|
}
|
||||||
|
|
||||||
String researchersNames = "";
|
String researchersNames = "";
|
||||||
Set<Researcher> researchers = dmpEntity.getResearchers();
|
Set<Researcher> researchers = dmpEntity.getResearchers();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -1052,27 +1036,30 @@ public class WordBuilder {
|
||||||
i++;
|
i++;
|
||||||
researchersNames += researcher.getLabel() + (i < researchers.size() ? ", " : "");
|
researchersNames += researcher.getLabel() + (i < researchers.size() ? ", " : "");
|
||||||
}
|
}
|
||||||
text = text.replace("{ARGOS.DMP.RESEARCHERS}", researchersNames);
|
this.replaceTextSegment(p, "'{ARGOS.DMP.RESEARCHERS}'", researchersNames, 15);
|
||||||
r.setText(text, 0);
|
|
||||||
r.setFontSize(17);
|
|
||||||
} else if(text.equals("{ARGOS.DMP.ORGANIZATIONS}")) {
|
|
||||||
String organisationsNames = "";
|
String organisationsNames = "";
|
||||||
Set<Organisation> organisations = dmpEntity.getOrganisations();
|
Set<Organisation> organisations = dmpEntity.getOrganisations();
|
||||||
int i = 0;
|
i = 0;
|
||||||
for(Organisation organisation : organisations){
|
for(Organisation organisation : organisations){
|
||||||
i++;
|
i++;
|
||||||
organisationsNames += organisation.getLabel() + (i < organisations.size() ? ", " : "");
|
organisationsNames += organisation.getLabel() + (i < organisations.size() ? ", " : "");
|
||||||
}
|
}
|
||||||
text = text.replace("{ARGOS.DMP.ORGANIZATIONS}", organisationsNames);
|
this.replaceTextSegment(p, "'{ARGOS.DMP.ORGANIZATIONS}'", organisationsNames, 15);
|
||||||
r.setText(text, 0);
|
|
||||||
r.setFontSize(17);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parPos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DESCRIPTION}'", "dfdsfsdf");
|
||||||
|
|
||||||
|
if(this.textSegmentExists(p,"'{ARGOS.DMP.DESCRIPTION}'")) {
|
||||||
|
descrParPos = parPos;
|
||||||
|
descrPar = p;
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DESCRIPTION}'", "");
|
||||||
|
}
|
||||||
|
if(this.textSegmentExists(p,"'{ARGOS.DATASET.DESCRIPTION}'")) {
|
||||||
|
descrParPos = parPos;
|
||||||
|
descrPar = p;
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.DESCRIPTION}'", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
if((descrParPos != -1) && (dmpEntity!=null) && (dmpEntity.getDescription() != null) && !isDataset) {
|
if((descrParPos != -1) && (dmpEntity!=null) && (dmpEntity.getDescription() != null) && !isDataset) {
|
||||||
XmlCursor cursor = descrPar.getCTP().newCursor();
|
XmlCursor cursor = descrPar.getCTP().newCursor();
|
||||||
cursor.toNextSibling();
|
cursor.toNextSibling();
|
||||||
|
@ -1096,7 +1083,7 @@ public class WordBuilder {
|
||||||
XWPFParagraph p = it.next().getCell(0).getParagraphs().get(0);
|
XWPFParagraph p = it.next().getCell(0).getParagraphs().get(0);
|
||||||
XWPFRun run = p.createRun();
|
XWPFRun run = p.createRun();
|
||||||
run.setText(dmpEntity.getGrant().getFunder().getLabel());
|
run.setText(dmpEntity.getGrant().getFunder().getLabel());
|
||||||
run.setFontSize(17);
|
run.setFontSize(15);
|
||||||
p.setAlignment(ParagraphAlignment.CENTER);
|
p.setAlignment(ParagraphAlignment.CENTER);
|
||||||
}
|
}
|
||||||
it = tbl.getRows().iterator();
|
it = tbl.getRows().iterator();
|
||||||
|
@ -1111,7 +1098,7 @@ public class WordBuilder {
|
||||||
text += parts.length > 1 ? "/ No "+parts[parts.length - 1] : "";
|
text += parts.length > 1 ? "/ No "+parts[parts.length - 1] : "";
|
||||||
}
|
}
|
||||||
run.setText(text);
|
run.setText(text);
|
||||||
run.setFontSize(17);
|
run.setFontSize(15);
|
||||||
p.setAlignment(ParagraphAlignment.CENTER);
|
p.setAlignment(ParagraphAlignment.CENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1119,43 +1106,165 @@ public class WordBuilder {
|
||||||
public void fillFooter(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
|
public void fillFooter(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
|
||||||
document.getFooterList().forEach(xwpfFooter -> {
|
document.getFooterList().forEach(xwpfFooter -> {
|
||||||
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
||||||
if(runs != null){
|
for(XWPFParagraph p : xwpfFooter.getParagraphs()){
|
||||||
for(XWPFRun r : runs){
|
if(p != null){
|
||||||
String text = r.getText(0);
|
if( dmpEntity != null) {
|
||||||
if(text != null){
|
this.replaceTextSegment(p, "'{ARGOS.DMP.TITLE}'", dmpEntity.getLabel());
|
||||||
if(text.contains("{ARGOS.DMP.TITLE}")){
|
|
||||||
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DATASET.TITLE}") && datasetEntity != null){
|
if( datasetEntity != null) {
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", datasetEntity.getLabel());
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DMP.LICENSE}")){
|
Map<String, String> license = null;
|
||||||
try{
|
try {
|
||||||
Map<String, String> license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
||||||
text = text.replace("{ARGOS.DMP.LICENSE}", license.get("pid"));
|
if (license != null && license.get("pid") != null) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", license.get("pid"));
|
||||||
|
} else {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", "License: -");
|
||||||
}
|
}
|
||||||
catch (JsonProcessingException | NullPointerException e){
|
} catch (JsonProcessingException e) {
|
||||||
text = text.replace("{ARGOS.DMP.LICENSE}", "License: -");
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", "License: -");
|
||||||
}
|
}
|
||||||
r.setText(text, 0);
|
if(dmpEntity.getDois() != null && !dmpEntity.getDois().isEmpty()) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DOI}'", dmpEntity.getDois().iterator().next().getDoi());
|
||||||
|
} else {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DOI}'", "-");
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DMP.DOI}")){
|
|
||||||
if(dmpEntity.getDois() != null && !dmpEntity.getDois().isEmpty())
|
|
||||||
text = text.replace("{ARGOS.DMP.DOI}", dmpEntity.getDois().iterator().next().getDoi());
|
|
||||||
else
|
|
||||||
text = text.replace("{ARGOS.DMP.DOI}", "-");
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
if(text.contains("{ARGOS.DMP.LAST_MODIFIED}")){
|
|
||||||
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
text = text.replace("{ARGOS.DMP.LAST_MODIFIED}", formatter.format(dmpEntity.getModified()));
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LAST_MODIFIED}'", formatter.format(dmpEntity.getModified()));
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean textSegmentExists(XWPFParagraph paragraph, String textToFind) {
|
||||||
|
TextSegment foundTextSegment = null;
|
||||||
|
PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);
|
||||||
|
while((foundTextSegment = this.searchText(paragraph, textToFind, startPos)) != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceTextSegment(XWPFParagraph paragraph, String textToFind, String replacement) {
|
||||||
|
this.replaceTextSegment(paragraph, textToFind, replacement, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceTextSegment(XWPFParagraph paragraph, String textToFind, String replacement, Integer fontSize) {
|
||||||
|
TextSegment foundTextSegment = null;
|
||||||
|
PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);
|
||||||
|
while((foundTextSegment = this.searchText(paragraph, textToFind, startPos)) != null) { // search all text segments having text to find
|
||||||
|
|
||||||
|
System.out.println(foundTextSegment.getBeginRun()+":"+foundTextSegment.getBeginText()+":"+foundTextSegment.getBeginChar());
|
||||||
|
System.out.println(foundTextSegment.getEndRun()+":"+foundTextSegment.getEndText()+":"+foundTextSegment.getEndChar());
|
||||||
|
|
||||||
|
// maybe there is text before textToFind in begin run
|
||||||
|
XWPFRun beginRun = paragraph.getRuns().get(foundTextSegment.getBeginRun());
|
||||||
|
String textInBeginRun = beginRun.getText(foundTextSegment.getBeginText());
|
||||||
|
String textBefore = textInBeginRun.substring(0, foundTextSegment.getBeginChar()); // we only need the text before
|
||||||
|
|
||||||
|
// maybe there is text after textToFind in end run
|
||||||
|
XWPFRun endRun = paragraph.getRuns().get(foundTextSegment.getEndRun());
|
||||||
|
String textInEndRun = endRun.getText(foundTextSegment.getEndText());
|
||||||
|
String textAfter = textInEndRun.substring(foundTextSegment.getEndChar() + 1); // we only need the text after
|
||||||
|
|
||||||
|
if (foundTextSegment.getEndRun() == foundTextSegment.getBeginRun()) {
|
||||||
|
textInBeginRun = textBefore + replacement + textAfter; // if we have only one run, we need the text before, then the replacement, then the text after in that run
|
||||||
|
} else {
|
||||||
|
textInBeginRun = textBefore + replacement; // else we need the text before followed by the replacement in begin run
|
||||||
|
endRun.setText(textAfter, foundTextSegment.getEndText()); // and the text after in end run
|
||||||
|
}
|
||||||
|
|
||||||
|
beginRun.setText(textInBeginRun, foundTextSegment.getBeginText());
|
||||||
|
if (fontSize != null) {
|
||||||
|
beginRun.setFontSize(fontSize);
|
||||||
|
}
|
||||||
|
// runs between begin run and end run needs to be removed
|
||||||
|
for (int runBetween = foundTextSegment.getEndRun() - 1; runBetween > foundTextSegment.getBeginRun(); runBetween--) {
|
||||||
|
paragraph.removeRun(runBetween); // remove not needed runs
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this methods parse the paragraph and search for the string searched.
|
||||||
|
* If it finds the string, it will return true and the position of the String
|
||||||
|
* will be saved in the parameter startPos.
|
||||||
|
*
|
||||||
|
* @param searched
|
||||||
|
* @param startPos
|
||||||
|
*/
|
||||||
|
private TextSegment searchText(XWPFParagraph paragraph, String searched, PositionInParagraph startPos) {
|
||||||
|
int startRun = startPos.getRun(),
|
||||||
|
startText = startPos.getText(),
|
||||||
|
startChar = startPos.getChar();
|
||||||
|
int beginRunPos = 0, candCharPos = 0;
|
||||||
|
boolean newList = false;
|
||||||
|
|
||||||
|
//CTR[] rArray = paragraph.getRArray(); //This does not contain all runs. It lacks hyperlink runs for ex.
|
||||||
|
java.util.List<XWPFRun> runs = paragraph.getRuns();
|
||||||
|
|
||||||
|
int beginTextPos = 0, beginCharPos = 0; //must be outside the for loop
|
||||||
|
|
||||||
|
//for (int runPos = startRun; runPos < rArray.length; runPos++) {
|
||||||
|
for (int runPos = startRun; runPos < runs.size(); runPos++) {
|
||||||
|
//int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos; //int beginTextPos = 0, beginCharPos = 0 must be outside the for loop
|
||||||
|
int textPos = 0, charPos;
|
||||||
|
//CTR ctRun = rArray[runPos];
|
||||||
|
CTR ctRun = runs.get(runPos).getCTR();
|
||||||
|
XmlCursor c = ctRun.newCursor();
|
||||||
|
c.selectPath("./*");
|
||||||
|
try {
|
||||||
|
while (c.toNextSelection()) {
|
||||||
|
XmlObject o = c.getObject();
|
||||||
|
if (o instanceof CTText) {
|
||||||
|
if (textPos >= startText) {
|
||||||
|
String candidate = ((CTText) o).getStringValue();
|
||||||
|
if (runPos == startRun) {
|
||||||
|
charPos = startChar;
|
||||||
|
} else {
|
||||||
|
charPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; charPos < candidate.length(); charPos++) {
|
||||||
|
if ((candidate.charAt(charPos) == searched.charAt(0)) && (candCharPos == 0)) {
|
||||||
|
beginTextPos = textPos;
|
||||||
|
beginCharPos = charPos;
|
||||||
|
beginRunPos = runPos;
|
||||||
|
newList = true;
|
||||||
|
}
|
||||||
|
if (candidate.charAt(charPos) == searched.charAt(candCharPos)) {
|
||||||
|
if (candCharPos + 1 < searched.length()) {
|
||||||
|
candCharPos++;
|
||||||
|
} else if (newList) {
|
||||||
|
TextSegment segment = new TextSegment();
|
||||||
|
segment.setBeginRun(beginRunPos);
|
||||||
|
segment.setBeginText(beginTextPos);
|
||||||
|
segment.setBeginChar(beginCharPos);
|
||||||
|
segment.setEndRun(runPos);
|
||||||
|
segment.setEndText(textPos);
|
||||||
|
segment.setEndChar(charPos);
|
||||||
|
return segment;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
candCharPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textPos++;
|
||||||
|
} else if (o instanceof CTProofErr) {
|
||||||
|
c.removeXml();
|
||||||
|
} else if (o instanceof CTRPr) {
|
||||||
|
//do nothing
|
||||||
|
} else {
|
||||||
|
candCharPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
c.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -364,7 +364,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
|
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
|
||||||
this.lockStatus = lockStatus;
|
this.lockStatus = lockStatus;
|
||||||
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
||||||
this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex;
|
|
||||||
this.datasetWizardModel.status = 0;
|
this.datasetWizardModel.status = 0;
|
||||||
this.formGroup = this.datasetWizardModel.buildForm();
|
this.formGroup = this.datasetWizardModel.buildForm();
|
||||||
this.formGroup.get('id').setValue(null);
|
this.formGroup.get('id').setValue(null);
|
||||||
|
@ -375,6 +374,10 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
this.datasetWizardModel.dmp = data;
|
this.datasetWizardModel.dmp = data;
|
||||||
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
|
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
|
||||||
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
||||||
|
const descipptionTemplateiNNewDmp:DmpDatasetProfile = this.datasetWizardModel.dmp?.profiles?.find(x => x.descriptionTemplateId === this.datasetWizardModel.profile.id);
|
||||||
|
|
||||||
|
this.dmpSectionIndex = descipptionTemplateiNNewDmp?.data?.dmpSectionIndex?.length > 0 ? descipptionTemplateiNNewDmp?.data?.dmpSectionIndex[0] : 0;
|
||||||
|
this.formGroup.get('dmpSectionIndex').setValue(this.dmpSectionIndex);
|
||||||
|
|
||||||
this.loadDatasetProfiles();
|
this.loadDatasetProfiles();
|
||||||
this.breadCrumbs = observableOf([
|
this.breadCrumbs = observableOf([
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
<div *ngIf="field.category === 'SYSTEM'">
|
<div *ngIf="field.category === 'SYSTEM'">
|
||||||
<div *ngIf="field.type == 0">
|
<div *ngIf="field.type == 0">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" [formControl]="formGroup.get('label')" required>
|
<input matInput placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.NAME' | translate)}}" type="text" name="label" [formControl]="formGroup.get('label')" required>
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
||||||
{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">
|
<mat-error *ngIf="formGroup.get('label').hasError('required')">
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 1">
|
<div *ngIf="field.type == 1">
|
||||||
<rich-text-editor-component [parentFormGroup]="formGroup" [controlName]="'description'"
|
<rich-text-editor-component [parentFormGroup]="formGroup" [controlName]="'description'"
|
||||||
[placeholder]="'DMP-EDITOR.PLACEHOLDER.DESCRIPTION'" [required]="field.required">
|
[placeholder]="field?.placeholder?.length > 0 ? field.placeholder : 'DMP-EDITOR.PLACEHOLDER.DESCRIPTION'" [required]="field.required">
|
||||||
</rich-text-editor-component>
|
</rich-text-editor-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 2">
|
<div *ngIf="field.type == 2">
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 4">
|
<div *ngIf="field.type == 4">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}" required>
|
<mat-select [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.LANGUAGE' | translate)}}" required>
|
||||||
<mat-option *ngFor="let lang of getLanguageInfos()" [value]="lang.code">
|
<mat-option *ngFor="let lang of getLanguageInfos()" [value]="lang.code">
|
||||||
{{ lang.name }}
|
{{ lang.name }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@ -205,7 +205,7 @@
|
||||||
<div *ngIf="field.type == 5">
|
<div *ngIf="field.type == 5">
|
||||||
<div class="contact-form">
|
<div class="contact-form">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('contact')" placeholder="{{'DMP-EDITOR.FIELDS.CONTACT' | translate}}">
|
<mat-select [formControl]="formGroup.get('extraProperties').get('contact')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.CONTACT' | translate)}}">
|
||||||
<mat-option *ngFor="let vis of getAssociates()" [value]="vis.id">
|
<mat-option *ngFor="let vis of getAssociates()" [value]="vis.id">
|
||||||
{{vis.name | translate}}
|
{{vis.name | translate}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@ -218,17 +218,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 6">
|
<div *ngIf="field.type == 6">
|
||||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="1" (onFormChanged)="formChanged()"></funding-info>
|
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [field]="field" [type]="1" (onFormChanged)="formChanged()"></funding-info>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 7">
|
<div *ngIf="field.type == 7">
|
||||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="2" (onFormChanged)="formChanged()"></funding-info>
|
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [field]="field" [type]="2" (onFormChanged)="formChanged()"></funding-info>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 8">
|
<div *ngIf="field.type == 8">
|
||||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="3" (onFormChanged)="formChanged()"></funding-info>
|
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [field]="field" [type]="3" (onFormChanged)="formChanged()"></funding-info>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 9">
|
<div *ngIf="field.type == 9">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<app-single-auto-complete [formControl]="formGroup.get('extraProperties').get('license')" placeholder="{{'DMP-EDITOR.FIELDS.LICENSE' | translate}}" [configuration]="licenseAutoCompleteConfiguration">
|
<app-single-auto-complete [formControl]="formGroup.get('extraProperties').get('license')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.LICENSE' | translate)}}" [configuration]="licenseAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('backendError')">
|
||||||
{{formGroup.get('extraProperties').get('license').getError('backendError').message}}</mat-error>
|
{{formGroup.get('extraProperties').get('license').getError('backendError').message}}</mat-error>
|
||||||
|
@ -238,7 +238,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 10">
|
<div *ngIf="field.type == 10">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('visible')" placeholder="{{'DMP-EDITOR.FIELDS.VISIBILITY' | translate}}">
|
<mat-select [formControl]="formGroup.get('extraProperties').get('visible')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.VISIBILITY' | translate)}}">
|
||||||
<mat-option *ngFor="let vis of visibles" [value]="vis.value">
|
<mat-option *ngFor="let vis of visibles" [value]="vis.value">
|
||||||
{{vis.name | translate}}
|
{{vis.name | translate}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@ -309,7 +309,7 @@
|
||||||
<div class="heading">Description templates</div>
|
<div class="heading">Description templates</div>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}</mat-label>
|
<mat-label>{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}</mat-label>
|
||||||
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}" [hidePlaceholder]="true" required='true' [value]="sectionTemplates[section.ordinal - 1]" [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, i)" (optionActionClicked)="onPreviewTemplate($event, i)" (optionSelected)="onOptionSelected($event, i)">
|
<app-multiple-auto-complete placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate)}}" [hidePlaceholder]="true" required='true' [value]="sectionTemplates[section.ordinal - 1]" [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, i)" (optionActionClicked)="onPreviewTemplate($event, i)" (optionSelected)="onOptionSelected($event, i)">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
|
||||||
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>
|
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="funder-form" *ngIf="type == 1">
|
<div class="funder-form" *ngIf="type == 1">
|
||||||
<div *ngIf="!isCreateNewFunder">
|
<div *ngIf="!isCreateNewFunder">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<app-single-auto-complete [required]="isRequired" [formControl]="funderFormGroup.get('existFunder')" placeholder="{{'DMP-EDITOR.FIELDS.FUNDER' | translate}}" [configuration]="funderAutoCompleteConfiguration">
|
<app-single-auto-complete [required]="isRequired" [formControl]="funderFormGroup.get('existFunder')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.FUNDER' | translate)}}" [configuration]="funderAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<div class="grant-form" *ngIf="type == 2">
|
<div class="grant-form" *ngIf="type == 2">
|
||||||
<div *ngIf="!isCreateNew">
|
<div *ngIf="!isCreateNew">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<app-single-auto-complete [required]="isRequired" [formControl]="grantformGroup.get('existGrant')" placeholder="{{'DMP-EDITOR.FIELDS.GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration">
|
<app-single-auto-complete [required]="isRequired" [formControl]="grantformGroup.get('existGrant')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.GRANT' | translate)}}" [configuration]="grantAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
<div class="project-form" *ngIf="type == 3">
|
<div class="project-form" *ngIf="type == 3">
|
||||||
<div *ngIf="!isCreateNewProject">
|
<div *ngIf="!isCreateNewProject">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<app-single-auto-complete [formControl]="projectFormGroup.get('existProject')" placeholder="{{'DMP-EDITOR.FIELDS.PROJECT' | translate}}" [configuration]="projectAutoCompleteConfiguration" [required]="isRequired">
|
<app-single-auto-complete [formControl]="projectFormGroup.get('existProject')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.PROJECT' | translate)}}" [configuration]="projectAutoCompleteConfiguration" [required]="isRequired">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { FunderCriteria } from '@app/core/query/funder/funder-criteria';
|
||||||
import { debounceTime, filter, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
import { debounceTime, filter, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { isNullOrUndefined } from '@swimlane/ngx-datatable';
|
import { isNullOrUndefined } from '@swimlane/ngx-datatable';
|
||||||
|
import { FieldInSection } from '@app/core/model/dmp/dmp-blueprint/dmp-blueprint';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'funding-info',
|
selector: 'funding-info',
|
||||||
templateUrl: './funding-info.component.html',
|
templateUrl: './funding-info.component.html',
|
||||||
|
@ -30,6 +31,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
@Input() isRequired: boolean;
|
@Input() isRequired: boolean;
|
||||||
@Input() type: number;
|
@Input() type: number;
|
||||||
|
@Input() field: FieldInSection;
|
||||||
|
|
||||||
@Input() formGroup: FormGroup;
|
@Input() formGroup: FormGroup;
|
||||||
@Input() grantformGroup: FormGroup;
|
@Input() grantformGroup: FormGroup;
|
||||||
|
|
Loading…
Reference in New Issue