DescriptionTemplate refactor
This commit is contained in:
parent
d38f22ccbf
commit
b6278ab1ef
|
@ -20,6 +20,7 @@ public class AuditableAction {
|
|||
public static final EventId DmpBlueprint_Delete = new EventId(3003, "DmpBlueprint_Delete");
|
||||
public static final EventId DmpBlueprint_Clone = new EventId(3004, "DmpBlueprint_Clone");
|
||||
public static final EventId DmpBlueprint_GetXml = new EventId(3005, "DmpBlueprint_GetXml");
|
||||
public static final EventId DmpBlueprint_Import = new EventId(3006, "DmpBlueprint_Import");
|
||||
|
||||
public static final EventId User_Settings_Query = new EventId(4000, "User_Settings_Query");
|
||||
public static final EventId User_Settings_Lookup = new EventId(4001, "User_Settings_Lookup");
|
||||
|
@ -47,5 +48,7 @@ public class AuditableAction {
|
|||
public static final EventId DescriptionTemplate_Delete = new EventId(8003, "DescriptionTemplate_Delete");
|
||||
public static final EventId DescriptionTemplate_Clone = new EventId(8004, "DescriptionTemplate_Clone");
|
||||
public static final EventId DescriptionTemplate_PersistNewVersion = new EventId(8005, "DescriptionTemplate_PersistNewVersion");
|
||||
public static final EventId DescriptionTemplate_GetXml = new EventId(8006, "DescriptionTemplate_GetXml");
|
||||
public static final EventId DescriptionTemplate_Import = new EventId(8007, "DescriptionTemplate_Import");
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public final class Permission {
|
|||
public static String CloneDescriptionTemplate = "CloneDescriptionTemplate";
|
||||
public static String CreateNewVersionDescriptionTemplate = "CreateNewVersionDescriptionTemplate";
|
||||
public static String ImportDescriptionTemplate = "ImportDescriptionTemplate";
|
||||
public static String ExportDescriptionTemplate = "ExportDescriptionTemplate";
|
||||
|
||||
//DescriptionTemplateType
|
||||
public static String BrowseDescriptionTemplateType = "BrowseDescriptionTemplateType";
|
||||
|
|
|
@ -23,18 +23,18 @@ public class DescriptionTemplateImportExport {
|
|||
@XmlAttribute(name = "language")
|
||||
private String language;
|
||||
@XmlAttribute(name = "type")
|
||||
private String type;
|
||||
private UUID type;
|
||||
@XmlElementWrapper(name = "pages")
|
||||
@XmlElement(name = "page")
|
||||
private List<PageImportExport> page;
|
||||
private List<PageImportExport> pages;
|
||||
|
||||
|
||||
public List<PageImportExport> getPage() {
|
||||
return page;
|
||||
public List<PageImportExport> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPage(List<PageImportExport> page) {
|
||||
this.page = page;
|
||||
public void setPages(List<PageImportExport> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,60 +56,11 @@ public class DescriptionTemplateImportExport {
|
|||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
public UUID getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
public void setType(UUID 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 (PageImportExport 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 (PageImportExport 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,27 +148,4 @@ public class FieldImportExport {
|
|||
this.visibilityRules = visibilityRules;
|
||||
}
|
||||
|
||||
public FieldPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||
FieldPersist fieldEntity =new FieldPersist();
|
||||
fieldEntity.setId(this.id);
|
||||
fieldEntity.setOrdinal(this.ordinal);
|
||||
fieldEntity.setValidations(this.validations);
|
||||
fieldEntity.setDefaultValue(this.defaultValue);
|
||||
List<RulePersist> rulePersists = new ArrayList<>();
|
||||
if(this.visibilityRules!=null) {
|
||||
for (RuleImportExport xmlRule : this.visibilityRules) {
|
||||
rulePersists.add(xmlRule.toPersistModel());
|
||||
}
|
||||
}
|
||||
fieldEntity.setVisibilityRules(rulePersists);
|
||||
FieldType fieldType = this.fieldType;
|
||||
|
||||
BaseFieldDataEntity<?> data = new FieldDataHelper().toFieldData(null, fieldType, (Element) this.data);
|
||||
if (data != null) {
|
||||
FieldDataHelperService fieldDataHelperService = fieldDataHelperServiceProvider.get(fieldType);
|
||||
fieldEntity.setData(fieldDataHelperService.importExportMapDataToPersist(this.data));
|
||||
}
|
||||
fieldEntity.setSchematics(this.schematics);
|
||||
return fieldEntity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,24 +113,4 @@ public class FieldSetImportExport {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
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.toPersistModel() : null);
|
||||
fieldSet1Entity.setTitle(this.title);
|
||||
fieldSet1Entity.setDescription(this.description);
|
||||
fieldSet1Entity.setExtendedDescription(this.extendedDescription);
|
||||
fieldSet1Entity.setAdditionalInformation(this.additionalInformation);
|
||||
|
||||
List<FieldPersist> fieldsEntity = new LinkedList<>();
|
||||
if (this.fields != null){
|
||||
for (FieldImportExport xmlField : this.fields) {
|
||||
fieldsEntity.add(xmlField.toPersistModel(fieldDataHelperServiceProvider));
|
||||
}
|
||||
}
|
||||
fieldSet1Entity.setFields(fieldsEntity);
|
||||
return fieldSet1Entity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,12 +48,4 @@ public class MultiplicityImportXml {
|
|||
this.tableView = tableView;
|
||||
}
|
||||
|
||||
public MultiplicityPersist toPersistModel() {
|
||||
MultiplicityPersist multiplicityEntity = new MultiplicityPersist();
|
||||
multiplicityEntity.setMax(max);
|
||||
multiplicityEntity.setMin(min);
|
||||
multiplicityEntity.setPlaceholder(placeholder);
|
||||
multiplicityEntity.setTableView(tableView);
|
||||
return multiplicityEntity;
|
||||
}
|
||||
}
|
|
@ -52,15 +52,4 @@ public class PageImportExport {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,11 +27,4 @@ public class RuleImportExport {
|
|||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public RulePersist toPersistModel(){
|
||||
RulePersist ruleEntity = new RulePersist();
|
||||
ruleEntity.setTarget(target);
|
||||
ruleEntity.setValue(value);
|
||||
return ruleEntity;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,7 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.importexport;
|
||||
|
||||
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.*;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
|
@ -29,7 +25,7 @@ public class SectionImportExport {
|
|||
private String title;
|
||||
@XmlElementWrapper(name = "sections")
|
||||
@XmlElement(name = "section")
|
||||
private List<SectionImportExport> section;
|
||||
private List<SectionImportExport> sections;
|
||||
@XmlAttribute(name = "multiplicity")
|
||||
private Boolean multiplicity;
|
||||
|
||||
|
@ -97,12 +93,12 @@ public class SectionImportExport {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public List<SectionImportExport> getSection() {
|
||||
return section;
|
||||
public List<SectionImportExport> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSection(List<SectionImportExport> section) {
|
||||
this.section = section;
|
||||
public void setSections(List<SectionImportExport> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
public Boolean getMultiplicity() {
|
||||
|
@ -113,35 +109,4 @@ public class SectionImportExport {
|
|||
this.multiplicity = multiplicity;
|
||||
}
|
||||
|
||||
public SectionPersist toPersistModel(FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||
SectionPersist sectionEntity = new SectionPersist();
|
||||
List<SectionPersist> sectionsListEntity = new LinkedList<>();
|
||||
|
||||
if (this.section != null) {
|
||||
for (SectionImportExport xmlsection : this.section) {
|
||||
sectionsListEntity.add(xmlsection.toPersistModel(fieldDataHelperServiceProvider));
|
||||
}
|
||||
}
|
||||
sectionEntity.setId(this.id);
|
||||
sectionEntity.setOrdinal(this.ordinal);
|
||||
sectionEntity.setTitle(this.title);
|
||||
sectionEntity.setPage(this.page);
|
||||
sectionEntity.setDescription(this.description);
|
||||
// List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> fieldSetsEntity =new LinkedList<>();
|
||||
//
|
||||
// for (FieldSets xmpFieldSets: this.fieldSets) {
|
||||
// fieldSetsEntity.add(xmpFieldSets.toAdminCompositeModelSection());
|
||||
// }
|
||||
List<FieldSetPersist> fieldSetEntity = new LinkedList<>();
|
||||
if(this.fieldSets!=null) {
|
||||
for (FieldSetImportExport xmlFieldSet : this.fieldSets) {
|
||||
fieldSetEntity.add(xmlFieldSet.toPersistModel(fieldDataHelperServiceProvider));
|
||||
}
|
||||
}
|
||||
sectionEntity.setFieldSets(fieldSetEntity);
|
||||
|
||||
sectionEntity.setSections(sectionsListEntity);
|
||||
sectionEntity.setDefaultVisibility(this.defaultVisibility);
|
||||
return sectionEntity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ 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.springframework.http.ResponseEntity;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
|
@ -25,4 +26,5 @@ public interface DescriptionTemplateService {
|
|||
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;
|
||||
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException;
|
||||
}
|
||||
|
|
|
@ -5,12 +5,14 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
||||
import eu.eudat.commons.enums.FieldType;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
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.importexport.DescriptionTemplateImportExport;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.FieldDataHelper;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importexport.*;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||
|
@ -30,9 +32,11 @@ import eu.eudat.model.persist.descriptiontemplatedefinition.*;
|
|||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist;
|
||||
import eu.eudat.query.DescriptionTemplateQuery;
|
||||
import eu.eudat.query.UserDescriptionTemplateQuery;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperService;
|
||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import eu.eudat.service.mail.MailService;
|
||||
import eu.eudat.service.mail.SimpleMail;
|
||||
import eu.eudat.service.responseutils.ResponseUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
|
@ -55,7 +59,9 @@ 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.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
|
@ -65,6 +71,7 @@ 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;
|
||||
|
@ -91,6 +98,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
private final ValidationService validationService;
|
||||
private final MailService mailService;
|
||||
private final Environment environment;
|
||||
private final ResponseUtilsService responseUtilsService;
|
||||
|
||||
@Autowired
|
||||
public DescriptionTemplateServiceImpl(
|
||||
|
@ -101,7 +109,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
ConventionService conventionService,
|
||||
MessageSource messageSource,
|
||||
XmlHandlingService xmlHandlingService,
|
||||
FieldDataHelperServiceProvider fieldDataHelperServiceProvider, QueryFactory queryFactory, ErrorThesaurusProperties errors, ValidationService validationService, MailService mailService, Environment environment) {
|
||||
FieldDataHelperServiceProvider fieldDataHelperServiceProvider, QueryFactory queryFactory, ErrorThesaurusProperties errors, ValidationService validationService, MailService mailService, Environment environment, ResponseUtilsService responseUtilsService) {
|
||||
this.entityManager = entityManager;
|
||||
this.userScope = userScope;
|
||||
this.authorizationService = authorizationService;
|
||||
|
@ -116,6 +124,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
this.validationService = validationService;
|
||||
this.mailService = mailService;
|
||||
this.environment = environment;
|
||||
this.responseUtilsService = responseUtilsService;
|
||||
}
|
||||
|
||||
//region Persist
|
||||
|
@ -132,6 +141,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
data = this.entityManager.find(DescriptionTemplateEntity.class, model.getId());
|
||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||
if (data.getStatus() == DescriptionTemplateStatus.Finalized) throw new MyForbiddenException("Can not update finalized template");
|
||||
} else {
|
||||
data = new DescriptionTemplateEntity();
|
||||
data.setId(UUID.randomUUID());
|
||||
|
@ -485,19 +495,292 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
this.authorizationService.authorizeForce(Permission.ImportDescriptionTemplate);
|
||||
|
||||
DescriptionTemplateImportExport importXml = this.xmlHandlingService.fromXml(DescriptionTemplateImportExport.class, new String(bytes, StandardCharsets.UTF_8));
|
||||
if (id != null) {
|
||||
DescriptionTemplatePersist persist = importXml.toPersistModel(label, this.fieldDataHelperServiceProvider);
|
||||
if (id == null) {
|
||||
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
||||
persist.setLabel(label);
|
||||
persist.setStatus(DescriptionTemplateStatus.Draft);
|
||||
persist.setDescription(importXml.getDescription());
|
||||
persist.setLanguage(importXml.getLanguage());
|
||||
persist.setType(importXml.getType());
|
||||
persist.setDefinition(this.xmlDefinitionToPersist(importXml));
|
||||
this.validationService.validateForce(persist);
|
||||
return this.persist(persist, fields);
|
||||
} else {
|
||||
NewVersionDescriptionTemplatePersist persist = importXml.toNewVersionPersistModel(id, label, this.fieldDataHelperServiceProvider);
|
||||
NewVersionDescriptionTemplatePersist persist = new NewVersionDescriptionTemplatePersist();
|
||||
persist.setId(id);
|
||||
persist.setLabel(label);
|
||||
persist.setStatus(DescriptionTemplateStatus.Draft);
|
||||
persist.setDescription(importXml.getDescription());
|
||||
persist.setLanguage(importXml.getLanguage());
|
||||
persist.setDefinition(this.xmlDefinitionToPersist(importXml));
|
||||
persist.setType(importXml.getType());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DefinitionPersist xmlDefinitionToPersist(DescriptionTemplateImportExport importExport){
|
||||
DefinitionPersist definitionPersist = new DefinitionPersist();
|
||||
if(importExport == null) return null;
|
||||
|
||||
List<PagePersist> pagesDatasetEntity = new LinkedList<>();
|
||||
List<SectionPersist> sectionDatasetEntity = new LinkedList<>();
|
||||
if (!this.conventionService.isListNullOrEmpty(importExport.getPages())) {
|
||||
for (PageImportExport xmlPage : importExport.getPages()) {
|
||||
pagesDatasetEntity.add(this.xmlPageToPersist(xmlPage));
|
||||
if (!this.conventionService.isListNullOrEmpty(xmlPage.getSections())) {
|
||||
for (int i = 0; i < xmlPage.getSections().size(); i++) {
|
||||
sectionDatasetEntity.add(this.xmlSectionToPersist(xmlPage.getSections().get(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
definitionPersist.setPages(pagesDatasetEntity);
|
||||
definitionPersist.setSections(sectionDatasetEntity);
|
||||
|
||||
return definitionPersist;
|
||||
}
|
||||
|
||||
public PagePersist xmlPageToPersist(PageImportExport importExport){
|
||||
PagePersist pageEntity = new PagePersist();
|
||||
pageEntity.setId(importExport.getId());
|
||||
pageEntity.setOrdinal(importExport.getOrdinal());
|
||||
pageEntity.setTitle(importExport.getTitle());
|
||||
return pageEntity;
|
||||
}
|
||||
|
||||
public SectionPersist xmlSectionToPersist(SectionImportExport importExport) {
|
||||
SectionPersist sectionEntity = new SectionPersist();
|
||||
List<SectionPersist> sectionsListEntity = new LinkedList<>();
|
||||
|
||||
if (!this.conventionService.isListNullOrEmpty(importExport.getSections())) {
|
||||
for (SectionImportExport xmlSection : importExport.getSections()) {
|
||||
sectionsListEntity.add(this.xmlSectionToPersist(xmlSection));
|
||||
}
|
||||
}
|
||||
sectionEntity.setId(importExport.getId());
|
||||
sectionEntity.setOrdinal(importExport.getOrdinal());
|
||||
sectionEntity.setTitle(importExport.getTitle());
|
||||
sectionEntity.setPage(importExport.getPage());
|
||||
sectionEntity.setDescription(importExport.getDescription());
|
||||
List<FieldSetPersist> fieldSetEntity = new LinkedList<>();
|
||||
if(!this.conventionService.isListNullOrEmpty(importExport.getFieldSets())) {
|
||||
for (FieldSetImportExport xmlFieldSet : importExport.getFieldSets()) {
|
||||
fieldSetEntity.add(this.toFieldSetModel(xmlFieldSet));
|
||||
}
|
||||
}
|
||||
sectionEntity.setFieldSets(fieldSetEntity);
|
||||
|
||||
sectionEntity.setSections(sectionsListEntity);
|
||||
sectionEntity.setDefaultVisibility(importExport.getDefaultVisibility());
|
||||
return sectionEntity;
|
||||
}
|
||||
|
||||
|
||||
public FieldSetPersist toFieldSetModel(FieldSetImportExport importExport) {
|
||||
FieldSetPersist fieldSet1Entity = new FieldSetPersist();
|
||||
fieldSet1Entity.setId(importExport.getId());
|
||||
fieldSet1Entity.setOrdinal(importExport.getOrdinal());
|
||||
fieldSet1Entity.setHasCommentField(importExport.getCommentField() != null ? importExport.getCommentField() : false);
|
||||
fieldSet1Entity.setMultiplicity(importExport.getMultiplicity() != null ? this.xmlMultiplicityToPersist(importExport.getMultiplicity()) : null);
|
||||
fieldSet1Entity.setTitle(importExport.getTitle());
|
||||
fieldSet1Entity.setDescription(importExport.getDescription());
|
||||
fieldSet1Entity.setExtendedDescription(importExport.getExtendedDescription());
|
||||
fieldSet1Entity.setAdditionalInformation(importExport.getAdditionalInformation());
|
||||
|
||||
List<FieldPersist> fieldsEntity = new LinkedList<>();
|
||||
if (!this.conventionService.isListNullOrEmpty(importExport.getFields())){
|
||||
for (FieldImportExport xmlField : importExport.getFields()) {
|
||||
fieldsEntity.add(this.xmlFieldToPersist(xmlField));
|
||||
}
|
||||
}
|
||||
fieldSet1Entity.setFields(fieldsEntity);
|
||||
return fieldSet1Entity;
|
||||
}
|
||||
|
||||
|
||||
public FieldPersist xmlFieldToPersist(FieldImportExport importExport) {
|
||||
FieldPersist fieldEntity = new FieldPersist();
|
||||
fieldEntity.setId(importExport.getId());
|
||||
fieldEntity.setOrdinal(importExport.getOrdinal());
|
||||
fieldEntity.setValidations(importExport.getValidations());
|
||||
fieldEntity.setDefaultValue(importExport.getDefaultValue());
|
||||
List<RulePersist> rulePersists = new ArrayList<>();
|
||||
if(importExport.getVisibilityRules() !=null) {
|
||||
for (RuleImportExport xmlRule : importExport.getVisibilityRules()) {
|
||||
rulePersists.add(this.toRuleModel(xmlRule));
|
||||
}
|
||||
}
|
||||
fieldEntity.setVisibilityRules(rulePersists);
|
||||
FieldType fieldType = importExport.getFieldType();
|
||||
|
||||
if (importExport.getData() != null) {
|
||||
FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(fieldType);
|
||||
fieldEntity.setData(fieldDataHelperService.importExportMapDataToPersist(importExport.getData()));
|
||||
}
|
||||
fieldEntity.setSchematics(importExport.getSchematics());
|
||||
return fieldEntity;
|
||||
}
|
||||
|
||||
public RulePersist toRuleModel(RuleImportExport importExport){
|
||||
RulePersist ruleEntity = new RulePersist();
|
||||
ruleEntity.setTarget(importExport.getTarget());
|
||||
ruleEntity.setValue(importExport.getValue());
|
||||
return ruleEntity;
|
||||
}
|
||||
|
||||
|
||||
public MultiplicityPersist xmlMultiplicityToPersist(MultiplicityImportXml importXml) {
|
||||
MultiplicityPersist multiplicityEntity = new MultiplicityPersist();
|
||||
multiplicityEntity.setMax(importXml.getMax());
|
||||
multiplicityEntity.setMin(importXml.getMin());
|
||||
multiplicityEntity.setPlaceholder(importXml.getPlaceholder());
|
||||
multiplicityEntity.setTableView(importXml.getTableView());
|
||||
return multiplicityEntity;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region Export
|
||||
|
||||
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("persisting data").And("id", id));
|
||||
|
||||
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);
|
||||
DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
DefinitionEntity definition = this.xmlHandlingService.fromXml(DefinitionEntity.class, data.getDefinition());
|
||||
String xml = this.xmlHandlingService.toXml(this.definitionXmlToExport(data, definition));
|
||||
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
||||
}
|
||||
|
||||
public DescriptionTemplateImportExport definitionXmlToExport(DescriptionTemplateEntity data, DefinitionEntity entity){
|
||||
DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport();
|
||||
xml.setType(data.getType());
|
||||
xml.setLanguage(data.getLanguage());
|
||||
xml.setDescription(data.getDescription());
|
||||
List<PageImportExport> pagesDatasetEntity = new LinkedList<>();
|
||||
for (PageEntity xmlPage: entity.getPages()) {
|
||||
pagesDatasetEntity.add(this.pageXmlToExport(xmlPage, entity.getSections()));
|
||||
}
|
||||
xml.setPages(pagesDatasetEntity);
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
public PageImportExport pageXmlToExport(PageEntity entity, List<SectionEntity> sectionEntities){
|
||||
PageImportExport xml = new PageImportExport();
|
||||
xml.setId(entity.getId());
|
||||
xml.setOrdinal(entity.getOrdinal());
|
||||
xml.setTitle(entity.getTitle());
|
||||
List<SectionImportExport> sectionsListEntity = new LinkedList<>();
|
||||
if (!this.conventionService.isListNullOrEmpty(sectionEntities)) {
|
||||
for (SectionEntity section : sectionEntities) {
|
||||
if (section.getPage().equals(entity.getId())) {
|
||||
sectionsListEntity.add(this.sectionXmlToExport(section));
|
||||
}
|
||||
}
|
||||
}
|
||||
xml.setSections(sectionsListEntity);
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
public SectionImportExport sectionXmlToExport(SectionEntity entity) {
|
||||
SectionImportExport xml = new SectionImportExport();
|
||||
List<SectionImportExport> sectionsListEntity = new LinkedList<>();
|
||||
|
||||
if (!this.conventionService.isListNullOrEmpty(entity.getSections())) {
|
||||
for (SectionEntity xmlSection : entity.getSections()) {
|
||||
sectionsListEntity.add(this.sectionXmlToExport(xmlSection));
|
||||
}
|
||||
}
|
||||
xml.setSections(sectionsListEntity);
|
||||
|
||||
xml.setId(entity.getId());
|
||||
xml.setOrdinal(entity.getOrdinal());
|
||||
xml.setTitle(entity.getTitle());
|
||||
xml.setPage(entity.getPage());
|
||||
xml.setDescription(entity.getDescription());
|
||||
List<FieldSetImportExport> fieldSetEntity = new LinkedList<>();
|
||||
if(!this.conventionService.isListNullOrEmpty(entity.getFieldSets())) {
|
||||
for (FieldSetEntity xmlFieldSet : entity.getFieldSets()) {
|
||||
fieldSetEntity.add(this.fieldSetXmlToExport(xmlFieldSet));
|
||||
}
|
||||
}
|
||||
xml.setFieldSets(fieldSetEntity);
|
||||
|
||||
xml.setDefaultVisibility(entity.isDefaultVisibility());
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
||||
public FieldSetImportExport fieldSetXmlToExport(FieldSetEntity entity) {
|
||||
FieldSetImportExport fieldSet1Entity = new FieldSetImportExport();
|
||||
fieldSet1Entity.setId(entity.getId());
|
||||
fieldSet1Entity.setOrdinal(entity.getOrdinal());
|
||||
fieldSet1Entity.setCommentField(entity.getHasCommentField());
|
||||
fieldSet1Entity.setMultiplicity(entity.getMultiplicity() != null ? this.multiplicityXmlToExport(entity.getMultiplicity()) : null);
|
||||
fieldSet1Entity.setTitle(entity.getTitle());
|
||||
fieldSet1Entity.setDescription(entity.getDescription());
|
||||
fieldSet1Entity.setExtendedDescription(entity.getExtendedDescription());
|
||||
fieldSet1Entity.setAdditionalInformation(entity.getAdditionalInformation());
|
||||
|
||||
List<FieldImportExport> fieldsEntity = new LinkedList<>();
|
||||
if (entity.getFields() != null){
|
||||
for (FieldEntity xmlField : entity.getFields()) {
|
||||
fieldsEntity.add(this.fieldXmlToExport(xmlField));
|
||||
}
|
||||
}
|
||||
fieldSet1Entity.setFields(fieldsEntity);
|
||||
return fieldSet1Entity;
|
||||
}
|
||||
|
||||
|
||||
public FieldImportExport fieldXmlToExport(FieldEntity entity) {
|
||||
FieldImportExport xml = new FieldImportExport();
|
||||
xml.setId(entity.getId());
|
||||
xml.setOrdinal(entity.getOrdinal());
|
||||
xml.setValidations(entity.getValidations());
|
||||
xml.setDefaultValue(entity.getDefaultValue());
|
||||
List<RuleImportExport> rulePersists = new ArrayList<>();
|
||||
if(!this.conventionService.isListNullOrEmpty(entity.getVisibilityRules())) {
|
||||
for (RuleEntity xmlRule : entity.getVisibilityRules()) {
|
||||
rulePersists.add(this.toRuleModel(xmlRule));
|
||||
}
|
||||
}
|
||||
xml.setVisibilityRules(rulePersists);
|
||||
|
||||
if (entity.getData() != null) {
|
||||
FieldType fieldType = entity.getData().getFieldType();
|
||||
FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(fieldType);
|
||||
xml.setData(fieldDataHelperService.dataToImportExportXml(entity.getData()));
|
||||
}
|
||||
xml.setSchematics(entity.getSchematics());
|
||||
return xml;
|
||||
}
|
||||
|
||||
public RuleImportExport toRuleModel(RuleEntity entity){
|
||||
RuleImportExport xml = new RuleImportExport();
|
||||
xml.setTarget(entity.getTarget());
|
||||
xml.setValue(entity.getValue());
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
||||
public MultiplicityImportXml multiplicityXmlToExport(MultiplicityEntity entity) {
|
||||
MultiplicityImportXml xml = new MultiplicityImportXml();
|
||||
xml.setMax(entity.getMax());
|
||||
xml.setMin(entity.getMin());
|
||||
xml.setPlaceholder(entity.getPlaceholder());
|
||||
xml.setTableView(entity.getTableView());
|
||||
return xml;
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
|
|
@ -189,4 +189,56 @@ public class AutoCompleteFieldDataHelperService extends BaseFieldDataHelperServi
|
|||
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AutoCompleteDataImportExport dataToImportExportXmlInternal(AutoCompleteDataEntity data, AutoCompleteDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getAutoCompleteSingleDataList())){
|
||||
xml.setAutoCompleteSingleDataList(new ArrayList<>());
|
||||
for (AutoCompleteDataEntity.AutoCompleteSingleData autoCompleteSingleData: data.getAutoCompleteSingleDataList()) {
|
||||
xml.getAutoCompleteSingleDataList().add(this.buildAutoCompleteSingleData(autoCompleteSingleData));
|
||||
}
|
||||
}
|
||||
return xml;
|
||||
}
|
||||
|
||||
private @NotNull AutoCompleteSingleData buildAutoCompleteSingleData(AutoCompleteDataEntity.AutoCompleteSingleData data){
|
||||
AutoCompleteSingleData xml = new AutoCompleteSingleData();
|
||||
if (data == null) return xml;
|
||||
|
||||
xml.setUrl(data.getUrl());
|
||||
xml.setAutocompleteType(data.getAutocompleteType());
|
||||
xml.setOptionsRoot(data.getOptionsRoot());
|
||||
xml.setHasAuth(data.getHasAuth());
|
||||
if(data.getAutoCompleteOptions() != null) xml.setAutoCompleteOptions(this.buildOption(data.getAutoCompleteOptions()));
|
||||
if(data.getAuth() != null) xml.setAuth(this.buildAuthAutoCompleteData(data.getAuth()));
|
||||
xml.setMethod(data.getMethod());
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
private @NotNull ComboBoxDataOptionEntity buildOption(ComboBoxDataEntity.Option data){
|
||||
ComboBoxDataOptionEntity xml = new ComboBoxDataOptionEntity();
|
||||
if (data == null) return xml;
|
||||
|
||||
xml.setLabel(data.getLabel());
|
||||
xml.setValue(data.getValue());
|
||||
xml.setUri(data.getUri());
|
||||
xml.setSource(data.getSource());
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
private @NotNull AuthAutoCompleteData buildAuthAutoCompleteData(AutoCompleteDataEntity.AuthAutoCompleteData data){
|
||||
AuthAutoCompleteData xml = new AuthAutoCompleteData();
|
||||
if (data == null) return xml;
|
||||
|
||||
xml.setBody(data.getBody());
|
||||
xml.setUrl(data.getUrl());
|
||||
xml.setMethod(data.getMethod());
|
||||
xml.setPath(data.getPath());
|
||||
xml.setType(data.getType());
|
||||
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM ext
|
|||
protected abstract List<M> buildInternal(FieldSet fieldSet, List<D> datas, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||
protected abstract D applyPersistInternal(PM persist, D data);
|
||||
protected abstract PM importExportMapDataToPersistInternal(IE data, PM persist);
|
||||
protected abstract IE dataToImportExportXmlInternal(D data, IE xml);
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> newDataInstance() {
|
||||
return this.newDataInstanceInternal();
|
||||
|
@ -51,6 +52,13 @@ public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM ext
|
|||
model.setLabel(data.getLabel());
|
||||
return this.importExportMapDataToPersistInternal((IE)data, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseFieldDataImportExport dataToImportExportXml(BaseFieldDataEntity<?> data){
|
||||
IE xml = this.newImportExportInstanceInternal();
|
||||
xml.setLabel(data.getLabel());
|
||||
return this.dataToImportExportXmlInternal((D)data, xml);
|
||||
}
|
||||
@Override
|
||||
public BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist){
|
||||
BaseFieldDataEntity<?> instance = this.newDataInstance();
|
||||
|
|
|
@ -88,4 +88,9 @@ public class BooleanDecisionFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BooleanDecisionDataImportExport dataToImportExportXmlInternal(BooleanDecisionDataEntity data, BooleanDecisionDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -91,4 +91,9 @@ public class CheckBoxFieldDataHelperService extends BaseFieldDataHelperService<C
|
|||
protected CheckBoxDataPersist importExportMapDataToPersistInternal(CheckBoxDataImportExport data, CheckBoxDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CheckBoxDataImportExport dataToImportExportXmlInternal(CheckBoxDataEntity data, CheckBoxDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,4 +88,9 @@ public class CurrencyFieldDataHelperService extends BaseFieldDataHelperService<C
|
|||
protected CurrencyDataPersist importExportMapDataToPersistInternal(CurrencyDataImportExport data, CurrencyDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CurrencyDataImportExport dataToImportExportXmlInternal(CurrencyDataEntity data, CurrencyDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,4 +90,10 @@ public class DataRepositoryFieldDataHelperService extends BaseFieldDataHelperSer
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataRepositoryDataImportExport dataToImportExportXmlInternal(DataRepositoryDataEntity data, DataRepositoryDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,4 +93,10 @@ public class DatasetAutoCompleteFieldDataHelperService extends BaseFieldDataHelp
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DatasetAutoCompleteDataImportExport dataToImportExportXmlInternal(DatasetAutoCompleteDataEntity data, DatasetAutoCompleteDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,4 +89,9 @@ public class DatasetIdentifierFieldDataHelperService extends BaseFieldDataHelper
|
|||
protected DatasetIdentifierDataPersist importExportMapDataToPersistInternal(DatasetIdentifierDataImportExport data, DatasetIdentifierDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DatasetIdentifierDataImportExport dataToImportExportXmlInternal(DatasetIdentifierDataEntity data, DatasetIdentifierDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,4 +89,9 @@ public class DatePickerFieldDataHelperService extends BaseFieldDataHelperService
|
|||
protected DatePickerDataPersist importExportMapDataToPersistInternal(DatePickerDataImportExport data, DatePickerDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DatePickerDataImportExport dataToImportExportXmlInternal(DatePickerDataEntity data, DatePickerDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,4 +93,10 @@ public class DmpAutoCompleteFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DmpAutoCompleteDataImportExport dataToImportExportXmlInternal(DmpAutoCompleteDataEntity data, DmpAutoCompleteDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,4 +94,11 @@ public class ExternalDatasetFieldDataHelperService extends BaseFieldDataHelperSe
|
|||
persist.setType(data.getType());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExternalDatasetDataImportExport dataToImportExportXmlInternal(ExternalDatasetDataEntity data, ExternalDatasetDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
xml.setType(data.getType());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.BaseFie
|
|||
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;
|
||||
|
@ -26,5 +25,6 @@ public interface FieldDataHelperService {
|
|||
BaseFieldData buildOne(FieldSet fieldSet, BaseFieldDataEntity<?> data, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||
BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist);
|
||||
BaseFieldDataEntity<?> applyPersist(BaseFieldDataPersist persist, BaseFieldDataEntity<?> data);
|
||||
BaseFieldDataPersist importExportMapDataToPersist(BaseFieldDataImportExport data);
|
||||
BaseFieldDataPersist importExportMapDataToPersist(BaseFieldDataImportExport xml);
|
||||
BaseFieldDataImportExport dataToImportExportXml(BaseFieldDataEntity<?> data);
|
||||
}
|
||||
|
|
|
@ -91,4 +91,9 @@ public class FreeTextFieldDataHelperService extends BaseFieldDataHelperService<F
|
|||
protected FreeTextDataPersist importExportMapDataToPersistInternal(FreeTextDataImportExport data, FreeTextDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FreeTextDataImportExport dataToImportExportXmlInternal(FreeTextDataEntity data, FreeTextDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,4 +94,10 @@ public class JournalRepositoryFieldDataHelperService extends BaseFieldDataHelper
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JournalRepositoryDataImportExport dataToImportExportXmlInternal(JournalRepositoryDataEntity data, JournalRepositoryDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class LicenseFieldDataHelperService extends BaseFieldDataHelperService<Li
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LicenseDataImportExport dataToImportExportXmlInternal(LicenseDataEntity data, LicenseDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class OrganizationFieldDataHelperService extends BaseFieldDataHelperServi
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OrganizationDataImportExport dataToImportExportXmlInternal(OrganizationDataEntity data, OrganizationDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class PublicationFieldDataHelperService extends BaseFieldDataHelperServic
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PublicationDataImportExport dataToImportExportXmlInternal(PublicationDataEntity data, PublicationDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,4 +94,10 @@ public class PublicationRepositoryFieldDataHelperService extends BaseFieldDataHe
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PublicationRepositoryDataImportExport dataToImportExportXmlInternal(PublicationRepositoryDataEntity data, PublicationRepositoryDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ import eu.eudat.commons.enums.FieldType;
|
|||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.RadioBoxDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.RadioBoxDataImportExport;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.RadioBoxOption;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.UploadDataOption;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.WordListDataImportExport;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.RadioBoxDataBuilder;
|
||||
|
@ -126,4 +128,25 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
|||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RadioBoxDataImportExport dataToImportExportXmlInternal(RadioBoxDataEntity data, RadioBoxDataImportExport xml) {
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getOptions())){
|
||||
xml.setOptions(new ArrayList<>());
|
||||
for (RadioBoxDataEntity.Option radioBoxOption: data.getOptions()) {
|
||||
xml.getOptions().add(this.buildOption(radioBoxOption));
|
||||
}
|
||||
}
|
||||
return xml;
|
||||
}
|
||||
|
||||
private @NotNull RadioBoxOption buildOption(RadioBoxDataEntity.Option data){
|
||||
RadioBoxOption xml = new RadioBoxOption();
|
||||
if (data == null) return xml;
|
||||
|
||||
xml.setLabel(data.getLabel());
|
||||
xml.setValue(data.getValue());
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class RegistryFieldDataHelperService extends BaseFieldDataHelperService<R
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RegistryDataImportExport dataToImportExportXmlInternal(RegistryDataEntity data, RegistryDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class ResearcherAutoCompleteFieldDataHelperService extends BaseFieldDataH
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResearcherAutoCompleteDataImportExport dataToImportExportXmlInternal(ResearcherAutoCompleteDataEntity data, ResearcherAutoCompleteDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class ResearcherFieldDataHelperService extends BaseFieldDataHelperService
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResearcherDataImportExport dataToImportExportXmlInternal(ResearcherDataEntity data, ResearcherDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,4 +91,9 @@ public class RichTextAreaDataFieldDataHelperService extends BaseFieldDataHelperS
|
|||
protected RichTextAreaDataPersist importExportMapDataToPersistInternal(RichTextAreaDataImportExport data, RichTextAreaDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RichTextAreaDataImportExport dataToImportExportXmlInternal(RichTextAreaDataEntity data, RichTextAreaDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class ServiceFieldDataHelperService extends BaseFieldDataHelperService<Se
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServiceDataImportExport dataToImportExportXmlInternal(ServiceDataEntity data, ServiceDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,4 +91,9 @@ public class TagFieldDataHelperService extends BaseFieldDataHelperService<TagDat
|
|||
protected TagDataPersist importExportMapDataToPersistInternal(TagDataImportExport data, TagDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TagDataImportExport dataToImportExportXmlInternal(TagDataEntity data, TagDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class TaxonomyFieldDataHelperService extends BaseFieldDataHelperService<T
|
|||
persist.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaxonomyDataImportExport dataToImportExportXmlInternal(TaxonomyDataEntity data, TaxonomyDataImportExport xml) {
|
||||
xml.setMultiAutoComplete(data.getMultiAutoComplete());
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,4 +90,9 @@ public class TextAreaFieldDataHelperService extends BaseFieldDataHelperService<T
|
|||
protected TextAreaDataPersist importExportMapDataToPersistInternal(TextAreaDataImportExport data, TextAreaDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextAreaDataImportExport dataToImportExportXmlInternal(TextAreaDataEntity data, TextAreaDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,4 +125,25 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
|||
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UploadDataImportExport dataToImportExportXmlInternal(UploadDataEntity data, UploadDataImportExport xml) {
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getTypes())){
|
||||
xml.setTypes(new ArrayList<>());
|
||||
for (UploadDataEntity.Option option: data.getTypes()) {
|
||||
xml.getTypes().add(this.buildOption(option));
|
||||
}
|
||||
}
|
||||
return xml;
|
||||
}
|
||||
|
||||
private @NotNull UploadDataOption buildOption(UploadDataEntity.Option data){
|
||||
UploadDataOption xml = new UploadDataOption();
|
||||
if (data == null) return xml;
|
||||
|
||||
xml.setLabel(data.getLabel());
|
||||
xml.setValue(data.getValue());
|
||||
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,4 +90,9 @@ public class ValidationFieldDataHelperService extends BaseFieldDataHelperService
|
|||
protected ValidationDataPersist importExportMapDataToPersistInternal(ValidationDataImportExport data, ValidationDataPersist persist) {
|
||||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ValidationDataImportExport dataToImportExportXmlInternal(ValidationDataEntity data, ValidationDataImportExport xml) {
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,4 +131,27 @@ public class WordListFieldDataHelperService extends BaseFieldDataHelperService<W
|
|||
return persist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WordListDataImportExport dataToImportExportXmlInternal(WordListDataEntity data, WordListDataImportExport xml) {
|
||||
xml.setMultiList(data.getMultiList());
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getOptions())){
|
||||
xml.setOptions(new ArrayList<>());
|
||||
for (ComboBoxDataEntity.Option option: data.getOptions()) {
|
||||
xml.getOptions().add(this.buildOption(option));
|
||||
}
|
||||
}
|
||||
return xml;
|
||||
}
|
||||
private @NotNull ComboBoxDataOptionEntity buildOption(ComboBoxDataEntity.Option data){
|
||||
ComboBoxDataOptionEntity xml = new ComboBoxDataOptionEntity();
|
||||
if (data == null) return xml;
|
||||
|
||||
xml.setLabel(data.getLabel());
|
||||
xml.setValue(data.getValue());
|
||||
xml.setUri(data.getUri());
|
||||
xml.setSource(data.getSource());
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import jakarta.xml.bind.JAXBException;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
@ -168,6 +169,20 @@ public class DescriptionTemplateController {
|
|||
return persisted;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/xml/export/{id}"}, produces = "application/xml")
|
||||
public @ResponseBody ResponseEntity getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("export" + DescriptionTemplate.class.getSimpleName()).And("id", id));
|
||||
|
||||
ResponseEntity response = this.descriptionTemplateTypeService.exportXml(id);
|
||||
|
||||
this.auditService.track(AuditableAction.DescriptionTemplate_GetXml, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("id", id)
|
||||
));
|
||||
return response;
|
||||
}
|
||||
|
||||
@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));
|
||||
|
@ -176,7 +191,7 @@ public class DescriptionTemplateController {
|
|||
|
||||
DescriptionTemplate model = this.descriptionTemplateTypeService.importXml(file.getBytes(), id, file.getOriginalFilename(), fieldSet);
|
||||
|
||||
this.auditService.track(AuditableAction.DmpBlueprint_Clone, Map.ofEntries(
|
||||
this.auditService.track(AuditableAction.DescriptionTemplate_Import, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("file", file),
|
||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||
|
|
|
@ -160,7 +160,7 @@ public class DmpBlueprintController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/xml/export/{id}"}, produces = "application/xml")
|
||||
public @ResponseBody ResponseEntity getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, TransformerException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("id", id));
|
||||
logger.debug(new MapLogEntry("export" + DmpBlueprint.class.getSimpleName()).And("id", id));
|
||||
|
||||
ResponseEntity response = this.dmpBlueprintService.exportXml(id);
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class DmpBlueprintController {
|
|||
|
||||
DmpBlueprint model = this.dmpBlueprintService.importXml(file.getBytes(), file.getOriginalFilename(), fieldSet);
|
||||
|
||||
this.auditService.track(AuditableAction.DmpBlueprint_Clone, Map.ofEntries(
|
||||
this.auditService.track(AuditableAction.DmpBlueprint_Import, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("file", file),
|
||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||
));
|
||||
|
|
|
@ -155,6 +155,14 @@ permissions:
|
|||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
ExportDescriptionTemplate:
|
||||
roles:
|
||||
- Admin
|
||||
- DatasetProfileManager
|
||||
claims: [ ]
|
||||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
# Dmp
|
||||
BrowseDmp:
|
||||
roles:
|
||||
|
|
Loading…
Reference in New Issue