DescriptionTemplate refactor
This commit is contained in:
parent
c37530c022
commit
08caf64d02
|
@ -7,6 +7,7 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -76,6 +77,15 @@ public class DefinitionEntity implements XmlSerializable<DefinitionEntity> {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<FieldEntity> getFieldById(String id){
|
||||
List<FieldEntity> fieldEntities = new ArrayList<>();
|
||||
if (id == null || id.isBlank()) return fieldEntities;
|
||||
if (this.getSections() != null){
|
||||
for (SectionEntity sectionEntity: this.getSections()) {
|
||||
fieldEntities.addAll(sectionEntity.getFieldById(id));
|
||||
}
|
||||
}
|
||||
return fieldEntities;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -199,7 +199,8 @@ public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable
|
|||
Element defaultValue = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "defaultValue");
|
||||
|
||||
this.defaultValue = defaultValue.getAttribute("value");
|
||||
this.data = new FieldDataHelper().toFieldData(null, fieldType, dataElement);
|
||||
String subType = dataElement != null ? dataElement.getAttribute("type") : null;
|
||||
this.data = new FieldDataHelper().create(fieldType, subType);
|
||||
if (this.data != null) this.data.fromXml(dataElement);
|
||||
|
||||
this.validations = new LinkedList<>();
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -190,4 +191,10 @@ public class FieldSetEntity implements DatabaseViewStyleDefinition, XmlSerializa
|
|||
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<FieldEntity> getFieldById(String id){
|
||||
if (this.getFields() == null || id == null || id.isBlank()) return new ArrayList<>();
|
||||
|
||||
return this.getFields().stream().filter(x-> id.equals(x.getId())).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -208,5 +209,19 @@ public class SectionEntity implements DatabaseViewStyleDefinition, XmlSerializab
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
public List<FieldEntity> getFieldById(String id){
|
||||
List<FieldEntity> fieldEntities = new ArrayList<>();
|
||||
if (id == null || id.isBlank()) return fieldEntities;
|
||||
if (this.getFieldSets() != null){
|
||||
for (FieldSetEntity fieldSetEntity: this.getFieldSets()) {
|
||||
fieldEntities.addAll(fieldSetEntity.getFieldById(id));
|
||||
}
|
||||
}
|
||||
if (this.getSections() != null){
|
||||
for (SectionEntity sectionEntity: this.getSections()) {
|
||||
fieldEntities.addAll(sectionEntity.getFieldById(id));
|
||||
}
|
||||
}
|
||||
return fieldEntities;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,144 +231,6 @@ public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataE
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoCompleteDataEntity fromData(Object data) {
|
||||
super.fromData(data);
|
||||
this.autoCompleteSingleDataList = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
if (data != null) {
|
||||
this.multiAutoComplete = (Boolean) ((Map<Boolean, Object>) data).get("multiAutoComplete");
|
||||
|
||||
List<Map<String, Object>> dataList = (List<Map<String, Object>>) ((Map<String, Object>) data).get("autocompleteSingle");
|
||||
if (dataList == null) {
|
||||
dataList = (List<Map<String, Object>>) ((Map<String, Object>) data).get("autoCompleteSingleDataList");
|
||||
}
|
||||
|
||||
this.autoCompleteSingleDataList = new ArrayList<>();
|
||||
|
||||
int i = 0;
|
||||
for (Map<String, Object> singleData: dataList) {
|
||||
this.autoCompleteSingleDataList.add(new AutoCompleteSingleData());
|
||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions = new Option();
|
||||
this.autoCompleteSingleDataList.get(i).url = (String) singleData.get("url");
|
||||
this.autoCompleteSingleDataList.get(i).optionsRoot = (String) singleData.get("optionsRoot");
|
||||
this.autoCompleteSingleDataList.get(i).hasAuth = (Boolean) singleData.get("hasAuth");
|
||||
this.autoCompleteSingleDataList.get(i).method = singleData.containsKey("method") ? (String) singleData.get("method") : "GET";
|
||||
|
||||
if (singleData.get("autoCompleteType") == null) {
|
||||
this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.UNCACHED;
|
||||
} else {
|
||||
this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.of((Integer) singleData.get("autoCompleteType"));
|
||||
}
|
||||
Map<String, String> options = (Map<String, String>) singleData.get("autoCompleteOptions");
|
||||
if (options != null) {
|
||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setLabel(options.get("label"));
|
||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setValue(options.get("value"));
|
||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setSource(options.get("source"));
|
||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setUri(options.get("uri"));
|
||||
}
|
||||
if (this.autoCompleteSingleDataList.get(i).hasAuth) {
|
||||
Map<String, String> auth = (Map<String, String>) singleData.get("auth");
|
||||
if (auth != null) {
|
||||
this.autoCompleteSingleDataList.get(i).auth = new AuthAutoCompleteData();
|
||||
this.autoCompleteSingleDataList.get(i).auth.setUrl(auth.get("url"));
|
||||
this.autoCompleteSingleDataList.get(i).auth.setType(auth.get("type"));
|
||||
this.autoCompleteSingleDataList.get(i).auth.setPath(auth.get("path"));
|
||||
this.autoCompleteSingleDataList.get(i).auth.setBody(auth.get("body"));
|
||||
this.autoCompleteSingleDataList.get(i).auth.setMethod(auth.get("method"));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
//dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "autocomplete");
|
||||
dataMap.put("multiAutoComplete", item != null ? Boolean.valueOf(item.getAttribute("multiAutoComplete")) : false);
|
||||
List<Map<String, Object>> autoCompletes = new ArrayList<>();
|
||||
NodeList autoCompleteSingles = item.getChildNodes();
|
||||
for (int i = 0; i < autoCompleteSingles.getLength(); i++) {
|
||||
if (autoCompleteSingles.item(i) instanceof Element) {
|
||||
if (!((Element) autoCompleteSingles.item(i)).getTagName().equals("option")) {
|
||||
Element node = (Element) autoCompleteSingles.item(i);
|
||||
if (!node.hasChildNodes()) {
|
||||
node.appendChild(node);
|
||||
}
|
||||
|
||||
autoCompletes.add(singleToMap(node));
|
||||
} else {
|
||||
Element node = item.getOwnerDocument().createElement("autocompleteSingle");
|
||||
node.appendChild(autoCompleteSingles.item(i));
|
||||
node.setAttribute("url", item.getAttribute("url"));
|
||||
node.setAttribute("optionsRoot", item.getAttribute("optionsRoot"));
|
||||
node.setAttribute("hasAuth", item.getAttribute("hasAuth"));
|
||||
node.setAttribute("method", item.hasAttribute("method") ? item.getAttribute("method") : "GET");
|
||||
autoCompletes.add(singleToMap(node));
|
||||
}
|
||||
}
|
||||
}
|
||||
dataMap.put("autocompleteSingle", autoCompletes);
|
||||
//dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
|
||||
//Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
||||
// if (optionElement != null) {
|
||||
// this.autoCompleteOptions = new Option();
|
||||
// this.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
|
||||
// this.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
|
||||
// }
|
||||
// dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private Map<String, Object> optionToMap(Element item){
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("value", item != null ? item.getAttribute("value") : "");
|
||||
dataMap.put("source", item != null ? item.getAttribute("source") : "");
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private Map<String, Object> authToMap(Element item){
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
||||
dataMap.put("method", item != null ? item.getAttribute("method") : "");
|
||||
dataMap.put("body", item != null ? item.getAttribute("body") : "");
|
||||
dataMap.put("path", item != null ? item.getAttribute("path") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "");
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private Map<String, Object> singleToMap(Element item) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
if (!item.getAttribute("autoCompleteType").isEmpty()) {
|
||||
dataMap.put("autoCompleteType", Integer.parseInt(item.getAttribute("autoCompleteType")));
|
||||
}
|
||||
dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
|
||||
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
||||
dataMap.put("hasAuth", item != null ? item.getAttribute("hasAuth") : "false");
|
||||
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
||||
dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
|
||||
Element authElement = (Element) item.getElementsByTagName("auth").item(0);
|
||||
dataMap.put("auth", item != null ? authToMap(authElement) : null);
|
||||
dataMap.put("method", item != null && item.hasAttribute("method") ? item.getAttribute("method") : "GET");
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public enum AutocompleteType implements DatabaseEnum<Integer> {
|
||||
UNCACHED(0),
|
||||
CACHED(1);
|
||||
|
|
|
@ -20,16 +20,6 @@ public abstract class BaseFieldDataEntity<T> implements XmlSerializable<T> {
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
public T fromData(Object data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Element toXml(Document doc) {
|
||||
Element root = doc.createElement("data");
|
||||
root.setAttribute("label", this.getLabel());
|
||||
|
@ -41,6 +31,4 @@ public abstract class BaseFieldDataEntity<T> implements XmlSerializable<T> {
|
|||
this.setLabel(item.getAttribute("label"));
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public abstract Map<String, Object> toMap(Element item);
|
||||
}
|
||||
|
|
|
@ -13,26 +13,4 @@ public class BooleanDecisionDataEntity extends BaseFieldDataEntity<BooleanDecisi
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.BOOLEAN_DECISION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanDecisionDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,25 +13,4 @@ public class CheckBoxDataEntity extends BaseFieldDataEntity<CheckBoxDataEntity>
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.CHECK_BOX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckBoxDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,28 +80,4 @@ public abstract class ComboBoxDataEntity<T> extends BaseFieldDataEntity<T> {
|
|||
super.fromXml(item);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromData(Object data) {
|
||||
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,24 +12,4 @@ public class CurrencyDataEntity extends BaseFieldDataEntity<CurrencyDataEntity>
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.CURRENCY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrencyDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,20 +23,6 @@ public class DataRepositoryDataEntity extends BaseFieldDataEntity<DataRepository
|
|||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataRepositoryDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -52,12 +38,4 @@ public class DataRepositoryDataEntity extends BaseFieldDataEntity<DataRepository
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,30 +44,4 @@ public class DatasetAutoCompleteDataEntity extends InternalDmpBaseDataEntity<Dat
|
|||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetAutoCompleteDataEntity fromData(Object data) {
|
||||
super.fromData(data);
|
||||
if (data != null) {
|
||||
this.multiAutoComplete = (Boolean) ((Map<Boolean, Object>) data).get("multiAutoComplete");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "datasets");
|
||||
dataMap.put("multiAutoComplete", item != null ? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false);
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,23 +12,4 @@ public class DatasetIdentifierDataEntity extends BaseFieldDataEntity<DatasetIden
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.DATASET_IDENTIFIER;
|
||||
}
|
||||
@Override
|
||||
public DatasetIdentifierDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,23 +12,4 @@ public class DatePickerDataEntity extends BaseFieldDataEntity<DatePickerDataEnti
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.DATE_PICKER;
|
||||
}
|
||||
@Override
|
||||
public DatePickerDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,30 +42,4 @@ public class DmpAutoCompleteDataEntity extends InternalDmpBaseDataEntity<DmpAuto
|
|||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DmpAutoCompleteDataEntity fromData(Object data) {
|
||||
super.fromData(data);
|
||||
if (data != null) {
|
||||
this.multiAutoComplete = (Boolean) ((Map<Boolean, Object>) data).get("multiAutoComplete");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "dmps");
|
||||
dataMap.put("multiAutoComplete", item != null ? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false);
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,21 +32,6 @@ public class ExternalDatasetDataEntity extends BaseFieldDataEntity<ExternalDatas
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalDatasetDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean( ((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
this.setType(((Map<String, Object>) data).get("type") != null && !((Map<String, Object>) data).get("type").toString().isEmpty()? FieldDataExternalDatasetType.of(((Map<String, Object>) data).get("type").toString()) : FieldDataExternalDatasetType.Other);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = doc.createElement("data");
|
||||
|
@ -67,13 +52,4 @@ public class ExternalDatasetDataEntity extends BaseFieldDataEntity<ExternalDatas
|
|||
this.setType(item.getAttribute("type") != null ? FieldDataExternalDatasetType.of(item.getAttribute("type")): FieldDataExternalDatasetType.Other);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false);
|
||||
dataMap.put("type", item != null && item.getAttributes().getLength() > 0? item.getAttribute("type") : "other");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,19 +66,4 @@ public class FieldDataHelper {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BaseFieldDataEntity<?> toFieldData(Object data, FieldType type, Element dataElement) {
|
||||
String subType = dataElement != null ? dataElement.getAttribute("type") : null;
|
||||
BaseFieldDataEntity<?> baseFieldData = this.create(type, subType);
|
||||
if (baseFieldData == null) return baseFieldData;
|
||||
return (BaseFieldDataEntity<?>) baseFieldData.fromData(data);
|
||||
}
|
||||
|
||||
public BaseFieldDataEntity<?> toFieldData(Object data, FieldType type) {
|
||||
Map<String, Object> dataAsMap = (Map<String, Object>) data;
|
||||
String subType = dataAsMap != null ? (String) dataAsMap.getOrDefault("type", null) : null;
|
||||
BaseFieldDataEntity<?> baseFieldData = this.create(type, subType);
|
||||
if (baseFieldData == null) return baseFieldData;
|
||||
return (BaseFieldDataEntity<?>) baseFieldData.fromData(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,24 +13,4 @@ public class FreeTextDataEntity extends BaseFieldDataEntity<FreeTextDataEntity>
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.FREE_TEXT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FreeTextDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel(((Map<String, String>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,29 +23,4 @@ public abstract class InternalDmpBaseDataEntity<T> extends BaseFieldDataEntity<T
|
|||
super.fromXml(item);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromData(Object data) {
|
||||
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "researchers");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,20 +23,6 @@ public class JournalRepositoryDataEntity extends BaseFieldDataEntity<JournalRepo
|
|||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JournalRepositoryDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -52,12 +38,4 @@ public class JournalRepositoryDataEntity extends BaseFieldDataEntity<JournalRepo
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,6 @@ public class LicenseDataEntity extends BaseFieldDataEntity<LicenseDataEntity> {
|
|||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LicenseDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -51,12 +37,4 @@ public class LicenseDataEntity extends BaseFieldDataEntity<LicenseDataEntity> {
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,6 @@ public class OrganizationDataEntity extends BaseFieldDataEntity<OrganizationData
|
|||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganizationDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean( ((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -51,12 +37,4 @@ public class OrganizationDataEntity extends BaseFieldDataEntity<OrganizationData
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,21 +21,6 @@ public class PublicationDataEntity extends BaseFieldDataEntity<PublicationDataEn
|
|||
public void setMultiAutoComplete(Boolean multiAutoComplete) {
|
||||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicationDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -51,12 +36,4 @@ public class PublicationDataEntity extends BaseFieldDataEntity<PublicationDataEn
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,20 +23,6 @@ public class PublicationRepositoryDataEntity extends BaseFieldDataEntity<Publica
|
|||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicationRepositoryDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -52,12 +38,4 @@ public class PublicationRepositoryDataEntity extends BaseFieldDataEntity<Publica
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,28 +65,6 @@ public class RadioBoxDataEntity extends BaseFieldDataEntity<RadioBoxDataEntity>
|
|||
this.options = options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RadioBoxDataEntity fromData(Object data) {
|
||||
this.options = new LinkedList();
|
||||
if (data != null) {
|
||||
List<Map<String, String>> options = ((Map<String, List<Map<String, String>>>) data).get("options");
|
||||
for (Map<String, String> map : options) {
|
||||
Option newOption = new Option();
|
||||
newOption.setLabel(map.get("label"));
|
||||
newOption.setValue(map.get("value"));
|
||||
this.options.add(newOption);
|
||||
}
|
||||
this.setLabel(((Map<String, String>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -114,34 +92,4 @@ public class RadioBoxDataEntity extends BaseFieldDataEntity<RadioBoxDataEntity>
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
Element optionsElement = (Element) item.getElementsByTagName("options").item(0);
|
||||
List<Map<String,String>> option =new LinkedList<>();
|
||||
|
||||
if (optionsElement != null) {
|
||||
NodeList optionElements = optionsElement.getChildNodes();
|
||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
||||
Node optionElement = optionElements.item(temp);
|
||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
option.add(optionToMap((Element) optionElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataMap.put("options", option != null ? option : null);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private Map<String, String> optionToMap(Element item){
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label",item.getAttribute("label"));
|
||||
dataMap.put("value",item.getAttribute("value"));
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,21 +21,6 @@ public class RegistryDataEntity extends BaseFieldDataEntity<RegistryDataEntity>
|
|||
public void setMultiAutoComplete(Boolean multiAutoComplete) {
|
||||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()?Boolean.parseBoolean( ((Map<String, Object>) data).get("multiAutoComplete").toString()): false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -51,12 +36,4 @@ public class RegistryDataEntity extends BaseFieldDataEntity<RegistryDataEntity>
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,29 +43,4 @@ public class ResearcherAutoCompleteDataEntity extends InternalDmpBaseDataEntity<
|
|||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResearcherAutoCompleteDataEntity fromData(Object data) {
|
||||
super.fromData(data);
|
||||
if (data != null) {
|
||||
this.multiAutoComplete = Boolean.parseBoolean(((Map<Boolean, Object>) data).get("multiAutoComplete").toString());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "researchers");
|
||||
dataMap.put("multiAutoComplete", item != null ? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,6 @@ public class ResearcherDataEntity extends BaseFieldDataEntity<ResearcherDataEnti
|
|||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResearcherDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean( ((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -51,12 +37,4 @@ public class ResearcherDataEntity extends BaseFieldDataEntity<ResearcherDataEnti
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,23 +13,4 @@ public class RichTextAreaDataEntity extends BaseFieldDataEntity<RichTextAreaData
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.RICH_TEXT_AREA;
|
||||
}
|
||||
@Override
|
||||
public RichTextAreaDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel(((Map<String, String>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,6 @@ public class ServiceDataEntity extends BaseFieldDataEntity<ServiceDataEntity> {
|
|||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean( ((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -51,12 +37,4 @@ public class ServiceDataEntity extends BaseFieldDataEntity<ServiceDataEntity> {
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,24 +12,4 @@ public class TagDataEntity extends BaseFieldDataEntity<TagDataEntity> {
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.TAGS;
|
||||
}
|
||||
@Override
|
||||
public TagDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,6 @@ public class TaxonomyDataEntity extends BaseFieldDataEntity<TaxonomyDataEntity>
|
|||
this.multiAutoComplete = multiAutoComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaxonomyDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
this.setMultiAutoComplete(((Map<String, Object>) data).get("multiAutoComplete") != null && !((Map<String, Object>) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map<String, Object>) data).get("multiAutoComplete").toString()) : false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -51,12 +37,4 @@ public class TaxonomyDataEntity extends BaseFieldDataEntity<TaxonomyDataEntity>
|
|||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,25 +13,4 @@ public class TextAreaDataEntity extends BaseFieldDataEntity<TextAreaDataEntity>
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.TEXT_AREA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextAreaDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel(((Map<String, String>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,35 +76,6 @@ public class UploadDataEntity extends BaseFieldDataEntity<UploadDataEntity> {
|
|||
this.maxFileSizeInMB = maxFileSizeInMB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UploadDataEntity fromData(Object data) {
|
||||
this.types = new LinkedList();
|
||||
if (data != null) {
|
||||
List<Map<String, String>> types = ((Map<String, List<Map<String, String>>>) data).get("types");
|
||||
for (Map<String, String> map : types) {
|
||||
UploadDataEntity.Option newOption = new Option();
|
||||
newOption.setLabel(map.get("label"));
|
||||
newOption.setValue(map.get("value"));
|
||||
this.types.add(newOption);
|
||||
}
|
||||
this.setLabel(((Map<String, String>) data).get("label"));
|
||||
Object maxFileSizeInMB = ((Map<String, Object>) data).get("maxFileSizeInMB");
|
||||
if(maxFileSizeInMB instanceof String){ // template export
|
||||
if(!((String)maxFileSizeInMB).isEmpty())
|
||||
this.setMaxFileSizeInMB(Integer.valueOf((String)maxFileSizeInMB));
|
||||
}
|
||||
else if(maxFileSizeInMB instanceof Integer){ // template preview
|
||||
this.setMaxFileSizeInMB((Integer)maxFileSizeInMB);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
@ -136,34 +107,4 @@ public class UploadDataEntity extends BaseFieldDataEntity<UploadDataEntity> {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("maxFileSizeInMB", item != null ? item.getAttribute("maxFileSizeInMB") : "");
|
||||
Element optionsElement = (Element) item.getElementsByTagName("types").item(0);
|
||||
List<Map<String,String>> type =new LinkedList<>();
|
||||
|
||||
if (optionsElement != null) {
|
||||
NodeList optionElements = optionsElement.getChildNodes();
|
||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
||||
Node optionElement = optionElements.item(temp);
|
||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
type.add(optionToMap((Element) optionElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataMap.put("types", type != null ? type : null);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private Map<String, String> optionToMap(Element item){
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label",item.getAttribute("label"));
|
||||
dataMap.put("value",item.getAttribute("value"));
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,24 +12,4 @@ public class ValidationDataEntity extends BaseFieldDataEntity<ValidationDataEnti
|
|||
public FieldType getFieldType() {
|
||||
return FieldType.VALIDATION;
|
||||
}
|
||||
@Override
|
||||
public ValidationDataEntity fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,61 +76,4 @@ public class WordListDataEntity extends ComboBoxDataEntity<WordListDataEntity> {
|
|||
this.multiList = temp != null ? temp : false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WordListDataEntity fromData(Object data) {
|
||||
super.fromData(data);
|
||||
this.options = new LinkedList();
|
||||
if (data != null) {
|
||||
List<Map<String, String>> options = ((Map<String, List<Map<String, String>>>) data).get("options");
|
||||
if (options != null) {
|
||||
for (Map<String, String> map : options) {
|
||||
Option newOption = new Option();
|
||||
newOption.setLabel(map.get("label"));
|
||||
newOption.setValue(map.get("value"));
|
||||
this.options.add(newOption);
|
||||
}
|
||||
}
|
||||
Object multiList1 = ((Map<String, Object>) data).get("multiList");
|
||||
this.multiList = multiList1 != null && (multiList1 instanceof String ? Boolean.parseBoolean((String) multiList1) : (Boolean) multiList1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("multiList", item != null ? item.getAttribute("multiList") : "false");
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "wordlist");
|
||||
Element optionsElement = (Element) item.getElementsByTagName("options").item(0);
|
||||
List<Map<String,String>> option =new LinkedList<>();
|
||||
|
||||
if (optionsElement != null) {
|
||||
NodeList optionElements = optionsElement.getChildNodes();
|
||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
||||
Node optionElement = optionElements.item(temp);
|
||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
option.add(optionToMap((Element) optionElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataMap.put("options", option != null ? option : null);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private Map<String, String> optionToMap(Element item){
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label",item.getAttribute("label"));
|
||||
dataMap.put("value",item.getAttribute("value"));
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
|||
data.getTypes().add(this.buildOption(uploadOptionPersist));
|
||||
}
|
||||
}
|
||||
data.setMaxFileSizeInMB(persist.getMaxFileSizeInMB());
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -113,6 +114,7 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
|||
persist.getTypes().add(this.buildOption(option));
|
||||
}
|
||||
}
|
||||
persist.setMaxFileSizeInMB(data.getMaxFileSizeInMB());
|
||||
return persist;
|
||||
}
|
||||
|
||||
|
@ -134,6 +136,7 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
|||
xml.getTypes().add(this.buildOption(option));
|
||||
}
|
||||
}
|
||||
xml.setMaxFileSizeInMB(data.getMaxFileSizeInMB());
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
|
|
@ -172,23 +172,23 @@ public class Admin extends BaseController {
|
|||
// }
|
||||
// }
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
||||
public ResponseEntity getDatasetProfileXml(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws IllegalAccessException, IOException, InstantiationException, InvalidApplicationException {
|
||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.DatasetProfileManagerRole);
|
||||
|
||||
if (contentType.equals("application/xml")) {
|
||||
DescriptionTemplateEntity profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(profile);
|
||||
datasetProfile.setStatus(profile.getStatus().getValue());
|
||||
datasetProfile.setDescription(profile.getDescription());
|
||||
datasetProfile.setLanguage(profile.getLanguage());
|
||||
datasetProfile.setType(this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(profile.getType()).first().getName());
|
||||
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||
}
|
||||
}
|
||||
// @Transactional
|
||||
// @RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
||||
// public ResponseEntity getDatasetProfileXml(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws IllegalAccessException, IOException, InstantiationException, InvalidApplicationException {
|
||||
// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.DatasetProfileManagerRole);
|
||||
//
|
||||
// if (contentType.equals("application/xml")) {
|
||||
// DescriptionTemplateEntity profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
// eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(profile);
|
||||
// datasetProfile.setStatus(profile.getStatus().getValue());
|
||||
// datasetProfile.setDescription(profile.getDescription());
|
||||
// datasetProfile.setLanguage(profile.getLanguage());
|
||||
// datasetProfile.setType(this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(profile.getType()).first().getName());
|
||||
// return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
||||
// } else {
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||
// }
|
||||
// }
|
||||
|
||||
// @RequestMapping(method = RequestMethod.POST, value = {"/upload", "/upload/{id}"})
|
||||
// public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||
import eu.eudat.data.dao.criteria.RequestItem;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.logic.managers.AdminManager;
|
||||
import eu.eudat.data.dao.criteria.RequestItem;
|
||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
||||
import eu.eudat.models.data.helpers.common.AutoCompleteOptionsLookupItem;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
//package eu.eudat.controllers;
|
||||
//
|
||||
//import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
|
||||
//import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||
//import eu.eudat.logic.managers.DatasetProfileManager;
|
||||
//import eu.eudat.logic.services.ApiContext;
|
||||
//import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||
//import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||
//import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
//import eu.eudat.types.ApiMessageCode;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.http.HttpStatus;
|
||||
//import org.springframework.http.ResponseEntity;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import javax.management.InvalidApplicationException;
|
||||
//import java.util.List;
|
||||
//
|
||||
//
|
||||
//@RestController
|
||||
//@CrossOrigin
|
||||
//@RequestMapping(value = {"/api"})
|
||||
//public class DatasetProfiles extends BaseController {
|
||||
//
|
||||
// private DatasetProfileManager datasetProfileManager;
|
||||
//
|
||||
// @Autowired
|
||||
// public DatasetProfiles(ApiContext apiContext, DatasetProfileManager datasetProfileManager) {
|
||||
// super(apiContext);
|
||||
// this.datasetProfileManager = datasetProfileManager;
|
||||
// }
|
||||
//
|
||||
//// @RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/get"}, produces = "application/json")
|
||||
//// public @ResponseBody
|
||||
//// ResponseEntity<ResponseItem<List<DatasetProfileAutocompleteItem>>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
|
||||
//// List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = this.datasetProfileManager.getWithCriteria(datasetProfileAutocompleteRequest);
|
||||
//// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileAutocompleteItems));
|
||||
//// }
|
||||
//
|
||||
//// @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getAll"}, produces = "application/json")
|
||||
//// public @ResponseBody
|
||||
//// ResponseEntity<ResponseItem<List<DatasetProfileListingModel>>> getAll(@RequestBody DatasetProfileTableRequestItem tableRequestItem) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
|
||||
//// List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
|
||||
//// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
//// }
|
||||
//}
|
||||
//
|
|
@ -3,8 +3,17 @@ package eu.eudat.controllers;
|
|||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.FieldType;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.old.Dataset;
|
||||
import eu.eudat.data.old.FileUpload;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
|
@ -16,8 +25,11 @@ import eu.eudat.logic.utilities.json.JsonSearcher;
|
|||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.query.DescriptionTemplateQuery;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -27,12 +39,16 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
|
@ -49,67 +65,46 @@ public class FileController {
|
|||
private DatabaseRepository databaseRepository;
|
||||
private final AuthorizationService authorizationService;
|
||||
private final UserScope userScope;
|
||||
private final QueryFactory queryFactory;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
|
||||
@Autowired
|
||||
public FileController(DatasetProfileManager datasetProfileManager, Environment environment, ApiContext apiContext, AuthorizationService authorizationService, UserScope userScope) {
|
||||
public FileController(DatasetProfileManager datasetProfileManager, Environment environment, ApiContext apiContext, AuthorizationService authorizationService, UserScope userScope, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) {
|
||||
this.datasetProfileManager = datasetProfileManager;
|
||||
this.environment = environment;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
this.authorizationService = authorizationService;
|
||||
this.userScope = userScope;
|
||||
this.queryFactory = queryFactory;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||
public ResponseEntity<ResponseItem<String>> upload(
|
||||
@RequestParam("file") MultipartFile file, @RequestParam("datasetProfileId") String datasetProfileId, @RequestParam("fieldId") String fieldId)
|
||||
throws IllegalAccessException, IOException, InvalidApplicationException {
|
||||
throws IllegalAccessException, IOException, InvalidApplicationException, JAXBException, ParserConfigurationException, InstantiationException, SAXException {
|
||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole);
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = this.datasetProfileManager.getDatasetProfile(datasetProfileId);
|
||||
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).ids(UUID.fromString(datasetProfileId)).authorize(AuthorizationFlags.OwnerOrPermission).first();
|
||||
DefinitionEntity definition = descriptionTemplate == null ? null : this.xmlHandlingService.fromXml(DefinitionEntity.class, descriptionTemplate.getDefinition());
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String json = mapper.writeValueAsString(datasetprofile.getSections());
|
||||
JsonNode propertiesJson = mapper.readTree(json);
|
||||
Set<JsonNode> fieldNodes = new HashSet<>();
|
||||
fieldNodes.addAll(JsonSearcher.findNodes(propertiesJson, "id", fieldId, false));
|
||||
|
||||
// AtomicReference<String> exceptionMessage = null;
|
||||
AtomicBoolean acceptedFile = new AtomicBoolean(false);
|
||||
fieldNodes.forEach(node -> {
|
||||
JsonNode data = node.get("data");
|
||||
if (data != null && !data.toString().equals("\"\"") && !data.toString().equals("null")) {
|
||||
String stringValue = data.toString().replaceAll("=", ":");
|
||||
JSONObject dataObj = new JSONObject(stringValue);
|
||||
Map<String, Object> dataMap = ((JSONObject) dataObj).toMap();
|
||||
if(dataMap.get("maxFileSizeInMB") != null && !dataMap.get("maxFileSizeInMB").toString().equals("\"\"") && !dataMap.get("maxFileSizeInMB").toString().equals("null")) {
|
||||
if (file.getSize() <= Integer.parseInt(dataMap.get("maxFileSizeInMB").toString())*1048576) {
|
||||
List<FieldEntity> fieldEntities = definition != null ? definition.getFieldById(fieldId).stream().filter(x -> x != null && x.getData() != null && x.getData().getFieldType().equals(FieldType.UPLOAD)).toList() : new ArrayList<>();
|
||||
|
||||
fieldEntities.forEach(x-> {
|
||||
UploadDataEntity uploadDataEntity = (UploadDataEntity)x.getData();
|
||||
if (DataSize.ofBytes(file.getSize()).equals(DataSize.ofMegabytes(uploadDataEntity.getMaxFileSizeInMB()))) {
|
||||
acceptedFile.set(true);
|
||||
}
|
||||
// else {
|
||||
// exceptionMessage.set("The file is too large. Max file upload is " + dataMap.get("maxFileSizeInMB").toString() + " MB.");
|
||||
// }
|
||||
}
|
||||
|
||||
if(acceptedFile.get() && data.get("types") != null && !data.get("types").toString().equals("\"\"") && !data.get("types").toString().equals("null")) {
|
||||
if(acceptedFile.get() && uploadDataEntity.getTypes() != null && !uploadDataEntity.getTypes().isEmpty()) {
|
||||
acceptedFile.set(false);
|
||||
|
||||
JSONArray types = new JSONArray(data.get("types").toString());
|
||||
|
||||
types.iterator().forEachRemaining(element -> {
|
||||
Map<String, Object> typesMap = ((JSONObject) element).toMap();
|
||||
if(typesMap.get("value") != null && !typesMap.get("value").toString().equals("\"\"") && !typesMap.get("value").toString().equals("null")) {
|
||||
if(file.getContentType().equals(typesMap.get("value").toString())) {
|
||||
for (UploadDataEntity.Option option: uploadDataEntity.getTypes()) {
|
||||
if(Objects.equals(file.getContentType(), option.getValue())) {
|
||||
acceptedFile.set(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// if(!acceptedFile.get()) {
|
||||
// exceptionMessage.set("The file type is not accepted.");
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.types.descriptiontemplate.PageEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
|
||||
import eu.eudat.data.dao.entities.DatasetDao;
|
||||
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
|
||||
import eu.eudat.logic.builders.entity.DatasetProfileBuilder;
|
||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.service.descriptiontemplatetype.DescriptionTemplateTypeService;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdminManager {
|
||||
|
||||
public static DescriptionTemplateEntity generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext, DescriptionTemplateTypeService descriptionTemplateTypeService) throws Exception {
|
||||
DefinitionEntity defintion = new DefinitionEntity();
|
||||
defintion.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), SectionEntity.class));
|
||||
defintion.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), PageEntity.class));
|
||||
Document viewStyleDoc = XmlBuilder.getDocument();
|
||||
Element elementViewStyle = defintion.toXml(viewStyleDoc);
|
||||
viewStyleDoc.appendChild(elementViewStyle);
|
||||
String xml = XmlBuilder.generateXml(viewStyleDoc);
|
||||
|
||||
if (profile.getDescription() == null) {
|
||||
profile.setDescription("");
|
||||
}
|
||||
|
||||
if (profile.getLanguage() == null) {
|
||||
profile.setLanguage("en");
|
||||
}
|
||||
|
||||
DescriptionTemplateTypeEntity type;
|
||||
try {
|
||||
//TODO: dtziotzios type = descriptionTemplateTypeService.getEntityByName(profile.getType());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new Exception("Description template type '" + profile.getType() + "' could not be found.");
|
||||
}
|
||||
|
||||
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
|
||||
.status(DescriptionTemplateStatus.of(profile.getStatus())).created(Instant.now()).description(profile.getDescription()).language(profile.getLanguage())
|
||||
//TODO: dtziotzios .type(type)
|
||||
.build();
|
||||
|
||||
if (descriptionTemplateEntity.getGroupId() == null) {
|
||||
descriptionTemplateEntity.setGroupId(UUID.randomUUID());
|
||||
}
|
||||
|
||||
if (descriptionTemplateEntity.getVersion() == null) {
|
||||
descriptionTemplateEntity.setVersion((short)1);
|
||||
}
|
||||
|
||||
return descriptionTemplateEntity;
|
||||
}
|
||||
|
||||
public static eu.eudat.models.data.admin.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplateEntity profile) {
|
||||
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
|
||||
Element root = viewStyleDoc.getDocumentElement();
|
||||
DefinitionEntity viewstyle = new DefinitionEntity().fromXml(root);
|
||||
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.admin.composite.DatasetProfile();
|
||||
datasetprofile.buildProfile(viewstyle);
|
||||
return datasetprofile;
|
||||
}
|
||||
}
|
|
@ -1,27 +1,17 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.logic.proxy.config.*;
|
||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||
import eu.eudat.logic.proxy.config.entities.GeneralUrls;
|
||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import eu.eudat.query.DescriptionTemplateQuery;
|
||||
import eu.eudat.query.DescriptionTemplateTypeQuery;
|
||||
import eu.eudat.query.UserDescriptionTemplateQuery;
|
||||
import eu.eudat.service.descriptiontemplatetype.DescriptionTemplateTypeService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
|
@ -30,16 +20,13 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import jakarta.activation.MimetypesFileTypeMap;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
|
@ -48,11 +35,13 @@ import javax.xml.transform.TransformerFactory;
|
|||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.xpath.*;
|
||||
import java.io.*;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
@ -61,82 +50,17 @@ public class DatasetProfileManager {
|
|||
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
|
||||
private static final List<String> cache = new ArrayList<>();
|
||||
|
||||
private final ApiContext apiContext;
|
||||
private final DatabaseRepository databaseRepository;
|
||||
private final Environment environment;
|
||||
private final ConfigLoader configLoader;
|
||||
private final MetricsManager metricsManager;
|
||||
private final RemoteFetcher remoteFetcher;
|
||||
private final DescriptionTemplateTypeService descriptionTemplateTypeService;
|
||||
private final AuthorizationService authorizationService;
|
||||
private final UserScope userScope;
|
||||
private final QueryFactory queryFactory;
|
||||
private final DeleterFactory deleterFactory;
|
||||
|
||||
@Autowired
|
||||
public DatasetProfileManager(ApiContext apiContext, Environment environment, ConfigLoader configLoader, MetricsManager metricsManager, RemoteFetcher remoteFetcher, DescriptionTemplateTypeService descriptionTemplateTypeService, AuthorizationService authorizationService, UserScope userScope, QueryFactory queryFactory, DeleterFactory deleterFactory) {
|
||||
this.apiContext = apiContext;
|
||||
public DatasetProfileManager(ApiContext apiContext, ConfigLoader configLoader, RemoteFetcher remoteFetcher) {
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
this.environment = environment;
|
||||
this.configLoader = configLoader;
|
||||
this.metricsManager = metricsManager;
|
||||
this.descriptionTemplateTypeService = descriptionTemplateTypeService;
|
||||
this.remoteFetcher = remoteFetcher;
|
||||
this.authorizationService = authorizationService;
|
||||
this.userScope = userScope;
|
||||
this.queryFactory = queryFactory;
|
||||
this.deleterFactory = deleterFactory;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public eu.eudat.models.data.admin.composite.DatasetProfile getDatasetProfile(String id) throws InvalidApplicationException {
|
||||
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
datasetprofile.setLabel(profile.getLabel());
|
||||
datasetprofile.setStatus(profile.getStatus().getValue());
|
||||
datasetprofile.setDescription(profile.getDescription());
|
||||
datasetprofile.setType(this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(profile.getType()).first().getName());
|
||||
datasetprofile.setLanguage(profile.getLanguage());
|
||||
datasetprofile.setUsers(new ArrayList<>());
|
||||
retrieveUsers(profile, datasetprofile);
|
||||
return datasetprofile;
|
||||
}
|
||||
|
||||
// public List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
||||
// QueryableList<DescriptionTemplateEntity> items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
|
||||
// QueryableList<DescriptionTemplateEntity> pagedItems = datasetProfileAutocompleteRequest.applyPaging(items);
|
||||
// List<DatasetProfileAutocompleteItem> datasetProfiles = pagedItems.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item));
|
||||
// return datasetProfiles;
|
||||
// }
|
||||
//
|
||||
// public DescriptionTemplateEntity clone(String id) throws InvalidApplicationException {
|
||||
// DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
// apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
|
||||
// profile.setId(null);
|
||||
// return profile;
|
||||
// }
|
||||
|
||||
// public DataTableData<DatasetProfileListingModel> getPaged(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception {
|
||||
// QueryableList<DescriptionTemplateEntity> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
// QueryableList<DescriptionTemplateEntity> authItems = null;
|
||||
// if (this.authorizationService.authorize(Permission.AdminRole)) {
|
||||
// authItems = items;
|
||||
// } else if (this.authorizationService.authorize(Permission.DatasetProfileManagerRole)) {
|
||||
// List<Integer> roles = Arrays.asList(0, 1);
|
||||
// authItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getAuthenticated(items, this.userScope.getUserId(), roles);
|
||||
// }
|
||||
// QueryableList<DescriptionTemplateEntity> pagedItems = PaginationManager.applyPaging(authItems, datasetProfileTableRequestItem);
|
||||
// List<DatasetProfileListingModel> datasetProfiles = pagedItems.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
// return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build();
|
||||
// }
|
||||
|
||||
// public List<DatasetProfileListingModel> getAll(DatasetProfileTableRequestItem tableRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
||||
// QueryableList<DescriptionTemplateEntity> items = databaseRepository.getDatasetProfileDao().getWithCriteria(tableRequestItem.getCriteria());
|
||||
// List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
//
|
||||
// return datasetProfiles;
|
||||
// }
|
||||
|
||||
public FieldEntity queryForField(String xml, String fieldId) throws XPathExpressionException {
|
||||
FieldEntity fieldEntity = new FieldEntity();
|
||||
Document document = XmlBuilder.fromXml(xml);
|
||||
|
@ -295,181 +219,6 @@ public class DatasetProfileManager {
|
|||
return item != null ? item.toString() : null;
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
|
||||
FileEnvelope envelope = getXmlDocument(datasetProfile, label);
|
||||
InputStream resource = new FileInputStream(envelope.getFile());
|
||||
logger.info("Mime Type of " + envelope.getFilename() + " is " +
|
||||
new MimetypesFileTypeMap().getContentType(envelope.getFile()));
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.setContentLength(envelope.getFile().length());
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
String fileName = envelope.getFilename().replace(" ", "_").replace(",", "_");
|
||||
responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".xml");
|
||||
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||
|
||||
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
|
||||
resource.close();
|
||||
Files.deleteIfExists(envelope.getFile().toPath());
|
||||
|
||||
return new ResponseEntity<>(content,
|
||||
responseHeaders,
|
||||
HttpStatus.OK);
|
||||
}
|
||||
|
||||
public FileEnvelope getXmlDocument(eu.eudat.models.data.user.composite.DatasetProfile datatasetProfile, String label) throws InstantiationException, IllegalAccessException, IOException {
|
||||
ExportXmlBuilderDatasetProfile xmlBuilder = new ExportXmlBuilderDatasetProfile();
|
||||
File file = xmlBuilder.build(datatasetProfile, environment);
|
||||
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||
fileEnvelope.setFile(file);
|
||||
fileEnvelope.setFilename(label);
|
||||
return fileEnvelope;
|
||||
}
|
||||
|
||||
// public DescriptionTemplateImportXml createDatasetProfileFromXml(MultipartFile multiPartFile) {
|
||||
// ImportXmlBuilderDatasetProfile xmlBuilder = new ImportXmlBuilderDatasetProfile();
|
||||
// try {
|
||||
// File localFile = convert(multiPartFile);
|
||||
// DescriptionTemplateImportXml profile = xmlBuilder.build(localFile);
|
||||
// Files.deleteIfExists(localFile.toPath());
|
||||
// metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricNames.DRAFT);
|
||||
// return profile;
|
||||
// } catch (IOException e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// private File convert(MultipartFile file) throws IOException {
|
||||
// File convFile = new File(this.environment.getProperty("temp.temp") + file.getOriginalFilename());
|
||||
// convFile.createNewFile();
|
||||
// FileOutputStream fos = new FileOutputStream(convFile);
|
||||
// fos.write(file.getBytes());
|
||||
// fos.close();
|
||||
// return convFile;
|
||||
// }
|
||||
//
|
||||
// public DescriptionTemplateEntity createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception {
|
||||
// // Getting the DescriptionTemplate which we will create its new version.
|
||||
// DescriptionTemplateEntity oldDescriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
//
|
||||
// // Getting the DescriptionTemplate with the latest Version.
|
||||
// DatasetProfileCriteria criteria = new DatasetProfileCriteria();
|
||||
// LinkedList<UUID> list = new LinkedList<>();
|
||||
// list.push(oldDescriptionTemplateEntity.getGroupId());
|
||||
// criteria.setGroupIds(list);
|
||||
// criteria.setAllVersions(false);
|
||||
// QueryableList<DescriptionTemplateEntity> datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria);
|
||||
// DescriptionTemplateEntity latestVersionDescriptionTemplateEntity = datasetProfileQueryableList.getSingle();
|
||||
//
|
||||
// if (latestVersionDescriptionTemplateEntity.getVersion().equals(oldDescriptionTemplateEntity.getVersion())){
|
||||
// eu.eudat.models.data.admin.composite.DatasetProfile sortedProfile = profile.toShort();
|
||||
// DescriptionTemplateEntity modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext, descriptionTemplateTypeService);
|
||||
//// modelDefinition.setLabel(oldDescriptionTemplate.getLabel());
|
||||
// modelDefinition.setVersion((short) (oldDescriptionTemplateEntity.getVersion() + 1));
|
||||
// modelDefinition.setGroupId(oldDescriptionTemplateEntity.getGroupId());
|
||||
//// modelDefinition.setLanguage(oldDescriptionTemplate.getLanguage());
|
||||
// apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
// DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
// this.storeDatasetProfileUsers(descriptionTemplateEntity, profile);
|
||||
// return modelDefinition;
|
||||
// } else {
|
||||
// throw new DatasetProfileNewVersionException("Version to update not the latest.");
|
||||
// }
|
||||
// }
|
||||
|
||||
// public void storeDatasetProfileUsers(DescriptionTemplateEntity entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
|
||||
// final List<UserDescriptionTemplateEntity> userDescriptionTemplateEntities = this.queryFactory.query(UserDescriptionTemplateQuery.class).isActive(IsActive.Active).descriptionTemplateIds(entity.getId()).collect();
|
||||
// if (model.getUsers() != null && !model.getUsers().isEmpty()) {
|
||||
// model.getUsers().stream().filter(userInfoListingModel -> userDescriptionTemplateEntities.stream()
|
||||
// .filter(userDatasetProfile -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() == 0)
|
||||
// .forEach(userInfoListingModel -> {
|
||||
// UserDescriptionTemplateEntity userDatasetProfile1 = new UserDescriptionTemplateEntity();
|
||||
// userDatasetProfile1.setDescriptionTemplate(entity.getId());
|
||||
// UserInfo userInfo1 = null;
|
||||
// try {
|
||||
// userInfo1 = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userInfoListingModel.getId());
|
||||
// } catch (InvalidApplicationException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// userDatasetProfile1.setUser(userInfo1.getId());
|
||||
// userDatasetProfile1.setRole(UserDescriptionTemplateRole.Member);
|
||||
// apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile1);
|
||||
// sendJoinMail(userDatasetProfile1);
|
||||
// });
|
||||
//// userDescriptionTemplateEntities.stream().filter(userDatasetProfile -> model.getUsers().stream()
|
||||
//// .filter(userInfoListingModel -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() > 0
|
||||
//// && userDatasetProfile.getRole() == UserDescriptionTemplateRole.Saved2).forEach(userDatasetProfile -> {
|
||||
//// userDatasetProfile.setRole(UserDescriptionTemplateRole.Member);
|
||||
//// apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
//// sendJoinMail(userDatasetProfile);
|
||||
//// });
|
||||
// }
|
||||
// if (userDescriptionTemplateEntities != null && !userDescriptionTemplateEntities.isEmpty()) {
|
||||
// List<UserDescriptionTemplateEntity> toDelete = new ArrayList<>();
|
||||
//
|
||||
// userDescriptionTemplateEntities.stream().filter(userDatasetProfile -> model.getUsers().stream()
|
||||
// .filter(userInfoListingModel -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() == 0)
|
||||
// .forEach(userDatasetProfile -> {
|
||||
// toDelete.add(userDatasetProfile);
|
||||
// apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
// });
|
||||
// try {
|
||||
// this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class).delete(toDelete);
|
||||
// } catch (InvalidApplicationException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
@Transactional
|
||||
public void retrieveUsers(DescriptionTemplateEntity entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
|
||||
final List<UserDescriptionTemplateEntity> userDescriptionTemplateEntities = this.queryFactory.query(UserDescriptionTemplateQuery.class).isActive(IsActive.Active).descriptionTemplateIds(entity.getId()).collect();
|
||||
if (userDescriptionTemplateEntities != null && !userDescriptionTemplateEntities.isEmpty()) {
|
||||
model.setUsers(userDescriptionTemplateEntities.stream().filter(userDatasetProfile -> userDatasetProfile.getRole().getValue() < 2).map(userDatasetProfile -> {
|
||||
UserInfo user = null;
|
||||
try {
|
||||
user = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userDatasetProfile.getUser());
|
||||
} catch (InvalidApplicationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UserInfoListingModel userInfoListingModel = new UserInfoListingModel();
|
||||
userInfoListingModel.setId(user.getId());
|
||||
userInfoListingModel.setName(user.getName());
|
||||
userInfoListingModel.setEmail(user.getEmail());
|
||||
userInfoListingModel.setRole(userDatasetProfile.getRole().getValue());
|
||||
return userInfoListingModel;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
// private void sendJoinMail(UserDescriptionTemplateEntity userDatasetProfile) {
|
||||
// SimpleMail mail = new SimpleMail();
|
||||
// UserInfo user = null;
|
||||
// try {
|
||||
// user = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userDatasetProfile.getUser());
|
||||
// } catch (InvalidApplicationException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDatasetProfile.getDescriptionTemplate()).first();
|
||||
//
|
||||
// mail.setSubject(environment.getProperty("admin.mail.subject").replace( "{templateName}", descriptionTemplate.getLabel()));
|
||||
// String content = apiContext.getUtilitiesService().getMailService().getMailTemplateContent(environment.getProperty("email.dataset.template"));
|
||||
// content = content.replace("{recipient}", user.getName());
|
||||
// content = content.replace("{templateName}", descriptionTemplate.getLabel());
|
||||
// content = content.replace("{host}", this.environment.getProperty("dmp.domain"));
|
||||
// content = content.replace("{templateID}", descriptionTemplate.getId().toString());
|
||||
// mail.setContent(content);
|
||||
// mail.setTo(user.getEmail());
|
||||
// try {
|
||||
// apiContext.getUtilitiesService().getMailService().sendSimpleMail(mail);
|
||||
// } catch (Exception ex) {
|
||||
// logger.error(ex.getMessage(), ex);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
public List<String> getSemantics(String query) {
|
||||
List<Semantic> semantics = configLoader.getSemantics();
|
||||
List<String> filteredSemantics = semantics.stream().map(Semantic::getName).collect(Collectors.toList());
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.commons.types.descriptiontemplate.todelete.VisibilityEntity;
|
|||
import eu.eudat.commons.types.descriptiontemplate.fielddata.FieldDataHelper;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -120,13 +121,15 @@ public class Field implements DatabaseViewStyleDefinition, ViewStyleDefinition<F
|
|||
|
||||
fieldEntity.setId(this.id);
|
||||
fieldEntity.setOrdinal(this.ordinal);
|
||||
fieldEntity.setData(new FieldDataHelper().toFieldData(data, this.viewStyle.getFieldType()));
|
||||
fieldEntity.setVisibilityRules(this.visible.getRules());
|
||||
fieldEntity.setDefaultValue(this.defaultValue.getValue());
|
||||
fieldEntity.setValidations(this.validations);
|
||||
fieldEntity.setSchematics(this.schematics);
|
||||
fieldEntity.setIncludeInExport(this.export);
|
||||
return fieldEntity;
|
||||
throw new NotImplementedException(" Use new logic");
|
||||
//TODO: Use new logic
|
||||
// fieldEntity.setData(new FieldDataHelper().toFieldData(data, this.viewStyle.getFieldType()));
|
||||
// fieldEntity.setVisibilityRules(this.visible.getRules());
|
||||
// fieldEntity.setDefaultValue(this.defaultValue.getValue());
|
||||
// fieldEntity.setValidations(this.validations);
|
||||
// fieldEntity.setSchematics(this.schematics);
|
||||
// fieldEntity.setIncludeInExport(this.export);
|
||||
// return fieldEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,7 @@ import eu.eudat.models.data.properties.PropertiesGenerator;
|
|||
import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
|
||||
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -191,13 +192,15 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin
|
|||
public FieldEntity toDatabaseDefinition(FieldEntity fieldEntity) {
|
||||
fieldEntity.setId(this.id);
|
||||
fieldEntity.setOrdinal(this.ordinal);
|
||||
fieldEntity.setData(new FieldDataHelper().toFieldData(data, this.viewStyle.getFieldType()));
|
||||
fieldEntity.setDefaultValue(this.defaultValue.getValue());
|
||||
fieldEntity.setVisibilityRules(this.visible.getRules());
|
||||
fieldEntity.setValidations(this.validations);
|
||||
fieldEntity.setSchematics(this.schematics);
|
||||
fieldEntity.setIncludeInExport(this.export);
|
||||
return fieldEntity;
|
||||
throw new NotImplementedException(" Use new logic");
|
||||
//TODO: Use new logic
|
||||
// fieldEntity.setData(new FieldDataHelper().toFieldData(data, this.viewStyle.getFieldType()));
|
||||
// fieldEntity.setDefaultValue(this.defaultValue.getValue());
|
||||
// fieldEntity.setVisibilityRules(this.visible.getRules());
|
||||
// fieldEntity.setValidations(this.validations);
|
||||
// fieldEntity.setSchematics(this.schematics);
|
||||
// fieldEntity.setIncludeInExport(this.export);
|
||||
// return fieldEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue