DescriptionTemplate refactor
This commit is contained in:
parent
3c799063cc
commit
ac15e33a87
|
@ -40,6 +40,10 @@
|
|||
<artifactId>repositorydepositbase</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.angus</groupId>
|
||||
<artifactId>jakarta.mail</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -29,6 +29,7 @@ public final class Permission {
|
|||
public static String DeleteDescriptionTemplate = "DeleteDescriptionTemplate";
|
||||
public static String CloneDescriptionTemplate = "CloneDescriptionTemplate";
|
||||
public static String CreateNewVersionDescriptionTemplate = "CreateNewVersionDescriptionTemplate";
|
||||
public static String ImportDescriptionTemplate = "ImportDescriptionTemplate";
|
||||
|
||||
//DescriptionTemplateType
|
||||
public static String BrowseDescriptionTemplateType = "BrowseDescriptionTemplateType";
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.importmodel;
|
||||
|
||||
|
||||
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
||||
|
||||
import eu.eudat.model.persist.DescriptionTemplatePersist;
|
||||
import eu.eudat.model.persist.NewVersionDescriptionTemplatePersist;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.DefinitionPersist;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.PagePersist;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.SectionPersist;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@XmlRootElement(name = "pages")
|
||||
public class DescriptionTemplateImportXml {
|
||||
|
||||
private String description;
|
||||
private String language;
|
||||
private String type;
|
||||
|
||||
private List<PageImportXml> page;
|
||||
|
||||
@XmlElement(name = "page")
|
||||
public List<PageImportXml> getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(List<PageImportXml> page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "description")
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "language")
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public DescriptionTemplatePersist toPersistModel(String label, FieldDataHelperServiceProvider fieldDataHelperServiceProvider){
|
||||
DescriptionTemplatePersist newDatasetEntityProfile = new DescriptionTemplatePersist();
|
||||
newDatasetEntityProfile.setLabel(label);
|
||||
newDatasetEntityProfile.setStatus(DescriptionTemplateStatus.Draft);
|
||||
newDatasetEntityProfile.setDescription(description);
|
||||
newDatasetEntityProfile.setLanguage(language);
|
||||
newDatasetEntityProfile.setType(UUID.fromString(type));
|
||||
DefinitionPersist definitionPersist = new DefinitionPersist();
|
||||
|
||||
List<PagePersist> pagesDatasetEntity = new LinkedList<>();
|
||||
List<SectionPersist> sectionDatasetEntity = new LinkedList<>();
|
||||
for (PageImportXml xmlPage: page) {
|
||||
pagesDatasetEntity.add(xmlPage.toPersistModel());
|
||||
for (int i = 0; i < xmlPage.getSections().size(); i++) {
|
||||
sectionDatasetEntity.add(xmlPage.toPersistModel(i, fieldDataHelperServiceProvider));
|
||||
}
|
||||
}
|
||||
definitionPersist.setPages(pagesDatasetEntity);
|
||||
definitionPersist.setSections(sectionDatasetEntity);
|
||||
newDatasetEntityProfile.setDefinition(definitionPersist);
|
||||
|
||||
return newDatasetEntityProfile;
|
||||
}
|
||||
|
||||
public NewVersionDescriptionTemplatePersist toNewVersionPersistModel(UUID id, String label, FieldDataHelperServiceProvider fieldDataHelperServiceProvider){
|
||||
NewVersionDescriptionTemplatePersist newDatasetEntityProfile = new NewVersionDescriptionTemplatePersist();
|
||||
newDatasetEntityProfile.setId(id);
|
||||
newDatasetEntityProfile.setLabel(label);
|
||||
newDatasetEntityProfile.setStatus(DescriptionTemplateStatus.Draft);
|
||||
newDatasetEntityProfile.setDescription(description);
|
||||
newDatasetEntityProfile.setLanguage(language);
|
||||
newDatasetEntityProfile.setType(UUID.fromString(type));
|
||||
DefinitionPersist definitionPersist = new DefinitionPersist();
|
||||
|
||||
List<PagePersist> pagesDatasetEntity = new LinkedList<>();
|
||||
List<SectionPersist> sectionDatasetEntity = new LinkedList<>();
|
||||
for (PageImportXml xmlPage: page) {
|
||||
pagesDatasetEntity.add(xmlPage.toPersistModel());
|
||||
for (int i = 0; i < xmlPage.getSections().size(); i++) {
|
||||
sectionDatasetEntity.add(xmlPage.toPersistModel(i, fieldDataHelperServiceProvider));
|
||||
}
|
||||
}
|
||||
definitionPersist.setPages(pagesDatasetEntity);
|
||||
definitionPersist.setSections(sectionDatasetEntity);
|
||||
newDatasetEntityProfile.setDefinition(definitionPersist);
|
||||
|
||||
return newDatasetEntityProfile;
|
||||
}
|
||||
}
|
|
@ -1,20 +1,22 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel;
|
||||
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.Fields;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importmodel.fields.FieldsImportXml;
|
||||
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.FieldSetPersist;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "field-Set")
|
||||
public class FieldSet {
|
||||
public class FieldSetImportXml {
|
||||
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private Fields fields;
|
||||
private FieldsImportXml fields;
|
||||
private String numbering;
|
||||
private Boolean commentField;
|
||||
private Multiplicity multiplicity;
|
||||
private MultiplicityImportXml multiplicity;
|
||||
private String description;
|
||||
private String extendedDescription;
|
||||
private String additionalInformation;
|
||||
|
@ -39,11 +41,11 @@ public class FieldSet {
|
|||
}
|
||||
|
||||
@XmlElement(name = "fields")
|
||||
public Fields getFields() {
|
||||
public FieldsImportXml getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(Fields fields) {
|
||||
public void setFields(FieldsImportXml fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
|
@ -66,11 +68,11 @@ public class FieldSet {
|
|||
}
|
||||
|
||||
@XmlElement(name = "multiplicity")
|
||||
public Multiplicity getMultiplicity() {
|
||||
public MultiplicityImportXml getMultiplicity() {
|
||||
return multiplicity;
|
||||
}
|
||||
|
||||
public void setMultiplicity(Multiplicity multiplicity) {
|
||||
public void setMultiplicity(MultiplicityImportXml multiplicity) {
|
||||
this.multiplicity = multiplicity;
|
||||
}
|
||||
|
||||
|
@ -110,18 +112,18 @@ public class FieldSet {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.FieldSet toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.admin.components.datasetprofile.FieldSet fieldSet1Entity = new eu.eudat.models.data.admin.components.datasetprofile.FieldSet();
|
||||
public FieldSetPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||
FieldSetPersist fieldSet1Entity = new FieldSetPersist();
|
||||
fieldSet1Entity.setId(this.id);
|
||||
fieldSet1Entity.setOrdinal(this.ordinal);
|
||||
fieldSet1Entity.setHasCommentField(this.commentField != null ? this.commentField : false);
|
||||
fieldSet1Entity.setMultiplicity(this.multiplicity != null ? this.multiplicity.toAdminCompositeModelSection() : null);
|
||||
fieldSet1Entity.setMultiplicity(this.multiplicity != null ? this.multiplicity.toPersistModel() : null);
|
||||
fieldSet1Entity.setTitle(this.title);
|
||||
fieldSet1Entity.setDescription(this.description);
|
||||
fieldSet1Entity.setExtendedDescription(this.extendedDescription);
|
||||
fieldSet1Entity.setAdditionalInformation(this.additionalInformation);
|
||||
|
||||
fieldSet1Entity.setFields(this.fields.toAdminCompositeModelSection());
|
||||
fieldSet1Entity.setFields(this.fields.toPersistModel(fieldDataHelperServiceProvider));
|
||||
return fieldSet1Entity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.importmodel;
|
||||
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.FieldSetPersist;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "field-Sets")
|
||||
public class FieldSetsImportXml {
|
||||
|
||||
List<FieldSetImportXml> fieldSet;
|
||||
|
||||
@XmlElement(name = "field-Set")
|
||||
public List<FieldSetImportXml> getFieldSet() {
|
||||
return fieldSet;
|
||||
}
|
||||
|
||||
public void setFieldSet(List<FieldSetImportXml> fieldSet) {
|
||||
this.fieldSet = fieldSet;
|
||||
}
|
||||
|
||||
public List<FieldSetPersist> toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider){
|
||||
List<FieldSetPersist> fieldSetEntity = new LinkedList<>();
|
||||
if(this.fieldSet!=null) {
|
||||
for (FieldSetImportXml xmlFieldSet : this.fieldSet) {
|
||||
fieldSetEntity.add(xmlFieldSet.toPersistModel(fieldDataHelperServiceProvider));
|
||||
}
|
||||
}
|
||||
return fieldSetEntity;
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel;
|
||||
|
||||
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.MultiplicityPersist;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
||||
@XmlRootElement(name = "multiplicity")
|
||||
public class Multiplicity {
|
||||
public class MultiplicityImportXml {
|
||||
private int max;
|
||||
private int min;
|
||||
private String placeholder;
|
||||
|
@ -48,8 +48,8 @@ public class Multiplicity {
|
|||
this.tableView = tableView;
|
||||
}
|
||||
|
||||
public MultiplicityEntity toAdminCompositeModelSection() {
|
||||
MultiplicityEntity multiplicityEntity = new MultiplicityEntity();
|
||||
public MultiplicityPersist toPersistModel() {
|
||||
MultiplicityPersist multiplicityEntity = new MultiplicityPersist();
|
||||
multiplicityEntity.setMax(max);
|
||||
multiplicityEntity.setMin(min);
|
||||
multiplicityEntity.setPlaceholder(placeholder);
|
|
@ -0,0 +1,65 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.importmodel;
|
||||
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.PagePersist;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.SectionPersist;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "page")
|
||||
public class PageImportXml {
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private String title;
|
||||
private List<SectionsImportXml> sections;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "ordinal")
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "title")
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlElement(name = "sections")
|
||||
public List<SectionsImportXml> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<SectionsImportXml> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
public PagePersist toPersistModel(){
|
||||
PagePersist pageEntity = new PagePersist();
|
||||
pageEntity.setId(this.id);
|
||||
pageEntity.setOrdinal(this.ordinal);
|
||||
pageEntity.setTitle(this.title);
|
||||
return pageEntity;
|
||||
}
|
||||
|
||||
public SectionPersist toPersistModel(int i, FieldDataHelperServiceProvider fieldDataHelperServiceProvider){
|
||||
return sections.get(i).toPersistModel(fieldDataHelperServiceProvider);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel;
|
||||
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.SectionPersist;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
@ -7,17 +9,17 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "section")
|
||||
public class Section {
|
||||
public class SectionImportXml {
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private String page;
|
||||
private Boolean defaultVisibility;
|
||||
private FieldSets fieldSets;
|
||||
private FieldSetsImportXml fieldSets;
|
||||
private String numbering;
|
||||
private String description;
|
||||
private String extendedDescription;
|
||||
private String title;
|
||||
private List<Section> section;
|
||||
private List<SectionImportXml> section;
|
||||
private Boolean multiplicity;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
|
@ -57,11 +59,11 @@ public class Section {
|
|||
}
|
||||
|
||||
@XmlElement(name = "field-Sets")
|
||||
public FieldSets getFieldSets() {
|
||||
public FieldSetsImportXml getFieldSets() {
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
public void setFieldSets(FieldSets fieldSets) {
|
||||
public void setFieldSets(FieldSetsImportXml fieldSets) {
|
||||
this.fieldSets = fieldSets;
|
||||
}
|
||||
|
||||
|
@ -101,13 +103,31 @@ public class Section {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity = new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionsListEntity = new LinkedList<>();
|
||||
@XmlElement(name = "section")
|
||||
public List<SectionImportXml> getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(List<SectionImportXml> section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "multiplicity")
|
||||
public Boolean getMultiplicity() {
|
||||
return multiplicity;
|
||||
}
|
||||
|
||||
public void setMultiplicity(Boolean multiplicity) {
|
||||
this.multiplicity = multiplicity;
|
||||
}
|
||||
|
||||
public SectionPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||
SectionPersist sectionEntity = new SectionPersist();
|
||||
List<SectionPersist> sectionsListEntity = new LinkedList<>();
|
||||
|
||||
if (this.section != null) {
|
||||
for (Section xmlsection : this.section) {
|
||||
sectionsListEntity.add(xmlsection.toAdminCompositeModelSection());
|
||||
for (SectionImportXml xmlsection : this.section) {
|
||||
sectionsListEntity.add(xmlsection.toPersistModel(fieldDataHelperServiceProvider));
|
||||
}
|
||||
}
|
||||
sectionEntity.setId(this.id);
|
||||
|
@ -120,28 +140,10 @@ public class Section {
|
|||
// for (FieldSets xmpFieldSets: this.fieldSets) {
|
||||
// fieldSetsEntity.add(xmpFieldSets.toAdminCompositeModelSection());
|
||||
// }
|
||||
sectionEntity.setFieldSets(this.fieldSets.toAdminCompositeModelSection());
|
||||
sectionEntity.setFieldSets(this.fieldSets.toPersistModel(fieldDataHelperServiceProvider));
|
||||
|
||||
sectionEntity.setSections(sectionsListEntity);
|
||||
sectionEntity.setDefaultVisibility(this.defaultVisibility);
|
||||
return sectionEntity;
|
||||
}
|
||||
|
||||
@XmlElement(name = "section")
|
||||
public List<Section> getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(List<Section> section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "multiplicity")
|
||||
public Boolean getMultiplicity() {
|
||||
return multiplicity;
|
||||
}
|
||||
|
||||
public void setMultiplicity(Boolean multiplicity) {
|
||||
this.multiplicity = multiplicity;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel;
|
||||
|
||||
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.FieldSetPersist;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.SectionPersist;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
@ -8,7 +11,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "sections")
|
||||
public class Sections {
|
||||
public class SectionsImportXml {
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private String page;
|
||||
|
@ -16,8 +19,8 @@ public class Sections {
|
|||
private String numbering;
|
||||
private String description;
|
||||
private String title;
|
||||
private List<Section> section;
|
||||
private FieldSets fieldSets;
|
||||
private List<SectionImportXml> section;
|
||||
private FieldSetsImportXml fieldSets;
|
||||
private Boolean multiplicity;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
|
@ -84,20 +87,20 @@ public class Sections {
|
|||
}
|
||||
|
||||
@XmlElement(name = "section")
|
||||
public List<Section> getSection() {
|
||||
public List<SectionImportXml> getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(List<Section> section) {
|
||||
public void setSection(List<SectionImportXml> section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
@XmlElement(name = "field-Sets")
|
||||
public FieldSets getFieldSets() {
|
||||
public FieldSetsImportXml getFieldSets() {
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
public void setFieldSets(FieldSets fieldSets) {
|
||||
public void setFieldSets(FieldSetsImportXml fieldSets) {
|
||||
this.fieldSets = fieldSets;
|
||||
}
|
||||
|
||||
|
@ -110,24 +113,22 @@ public class Sections {
|
|||
this.multiplicity = multiplicity;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity = new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionsListEntity = new LinkedList<>();
|
||||
public SectionPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||
SectionPersist sectionEntity = new SectionPersist();
|
||||
List<SectionPersist> sectionsListEntity = new LinkedList<>();
|
||||
|
||||
if (this.section != null) {
|
||||
for (Section xmlsection : this.section) {
|
||||
sectionsListEntity.add(xmlsection.toAdminCompositeModelSection());
|
||||
for (SectionImportXml xmlsection : this.section) {
|
||||
sectionsListEntity.add(xmlsection.toPersistModel(fieldDataHelperServiceProvider));
|
||||
}
|
||||
}
|
||||
} /*else {
|
||||
sectionsListEntity.add(new eu.eudat.models.data.admin.components.datasetprofile.Section());
|
||||
}*/
|
||||
sectionEntity.setId(this.id);
|
||||
sectionEntity.setOrdinal(this.ordinal);
|
||||
sectionEntity.setTitle(this.title);
|
||||
sectionEntity.setDefaultVisibility(this.defaultVisibility);
|
||||
sectionEntity.setDescription(description);
|
||||
sectionEntity.setPage(this.page);
|
||||
sectionEntity.setFieldSets(toAdminCompositeModelSectionFieldSets());
|
||||
sectionEntity.setFieldSets(toFieldSetPersistModel(fieldDataHelperServiceProvider));
|
||||
sectionEntity.setMultiplicity(this.multiplicity);
|
||||
|
||||
|
||||
|
@ -135,8 +136,8 @@ public class Sections {
|
|||
return sectionEntity;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> toAdminCompositeModelSectionFieldSets() {
|
||||
return fieldSets.toAdminCompositeModelSection();
|
||||
public List<FieldSetPersist> toFieldSetPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||
return fieldSets.toPersistModel(fieldDataHelperServiceProvider);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import eu.eudat.commons.types.descriptiontemplate.todelete.DefaultValueEntity;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "defaultValue")
|
||||
public class DefaultValue {
|
||||
public class DefaultValueImportXml {
|
||||
|
||||
private String type;
|
||||
private String value;
|
||||
|
@ -28,10 +27,7 @@ public class DefaultValue {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
public DefaultValueEntity toAdminCompositeModelSection(){
|
||||
DefaultValueEntity defaultValueEntity =new DefaultValueEntity();
|
||||
defaultValueEntity.setValue(value);
|
||||
defaultValueEntity.setType(type);
|
||||
return defaultValueEntity;
|
||||
public String toPersistModel(){
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
import eu.eudat.commons.enums.FieldType;
|
||||
import eu.eudat.commons.enums.FieldValidationType;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.FieldDataHelper;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.FieldPersist;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperService;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
|
@ -12,7 +15,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "field")
|
||||
public class Field {
|
||||
public class FieldImportXml {
|
||||
|
||||
private String id;
|
||||
|
||||
|
@ -20,17 +23,17 @@ public class Field {
|
|||
|
||||
private String numbering;
|
||||
|
||||
private List<validations> validations;
|
||||
private List<ValidationsImportXml> validations;
|
||||
|
||||
private DefaultValue defaultValue;
|
||||
private DefaultValueImportXml defaultValue;
|
||||
|
||||
private Visible visible;
|
||||
private VisibleImportXml visible;
|
||||
|
||||
private ViewStyle viewStyle;
|
||||
private ViewStyleImportXml viewStyle;
|
||||
|
||||
private Object data;
|
||||
private Element data;
|
||||
|
||||
private Schematics schematics;
|
||||
private SchematicsImportXml schematics;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
|
@ -60,80 +63,82 @@ public class Field {
|
|||
}
|
||||
|
||||
@XmlElement(name = "validations")
|
||||
public List<eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.validations> getValidations() {
|
||||
public List<ValidationsImportXml> getValidations() {
|
||||
return validations;
|
||||
}
|
||||
|
||||
public void setValidations(List<eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.validations> validations) {
|
||||
public void setValidations(List<ValidationsImportXml> validations) {
|
||||
this.validations = validations;
|
||||
}
|
||||
|
||||
@XmlElement(name = "defaultValue")
|
||||
public DefaultValue getDefaultValue() {
|
||||
public DefaultValueImportXml getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(DefaultValue defaultValue) {
|
||||
public void setDefaultValue(DefaultValueImportXml defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
@XmlElement(name = "visible")
|
||||
public Visible getVisible() {
|
||||
public VisibleImportXml getVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(Visible visible) {
|
||||
public void setVisible(VisibleImportXml visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
@XmlElement(name = "viewStyle")
|
||||
public ViewStyle getViewStyle() {
|
||||
public ViewStyleImportXml getViewStyle() {
|
||||
return viewStyle;
|
||||
}
|
||||
|
||||
public void setViewStyle(ViewStyle viewStyle) {
|
||||
public void setViewStyle(ViewStyleImportXml viewStyle) {
|
||||
this.viewStyle = viewStyle;
|
||||
}
|
||||
|
||||
@XmlElement(name = "data")
|
||||
public Object getData() {
|
||||
public Element getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
public void setData(Element data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@XmlElement(name = "schematics")
|
||||
public Schematics getSchematics() {
|
||||
public SchematicsImportXml getSchematics() {
|
||||
return schematics;
|
||||
}
|
||||
|
||||
public void setSchematics(Schematics schematics) {
|
||||
public void setSchematics(SchematicsImportXml schematics) {
|
||||
this.schematics = schematics;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Field toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.admin.components.datasetprofile.Field fieldEntity =new eu.eudat.models.data.admin.components.datasetprofile.Field();
|
||||
public FieldPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||
FieldPersist fieldEntity =new FieldPersist();
|
||||
fieldEntity.setId(this.id);
|
||||
fieldEntity.setOrdinal(this.ordinal);
|
||||
List<Integer> validationList = new LinkedList<>();
|
||||
for(validations validation:this.validations){
|
||||
if(validation.getValidation()!=null)
|
||||
validationList.add(validation.toAdminCompositeModelSection());
|
||||
List<FieldValidationType> validationList = new LinkedList<>();
|
||||
for(ValidationsImportXml validation:this.validations){
|
||||
if(validation.getValidation()!=null) {
|
||||
validationList.add(validation.toPersistModel());
|
||||
}
|
||||
}
|
||||
fieldEntity.setValidations(validationList);
|
||||
fieldEntity.setDefaultValue(this.defaultValue.toAdminCompositeModelSection());
|
||||
fieldEntity.setVisible(this.visible.toAdminCompositeModelSection());
|
||||
fieldEntity.setViewStyle(this.viewStyle.toAdminCompositeModelSection());
|
||||
BaseFieldDataEntity data = new FieldDataHelper().toFieldData(null, FieldType.of(this.viewStyle.getRenderStyle()), (Element) this.data);
|
||||
// fieldEntity.setData( data.fromXml((Element) this.data));
|
||||
fieldEntity.setDefaultValue(this.defaultValue.toPersistModel());
|
||||
fieldEntity.setVisibilityRules(this.visible.toPersistModel());
|
||||
FieldType fieldType = this.viewStyle.toPersistModel();
|
||||
|
||||
BaseFieldDataEntity<?> data = new FieldDataHelper().toFieldData(null, fieldType, (Element) this.data);
|
||||
if (data != null) {
|
||||
fieldEntity.setData(data.toMap((Element) this.data));
|
||||
FieldDataHelperService fieldDataHelperService = fieldDataHelperServiceProvider.get(fieldType);
|
||||
fieldEntity.setData(fieldDataHelperService.mapDataToPersist((BaseFieldDataEntity<?>)fieldDataHelperService.newDataInstance().fromXml(this.data)));
|
||||
}
|
||||
List<String> schematicsList = new LinkedList<>();
|
||||
if (this.schematics != null && this.schematics.getSchematics() != null) {
|
||||
for (Schematic schematic : this.schematics.getSchematics()) {
|
||||
for (SchematicImportXml schematic : this.schematics.getSchematics()) {
|
||||
if (schematic != null && schematic.getSchematic() != null && !schematic.getSchematic().isEmpty())
|
||||
schematicsList.add(schematic.getSchematic());
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.FieldPersist;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "fields")
|
||||
public class FieldsImportXml {
|
||||
|
||||
private List<FieldImportXml> field;
|
||||
|
||||
@XmlElement(name = "field")
|
||||
public List<FieldImportXml> getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(List<FieldImportXml> field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public List<FieldPersist> toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||
List<FieldPersist> fieldsEntity = new LinkedList<>();
|
||||
if (this.field != null)
|
||||
for (FieldImportXml xmlField : this.field) {
|
||||
fieldsEntity.add(xmlField.toPersistModel(fieldDataHelperServiceProvider));
|
||||
}
|
||||
return fieldsEntity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.RulePersist;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "rule")
|
||||
public class Rule {
|
||||
public class RuleImportXml {
|
||||
|
||||
private String ruleStyle;
|
||||
private String target;
|
||||
private String type;
|
||||
private Value value;
|
||||
private ValueImportXml value;
|
||||
|
||||
@XmlAttribute(name = "ruleStyle")
|
||||
public String getRuleStyle() {
|
||||
|
@ -38,16 +38,16 @@ public class Rule {
|
|||
this.type = type;
|
||||
}
|
||||
@XmlElement(name = "value")
|
||||
public Value getValue() {
|
||||
public ValueImportXml getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Value value) {
|
||||
public void setValue(ValueImportXml value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public RuleEntity toAdminCompositeModelSection(){
|
||||
RuleEntity ruleEntity = new RuleEntity();
|
||||
public RulePersist toPersistModel(){
|
||||
RulePersist ruleEntity = new RulePersist();
|
||||
ruleEntity.setTarget(target);
|
||||
ruleEntity.setValue(value.getValue());
|
||||
return ruleEntity;
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlValue;
|
||||
|
||||
@XmlRootElement(name = "schematic")
|
||||
public class Schematic {
|
||||
public class SchematicImportXml {
|
||||
|
||||
private String schematic;
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "schematics")
|
||||
public class Schematics {
|
||||
public class SchematicsImportXml {
|
||||
|
||||
private List<Schematic> schematics;
|
||||
private List<SchematicImportXml> schematics;
|
||||
|
||||
@XmlElement(name = "schematic")
|
||||
public List<Schematic> getSchematics() {
|
||||
public List<SchematicImportXml> getSchematics() {
|
||||
return schematics;
|
||||
}
|
||||
|
||||
public void setSchematics(List<Schematic> schematics) {
|
||||
public void setSchematics(List<SchematicImportXml> schematics) {
|
||||
this.schematics = schematics;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "validation")
|
||||
public class Validation {
|
||||
public class ValidationImportXml {
|
||||
|
||||
private int type;
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import eu.eudat.commons.enums.FieldValidationType;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "validations")
|
||||
public class ValidationsImportXml {
|
||||
|
||||
ValidationImportXml validation;
|
||||
|
||||
@XmlElement(name = "validation")
|
||||
public ValidationImportXml getValidation() {
|
||||
return validation;
|
||||
}
|
||||
|
||||
public void setValidation(ValidationImportXml validation) {
|
||||
this.validation = validation;
|
||||
}
|
||||
|
||||
public FieldValidationType toPersistModel() {
|
||||
return FieldValidationType.of((short)validation.getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlValue;
|
||||
|
||||
@XmlRootElement(name = "value")
|
||||
public class Value {
|
||||
public class ValueImportXml {
|
||||
|
||||
private String type;
|
||||
private String value;
|
|
@ -1,13 +1,12 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
|
||||
import eu.eudat.commons.enums.FieldType;
|
||||
import eu.eudat.commons.types.descriptiontemplate.todelete.FieldDescriptionEntity;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "viewStyle")
|
||||
public class ViewStyle {
|
||||
public class ViewStyleImportXml {
|
||||
|
||||
private String cssClass;
|
||||
private String renderStyle;
|
||||
|
@ -29,10 +28,7 @@ public class ViewStyle {
|
|||
this.renderStyle = renderStyle;
|
||||
}
|
||||
|
||||
public FieldDescriptionEntity toAdminCompositeModelSection(){
|
||||
FieldDescriptionEntity fieldDescriptionEntity = new FieldDescriptionEntity();
|
||||
fieldDescriptionEntity.setCssClass(this.cssClass);
|
||||
fieldDescriptionEntity.setFieldType(FieldType.of(this.renderStyle));
|
||||
return fieldDescriptionEntity;
|
||||
public FieldType toPersistModel(){
|
||||
return FieldType.of(this.renderStyle);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.importmodel.fields;
|
||||
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.RulePersist;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "visible")
|
||||
public class VisibleImportXml {
|
||||
|
||||
private String style;
|
||||
private List<RuleImportXml> rule;
|
||||
|
||||
@XmlAttribute(name = "style")
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
public void setStyle(String style) {
|
||||
this.style = style;
|
||||
}
|
||||
@XmlElement(name = "rule")
|
||||
public List<RuleImportXml> getRule() {
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void setRule(List<RuleImportXml> rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public List<RulePersist> toPersistModel(){
|
||||
List<RulePersist> rulePersists = new ArrayList<>();
|
||||
if(this.rule!=null) {
|
||||
for (RuleImportXml xmlRule : this.rule) {
|
||||
rulePersists.add(xmlRule.toPersistModel());
|
||||
}
|
||||
}
|
||||
return rulePersists;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package eu.eudat.model.persist.descriptiontemplatedefinition;
|
|||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public abstract class MultiplicityPersist {
|
||||
public class MultiplicityPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private Integer min = null;
|
||||
|
|
|
@ -10,10 +10,12 @@ import gr.cite.tools.exception.MyNotFoundException;
|
|||
import gr.cite.tools.exception.MyValidationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DescriptionTemplateService {
|
||||
|
@ -22,5 +24,5 @@ public interface DescriptionTemplateService {
|
|||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||
DescriptionTemplate buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException;
|
||||
DescriptionTemplate createNewVersion(NewVersionDescriptionTemplatePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException;
|
||||
|
||||
DescriptionTemplate importXml(byte[] bytes, UUID id, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ import eu.eudat.commons.enums.UserDescriptionTemplateRole;
|
|||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.commons.types.descriptiontemplate.*;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importmodel.DescriptionTemplateImportXml;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||
import eu.eudat.model.DescriptionTemplate;
|
||||
import eu.eudat.model.builder.DescriptionTemplateBuilder;
|
||||
|
@ -29,6 +31,8 @@ import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldD
|
|||
import eu.eudat.query.DescriptionTemplateQuery;
|
||||
import eu.eudat.query.UserDescriptionTemplateQuery;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import eu.eudat.service.mail.MailService;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
|
@ -42,6 +46,7 @@ import gr.cite.tools.fieldset.BaseFieldSet;
|
|||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import gr.cite.tools.validation.ValidationService;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -49,14 +54,19 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
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.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -80,6 +90,9 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
|
||||
private final QueryFactory queryFactory;
|
||||
private final ErrorThesaurusProperties errors;
|
||||
private final ValidationService validationService;
|
||||
private final MailService mailService;
|
||||
private final Environment environment;
|
||||
|
||||
@Autowired
|
||||
public DescriptionTemplateServiceImpl(
|
||||
|
@ -90,7 +103,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
ConventionService conventionService,
|
||||
MessageSource messageSource,
|
||||
XmlHandlingService xmlHandlingService,
|
||||
FieldDataHelperServiceProvider fieldDataHelperServiceProvider, QueryFactory queryFactory, ErrorThesaurusProperties errors) {
|
||||
FieldDataHelperServiceProvider fieldDataHelperServiceProvider, QueryFactory queryFactory, ErrorThesaurusProperties errors, ValidationService validationService, MailService mailService, Environment environment) {
|
||||
this.entityManager = entityManager;
|
||||
this.userScope = userScope;
|
||||
this.authorizationService = authorizationService;
|
||||
|
@ -102,6 +115,9 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
|
||||
this.queryFactory = queryFactory;
|
||||
this.errors = errors;
|
||||
this.validationService = validationService;
|
||||
this.mailService = mailService;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
public DescriptionTemplate persist(DescriptionTemplatePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
|
||||
|
@ -160,15 +176,34 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
data.setUser(userId);
|
||||
data.setRole(UserDescriptionTemplateRole.Member);
|
||||
this.entityManager.persist(data);
|
||||
this.sendJoinMail(data);
|
||||
}
|
||||
}
|
||||
List<UUID> finalUsers = users;
|
||||
List<UserDescriptionTemplateEntity> toDelete = items.stream().filter(x-> finalUsers.stream().noneMatch(y-> y.equals(x.getUser()))).collect(Collectors.toList());
|
||||
|
||||
this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class).delete(toDelete);
|
||||
}
|
||||
private void sendJoinMail(UserDescriptionTemplateEntity userDatasetProfile) {
|
||||
SimpleMail mail = new SimpleMail();
|
||||
UserInfo user = this.entityManager.find(UserInfo.class, userDatasetProfile.getUser());
|
||||
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDatasetProfile.getDescriptionTemplate()).first();
|
||||
|
||||
mail.setSubject(environment.getProperty("admin.mail.subject").replace( "{templateName}", descriptionTemplate.getLabel()));
|
||||
String content = this.mailService.getMailTemplateContent(environment.getProperty("email.dataset.template"));
|
||||
content = content.replace("{recipient}", user.getName());
|
||||
content = content.replace("{templateName}", descriptionTemplate.getLabel());
|
||||
content = content.replace("{host}", this.environment.getProperty("dmp.domain"));
|
||||
content = content.replace("{templateID}", descriptionTemplate.getId().toString());
|
||||
mail.setContent(content);
|
||||
mail.setTo(user.getEmail());
|
||||
try {
|
||||
this.mailService.sendSimpleMail(mail);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
private void addOwner(DescriptionTemplateEntity descriptionTemplateEntity) throws InvalidApplicationException {
|
||||
UserDescriptionTemplateEntity data = new UserDescriptionTemplateEntity();
|
||||
data.setId(UUID.randomUUID());
|
||||
|
@ -428,5 +463,25 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
||||
}
|
||||
|
||||
public DescriptionTemplate importXml(byte[] bytes, UUID id, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
||||
logger.debug(new MapLogEntry("import data").And("bytes", bytes).And("fields", fields));
|
||||
|
||||
this.authorizationService.authorizeForce(Permission.ImportDescriptionTemplate);
|
||||
|
||||
if (id != null) {
|
||||
DescriptionTemplateImportXml importXml = this.xmlHandlingService.fromXml(DescriptionTemplateImportXml.class, new String(bytes, StandardCharsets.UTF_8));
|
||||
DescriptionTemplatePersist persist = importXml.toPersistModel(label, this.fieldDataHelperServiceProvider);
|
||||
this.validationService.validateForce(persist);
|
||||
return this.persist(persist, fields);
|
||||
} else {
|
||||
DescriptionTemplateImportXml importXml = this.xmlHandlingService.fromXml(DescriptionTemplateImportXml.class, new String(bytes, StandardCharsets.UTF_8));
|
||||
NewVersionDescriptionTemplatePersist persist = importXml.toNewVersionPersistModel(id, label, this.fieldDataHelperServiceProvider);
|
||||
DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
||||
if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
persist.setHash(this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()));
|
||||
this.validationService.validateForce(persist);
|
||||
return this.createNewVersion(persist, fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
@ -42,17 +43,17 @@ public class AutoCompleteFieldDataHelperService extends BaseFieldDataHelperServi
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public AutoCompleteDataEntity newDataInstanceInternal() {
|
||||
return new AutoCompleteDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public AutoCompleteData newModelInstanceInternal() {
|
||||
return new AutoCompleteData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public AutoCompleteDataPersist newPersistModelInstanceInternal() {
|
||||
return new AutoCompleteDataPersist();
|
||||
}
|
||||
|
||||
|
@ -126,4 +127,56 @@ public class AutoCompleteFieldDataHelperService extends BaseFieldDataHelperServi
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AutoCompleteDataPersist mapDataToPersist(AutoCompleteDataEntity data, AutoCompleteDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getAutoCompleteSingleDataList())){
|
||||
persist.setAutoCompleteSingleDataList(new ArrayList<>());
|
||||
for (AutoCompleteDataEntity.AutoCompleteSingleData autoCompleteSingleData: data.getAutoCompleteSingleDataList()) {
|
||||
persist.getAutoCompleteSingleDataList().add(this.buildAutoCompleteSingleData(autoCompleteSingleData));
|
||||
}
|
||||
}
|
||||
return persist;
|
||||
}
|
||||
|
||||
private @NotNull AutoCompleteSingleDataPersist buildAutoCompleteSingleData(AutoCompleteDataEntity.AutoCompleteSingleData data){
|
||||
AutoCompleteSingleDataPersist persist = new AutoCompleteSingleDataPersist();
|
||||
if (data == null) return persist;
|
||||
|
||||
persist.setUrl(data.getUrl());
|
||||
persist.setAutocompleteType(data.getAutocompleteType());
|
||||
persist.setOptionsRoot(data.getOptionsRoot());
|
||||
persist.setHasAuth(data.getHasAuth());
|
||||
if(data.getAutoCompleteOptions() != null) persist.setAutoCompleteOptions(this.buildOption(data.getAutoCompleteOptions()));
|
||||
if(data.getAuth() != null) persist.setAuth(this.buildAuthAutoCompleteData(data.getAuth()));
|
||||
persist.setMethod(data.getMethod());
|
||||
|
||||
return persist;
|
||||
}
|
||||
|
||||
private @NotNull ComboBoxOptionPersist buildOption(ComboBoxDataEntity.Option data){
|
||||
ComboBoxOptionPersist persist = new ComboBoxOptionPersist();
|
||||
if (data == null) return persist;
|
||||
|
||||
persist.setLabel(data.getLabel());
|
||||
persist.setValue(data.getValue());
|
||||
persist.setUri(data.getUri());
|
||||
persist.setSource(data.getSource());
|
||||
|
||||
return persist;
|
||||
}
|
||||
|
||||
private @NotNull AuthAutoCompleteDataPersist buildAuthAutoCompleteData(AutoCompleteDataEntity.AuthAutoCompleteData data){
|
||||
AuthAutoCompleteDataPersist persist = new AuthAutoCompleteDataPersist();
|
||||
if (data == null) return persist;
|
||||
|
||||
persist.setBody(data.getBody());
|
||||
persist.setUrl(data.getUrl());
|
||||
persist.setMethod(data.getMethod());
|
||||
persist.setPath(data.getPath());
|
||||
persist.setType(data.getType());
|
||||
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,48 @@ package eu.eudat.service.fielddatahelper;
|
|||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.BooleanDecisionDataEntity;
|
||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.BaseFieldData;
|
||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.BooleanDecisionData;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.BooleanDecisionDataPersist;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM extends BaseFieldDataPersist, D extends BaseFieldDataEntity<?>> implements FieldDataHelperService {
|
||||
protected String subType;
|
||||
protected abstract D newDataInstanceInternal();
|
||||
protected abstract M newModelInstanceInternal();
|
||||
protected abstract PM newPersistModelInstanceInternal();
|
||||
|
||||
protected abstract List<M> buildInternal(FieldSet fieldSet, List<D> datas, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||
protected abstract D applyPersistInternal(PM persist, D data);
|
||||
protected abstract PM mapDataToPersist(D data, PM persist);
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
return this.newDataInstanceInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
return this.newModelInstanceInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
return this.newPersistModelInstanceInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist mapDataToPersist(BaseFieldDataEntity<?> data) {
|
||||
PM model = this.newPersistModelInstanceInternal();
|
||||
model.setFieldType(this.getFormType());
|
||||
model.setLabel(data.getLabel());
|
||||
return this.mapDataToPersist((D)data, model);
|
||||
}
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist){
|
||||
BaseFieldDataEntity<?> instance = this.newDataInstance();
|
||||
|
|
|
@ -17,6 +17,7 @@ import gr.cite.tools.fieldset.FieldSet;
|
|||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
@ -36,17 +37,17 @@ public class BooleanDecisionFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public BooleanDecisionDataEntity newDataInstanceInternal() {
|
||||
return new BooleanDecisionDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public BooleanDecisionData newModelInstanceInternal() {
|
||||
return new BooleanDecisionData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public BooleanDecisionDataPersist newPersistModelInstanceInternal() {
|
||||
return new BooleanDecisionDataPersist();
|
||||
}
|
||||
|
||||
|
@ -58,7 +59,6 @@ public class BooleanDecisionFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
public Class<?> getModelClass() {
|
||||
return BooleanDecisionData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getPersistModelClass() {
|
||||
return BooleanDecisionDataPersist.class;
|
||||
|
@ -73,4 +73,10 @@ public class BooleanDecisionFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
protected BooleanDecisionDataEntity applyPersistInternal(BooleanDecisionDataPersist persist, BooleanDecisionDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BooleanDecisionDataPersist mapDataToPersist(BooleanDecisionDataEntity data, BooleanDecisionDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class CheckBoxFieldDataHelperService extends BaseFieldDataHelperService<C
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public CheckBoxDataEntity newDataInstanceInternal() {
|
||||
return new CheckBoxDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public CheckBoxData newModelInstanceInternal() {
|
||||
return new CheckBoxData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public CheckBoxDataPersist newPersistModelInstanceInternal() {
|
||||
return new CheckBoxDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,9 @@ public class CheckBoxFieldDataHelperService extends BaseFieldDataHelperService<C
|
|||
protected CheckBoxDataEntity applyPersistInternal(CheckBoxDataPersist persist, CheckBoxDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CheckBoxDataPersist mapDataToPersist(CheckBoxDataEntity data, CheckBoxDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,17 +34,17 @@ public class CurrencyFieldDataHelperService extends BaseFieldDataHelperService<C
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public CurrencyDataEntity newDataInstanceInternal() {
|
||||
return new CurrencyDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public CurrencyData newModelInstanceInternal() {
|
||||
return new CurrencyData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public CurrencyDataPersist newPersistModelInstanceInternal() {
|
||||
return new CurrencyDataPersist();
|
||||
}
|
||||
|
||||
|
@ -70,4 +70,9 @@ public class CurrencyFieldDataHelperService extends BaseFieldDataHelperService<C
|
|||
protected CurrencyDataEntity applyPersistInternal(CurrencyDataPersist persist, CurrencyDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CurrencyDataPersist mapDataToPersist(CurrencyDataEntity data, CurrencyDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,17 @@ public class DataRepositoryFieldDataHelperService extends BaseFieldDataHelperSer
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public DataRepositoryDataEntity newDataInstanceInternal() {
|
||||
return new DataRepositoryDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public DataRepositoryData newModelInstanceInternal() {
|
||||
return new DataRepositoryData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public DataRepositoryDataPersist newPersistModelInstanceInternal() {
|
||||
return new DataRepositoryDataPersist();
|
||||
}
|
||||
|
||||
|
@ -75,4 +75,10 @@ public class DataRepositoryFieldDataHelperService extends BaseFieldDataHelperSer
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataRepositoryDataPersist mapDataToPersist(DataRepositoryDataEntity data, DataRepositoryDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class DatasetAutoCompleteFieldDataHelperService extends BaseFieldDataHelp
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public DatasetAutoCompleteDataEntity newDataInstanceInternal() {
|
||||
return new DatasetAutoCompleteDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public DatasetAutoCompleteData newModelInstanceInternal() {
|
||||
return new DatasetAutoCompleteData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public DatasetAutoCompleteDataPersist newPersistModelInstanceInternal() {
|
||||
return new DatasetAutoCompleteDataPersist();
|
||||
}
|
||||
|
||||
|
@ -74,4 +74,10 @@ public class DatasetAutoCompleteFieldDataHelperService extends BaseFieldDataHelp
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DatasetAutoCompleteDataPersist mapDataToPersist(DatasetAutoCompleteDataEntity data, DatasetAutoCompleteDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,24 +29,23 @@ public class DatasetIdentifierFieldDataHelperService extends BaseFieldDataHelper
|
|||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FieldType getFormType() {
|
||||
return FieldType.DATASET_IDENTIFIER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public DatasetIdentifierDataEntity newDataInstanceInternal() {
|
||||
return new DatasetIdentifierDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public DatasetIdentifierData newModelInstanceInternal() {
|
||||
return new DatasetIdentifierData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public DatasetIdentifierDataPersist newPersistModelInstanceInternal() {
|
||||
return new DatasetIdentifierDataPersist();
|
||||
}
|
||||
|
||||
|
@ -72,4 +71,9 @@ public class DatasetIdentifierFieldDataHelperService extends BaseFieldDataHelper
|
|||
protected DatasetIdentifierDataEntity applyPersistInternal(DatasetIdentifierDataPersist persist, DatasetIdentifierDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DatasetIdentifierDataPersist mapDataToPersist(DatasetIdentifierDataEntity data, DatasetIdentifierDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,16 +36,16 @@ public class DatePickerFieldDataHelperService extends BaseFieldDataHelperService
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public DatePickerDataEntity newDataInstanceInternal() {
|
||||
return new DatePickerDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public DatePickerData newModelInstanceInternal() {
|
||||
return new DatePickerData();
|
||||
}
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public DatePickerDataPersist newPersistModelInstanceInternal() {
|
||||
return new DatePickerDataPersist();
|
||||
}
|
||||
|
||||
|
@ -71,4 +71,9 @@ public class DatePickerFieldDataHelperService extends BaseFieldDataHelperService
|
|||
protected DatePickerDataEntity applyPersistInternal(DatePickerDataPersist persist, DatePickerDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DatePickerDataPersist mapDataToPersist(DatePickerDataEntity data, DatePickerDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class DmpAutoCompleteFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public DmpAutoCompleteDataEntity newDataInstanceInternal() {
|
||||
return new DmpAutoCompleteDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public DmpAutoCompleteData newModelInstanceInternal() {
|
||||
return new DmpAutoCompleteData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public DmpAutoCompleteDataPersist newPersistModelInstanceInternal() {
|
||||
return new DmpAutoCompleteDataPersist();
|
||||
}
|
||||
|
||||
|
@ -74,4 +74,10 @@ public class DmpAutoCompleteFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DmpAutoCompleteDataPersist mapDataToPersist(DmpAutoCompleteDataEntity data, DmpAutoCompleteDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class ExternalDatasetFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public ExternalDatasetDataEntity newDataInstanceInternal() {
|
||||
return new ExternalDatasetDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public ExternalDatasetData newModelInstanceInternal() {
|
||||
return new ExternalDatasetData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public ExternalDatasetDataPersist newPersistModelInstanceInternal() {
|
||||
return new ExternalDatasetDataPersist();
|
||||
}
|
||||
|
||||
|
@ -74,4 +74,11 @@ public class ExternalDatasetFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
data.setType(persist.getType());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExternalDatasetDataPersist mapDataToPersist(ExternalDatasetDataEntity data, ExternalDatasetDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
persist.setType(data.getType());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
|||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.BaseFieldData;
|
||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
@ -22,4 +23,5 @@ public interface FieldDataHelperService {
|
|||
BaseFieldData buildOne(FieldSet fieldSet, BaseFieldDataEntity<?> data, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||
BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist);
|
||||
BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist, BaseFieldDataEntity<?> data);
|
||||
BaseFieldDataPersist mapDataToPersist(BaseFieldDataEntity<?> data);
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class FreeTextFieldDataHelperService extends BaseFieldDataHelperService<F
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public FreeTextDataEntity newDataInstanceInternal() {
|
||||
return new FreeTextDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public FreeTextData newModelInstanceInternal() {
|
||||
return new FreeTextData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public FreeTextDataPersist newPersistModelInstanceInternal() {
|
||||
return new FreeTextDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,9 @@ public class FreeTextFieldDataHelperService extends BaseFieldDataHelperService<F
|
|||
protected FreeTextDataEntity applyPersistInternal(FreeTextDataPersist persist, FreeTextDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FreeTextDataPersist mapDataToPersist(FreeTextDataEntity data, FreeTextDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,17 @@ public class JournalRepositoryFieldDataHelperService extends BaseFieldDataHelper
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public JournalRepositoryDataEntity newDataInstanceInternal() {
|
||||
return new JournalRepositoryDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public JournalRepositoryData newModelInstanceInternal() {
|
||||
return new JournalRepositoryData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public JournalRepositoryDataPersist newPersistModelInstanceInternal() {
|
||||
return new JournalRepositoryDataPersist();
|
||||
}
|
||||
|
||||
|
@ -75,4 +75,10 @@ public class JournalRepositoryFieldDataHelperService extends BaseFieldDataHelper
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JournalRepositoryDataPersist mapDataToPersist(JournalRepositoryDataEntity data, JournalRepositoryDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class LicenseFieldDataHelperService extends BaseFieldDataHelperService<Li
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public LicenseDataEntity newDataInstanceInternal() {
|
||||
return new LicenseDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public LicenseData newModelInstanceInternal() {
|
||||
return new LicenseData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public LicenseDataPersist newPersistModelInstanceInternal() {
|
||||
return new LicenseDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public class LicenseFieldDataHelperService extends BaseFieldDataHelperService<Li
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LicenseDataPersist mapDataToPersist(LicenseDataEntity data, LicenseDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class OrganizationFieldDataHelperService extends BaseFieldDataHelperServi
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public OrganizationDataEntity newDataInstanceInternal() {
|
||||
return new OrganizationDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public OrganizationData newModelInstanceInternal() {
|
||||
return new OrganizationData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public OrganizationDataPersist newPersistModelInstanceInternal() {
|
||||
return new OrganizationDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public class OrganizationFieldDataHelperService extends BaseFieldDataHelperServi
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OrganizationDataPersist mapDataToPersist(OrganizationDataEntity data, OrganizationDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class PublicationFieldDataHelperService extends BaseFieldDataHelperServic
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public PublicationDataEntity newDataInstanceInternal() {
|
||||
return new PublicationDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public PublicationData newModelInstanceInternal() {
|
||||
return new PublicationData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public PublicationDataPersist newPersistModelInstanceInternal() {
|
||||
return new PublicationDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public class PublicationFieldDataHelperService extends BaseFieldDataHelperServic
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PublicationDataPersist mapDataToPersist(PublicationDataEntity data, PublicationDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,17 @@ public class PublicationRepositoryFieldDataHelperService extends BaseFieldDataHe
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public PublicationRepositoryDataEntity newDataInstanceInternal() {
|
||||
return new PublicationRepositoryDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public PublicationRepositoryData newModelInstanceInternal() {
|
||||
return new PublicationRepositoryData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public PublicationRepositoryDataPersist newPersistModelInstanceInternal() {
|
||||
return new PublicationRepositoryDataPersist();
|
||||
}
|
||||
|
||||
|
@ -75,4 +75,10 @@ public class PublicationRepositoryFieldDataHelperService extends BaseFieldDataHe
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PublicationRepositoryDataPersist mapDataToPersist(PublicationRepositoryDataEntity data, PublicationRepositoryDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,17 +42,17 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public RadioBoxDataEntity newDataInstanceInternal() {
|
||||
return new RadioBoxDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public RadioBoxData newModelInstanceInternal() {
|
||||
return new RadioBoxData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public RadioBoxDataPersist newPersistModelInstanceInternal() {
|
||||
return new RadioBoxDataPersist();
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,6 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
|||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull RadioBoxDataEntity.Option buildOption(RadioBoxOptionPersist persist){
|
||||
RadioBoxDataEntity.Option data = new RadioBoxDataEntity.Option();
|
||||
if (persist == null) return data;
|
||||
|
@ -94,4 +93,26 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RadioBoxDataPersist mapDataToPersist(RadioBoxDataEntity data, RadioBoxDataPersist persist) {
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getOptions())){
|
||||
persist.setOptions(new ArrayList<>());
|
||||
for (RadioBoxDataEntity.Option radioBoxOption: data.getOptions()) {
|
||||
persist.getOptions().add(this.buildOption(radioBoxOption));
|
||||
}
|
||||
}
|
||||
return persist;
|
||||
}
|
||||
|
||||
private @NotNull RadioBoxOptionPersist buildOption(RadioBoxDataEntity.Option data){
|
||||
RadioBoxOptionPersist persist = new RadioBoxOptionPersist();
|
||||
if (data == null) return persist;
|
||||
|
||||
persist.setLabel(data.getLabel());
|
||||
persist.setValue(data.getValue());
|
||||
|
||||
return persist;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class RegistryFieldDataHelperService extends BaseFieldDataHelperService<R
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public RegistryDataEntity newDataInstanceInternal() {
|
||||
return new RegistryDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public RegistryData newModelInstanceInternal() {
|
||||
return new RegistryData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public RegistryDataPersist newPersistModelInstanceInternal() {
|
||||
return new RegistryDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public class RegistryFieldDataHelperService extends BaseFieldDataHelperService<R
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RegistryDataPersist mapDataToPersist(RegistryDataEntity data, RegistryDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class ResearcherAutoCompleteFieldDataHelperService extends BaseFieldDataH
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public ResearcherAutoCompleteDataEntity newDataInstanceInternal() {
|
||||
return new ResearcherAutoCompleteDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public ResearcherAutoCompleteData newModelInstanceInternal() {
|
||||
return new ResearcherAutoCompleteData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public ResearcherAutoCompleteDataPersist newPersistModelInstanceInternal() {
|
||||
return new ResearcherAutoCompleteDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public class ResearcherAutoCompleteFieldDataHelperService extends BaseFieldDataH
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResearcherAutoCompleteDataPersist mapDataToPersist(ResearcherAutoCompleteDataEntity data, ResearcherAutoCompleteDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class ResearcherFieldDataHelperService extends BaseFieldDataHelperService
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public ResearcherDataEntity newDataInstanceInternal() {
|
||||
return new ResearcherDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public ResearcherData newModelInstanceInternal() {
|
||||
return new ResearcherData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public ResearcherDataPersist newPersistModelInstanceInternal() {
|
||||
return new ResearcherDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public class ResearcherFieldDataHelperService extends BaseFieldDataHelperService
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResearcherDataPersist mapDataToPersist(ResearcherDataEntity data, ResearcherDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class RichTextAreaDataFieldDataHelperService extends BaseFieldDataHelperS
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public RichTextAreaDataEntity newDataInstanceInternal() {
|
||||
return new RichTextAreaDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public RichTextAreaData newModelInstanceInternal() {
|
||||
return new RichTextAreaData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public RichTextAreaDataPersist newPersistModelInstanceInternal() {
|
||||
return new RichTextAreaDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,9 @@ public class RichTextAreaDataFieldDataHelperService extends BaseFieldDataHelperS
|
|||
protected RichTextAreaDataEntity applyPersistInternal(RichTextAreaDataPersist persist, RichTextAreaDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RichTextAreaDataPersist mapDataToPersist(RichTextAreaDataEntity data, RichTextAreaDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class ServiceFieldDataHelperService extends BaseFieldDataHelperService<Se
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public ServiceDataEntity newDataInstanceInternal() {
|
||||
return new ServiceDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public ServiceData newModelInstanceInternal() {
|
||||
return new ServiceData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public ServiceDataPersist newPersistModelInstanceInternal() {
|
||||
return new ServiceDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public class ServiceFieldDataHelperService extends BaseFieldDataHelperService<Se
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServiceDataPersist mapDataToPersist(ServiceDataEntity data, ServiceDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class TagFieldDataHelperService extends BaseFieldDataHelperService<TagDat
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public TagDataEntity newDataInstanceInternal() {
|
||||
return new TagDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public TagDataPersist newPersistModelInstanceInternal() {
|
||||
return new TagDataPersist();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public TagData newModelInstanceInternal() {
|
||||
return new TagData();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,9 @@ public class TagFieldDataHelperService extends BaseFieldDataHelperService<TagDat
|
|||
protected TagDataEntity applyPersistInternal(TagDataPersist persist, TagDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TagDataPersist mapDataToPersist(TagDataEntity data, TagDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class TaxonomyFieldDataHelperService extends BaseFieldDataHelperService<T
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public TaxonomyDataEntity newDataInstanceInternal() {
|
||||
return new TaxonomyDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public TaxonomyData newModelInstanceInternal() {
|
||||
return new TaxonomyData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public TaxonomyDataPersist newPersistModelInstanceInternal() {
|
||||
return new TaxonomyDataPersist();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public class TaxonomyFieldDataHelperService extends BaseFieldDataHelperService<T
|
|||
data.setMultiAutoComplete(persist.getMultiAutoComplete());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaxonomyDataPersist mapDataToPersist(TaxonomyDataEntity data, TaxonomyDataPersist persist) {
|
||||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class TextAreaFieldDataHelperService extends BaseFieldDataHelperService<T
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public TextAreaDataEntity newDataInstanceInternal() {
|
||||
return new TextAreaDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public TextAreaData newModelInstanceInternal() {
|
||||
return new TextAreaData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public TextAreaDataPersist newPersistModelInstanceInternal() {
|
||||
return new TextAreaDataPersist();
|
||||
}
|
||||
|
||||
|
@ -72,4 +72,9 @@ public class TextAreaFieldDataHelperService extends BaseFieldDataHelperService<T
|
|||
protected TextAreaDataEntity applyPersistInternal(TextAreaDataPersist persist, TextAreaDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextAreaDataPersist mapDataToPersist(TextAreaDataEntity data, TextAreaDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,17 +39,17 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public UploadDataEntity newDataInstanceInternal() {
|
||||
return new UploadDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public UploadData newModelInstanceInternal() {
|
||||
return new UploadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public UploadDataPersist newPersistModelInstanceInternal() {
|
||||
return new UploadDataPersist();
|
||||
}
|
||||
|
||||
|
@ -91,4 +91,25 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UploadDataPersist mapDataToPersist(UploadDataEntity data, UploadDataPersist persist) {
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getTypes())){
|
||||
persist.setTypes(new ArrayList<>());
|
||||
for (UploadDataEntity.Option option: data.getTypes()) {
|
||||
persist.getTypes().add(this.buildOption(option));
|
||||
}
|
||||
}
|
||||
return persist;
|
||||
}
|
||||
|
||||
private @NotNull UploadOptionPersist buildOption(UploadDataEntity.Option data){
|
||||
UploadOptionPersist persist = new UploadOptionPersist();
|
||||
if (data == null) return persist;
|
||||
|
||||
persist.setLabel(data.getLabel());
|
||||
persist.setValue(data.getValue());
|
||||
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ public class ValidationFieldDataHelperService extends BaseFieldDataHelperService
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public ValidationDataEntity newDataInstanceInternal() {
|
||||
return new ValidationDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public ValidationData newModelInstanceInternal() {
|
||||
return new ValidationData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public ValidationDataPersist newPersistModelInstanceInternal() {
|
||||
return new ValidationDataPersist();
|
||||
}
|
||||
|
||||
|
@ -72,4 +72,9 @@ public class ValidationFieldDataHelperService extends BaseFieldDataHelperService
|
|||
protected ValidationDataEntity applyPersistInternal(ValidationDataPersist persist, ValidationDataEntity data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ValidationDataPersist mapDataToPersist(ValidationDataEntity data, ValidationDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,17 @@ public class WordListFieldDataHelperService extends BaseFieldDataHelperService<W
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
public WordListDataEntity newDataInstanceInternal() {
|
||||
return new WordListDataEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldData newModelInstance() {
|
||||
public WordListData newModelInstanceInternal() {
|
||||
return new WordListData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataPersist newPersistModelInstance() {
|
||||
public WordListDataPersist newPersistModelInstanceInternal() {
|
||||
return new WordListDataPersist();
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ public class WordListFieldDataHelperService extends BaseFieldDataHelperService<W
|
|||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull ComboBoxDataEntity.Option buildOption(ComboBoxOptionPersist persist){
|
||||
ComboBoxDataEntity.Option data = new ComboBoxDataEntity.Option();
|
||||
if (persist == null) return data;
|
||||
|
@ -93,4 +94,28 @@ public class WordListFieldDataHelperService extends BaseFieldDataHelperService<W
|
|||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WordListDataPersist mapDataToPersist(WordListDataEntity data, WordListDataPersist persist) {
|
||||
persist.setMultiList(data.getMultiList());
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getOptions())){
|
||||
persist.setOptions(new ArrayList<>());
|
||||
for (ComboBoxDataEntity.Option option: data.getOptions()) {
|
||||
persist.getOptions().add(this.buildOption(option));
|
||||
}
|
||||
}
|
||||
return persist;
|
||||
}
|
||||
|
||||
private @NotNull ComboBoxOptionPersist buildOption(ComboBoxDataEntity.Option data){
|
||||
ComboBoxOptionPersist persist = new ComboBoxOptionPersist();
|
||||
if (data == null) return persist;
|
||||
|
||||
persist.setLabel(data.getLabel());
|
||||
persist.setValue(data.getValue());
|
||||
persist.setUri(data.getUri());
|
||||
persist.setSource(data.getSource());
|
||||
|
||||
return persist;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package eu.eudat.service.mail;
|
||||
|
||||
import jakarta.mail.MessagingException;
|
||||
|
||||
|
||||
public interface MailService {
|
||||
void sendSimpleMail(SimpleMail mail) throws MessagingException;
|
||||
|
||||
String getMailTemplateContent(String resourceTemplate);
|
||||
|
||||
String getMailTemplateSubject();
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package eu.eudat.service.mail;
|
||||
|
||||
import jakarta.mail.BodyPart;
|
||||
import jakarta.mail.Message;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Service("mailService")
|
||||
public class MailServiceImpl implements MailService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MailServiceImpl.class);
|
||||
|
||||
private Environment env;
|
||||
|
||||
private JavaMailSender emailSender;
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
public MailServiceImpl(Environment env, JavaMailSender emailSender, ApplicationContext applicationContext) {
|
||||
this.env = env;
|
||||
this.emailSender = emailSender;
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSimpleMail(SimpleMail mail) throws MessagingException {
|
||||
List<String> imageSources = parseImages(mail.getContent());
|
||||
List<String> cids = new ArrayList<>();
|
||||
if (!imageSources.isEmpty()) {
|
||||
for (int i = 0; i < imageSources.size(); i++) {
|
||||
cids.add(UUID.randomUUID().toString());
|
||||
}
|
||||
mail.setContent(replaceImageSources(mail.getContent(), cids));
|
||||
}
|
||||
MimeMultipart content = new MimeMultipart("related");
|
||||
BodyPart messageBodyPart = new MimeBodyPart();
|
||||
messageBodyPart.setContent(mail.getContent(), "text/html; charset=UTF-8");
|
||||
content.addBodyPart(messageBodyPart);
|
||||
if (!imageSources.isEmpty()) {
|
||||
for (int i =0; i < imageSources.size(); i++) {
|
||||
MimeBodyPart imagePart = new MimeBodyPart();
|
||||
try {
|
||||
imagePart.attachFile(applicationContext.getResource(imageSources.get(i)).getFile());
|
||||
imagePart.setContentID("<" + cids.get(i) + ">");
|
||||
imagePart.setDisposition(MimeBodyPart.INLINE);
|
||||
content.addBodyPart(imagePart);
|
||||
} catch (IOException | MessagingException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
MimeMessage message = this.emailSender.createMimeMessage();
|
||||
message.setSubject(mail.getSubject());
|
||||
message.setContent(content);
|
||||
message.addRecipients(Message.RecipientType.TO, mail.getTo());
|
||||
message.setFrom(env.getProperty("mail.from"));
|
||||
this.emailSender.send(message);
|
||||
}
|
||||
|
||||
public Environment getEnv() {
|
||||
return env;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMailTemplateContent(String resourceTemplate) {
|
||||
Resource resource = applicationContext.getResource(resourceTemplate);
|
||||
try {
|
||||
InputStream inputStream = resource.getInputStream();
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(inputStream, writer, "UTF-8");
|
||||
inputStream.close();
|
||||
return writer.toString();
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMailTemplateSubject() {
|
||||
return env.getProperty("mail.subject");
|
||||
}
|
||||
|
||||
private List<String> parseImages(String content) {
|
||||
List<String> imagePaths = new ArrayList<>();
|
||||
|
||||
int lastIndex = 0;
|
||||
|
||||
while (lastIndex != -1) {
|
||||
lastIndex = content.indexOf("img src=\"", lastIndex);
|
||||
|
||||
if (lastIndex != -1) {
|
||||
String imagePath = content.substring(lastIndex + 9, content.indexOf("\"", lastIndex + 9));
|
||||
if (!imagePath.contains("data:image/png;base64")) {
|
||||
imagePaths.add(imagePath);
|
||||
}
|
||||
lastIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
return imagePaths;
|
||||
}
|
||||
|
||||
private String replaceImageSources(String content, List<String> cids) {
|
||||
|
||||
int lastIndex = 0;
|
||||
int cidIndex = 0;
|
||||
|
||||
while (lastIndex != -1) {
|
||||
lastIndex = content.indexOf("img src=\"", lastIndex);
|
||||
|
||||
if (lastIndex != -1) {
|
||||
content = content.replace(content.substring(lastIndex + 9, content.indexOf("\"", lastIndex + 9)), "cid:" + cids.get(cidIndex));
|
||||
lastIndex ++;
|
||||
cidIndex ++;
|
||||
}
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.models.data.mail;
|
||||
package eu.eudat.service.mail;
|
||||
|
||||
|
||||
public class SimpleMail {
|
|
@ -1,9 +1,9 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
||||
import eu.eudat.commons.enums.UserDescriptionTemplateRole;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importmodel.DescriptionTemplateImportXml;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
|
@ -17,8 +17,8 @@ import eu.eudat.models.data.admin.composite.DatasetProfile;
|
|||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.query.DescriptionTemplateTypeQuery;
|
||||
import eu.eudat.service.descriptiontemplatetype.DescriptionTemplateTypeService;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperService;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import eu.eudat.types.MetricNames;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -28,7 +28,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.io.IOException;
|
||||
|
@ -50,8 +49,10 @@ public class Admin extends BaseController {
|
|||
|
||||
private final DescriptionTemplateTypeService descriptionTemplateTypeService;
|
||||
|
||||
private final FieldDataHelperService fieldDataHelperService;
|
||||
|
||||
@Autowired
|
||||
public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, UserManager userManager/*, Logger logger*/, ConfigLoader configLoader, MetricsManager metricsManager, AuthorizationService authorizationService, UserScope userScope, QueryFactory queryFactory, DescriptionTemplateTypeService descriptionTemplateTypeService) {
|
||||
public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, UserManager userManager/*, Logger logger*/, ConfigLoader configLoader, MetricsManager metricsManager, AuthorizationService authorizationService, UserScope userScope, QueryFactory queryFactory, DescriptionTemplateTypeService descriptionTemplateTypeService, FieldDataHelperService fieldDataHelperService) {
|
||||
super(apiContext);
|
||||
this.datasetProfileManager = datasetProfileManager;
|
||||
this.userManager = userManager;
|
||||
|
@ -61,6 +62,7 @@ public class Admin extends BaseController {
|
|||
this.userScope = userScope;
|
||||
this.queryFactory = queryFactory;
|
||||
this.descriptionTemplateTypeService = descriptionTemplateTypeService;
|
||||
this.fieldDataHelperService = fieldDataHelperService;
|
||||
}
|
||||
|
||||
// @Transactional
|
||||
|
@ -195,29 +197,29 @@ public class Admin extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload", "/upload/{id}"})
|
||||
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||
@PathVariable(value = "id", required = false) String id) throws Exception {
|
||||
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.DatasetProfileManagerRole);
|
||||
|
||||
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile descriptionTemplateImportXmlModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = descriptionTemplateImportXmlModel.toAdminCompositeModel(file.getOriginalFilename());
|
||||
DescriptionTemplateEntity modelDefinition;
|
||||
if (id == null) {
|
||||
modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext(), descriptionTemplateTypeService);
|
||||
DescriptionTemplateEntity descriptionTemplateEntity = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
UserDescriptionTemplateEntity userDatasetProfile = new UserDescriptionTemplateEntity();
|
||||
userDatasetProfile.setDescriptionTemplate(descriptionTemplateEntity.getId());
|
||||
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userScope.getUserId());
|
||||
userDatasetProfile.setUser(userInfo.getId());
|
||||
userDatasetProfile.setRole(UserDescriptionTemplateRole.Owner);
|
||||
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
} else {
|
||||
modelDefinition = datasetProfileManager.createNewVersionDatasetProfile(id, datasetProfileEntity);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplateEntity>>()
|
||||
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||
}
|
||||
// @RequestMapping(method = RequestMethod.POST, value = {"/upload", "/upload/{id}"})
|
||||
// public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||
// @PathVariable(value = "id", required = false) String id) throws Exception {
|
||||
// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.DatasetProfileManagerRole);
|
||||
//
|
||||
// DescriptionTemplateImportXml descriptionTemplateImportXmlModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
|
||||
// eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = descriptionTemplateImportXmlModel.toPersistModel(file.getOriginalFilename(), this.fieldDataHelperService);
|
||||
// DescriptionTemplateEntity modelDefinition;
|
||||
// if (id == null) {
|
||||
// modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext(), descriptionTemplateTypeService);
|
||||
// DescriptionTemplateEntity descriptionTemplateEntity = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
// UserDescriptionTemplateEntity userDatasetProfile = new UserDescriptionTemplateEntity();
|
||||
// userDatasetProfile.setDescriptionTemplate(descriptionTemplateEntity.getId());
|
||||
// UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userScope.getUserId());
|
||||
// userDatasetProfile.setUser(userInfo.getId());
|
||||
// userDatasetProfile.setRole(UserDescriptionTemplateRole.Owner);
|
||||
// getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
// } else {
|
||||
// modelDefinition = datasetProfileManager.createNewVersionDatasetProfile(id, datasetProfileEntity);
|
||||
// }
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplateEntity>>()
|
||||
// .status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||
// }
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSemantics"}, produces = "application/json")
|
||||
|
|
|
@ -32,10 +32,13 @@ import org.springframework.context.MessageSource;
|
|||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
|
@ -164,4 +167,22 @@ public class DescriptionTemplateController {
|
|||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||
return persisted;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/xml/import/{id}", "/xml/import"})
|
||||
public DescriptionTemplate importXml(@RequestParam("file") MultipartFile file, @PathVariable(value = "id", required = false) UUID id, FieldSet fieldSet) throws IOException, JAXBException, InvalidApplicationException, ParserConfigurationException, TransformerException, InstantiationException, IllegalAccessException, SAXException {
|
||||
logger.debug(new MapLogEntry("import" + DescriptionTemplate.class.getSimpleName()).And("file", file).And("id", id));
|
||||
|
||||
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(fieldSet, null);
|
||||
|
||||
DescriptionTemplate model = this.descriptionTemplateTypeService.importXml(file.getBytes(), id, file.getOriginalFilename(), fieldSet);
|
||||
|
||||
this.auditService.track(AuditableAction.DmpBlueprint_Clone, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("file", file),
|
||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||
));
|
||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import eu.eudat.data.old.UserInfo;
|
|||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.ContactEmail.ContactEmailModel;
|
||||
import eu.eudat.models.data.ContactEmail.PublicContactEmailModel;
|
||||
import eu.eudat.models.data.mail.SimpleMail;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.UserDescriptionTemplateRole;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
|
||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
|
||||
import eu.eudat.logic.proxy.config.*;
|
||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||
import eu.eudat.logic.proxy.config.entities.GeneralUrls;
|
||||
|
@ -19,22 +14,15 @@ import eu.eudat.logic.services.operations.DatabaseRepository;
|
|||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile;
|
||||
import eu.eudat.model.deleter.UserDescriptionTemplateDeleter;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.models.data.mail.SimpleMail;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import eu.eudat.query.DescriptionTemplateQuery;
|
||||
import eu.eudat.query.DescriptionTemplateTypeQuery;
|
||||
import eu.eudat.query.UserDescriptionTemplateQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.service.descriptiontemplatetype.DescriptionTemplateTypeService;
|
||||
import eu.eudat.types.MetricNames;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
@ -44,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -339,102 +326,102 @@ public class DatasetProfileManager {
|
|||
return fileEnvelope;
|
||||
}
|
||||
|
||||
public DatasetProfile createDatasetProfileFromXml(MultipartFile multiPartFile) {
|
||||
ImportXmlBuilderDatasetProfile xmlBuilder = new ImportXmlBuilderDatasetProfile();
|
||||
try {
|
||||
File localFile = convert(multiPartFile);
|
||||
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile profile = xmlBuilder.build(localFile);
|
||||
Files.deleteIfExists(localFile.toPath());
|
||||
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricNames.DRAFT);
|
||||
return profile;
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// public DescriptionTemplateImportXml createDatasetProfileFromXml(MultipartFile multiPartFile) {
|
||||
// ImportXmlBuilderDatasetProfile xmlBuilder = new ImportXmlBuilderDatasetProfile();
|
||||
// try {
|
||||
// File localFile = convert(multiPartFile);
|
||||
// DescriptionTemplateImportXml profile = xmlBuilder.build(localFile);
|
||||
// Files.deleteIfExists(localFile.toPath());
|
||||
// metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricNames.DRAFT);
|
||||
// return profile;
|
||||
// } catch (IOException e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
private File convert(MultipartFile file) throws IOException {
|
||||
File convFile = new File(this.environment.getProperty("temp.temp") + file.getOriginalFilename());
|
||||
convFile.createNewFile();
|
||||
FileOutputStream fos = new FileOutputStream(convFile);
|
||||
fos.write(file.getBytes());
|
||||
fos.close();
|
||||
return convFile;
|
||||
}
|
||||
// private File convert(MultipartFile file) throws IOException {
|
||||
// File convFile = new File(this.environment.getProperty("temp.temp") + file.getOriginalFilename());
|
||||
// convFile.createNewFile();
|
||||
// FileOutputStream fos = new FileOutputStream(convFile);
|
||||
// fos.write(file.getBytes());
|
||||
// fos.close();
|
||||
// return convFile;
|
||||
// }
|
||||
//
|
||||
// public DescriptionTemplateEntity createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception {
|
||||
// // Getting the DescriptionTemplate which we will create its new version.
|
||||
// DescriptionTemplateEntity oldDescriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
//
|
||||
// // Getting the DescriptionTemplate with the latest Version.
|
||||
// DatasetProfileCriteria criteria = new DatasetProfileCriteria();
|
||||
// LinkedList<UUID> list = new LinkedList<>();
|
||||
// list.push(oldDescriptionTemplateEntity.getGroupId());
|
||||
// criteria.setGroupIds(list);
|
||||
// criteria.setAllVersions(false);
|
||||
// QueryableList<DescriptionTemplateEntity> datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria);
|
||||
// DescriptionTemplateEntity latestVersionDescriptionTemplateEntity = datasetProfileQueryableList.getSingle();
|
||||
//
|
||||
// if (latestVersionDescriptionTemplateEntity.getVersion().equals(oldDescriptionTemplateEntity.getVersion())){
|
||||
// eu.eudat.models.data.admin.composite.DatasetProfile sortedProfile = profile.toShort();
|
||||
// DescriptionTemplateEntity modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext, descriptionTemplateTypeService);
|
||||
//// modelDefinition.setLabel(oldDescriptionTemplate.getLabel());
|
||||
// modelDefinition.setVersion((short) (oldDescriptionTemplateEntity.getVersion() + 1));
|
||||
// modelDefinition.setGroupId(oldDescriptionTemplateEntity.getGroupId());
|
||||
//// modelDefinition.setLanguage(oldDescriptionTemplate.getLanguage());
|
||||
// apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
// DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
// this.storeDatasetProfileUsers(descriptionTemplateEntity, profile);
|
||||
// return modelDefinition;
|
||||
// } else {
|
||||
// throw new DatasetProfileNewVersionException("Version to update not the latest.");
|
||||
// }
|
||||
// }
|
||||
|
||||
public DescriptionTemplateEntity createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception {
|
||||
// Getting the DescriptionTemplate which we will create its new version.
|
||||
DescriptionTemplateEntity oldDescriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
|
||||
// Getting the DescriptionTemplate with the latest Version.
|
||||
DatasetProfileCriteria criteria = new DatasetProfileCriteria();
|
||||
LinkedList<UUID> list = new LinkedList<>();
|
||||
list.push(oldDescriptionTemplateEntity.getGroupId());
|
||||
criteria.setGroupIds(list);
|
||||
criteria.setAllVersions(false);
|
||||
QueryableList<DescriptionTemplateEntity> datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria);
|
||||
DescriptionTemplateEntity latestVersionDescriptionTemplateEntity = datasetProfileQueryableList.getSingle();
|
||||
|
||||
if (latestVersionDescriptionTemplateEntity.getVersion().equals(oldDescriptionTemplateEntity.getVersion())){
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile sortedProfile = profile.toShort();
|
||||
DescriptionTemplateEntity modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext, descriptionTemplateTypeService);
|
||||
// modelDefinition.setLabel(oldDescriptionTemplate.getLabel());
|
||||
modelDefinition.setVersion((short) (oldDescriptionTemplateEntity.getVersion() + 1));
|
||||
modelDefinition.setGroupId(oldDescriptionTemplateEntity.getGroupId());
|
||||
// modelDefinition.setLanguage(oldDescriptionTemplate.getLanguage());
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
DescriptionTemplateEntity descriptionTemplateEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
this.storeDatasetProfileUsers(descriptionTemplateEntity, profile);
|
||||
return modelDefinition;
|
||||
} else {
|
||||
throw new DatasetProfileNewVersionException("Version to update not the latest.");
|
||||
}
|
||||
}
|
||||
|
||||
public void storeDatasetProfileUsers(DescriptionTemplateEntity entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
|
||||
final List<UserDescriptionTemplateEntity> userDescriptionTemplateEntities = this.queryFactory.query(UserDescriptionTemplateQuery.class).isActive(IsActive.Active).descriptionTemplateIds(entity.getId()).collect();
|
||||
if (model.getUsers() != null && !model.getUsers().isEmpty()) {
|
||||
model.getUsers().stream().filter(userInfoListingModel -> userDescriptionTemplateEntities.stream()
|
||||
.filter(userDatasetProfile -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() == 0)
|
||||
.forEach(userInfoListingModel -> {
|
||||
UserDescriptionTemplateEntity userDatasetProfile1 = new UserDescriptionTemplateEntity();
|
||||
userDatasetProfile1.setDescriptionTemplate(entity.getId());
|
||||
UserInfo userInfo1 = null;
|
||||
try {
|
||||
userInfo1 = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userInfoListingModel.getId());
|
||||
} catch (InvalidApplicationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
userDatasetProfile1.setUser(userInfo1.getId());
|
||||
userDatasetProfile1.setRole(UserDescriptionTemplateRole.Member);
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile1);
|
||||
sendJoinMail(userDatasetProfile1);
|
||||
});
|
||||
// userDescriptionTemplateEntities.stream().filter(userDatasetProfile -> model.getUsers().stream()
|
||||
// .filter(userInfoListingModel -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() > 0
|
||||
// && userDatasetProfile.getRole() == UserDescriptionTemplateRole.Saved2).forEach(userDatasetProfile -> {
|
||||
// userDatasetProfile.setRole(UserDescriptionTemplateRole.Member);
|
||||
// apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
// sendJoinMail(userDatasetProfile);
|
||||
// public void storeDatasetProfileUsers(DescriptionTemplateEntity entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
|
||||
// final List<UserDescriptionTemplateEntity> userDescriptionTemplateEntities = this.queryFactory.query(UserDescriptionTemplateQuery.class).isActive(IsActive.Active).descriptionTemplateIds(entity.getId()).collect();
|
||||
// if (model.getUsers() != null && !model.getUsers().isEmpty()) {
|
||||
// model.getUsers().stream().filter(userInfoListingModel -> userDescriptionTemplateEntities.stream()
|
||||
// .filter(userDatasetProfile -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() == 0)
|
||||
// .forEach(userInfoListingModel -> {
|
||||
// UserDescriptionTemplateEntity userDatasetProfile1 = new UserDescriptionTemplateEntity();
|
||||
// userDatasetProfile1.setDescriptionTemplate(entity.getId());
|
||||
// UserInfo userInfo1 = null;
|
||||
// try {
|
||||
// userInfo1 = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userInfoListingModel.getId());
|
||||
// } catch (InvalidApplicationException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// userDatasetProfile1.setUser(userInfo1.getId());
|
||||
// userDatasetProfile1.setRole(UserDescriptionTemplateRole.Member);
|
||||
// apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile1);
|
||||
// sendJoinMail(userDatasetProfile1);
|
||||
// });
|
||||
}
|
||||
if (userDescriptionTemplateEntities != null && !userDescriptionTemplateEntities.isEmpty()) {
|
||||
List<UserDescriptionTemplateEntity> toDelete = new ArrayList<>();
|
||||
|
||||
userDescriptionTemplateEntities.stream().filter(userDatasetProfile -> model.getUsers().stream()
|
||||
.filter(userInfoListingModel -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() == 0)
|
||||
.forEach(userDatasetProfile -> {
|
||||
toDelete.add(userDatasetProfile);
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
});
|
||||
try {
|
||||
this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class).delete(toDelete);
|
||||
} catch (InvalidApplicationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//// userDescriptionTemplateEntities.stream().filter(userDatasetProfile -> model.getUsers().stream()
|
||||
//// .filter(userInfoListingModel -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() > 0
|
||||
//// && userDatasetProfile.getRole() == UserDescriptionTemplateRole.Saved2).forEach(userDatasetProfile -> {
|
||||
//// userDatasetProfile.setRole(UserDescriptionTemplateRole.Member);
|
||||
//// apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
//// sendJoinMail(userDatasetProfile);
|
||||
//// });
|
||||
// }
|
||||
// if (userDescriptionTemplateEntities != null && !userDescriptionTemplateEntities.isEmpty()) {
|
||||
// List<UserDescriptionTemplateEntity> toDelete = new ArrayList<>();
|
||||
//
|
||||
// userDescriptionTemplateEntities.stream().filter(userDatasetProfile -> model.getUsers().stream()
|
||||
// .filter(userInfoListingModel -> userDatasetProfile.getUser().equals(userInfoListingModel.getId())).count() == 0)
|
||||
// .forEach(userDatasetProfile -> {
|
||||
// toDelete.add(userDatasetProfile);
|
||||
// apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
// });
|
||||
// try {
|
||||
// this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class).delete(toDelete);
|
||||
// } catch (InvalidApplicationException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
@Transactional
|
||||
public void retrieveUsers(DescriptionTemplateEntity entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
|
||||
|
@ -457,31 +444,31 @@ public class DatasetProfileManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void sendJoinMail(UserDescriptionTemplateEntity userDatasetProfile) {
|
||||
SimpleMail mail = new SimpleMail();
|
||||
UserInfo user = null;
|
||||
try {
|
||||
user = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userDatasetProfile.getUser());
|
||||
} catch (InvalidApplicationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDatasetProfile.getDescriptionTemplate()).first();
|
||||
|
||||
mail.setSubject(environment.getProperty("admin.mail.subject").replace( "{templateName}", descriptionTemplate.getLabel()));
|
||||
String content = apiContext.getUtilitiesService().getMailService().getMailTemplateContent(environment.getProperty("email.dataset.template"));
|
||||
content = content.replace("{recipient}", user.getName());
|
||||
content = content.replace("{templateName}", descriptionTemplate.getLabel());
|
||||
content = content.replace("{host}", this.environment.getProperty("dmp.domain"));
|
||||
content = content.replace("{templateID}", descriptionTemplate.getId().toString());
|
||||
mail.setContent(content);
|
||||
mail.setTo(user.getEmail());
|
||||
try {
|
||||
apiContext.getUtilitiesService().getMailService().sendSimpleMail(mail);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
// private void sendJoinMail(UserDescriptionTemplateEntity userDatasetProfile) {
|
||||
// SimpleMail mail = new SimpleMail();
|
||||
// UserInfo user = null;
|
||||
// try {
|
||||
// user = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userDatasetProfile.getUser());
|
||||
// } catch (InvalidApplicationException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDatasetProfile.getDescriptionTemplate()).first();
|
||||
//
|
||||
// mail.setSubject(environment.getProperty("admin.mail.subject").replace( "{templateName}", descriptionTemplate.getLabel()));
|
||||
// String content = apiContext.getUtilitiesService().getMailService().getMailTemplateContent(environment.getProperty("email.dataset.template"));
|
||||
// content = content.replace("{recipient}", user.getName());
|
||||
// content = content.replace("{templateName}", descriptionTemplate.getLabel());
|
||||
// content = content.replace("{host}", this.environment.getProperty("dmp.domain"));
|
||||
// content = content.replace("{templateID}", descriptionTemplate.getId().toString());
|
||||
// mail.setContent(content);
|
||||
// mail.setTo(user.getEmail());
|
||||
// try {
|
||||
// apiContext.getUtilitiesService().getMailService().sendSimpleMail(mail);
|
||||
// } catch (Exception ex) {
|
||||
// logger.error(ex.getMessage(), ex);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
public List<String> getSemantics(String query) {
|
||||
List<Semantic> semantics = configLoader.getSemantics();
|
||||
|
|
|
@ -7,7 +7,7 @@ import eu.eudat.commons.enums.old.notification.ActiveStatus;
|
|||
import eu.eudat.commons.enums.old.notification.NotifyState;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.utilities.MailService;
|
||||
import eu.eudat.models.data.mail.SimpleMail;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -7,8 +7,7 @@ import eu.eudat.commons.scope.user.UserScope;
|
|||
import eu.eudat.data.dao.entities.EmailConfirmationDao;
|
||||
import eu.eudat.data.old.EmailConfirmation;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.mail.SimpleMail;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
|
|
@ -8,7 +8,7 @@ import eu.eudat.data.old.Invitation;
|
|||
import eu.eudat.data.old.UserDMP;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.models.data.invitation.Properties;
|
||||
import eu.eudat.models.data.mail.SimpleMail;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.logic.services.utilities;
|
||||
|
||||
import eu.eudat.models.data.mail.SimpleMail;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
|
||||
import jakarta.mail.MessagingException;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.logic.services.utilities;
|
||||
|
||||
import eu.eudat.models.data.mail.SimpleMail;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importmodel.DescriptionTemplateImportXml;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -11,18 +11,18 @@ import java.io.*;
|
|||
public class ImportXmlBuilderDatasetProfile {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDatasetProfile.class);
|
||||
|
||||
public DatasetProfile build(File xmlFile) throws IOException {
|
||||
DatasetProfile datasetProfile = new DatasetProfile();
|
||||
public DescriptionTemplateImportXml build(File xmlFile) throws IOException {
|
||||
DescriptionTemplateImportXml descriptionTemplateImportXml = new DescriptionTemplateImportXml();
|
||||
JAXBContext jaxbContext = null;
|
||||
try {
|
||||
jaxbContext = JAXBContext.newInstance(DatasetProfile.class);
|
||||
jaxbContext = JAXBContext.newInstance(DescriptionTemplateImportXml.class);
|
||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||
datasetProfile = (DatasetProfile) unmarshaller.unmarshal(xmlFile);
|
||||
descriptionTemplateImportXml = (DescriptionTemplateImportXml) unmarshaller.unmarshal(xmlFile);
|
||||
} catch (JAXBException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
return datasetProfile;
|
||||
return descriptionTemplateImportXml;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
|
||||
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "pages")
|
||||
public class DatasetProfile {
|
||||
|
||||
private String description;
|
||||
private String language;
|
||||
private String type;
|
||||
|
||||
private List<Page> page;
|
||||
|
||||
@XmlElement(name = "page")
|
||||
public List<Page> getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(List<Page> page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "description")
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "language")
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.composite.DatasetProfile toAdminCompositeModel(String label){
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile newDatasetEntityProfile = new eu.eudat.models.data.admin.composite.DatasetProfile();
|
||||
newDatasetEntityProfile.setLabel(label);
|
||||
newDatasetEntityProfile.setStatus(DescriptionTemplateStatus.Draft.getValue());
|
||||
newDatasetEntityProfile.setDescription(description);
|
||||
newDatasetEntityProfile.setLanguage(language);
|
||||
newDatasetEntityProfile.setType(type);
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionDatasetEntity = new LinkedList<>();
|
||||
for (Page xmlPage: page) {
|
||||
pagesDatasetEntity.add(xmlPage.toAdminCompositeModelPage());
|
||||
for (int i = 0; i < xmlPage.getSections().size(); i++) {
|
||||
sectionDatasetEntity.add(xmlPage.toAdminCompositeModelSection(i));
|
||||
}
|
||||
}
|
||||
newDatasetEntityProfile.setPages(pagesDatasetEntity);
|
||||
newDatasetEntityProfile.setSections(sectionDatasetEntity);
|
||||
|
||||
return newDatasetEntityProfile;
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "field-Sets")
|
||||
public class FieldSets {
|
||||
|
||||
List<FieldSet> fieldSet;
|
||||
|
||||
@XmlElement(name = "field-Set")
|
||||
public List<FieldSet> getFieldSet() {
|
||||
return fieldSet;
|
||||
}
|
||||
|
||||
public void setFieldSet(List<FieldSet> fieldSet) {
|
||||
this.fieldSet = fieldSet;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> toAdminCompositeModelSection(){
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> fieldSetEntity = new LinkedList<>();
|
||||
if(this.fieldSet!=null)
|
||||
for (FieldSet xmlFieldSet:this.fieldSet){
|
||||
fieldSetEntity.add(xmlFieldSet.toAdminCompositeModelSection());
|
||||
}
|
||||
return fieldSetEntity;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "fields")
|
||||
public class Fields {
|
||||
|
||||
private List<Field> field;
|
||||
|
||||
@XmlElement(name = "field")
|
||||
public List<Field> getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(List<Field> field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.admin.components.datasetprofile.Field> toAdminCompositeModelSection() {
|
||||
List<eu.eudat.models.data.admin.components.datasetprofile.Field> fieldsEntity = new LinkedList<>();
|
||||
if (this.field != null)
|
||||
for (Field xmlField : this.field) {
|
||||
fieldsEntity.add(xmlField.toAdminCompositeModelSection());
|
||||
}
|
||||
return fieldsEntity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.todelete.VisibilityEntity;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "visible")
|
||||
public class Visible {
|
||||
|
||||
private String style;
|
||||
private List<Rule> rule;
|
||||
|
||||
@XmlAttribute(name = "style")
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
public void setStyle(String style) {
|
||||
this.style = style;
|
||||
}
|
||||
@XmlElement(name = "rule")
|
||||
public List<Rule> getRule() {
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void setRule(List<Rule> rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public VisibilityEntity toAdminCompositeModelSection(){
|
||||
VisibilityEntity visibilityEntity = new VisibilityEntity();
|
||||
visibilityEntity.setStyle(this.style);
|
||||
if(this.rule!=null) {
|
||||
List<RuleEntity> ruleListEntity = new LinkedList<>();
|
||||
for (Rule xmlRule : this.rule) {
|
||||
ruleListEntity.add(xmlRule.toAdminCompositeModelSection());
|
||||
}
|
||||
visibilityEntity.setRules(ruleListEntity);
|
||||
}
|
||||
return visibilityEntity;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "validations")
|
||||
public class validations {
|
||||
|
||||
Validation validation;
|
||||
|
||||
@XmlElement(name = "validation")
|
||||
public Validation getValidation() {
|
||||
return validation;
|
||||
}
|
||||
|
||||
public void setValidation(Validation validation) {
|
||||
this.validation = validation;
|
||||
}
|
||||
|
||||
public int toAdminCompositeModelSection() {
|
||||
return validation.getType();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "page")
|
||||
public class Page {
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private String title;
|
||||
private List<Sections> sections;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "ordinal")
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "title")
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlElement(name = "sections")
|
||||
public List<Sections> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<Sections> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Page toAdminCompositeModelPage(){
|
||||
eu.eudat.models.data.admin.components.datasetprofile.Page pageEntity = new eu.eudat.models.data.admin.components.datasetprofile.Page();
|
||||
pageEntity.setId(this.id);
|
||||
pageEntity.setOrdinal(this.ordinal);
|
||||
pageEntity.setTitle(this.title);
|
||||
return pageEntity;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection(int i){
|
||||
/* eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity =new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||
// List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionsListEntity = new LinkedList<>();
|
||||
// for (Section xmlsection:this.sections.section) {
|
||||
// sectionsListEntity.add(xmlsection.toAdminCompositeModelSection());
|
||||
// }
|
||||
if(this.sections.section!=null)
|
||||
sectionEntity.setSections(this.sections.toAdminCompositeModelSection());
|
||||
if(this.sections.fieldSets.fieldSet!=null)
|
||||
sectionEntity.setFieldSets(this.sections.toAdminCompositeModelSectionFieldSets());
|
||||
sectionEntity.setId(this.id);
|
||||
sectionEntity.setOrdinal(this.ordinal);
|
||||
sectionEntity.setTitle(this.title);*/
|
||||
return sections.get(i).toAdminCompositeModelSection();
|
||||
}
|
||||
}
|
|
@ -147,6 +147,14 @@ permissions:
|
|||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
ImportDescriptionTemplate:
|
||||
roles:
|
||||
- Admin
|
||||
- DatasetProfileManager
|
||||
claims: [ ]
|
||||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
# Dmp
|
||||
BrowseDmp:
|
||||
roles:
|
||||
|
|
Loading…
Reference in New Issue