Fix issue when exporting to docx/pdf
This commit is contained in:
parent
cb1d7b5340
commit
524cededb6
|
@ -1181,8 +1181,14 @@ public class DataManagementPlanManager {
|
||||||
.forEach(datasetEntity -> {
|
.forEach(datasetEntity -> {
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (datasetEntity.getProperties() != null) {
|
||||||
JSONObject jObject = new JSONObject(datasetEntity.getProperties());
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
properties = jObject.toMap();
|
try {
|
||||||
|
properties = objectMapper.readValue(datasetEntity.getProperties(), LinkedHashMap.class);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
/*JSONObject jObject = new JSONObject(datasetEntity.getProperties());
|
||||||
|
properties = jObject.toMap();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom style for the Dataset title.
|
// Custom style for the Dataset title.
|
||||||
|
|
|
@ -3,9 +3,7 @@ package eu.eudat.logic.services.forms;
|
||||||
import eu.eudat.models.data.user.components.commons.Rule;
|
import eu.eudat.models.data.user.components.commons.Rule;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/5/2018.
|
* Created by ikalyvas on 3/5/2018.
|
||||||
|
@ -23,6 +21,15 @@ public class VisibilityRuleServiceImpl implements VisibilityRuleService {
|
||||||
|
|
||||||
public void setProperties(Map<String, Object> properties) {
|
public void setProperties(Map<String, Object> properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
this.properties.entrySet().stream()
|
||||||
|
.filter(stringObjectEntry -> stringObjectEntry.getValue() instanceof String && ((String) stringObjectEntry.getValue()).startsWith("[") && ((String) stringObjectEntry.getValue()).endsWith("]")).forEach(stringObjectEntry -> {
|
||||||
|
stringObjectEntry.setValue(parseArray((String) stringObjectEntry.getValue()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> parseArray(String original) {
|
||||||
|
String parsed = original.replace("[", "").replace("\"", "").replace("]", "");
|
||||||
|
return Arrays.asList(parsed.split(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildVisibilityContext(List<Rule> sources) {
|
public void buildVisibilityContext(List<Rule> sources) {
|
||||||
|
@ -34,12 +41,19 @@ public class VisibilityRuleServiceImpl implements VisibilityRuleService {
|
||||||
private void evaluateVisibility(VisibilityRule rule) {
|
private void evaluateVisibility(VisibilityRule rule) {
|
||||||
List<VisibilityRuleSource> sources = rule.getVisibilityRuleSources();
|
List<VisibilityRuleSource> sources = rule.getVisibilityRuleSources();
|
||||||
for(int i = 0; i < sources.size(); i++){
|
for(int i = 0; i < sources.size(); i++){
|
||||||
if (!properties.containsKey(sources.get(i).getVisibilityRuleSourceId()) || !properties.get(sources.get(i).getVisibilityRuleSourceId()).equals(sources.get(i).getVisibilityRuleSourceValue())) {
|
if (properties.containsKey(sources.get(i).getVisibilityRuleSourceId()) && (isContained(properties.get(sources.get(i).getVisibilityRuleSourceId()), sources.get(i).getVisibilityRuleSourceValue()) || properties.get(sources.get(i).getVisibilityRuleSourceId()).equals(sources.get(i).getVisibilityRuleSourceValue()))) {
|
||||||
|
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), true);
|
||||||
|
}else{
|
||||||
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), false);
|
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), false);
|
||||||
return;
|
return;
|
||||||
}else{
|
|
||||||
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Boolean isContained(Object values, String source) {
|
||||||
|
if (values instanceof List) {
|
||||||
|
return ((Collection<?>) values).contains(source);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,11 +225,13 @@ public class WordBuilder {
|
||||||
if (visibilityRuleService.isElementVisible(field.getId())) {
|
if (visibilityRuleService.isElementVisible(field.getId())) {
|
||||||
if (!createListing) {
|
if (!createListing) {
|
||||||
try {
|
try {
|
||||||
XWPFParagraph paragraph = addParagraphContent(this.formatter(field), mainDocumentPart, ParagraphStyle.TEXT, numId);
|
if (field.getValue() != null && !field.getValue().toString().isEmpty()) {
|
||||||
if (paragraph != null) {
|
XWPFParagraph paragraph = addParagraphContent(this.formatter(field), mainDocumentPart, ParagraphStyle.TEXT, numId);
|
||||||
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
if (paragraph != null) {
|
||||||
number.setVal(BigInteger.valueOf(indent));
|
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||||
hasValue = true;
|
number.setVal(BigInteger.valueOf(indent));
|
||||||
|
hasValue = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
|
Loading…
Reference in New Issue