Dataset Profile Download Xml And Import FromXml
This commit is contained in:
parent
f6ef760e99
commit
5302024a0b
|
@ -8,7 +8,6 @@ import eu.eudat.logic.managers.DatasetProfileManager;
|
|||
import eu.eudat.logic.managers.UserManager;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.helpers.LoggerService;
|
||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
|
@ -20,9 +19,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static eu.eudat.types.Authorities.ADMIN;
|
||||
|
@ -44,7 +46,8 @@ public class Admin extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||
DatasetProfile shortenProfile = profile.toShort();
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||
}
|
||||
|
@ -52,7 +55,8 @@ public class Admin extends BaseController {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||
DatasetProfile shortenProfile = profile.toShort();
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
||||
datasetprofile.setStatus(modelDefinition.getStatus());
|
||||
|
@ -106,4 +110,30 @@ 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, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
|
||||
if(contentType.equals("application/xml")){
|
||||
eu.eudat.data.entities.DatasetProfile 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());
|
||||
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"})
|
||||
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException{
|
||||
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
|
||||
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
||||
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequest
|
|||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
|
||||
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||
|
@ -20,12 +23,19 @@ import eu.eudat.queryable.QueryableList;
|
|||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
import javax.xml.xpath.*;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
@Component
|
||||
public class DatasetProfileManager {
|
||||
|
||||
|
@ -36,7 +46,7 @@ public class DatasetProfileManager {
|
|||
}
|
||||
|
||||
public DatasetProfile clone(ApiContext apiContext, String id) {
|
||||
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
|
||||
profile.setId(null);
|
||||
return profile;
|
||||
|
@ -83,4 +93,57 @@ public class DatasetProfileManager {
|
|||
jsonItems.forEach(item -> result.add(new Tuple<>(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()))));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
System.out.println("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);
|
||||
responseHeaders.set("Content-Disposition", "attachment;filename=" + envelope.getFilename() + ".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);
|
||||
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||
fileEnvelope.setFile(file);
|
||||
fileEnvelope.setFilename(label);
|
||||
return fileEnvelope;
|
||||
}
|
||||
|
||||
|
||||
public eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile createDatasetProfileFromXml(MultipartFile multiPartFile) {
|
||||
ImportXmlBuilderDatasetProfile xmlBuilder = new ImportXmlBuilderDatasetProfile();
|
||||
try {
|
||||
return xmlBuilder.build(convert(multiPartFile));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static File convert(MultipartFile file) throws IOException {
|
||||
File convFile = new File(file.getOriginalFilename());
|
||||
convFile.createNewFile();
|
||||
FileOutputStream fos = new FileOutputStream(convFile);
|
||||
fos.write(file.getBytes());
|
||||
fos.close();
|
||||
return convFile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class ModelBuilder {
|
|||
if (type.equals("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
||||
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
|
||||
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
|
||||
if (type.equals("datePicker")) return (FieldData<U>) new DataPickerData().fromData(data);
|
||||
if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class ModelBuilder {
|
|||
if (type.equals("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
||||
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
|
||||
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
|
||||
if (type.equals("datePicker")) return (FieldData<U>) new DataPickerData().fromData(data);
|
||||
if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,259 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml;
|
||||
|
||||
|
||||
import eu.eudat.models.data.admin.components.datasetprofile.Page;
|
||||
import eu.eudat.models.data.components.commons.datafield.*;
|
||||
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
||||
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
||||
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class ExportXmlBuilderDatasetProfile {
|
||||
|
||||
|
||||
public File build(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile) throws IOException {
|
||||
|
||||
File xmlFile = new File(UUID.randomUUID() + ".xml");
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
|
||||
Document xmlDoc = XmlBuilder.getDocument();
|
||||
// Element root = xmlDoc.createElement("root");
|
||||
// root.appendChild(createPages(datasetProfile.getPages(), datasetProfile.getSections(), xmlDoc));
|
||||
|
||||
xmlDoc.appendChild(createPages(datasetProfile.getPages(), datasetProfile.getSections(), xmlDoc));
|
||||
String xml = XmlBuilder.generateXml(xmlDoc);
|
||||
writer.write(xml);
|
||||
writer.close();
|
||||
return xmlFile;
|
||||
}
|
||||
|
||||
public Element createPages(List<Page> datasetProfilePages, List<Section> sections, Document element) {
|
||||
Element pages = element.createElement("pages");
|
||||
datasetProfilePages.forEach(item -> {
|
||||
Element page = element.createElement("page");
|
||||
page.setAttribute("id", "" + item.getId());
|
||||
page.setAttribute("ordinal", "" + item.getOrdinal());
|
||||
page.setAttribute("title", "" + item.getTitle());
|
||||
sections.forEach(sectionFromLis -> {
|
||||
if (sectionFromLis.getPage().equals(item.getId())) {
|
||||
Element elementSections = element.createElement("sections");
|
||||
page.appendChild(createSections(sectionFromLis, element, elementSections));
|
||||
}
|
||||
});
|
||||
pages.appendChild(page);
|
||||
});
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
||||
public Element createSections(Section sections, Document element, Element elementSections) {
|
||||
// if (sections.getSections() != null) {
|
||||
sections.getSections().forEach(sectionFor -> {
|
||||
Element elementSectionsChild = element.createElement("section");
|
||||
elementSections.appendChild(createSections(sectionFor, element, elementSectionsChild));
|
||||
});
|
||||
// }
|
||||
|
||||
elementSections.setAttribute("defaultVisibility", "" + sections.getDefaultVisibility());
|
||||
elementSections.setAttribute("id", "" + sections.getId());
|
||||
elementSections.setAttribute("ordinal", "" + sections.getOrdinal());
|
||||
elementSections.setAttribute("page", "" + sections.getPage());
|
||||
elementSections.setAttribute("page", "" + sections.getPage());
|
||||
|
||||
if (sections.getCompositeFields() != null) {
|
||||
elementSections.appendChild(createFieldSet(sections.getCompositeFields(), element));
|
||||
}
|
||||
|
||||
if (sections.getNumbering() != null) {
|
||||
Element numbering = element.createElement("numbering");
|
||||
numbering.setTextContent(sections.getNumbering());
|
||||
elementSections.appendChild(numbering);
|
||||
}
|
||||
if (sections.getDescription() != null) {
|
||||
Element description = element.createElement("description");
|
||||
description.setTextContent(sections.getDescription());
|
||||
elementSections.appendChild(description);
|
||||
}
|
||||
if (sections.getTitle() != null) {
|
||||
Element title = element.createElement("title");
|
||||
title.setTextContent(sections.getTitle());
|
||||
elementSections.appendChild(title);
|
||||
}
|
||||
|
||||
return elementSections;
|
||||
}
|
||||
|
||||
public Element createFieldSet(List<FieldSet> fieldSet, Document element) {
|
||||
Element elementFieldSets = element.createElement("field-Sets");
|
||||
fieldSet.forEach(field -> {
|
||||
Element composite = element.createElement("field-Set");
|
||||
composite.setAttribute("id", field.getId());
|
||||
composite.setAttribute("ordinal", "" + field.getOrdinal());
|
||||
|
||||
if (field.getNumbering() != null) {
|
||||
Element numbering = element.createElement("numbering");
|
||||
numbering.setTextContent(field.getNumbering());
|
||||
composite.appendChild(numbering);
|
||||
}
|
||||
Element commentField = element.createElement("CommentField");
|
||||
commentField.setTextContent("" + field.getHasCommentField());
|
||||
composite.appendChild(commentField);
|
||||
|
||||
composite.appendChild(createFields(field.getFields(), element));
|
||||
|
||||
if (field.getMultiplicity() != null) {
|
||||
Element multiplicity = element.createElement("multiplicity");
|
||||
multiplicity.setAttribute("max", "" + field.getMultiplicity().getMax());
|
||||
multiplicity.setAttribute("min", "" + field.getMultiplicity().getMin());
|
||||
composite.appendChild(multiplicity);
|
||||
}
|
||||
if (field.getTitle() != null && !field.getTitle().isEmpty()) {
|
||||
Element title = element.createElement("title");
|
||||
title.setTextContent(field.getTitle());
|
||||
composite.appendChild(title);
|
||||
}
|
||||
if (field.getDescription() != null && !field.getDescription().isEmpty()) {
|
||||
Element title = element.createElement("description");
|
||||
title.setTextContent(field.getDescription());
|
||||
composite.appendChild(title);
|
||||
}
|
||||
if (field.getExtendedDescription() != null && !field.getExtendedDescription().isEmpty()) {
|
||||
Element extendedDescription = element.createElement("extendedDescription");
|
||||
extendedDescription.setTextContent(field.getExtendedDescription());
|
||||
composite.appendChild(extendedDescription);
|
||||
}
|
||||
|
||||
|
||||
elementFieldSets.appendChild(composite);
|
||||
});
|
||||
return elementFieldSets;
|
||||
}
|
||||
|
||||
|
||||
public Element createFields(List<Field> fields, Document element) {
|
||||
Element elementFields = element.createElement("fields");
|
||||
fields.forEach(field -> {
|
||||
Element elementField = element.createElement("field");
|
||||
elementField.setAttribute("id", field.getId());
|
||||
elementField.setAttribute("ordinal", "" + field.getOrdinal());
|
||||
|
||||
if (field.getNumbering() != null) {
|
||||
Element numbering = element.createElement("numbering");
|
||||
numbering.setTextContent(field.getNumbering());
|
||||
elementField.appendChild(numbering);
|
||||
}
|
||||
if (field.getValidations() != null) {
|
||||
Element validations = element.createElement("validations");
|
||||
field.getValidations().forEach(validation -> {
|
||||
Element validationChild = element.createElement("validation");
|
||||
validationChild.setAttribute("type", "" + validation);
|
||||
validations.appendChild(validationChild);
|
||||
});
|
||||
elementField.appendChild(validations);
|
||||
}
|
||||
if (field.getDefaultValue() != null) {
|
||||
Element defaultValue = element.createElement("defaultValue");
|
||||
defaultValue.setAttribute("type", field.getDefaultValue().getType());
|
||||
defaultValue.setAttribute("value", field.getDefaultValue().getValue());
|
||||
elementField.appendChild(defaultValue);
|
||||
}
|
||||
if (field.getVisible() != null) {
|
||||
Element visible = element.createElement("visible");
|
||||
visible.setAttribute("style", "" + field.getVisible().getStyle());
|
||||
field.getVisible().getRules().forEach(rule -> {
|
||||
Element ruleChild = element.createElement("rule");
|
||||
ruleChild.setAttribute("ruleStyle", "" + rule.getRuleStyle());
|
||||
ruleChild.setAttribute("target", "" + rule.getTarget());
|
||||
ruleChild.setAttribute("type", "" + rule.getRuleType());
|
||||
Element ruleChildValue = element.createElement("value");
|
||||
ruleChildValue.setAttribute("type", "" + rule.getValueType());
|
||||
ruleChildValue.setTextContent(rule.getValue());
|
||||
ruleChild.appendChild(ruleChildValue);
|
||||
visible.appendChild(ruleChild);
|
||||
|
||||
});
|
||||
elementField.appendChild(visible);
|
||||
}
|
||||
if (field.getViewStyle() != null) {
|
||||
Element viewStyle = element.createElement("viewStyle");
|
||||
viewStyle.setAttribute("cssClass", field.getViewStyle().getCssClass());
|
||||
viewStyle.setAttribute("renderStyle", field.getViewStyle().getRenderStyle());
|
||||
elementField.appendChild(viewStyle);
|
||||
}
|
||||
|
||||
if (field.getData() != null) {
|
||||
Element dataOut = element.createElement("data");
|
||||
if (field.getViewStyle().getRenderStyle().equals("combobox")) {
|
||||
ComboBoxData comboBoxDataObject = (ComboBoxData) field.getData();
|
||||
if (comboBoxDataObject.getType().equals("wordlist")) {
|
||||
WordListData wordListDataObject = (WordListData) field.getData();
|
||||
dataOut.setAttribute("label", wordListDataObject.getLabel());
|
||||
dataOut.setAttribute("type", wordListDataObject.getType());
|
||||
Element options = element.createElement("options");
|
||||
wordListDataObject.getOptions().forEach(optionChildFor -> {
|
||||
Element optionChild = element.createElement("option");
|
||||
optionChild.setAttribute("label", optionChildFor.getLabel());
|
||||
optionChild.setAttribute("value", optionChildFor.getValue());
|
||||
options.appendChild(optionChild);
|
||||
});
|
||||
dataOut.appendChild(options);
|
||||
} else if (comboBoxDataObject.getType().equals("autocomplete")) {
|
||||
AutoCompleteData autoCompleteDataObject = (AutoCompleteData) field.getData();
|
||||
dataOut.setAttribute("label", autoCompleteDataObject.getLabel());
|
||||
dataOut.setAttribute("type", autoCompleteDataObject.getType());
|
||||
dataOut.setAttribute("optionsRoot", autoCompleteDataObject.getOptionsRoot());
|
||||
dataOut.setAttribute("url", autoCompleteDataObject.getUrl());
|
||||
if (autoCompleteDataObject.getAutoCompleteOptions() != null) {
|
||||
Element optionChild = element.createElement("option");
|
||||
optionChild.setAttribute("label", autoCompleteDataObject.getAutoCompleteOptions().getLabel());
|
||||
optionChild.setAttribute("value", autoCompleteDataObject.getAutoCompleteOptions().getValue());
|
||||
dataOut.appendChild(optionChild);
|
||||
}
|
||||
}
|
||||
} else if (field.getViewStyle().getRenderStyle().equals("booleanDecision")) {
|
||||
BooleanDecisionData booleanDecisionDataObject = (BooleanDecisionData) field.getData();
|
||||
dataOut.setAttribute("label", booleanDecisionDataObject.getLabel());
|
||||
} else if (field.getViewStyle().getRenderStyle().equals("radiobox")) {
|
||||
RadioBoxData radioBoxDataObject = (RadioBoxData) field.getData();
|
||||
dataOut.setAttribute("label", radioBoxDataObject.getLabel());
|
||||
|
||||
Element options = element.createElement("options");
|
||||
radioBoxDataObject.getOptions().forEach(optionChildFor -> {
|
||||
Element optionChild = element.createElement("option");
|
||||
optionChild.setAttribute("label", optionChildFor.getLabel());
|
||||
optionChild.setAttribute("value", optionChildFor.getValue());
|
||||
options.appendChild(optionChild);
|
||||
});
|
||||
dataOut.appendChild(options);
|
||||
} else if (field.getViewStyle().getRenderStyle().equals("checkBox")) {
|
||||
CheckBoxData checkBoxDataObject = (CheckBoxData) field.getData();
|
||||
dataOut.setAttribute("label", checkBoxDataObject.getLabel());
|
||||
} else if (field.getViewStyle().getRenderStyle().equals("freetext")) {
|
||||
FreeTextData freeTextDataObject = (FreeTextData) field.getData();
|
||||
dataOut.setAttribute("label", freeTextDataObject.getLabel());
|
||||
} else if (field.getViewStyle().getRenderStyle().equals("textarea")) {
|
||||
TextAreaData textAreaDataObject = (TextAreaData) field.getData();
|
||||
dataOut.setAttribute("label", textAreaDataObject.getLabel());
|
||||
} else if (field.getViewStyle().getRenderStyle().equals("datePicker")) {
|
||||
DatePickerData datePickerDataObject = (DatePickerData) field.getData();
|
||||
dataOut.setAttribute("label", datePickerDataObject.getLabel());
|
||||
}
|
||||
elementField.appendChild(dataOut);
|
||||
}
|
||||
|
||||
elementFields.appendChild(elementField);
|
||||
});
|
||||
return elementFields;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.*;
|
||||
|
||||
public class ImportXmlBuilderDatasetProfile {
|
||||
|
||||
public DatasetProfile build(File xmlFile) throws IOException {
|
||||
DatasetProfile datasetProfile = new DatasetProfile();
|
||||
JAXBContext jaxbContext = null;
|
||||
try {
|
||||
jaxbContext = JAXBContext.newInstance(DatasetProfile.class);
|
||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||
datasetProfile = (DatasetProfile) unmarshaller.unmarshal(xmlFile);
|
||||
} catch (JAXBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "pages")
|
||||
public class DatasetProfile {
|
||||
|
||||
private List<Page> page;
|
||||
|
||||
@XmlElement(name = "page")
|
||||
public List<Page> getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(List<Page> page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.composite.DatasetProfile toAdminCompositeModel(String label){
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile newDatasetEntityProfile = new eu.eudat.models.data.admin.composite.DatasetProfile();
|
||||
newDatasetEntityProfile.setLabel(label);
|
||||
newDatasetEntityProfile.setStatus(eu.eudat.data.entities.DatasetProfile.Status.SAVED.getValue());
|
||||
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionDatasetEntity = new LinkedList<>();
|
||||
for (Page xmlPage: page) {
|
||||
pagesDatasetEntity.add(xmlPage.toAdminCompositeModelPage());
|
||||
sectionDatasetEntity.add(xmlPage.toAdminCompositeModelSection());
|
||||
}
|
||||
newDatasetEntityProfile.setPages(pagesDatasetEntity);
|
||||
newDatasetEntityProfile.setSections(sectionDatasetEntity);
|
||||
|
||||
return newDatasetEntityProfile;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.Fields;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "field-Set")
|
||||
public class FieldSet {
|
||||
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private Fields fields;
|
||||
private String numbering;
|
||||
private Boolean commentField;
|
||||
private Multiplicity multiplicity;
|
||||
private String title;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "ordinal")
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@XmlElement(name = "fields")
|
||||
public Fields getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(Fields fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
@XmlElement(name = "numbering")
|
||||
public String getNumbering() {
|
||||
return numbering;
|
||||
}
|
||||
|
||||
public void setNumbering(String numbering) {
|
||||
this.numbering = numbering;
|
||||
}
|
||||
|
||||
@XmlElement(name = "CommentField")
|
||||
public Boolean getCommentField() {
|
||||
return commentField;
|
||||
}
|
||||
|
||||
public void setCommentField(Boolean commentField) {
|
||||
this.commentField = commentField;
|
||||
}
|
||||
|
||||
@XmlElement(name = "multiplicity")
|
||||
public Multiplicity getMultiplicity() {
|
||||
return multiplicity;
|
||||
}
|
||||
|
||||
public void setMultiplicity(Multiplicity multiplicity) {
|
||||
this.multiplicity = multiplicity;
|
||||
}
|
||||
|
||||
@XmlElement(name = "title")
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.FieldSet toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.admin.components.datasetprofile.FieldSet fieldSet1Entity = new eu.eudat.models.data.admin.components.datasetprofile.FieldSet();
|
||||
fieldSet1Entity.setId(this.id);
|
||||
fieldSet1Entity.setOrdinal(this.ordinal);
|
||||
fieldSet1Entity.setHasCommentField(this.commentField != null ? this.commentField : false);
|
||||
fieldSet1Entity.setMultiplicity(this.multiplicity != null ? this.multiplicity.toAdminCompositeModelSection() : null);
|
||||
fieldSet1Entity.setTitle(this.title);
|
||||
// List<eu.eudat.models.data.admin.components.datasetprofile.Field> fieldsEntity = new LinkedList<>();
|
||||
//
|
||||
// for (Fields xmlField:this.fields) {
|
||||
// fieldsEntity.add(xmlField.toAdminCompositeModelSection());
|
||||
// }
|
||||
fieldSet1Entity.setFields(this.fields.toAdminCompositeModelSection());
|
||||
return fieldSet1Entity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "field-Sets")
|
||||
public class FieldSets {
|
||||
|
||||
List<FieldSet> fieldSet;
|
||||
|
||||
@XmlElement(name = "field-Set")
|
||||
public List<FieldSet> getFieldSet() {
|
||||
return fieldSet;
|
||||
}
|
||||
|
||||
public void setFieldSet(List<FieldSet> fieldSet) {
|
||||
this.fieldSet = fieldSet;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> toAdminCompositeModelSection(){
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> fieldSetEntity = new LinkedList<>();
|
||||
if(this.fieldSet!=null)
|
||||
for (FieldSet xmlFieldSet:this.fieldSet){
|
||||
fieldSetEntity.add(xmlFieldSet.toAdminCompositeModelSection());
|
||||
}
|
||||
return fieldSetEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "defaultValue")
|
||||
public class DefaultValue {
|
||||
|
||||
private String type;
|
||||
private String value;
|
||||
|
||||
@XmlAttribute(name = "type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "value")
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.components.commons.DefaultValue toAdminCompositeModelSection(){
|
||||
eu.eudat.models.data.components.commons.DefaultValue defaultValueEntity =new eu.eudat.models.data.components.commons.DefaultValue();
|
||||
defaultValueEntity.setValue(value);
|
||||
defaultValueEntity.setType(type);
|
||||
return defaultValueEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||
import eu.eudat.models.data.components.commons.datafield.FieldData;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "field")
|
||||
public class Field {
|
||||
|
||||
private String id;
|
||||
|
||||
private int ordinal;
|
||||
|
||||
private String numbering;
|
||||
|
||||
private List<validations> validations;
|
||||
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
private Visible visible;
|
||||
|
||||
private ViewStyle viewStyle;
|
||||
|
||||
private Object data;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "ordinal")
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@XmlElement(name = "numbering")
|
||||
public String getNumbering() {
|
||||
return numbering;
|
||||
}
|
||||
|
||||
public void setNumbering(String numbering) {
|
||||
this.numbering = numbering;
|
||||
}
|
||||
|
||||
@XmlElement(name = "validations")
|
||||
public List<eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.validations> getValidations() {
|
||||
return validations;
|
||||
}
|
||||
|
||||
public void setValidations(List<eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.validations> validations) {
|
||||
this.validations = validations;
|
||||
}
|
||||
|
||||
@XmlElement(name = "defaultValue")
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(DefaultValue defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
@XmlElement(name = "visible")
|
||||
public Visible getVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(Visible visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
@XmlElement(name = "viewStyle")
|
||||
public ViewStyle getViewStyle() {
|
||||
return viewStyle;
|
||||
}
|
||||
|
||||
public void setViewStyle(ViewStyle viewStyle) {
|
||||
this.viewStyle = viewStyle;
|
||||
}
|
||||
|
||||
@XmlElement(name = "data")
|
||||
public Object getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Field toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.admin.components.datasetprofile.Field fieldEntity =new eu.eudat.models.data.admin.components.datasetprofile.Field();
|
||||
fieldEntity.setId(this.id);
|
||||
fieldEntity.setOrdinal(this.ordinal);
|
||||
List<Integer> validationList = new LinkedList<>();
|
||||
for(validations validation:this.validations){
|
||||
if(validation.getValidation()!=null)
|
||||
validationList.add(validation.toAdminCompositeModelSection());
|
||||
}
|
||||
fieldEntity.setValidations(validationList);
|
||||
fieldEntity.setDefaultValue(this.defaultValue.toAdminCompositeModelSection());
|
||||
fieldEntity.setVisible(this.visible.toAdminCompositeModelSection());
|
||||
fieldEntity.setViewStyle(this.viewStyle.toAdminCompositeModelSection());
|
||||
FieldData data = new ModelBuilder().toFieldData(null, this.viewStyle.getRenderStyle(), (Element) this.data);
|
||||
// fieldEntity.setData( data.fromXml((Element) this.data));
|
||||
fieldEntity.setData( data.toMap((Element)this.data));
|
||||
return fieldEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "fields")
|
||||
public class Fields {
|
||||
|
||||
private List<Field> field;
|
||||
|
||||
@XmlElement(name = "field")
|
||||
public List<Field> getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(List<Field> field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.admin.components.datasetprofile.Field> toAdminCompositeModelSection() {
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Field> fieldsEntity = new LinkedList<>();
|
||||
if (this.field != null)
|
||||
for (Field xmlField : this.field) {
|
||||
fieldsEntity.add(xmlField.toAdminCompositeModelSection());
|
||||
}
|
||||
return fieldsEntity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "rule")
|
||||
public class Rule{
|
||||
|
||||
private String ruleStyle;
|
||||
private String target;
|
||||
private String type;
|
||||
private Value value;
|
||||
|
||||
@XmlAttribute(name = "ruleStyle")
|
||||
public String getRuleStyle() {
|
||||
return ruleStyle;
|
||||
}
|
||||
|
||||
public void setRuleStyle(String ruleStyle) {
|
||||
this.ruleStyle = ruleStyle;
|
||||
}
|
||||
@XmlAttribute(name = "target")
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
@XmlAttribute(name = "type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
@XmlElement(name = "value")
|
||||
public Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Value value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.components.commons.Rule toAdminCompositeModelSection(){
|
||||
eu.eudat.models.data.components.commons.Rule ruleEntity = new eu.eudat.models.data.components.commons.Rule();
|
||||
ruleEntity.setRuleStyle(ruleStyle);
|
||||
ruleEntity.setTarget(target);
|
||||
ruleEntity.setRuleType(type);
|
||||
ruleEntity.setValueType(value.getType());
|
||||
ruleEntity.setValue(value.getValue());
|
||||
return ruleEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "validation")
|
||||
public class Validation {
|
||||
|
||||
private int type;
|
||||
|
||||
@XmlAttribute(name = "type")
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
|
||||
@XmlRootElement(name = "value")
|
||||
public class Value {
|
||||
|
||||
private String type;
|
||||
private String value;
|
||||
|
||||
@XmlAttribute(name = "type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@XmlValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "viewStyle")
|
||||
public class ViewStyle {
|
||||
|
||||
private String cssClass;
|
||||
private String renderStyle;
|
||||
|
||||
@XmlAttribute(name = "cssClass")
|
||||
public String getCssClass() {
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
public void setCssClass(String cssClass) {
|
||||
this.cssClass = cssClass;
|
||||
}
|
||||
@XmlAttribute(name = "renderStyle")
|
||||
public String getRenderStyle() {
|
||||
return renderStyle;
|
||||
}
|
||||
|
||||
public void setRenderStyle(String renderStyle) {
|
||||
this.renderStyle = renderStyle;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.components.commons.ViewStyle toAdminCompositeModelSection(){
|
||||
eu.eudat.models.data.components.commons.ViewStyle viewStyleEntity = new eu.eudat.models.data.components.commons.ViewStyle();
|
||||
viewStyleEntity.setCssClass(this.cssClass);
|
||||
viewStyleEntity.setRenderStyle(this.renderStyle);
|
||||
return viewStyleEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "visible")
|
||||
public class Visible {
|
||||
|
||||
private String style;
|
||||
private List<Rule> rule;
|
||||
|
||||
@XmlAttribute(name = "style")
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
public void setStyle(String style) {
|
||||
this.style = style;
|
||||
}
|
||||
@XmlElement(name = "rule")
|
||||
public List<Rule> getRule() {
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void setRule(List<Rule> rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.components.commons.Visibility toAdminCompositeModelSection(){
|
||||
eu.eudat.models.data.components.commons.Visibility visibilityEntity = new eu.eudat.models.data.components.commons.Visibility();
|
||||
visibilityEntity.setStyle(this.style);
|
||||
if(this.rule!=null) {
|
||||
List<eu.eudat.models.data.components.commons.Rule> ruleListEntity = new LinkedList<>();
|
||||
for (Rule xmlRule : this.rule) {
|
||||
ruleListEntity.add(xmlRule.toAdminCompositeModelSection());
|
||||
}
|
||||
visibilityEntity.setRules(ruleListEntity);
|
||||
}
|
||||
return visibilityEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "validations")
|
||||
public class validations {
|
||||
|
||||
Validation validation;
|
||||
|
||||
@XmlElement(name = "validation")
|
||||
public Validation getValidation() {
|
||||
return validation;
|
||||
}
|
||||
|
||||
public void setValidation(Validation validation) {
|
||||
this.validation = validation;
|
||||
}
|
||||
|
||||
public int toAdminCompositeModelSection() {
|
||||
return validation.getType();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
||||
@XmlRootElement(name = "multiplicity")
|
||||
public class Multiplicity {
|
||||
private int max;
|
||||
private int min;
|
||||
|
||||
@XmlAttribute(name = "max")
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "min")
|
||||
public int getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public void setMin(int min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.components.commons.Multiplicity toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.components.commons.Multiplicity multiplicityEntity = new eu.eudat.models.data.components.commons.Multiplicity();
|
||||
multiplicityEntity.setMax(max);
|
||||
multiplicityEntity.setMin(min);
|
||||
return multiplicityEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "page")
|
||||
public class Page {
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private String title;
|
||||
private Sections sections;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "ordinal")
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "title")
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlElement(name = "sections")
|
||||
public Sections getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(Sections sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Page toAdminCompositeModelPage(){
|
||||
eu.eudat.models.data.admin.components.datasetprofile.Page pageEntity = new eu.eudat.models.data.admin.components.datasetprofile.Page();
|
||||
pageEntity.setId(this.id);
|
||||
pageEntity.setOrdinal(this.ordinal);
|
||||
pageEntity.setTitle(this.title);
|
||||
return pageEntity;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection(){
|
||||
/* eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity =new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||
// List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionsListEntity = new LinkedList<>();
|
||||
// for (Section xmlsection:this.sections.section) {
|
||||
// sectionsListEntity.add(xmlsection.toAdminCompositeModelSection());
|
||||
// }
|
||||
if(this.sections.section!=null)
|
||||
sectionEntity.setSections(this.sections.toAdminCompositeModelSection());
|
||||
if(this.sections.fieldSets.fieldSet!=null)
|
||||
sectionEntity.setFieldSets(this.sections.toAdminCompositeModelSectionFieldSets());
|
||||
sectionEntity.setId(this.id);
|
||||
sectionEntity.setOrdinal(this.ordinal);
|
||||
sectionEntity.setTitle(this.title);*/
|
||||
return sections.toAdminCompositeModelSection();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "section")
|
||||
public class Section {
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private String page;
|
||||
private Boolean defaultVisibility;
|
||||
private FieldSets fieldSets;
|
||||
private String numbering;
|
||||
private String description;
|
||||
private String extendedDescription;
|
||||
private String title;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "ordinal")
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "page")
|
||||
public String getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(String page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "defaultVisibility")
|
||||
public Boolean getDefaultVisibility() {
|
||||
return defaultVisibility;
|
||||
}
|
||||
|
||||
public void setDefaultVisibility(Boolean defaultVisibility) {
|
||||
this.defaultVisibility = defaultVisibility;
|
||||
}
|
||||
|
||||
@XmlElement(name = "field-Sets")
|
||||
public FieldSets getFieldSets() {
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
public void setFieldSets(FieldSets fieldSets) {
|
||||
this.fieldSets = fieldSets;
|
||||
}
|
||||
|
||||
@XmlElement(name = "numbering")
|
||||
public String getNumbering() {
|
||||
return numbering;
|
||||
}
|
||||
|
||||
public void setNumbering(String numbering) {
|
||||
this.numbering = numbering;
|
||||
}
|
||||
|
||||
@XmlElement(name = "description")
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@XmlElement(name = "extendedDescription")
|
||||
public String getExtendedDescription() {
|
||||
return extendedDescription;
|
||||
}
|
||||
|
||||
public void setExtendedDescription(String extendedDescription) {
|
||||
this.extendedDescription = extendedDescription;
|
||||
}
|
||||
|
||||
@XmlElement(name = "title")
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity = new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||
sectionEntity.setId(this.id);
|
||||
sectionEntity.setOrdinal(this.ordinal);
|
||||
sectionEntity.setTitle(this.title);
|
||||
sectionEntity.setPage(this.page);
|
||||
sectionEntity.setDescription(this.description);
|
||||
// List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> fieldSetsEntity =new LinkedList<>();
|
||||
//
|
||||
// for (FieldSets xmpFieldSets: this.fieldSets) {
|
||||
// fieldSetsEntity.add(xmpFieldSets.toAdminCompositeModelSection());
|
||||
// }
|
||||
sectionEntity.setFieldSets(this.fieldSets.toAdminCompositeModelSection());
|
||||
sectionEntity.setDefaultVisibility(this.defaultVisibility);
|
||||
return sectionEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "sections")
|
||||
public class Sections {
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private String page;
|
||||
private Boolean defaultVisibility;
|
||||
private String numbering;
|
||||
private String description;
|
||||
private String title;
|
||||
private List<Section> section;
|
||||
private FieldSets fieldSets;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "ordinal")
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "page")
|
||||
public String getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(String page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "defaultVisibility")
|
||||
public Boolean getDefaultVisibility() {
|
||||
return defaultVisibility;
|
||||
}
|
||||
|
||||
public void setDefaultVisibility(Boolean defaultVisibility) {
|
||||
this.defaultVisibility = defaultVisibility;
|
||||
}
|
||||
|
||||
@XmlElement(name = "numbering")
|
||||
public String getNumbering() {
|
||||
return numbering;
|
||||
}
|
||||
|
||||
public void setNumbering(String numbering) {
|
||||
this.numbering = numbering;
|
||||
}
|
||||
|
||||
@XmlElement(name = "description")
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@XmlElement(name = "title")
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlElement(name = "section")
|
||||
public List<Section> getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(List<Section> section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
@XmlElement(name = "field-Sets")
|
||||
public FieldSets getFieldSets() {
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
public void setFieldSets(FieldSets fieldSets) {
|
||||
this.fieldSets = fieldSets;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity = new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionsListEntity = new LinkedList<>();
|
||||
|
||||
if (this.section != null) {
|
||||
for (Section xmlsection : this.section) {
|
||||
sectionsListEntity.add(xmlsection.toAdminCompositeModelSection());
|
||||
}
|
||||
} /*else {
|
||||
sectionsListEntity.add(new eu.eudat.models.data.admin.components.datasetprofile.Section());
|
||||
}*/
|
||||
sectionEntity.setId(this.id);
|
||||
sectionEntity.setOrdinal(this.ordinal);
|
||||
sectionEntity.setTitle(this.title);
|
||||
sectionEntity.setDefaultVisibility(this.defaultVisibility);
|
||||
sectionEntity.setDescription(description);
|
||||
sectionEntity.setPage(this.page);
|
||||
sectionEntity.setFieldSets(toAdminCompositeModelSectionFieldSets());
|
||||
|
||||
|
||||
sectionEntity.setSections(sectionsListEntity);
|
||||
return sectionEntity;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> toAdminCompositeModelSectionFieldSets() {
|
||||
return fieldSets.toAdminCompositeModelSection();
|
||||
}
|
||||
}
|
||||
|
|
@ -164,5 +164,4 @@ public class Field implements ViewStyleDefinition<eu.eudat.models.data.entities.
|
|||
return this.ordinal.compareTo(((Field) o).ordinal);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
|||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.FieldSet> {
|
||||
|
@ -33,7 +34,7 @@ public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.models
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public int getOrdinal() {
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
|
@ -118,4 +119,19 @@ public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.models
|
|||
}
|
||||
|
||||
|
||||
public FieldSet toShort(){
|
||||
FieldSet shortenFieldSet = new FieldSet();
|
||||
shortenFieldSet.setId(this.id);
|
||||
shortenFieldSet.setMultiplicity(this.multiplicity);
|
||||
shortenFieldSet.setTitle(this.title);
|
||||
shortenFieldSet.setDescription(this.description);
|
||||
shortenFieldSet.setExtendedDescription(this.extendedDescription);
|
||||
shortenFieldSet.setHasCommentField(this.hasCommentField);
|
||||
|
||||
List<Field> fieldToShort = this.fields;
|
||||
Collections.sort(fieldToShort);
|
||||
shortenFieldSet.setFields(fieldToShort);
|
||||
return shortenFieldSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
|||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section> {
|
||||
|
@ -114,5 +115,26 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
|
|||
return this.ordinal.compareTo(((Section) o).getOrdinal());
|
||||
}
|
||||
|
||||
public Section toShort(){
|
||||
Section shortenSection = new Section();
|
||||
|
||||
List<Section> toShortsections = this.sections;
|
||||
List<FieldSet> toShortFieldSets = this.fieldSets;
|
||||
Collections.sort(toShortsections);
|
||||
Collections.sort(toShortFieldSets);
|
||||
for (Section shortsections : toShortsections ) { shortsections.toShort(); }
|
||||
for (FieldSet shortFieldSets : toShortFieldSets ) { shortFieldSets.toShort(); }
|
||||
|
||||
shortenSection.setSections(toShortsections);
|
||||
shortenSection.setFieldSets(toShortFieldSets);
|
||||
|
||||
shortenSection.setDefaultVisibility(this.defaultVisibility);
|
||||
shortenSection.setPage(this.page);
|
||||
shortenSection.setOrdinal(this.ordinal);
|
||||
shortenSection.setId(this.id);
|
||||
shortenSection.setTitle(this.title);
|
||||
shortenSection.setDescription(this.description);
|
||||
return shortenSection;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import eu.eudat.models.data.admin.components.datasetprofile.Page;
|
|||
import eu.eudat.models.data.admin.components.datasetprofile.Section;
|
||||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class DatasetProfile {
|
||||
|
@ -48,4 +50,18 @@ public class DatasetProfile {
|
|||
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
|
||||
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
|
||||
}
|
||||
|
||||
public DatasetProfile toShort() {
|
||||
DatasetProfile shortProfile = new DatasetProfile();
|
||||
shortProfile.setLabel(this.label);
|
||||
List<Section> shortSection = new LinkedList<>();
|
||||
for (Section toshortSection : this.getSections()) {
|
||||
shortSection.add(toshortSection.toShort());
|
||||
}
|
||||
Collections.sort(shortSection);
|
||||
shortProfile.setSections(shortSection);
|
||||
shortProfile.setPages(this.pages);
|
||||
shortProfile.setStatus(this.status);
|
||||
return shortProfile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||
|
@ -85,5 +86,27 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
|||
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("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") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BooleanDecisionData extends FieldData<BooleanDecisionData> {
|
||||
|
@ -33,4 +34,11 @@ public class BooleanDecisionData extends FieldData<BooleanDecisionData> {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CheckBoxData extends FieldData<CheckBoxData> {
|
||||
|
@ -34,4 +35,10 @@ public class CheckBoxData extends FieldData<CheckBoxData> {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.logic.utilities.interfaces.XmlSerializable;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ComboBoxData<T> extends FieldData<T> {
|
||||
|
@ -86,5 +87,11 @@ public abstract class ComboBoxData<T> extends FieldData<T> {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,12 @@ package eu.eudat.models.data.components.commons.datafield;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DataPickerData extends FieldData<DataPickerData> {
|
||||
public class DatePickerData extends FieldData<DatePickerData> {
|
||||
@Override
|
||||
public DataPickerData fromData(Object data) {
|
||||
public DatePickerData fromData(Object data) {
|
||||
if (data != null) {
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
|
@ -27,8 +28,15 @@ public class DataPickerData extends FieldData<DataPickerData> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DataPickerData fromXml(Element item) {
|
||||
public DatePickerData fromXml(Element item) {
|
||||
this.setLabel(item != null ? item.getAttribute("label") : "");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@ import eu.eudat.logic.utilities.interfaces.XmlSerializable;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class FieldData<T> implements XmlSerializable<T> {
|
||||
private String label;
|
||||
|
||||
|
@ -30,4 +32,6 @@ public abstract class FieldData<T> implements XmlSerializable<T> {
|
|||
public T fromXml(Element item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract Map<String, Object> toMap(Element item);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
@ -33,4 +34,11 @@ public class FreeTextData extends FieldData<FreeTextData> {
|
|||
this.setLabel(item.getAttribute("label"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,14 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RadioBoxData extends FieldData<RadioBoxData> {
|
||||
|
||||
private class Option implements XmlSerializable<Option> {
|
||||
public class Option implements XmlSerializable<Option> {
|
||||
private String label;
|
||||
private String value;
|
||||
|
||||
|
@ -47,6 +48,7 @@ public class RadioBoxData extends FieldData<RadioBoxData> {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private List<Option> options;
|
||||
|
@ -111,4 +113,12 @@ public class RadioBoxData extends FieldData<RadioBoxData> {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("options", item != null ? item.getAttribute("options") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
@ -32,4 +33,11 @@ public class TextAreaData extends FieldData<TextAreaData> {
|
|||
this.setLabel(item.getAttribute("label"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -78,5 +79,33 @@ public class WordListData extends ComboBoxData<WordListData> {
|
|||
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") : "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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class Section implements DatabaseViewStyleDefinition, XmlSerializable<Sec
|
|||
|
||||
this.id = element.getAttribute("id");
|
||||
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
||||
this.defaultVisibility = Boolean.getBoolean(element.getAttribute("defaultVisibility"));
|
||||
this.defaultVisibility = Boolean.valueOf(element.getAttribute("defaultVisibility"));
|
||||
this.page = element.getAttribute("page");
|
||||
|
||||
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { DataTableData } from '../../model/data-table/data-table-data';
|
||||
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
||||
import { BaseHttpParams } from '../../../common/http/base-http-params';
|
||||
import { InterceptorType } from '../../../common/http/interceptors/interceptor-type';
|
||||
import { DatasetProfileEditorModel } from '../../../ui/admin/dataset-profile/editor/dataset-profile-editor-model';
|
||||
import { DatasetProfile } from '../../model/admin/dataset-profile/dataset-profile';
|
||||
import { DataTableData } from '../../model/data-table/data-table-data';
|
||||
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
||||
import { DatasetProfileDefinitionModel } from '../../model/dataset-profile-definition/dataset-profile-definition';
|
||||
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
|
||||
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
|
||||
import { BaseHttpService } from '../http/base-http.service';
|
||||
import { DatasetProfileDefinitionModel } from '../../model/dataset-profile-definition/dataset-profile-definition';
|
||||
|
||||
@Injectable()
|
||||
export class DatasetProfileService {
|
||||
|
||||
private actionUrl: string;
|
||||
private headers = new HttpHeaders();
|
||||
|
||||
constructor(private http: BaseHttpService) {
|
||||
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
|
||||
this.actionUrl = environment.Server + 'admin/';
|
||||
}
|
||||
createForm(data) {
|
||||
|
@ -47,4 +51,20 @@ export class DatasetProfileService {
|
|||
//return this.http.delete<DatasetProfile>(this.actionUrl + id, {});
|
||||
}
|
||||
|
||||
|
||||
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||||
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml')
|
||||
return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml });
|
||||
}
|
||||
|
||||
|
||||
uploadFile(file: FileList, labelSent: string): Observable<DataTableData<DatasetListingModel>> {
|
||||
const params = new BaseHttpParams();
|
||||
params.interceptorContext = {
|
||||
excludedInterceptors: [InterceptorType.JSONContentType]
|
||||
};
|
||||
const formData = new FormData();
|
||||
formData.append('file', file[0], labelSent);
|
||||
return this.http.post(this.actionUrl + "upload", formData, { params: params });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { HttpHeaders } from '@angular/common/http';
|
||||
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
|
@ -9,14 +9,17 @@ import { DmpProfileListing } from '../../model/dmp-profile/dmp-profile-listing';
|
|||
import { RequestItem } from '../../query/request-item';
|
||||
import { DataTableData } from '../../model/data-table/data-table-data';
|
||||
import { DmpProfileCriteria } from '../../query/dmp/dmp-profile-criteria';
|
||||
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
|
||||
import { BaseHttpParams } from '../../../common/http/base-http-params';
|
||||
import { InterceptorType } from '../../../common/http/interceptors/interceptor-type';
|
||||
|
||||
@Injectable()
|
||||
export class DmpProfileService {
|
||||
|
||||
private actionUrl: string;
|
||||
private headers: HttpHeaders;
|
||||
private headers = new HttpHeaders();
|
||||
|
||||
constructor(private http: BaseHttpService) {
|
||||
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
|
||||
this.actionUrl = environment.Server + 'dmpprofile/';
|
||||
}
|
||||
|
||||
|
@ -31,4 +34,19 @@ export class DmpProfileService {
|
|||
createDmp(dataManagementPlanModel: DmpProfile): Observable<DmpProfile> {
|
||||
return this.http.post<DmpProfile>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||||
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml')
|
||||
return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml });
|
||||
}
|
||||
|
||||
uploadFile(file: FileList, labelSent: string): Observable<DataTableData<DatasetListingModel>> {
|
||||
const params = new BaseHttpParams();
|
||||
params.interceptorContext = {
|
||||
excludedInterceptors: [InterceptorType.JSONContentType]
|
||||
};
|
||||
const formData = new FormData();
|
||||
formData.append('file', file[0], labelSent);
|
||||
return this.http.post(this.actionUrl + "upload", formData, { params: params });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import { DatasetProfileCriteriaComponent } from './listing/criteria/dataset-prof
|
|||
import { DatasetProfileListingComponent } from './listing/dataset-profile-listing.component';
|
||||
import { ConfirmationDialogModule } from '../../../library/confirmation-dialog/confirmation-dialog.module';
|
||||
import { DatasetProfileEditorDatePickerFieldComponent } from './editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component';
|
||||
import { DialodConfirmationUploadDatasetProfiles } from './listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -49,10 +50,12 @@ import { DatasetProfileEditorDatePickerFieldComponent } from './editor/component
|
|||
DatasetProfileEditorTextAreaFieldComponent,
|
||||
DatasetProfileEditorDatePickerFieldComponent,
|
||||
DatasetProfileEditorWordListFieldComponent,
|
||||
DatasetProfileEditorDefaultValueComponent
|
||||
DatasetProfileEditorDefaultValueComponent,
|
||||
DialodConfirmationUploadDatasetProfiles
|
||||
|
||||
],
|
||||
entryComponents: [
|
||||
DialodConfirmationUploadDatasetProfiles
|
||||
]
|
||||
})
|
||||
export class DatasetProfileModule { }
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
<div class="container" *ngIf="form" [formGroup]='form' class="dataset-profile-editor">
|
||||
<mat-form-field class="full-width">
|
||||
<input matInput formControlName="label" placeholder="{{'DATASET-PROFILE-EDITOR.FIELDS.DATASET-TITLE' | translate}}" required>
|
||||
<mat-error *ngIf="form.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
<input matInput formControlName="label"
|
||||
placeholder="{{'DATASET-PROFILE-EDITOR.FIELDS.DATASET-TITLE' | translate}}" required>
|
||||
<mat-error *ngIf="form.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="row" *ngIf="form.get('status').value==1">
|
||||
<div class="col"></div>
|
||||
<button mat-raised-button class="col-auto" color="primary" (click)="downloadXML();"
|
||||
type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-XML' | translate }}</button>
|
||||
</div>
|
||||
<mat-horizontal-stepper [linear]="true" #stepper>
|
||||
<mat-step>
|
||||
<ng-template matStepLabel>{{'DATASET-PROFILE-EDITOR.STEPS.PAGES.TITLE' | translate}}</ng-template>
|
||||
<div class="row">
|
||||
<app-dataset-profile-editor-page-component class="col-12" [form]="form.get('pages')" [viewOnly]="viewOnly"></app-dataset-profile-editor-page-component>
|
||||
<app-dataset-profile-editor-page-component class="col-12" [form]="form.get('pages')"
|
||||
[viewOnly]="viewOnly"></app-dataset-profile-editor-page-component>
|
||||
<div class="col-12">
|
||||
<button mat-button class="full-width" (click)="addPage()" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-PAGE' | translate}}</button>
|
||||
<button mat-button class="full-width" (click)="addPage()"
|
||||
[disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-PAGE' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-step>
|
||||
|
@ -20,19 +28,22 @@
|
|||
<mat-accordion class="col-12" [multi]="true">
|
||||
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title>
|
||||
<mat-panel-title>{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}
|
||||
</mat-panel-title>
|
||||
<button mat-icon-button type="button" (click)="DeleteSection(i);" [disabled]="viewOnly">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</mat-expansion-panel-header>
|
||||
<div id="{{'s' + i}}" class="row" *ngIf="panel.expanded">
|
||||
<app-dataset-profile-editor-section-component class="col-12" [form]="form.get('sections').get(''+i)" [dataModel]="section"
|
||||
[indexPath]="'s' + i" [viewOnly]="viewOnly"></app-dataset-profile-editor-section-component>
|
||||
<app-dataset-profile-editor-section-component class="col-12"
|
||||
[form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="'s' + i"
|
||||
[viewOnly]="viewOnly"></app-dataset-profile-editor-section-component>
|
||||
</div>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
<div class="col-12">
|
||||
<button mat-button (click)="addSection()" class="full-width" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-SECTION' | translate}}</button>
|
||||
<button mat-button (click)="addSection()" class="full-width"
|
||||
[disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-SECTION' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-step>
|
||||
|
@ -47,9 +58,11 @@
|
|||
<!-- SAVE BUTTON -->
|
||||
<div class="col-auto" *ngIf="!viewOnly">
|
||||
<div class="row">
|
||||
<button mat-raised-button color="primary" type="button col-auto" (click)='onSubmit()' [disabled]="!form.valid">Save</button>
|
||||
<button mat-raised-button color="primary" type="button col-auto" (click)='onSubmit()'
|
||||
[disabled]="!form.valid">Save</button>
|
||||
<div class="col-1"></div>
|
||||
<button mat-raised-button color="primary" type="button col-auto" (click)='finalize()' [disabled]="!form.valid">Finalize</button>
|
||||
<button mat-raised-button color="primary" type="button col-auto" (click)='finalize()'
|
||||
[disabled]="!form.valid">Finalize</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
|
@ -60,4 +73,4 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -16,6 +16,7 @@ import { SectionEditorModel } from '../admin/section-editor-model';
|
|||
import { DatasetProfileEditorModel } from './dataset-profile-editor-model';
|
||||
import { ConfirmationDialogComponent } from '../../../../library/confirmation-dialog/confirmation-dialog.component';
|
||||
import { DatasetProfileEnum } from '../../../../core/common/enum/dataset-profile';
|
||||
import * as FileSaver from 'file-saver';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-profile-editor-component',
|
||||
|
@ -58,40 +59,40 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
|||
this.datasetProfileService.getDatasetProfileById(this.datasetProfileId)
|
||||
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
data => {
|
||||
try {
|
||||
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
||||
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
||||
this.form = this.dataModel.buildForm();
|
||||
if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
|
||||
this.form.disable();
|
||||
this.viewOnly = true;
|
||||
data => {
|
||||
try {
|
||||
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
||||
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
||||
this.form = this.dataModel.buildForm();
|
||||
if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
|
||||
this.form.disable();
|
||||
this.viewOnly = true;
|
||||
}
|
||||
this.prepareForm();
|
||||
} catch {
|
||||
this.logger.error('Could not parse MasterItem: ' + data);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
this.prepareForm();
|
||||
} catch {
|
||||
this.logger.error('Could not parse MasterItem: ' + data);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
} else if (cloneId != null) {
|
||||
this.datasetProfileService.clone(cloneId)
|
||||
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
data => {
|
||||
try {
|
||||
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
||||
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
||||
this.dataModel.status = DatasetProfileEnum.SAVED;
|
||||
this.form = this.dataModel.buildForm();
|
||||
this.prepareForm();
|
||||
} catch {
|
||||
this.logger.error('Could not parse MasterItem: ' + data);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
data => {
|
||||
try {
|
||||
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
||||
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
||||
this.dataModel.status = DatasetProfileEnum.SAVED;
|
||||
this.form = this.dataModel.buildForm();
|
||||
this.prepareForm();
|
||||
} catch {
|
||||
this.logger.error('Could not parse MasterItem: ' + data);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
} else {
|
||||
this.dataModel = new DatasetProfileEditorModel();
|
||||
|
@ -148,7 +149,6 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
|||
|
||||
onSubmit() {
|
||||
let data = this.form.value;
|
||||
|
||||
if (this.datasetProfileId) {
|
||||
this.datasetProfileService.updateForm(this.datasetProfileId, data)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
|
@ -205,20 +205,53 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
|||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.form.get('status').setValue(DatasetProfileEnum.DELETED);
|
||||
this.datasetProfileService.delete(this.datasetProfileId,this.form.value)
|
||||
this.datasetProfileService.delete(this.datasetProfileId, this.form.value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => {
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
|
||||
this.router.navigate(['/dataset-profiles']);
|
||||
},
|
||||
error => {
|
||||
this.onCallbackError(error);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
|
||||
}
|
||||
complete => {
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
|
||||
this.router.navigate(['/dataset-profiles']);
|
||||
},
|
||||
error => {
|
||||
this.onCallbackError(error);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
downloadXML(): void {
|
||||
this.datasetProfileService.downloadXML(this.datasetProfileId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(response => {
|
||||
const blob = new Blob([response.body], { type: 'application/xml' });
|
||||
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||
|
||||
FileSaver.saveAs(blob, filename);
|
||||
});
|
||||
}
|
||||
|
||||
getFilenameFromContentDispositionHeader(header: string): string {
|
||||
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
||||
|
||||
const matches = header.match(regex);
|
||||
let filename: string;
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
const match = matches[i];
|
||||
if (match.includes('filename="')) {
|
||||
filename = match.substring(10, match.length - 1);
|
||||
break;
|
||||
} else if (match.includes('filename=')) {
|
||||
filename = match.substring(9);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
<div class="dmp-criteria">
|
||||
<mat-card class="mat-card">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder=" {{'CRITERIA.DATASET-PROFILE.LIKE'| translate}}" name="datasetProfileLike"
|
||||
[(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
||||
</mat-form-field>
|
||||
<mat-form-field class="col-md-6">
|
||||
<input matInput placeholder=" {{'CRITERIA.DATASET-PROFILE.LIKE'| translate}}" name="datasetProfileLike"
|
||||
[(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
||||
</mat-form-field>
|
||||
<div class="col"></div>
|
||||
<div class="col-auto">
|
||||
<!-- imgFileInput.click() && -->
|
||||
<button mat-raised-button class="col-auto" color="primary" (click)="openDialog()"
|
||||
type="button">{{ 'DATASET-WIZARD.UPLOAD.UPLOAD-XML' | translate }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
|
@ -1,7 +1,12 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ValidationErrorModel } from '../../../../../common/forms/validation/error-model/validation-error-model';
|
||||
import { DatasetProfileCriteria } from '../../../../../core/query/dataset-profile/dataset-profile-criteria';
|
||||
import { DatasetProfileService } from '../../../../../core/services/dataset-profile/dataset-profile.service';
|
||||
import { BaseCriteriaComponent } from '../../../../misc/criteria/base-criteria.component';
|
||||
import { DialodConfirmationUploadDatasetProfiles } from './dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-profile-criteria-component',
|
||||
|
@ -13,6 +18,9 @@ export class DatasetProfileCriteriaComponent extends BaseCriteriaComponent imple
|
|||
public criteria: DatasetProfileCriteria = new DatasetProfileCriteria();
|
||||
|
||||
constructor(
|
||||
private datasetService: DatasetProfileService,
|
||||
private dialog: MatDialog,
|
||||
private language: TranslateService,
|
||||
) {
|
||||
super(new ValidationErrorModel());
|
||||
}
|
||||
|
@ -38,4 +46,27 @@ export class DatasetProfileCriteriaComponent extends BaseCriteriaComponent imple
|
|||
this.refreshCallback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
openDialog(): void {
|
||||
const dialogRef = this.dialog.open(DialodConfirmationUploadDatasetProfiles, {
|
||||
data: {
|
||||
message: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-FILE-TITLE'),
|
||||
confirmButton: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML'),
|
||||
cancelButton: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-FILE-CANCEL'),
|
||||
name: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-NAME'),
|
||||
file: FileList,
|
||||
sucsess: false
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => {
|
||||
if (data.sucsess && data.name != null && data.file != null) {
|
||||
this.datasetService.uploadFile(data.file, data.name)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<div class="confirmation-dialog">
|
||||
<div class="row">
|
||||
<div class="confirmation-message col">
|
||||
<h4>{{ data.message }}</h4>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<input class="hidden" type="file" #imgFileInput (change)="selectXML($event)" accept="text/xml" />
|
||||
<button mat-raised-button class="col-auto" color="{{btnColore}}" (click)="imgFileInput.click()"
|
||||
type="button">{{ 'DATASET-WIZARD.UPLOAD.UPLOAD-XML-IMPORT' | translate }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<mat-form-field class="col-12">
|
||||
<input matInput placeholder="{{'DATASET-WIZARD.UPLOAD.UPLOAD-XML-NAME'| translate}}"
|
||||
name="datasetProfileName" [(ngModel)]="data.name">
|
||||
</mat-form-field>
|
||||
<div class="col-auto"><button mat-raised-button color="primary" type="button"
|
||||
(click)="cancel()">{{ data.cancelButton }}</button></div>
|
||||
<div class="col"></div>
|
||||
<div class="col-auto"><button mat-raised-button color="primary" type="button"
|
||||
(click)="confirm()" [disabled]="!hasProfile()">{{ data.confirmButton }}</button></div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,3 @@
|
|||
.hidden {
|
||||
display: none;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { Inject, Component } from '@angular/core';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-dialog-confirmation-upload',
|
||||
templateUrl: './dialog-confirmation-upload-profiles.component.html',
|
||||
styleUrls: ['./dialog-confirmation-upload-profiles.component.scss']
|
||||
})
|
||||
export class DialodConfirmationUploadDatasetProfiles {
|
||||
|
||||
sizeError = false;
|
||||
btnColore:String="primary";
|
||||
selectFile =false;
|
||||
maxFileSize: number = 1048576;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<DialodConfirmationUploadDatasetProfiles>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any
|
||||
) { }
|
||||
|
||||
|
||||
selectXML(event) {
|
||||
const file: FileList = event.target.files;
|
||||
const size: number = file[0].size; // Get file size.
|
||||
this.sizeError = size > this.maxFileSize; // Checks if file size is valid.
|
||||
const formdata: FormData = new FormData();
|
||||
if (!this.sizeError) {
|
||||
this.data.file = file;
|
||||
this.selectFile=true;
|
||||
this.btnColore="primary";
|
||||
}else{
|
||||
this.btnColore="warn";
|
||||
}
|
||||
this.data.name = file[0].name;
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.data.sucsess = false;
|
||||
this.dialogRef.close(this.data);
|
||||
}
|
||||
|
||||
confirm() {
|
||||
this.data.name = this.data.name;
|
||||
this.data.sucsess = true;
|
||||
this.dialogRef.close(this.data);
|
||||
}
|
||||
|
||||
hasProfile():boolean{
|
||||
return (this.selectFile && !this.sizeError);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
<div class="container-fluid">
|
||||
<h3>{{titlePrefix}} {{'DATASET-PROFILE-LISTING.TITLE' | translate}}</h3>
|
||||
|
||||
|
||||
<app-dataset-profile-criteria-component></app-dataset-profile-criteria-component>
|
||||
<mat-card class="mat-card">
|
||||
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
|
||||
|
|
|
@ -33,4 +33,6 @@ mat-row:hover {
|
|||
|
||||
mat-row:nth-child(odd){
|
||||
background-color:#eef0fb;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -245,6 +245,13 @@
|
|||
"SAVE-AND-FINALISE": "Save and Finalise",
|
||||
"DOWNLOAD-PDF": "Download PDF",
|
||||
"DOWNLOAD-XML": "Download XML"
|
||||
},
|
||||
"UPLOAD":{
|
||||
"UPLOAD-XML": "Import",
|
||||
"UPLOAD-XML-FILE-TITLE":"Select Xml file with Dataset Profile to Upload",
|
||||
"UPLOAD-XML-NAME":"Name Of Dataset Profile",
|
||||
"UPLOAD-XML-IMPORT":"File",
|
||||
"UPLOAD-XML-FILE-CANCEL":"Cansel"
|
||||
}
|
||||
},
|
||||
"DATASET-LISTING": {
|
||||
|
@ -312,7 +319,9 @@
|
|||
"ACTIONS": {
|
||||
"SAVE": "Save",
|
||||
"CANCEL": "Cancel",
|
||||
"DELETE": "Delete"
|
||||
"DELETE": "Delete",
|
||||
"FINALIZE":"Finalise",
|
||||
"DOWNLOAD-XML": "Download XML"
|
||||
}
|
||||
},
|
||||
"PROJECT-EDITOR": {
|
||||
|
@ -367,6 +376,13 @@
|
|||
"NAME": "Name",
|
||||
"STATUS": "Status",
|
||||
"CREATED": "Created"
|
||||
},
|
||||
"UPLOAD":{
|
||||
"UPLOAD-XML": "Import",
|
||||
"UPLOAD-XML-FILE-TITLE":"Select Xml file with Dmp Profile to Upload",
|
||||
"UPLOAD-XML-NAME":"Name Of Dmp Profile",
|
||||
"UPLOAD-XML-IMPORT":"File",
|
||||
"UPLOAD-XML-FILE-CANCEL":"Cansel"
|
||||
}
|
||||
},
|
||||
"DYNAMIC-FORM": {
|
||||
|
|
Loading…
Reference in New Issue