|
|
|
@ -5,10 +5,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
|
|
|
|
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
|
|
|
|
import eu.eudat.logic.utilities.interfaces.ApplierWithValue;
|
|
|
|
|
import eu.eudat.models.data.components.commons.datafield.CheckBoxData;
|
|
|
|
|
import eu.eudat.models.data.components.commons.datafield.ComboBoxData;
|
|
|
|
|
import eu.eudat.models.data.components.commons.datafield.UploadData;
|
|
|
|
|
import eu.eudat.models.data.components.commons.datafield.WordListData;
|
|
|
|
|
import eu.eudat.logic.utilities.json.JavaToJson;
|
|
|
|
|
import eu.eudat.models.data.components.commons.datafield.*;
|
|
|
|
|
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
|
|
|
|
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
|
|
|
|
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
|
|
|
@ -17,13 +15,13 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
|
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
|
import org.apache.poi.util.Units;
|
|
|
|
|
import org.apache.poi.xwpf.usermodel.*;
|
|
|
|
|
import org.json.JSONArray;
|
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.imageio.ImageReader;
|
|
|
|
@ -328,7 +326,7 @@ public class WordBuilder {
|
|
|
|
|
boolean isImage = false;
|
|
|
|
|
for(UploadData.Option type: ((UploadData)field.getData()).getTypes()){
|
|
|
|
|
String fileFormat = type.getValue();
|
|
|
|
|
if(fileFormat.equals(MediaType.IMAGE_JPEG_VALUE) || fileFormat.equals(MediaType.IMAGE_PNG_VALUE) || fileFormat.equals(MediaType.IMAGE_GIF_VALUE)){
|
|
|
|
|
if(IMAGE_TYPE_MAP.containsKey(fileFormat)){
|
|
|
|
|
isImage = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -347,6 +345,11 @@ public class WordBuilder {
|
|
|
|
|
else if (field.getValue() != null && !field.getValue().toString().isEmpty()) {
|
|
|
|
|
this.indent = indent;
|
|
|
|
|
String format = this.formatter(field);
|
|
|
|
|
if (field.getViewStyle().getRenderStyle().equals("tags")) {
|
|
|
|
|
format = getCommaSeparatedFormatsFromJson(format, "name");
|
|
|
|
|
} else if (field.getViewStyle().getRenderStyle().equals("combobox") && field.getData() instanceof AutoCompleteData) {
|
|
|
|
|
format = getCommaSeparatedFormatsFromJson(format, "label");
|
|
|
|
|
}
|
|
|
|
|
if(format != null && !format.isEmpty()){
|
|
|
|
|
if(format.charAt(0) == '['){
|
|
|
|
|
format = format.substring(1, format.length() - 1).replaceAll(",", ", ");
|
|
|
|
@ -371,6 +374,21 @@ public class WordBuilder {
|
|
|
|
|
return hasValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getCommaSeparatedFormatsFromJson(String format, String attribute){
|
|
|
|
|
if((format == null || format.isEmpty()) || (attribute == null || attribute.isEmpty())){
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
JSONArray array = new JSONArray(JavaToJson.objectStringToJson(format));
|
|
|
|
|
StringBuilder multipleFormats = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
|
|
|
multipleFormats.append(array.getJSONObject(i).getString(attribute)).append(", ");
|
|
|
|
|
}
|
|
|
|
|
if (multipleFormats.length() > 0) {
|
|
|
|
|
multipleFormats.setLength(multipleFormats.length() - 2);
|
|
|
|
|
}
|
|
|
|
|
return multipleFormats.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public XWPFParagraph addParagraphContent(Object content, XWPFDocument mainDocumentPart, ParagraphStyle style, BigInteger numId) {
|
|
|
|
|
if (content != null) {
|
|
|
|
|
if (content instanceof String && ((String)content).isEmpty()) {
|
|
|
|
|