DmpBlueprint refactor
This commit is contained in:
parent
a68668f07e
commit
de566729f1
|
@ -49,3 +49,4 @@ bin/
|
||||||
.run
|
.run
|
||||||
openDMP/dmp-backend/uploads/
|
openDMP/dmp-backend/uploads/
|
||||||
openDMP/dmp-backend/tmp/
|
openDMP/dmp-backend/tmp/
|
||||||
|
storage/
|
||||||
|
|
|
@ -5,43 +5,30 @@ import gr.cite.tools.logging.EventId;
|
||||||
public class AuditableAction {
|
public class AuditableAction {
|
||||||
|
|
||||||
public static final EventId DescriptionTemplateType_Query = new EventId(1000, "DescriptionTemplateType_Query");
|
public static final EventId DescriptionTemplateType_Query = new EventId(1000, "DescriptionTemplateType_Query");
|
||||||
|
|
||||||
public static final EventId DescriptionTemplateType_Lookup = new EventId(1001, "DescriptionTemplateType_Lookup");
|
public static final EventId DescriptionTemplateType_Lookup = new EventId(1001, "DescriptionTemplateType_Lookup");
|
||||||
|
|
||||||
public static final EventId DescriptionTemplateType_Persist = new EventId(1002, "DescriptionTemplateType_Persist");
|
public static final EventId DescriptionTemplateType_Persist = new EventId(1002, "DescriptionTemplateType_Persist");
|
||||||
|
|
||||||
public static final EventId DescriptionTemplateType_Delete = new EventId(1003, "DescriptionTemplateType_Delete");
|
public static final EventId DescriptionTemplateType_Delete = new EventId(1003, "DescriptionTemplateType_Delete");
|
||||||
|
|
||||||
public static final EventId EntityDoi_Query = new EventId(2000, "EntityDoi_Query");
|
public static final EventId EntityDoi_Query = new EventId(2000, "EntityDoi_Query");
|
||||||
|
|
||||||
public static final EventId EntityDoi_Lookup = new EventId(2001, "EntityDoi_Lookup");
|
public static final EventId EntityDoi_Lookup = new EventId(2001, "EntityDoi_Lookup");
|
||||||
|
|
||||||
public static final EventId EntityDoi_Persist = new EventId(2002, "EntityDoi_Persist");
|
public static final EventId EntityDoi_Persist = new EventId(2002, "EntityDoi_Persist");
|
||||||
|
|
||||||
public static final EventId EntityDoi_Delete = new EventId(2003, "EntityDoi_Delete");
|
public static final EventId EntityDoi_Delete = new EventId(2003, "EntityDoi_Delete");
|
||||||
|
|
||||||
public static final EventId DmpBlueprint_Query = new EventId(3000, "DmpBlueprint_Query");
|
public static final EventId DmpBlueprint_Query = new EventId(3000, "DmpBlueprint_Query");
|
||||||
|
|
||||||
public static final EventId DmpBlueprint_Lookup = new EventId(3001, "DmpBlueprint_Lookup");
|
public static final EventId DmpBlueprint_Lookup = new EventId(3001, "DmpBlueprint_Lookup");
|
||||||
|
|
||||||
public static final EventId DmpBlueprint_Persist = new EventId(3002, "DmpBlueprint_Persist");
|
public static final EventId DmpBlueprint_Persist = new EventId(3002, "DmpBlueprint_Persist");
|
||||||
|
|
||||||
public static final EventId DmpBlueprint_Delete = new EventId(3003, "DmpBlueprint_Delete");
|
public static final EventId DmpBlueprint_Delete = new EventId(3003, "DmpBlueprint_Delete");
|
||||||
|
public static final EventId DmpBlueprint_Clone = new EventId(3004, "DmpBlueprint_Clone");
|
||||||
|
public static final EventId DmpBlueprint_GetXml = new EventId(3005, "DmpBlueprint_GetXml");
|
||||||
|
|
||||||
public static final EventId User_Settings_Query = new EventId(4000, "User_Settings_Query");
|
public static final EventId User_Settings_Query = new EventId(4000, "User_Settings_Query");
|
||||||
|
|
||||||
public static final EventId User_Settings_Lookup = new EventId(4001, "User_Settings_Lookup");
|
public static final EventId User_Settings_Lookup = new EventId(4001, "User_Settings_Lookup");
|
||||||
|
|
||||||
public static final EventId User_Settings_Persist = new EventId(4002, "User_Settings_Persist");
|
public static final EventId User_Settings_Persist = new EventId(4002, "User_Settings_Persist");
|
||||||
|
|
||||||
public static final EventId User_Settings_Delete = new EventId(4003, "User_Settings_Delete");
|
public static final EventId User_Settings_Delete = new EventId(4003, "User_Settings_Delete");
|
||||||
|
|
||||||
public static final EventId Dmp_Query = new EventId(5000, "Dmp_Query");
|
public static final EventId Dmp_Query = new EventId(5000, "Dmp_Query");
|
||||||
|
|
||||||
public static final EventId Dmp_Lookup = new EventId(5001, "Dmp_Lookup");
|
public static final EventId Dmp_Lookup = new EventId(5001, "Dmp_Lookup");
|
||||||
|
|
||||||
public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist");
|
public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist");
|
||||||
|
|
||||||
public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete");
|
public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,9 @@ public final class Permission {
|
||||||
public static String BrowseDmpBlueprint = "BrowseDmpBlueprint";
|
public static String BrowseDmpBlueprint = "BrowseDmpBlueprint";
|
||||||
public static String EditDmpBlueprint = "EditDmpBlueprint";
|
public static String EditDmpBlueprint = "EditDmpBlueprint";
|
||||||
public static String DeleteDmpBlueprint = "DeleteDmpBlueprint";
|
public static String DeleteDmpBlueprint = "DeleteDmpBlueprint";
|
||||||
|
public static String CloneDmpBlueprint = "CloneDmpBlueprint";
|
||||||
|
public static String ExportDmpBlueprint = "ExportDmpBlueprint";
|
||||||
|
public static String ImportDmpBlueprint = "ImportDmpBlueprint";
|
||||||
|
|
||||||
//DescriptionTemplateType
|
//DescriptionTemplateType
|
||||||
public static String BrowseEntityDoi = "BrowseEntityDoi";
|
public static String BrowseEntityDoi = "BrowseEntityDoi";
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
package eu.eudat.commons;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import jakarta.xml.bind.Marshaller;
|
||||||
|
import jakarta.xml.bind.Unmarshaller;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.*;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
|
||||||
|
public class XmlHandlingService {
|
||||||
|
|
||||||
|
public String xmlSerializableToXml(XmlSerializable<?> item) throws InvalidApplicationException, TransformerException, ParserConfigurationException {
|
||||||
|
Document document = this.getDocument();
|
||||||
|
if (document == null) throw new InvalidApplicationException("Can not create document");
|
||||||
|
document.appendChild(item.toXml(document));
|
||||||
|
return this.generateXml(document);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String xmlSerializableToXmlSafe(XmlSerializable<?> item) {
|
||||||
|
if (item == null) return null;
|
||||||
|
try {
|
||||||
|
return this.xmlSerializableToXml(item);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateXml(Document doc) throws TransformerException {
|
||||||
|
TransformerFactory tFact = TransformerFactory.newInstance();
|
||||||
|
Transformer trans = tFact.newTransformer();
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
StreamResult result = new StreamResult(writer);
|
||||||
|
DOMSource source = new DOMSource(doc);
|
||||||
|
trans.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||||
|
trans.transform(source, result);
|
||||||
|
return writer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toXml(Object item) throws JsonProcessingException, JAXBException {
|
||||||
|
JAXBContext context = JAXBContext.newInstance(item.getClass());
|
||||||
|
Marshaller marshaller = context.createMarshaller();
|
||||||
|
StringWriter out = new StringWriter();
|
||||||
|
marshaller.marshal(item, out);
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toXmlSafe(Object item) {
|
||||||
|
if (item == null) return null;
|
||||||
|
try {
|
||||||
|
return this.toXml(item);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T fromXml(Class<T> type, String xmlString) throws JAXBException {
|
||||||
|
JAXBContext jaxbContext = JAXBContext.newInstance(type);
|
||||||
|
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||||
|
|
||||||
|
return (T) jaxbUnmarshaller.unmarshal(new StringReader(xmlString));
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T fromXmlSafe(Class<T> type, String xmlString) {
|
||||||
|
if (xmlString == null) return null;
|
||||||
|
try {
|
||||||
|
return this.fromXml(type, xmlString);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends XmlSerializable<T>> T xmlSerializableFromXml(Class<T> type, String xmlString) throws JAXBException, InstantiationException, IllegalAccessException, ParserConfigurationException, IOException, SAXException {
|
||||||
|
T object = type.newInstance();
|
||||||
|
return (T) object.fromXml(this.getDocument(xmlString).getDocumentElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends XmlSerializable<T>> T xmlSerializableFromXmlSafe(Class<T> type, String xmlString) {
|
||||||
|
if (xmlString == null) return null;
|
||||||
|
try {
|
||||||
|
return this.xmlSerializableFromXml(type, xmlString);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Document getDocument(String xml) throws ParserConfigurationException, IOException, SAXException {
|
||||||
|
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||||
|
InputSource inputStream = new InputSource(new StringReader(xml));
|
||||||
|
return docBuilder.parse(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Document getDocument() throws ParserConfigurationException {
|
||||||
|
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||||
|
return docBuilder.newDocument();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity;
|
import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity;
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlRootElement(name = "descriptionTemplate")
|
@XmlRootElement(name = "descriptionTemplate")
|
||||||
|
@ -59,7 +60,7 @@ public class DescriptionTemplate {
|
||||||
this.maxMultiplicity = maxMultiplicity;
|
this.maxMultiplicity = maxMultiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionTemplateEntity toDmpBlueprintCompositeModel() {
|
public DescriptionTemplateEntity toEntity() {
|
||||||
DescriptionTemplateEntity descriptionTemplate = new DescriptionTemplateEntity();
|
DescriptionTemplateEntity descriptionTemplate = new DescriptionTemplateEntity();
|
||||||
descriptionTemplate.setId(UUID.fromString(this.id));
|
descriptionTemplate.setId(UUID.fromString(this.id));
|
||||||
descriptionTemplate.setDescriptionTemplateId(UUID.fromString(this.descriptionTemplateId));
|
descriptionTemplate.setDescriptionTemplateId(UUID.fromString(this.descriptionTemplateId));
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlRootElement(name = "descriptionTemplates")
|
@XmlRootElement(name = "descriptionTemplates")
|
|
@ -0,0 +1,25 @@
|
||||||
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
|
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
||||||
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "root")
|
||||||
|
public class DmpBlueprint {
|
||||||
|
|
||||||
|
private DmpBlueprintDefinition dmpBlueprintDefinition;
|
||||||
|
|
||||||
|
@XmlElement(name = "definition")
|
||||||
|
public DmpBlueprintDefinition getDmpBlueprintDefinition() {
|
||||||
|
return dmpBlueprintDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpBlueprintDefinition(DmpBlueprintDefinition dmpBlueprintDefinition) {
|
||||||
|
this.dmpBlueprintDefinition = dmpBlueprintDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefinitionEntity toDefinitionEntity() {
|
||||||
|
return this.dmpBlueprintDefinition.toEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
||||||
import eu.eudat.commons.types.dmpblueprint.SectionEntity;
|
import eu.eudat.commons.types.dmpblueprint.SectionEntity;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -21,12 +22,12 @@ public class DmpBlueprintDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DefinitionEntity toDmpBlueprintCompositeModel() {
|
public DefinitionEntity toEntity() {
|
||||||
DefinitionEntity dmpBlueprint = new DefinitionEntity();
|
DefinitionEntity dmpBlueprint = new DefinitionEntity();
|
||||||
List<SectionEntity> dmpBlueprintSections = new LinkedList<>();
|
List<SectionEntity> dmpBlueprintSections = new LinkedList<>();
|
||||||
if (this.sections != null && this.sections.getSections() != null) {
|
if (this.sections != null && this.sections.getSections() != null) {
|
||||||
for (Section section : this.sections.getSections()) {
|
for (Section section : this.sections.getSections()) {
|
||||||
dmpBlueprintSections.add(section.toDmpBlueprintCompositeModel());
|
dmpBlueprintSections.add(section.toEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dmpBlueprint.setSections(dmpBlueprintSections);
|
dmpBlueprint.setSections(dmpBlueprintSections);
|
|
@ -1,12 +1,12 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DmpBlueprintExtraFieldDataType;
|
import eu.eudat.commons.enums.DmpBlueprintExtraFieldDataType;
|
||||||
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
||||||
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity;
|
||||||
import eu.eudat.commons.types.dmpblueprint.FieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.FieldEntity;
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlRootElement(name = "extraField")
|
@XmlRootElement(name = "extraField")
|
||||||
|
@ -83,7 +83,7 @@ public class ExtraField {
|
||||||
this.required = required;
|
this.required = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldEntity toDmpBlueprintCompositeModel() {
|
public FieldEntity toEntity() {
|
||||||
ExtraFieldEntity systemField = new ExtraFieldEntity();
|
ExtraFieldEntity systemField = new ExtraFieldEntity();
|
||||||
systemField.setId(UUID.fromString(this.id));
|
systemField.setId(UUID.fromString(this.id));
|
||||||
systemField.setCategory(DmpBlueprintFieldCategory.Extra);
|
systemField.setCategory(DmpBlueprintFieldCategory.Extra);
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlRootElement(name = "extraFields")
|
@XmlRootElement(name = "extraFields")
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity;
|
import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity;
|
||||||
import eu.eudat.commons.types.dmpblueprint.FieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.FieldEntity;
|
||||||
|
@ -6,6 +6,7 @@ import eu.eudat.commons.types.dmpblueprint.SectionEntity;
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -94,7 +95,7 @@ public class Section {
|
||||||
this.descriptionTemplates = descriptionTemplates;
|
this.descriptionTemplates = descriptionTemplates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SectionEntity toDmpBlueprintCompositeModel() {
|
public SectionEntity toEntity() {
|
||||||
SectionEntity section = new SectionEntity();
|
SectionEntity section = new SectionEntity();
|
||||||
section.setId(UUID.fromString(this.id));
|
section.setId(UUID.fromString(this.id));
|
||||||
section.setLabel(this.label);
|
section.setLabel(this.label);
|
||||||
|
@ -104,19 +105,19 @@ public class Section {
|
||||||
List<FieldEntity> dmpBlueprintFieldModels = new LinkedList<>();
|
List<FieldEntity> dmpBlueprintFieldModels = new LinkedList<>();
|
||||||
if (this.systemFields != null && this.systemFields.getSystemFields() != null) {
|
if (this.systemFields != null && this.systemFields.getSystemFields() != null) {
|
||||||
for (SystemField systemField : this.systemFields.getSystemFields()) {
|
for (SystemField systemField : this.systemFields.getSystemFields()) {
|
||||||
dmpBlueprintFieldModels.add(systemField.toDmpBlueprintCompositeModel());
|
dmpBlueprintFieldModels.add(systemField.toEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.extraFields != null&& this.extraFields.getExtraFields() != null) {
|
if (this.extraFields != null&& this.extraFields.getExtraFields() != null) {
|
||||||
for (ExtraField extraField : this.extraFields.getExtraFields()) {
|
for (ExtraField extraField : this.extraFields.getExtraFields()) {
|
||||||
dmpBlueprintFieldModels.add(extraField.toDmpBlueprintCompositeModel());
|
dmpBlueprintFieldModels.add(extraField.toEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
section.setFields(dmpBlueprintFieldModels);
|
section.setFields(dmpBlueprintFieldModels);
|
||||||
List<DescriptionTemplateEntity> dmpBlueprintDescriptionTemplates = new LinkedList<>();
|
List<DescriptionTemplateEntity> dmpBlueprintDescriptionTemplates = new LinkedList<>();
|
||||||
if (this.descriptionTemplates != null && this.descriptionTemplates.getDescriptionTemplates() != null) {
|
if (this.descriptionTemplates != null && this.descriptionTemplates.getDescriptionTemplates() != null) {
|
||||||
for (DescriptionTemplate descriptionTemplate : this.descriptionTemplates.getDescriptionTemplates()) {
|
for (DescriptionTemplate descriptionTemplate : this.descriptionTemplates.getDescriptionTemplates()) {
|
||||||
dmpBlueprintDescriptionTemplates.add(descriptionTemplate.toDmpBlueprintCompositeModel());
|
dmpBlueprintDescriptionTemplates.add(descriptionTemplate.toEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
section.setDescriptionTemplates(dmpBlueprintDescriptionTemplates);
|
section.setDescriptionTemplates(dmpBlueprintDescriptionTemplates);
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlRootElement(name = "sections")
|
@XmlRootElement(name = "sections")
|
|
@ -1,12 +1,12 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
||||||
import eu.eudat.commons.types.dmpblueprint.FieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.FieldEntity;
|
||||||
import eu.eudat.commons.types.dmpblueprint.SystemFieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.SystemFieldEntity;
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlRootElement(name = "systemField")
|
@XmlRootElement(name = "systemField")
|
||||||
|
@ -83,7 +83,7 @@ public class SystemField {
|
||||||
this.required = required;
|
this.required = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldEntity toDmpBlueprintCompositeModel() {
|
public FieldEntity toEntity() {
|
||||||
SystemFieldEntity systemField = new SystemFieldEntity();
|
SystemFieldEntity systemField = new SystemFieldEntity();
|
||||||
systemField.setId(UUID.fromString(this.id));
|
systemField.setId(UUID.fromString(this.id));
|
||||||
systemField.setCategory(DmpBlueprintFieldCategory.System);
|
systemField.setCategory(DmpBlueprintFieldCategory.System);
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
package eu.eudat.commons.types.dmpblueprint.importmodel;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlRootElement(name = "systemFields")
|
@XmlRootElement(name = "systemFields")
|
|
@ -74,11 +74,6 @@ public class XmlBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getItemValueAsString(String xml,String name){
|
|
||||||
Document doc = fromXml(xml);
|
|
||||||
Element root = doc.getDocumentElement();
|
|
||||||
return root.getElementsByTagName(name).item(0).getNodeValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Element getNodeFromListByTagName(NodeList list, String tagName) {
|
public static Element getNodeFromListByTagName(NodeList list, String tagName) {
|
||||||
for (int temp = 0; temp < list.getLength(); temp++) {
|
for (int temp = 0; temp < list.getLength(); temp++) {
|
||||||
|
|
|
@ -38,13 +38,11 @@ public class EntityDoiEntity {
|
||||||
public static final String _doi = "doi";
|
public static final String _doi = "doi";
|
||||||
|
|
||||||
@Column(name = "created_at", nullable = false)
|
@Column(name = "created_at", nullable = false)
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Instant createdAt;
|
private Instant createdAt;
|
||||||
|
|
||||||
public static final String _createdAt = "createdAt";
|
public static final String _createdAt = "createdAt";
|
||||||
|
|
||||||
@Column(name = "updated_at", nullable = false)
|
@Column(name = "updated_at", nullable = false)
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Instant updatedAt;
|
private Instant updatedAt;
|
||||||
|
|
||||||
public static final String _updatedAt = "updatedAt";
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package eu.eudat.model.builder;
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.model.DmpBlueprint;
|
import eu.eudat.model.DmpBlueprint;
|
||||||
import eu.eudat.model.builder.dmpblueprintdefinition.DefinitionBuilder;
|
import eu.eudat.model.builder.dmpblueprintdefinition.DefinitionBuilder;
|
||||||
import eu.eudat.model.builder.dmpblueprintdefinition.SectionBuilder;
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
@ -26,14 +25,16 @@ import java.util.*;
|
||||||
public class DmpBlueprintBuilder extends BaseBuilder<DmpBlueprint, DmpBlueprintEntity> {
|
public class DmpBlueprintBuilder extends BaseBuilder<DmpBlueprint, DmpBlueprintEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpBlueprintBuilder(
|
public DmpBlueprintBuilder(
|
||||||
ConventionService conventionService,
|
ConventionService conventionService,
|
||||||
BuilderFactory builderFactory) {
|
BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintBuilder.class)));
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpBlueprintBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public DmpBlueprintBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
@ -48,7 +49,6 @@ public class DmpBlueprintBuilder extends BaseBuilder<DmpBlueprint, DmpBlueprintE
|
||||||
if (fields == null || data == null || fields.isEmpty())
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(DmpBlueprint._definition));
|
FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(DmpBlueprint._definition));
|
||||||
// new DefinitionEntity().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement());
|
|
||||||
List<DmpBlueprint> models = new ArrayList<>();
|
List<DmpBlueprint> models = new ArrayList<>();
|
||||||
for (DmpBlueprintEntity d : data) {
|
for (DmpBlueprintEntity d : data) {
|
||||||
DmpBlueprint m = new DmpBlueprint();
|
DmpBlueprint m = new DmpBlueprint();
|
||||||
|
@ -60,7 +60,7 @@ public class DmpBlueprintBuilder extends BaseBuilder<DmpBlueprint, DmpBlueprintE
|
||||||
if (fields.hasField(this.asIndexer(DmpBlueprint._status))) m.setStatus(d.getStatus());
|
if (fields.hasField(this.asIndexer(DmpBlueprint._status))) m.setStatus(d.getStatus());
|
||||||
if (fields.hasField(this.asIndexer(DmpBlueprint._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
if (fields.hasField(this.asIndexer(DmpBlueprint._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||||
if (!definitionFields.isEmpty() && d.getDefinition() != null){
|
if (!definitionFields.isEmpty() && d.getDefinition() != null){
|
||||||
DefinitionEntity definition = new DefinitionEntity().fromXml(XmlBuilder.fromXml(d.getDefinition()).getDocumentElement());
|
DefinitionEntity definition = this.xmlHandlingService.xmlSerializableFromXmlSafe(DefinitionEntity.class, d.getDefinition());
|
||||||
m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
|
m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
|
||||||
}
|
}
|
||||||
models.add(m);
|
models.add(m);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.service.dmpblueprint;
|
package eu.eudat.service.dmpblueprint;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.model.DmpBlueprint;
|
import eu.eudat.model.DmpBlueprint;
|
||||||
|
@ -9,16 +10,27 @@ import gr.cite.tools.exception.MyForbiddenException;
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.exception.MyValidationException;
|
import gr.cite.tools.exception.MyValidationException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface DmpBlueprintService {
|
public interface DmpBlueprintService {
|
||||||
|
|
||||||
DmpBlueprint persist(DmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
|
DmpBlueprint persist(DmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException;
|
||||||
|
|
||||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||||
boolean fieldInBlueprint(DmpBlueprintEntity dmpBlueprintEntity, DmpBlueprintSystemFieldType type);
|
boolean fieldInBlueprint(DmpBlueprintEntity dmpBlueprintEntity, DmpBlueprintSystemFieldType type);
|
||||||
|
|
||||||
boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type);
|
boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type);
|
||||||
|
|
||||||
|
DmpBlueprint buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException;
|
||||||
|
|
||||||
|
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException;
|
||||||
|
DmpBlueprint importXml(byte[] bytes, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package eu.eudat.service.dmpblueprint;
|
package eu.eudat.service.dmpblueprint;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
||||||
|
import eu.eudat.commons.enums.DmpBlueprintStatus;
|
||||||
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.dmpblueprint.*;
|
import eu.eudat.commons.types.dmpblueprint.*;
|
||||||
|
@ -11,13 +14,19 @@ import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.model.DmpBlueprint;
|
import eu.eudat.model.DmpBlueprint;
|
||||||
import eu.eudat.model.builder.DmpBlueprintBuilder;
|
import eu.eudat.model.builder.DmpBlueprintBuilder;
|
||||||
import eu.eudat.model.builder.dmpblueprintdefinition.DefinitionBuilder;
|
|
||||||
import eu.eudat.model.deleter.DmpBlueprintDeleter;
|
import eu.eudat.model.deleter.DmpBlueprintDeleter;
|
||||||
|
import eu.eudat.model.dmpblueprintdefinition.Definition;
|
||||||
|
import eu.eudat.model.dmpblueprintdefinition.DescriptionTemplate;
|
||||||
|
import eu.eudat.model.dmpblueprintdefinition.Field;
|
||||||
|
import eu.eudat.model.dmpblueprintdefinition.Section;
|
||||||
import eu.eudat.model.persist.DmpBlueprintPersist;
|
import eu.eudat.model.persist.DmpBlueprintPersist;
|
||||||
import eu.eudat.model.persist.dmpblueprintdefinition.*;
|
import eu.eudat.model.persist.dmpblueprintdefinition.*;
|
||||||
|
import eu.eudat.query.DmpBlueprintQuery;
|
||||||
|
import eu.eudat.service.responseutils.ResponseUtilsService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.exception.MyForbiddenException;
|
import gr.cite.tools.exception.MyForbiddenException;
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
@ -27,15 +36,23 @@ import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -55,10 +72,10 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
|
|
||||||
|
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final ResponseUtilsService responseUtilsService;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpBlueprintServiceImpl(
|
public DmpBlueprintServiceImpl(
|
||||||
|
@ -67,16 +84,20 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
DeleterFactory deleterFactory,
|
DeleterFactory deleterFactory,
|
||||||
BuilderFactory builderFactory,
|
BuilderFactory builderFactory,
|
||||||
ConventionService conventionService,
|
ConventionService conventionService,
|
||||||
MessageSource messageSource) {
|
MessageSource messageSource, QueryFactory queryFactory,
|
||||||
|
ResponseUtilsService responseUtilsService, XmlHandlingService xmlHandlingService) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.deleterFactory = deleterFactory;
|
this.deleterFactory = deleterFactory;
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
this.conventionService = conventionService;
|
this.conventionService = conventionService;
|
||||||
this.messageSource = messageSource;
|
this.messageSource = messageSource;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.responseUtilsService = responseUtilsService;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpBlueprint persist(DmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException {
|
public DmpBlueprint persist(DmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException {
|
||||||
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.EditDmpBlueprint);
|
this.authorizationService.authorizeForce(Permission.EditDmpBlueprint);
|
||||||
|
@ -98,11 +119,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
data.setLabel(model.getLabel());
|
data.setLabel(model.getLabel());
|
||||||
data.setStatus(model.getStatus());
|
data.setStatus(model.getStatus());
|
||||||
data.setUpdatedAt(Instant.now());
|
data.setUpdatedAt(Instant.now());
|
||||||
|
data.setDefinition(this.xmlHandlingService.xmlSerializableToXml(this.buildDefinitionEntity(model.getDefinition())));
|
||||||
Document document = XmlBuilder.getDocument();
|
|
||||||
if (document == null) throw new InvalidApplicationException("Can not create document");
|
|
||||||
document.appendChild(this.buildDefinitionEntity(model.getDefinition()).toXml(document));
|
|
||||||
data.setDefinition(XmlBuilder.generateXml(document));
|
|
||||||
|
|
||||||
if (isUpdate) this.entityManager.merge(data);
|
if (isUpdate) this.entityManager.merge(data);
|
||||||
else this.entityManager.persist(data);
|
else this.entityManager.persist(data);
|
||||||
|
@ -197,7 +214,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
|
|
||||||
public boolean fieldInBlueprint(DmpBlueprintEntity dmpBlueprintEntity, DmpBlueprintSystemFieldType type) {
|
public boolean fieldInBlueprint(DmpBlueprintEntity dmpBlueprintEntity, DmpBlueprintSystemFieldType type) {
|
||||||
|
|
||||||
DefinitionEntity definition = new DefinitionEntity().fromXml(XmlBuilder.fromXml(dmpBlueprintEntity.getDefinition()).getDocumentElement());
|
DefinitionEntity definition = this.xmlHandlingService.xmlSerializableFromXmlSafe(DefinitionEntity.class, dmpBlueprintEntity.getDefinition());
|
||||||
if (definition == null || definition.getSections() == null) return false;
|
if (definition == null || definition.getSections() == null) return false;
|
||||||
|
|
||||||
for(SectionEntity section: definition.getSections()){
|
for(SectionEntity section: definition.getSections()){
|
||||||
|
@ -220,5 +237,106 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return this.fieldInBlueprint(data, type);
|
return this.fieldInBlueprint(data, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DmpBlueprint buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException {
|
||||||
|
logger.debug(new MapLogEntry("persisting data").And("id", id).And("fields", fields));
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.CloneDmpBlueprint);
|
||||||
|
|
||||||
|
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).ids(id);
|
||||||
|
DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fields, query.firstAs(fields));
|
||||||
|
if (model == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
model.setLabel(model.getLabel() + " new ");
|
||||||
|
model.setId(null);
|
||||||
|
model.setHash(null);
|
||||||
|
this.reassignDefinition(model.getDefinition());
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reassignDefinition(Definition model){
|
||||||
|
if (model == null) return;;
|
||||||
|
|
||||||
|
if (model.getSections() != null){
|
||||||
|
for (Section section : model.getSections()) {
|
||||||
|
this.reassignSection(section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reassignSection(Section model){
|
||||||
|
if (model == null) return;;
|
||||||
|
model.setId(UUID.randomUUID());
|
||||||
|
|
||||||
|
if (model.getFields() != null){
|
||||||
|
for (Field field : model.getFields()) {
|
||||||
|
this.reassignField(field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (model.getDescriptionTemplates() != null){
|
||||||
|
for (DescriptionTemplate descriptionTemplate : model.getDescriptionTemplates()) {
|
||||||
|
this.reassignDescriptionTemplate(descriptionTemplate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reassignField(Field model){
|
||||||
|
if (model == null) return;
|
||||||
|
model.setId(UUID.randomUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reassignDescriptionTemplate(DescriptionTemplate model){
|
||||||
|
if (model == null) return;
|
||||||
|
model.setId(UUID.randomUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException {
|
||||||
|
logger.debug(new MapLogEntry("persisting data").And("id", id));
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.ExportDmpBlueprint);
|
||||||
|
DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, id);
|
||||||
|
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
DefinitionEntity dmpDefinition = this.xmlHandlingService.xmlSerializableFromXml(DefinitionEntity.class, data.getDefinition());
|
||||||
|
String xml = this.buildExportXml(dmpDefinition);
|
||||||
|
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildExportXml(DefinitionEntity dmpDefinition) throws TransformerException, ParserConfigurationException {
|
||||||
|
Document xmlDoc = this.xmlHandlingService.getDocument();
|
||||||
|
Element root = xmlDoc.createElement("root");
|
||||||
|
Element definition = xmlDoc.createElement("definition");
|
||||||
|
Element sections = xmlDoc.createElement("sections");
|
||||||
|
for (SectionEntity section : dmpDefinition.getSections()) {
|
||||||
|
sections.appendChild(section.toXml(xmlDoc));
|
||||||
|
}
|
||||||
|
definition.appendChild(sections);
|
||||||
|
root.appendChild(definition);
|
||||||
|
xmlDoc.appendChild(root);
|
||||||
|
return this.xmlHandlingService.generateXml(xmlDoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpBlueprint importXml(byte[] bytes, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("import data").And("bytes", bytes).And("label", label).And("fields", fields));
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.ImportDmpBlueprint);
|
||||||
|
|
||||||
|
eu.eudat.commons.types.dmpblueprint.importmodel.DmpBlueprint dmpDefinition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.dmpblueprint.importmodel.DmpBlueprint.class, new String(bytes, StandardCharsets.UTF_8));
|
||||||
|
DmpBlueprintEntity data = new DmpBlueprintEntity();
|
||||||
|
data.setId(UUID.randomUUID());
|
||||||
|
data.setIsActive(IsActive.Active);
|
||||||
|
data.setCreatedAt(Instant.now());
|
||||||
|
|
||||||
|
data.setLabel(label);
|
||||||
|
data.setStatus(DmpBlueprintStatus.Draft);
|
||||||
|
data.setUpdatedAt(Instant.now());
|
||||||
|
data.setDefinition(this.xmlHandlingService.xmlSerializableToXml(dmpDefinition.toDefinitionEntity()));
|
||||||
|
|
||||||
|
this.entityManager.persist(data);
|
||||||
|
|
||||||
|
this.entityManager.flush();
|
||||||
|
|
||||||
|
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package eu.eudat.service.responseutils;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
public interface ResponseUtilsService {
|
||||||
|
ResponseEntity<byte[]> buildResponseFileFromText(String text, String fileName);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package eu.eudat.service.responseutils;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ResponseUtilsServiceImpl implements ResponseUtilsService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ResponseUtilsServiceImpl() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<byte[]> buildResponseFileFromText(String text, String fileName) {
|
||||||
|
byte[] content = text.getBytes(StandardCharsets.UTF_8);
|
||||||
|
HttpHeaders responseHeaders = new HttpHeaders();
|
||||||
|
responseHeaders.setContentLength(content.length);
|
||||||
|
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
fileName = fileName.replace(" ", "_").replace(",", "_");
|
||||||
|
responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName);
|
||||||
|
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||||
|
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 3/21/2018.
|
|
||||||
*/
|
|
||||||
public interface DMPProfileDao extends DatabaseAccessLayer<DmpBlueprintEntity, UUID> {
|
|
||||||
|
|
||||||
QueryableList<DmpBlueprintEntity> getWithCriteria(DataManagementPlanProfileCriteria criteria);
|
|
||||||
|
|
||||||
QueryableList<DmpBlueprintEntity> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
package eu.eudat.data.dao.entities;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DmpBlueprintStatus;
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 3/21/2018.
|
|
||||||
*/
|
|
||||||
@Service("dmpProfileDao")
|
|
||||||
public class DMPProfileDaoImpl extends DatabaseAccess<DmpBlueprintEntity> implements DMPProfileDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public DMPProfileDaoImpl(DatabaseService<DmpBlueprintEntity> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<DmpBlueprintEntity> createOrUpdateAsync(DmpBlueprintEntity item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DmpBlueprintEntity createOrUpdate(DmpBlueprintEntity item) {
|
|
||||||
return this.getDatabaseService().createOrUpdate(item, DmpBlueprintEntity.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DmpBlueprintEntity find(UUID id) throws InvalidApplicationException {
|
|
||||||
return getDatabaseService().getQueryable(DmpBlueprintEntity.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DmpBlueprintEntity find(UUID id, String hint) throws InvalidApplicationException {
|
|
||||||
return getDatabaseService().getQueryable(DmpBlueprintEntity.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(DmpBlueprintEntity item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<DmpBlueprintEntity> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(DmpBlueprintEntity.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<DmpBlueprintEntity> getWithCriteria(DataManagementPlanProfileCriteria criteria) {
|
|
||||||
QueryableList<DmpBlueprintEntity> query = getDatabaseService().getQueryable(DmpBlueprintEntity.class);
|
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
|
||||||
query.where(((builder, root) -> builder.notEqual(root.get(DmpBlueprintEntity._isActive), IsActive.Inactive)));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<DmpBlueprintEntity> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria){
|
|
||||||
QueryableList<DmpBlueprintEntity> query = getDatabaseService().getQueryable(DmpBlueprintEntity.class);
|
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
|
||||||
if (criteria.getStatus() != null) {
|
|
||||||
if (criteria.getStatus().equals(DmpBlueprintStatus.Finalized)) {
|
|
||||||
query.where((builder, root) -> builder.equal(root.get(DmpBlueprintEntity._status), DmpBlueprintStatus.Finalized));
|
|
||||||
} else if (criteria.getStatus().equals(DmpBlueprintStatus.Draft)) {
|
|
||||||
query.where((builder, root) -> builder.equal(root.get(DmpBlueprintEntity._status), DmpBlueprintStatus.Draft));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
query.where(((builder, root) -> builder.notEqual(root.get(DmpBlueprintEntity._isActive), IsActive.Inactive)));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package eu.eudat.data.query.items.item.dmpprofile;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
|
||||||
import eu.eudat.data.query.definition.Query;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 3/21/2018.
|
|
||||||
*/
|
|
||||||
public class DataManagementPlanProfileCriteriaRequest extends Query<DataManagementPlanProfileCriteria, DmpBlueprintEntity> {
|
|
||||||
@Override
|
|
||||||
public QueryableList<DmpBlueprintEntity> applyCriteria() {
|
|
||||||
QueryableList<DmpBlueprintEntity> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package eu.eudat.data.query.items.table.dmpprofile;
|
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
|
||||||
import eu.eudat.data.query.PaginationService;
|
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 3/21/2018.
|
|
||||||
*/
|
|
||||||
public class DataManagementPlanProfileTableRequest extends TableQuery<DataManagementPlanProfileCriteria, DmpBlueprintEntity, UUID> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<DmpBlueprintEntity> applyCriteria() {
|
|
||||||
QueryableList<DmpBlueprintEntity> query = this.getQuery();
|
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
|
||||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<DmpBlueprintEntity> applyPaging(QueryableList<DmpBlueprintEntity> items) {
|
|
||||||
return PaginationService.applyPaging(items, this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -157,7 +157,7 @@ public class FileController {
|
||||||
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
|
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
|
||||||
}
|
}
|
||||||
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
||||||
.stream().filter(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe())
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
package eu.eudat.controllers.v2;
|
package eu.eudat.controllers.v2;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.audit.AuditableAction;
|
import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.data.old.DescriptionTemplate;
|
|
||||||
import eu.eudat.model.DmpBlueprint;
|
import eu.eudat.model.DmpBlueprint;
|
||||||
import eu.eudat.model.builder.DmpBlueprintBuilder;
|
import eu.eudat.model.builder.DmpBlueprintBuilder;
|
||||||
import eu.eudat.model.censorship.DmpBlueprintCensor;
|
import eu.eudat.model.censorship.DmpBlueprintCensor;
|
||||||
import eu.eudat.model.persist.DmpBlueprintPersist;
|
import eu.eudat.model.persist.DmpBlueprintPersist;
|
||||||
import eu.eudat.model.result.QueryResult;
|
import eu.eudat.model.result.QueryResult;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.query.DmpBlueprintQuery;
|
import eu.eudat.query.DmpBlueprintQuery;
|
||||||
import eu.eudat.query.lookup.DmpBlueprintLookup;
|
import eu.eudat.query.lookup.DmpBlueprintLookup;
|
||||||
import eu.eudat.service.dmpblueprint.DmpBlueprintService;
|
import eu.eudat.service.dmpblueprint.DmpBlueprintService;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.service.responseutils.ResponseUtilsService;
|
||||||
import gr.cite.tools.auditing.AuditService;
|
import gr.cite.tools.auditing.AuditService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.censor.CensorFactory;
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
@ -27,17 +25,23 @@ import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
import gr.cite.tools.validation.MyValidate;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.AbstractMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(path = "api/dmp-blueprint")
|
@RequestMapping(path = "api/dmp-blueprint")
|
||||||
|
@ -112,7 +116,7 @@ public class DmpBlueprintController {
|
||||||
|
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@Transactional
|
||||||
public DmpBlueprint persist(@MyValidate @RequestBody DmpBlueprintPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
public DmpBlueprint persist(@MyValidate @RequestBody DmpBlueprintPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
|
||||||
logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
@ -137,27 +141,49 @@ public class DmpBlueprintController {
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
@GetMapping("clone/{id}")
|
||||||
// public @ResponseBody
|
public DmpBlueprint buildClone(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||||
// ResponseEntity getXml(@RequestHeader("Content-Type") String contentType, @PathVariable String id) throws IOException, InvalidApplicationException {
|
logger.debug(new MapLogEntry("clone" + DmpBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
//
|
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
|
||||||
// if (contentType.equals("application/xml")) {
|
|
||||||
// DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id);
|
DmpBlueprint model = this.dmpBlueprintService.buildClone(id, fieldSet);
|
||||||
// return this.dataManagementProfileManager.getDocument(dataManagementPlanBlueprintListingModel);
|
|
||||||
// }else {
|
this.auditService.track(AuditableAction.DmpBlueprint_Clone, Map.ofEntries(
|
||||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
// }
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
// }
|
));
|
||||||
//
|
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||||
// @RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
|
||||||
// public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file) throws Exception {
|
return model;
|
||||||
// this.authorizationService.authorizeForce(Permission.AdminRole);
|
}
|
||||||
//
|
|
||||||
// eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint dmpBlueprintModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
@RequestMapping(method = RequestMethod.GET, value = {"/xml/export/{id}"}, produces = "application/xml")
|
||||||
// DataManagementPlanBlueprintListingModel dmpBlueprint = dmpBlueprintModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
public @ResponseBody ResponseEntity getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
// this.dataManagementProfileManager.createOrUpdateBlueprint(dmpBlueprint);
|
logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("id", id));
|
||||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
|
|
||||||
// .status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
ResponseEntity response = this.dmpBlueprintService.exportXml(id);
|
||||||
// }
|
|
||||||
|
this.auditService.track(AuditableAction.DmpBlueprint_GetXml, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("id", id)
|
||||||
|
));
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/xml/import"})
|
||||||
|
public DmpBlueprint importXml(@RequestParam("file") MultipartFile file, FieldSet fieldSet) throws IOException, JAXBException, InvalidApplicationException, ParserConfigurationException, TransformerException {
|
||||||
|
logger.debug(new MapLogEntry("clone" + DmpBlueprint.class.getSimpleName()).And("file", file));
|
||||||
|
|
||||||
|
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
DmpBlueprint model = this.dmpBlueprintService.importXml(file.getBytes(), file.getOriginalFilename(), fieldSet);
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.DmpBlueprint_Clone, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("file", file),
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
|
));
|
||||||
|
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.managers;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.enums.EntityType;
|
import eu.eudat.commons.enums.EntityType;
|
||||||
import eu.eudat.commons.types.dmpblueprint.*;
|
import eu.eudat.commons.types.dmpblueprint.*;
|
||||||
|
@ -68,10 +69,12 @@ import eu.eudat.models.data.listingmodels.*;
|
||||||
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
|
import eu.eudat.query.DmpBlueprintQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.service.dmpblueprint.DmpBlueprintService;
|
import eu.eudat.service.dmpblueprint.DmpBlueprintService;
|
||||||
import eu.eudat.types.MetricNames;
|
import eu.eudat.types.MetricNames;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||||
|
@ -129,10 +132,13 @@ public class DataManagementPlanManager {
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
private final DmpBlueprintService dmpBlueprintService;
|
private final DmpBlueprintService dmpBlueprintService;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager, UserManager userManager,
|
public DataManagementPlanManager(XmlHandlingService xmlHandlingService, ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager, UserManager userManager,
|
||||||
MetricsManager metricsManager, ConfigLoader configLoader, List<RepositoryDeposit> repositoriesDeposit, UserScope userScope, AuthorizationService authorizationService, DmpBlueprintService dmpBlueprintService) {
|
MetricsManager metricsManager, ConfigLoader configLoader, List<RepositoryDeposit> repositoriesDeposit, UserScope userScope, AuthorizationService authorizationService, DmpBlueprintService dmpBlueprintService, QueryFactory queryFactory) {
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||||
|
@ -144,6 +150,7 @@ public class DataManagementPlanManager {
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.dmpBlueprintService = dmpBlueprintService;
|
this.dmpBlueprintService = dmpBlueprintService;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
this.objectMapper = new ObjectMapper();
|
this.objectMapper = new ObjectMapper();
|
||||||
this.repositoriesDeposit = repositoriesDeposit;
|
this.repositoriesDeposit = repositoriesDeposit;
|
||||||
}
|
}
|
||||||
|
@ -312,7 +319,7 @@ public class DataManagementPlanManager {
|
||||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||||
if (!isPublic && !this.userScope.isSet()) {
|
if (!isPublic && !this.userScope.isSet()) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else if (!isPublic && (dataManagementPlanEntity.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe()))) {
|
} else if (!isPublic && (dataManagementPlanEntity.getUsers().stream().noneMatch(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())))) {
|
||||||
if (!dataManagementPlanEntity.isPublic()) {
|
if (!dataManagementPlanEntity.isPublic()) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
}
|
}
|
||||||
|
@ -500,7 +507,7 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
DMP newDmp = dataManagementPlan.toDataModel();
|
DMP newDmp = dataManagementPlan.toDataModel();
|
||||||
if(dataManagementPlan.getProfile() != null){
|
if(dataManagementPlan.getProfile() != null){
|
||||||
DmpBlueprintEntity dmpBlueprint = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(dataManagementPlan.getProfile().getId());
|
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(dataManagementPlan.getProfile().getId()).first();
|
||||||
newDmp.setProfile(dmpBlueprint);
|
newDmp.setProfile(dmpBlueprint);
|
||||||
}
|
}
|
||||||
if (newDmp.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
if (newDmp.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
|
@ -534,7 +541,7 @@ public class DataManagementPlanManager {
|
||||||
} else dmp = new DMP();
|
} else dmp = new DMP();
|
||||||
|
|
||||||
newDmp.setCreated(dmp.getCreated() == null ? new Date() : dmp.getCreated());
|
newDmp.setCreated(dmp.getCreated() == null ? new Date() : dmp.getCreated());
|
||||||
if (newDmp.getUsers()!= null && newDmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe())
|
if (newDmp.getUsers()!= null && newDmp.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0) {
|
.collect(Collectors.toList()).size() == 0) {
|
||||||
List<UserDMP> userDMPList = new ArrayList<>(newDmp.getUsers());
|
List<UserDMP> userDMPList = new ArrayList<>(newDmp.getUsers());
|
||||||
for (UserInfoListingModel userInfoListingModel : dataManagementPlan.getUsers()) {
|
for (UserInfoListingModel userInfoListingModel : dataManagementPlan.getUsers()) {
|
||||||
|
@ -1374,9 +1381,7 @@ public class DataManagementPlanManager {
|
||||||
// // Space below Datasets.
|
// // Space below Datasets.
|
||||||
// XWPFParagraph parBreakDatasets = document.createParagraph();
|
// XWPFParagraph parBreakDatasets = document.createParagraph();
|
||||||
|
|
||||||
DmpBlueprintEntity dmpProfile = dmpEntity.getProfile();
|
DefinitionEntity dmpBlueprint = this.xmlHandlingService.xmlSerializableFromXmlSafe(DefinitionEntity.class, dmpEntity.getProfile().getDefinition());
|
||||||
DefinitionEntity dmpBlueprint = new DefinitionEntity().fromXml(XmlBuilder.fromXml(dmpProfile.getDefinition()).getDocumentElement());
|
|
||||||
|
|
||||||
for(SectionEntity section: dmpBlueprint.getSections()){
|
for(SectionEntity section: dmpBlueprint.getSections()){
|
||||||
wordBuilder.addParagraphContent("Section " + section.getOrdinal(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
|
wordBuilder.addParagraphContent("Section " + section.getOrdinal(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
|
||||||
XWPFParagraph sectionInfoParagraph = document.createParagraph();
|
XWPFParagraph sectionInfoParagraph = document.createParagraph();
|
||||||
|
@ -1700,7 +1705,7 @@ public class DataManagementPlanManager {
|
||||||
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
||||||
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||||
if (!dmp.isPublic() && dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe()).collect(Collectors.toList()).size() == 0)
|
if (!dmp.isPublic() && dmp.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
final Boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
final Boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||||
final Boolean isPublic = dmp.isPublic();
|
final Boolean isPublic = dmp.isPublic();
|
||||||
|
@ -1981,7 +1986,7 @@ public class DataManagementPlanManager {
|
||||||
@Transactional
|
@Transactional
|
||||||
public FileEnvelope getRDAJsonDocument(String id) throws Exception {
|
public FileEnvelope getRDAJsonDocument(String id) throws Exception {
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||||
if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe()))
|
if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())))
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
final boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
final boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||||
final boolean isPublic = dmp.isPublic();
|
final boolean isPublic = dmp.isPublic();
|
||||||
|
|
|
@ -293,7 +293,7 @@ public class DatasetManager {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
if (datasetEntity.getDmp().getUsers()
|
if (datasetEntity.getDmp().getUsers()
|
||||||
.stream().filter(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe())
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0 && !datasetEntity.getDmp().isPublic())
|
.collect(Collectors.toList()).size() == 0 && !datasetEntity.getDmp().isPublic())
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
||||||
|
@ -375,7 +375,7 @@ public class DatasetManager {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else
|
} else
|
||||||
if (!isPublic && datasetEntity.getDmp().getUsers()
|
if (!isPublic && datasetEntity.getDmp().getUsers()
|
||||||
.stream().noneMatch(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe())) {
|
.stream().noneMatch(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else if (isPublic && !datasetEntity.getDmp().isPublic()) {
|
} else if (isPublic && !datasetEntity.getDmp().isPublic()) {
|
||||||
throw new ForbiddenException("Selected Dataset is not public");
|
throw new ForbiddenException("Selected Dataset is not public");
|
||||||
|
@ -410,7 +410,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
DMP dmpEntity = datasetEntity.getDmp();
|
DMP dmpEntity = datasetEntity.getDmp();
|
||||||
|
|
||||||
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe()).collect(Collectors.toList()).size() == 0)
|
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
|
||||||
wordBuilder.fillFirstPage(dmpEntity, datasetEntity, document, true);
|
wordBuilder.fillFirstPage(dmpEntity, datasetEntity, document, true);
|
||||||
|
@ -548,7 +548,7 @@ public class DatasetManager {
|
||||||
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
||||||
.stream().filter(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe())
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
String label = datasetEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
String label = datasetEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||||
|
@ -577,7 +577,7 @@ public class DatasetManager {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
||||||
.stream().filter(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe())
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
|
|
@ -41,8 +41,6 @@ public interface DatabaseRepository {
|
||||||
|
|
||||||
ContentDao getContentDao();
|
ContentDao getContentDao();
|
||||||
|
|
||||||
DMPProfileDao getDmpProfileDao();
|
|
||||||
|
|
||||||
DatasetExternalDatasetDao getDatasetExternalDatasetDao();
|
DatasetExternalDatasetDao getDatasetExternalDatasetDao();
|
||||||
|
|
||||||
DatasetServiceDao getDatasetServiceDao();
|
DatasetServiceDao getDatasetServiceDao();
|
||||||
|
|
|
@ -45,8 +45,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
||||||
|
|
||||||
private ContentDao contentDao;
|
private ContentDao contentDao;
|
||||||
|
|
||||||
private DMPProfileDao dmpProfileDao;
|
|
||||||
|
|
||||||
private DatasetExternalDatasetDao datasetExternalDatasetDao;
|
private DatasetExternalDatasetDao datasetExternalDatasetDao;
|
||||||
|
|
||||||
private DatasetServiceDao datasetServiceDao;
|
private DatasetServiceDao datasetServiceDao;
|
||||||
|
@ -240,16 +238,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
||||||
this.contentDao = contentDao;
|
this.contentDao = contentDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DMPProfileDao getDmpProfileDao() {
|
|
||||||
return dmpProfileDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public void setDmpProfileDao(DMPProfileDao dmpProfileDao) {
|
|
||||||
this.dmpProfileDao = dmpProfileDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasetExternalDatasetDao getDatasetExternalDatasetDao() {
|
public DatasetExternalDatasetDao getDatasetExternalDatasetDao() {
|
||||||
return datasetExternalDatasetDao;
|
return datasetExternalDatasetDao;
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
|
||||||
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
|
||||||
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.SectionEntity;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
|
||||||
import eu.eudat.model.DmpBlueprint;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
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.UUID;
|
|
||||||
|
|
||||||
public class ExportXmlBuilderDmpBlueprint {
|
|
||||||
|
|
||||||
|
|
||||||
public File build(DmpBlueprintEntity dmpProfile, Environment environment) throws IOException {
|
|
||||||
|
|
||||||
File xmlFile = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".xml");
|
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
|
|
||||||
Document xmlDoc = XmlBuilder.getDocument();
|
|
||||||
Element root = xmlDoc.createElement("root");
|
|
||||||
Element definition = xmlDoc.createElement("definition");
|
|
||||||
// Element root = xmlDoc.createElement(dmpProfile.getLabel());
|
|
||||||
definition.appendChild(createDefinition(new DefinitionEntity().fromXml(XmlBuilder.fromXml(dmpProfile.getDefinition()).getDocumentElement()), xmlDoc));
|
|
||||||
root.appendChild(definition);
|
|
||||||
xmlDoc.appendChild(root);
|
|
||||||
String xml = XmlBuilder.generateXml(xmlDoc);
|
|
||||||
writer.write(xml);
|
|
||||||
writer.close();
|
|
||||||
return xmlFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Element createDefinition(DefinitionEntity dmpDefinition, Document doc) {
|
|
||||||
Element sections = doc.createElement("sections");
|
|
||||||
for (SectionEntity section : dmpDefinition.getSections()) {
|
|
||||||
sections.appendChild(section.toXml(doc));
|
|
||||||
}
|
|
||||||
return sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
|
||||||
|
|
||||||
import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.xml.bind.JAXBContext;
|
|
||||||
import jakarta.xml.bind.JAXBException;
|
|
||||||
import jakarta.xml.bind.Unmarshaller;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class ImportXmlBuilderDmpBlueprint {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDmpBlueprint.class);
|
|
||||||
|
|
||||||
public DmpBlueprint build(File xmlFile) throws IOException {
|
|
||||||
DmpBlueprint dmpBlueprint = new DmpBlueprint();
|
|
||||||
JAXBContext jaxbContext = null;
|
|
||||||
try {
|
|
||||||
jaxbContext = JAXBContext.newInstance(DmpBlueprint.class);
|
|
||||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
|
||||||
dmpBlueprint = (DmpBlueprint) unmarshaller.unmarshal(xmlFile);
|
|
||||||
} catch (JAXBException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dmpBlueprint;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DmpBlueprintStatus;
|
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@XmlRootElement(name = "root")
|
|
||||||
public class DmpBlueprint {
|
|
||||||
|
|
||||||
private DmpBlueprintDefinition dmpBlueprintDefinition;
|
|
||||||
|
|
||||||
@XmlElement(name = "definition")
|
|
||||||
public DmpBlueprintDefinition getDmpBlueprintDefinition() {
|
|
||||||
return dmpBlueprintDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmpBlueprintDefinition(DmpBlueprintDefinition dmpBlueprintDefinition) {
|
|
||||||
this.dmpBlueprintDefinition = dmpBlueprintDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DmpBlueprintEntity toDmpProfileCompositeModel(String label) {
|
|
||||||
DmpBlueprintEntity dmpProfileModel = new DmpBlueprintEntity();
|
|
||||||
dmpProfileModel.setLabel(label);
|
|
||||||
dmpProfileModel.setStatus(DmpBlueprintStatus.Draft);
|
|
||||||
dmpProfileModel.setCreatedAt(Instant.now());
|
|
||||||
dmpProfileModel.setUpdatedAt(Instant.now());
|
|
||||||
if (this.dmpBlueprintDefinition != null) {
|
|
||||||
Document document = XmlBuilder.getDocument();
|
|
||||||
document.appendChild(this.dmpBlueprintDefinition.toDmpBlueprintCompositeModel().toXml(document));
|
|
||||||
dmpProfileModel.setDefinition(XmlBuilder.generateXml(document));
|
|
||||||
}
|
|
||||||
return dmpProfileModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -101,6 +101,25 @@ permissions:
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
CloneDmpBlueprint:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
ExportDmpBlueprint:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
ImportDmpBlueprint:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
DeleteDmpBlueprint:
|
DeleteDmpBlueprint:
|
||||||
roles:
|
roles:
|
||||||
- Admin
|
- Admin
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { HelpService } from '@app/core/model/configuration-models/help-service.m
|
||||||
import { Logging } from '@app/core/model/configuration-models/logging.model';
|
import { Logging } from '@app/core/model/configuration-models/logging.model';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { KeycloakConfiguration } from '@app/core/model/configuration-models/keycloak-configuration.model';
|
import { KeycloakConfiguration } from '@app/core/model/configuration-models/keycloak-configuration.model';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
@ -36,6 +37,11 @@ export class ConfigurationService extends BaseComponent {
|
||||||
return this._defaultCulture;
|
return this._defaultCulture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _defaultBlueprintId: Guid;
|
||||||
|
get defaultBlueprintId(): Guid {
|
||||||
|
return this._defaultBlueprintId;
|
||||||
|
}
|
||||||
|
|
||||||
private _defaultTimezone: string;
|
private _defaultTimezone: string;
|
||||||
get defaultTimezone(): string {
|
get defaultTimezone(): string {
|
||||||
return this._defaultTimezone || 'UTC';
|
return this._defaultTimezone || 'UTC';
|
||||||
|
@ -153,6 +159,7 @@ export class ConfigurationService extends BaseComponent {
|
||||||
this._app = config.App;
|
this._app = config.App;
|
||||||
this._helpService = HelpService.parseValue(config.HelpService);
|
this._helpService = HelpService.parseValue(config.HelpService);
|
||||||
this._defaultCulture = config.defaultCulture;
|
this._defaultCulture = config.defaultCulture;
|
||||||
|
this._defaultBlueprintId = config.defaultBlueprintId;
|
||||||
this._defaultTimezone = config.defaultTimezone;
|
this._defaultTimezone = config.defaultTimezone;
|
||||||
this._defaultLanguage = config.defaultLanguage;
|
this._defaultLanguage = config.defaultLanguage;
|
||||||
this._availableLanguages = config.availableLanguages;
|
this._availableLanguages = config.availableLanguages;
|
||||||
|
|
|
@ -64,45 +64,34 @@ export class DmpBlueprintService {
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clone(id: string, reqFields: string[] = []): Observable<DmpBlueprint> {
|
||||||
|
const url = `${this.apiBase}/clone/${id}`;
|
||||||
|
const options = { params: { f: reqFields } };
|
||||||
|
|
||||||
|
return this.http
|
||||||
getPaged(dataTableRequest: DataTableRequest<DmpBlueprintCriteria>): Observable<DataTableData<DmpBlueprint>> {
|
.get<DmpBlueprint>(url, options).pipe(
|
||||||
return this.http.post<DataTableData<DmpBlueprint>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getSingleBlueprint(id: String): Observable<DmpBlueprint> {
|
downloadXML(id: Guid): Observable<HttpResponse<Blob>> {
|
||||||
return this.http.get<DmpBlueprint>(this.actionUrl + 'getSingleBlueprint/' + id, { headers: this.headers });
|
const url = `${this.apiBase}/xml/export/${id}`;
|
||||||
|
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml');
|
||||||
|
const params = new BaseHttpParams();
|
||||||
|
params.interceptorContext = {
|
||||||
|
excludedInterceptors: [InterceptorType.JSONContentType]
|
||||||
|
};
|
||||||
|
return this.httpClient.get(url, { params: params, responseType: 'blob', observe: 'response', headers: headerXml });
|
||||||
}
|
}
|
||||||
|
|
||||||
createDmp(dataManagementPlanModel: DmpBlueprint): Observable<DmpBlueprint> {
|
uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable<DataTableData<DmpBlueprint>> {
|
||||||
return this.http.post<DmpBlueprint>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
const url = `${this.apiBase}/xml/import`;
|
||||||
}
|
|
||||||
|
|
||||||
createBlueprint(dmpBlueprint: DmpBlueprint): Observable<DmpBlueprint> {
|
|
||||||
return this.http.post<DmpBlueprint>(this.actionUrl + 'blueprint', dmpBlueprint, { 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();
|
const params = new BaseHttpParams();
|
||||||
params.interceptorContext = {
|
params.interceptorContext = {
|
||||||
excludedInterceptors: [InterceptorType.JSONContentType]
|
excludedInterceptors: [InterceptorType.JSONContentType]
|
||||||
};
|
};
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file[0], labelSent);
|
formData.append('file', file[0], labelSent);
|
||||||
return this.http.post(this.actionUrl + "upload", formData, { params: params });
|
return this.http.post(url, formData, { params: params });
|
||||||
}
|
|
||||||
|
|
||||||
clone(id: string): Observable<DmpBlueprint> {
|
|
||||||
return this.http.post<DmpBlueprint>(this.actionUrl + 'clone/' + id, { headers: this.headers });
|
|
||||||
}
|
|
||||||
|
|
||||||
externalAutocomplete(lookUpItem: RequestItem<DmpBlueprintExternalAutocompleteCriteria>): Observable<any> {
|
|
||||||
return this.httpClient.post(this.actionUrl + 'search/autocomplete', lookUpItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -44,7 +44,9 @@ import { HttpClient } from '@angular/common/http';
|
||||||
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
||||||
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
||||||
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
||||||
import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-recent-edited-activity',
|
selector: 'app-recent-edited-activity',
|
||||||
|
@ -305,9 +307,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
||||||
this.dmpFormGroup = this.dmpModel.buildForm();
|
this.dmpFormGroup = this.dmpModel.buildForm();
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
||||||
this.dmpBlueprintService.getSingleBlueprint(this.formGroup.get('profile').value)
|
this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => {
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
this.checkForGrant(result.definition);
|
this.checkForGrant(result.definition);
|
||||||
this.checkForFunder(result.definition);
|
this.checkForFunder(result.definition);
|
||||||
this.checkForProject(result.definition);
|
this.checkForProject(result.definition);
|
||||||
|
@ -321,6 +321,40 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private getBlueprintDefinition(blueprintId: Guid, successFunction) {
|
||||||
|
this.dmpBlueprintService.getSingle(blueprintId, [
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
.pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
data => successFunction(data),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
||||||
let hasGrant = false;
|
let hasGrant = false;
|
||||||
blueprint.sections.forEach(section => section.fields.forEach(
|
blueprint.sections.forEach(section => section.fields.forEach(
|
||||||
|
|
|
@ -36,7 +36,9 @@ import { HttpClient } from '@angular/common/http';
|
||||||
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
||||||
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
||||||
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
||||||
import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-recent-edited-dmp-activity',
|
selector: 'app-recent-edited-dmp-activity',
|
||||||
|
@ -258,9 +260,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
|
||||||
this.dmpFormGroup = this.dmpModel.buildForm();
|
this.dmpFormGroup = this.dmpModel.buildForm();
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
||||||
this.dmpBlueprintService.getSingleBlueprint(this.formGroup.get('profile').value)
|
this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => {
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
this.checkForGrant(result.definition);
|
this.checkForGrant(result.definition);
|
||||||
this.checkForFunder(result.definition);
|
this.checkForFunder(result.definition);
|
||||||
this.checkForProject(result.definition);
|
this.checkForProject(result.definition);
|
||||||
|
@ -274,6 +274,37 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getBlueprintDefinition(blueprintId: Guid, successFunction) {
|
||||||
|
this.dmpBlueprintService.getSingle(blueprintId, [
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
.pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
data => successFunction(data),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
||||||
let hasGrant = false;
|
let hasGrant = false;
|
||||||
blueprint.sections.forEach(section => section.fields.forEach(
|
blueprint.sections.forEach(section => section.fields.forEach(
|
||||||
|
|
|
@ -11,6 +11,8 @@ import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.servic
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
|
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
|
||||||
import { Guid } from '@common/types/guid';
|
import { Guid } from '@common/types/guid';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-editor-component',
|
selector: 'app-dataset-editor-component',
|
||||||
|
@ -54,7 +56,31 @@ export class DatasetEditorComponent extends BaseComponent {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value;
|
const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value;
|
||||||
const blueprintId = this.formGroup.get('dmp').value.profile.id;
|
const blueprintId = this.formGroup.get('dmp').value.profile.id;
|
||||||
this.dmpBlueprintService.getSingleBlueprint(blueprintId)
|
this.dmpBlueprintService.getSingle(blueprintId,
|
||||||
|
[
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
||||||
|
]
|
||||||
|
)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(result => {
|
.subscribe(result => {
|
||||||
const section = result.definition.sections[dmpSectionIndex];
|
const section = result.definition.sections[dmpSectionIndex];
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms
|
||||||
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog";
|
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog";
|
||||||
import { DatasetProfileModel } from "@app/core/model/dataset/dataset-profile";
|
import { DatasetProfileModel } from "@app/core/model/dataset/dataset-profile";
|
||||||
import { Prefilling } from "@app/core/model/dataset/prefilling";
|
import { Prefilling } from "@app/core/model/dataset/prefilling";
|
||||||
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint";
|
||||||
import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service";
|
import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service";
|
||||||
import { PrefillingService } from "@app/core/services/prefilling.service";
|
import { PrefillingService } from "@app/core/services/prefilling.service";
|
||||||
import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service";
|
import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service";
|
||||||
|
@ -13,6 +14,7 @@ import { Guid } from "@common/types/guid";
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
import { map, takeUntil } from "rxjs/operators";
|
import { map, takeUntil } from "rxjs/operators";
|
||||||
|
import { nameof } from "ts-simple-nameof";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'prefill-dataset-component',
|
selector: 'prefill-dataset-component',
|
||||||
|
@ -61,7 +63,7 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
addProfileIfUsedLessThanMax(profile: DatasetProfileModel) {
|
addProfileIfUsedLessThanMax(profile: DatasetProfileModel) {
|
||||||
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
|
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
|
||||||
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
|
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
|
||||||
this.dmpBlueprintService.getSingleBlueprint(blueprintId)
|
this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(result => {
|
.subscribe(result => {
|
||||||
const section = result.definition.sections[dmpSectionIndex];
|
const section = result.definition.sections[dmpSectionIndex];
|
||||||
|
@ -94,7 +96,7 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
|
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
|
||||||
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
|
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
|
||||||
this.dmpBlueprintService.getSingleBlueprint(blueprintId)
|
this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(result => {
|
.subscribe(result => {
|
||||||
const section = result.definition.sections[dmpSectionIndex];
|
const section = result.definition.sections[dmpSectionIndex];
|
||||||
|
@ -131,6 +133,32 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getBlueprintDefinitionFields() {
|
||||||
|
return [
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public compareWith(object1: any, object2: any) {
|
public compareWith(object1: any, object2: any) {
|
||||||
return object1 && object2 && object1.id === object2.id;
|
return object1 && object2 && object1.id === object2.id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,9 @@ import { MatDialog } from '@angular/material/dialog';
|
||||||
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
||||||
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
||||||
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
||||||
import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -93,9 +95,7 @@ export class DmpCloneComponent extends BaseComponent implements OnInit {
|
||||||
this.formGroup = this.dmp.buildForm();
|
this.formGroup = this.dmp.buildForm();
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
||||||
this.dmpBlueprintService.getSingleBlueprint(this.formGroup.get('profile').value)
|
this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => {
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
this.checkForGrant(result.definition);
|
this.checkForGrant(result.definition);
|
||||||
this.checkForFunder(result.definition);
|
this.checkForFunder(result.definition);
|
||||||
this.checkForProject(result.definition);
|
this.checkForProject(result.definition);
|
||||||
|
@ -140,6 +140,38 @@ export class DmpCloneComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getBlueprintDefinition(blueprintId: Guid, successFunction) {
|
||||||
|
this.dmpBlueprintService.getSingle(blueprintId, [
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
.pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
data => successFunction(data),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
||||||
let hasGrant = false;
|
let hasGrant = false;
|
||||||
blueprint.sections.forEach(section => section.fields.forEach(
|
blueprint.sections.forEach(section => section.fields.forEach(
|
||||||
|
|
|
@ -130,8 +130,6 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
|
|
||||||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||||
|
|
||||||
readonly defaultBlueprintId: Guid = Guid.parse('86635178-36a6-484f-9057-a934e4eeecd5');
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dmpBlueprintService: DmpBlueprintService,
|
private dmpBlueprintService: DmpBlueprintService,
|
||||||
private datasetService: DatasetService,
|
private datasetService: DatasetService,
|
||||||
|
@ -431,7 +429,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
}
|
}
|
||||||
|
|
||||||
selectDefaultBlueprint() {
|
selectDefaultBlueprint() {
|
||||||
this.getSingle(this.defaultBlueprintId, data => {
|
this.getSingle(this.configurationService.defaultBlueprintId, data => {
|
||||||
this.selectedDmpBlueprintDefinition = data.definition;
|
this.selectedDmpBlueprintDefinition = data.definition;
|
||||||
this.formGroup.get('profile').setValue(data.id);
|
this.formGroup.get('profile').setValue(data.id);
|
||||||
this.maxStep = this.selectedDmpBlueprintDefinition.sections.length;
|
this.maxStep = this.selectedDmpBlueprintDefinition.sections.length;
|
||||||
|
|
|
@ -11,14 +11,11 @@ import {AvailableProfilesComponent} from '@app/ui/dmp/editor/available-profiles/
|
||||||
import {DatasetsTabComponent} from '@app/ui/dmp/editor/datasets-tab/datasets-tab.component';
|
import {DatasetsTabComponent} from '@app/ui/dmp/editor/datasets-tab/datasets-tab.component';
|
||||||
import {DmpEditorComponent} from '@app/ui/dmp/editor/dmp-editor.component';
|
import {DmpEditorComponent} from '@app/ui/dmp/editor/dmp-editor.component';
|
||||||
import {DmpFinalizeDialogComponent} from '@app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
|
import {DmpFinalizeDialogComponent} from '@app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
|
||||||
import {
|
|
||||||
DynamicDmpFieldResolverComponent
|
|
||||||
} from '@app/ui/dmp/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component';
|
|
||||||
import {
|
import {
|
||||||
DynamicFieldGrantComponent
|
DynamicFieldGrantComponent
|
||||||
} from '@app/ui/dmp/editor/dynamic-fields-grant/dynamic-field-grant/dynamic-field-grant.component';
|
} from '@app/ui/dmp/editor/dynamic-fields-grant/dynamic-field-grant/dynamic-field-grant.component';
|
||||||
import {DynamicFieldsGrantComponent} from '@app/ui/dmp/editor/dynamic-fields-grant/dynamic-fields-grant.component';
|
import {DynamicFieldsGrantComponent} from '@app/ui/dmp/editor/dynamic-fields-grant/dynamic-fields-grant.component';
|
||||||
import {GeneralTabComponent} from '@app/ui/dmp/editor/general-tab/general-tab.component';
|
// import {GeneralTabComponent} from '@app/ui/dmp/editor/general-tab/general-tab.component';
|
||||||
import {GrantTabComponent} from '@app/ui/dmp/editor/grant-tab/grant-tab.component';
|
import {GrantTabComponent} from '@app/ui/dmp/editor/grant-tab/grant-tab.component';
|
||||||
import {PeopleTabComponent} from '@app/ui/dmp/editor/people-tab/people-tab.component';
|
import {PeopleTabComponent} from '@app/ui/dmp/editor/people-tab/people-tab.component';
|
||||||
import {InvitationAcceptedComponent} from '@app/ui/dmp/invitation/accepted/dmp-invitation-accepted.component';
|
import {InvitationAcceptedComponent} from '@app/ui/dmp/invitation/accepted/dmp-invitation-accepted.component';
|
||||||
|
@ -91,12 +88,10 @@ import { DmpEditorBlueprintComponent } from './dmp-editor-blueprint/dmp-editor-b
|
||||||
AddResearcherComponent,
|
AddResearcherComponent,
|
||||||
AvailableProfilesComponent,
|
AvailableProfilesComponent,
|
||||||
DmpFinalizeDialogComponent,
|
DmpFinalizeDialogComponent,
|
||||||
DynamicDmpFieldResolverComponent,
|
|
||||||
DynamicFieldsGrantComponent,
|
DynamicFieldsGrantComponent,
|
||||||
DynamicFieldGrantComponent,
|
DynamicFieldGrantComponent,
|
||||||
DmpUploadDialogue,
|
DmpUploadDialogue,
|
||||||
DmpListingItemComponent,
|
DmpListingItemComponent,
|
||||||
GeneralTabComponent,
|
|
||||||
PeopleTabComponent,
|
PeopleTabComponent,
|
||||||
GrantTabComponent,
|
GrantTabComponent,
|
||||||
DatasetsTabComponent,
|
DatasetsTabComponent,
|
||||||
|
|
|
@ -85,7 +85,6 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
|
||||||
filteredOptions: DmpBlueprint[];
|
filteredOptions: DmpBlueprint[];
|
||||||
selectedDmpBlueprintDefinition: DmpBlueprintDefinition;
|
selectedDmpBlueprintDefinition: DmpBlueprintDefinition;
|
||||||
|
|
||||||
DynamicDmpFieldResolverComponent: any;
|
|
||||||
lock: LockModel;
|
lock: LockModel;
|
||||||
lockStatus: Boolean;
|
lockStatus: Boolean;
|
||||||
|
|
||||||
|
@ -403,12 +402,6 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
|
||||||
// ]);
|
// ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dmpBlueprintSearch(query: string) {
|
|
||||||
let fields: Array<string> = new Array();
|
|
||||||
var request = new DataTableRequest<DmpBlueprintCriteria>(0, 10, { fields: fields });
|
|
||||||
request.criteria = new DmpBlueprintCriteria();
|
|
||||||
return this.dmpBlueprintService.getPaged(request).pipe(map(x => x.data));
|
|
||||||
}
|
|
||||||
|
|
||||||
// searchGrant(query: string) {
|
// searchGrant(query: string) {
|
||||||
// const grantRequestItem: RequestItem<GrantCriteria> = new RequestItem();
|
// const grantRequestItem: RequestItem<GrantCriteria> = new RequestItem();
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
<!-- <div *ngFor="let field of dmpBlueprintDefinition?.fields; let i = index" class="row">
|
|
||||||
<div class="col-md-8">
|
|
||||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpBlueprintFieldDataType.Date">
|
|
||||||
<input matInput [matDatepicker]="picker" [placeholder]="field.label"
|
|
||||||
[formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')"
|
|
||||||
[required]="field.required">
|
|
||||||
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
|
|
||||||
<mat-datepicker #picker></mat-datepicker>
|
|
||||||
<mat-error *ngIf="formGroup.get('properties').get('fields').get(''+i).get('value')['errors']">{{'GENERAL.VALIDATION.REQUIRED'
|
|
||||||
| translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpBlueprintFieldDataType.Text">
|
|
||||||
<input matInput [placeholder]="field.label"
|
|
||||||
[formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')"
|
|
||||||
[required]="field.required">
|
|
||||||
<mat-error *ngIf="formGroup.get('properties').get('fields').get(''+i).get('value')['errors']">{{'GENERAL.VALIDATION.REQUIRED'
|
|
||||||
| translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field class="full-width" *ngIf="field.dataType == dmpBlueprintFieldDataType.Number">
|
|
||||||
<input matInput type="number" [placeholder]="field.label"
|
|
||||||
[formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')"
|
|
||||||
[required]="field.required">
|
|
||||||
<mat-error *ngIf="formGroup.get('properties').get('fields').get(''+i).get('value')['errors']">{{'GENERAL.VALIDATION.REQUIRED'
|
|
||||||
| translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
<div class="full-width" *ngIf="field.dataType == dmpBlueprintFieldDataType.ExternalAutocomplete">
|
|
||||||
<div *ngIf="field.externalAutocomplete.multiAutoComplete == false">
|
|
||||||
<mat-form-field class="full-width">
|
|
||||||
<app-single-auto-complete
|
|
||||||
[required]="false"
|
|
||||||
[formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')"
|
|
||||||
placeholder="{{field.label}}"
|
|
||||||
[configuration]="singleAutocompleteMap[field.id]">
|
|
||||||
</app-single-auto-complete>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="field.externalAutocomplete.multiAutoComplete == true">
|
|
||||||
<mat-form-field class="full-width">
|
|
||||||
<app-multiple-auto-complete
|
|
||||||
[required]="field.required"
|
|
||||||
[formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')"
|
|
||||||
placeholder="{{field.label}}"
|
|
||||||
[configuration]="multiAutocompleteMap[field.id]">
|
|
||||||
</app-multiple-auto-complete>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
//TODO: dtziotzios
|
|
||||||
-->
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
.full-width{
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
|
@ -1,109 +0,0 @@
|
||||||
import { Component, Input, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
|
|
||||||
import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
|
||||||
import { DmpBlueprintExtraFieldDataType } from '@app/core/common/enum/dmp-blueprint-field-type';
|
|
||||||
import { DmpBlueprintType } from '@app/core/common/enum/dmp-blueprint-type';
|
|
||||||
import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
|
||||||
import { DmpBlueprintExternalAutocompleteCriteria } from '@app/core/query/dmp/dmp-profile-external-autocomplete-criteria';
|
|
||||||
import { RequestItem } from '@app/core/query/request-item';
|
|
||||||
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
|
||||||
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
|
||||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-dynamic-dmp-field-resolver',
|
|
||||||
templateUrl: 'dynamic-dmp-field-resolver.component.html',
|
|
||||||
styleUrls: ['./dynamic-dmp-field-resolver.component.scss']
|
|
||||||
})
|
|
||||||
export class DynamicDmpFieldResolverComponent implements OnInit, OnDestroy {
|
|
||||||
|
|
||||||
|
|
||||||
dmpBlueprintFieldDataType = DmpBlueprintExtraFieldDataType;
|
|
||||||
dmpBlueprintTypeEnum = DmpBlueprintType;
|
|
||||||
singleAutocompleteMap: { [id: string]: SingleAutoCompleteConfiguration; } = {};
|
|
||||||
multiAutocompleteMap: { [id: string]: MultipleAutoCompleteConfiguration; } = {};
|
|
||||||
|
|
||||||
@Input() dmpBlueprintId: string;
|
|
||||||
@Input() dmpBlueprintDefinition: DmpBlueprintDefinition;
|
|
||||||
@Input() formGroup: UntypedFormGroup;
|
|
||||||
@Input() isUserOwner: boolean;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private dmpBlueprintService: DmpBlueprintService
|
|
||||||
) { }
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.createControleFields();
|
|
||||||
|
|
||||||
if (this.dmpBlueprintDefinition) {
|
|
||||||
// this.dmpBlueprintDefinition.fields.forEach(
|
|
||||||
// field => {
|
|
||||||
// if (field.externalAutocomplete) {
|
|
||||||
// if (field.externalAutocomplete.multiAutoComplete) {
|
|
||||||
// const multiConf: MultipleAutoCompleteConfiguration = {
|
|
||||||
// filterFn: this.externalAutocomplete.bind(this, field),
|
|
||||||
// initialItems: (extraData) => this.externalAutocomplete('', field.id),
|
|
||||||
// displayFn: (item) => item['label'],
|
|
||||||
// titleFn: (item) => item['label']
|
|
||||||
// }
|
|
||||||
// this.multiAutocompleteMap[field.id] = multiConf;
|
|
||||||
// } else {
|
|
||||||
// const singleConf: SingleAutoCompleteConfiguration = {
|
|
||||||
// filterFn: this.externalAutocomplete.bind(this, field),
|
|
||||||
// initialItems: (extraData) => this.externalAutocomplete('', field.id),
|
|
||||||
// displayFn: (item) => item['label'],
|
|
||||||
// titleFn: (item) => item['label']
|
|
||||||
// }
|
|
||||||
// this.singleAutocompleteMap[field.id] = singleConf;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
//TODO: dtziotzios
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
|
||||||
if (changes['dmpBlueprintDefinition'] && !changes['dmpBlueprintDefinition'].isFirstChange()) {
|
|
||||||
this.createControleFields();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
createControleFields(): void {
|
|
||||||
if (this.dmpBlueprintDefinition != null) {
|
|
||||||
const diasableBoolean = this.formGroup.disabled;
|
|
||||||
this.formGroup.addControl('properties', new UntypedFormBuilder().group([]));
|
|
||||||
(<UntypedFormGroup>this.formGroup.get('properties')).addControl('fields', new UntypedFormBuilder().array([]));
|
|
||||||
// this.dmpBlueprintDefinition.fields.forEach(item => {
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('properties').get('fields')).push(new UntypedFormBuilder().group({
|
|
||||||
// id: [{ value: item.id, disabled: diasableBoolean }],
|
|
||||||
// value: [{ value: item.value, disabled: diasableBoolean }]
|
|
||||||
// }));
|
|
||||||
// });
|
|
||||||
//TODO: dtziotzios
|
|
||||||
}
|
|
||||||
if (this.dmpBlueprintDefinition == null) {
|
|
||||||
this.formGroup.removeControl('properties');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.formGroup.removeControl('properties');
|
|
||||||
}
|
|
||||||
|
|
||||||
externalAutocomplete(query: any, extFieldID: any) {
|
|
||||||
const autocompleteRequestItem: RequestItem<DmpBlueprintExternalAutocompleteCriteria> = new RequestItem();
|
|
||||||
autocompleteRequestItem.criteria = new DmpBlueprintExternalAutocompleteCriteria();
|
|
||||||
|
|
||||||
if (typeof extFieldID == "string" && typeof query == "string") {
|
|
||||||
autocompleteRequestItem.criteria.like = query;
|
|
||||||
autocompleteRequestItem.criteria.profileID = this.dmpBlueprintId;
|
|
||||||
autocompleteRequestItem.criteria.fieldID = extFieldID;
|
|
||||||
} else {
|
|
||||||
autocompleteRequestItem.criteria.like = extFieldID;
|
|
||||||
autocompleteRequestItem.criteria.profileID = this.dmpBlueprintId;
|
|
||||||
autocompleteRequestItem.criteria.fieldID = query.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.dmpBlueprintService.externalAutocomplete(autocompleteRequestItem);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,182 +0,0 @@
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row" [formGroup]="formGroup">
|
|
||||||
<div class="col-sm-12 col-md-9 pt-4 pb-4 pl-4">
|
|
||||||
<div class="row pt-2">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label" required>
|
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
|
||||||
{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div class="row pt-2">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<!-- <textarea matInput class="description-area" -->
|
|
||||||
<textarea rows="3" matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description">
|
|
||||||
</textarea>
|
|
||||||
<!-- <mat-error *ngIf="formGroup.get('description').hasError('backendError')">
|
|
||||||
{{formGroup.get('description').getError('backendError').message}}
|
|
||||||
</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('description').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}
|
|
||||||
</mat-error> -->
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div class="row pt-2">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<app-multiple-auto-complete required='true' [formControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}" [configuration]="profilesAutoCompleteConfiguration">
|
|
||||||
</app-multiple-auto-complete>
|
|
||||||
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
|
|
||||||
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('profiles').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
<button matSuffix class="input-btn" [disabled]="formGroup.get('profiles').disabled" (click)="availableProfiles($event)">
|
|
||||||
<mat-icon class="icon-btn">view_list</mat-icon>
|
|
||||||
</button>
|
|
||||||
</mat-form-field>
|
|
||||||
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
|
|
||||||
</div>
|
|
||||||
<div class="row pt-1">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<app-multiple-auto-complete [formControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}" [configuration]="organisationsAutoCompleteConfiguration">
|
|
||||||
</app-multiple-auto-complete>
|
|
||||||
<mat-error *ngIf="formGroup.get('organisations').hasError('backendError')">
|
|
||||||
{{formGroup.get('organisations').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('organisations').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
|
|
||||||
translate}}</mat-error>
|
|
||||||
<mat-hint>{{'DMP-EDITOR.FIELDS.ORGANISATIONS-HINT' | translate}}</mat-hint>
|
|
||||||
<button *ngIf="showOrganizationCreator()" matSuffix class="input-btn" [disabled]="canAddOrganizations()" type="button" (click)="addOrganization($event)">
|
|
||||||
<mat-icon class="icon-btn">add_circle</mat-icon>
|
|
||||||
</button>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div class="row pt-3">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<app-multiple-auto-complete [formControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
|
|
||||||
</app-multiple-auto-complete>
|
|
||||||
<mat-error *ngIf="formGroup.get('researchers').hasError('backendError')">
|
|
||||||
{{formGroup.get('researchers').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('researchers').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
<button matSuffix class="input-btn" [disabled]="formGroup.get('researchers').disabled" type="button" (click)="addResearcher($event)">
|
|
||||||
<mat-icon class="icon-btn">add_circle</mat-icon>
|
|
||||||
</button>
|
|
||||||
</mat-form-field>
|
|
||||||
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
|
|
||||||
</div>
|
|
||||||
<div class="row pt-3">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
|
|
||||||
</app-multiple-auto-complete> -->
|
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}">
|
|
||||||
<mat-option *ngFor="let lang of getLanguageInfos()" [value]="lang.code">
|
|
||||||
{{ lang.name }}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('language').hasError('backendError')">
|
|
||||||
{{formGroup.get('extraProperties').get('language').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('language').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
|
|
||||||
</div>
|
|
||||||
<div class="row pt-3">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
|
|
||||||
</app-multiple-auto-complete> -->
|
|
||||||
<app-single-auto-complete [formControl]="formGroup.get('extraProperties').get('license')" placeholder="{{'DMP-EDITOR.FIELDS.LICENSE' | translate}}" [configuration]="licenseAutoCompleteConfiguration">
|
|
||||||
</app-single-auto-complete>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('backendError')">
|
|
||||||
{{formGroup.get('extraProperties').get('license').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
|
|
||||||
</div>
|
|
||||||
<div class="row pt-3">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
|
|
||||||
</app-multiple-auto-complete> -->
|
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('visible')" placeholder="{{'DMP-EDITOR.FIELDS.VISIBILITY' | translate}}">
|
|
||||||
<mat-option *ngFor="let vis of visibles" [value]="vis.value">
|
|
||||||
{{vis.name | translate}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('visible').hasError('backendError')">
|
|
||||||
{{formGroup.get('extraProperties').get('visible').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('visible').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
|
|
||||||
</div>
|
|
||||||
<div class="row pt-3" *ngIf="formGroup.get('extraProperties').get('visible').value">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
|
|
||||||
</app-multiple-auto-complete> -->
|
|
||||||
<input matInput [matDatepicker]="picker" [formControl]="formGroup.get('extraProperties').get('publicDate')" placeholder="{{'DMP-EDITOR.FIELDS.PUBLICATION' | translate}}">
|
|
||||||
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
|
|
||||||
<mat-datepicker #picker></mat-datepicker>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('publicDate').hasError('backendError')">
|
|
||||||
{{formGroup.get('extraProperties').get('publicDate').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('publicDate').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
|
|
||||||
</div>
|
|
||||||
<div class="row pt-3">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
|
|
||||||
</app-multiple-auto-complete> -->
|
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('contact')" placeholder="{{'DMP-EDITOR.FIELDS.CONTACT' | translate}}">
|
|
||||||
<mat-option *ngFor="let vis of getAssociates()" [value]="vis.id">
|
|
||||||
{{vis.name | translate}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('contact').hasError('backendError')">
|
|
||||||
{{formGroup.get('extraProperties').get('contact').getError('backendError').message}}</mat-error>
|
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('contact').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
|
|
||||||
</div>
|
|
||||||
<div class="row pt-3">
|
|
||||||
<mat-label class="col-12 cost-placeholder">Costs</mat-label>
|
|
||||||
<app-cost-listing class="col-12" [form] = "formGroup.get('extraProperties').get('costs')"></app-cost-listing>
|
|
||||||
<button class="col-12 cost-add" matSuffix class="input-btn" type="button" (click)="addCost($event)">
|
|
||||||
<mat-icon class="icon-btn">add_circle</mat-icon>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="row pt-2">
|
|
||||||
<mat-form-field class="col-sm-12 col-md-8">
|
|
||||||
<app-single-auto-complete [required]="false" [formControl]="formGroup.get('profile')" placeholder="{{'DMP-EDITOR.FIELDS.TEMPLATE' | translate}}" [configuration]="dmpBlueprintAutoCompleteConfiguration">
|
|
||||||
</app-single-auto-complete>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<app-dynamic-dmp-field-resolver *ngIf="selectedDmpBlueprintDefinition" [formGroup]="formGroup" [dmpBlueprintDefinition]="selectedDmpBlueprintDefinition" [dmpBlueprintId]="formGroup.get('profile').value.id" [isUserOwner]="isUserOwner">
|
|
||||||
</app-dynamic-dmp-field-resolver>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Versioning Container-->
|
|
||||||
<div class="col-sm-12 col-md-2">
|
|
||||||
<div class="version-menu">
|
|
||||||
<mat-form-field class="col-auto">
|
|
||||||
<input matInput placeholder="Version" disabled [value]="formGroup.get('version').value == undefined ?0 :formGroup.get('version').value">
|
|
||||||
</mat-form-field>
|
|
||||||
<!-- <app-dynamic-dmp-field-resolver *ngIf="dmp.definition" class="col-md-12" [formGroup]="formGroup" [dmpBlueprintDefinition]=dmp.definition></app-dynamic-dmp-field-resolver> -->
|
|
||||||
<div class="col-auto mb-2">
|
|
||||||
{{ 'DATASET-EDITOR.VERSION-DIALOG.ABOUT' | translate }}
|
|
||||||
</div>
|
|
||||||
<!-- Versioning Actions -->
|
|
||||||
<!-- <div class="col-auto d-flex align-content-center mb-1" style="cursor: pointer;">
|
|
||||||
<mat-icon>edit</mat-icon>
|
|
||||||
<span>Click here to edit</span>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto d-flex align-content-center mb-3" style="cursor: pointer;">
|
|
||||||
<mat-icon>history</mat-icon>
|
|
||||||
Click here to view previous versions
|
|
||||||
</div> -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1,47 +0,0 @@
|
||||||
.input-btn {
|
|
||||||
border: none;
|
|
||||||
color: #aaaaaa;
|
|
||||||
background-color: #ffffff00;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-btn :hover {
|
|
||||||
color: var(--primary-color-3) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
// .icon-btn {
|
|
||||||
// font-size: 22px !important;
|
|
||||||
// color: #aaaaaa;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// .mat-icon-button :hover {
|
|
||||||
// color: #4687f0 !important;
|
|
||||||
// }
|
|
||||||
|
|
||||||
.version-menu {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
flex-direction: column;
|
|
||||||
background-color: rgba(250, 250, 250, 1);
|
|
||||||
border: 1px solid #ececec;
|
|
||||||
padding-top: 1em;
|
|
||||||
margin-top: 2em;
|
|
||||||
margin-right: 2em;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.version-menu mat-icon {
|
|
||||||
color: var(--primary-color-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .mat-form-field-appearance-legacy .mat-form-field-wrapper {
|
|
||||||
padding-bottom: 1.25em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cost-placeholder {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cost-add {
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
|
@ -1,282 +0,0 @@
|
||||||
|
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
|
||||||
import { UntypedFormGroup, UntypedFormArray } from '@angular/forms';
|
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
|
|
||||||
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
|
|
||||||
import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item';
|
|
||||||
import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria';
|
|
||||||
import { DmpBlueprintCriteria } from '@app/core/query/dmp/dmp-blueprint-criteria';
|
|
||||||
import { RequestItem } from '@app/core/query/request-item';
|
|
||||||
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
|
||||||
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
|
||||||
import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service';
|
|
||||||
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
|
||||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
|
||||||
import { AddResearcherComponent } from '@app/ui/dmp/editor/add-researcher/add-researcher.component';
|
|
||||||
import { AvailableProfilesComponent } from '@app/ui/dmp/editor/available-profiles/available-profiles.component';
|
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { map, takeUntil } from 'rxjs/operators';
|
|
||||||
import { AddOrganizationComponent } from '../add-organization/add-organization.component';
|
|
||||||
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
|
||||||
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
|
||||||
import { LanguageInfoService } from '@app/core/services/culture/language-info-service';
|
|
||||||
import { LanguageInfo } from '@app/core/model/language-info';
|
|
||||||
import { LicenseCriteria } from '@app/core/query/license/license-criteria';
|
|
||||||
import { AddCostComponent } from '../cost-editor/add-cost/add-cost.component';
|
|
||||||
import { CostEditorModel } from '../cost-editor/add-cost/add-cost.model';
|
|
||||||
import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
|
||||||
|
|
||||||
interface Visible {
|
|
||||||
value: boolean;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-general-tab',
|
|
||||||
templateUrl: './general-tab.component.html',
|
|
||||||
styleUrls: ['./general-tab.component.scss']
|
|
||||||
})
|
|
||||||
export class GeneralTabComponent extends BaseComponent implements OnInit {
|
|
||||||
|
|
||||||
@Input() formGroup: UntypedFormGroup = null;
|
|
||||||
@Input() isNewVersion: boolean;
|
|
||||||
@Input() isUserOwner: boolean;
|
|
||||||
@Input() isClone: boolean;
|
|
||||||
|
|
||||||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
|
||||||
filterFn: this.filterProfiles.bind(this),
|
|
||||||
initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
|
||||||
displayFn: (item) => item['label'],
|
|
||||||
titleFn: (item) => item['label'],
|
|
||||||
subtitleFn: (item) => item['description'],
|
|
||||||
popupItemActionIcon: 'visibility'
|
|
||||||
};
|
|
||||||
|
|
||||||
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
|
||||||
filterFn: this.filterOrganisations.bind(this),
|
|
||||||
initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
|
||||||
displayFn: (item) => item['name'],
|
|
||||||
titleFn: (item) => item['name'],
|
|
||||||
subtitleFn: (item) => item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE'))
|
|
||||||
};
|
|
||||||
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
|
||||||
filterFn: this.filterResearchers.bind(this),
|
|
||||||
initialItems: (excludedItems: any[]) => this.filterResearchers('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
|
||||||
displayFn: (item) => item['name'],
|
|
||||||
titleFn: (item) => item['name'],
|
|
||||||
subtitleFn: (item) => item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE'))
|
|
||||||
};
|
|
||||||
dmpBlueprintAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
|
|
||||||
filterFn: this.dmpBlueprintSearch.bind(this),
|
|
||||||
initialItems: (extraData) => this.dmpBlueprintSearch(''),
|
|
||||||
displayFn: (item) => item['label'],
|
|
||||||
titleFn: (item) => item['label']
|
|
||||||
};
|
|
||||||
|
|
||||||
licenseAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
|
|
||||||
filterFn: this.licenseSearch.bind(this),
|
|
||||||
initialItems: (excludedItems: any[]) => this.licenseSearch('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
|
||||||
displayFn: (item) => item['name'],
|
|
||||||
titleFn: (item) => item['name']
|
|
||||||
};
|
|
||||||
|
|
||||||
selectedDmpBlueprintDefinition: DmpBlueprintDefinition;
|
|
||||||
|
|
||||||
visibles: Visible[] = [
|
|
||||||
{ value: true, name: 'DMP-EDITOR.VISIBILITY.PUBLIC' },
|
|
||||||
{ value: false, name: 'DMP-EDITOR.VISIBILITY.RESTRICTED' }
|
|
||||||
]
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private dmpBlueprintService: DmpBlueprintService,
|
|
||||||
private externalSourcesService: ExternalSourcesService,
|
|
||||||
private _service: DmpService,
|
|
||||||
private dialog: MatDialog,
|
|
||||||
private language: TranslateService,
|
|
||||||
private configurationService: ConfigurationService,
|
|
||||||
private languageInfoService: LanguageInfoService
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
if (this.formGroup.get('definition')) { this.selectedDmpBlueprintDefinition = this.formGroup.get('definition').value; }
|
|
||||||
this.registerFormEventsForDmpBlueprint();
|
|
||||||
|
|
||||||
if (this.isNewVersion) {
|
|
||||||
this.formGroup.get('label').disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.isUserOwner && !this.isClone) {
|
|
||||||
this.formGroup.disable();
|
|
||||||
}
|
|
||||||
if (isNullOrUndefined(this.formGroup.get('extraProperties').get('publicDate').value)) {
|
|
||||||
this.formGroup.get('extraProperties').get('publicDate').patchValue(new Date());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registerFormEventsForDmpBlueprint(definitionProperties?: DmpBlueprintDefinition): void {
|
|
||||||
this.formGroup.get('profile').valueChanges
|
|
||||||
.pipe(
|
|
||||||
takeUntil(this._destroyed))
|
|
||||||
.subscribe(Option => {
|
|
||||||
if (Option instanceof Object) {
|
|
||||||
this.selectedDmpBlueprintDefinition = null;
|
|
||||||
this.dmpBlueprintService.getSingle(Option.id)
|
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
this.selectedDmpBlueprintDefinition = result.definition;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.selectedDmpBlueprintDefinition = null;
|
|
||||||
}
|
|
||||||
this.selectedDmpBlueprintDefinition = definitionProperties;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
dmpBlueprintSearch(query: string) {
|
|
||||||
let fields: Array<string> = new Array();
|
|
||||||
var request = new DataTableRequest<DmpBlueprintCriteria>(0, 10, { fields: fields });
|
|
||||||
request.criteria = new DmpBlueprintCriteria();
|
|
||||||
return this.dmpBlueprintService.getPaged(request).pipe(map(x => x.data));
|
|
||||||
}
|
|
||||||
|
|
||||||
licenseSearch(query: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
const request = new RequestItem<LicenseCriteria>();
|
|
||||||
request.criteria = new LicenseCriteria();
|
|
||||||
request.criteria.like = query;
|
|
||||||
request.criteria.type = '';
|
|
||||||
return this.externalSourcesService.searchLicense(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// onCallbackSuccess(): void {
|
|
||||||
// this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
|
||||||
// this.router.navigate(['/plans']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// onCallbackError(error: any) {
|
|
||||||
// this.setErrorModel(error.error);
|
|
||||||
|
|
||||||
// //this.validateAllFormFields(this.formGroup);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public setErrorModel(validationErrorModel: ValidationErrorModel) {
|
|
||||||
// Object.keys(validationErrorModel).forEach(item => {
|
|
||||||
// (<any>this.dmp.validationErrorModel)[item] = (<any>validationErrorModel)[item];
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
filterOrganisations(value: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
return this.externalSourcesService.searchDMPOrganizations(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
filterResearchers(value: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } });
|
|
||||||
}
|
|
||||||
|
|
||||||
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
|
|
||||||
const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] });
|
|
||||||
const criteria = new DatasetProfileCriteria();
|
|
||||||
criteria.like = value;
|
|
||||||
request.criteria = criteria;
|
|
||||||
return this._service.searchDmpBlueprints(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
addResearcher(event: MouseEvent) {
|
|
||||||
event.stopPropagation();
|
|
||||||
const dialogRef = this.dialog.open(AddResearcherComponent, {
|
|
||||||
data: this.formGroup.get('researchers')
|
|
||||||
});
|
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
||||||
if (result) {
|
|
||||||
const fullName = result.firstName + " " + result.lastName;
|
|
||||||
const newItem = {
|
|
||||||
label: null,
|
|
||||||
name: fullName,
|
|
||||||
id: null,
|
|
||||||
status: 0,
|
|
||||||
key: "Internal",
|
|
||||||
reference: result.reference
|
|
||||||
};
|
|
||||||
const researchersArray = this.formGroup.get('researchers').value || [];
|
|
||||||
researchersArray.push(newItem);
|
|
||||||
this.formGroup.get('researchers').setValue(researchersArray);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
addOrganization(event: MouseEvent) {
|
|
||||||
event.stopPropagation();
|
|
||||||
const dialogRef = this.dialog.open(AddOrganizationComponent, {
|
|
||||||
data: this.formGroup.get('organisations')
|
|
||||||
});
|
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
||||||
if (result) {
|
|
||||||
const fullName = result.name;
|
|
||||||
const newItem = {
|
|
||||||
label: null,
|
|
||||||
name: fullName,
|
|
||||||
id: null,
|
|
||||||
status: 0,
|
|
||||||
key: "Internal",
|
|
||||||
};
|
|
||||||
const organizationsArray = this.formGroup.get('organisations').value || [];
|
|
||||||
organizationsArray.push(newItem);
|
|
||||||
this.formGroup.get('organisations').setValue(organizationsArray);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
showOrganizationCreator(): boolean {
|
|
||||||
return this.configurationService.allowOrganizationCreator;
|
|
||||||
}
|
|
||||||
|
|
||||||
canAddOrganizations(): boolean {
|
|
||||||
if (!isNullOrUndefined(this.formGroup.get('organizations'))) {
|
|
||||||
return this.formGroup.get('organiztions').disabled;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
availableProfiles(event: MouseEvent) {
|
|
||||||
event.stopPropagation();
|
|
||||||
const dialogRef = this.dialog.open(AvailableProfilesComponent, {
|
|
||||||
data: {
|
|
||||||
profiles: this.formGroup.get('profiles')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLanguageInfos(): LanguageInfo[] {
|
|
||||||
return this.languageInfoService.getLanguageInfoValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
getAssociates(): any[] {
|
|
||||||
let associates: any[] = [];
|
|
||||||
//associates = (this.formGroup.get('researchers').value as any[]);
|
|
||||||
associates = associates.concat(this.formGroup.get('associatedUsers').value);
|
|
||||||
return associates;
|
|
||||||
}
|
|
||||||
|
|
||||||
addCost(event: MouseEvent) {
|
|
||||||
event.stopPropagation();
|
|
||||||
const dialogRef = this.dialog.open(AddCostComponent, {
|
|
||||||
data: this.formGroup.get('extraProperties').get('costs')
|
|
||||||
});
|
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
||||||
if (result) {
|
|
||||||
const costsArray = this.formGroup.get('extraProperties').get('costs').value || [];
|
|
||||||
costsArray.push(result);
|
|
||||||
let costeditModel: CostEditorModel = new CostEditorModel();
|
|
||||||
costeditModel = costeditModel.fromModel(result);
|
|
||||||
(<UntypedFormArray>this.formGroup.get('extraProperties').get('costs')).push(costeditModel.buildForm(null, true));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -29,7 +29,9 @@ import { HttpClient } from '@angular/common/http';
|
||||||
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
||||||
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
||||||
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
||||||
import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-listing-item-component',
|
selector: 'app-dmp-listing-item-component',
|
||||||
|
@ -177,9 +179,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
|
||||||
this.dmpFormGroup = this.dmpModel.buildForm();
|
this.dmpFormGroup = this.dmpModel.buildForm();
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.dmpFormGroup.get('profile').value)) {
|
if (!isNullOrUndefined(this.dmpFormGroup.get('profile').value)) {
|
||||||
this.dmpBlueprintService.getSingleBlueprint(this.dmpFormGroup.get('profile').value)
|
this.getBlueprintDefinition(Guid.parse(this.dmpFormGroup.get('profile').value), result => {
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
this.checkForGrant(result.definition);
|
this.checkForGrant(result.definition);
|
||||||
this.checkForFunder(result.definition);
|
this.checkForFunder(result.definition);
|
||||||
this.checkForProject(result.definition);
|
this.checkForProject(result.definition);
|
||||||
|
@ -193,6 +193,37 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getBlueprintDefinition(blueprintId: Guid, successFunction) {
|
||||||
|
this.dmpBlueprintService.getSingle(blueprintId, [
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
.pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
data => successFunction(data),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
||||||
let hasGrant = false;
|
let hasGrant = false;
|
||||||
blueprint.sections.forEach(section => section.fields.forEach(
|
blueprint.sections.forEach(section => section.fields.forEach(
|
||||||
|
|
|
@ -48,8 +48,9 @@ import {DoiModel} from '@app/core/model/doi/doi';
|
||||||
import {isNullOrUndefined} from '@app/utilities/enhancers/utils';
|
import {isNullOrUndefined} from '@app/utilities/enhancers/utils';
|
||||||
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
|
||||||
import { Guid } from '@common/types/guid';
|
import { Guid } from '@common/types/guid';
|
||||||
import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-overview',
|
selector: 'app-dmp-overview',
|
||||||
|
@ -212,9 +213,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
this.formGroup = this.dmpModel.buildForm();
|
this.formGroup = this.dmpModel.buildForm();
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
||||||
this.dmpBlueprintService.getSingleBlueprint(this.formGroup.get('profile').value)
|
this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => {
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
this.checkForGrant(result.definition);
|
this.checkForGrant(result.definition);
|
||||||
this.checkForFunder(result.definition);
|
this.checkForFunder(result.definition);
|
||||||
this.checkForProject(result.definition);
|
this.checkForProject(result.definition);
|
||||||
|
@ -228,6 +227,38 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getBlueprintDefinition(blueprintId: Guid, successFunction) {
|
||||||
|
this.dmpBlueprintService.getSingle(blueprintId, [
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
|
||||||
|
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
.pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
data => successFunction(data),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
private checkForGrant(blueprint: DmpBlueprintDefinition) {
|
||||||
let hasGrant = false;
|
let hasGrant = false;
|
||||||
blueprint.sections.forEach(section => section.fields.forEach(
|
blueprint.sections.forEach(section => section.fields.forEach(
|
||||||
|
|
Loading…
Reference in New Issue