1. export redesign: multiplicity #ref 7834, multiple select #ref 7836

2. fix bug in license api export
This commit is contained in:
Bernaldo Mihasi 2022-06-08 16:27:47 +03:00
parent 3433f58506
commit 73be5d9a98
3 changed files with 61 additions and 46 deletions

View File

@ -167,7 +167,16 @@ public class PrefillingMapper {
List<LicenseModel> licenses = licenseManager.getLicenses("", ""); List<LicenseModel> licenses = licenseManager.getLicenses("", "");
String finalParsedValue = parsedValue; String finalParsedValue = parsedValue;
licenses = licenses.stream().filter(license -> license.getPid().equals(finalParsedValue)).collect(Collectors.toList()); licenses = licenses.stream().filter(license -> license.getPid().equals(finalParsedValue)).collect(Collectors.toList());
properties.put(id, licenses); boolean isMultiAutocomplete = node.isArray() ? node.get(0).get("data").get("multiAutoComplete").booleanValue() : node.get("data").get("multiAutoComplete").booleanValue();
if(isMultiAutocomplete){
List<String> lic = new ArrayList<>();
for(LicenseModel license: licenses){
lic.add(mapper.writeValueAsString(license));
}
properties.put(id, mapper.writeValueAsString(lic));
} else {
properties.put(id, mapper.writeValueAsString(licenses.get(0)));
}
} }
catch (NoURLFound | HugeResultSet e){ catch (NoURLFound | HugeResultSet e){
properties.put(id, parsedValue); properties.put(id, parsedValue);

View File

@ -279,6 +279,7 @@ public class WordBuilder {
for (FieldSet compositeField: compositeFields) { for (FieldSet compositeField: compositeFields) {
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) { if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
char c = 'a'; char c = 'a';
boolean hasMultiplicityItems = false;
int paragraphPos = -1; int paragraphPos = -1;
if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) { if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) {
XWPFParagraph paragraph = addParagraphContent(page + "." + section + "." + (compositeField.getOrdinal() +1) + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER6, numId); XWPFParagraph paragraph = addParagraphContent(page + "." + section + "." + (compositeField.getOrdinal() +1) + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER6, numId);
@ -286,10 +287,11 @@ public class WordBuilder {
number.setVal(BigInteger.valueOf(indent)); number.setVal(BigInteger.valueOf(indent));
paragraphPos = mainDocumentPart.getPosOfParagraph(paragraph); paragraphPos = mainDocumentPart.getPosOfParagraph(paragraph);
if(compositeField.getMultiplicityItems() != null && !compositeField.getMultiplicityItems().isEmpty()){ if(compositeField.getMultiplicityItems() != null && !compositeField.getMultiplicityItems().isEmpty()){
addParagraphContent(c + ".\n", mainDocumentPart, ParagraphStyle.HEADER6, numId); addParagraphContent(c + ". ", mainDocumentPart, ParagraphStyle.HEADER6, numId);
hasMultiplicityItems = true;
} }
} }
hasValue = createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService); hasValue = createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService, hasMultiplicityItems);
if(hasValue){ if(hasValue){
returnedValue = true; returnedValue = true;
} }
@ -298,9 +300,10 @@ public class WordBuilder {
for (FieldSet multiplicityFieldset : list) { for (FieldSet multiplicityFieldset : list) {
if(!createListing){ if(!createListing){
c++; c++;
addParagraphContent(c + ".\n", mainDocumentPart, ParagraphStyle.HEADER6, numId); addParagraphContent(c + ". ", mainDocumentPart, ParagraphStyle.HEADER6, numId);
hasMultiplicityItems = true;
} }
hasValue = createFields(multiplicityFieldset.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService); hasValue = createFields(multiplicityFieldset.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService, hasMultiplicityItems);
if(hasValue){ if(hasValue){
returnedValue = true; returnedValue = true;
} }
@ -319,19 +322,10 @@ public class WordBuilder {
return returnedValue; return returnedValue;
} }
private Boolean createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) { private Boolean createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService, boolean hasMultiplicityItems) {
if (createListing) this.addListing(mainDocumentPart, indent, false, false); if (createListing) this.addListing(mainDocumentPart, indent, false, false);
boolean hasValue = false; boolean hasValue = false;
List<Field> tempFields = fields.stream().sorted(Comparator.comparingInt(Field::getOrdinal)).collect(Collectors.toList()); List<Field> tempFields = fields.stream().sorted(Comparator.comparingInt(Field::getOrdinal)).collect(Collectors.toList());
List<Field> formats = tempFields.stream().filter(f -> {
try {
String fTemp = this.formatter(f);
return fTemp != null && !fTemp.isEmpty();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return false;
}).collect(Collectors.toList());
for (Field field: tempFields) { for (Field field: tempFields) {
if (visibilityRuleService.isElementVisible(field.getId()) && field.getExport()) { if (visibilityRuleService.isElementVisible(field.getId()) && field.getExport()) {
if (!createListing) { if (!createListing) {
@ -346,13 +340,16 @@ public class WordBuilder {
} }
} }
if(isImage){ if(isImage){
if (!field.getValue().toString().isEmpty()) { if (field.getValue() != null && !field.getValue().toString().isEmpty()) {
XWPFParagraph paragraph = addParagraphContent(mapper.convertValue(field.getValue(), Map.class), mainDocumentPart, ParagraphStyle.IMAGE, numId); XWPFParagraph paragraph = addParagraphContent(mapper.convertValue(field.getValue(), Map.class), mainDocumentPart, ParagraphStyle.IMAGE, numId);
if (paragraph != null) { if (paragraph != null) {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent)); number.setVal(BigInteger.valueOf(indent));
hasValue = true; hasValue = true;
} }
if(hasMultiplicityItems){
hasMultiplicityItems = false;
}
} }
} }
} }
@ -365,18 +362,45 @@ public class WordBuilder {
format = getCommaSeparatedFormatsFromJson(format, "label"); format = getCommaSeparatedFormatsFromJson(format, "label");
} }
if(format != null && !format.isEmpty()){ if(format != null && !format.isEmpty()){
if(format.charAt(0) == '['){ Object hasMultiAutoComplete = mapper.convertValue(field.getData(), Map.class).get("multiAutoComplete");
format = format.substring(1, format.length() - 1).replaceAll(",", ", "); boolean isMultiAutoComplete = hasMultiAutoComplete != null && (boolean)hasMultiAutoComplete;
} boolean arrayStringFormat = format.charAt(0) == '[';
if(formats.size() > 1){ if(arrayStringFormat || isMultiAutoComplete){
format = "\t• " + format; List<String> values = (arrayStringFormat) ? Arrays.asList(format.substring(1, format.length() - 1).split(",[ ]*")) : Arrays.asList(format.split(",[ ]*"));
if(values.size() > 1) {
for (String val : values) {
format = "" + val;
if(hasMultiplicityItems){
mainDocumentPart.getLastParagraph().createRun().setText(format);
hasMultiplicityItems = false;
}
else{
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId);
if (paragraph != null) {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent));
hasValue = true;
}
}
format = null;
}
}
else if(values.size() == 1){
format = values.get(0);
}
} }
} }
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId); if(hasMultiplicityItems){
if (paragraph != null) { mainDocumentPart.getLastParagraph().createRun().setText(format);
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); hasMultiplicityItems = false;
number.setVal(BigInteger.valueOf(indent)); }
hasValue = true; else{
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId);
if (paragraph != null) {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent));
hasValue = true;
}
} }
} }
} catch (IOException e) { } catch (IOException e) {

View File

@ -27,27 +27,9 @@
}, },
{ {
"enabled": false, "enabled": false,
"type": "", "type": "saml2",
"configurableLoginId": "", "configurableLoginId": "",
"name": "", "name": ""
"spEntityId": "",
"idpEntityId": "",
"idpUrl": "",
"idpArtifactUrl": "",
"idpMetadataUrl": "",
"assertionEncrypted": null,
"keyFormat": "",
"keyAlias": "",
"credentialPath": "",
"archivePassword": "",
"keyPassword": "",
"responseSigned": null,
"assertionSigned": null,
"usingFormat": "",
"configurableUserFromAttributes": null,
"attributeTypes": null,
"binding": "",
"logoUrl": ""
} }
] ]
} }