update description properties json format
This commit is contained in:
parent
1fc4e8add5
commit
46c19f61a1
|
@ -1,17 +1,8 @@
|
||||||
package eu.eudat.commons.types.description;
|
package eu.eudat.commons.types.description;
|
||||||
|
|
||||||
public class FieldEntity {
|
public class FieldEntity {
|
||||||
private String key;
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(String key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
package eu.eudat.commons.types.description;
|
package eu.eudat.commons.types.description;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PropertyDefinitionEntity {
|
public class PropertyDefinitionEntity {
|
||||||
private List<FieldEntity> fields;
|
private Map<String, PropertyDefinitionFieldSetEntity> fieldSets;
|
||||||
|
|
||||||
public List<FieldEntity> getFields() {
|
public Map<String, PropertyDefinitionFieldSetEntity> getFieldSets() {
|
||||||
return fields;
|
return fieldSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFields(List<FieldEntity> fields) {
|
public void setFieldSets(Map<String, PropertyDefinitionFieldSetEntity> fieldSets) {
|
||||||
this.fields = fields;
|
this.fieldSets = fieldSets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package eu.eudat.commons.types.description;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PropertyDefinitionFieldSetEntity {
|
||||||
|
private List<PropertyDefinitionFieldSetItemEntity> items;
|
||||||
|
|
||||||
|
public List<PropertyDefinitionFieldSetItemEntity> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<PropertyDefinitionFieldSetItemEntity> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package eu.eudat.commons.types.description;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PropertyDefinitionFieldSetItemEntity {
|
||||||
|
private Map<String, FieldEntity> fields;
|
||||||
|
private String comment;
|
||||||
|
private int ordinal;
|
||||||
|
|
||||||
|
public Map<String, FieldEntity> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(Map<String, FieldEntity> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComment(String comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,15 @@ public class DefinitionEntity {
|
||||||
return fieldEntities;
|
return fieldEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FieldSetEntity> getAllFieldSets(){
|
||||||
|
List<FieldSetEntity> fieldSetsEntities = new ArrayList<>();
|
||||||
|
if (this.getPages() != null){
|
||||||
|
for (PageEntity sectionEntity: this.getPages()) {
|
||||||
|
fieldSetsEntities.addAll(sectionEntity.getAllFieldSets());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fieldSetsEntities;
|
||||||
|
}
|
||||||
public List<FieldEntity> getFieldById(String id) {
|
public List<FieldEntity> getFieldById(String id) {
|
||||||
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
|
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,4 +62,14 @@ public class PageEntity implements DatabaseViewStyleDefinition {
|
||||||
}
|
}
|
||||||
return fieldEntities;
|
return fieldEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FieldSetEntity> getAllFieldSets(){
|
||||||
|
List<FieldSetEntity> fieldSetsEntities = new ArrayList<>();
|
||||||
|
if (this.getSections() != null){
|
||||||
|
for (SectionEntity sectionEntity: this.getSections()) {
|
||||||
|
fieldSetsEntities.addAll(sectionEntity.getAllFieldSets());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fieldSetsEntities;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,4 +126,17 @@ public class SectionEntity implements DatabaseViewStyleDefinition{
|
||||||
}
|
}
|
||||||
return fieldEntities;
|
return fieldEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FieldSetEntity> getAllFieldSets(){
|
||||||
|
List<FieldSetEntity> fieldSetEntities = new ArrayList<>();
|
||||||
|
if (this.getFieldSets() != null){
|
||||||
|
fieldSetEntities.addAll(this.getFieldSets());
|
||||||
|
}
|
||||||
|
if (this.getSections() != null){
|
||||||
|
for (SectionEntity sectionEntity: this.getSections()) {
|
||||||
|
fieldSetEntities.addAll(sectionEntity.getAllFieldSets());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fieldSetEntities;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,9 @@ public class DescriptionDepositBuilder extends BaseDepositBuilder<DescriptionDep
|
||||||
m.setLabel(d.getLabel());
|
m.setLabel(d.getLabel());
|
||||||
m.setDescription(d.getDescription());
|
m.setDescription(d.getDescription());
|
||||||
if (d.getProperties() != null){
|
if (d.getProperties() != null){
|
||||||
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
//TODO Update with the new logic of property definition
|
||||||
if (definitionMap != null && definitionMap.containsKey(d.getDescriptionTemplateId()) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setFields(this.builderFactory.builder(DescriptionFieldDepositBuilder.class).authorize(this.authorize).setDefinition(definitionMap.get(d.getDescriptionTemplateId())).build(propertyDefinition.getFields()));
|
// PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
||||||
|
// if (definitionMap != null && definitionMap.containsKey(d.getDescriptionTemplateId()) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setFields(this.builderFactory.builder(DescriptionFieldDepositBuilder.class).authorize(this.authorize).setDefinition(definitionMap.get(d.getDescriptionTemplateId())).build(propertyDefinition.getFields()));
|
||||||
}
|
}
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
models.add(new DepositBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,10 @@ public class DescriptionFieldDepositBuilder extends BaseDepositBuilder<Descripti
|
||||||
for (FieldEntity d : data) {
|
for (FieldEntity d : data) {
|
||||||
DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
|
DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
|
||||||
if (definition != null){
|
if (definition != null){
|
||||||
List<eu.eudat.commons.types.descriptiontemplate.FieldEntity> fieldEntities = definition.getFieldById(d.getKey());
|
|
||||||
|
//TODO Update with the new logic of property definition
|
||||||
|
//List<eu.eudat.commons.types.descriptiontemplate.FieldEntity> fieldEntities = definition.getFieldById(d.getKey());
|
||||||
|
List<eu.eudat.commons.types.descriptiontemplate.FieldEntity> fieldEntities = new ArrayList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(fieldEntities)){
|
if (!this.conventionService.isListNullOrEmpty(fieldEntities)){
|
||||||
eu.eudat.commons.types.descriptiontemplate.FieldEntity field = fieldEntities.getFirst();
|
eu.eudat.commons.types.descriptiontemplate.FieldEntity field = fieldEntities.getFirst();
|
||||||
m.setSchematics(field.getSchematics());
|
m.setSchematics(field.getSchematics());
|
||||||
|
|
|
@ -19,20 +19,16 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component("descriptionpropertiesdefinitionFieldbuilder")
|
@Component("description.FieldBuilder")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
|
||||||
private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public FieldBuilder(
|
public FieldBuilder(
|
||||||
ConventionService conventionService, BuilderFactory builderFactory, FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
ConventionService conventionService, BuilderFactory builderFactory, FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldBuilder.class)));
|
||||||
this.builderFactory = builderFactory;
|
|
||||||
this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public FieldBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
@ -51,7 +47,6 @@ public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
||||||
List<Field> models = new ArrayList<>();
|
List<Field> models = new ArrayList<>();
|
||||||
for (FieldEntity d : data) {
|
for (FieldEntity d : data) {
|
||||||
Field m = new Field();
|
Field m = new Field();
|
||||||
if (fields.hasField(this.asIndexer(Field._key))) m.setKey(d.getKey());
|
|
||||||
if (fields.hasField(this.asIndexer(Field._value))) m.setValue(d.getValue());
|
if (fields.hasField(this.asIndexer(Field._value))) m.setValue(d.getValue());
|
||||||
|
|
||||||
models.add(m);
|
models.add(m);
|
||||||
|
|
|
@ -47,12 +47,17 @@ public class PropertyDefinitionBuilder extends BaseBuilder<PropertyDefinition, P
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
//Not Bulk Build because is XML no interaction with db
|
//Not Bulk Build because is XML no interaction with db
|
||||||
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(PropertyDefinition._fields));
|
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(PropertyDefinition._fieldSets));
|
||||||
|
|
||||||
List<PropertyDefinition> models = new ArrayList<>();
|
List<PropertyDefinition> models = new ArrayList<>();
|
||||||
for (PropertyDefinitionEntity d : data) {
|
for (PropertyDefinitionEntity d : data) {
|
||||||
PropertyDefinition m = new PropertyDefinition();
|
PropertyDefinition m = new PropertyDefinition();
|
||||||
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
|
if (!fieldsFields.isEmpty() && d.getFieldSets() != null && !d.getFieldSets().isEmpty()) {
|
||||||
|
m.setFieldSets(new HashMap<>());
|
||||||
|
for (String key : d.getFieldSets().keySet()){
|
||||||
|
m.getFieldSets().put(key, this.builderFactory.builder(PropertyDefinitionFieldSetBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFieldSets().get(key)));
|
||||||
|
}
|
||||||
|
}
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package eu.eudat.model.builder.descriptionpropertiesdefinition;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionFieldSetEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component("description.PropertyDefinitionFieldSet")
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionFieldSetBuilder extends BaseBuilder<PropertyDefinitionFieldSet, PropertyDefinitionFieldSetEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public PropertyDefinitionFieldSetBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(PropertyDefinitionFieldSetBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyDefinitionFieldSetBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PropertyDefinitionFieldSet> build(FieldSet fields, List<PropertyDefinitionFieldSetEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
//Not Bulk Build because is XML no interaction with db
|
||||||
|
FieldSet itemsFields = fields.extractPrefixed(this.asPrefix(PropertyDefinitionFieldSet._items));
|
||||||
|
|
||||||
|
List<PropertyDefinitionFieldSet> models = new ArrayList<>();
|
||||||
|
for (PropertyDefinitionFieldSetEntity d : data) {
|
||||||
|
PropertyDefinitionFieldSet m = new PropertyDefinitionFieldSet();
|
||||||
|
if (!itemsFields.isEmpty() && d.getItems() != null) m.setItems(this.builderFactory.builder(PropertyDefinitionFieldSetItemBuilder.class).authorize(this.authorize).build(itemsFields, d.getItems()));
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package eu.eudat.model.builder.descriptionpropertiesdefinition;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionFieldSetItemEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.DescriptionTemplate;
|
||||||
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinition;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component("description.PropertyDefinitionFieldSetItemBuilder")
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionFieldSetItemBuilder extends BaseBuilder<PropertyDefinitionFieldSetItem, PropertyDefinitionFieldSetItemEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public PropertyDefinitionFieldSetItemBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(PropertyDefinitionFieldSetItemBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyDefinitionFieldSetItemBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PropertyDefinitionFieldSetItem> build(FieldSet fields, List<PropertyDefinitionFieldSetItemEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
//Not Bulk Build because is XML no interaction with db
|
||||||
|
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(PropertyDefinitionFieldSetItem._fields));
|
||||||
|
|
||||||
|
List<PropertyDefinitionFieldSetItem> models = new ArrayList<>();
|
||||||
|
for (PropertyDefinitionFieldSetItemEntity d : data) {
|
||||||
|
PropertyDefinitionFieldSetItem m = new PropertyDefinitionFieldSetItem();
|
||||||
|
if (fields.hasField(this.asIndexer(PropertyDefinitionFieldSetItem._comment))) m.setComment(d.getComment());
|
||||||
|
if (fields.hasField(this.asIndexer(PropertyDefinitionFieldSetItem._ordinal))) m.setOrdinal(d.getOrdinal());
|
||||||
|
if (!fieldsFields.isEmpty() && d.getFields() != null && !d.getFields().isEmpty()) {
|
||||||
|
m.setFields(new HashMap<>());
|
||||||
|
for (String key : d.getFields().keySet()){
|
||||||
|
m.getFields().put(key, this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields().get(key)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -58,7 +58,9 @@ public class DescriptionFieldFileTransformerBuilder extends BaseFileTransformerB
|
||||||
for (FieldEntity d : data) {
|
for (FieldEntity d : data) {
|
||||||
// DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
|
// DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
|
||||||
if (definition != null){
|
if (definition != null){
|
||||||
FieldFileTransformerModel fieldEntity = findFieldById(d.getKey());
|
//TODO Update with the new logic of property definition
|
||||||
|
// FieldFileTransformerModel fieldEntity = findFieldById(d.getKey());
|
||||||
|
FieldFileTransformerModel fieldEntity = new FieldFileTransformerModel();
|
||||||
if (fieldEntity != null){
|
if (fieldEntity != null){
|
||||||
//m.setSchematics(fieldEntity.getSchematics());
|
//m.setSchematics(fieldEntity.getSchematics());
|
||||||
if (fieldEntity.getData() != null) {
|
if (fieldEntity.getData() != null) {
|
||||||
|
|
|
@ -93,7 +93,8 @@ public class DescriptionFileTransformerBuilder extends BaseFileTransformerBuilde
|
||||||
if (d.getProperties() != null){
|
if (d.getProperties() != null){
|
||||||
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
||||||
|
|
||||||
if (definitionMap != null && definitionMap.stream().anyMatch(dt -> dt.getId().equals(d.getDescriptionTemplateId())) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setDescriptionTemplate(this.builderFactory.builder(DescriptionFieldFileTransformerBuilder.class).authorize(this.authorize).setDefinition(definitionMap.stream().filter(dm -> dm.getId().equals(d.getDescriptionTemplateId())).findFirst().get()).build(propertyDefinition.getFields()).get(0));
|
//TODO Update with the new logic of property definition
|
||||||
|
// if (definitionMap != null && definitionMap.stream().anyMatch(dt -> dt.getId().equals(d.getDescriptionTemplateId())) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setDescriptionTemplate(this.builderFactory.builder(DescriptionFieldFileTransformerBuilder.class).authorize(this.authorize).setDefinition(definitionMap.stream().filter(dm -> dm.getId().equals(d.getDescriptionTemplateId())).findFirst().get()).build(propertyDefinition.getFields()).get(0));
|
||||||
}
|
}
|
||||||
if (referenceMap != null && !referenceMap.isEmpty() && referenceMap.containsKey(d.getId())) m.setDescriptionReferenceFileTransformerModels(referenceMap.get(d.getId()));
|
if (referenceMap != null && !referenceMap.isEmpty() && referenceMap.containsKey(d.getId())) m.setDescriptionReferenceFileTransformerModels(referenceMap.get(d.getId()));
|
||||||
if (tagMap != null && !tagMap.isEmpty() && tagMap.containsKey(d.getId())) m.setDescriptionTagFileTransformerModels(tagMap.get(d.getId()));
|
if (tagMap != null && !tagMap.isEmpty() && tagMap.containsKey(d.getId())) m.setDescriptionTagFileTransformerModels(tagMap.get(d.getId()));
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Component("descriptionpropertiesfieldcensor")
|
@Component("description.FieldCensor")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class FieldCensor extends BaseCensor {
|
public class FieldCensor extends BaseCensor {
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Component("descriptionpropertiescensor")
|
@Component("description.PropertyDefinitionCensor")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PropertyDefinitionCensor extends BaseCensor {
|
public class PropertyDefinitionCensor extends BaseCensor {
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ public class PropertyDefinitionCensor extends BaseCensor {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDescription);
|
this.authService.authorizeForce(Permission.BrowseDescription);
|
||||||
FieldSet fieldFields = fields.extractPrefixed(this.asIndexerPrefix(PropertyDefinition._fields));
|
FieldSet fieldSetFields = fields.extractPrefixed(this.asIndexerPrefix(PropertyDefinition._fieldSets));
|
||||||
this.censorFactory.censor(FieldCensor.class).censor(fieldFields, userId);
|
this.censorFactory.censor(PropertyDefinitionFieldSetCensor.class).censor(fieldSetFields, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.eudat.model.censorship.descriptionproperties;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.censorship.BaseCensor;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinition;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component("description.PropertyDefinitionFieldSetCensor")
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionFieldSetCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PropertyDefinitionFieldSetCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
public PropertyDefinitionFieldSetCensor(ConventionService conventionService,
|
||||||
|
AuthorizationService authService,
|
||||||
|
CensorFactory censorFactory) {
|
||||||
|
super(conventionService);
|
||||||
|
this.authService = authService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
|
if (fields == null || fields.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.authService.authorizeForce(Permission.BrowseDescription);
|
||||||
|
FieldSet itemsFields = fields.extractPrefixed(this.asIndexerPrefix(PropertyDefinitionFieldSet._items));
|
||||||
|
this.censorFactory.censor(PropertyDefinitionFieldSetItemCensor.class).censor(itemsFields, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.eudat.model.censorship.descriptionproperties;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.censorship.BaseCensor;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinition;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component("description.PropertyDefinitionFieldSetItemCensor")
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionFieldSetItemCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PropertyDefinitionFieldSetItemCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
public PropertyDefinitionFieldSetItemCensor(ConventionService conventionService,
|
||||||
|
AuthorizationService authService,
|
||||||
|
CensorFactory censorFactory) {
|
||||||
|
super(conventionService);
|
||||||
|
this.authService = authService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
|
if (fields == null || fields.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.authService.authorizeForce(Permission.BrowseDescription);
|
||||||
|
FieldSet fieldFields = fields.extractPrefixed(this.asIndexerPrefix(PropertyDefinitionFieldSetItem._fields));
|
||||||
|
this.censorFactory.censor(FieldCensor.class).censor(fieldFields, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,20 +3,10 @@ package eu.eudat.model.descriptionproperties;
|
||||||
|
|
||||||
public class Field {
|
public class Field {
|
||||||
|
|
||||||
public final static String _key = "key";
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
public final static String _value = "value";
|
public final static String _value = "value";
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(String key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
package eu.eudat.model.descriptionproperties;
|
package eu.eudat.model.descriptionproperties;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class PropertyDefinition {
|
public class PropertyDefinition {
|
||||||
|
|
||||||
public final static String _fields = "fields";
|
public final static String _fieldSets = "fieldSets";
|
||||||
private List<Field> fields;
|
|
||||||
|
|
||||||
public List<Field> getFields() {
|
private Map<String, PropertyDefinitionFieldSet> fieldSets;
|
||||||
return fields;
|
|
||||||
|
public Map<String, PropertyDefinitionFieldSet> getFieldSets() {
|
||||||
|
return fieldSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFields(List<Field> fields) {
|
public void setFieldSets(Map<String, PropertyDefinitionFieldSet> fieldSets) {
|
||||||
this.fields = fields;
|
this.fieldSets = fieldSets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.eudat.model.descriptionproperties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PropertyDefinitionFieldSet {
|
||||||
|
|
||||||
|
public final static String _items = "items";
|
||||||
|
private List<PropertyDefinitionFieldSetItem> items;
|
||||||
|
|
||||||
|
public List<PropertyDefinitionFieldSetItem> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<PropertyDefinitionFieldSetItem> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package eu.eudat.model.descriptionproperties;
|
||||||
|
|
||||||
|
import eu.eudat.commons.types.description.FieldEntity;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PropertyDefinitionFieldSetItem {
|
||||||
|
|
||||||
|
public final static String _fields = "fields";
|
||||||
|
private Map<String, Field> fields;
|
||||||
|
|
||||||
|
public final static String _comment = "comment";
|
||||||
|
private String comment;
|
||||||
|
|
||||||
|
public final static String _ordinal = "ordinal";
|
||||||
|
private Integer ordinal;
|
||||||
|
|
||||||
|
public Map<String, Field> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(Map<String, Field> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComment(String comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(Integer ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,22 +13,10 @@ import java.util.List;
|
||||||
|
|
||||||
public class FieldPersist {
|
public class FieldPersist {
|
||||||
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
public static final String _key = "key";
|
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public static final String _value = "value";
|
public static final String _value = "value";
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(String key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -37,14 +25,14 @@ public class FieldPersist {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(FieldPersistValidator.ValidatorName)
|
@Component(PersistValidator.ValidatorName)
|
||||||
public static class FieldPersistValidator extends BaseValidator<FieldPersist> {
|
public static class PersistValidator extends BaseValidator<FieldPersist> {
|
||||||
|
|
||||||
public static final String ValidatorName = "Description.FieldPersistValidator";
|
public static final String ValidatorName = "Description.FieldPersistValidator";
|
||||||
|
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
protected FieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
||||||
super(conventionService, errors);
|
super(conventionService, errors);
|
||||||
this.messageSource = messageSource;
|
this.messageSource = messageSource;
|
||||||
}
|
}
|
||||||
|
@ -57,9 +45,6 @@ public class FieldPersist {
|
||||||
@Override
|
@Override
|
||||||
protected List<Specification> specifications(FieldPersist item) {
|
protected List<Specification> specifications(FieldPersist item) {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
this.spec()
|
|
||||||
.must(() -> !this.isEmpty(item.getKey()))
|
|
||||||
.failOn(FieldPersist._key).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._key}, LocaleContextHolder.getLocale())),
|
|
||||||
this.spec()
|
this.spec()
|
||||||
.must(() -> !this.isEmpty(item.getValue()))
|
.must(() -> !this.isEmpty(item.getValue()))
|
||||||
.failOn(FieldPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._value}, LocaleContextHolder.getLocale()))
|
.failOn(FieldPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._value}, LocaleContextHolder.getLocale()))
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
package eu.eudat.model.persist.descriptionproperties;
|
||||||
|
|
||||||
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
|
import eu.eudat.model.persist.DescriptionPersist;
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PropertyDefinitionFieldSetItemPersist {
|
||||||
|
|
||||||
|
public final static String _fields = "fields";
|
||||||
|
private Map<String, FieldPersist> fields;
|
||||||
|
|
||||||
|
public final static String _comment = "comment";
|
||||||
|
private String comment;
|
||||||
|
|
||||||
|
public final static String _ordinal = "ordinal";
|
||||||
|
private Integer ordinal = null;
|
||||||
|
|
||||||
|
public Map<String, FieldPersist> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(Map<String, FieldPersist> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComment(String comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(Integer ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component(PersistValidator.ValidatorName)
|
||||||
|
public static class PersistValidator extends BaseValidator<PropertyDefinitionFieldSetItemPersist> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "Description.PropertyDefinitionFieldSetItemPersistValidator";
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<PropertyDefinitionFieldSetItemPersist> modelClass() {
|
||||||
|
return PropertyDefinitionFieldSetItemPersist.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(PropertyDefinitionFieldSetItemPersist item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.spec()
|
||||||
|
.must(() -> !this.isNull(item.getOrdinal()))
|
||||||
|
.failOn(PropertyDefinitionFieldSetItemPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{PropertyDefinitionFieldSetItemPersist._ordinal}, LocaleContextHolder.getLocale())),
|
||||||
|
this.mapSpec()
|
||||||
|
.iff(() -> !this.isNull(item.getFields()))
|
||||||
|
.on(PropertyDefinitionFieldSetItemPersist._fields)
|
||||||
|
.over(item.getFields())
|
||||||
|
.mapKey((k) -> ((String)k))
|
||||||
|
.using((itm) -> this.validatorFactory.validator(FieldPersist.PersistValidator.class))
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package eu.eudat.model.persist.descriptionproperties;
|
||||||
|
|
||||||
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PropertyDefinitionFieldSetPersist {
|
||||||
|
|
||||||
|
public final static String _items = "items";
|
||||||
|
private List<PropertyDefinitionFieldSetItemPersist> items;
|
||||||
|
|
||||||
|
public List<PropertyDefinitionFieldSetItemPersist> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<PropertyDefinitionFieldSetItemPersist> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component(PersistValidator.ValidatorName)
|
||||||
|
public static class PersistValidator extends BaseValidator<PropertyDefinitionFieldSetPersist> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "Description.PropertyDefinitionFieldSetPersistValidator";
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<PropertyDefinitionFieldSetPersist> modelClass() {
|
||||||
|
return PropertyDefinitionFieldSetPersist.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(PropertyDefinitionFieldSetPersist item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.refSpec()
|
||||||
|
.iff(() -> !this.isNull(item.getItems()))
|
||||||
|
.on(PropertyDefinitionFieldSetPersist._items)
|
||||||
|
.over(item.getItems())
|
||||||
|
.using(() -> this.validatorFactory.validator(PropertyDefinitionFieldSetItemPersist.PersistValidator.class))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,20 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class PropertyDefinitionPersist {
|
public class PropertyDefinitionPersist {
|
||||||
|
|
||||||
private List<FieldPersist> fields;
|
public final static String _fieldSets = "fieldSets";
|
||||||
|
|
||||||
public static final String _fields = "fields";
|
private Map<String, PropertyDefinitionFieldSetPersist> fieldSets;
|
||||||
|
|
||||||
public List<FieldPersist> getFields() {
|
public Map<String, PropertyDefinitionFieldSetPersist> getFieldSets() {
|
||||||
return fields;
|
return fieldSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFields(List<FieldPersist> fields) {
|
public void setFieldSets(Map<String, PropertyDefinitionFieldSetPersist> fieldSets) {
|
||||||
this.fields = fields;
|
this.fieldSets = fieldSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(PropertyDefinitionPersistValidator.ValidatorName)
|
@Component(PropertyDefinitionPersistValidator.ValidatorName)
|
||||||
|
@ -58,13 +59,15 @@ public class PropertyDefinitionPersist {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> this.status == DescriptionStatus.Finalized)
|
.iff(() -> this.status == DescriptionStatus.Finalized)
|
||||||
.must(() -> !this.isListNullOrEmpty(item.getFields()))
|
.must(() -> !this.isNull(item.getFieldSets()) && !item.getFieldSets().isEmpty())
|
||||||
.failOn(PropertyDefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{PropertyDefinitionPersist._fields}, LocaleContextHolder.getLocale())),
|
.failOn(PropertyDefinitionPersist._fieldSets).failWith(messageSource.getMessage("Validation_Required", new Object[]{PropertyDefinitionPersist._fieldSets}, LocaleContextHolder.getLocale())),
|
||||||
this.navSpec()
|
|
||||||
.iff(() -> !this.isListNullOrEmpty(item.getFields()))
|
this.mapSpec()
|
||||||
.on(PropertyDefinitionPersist._fields)
|
.iff(() -> !this.isNull(item.getFieldSets()))
|
||||||
.over(item.getFields())
|
.on(PropertyDefinitionPersist._fieldSets)
|
||||||
.using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))
|
.over(item.getFieldSets())
|
||||||
|
.mapKey((k) -> ((String)k))
|
||||||
|
.using((itm) -> this.validatorFactory.validator(PropertyDefinitionFieldSetPersist.PersistValidator.class))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import eu.eudat.commons.enums.notification.NotificationContactType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.types.description.FieldEntity;
|
import eu.eudat.commons.types.description.FieldEntity;
|
||||||
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionFieldSetEntity;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionFieldSetItemEntity;
|
||||||
import eu.eudat.commons.types.notification.*;
|
import eu.eudat.commons.types.notification.*;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
import eu.eudat.configurations.notification.NotificationProperties;
|
import eu.eudat.configurations.notification.NotificationProperties;
|
||||||
|
@ -33,6 +35,8 @@ import eu.eudat.model.persist.DescriptionReferencePersist;
|
||||||
import eu.eudat.model.persist.DescriptionStatusPersist;
|
import eu.eudat.model.persist.DescriptionStatusPersist;
|
||||||
import eu.eudat.model.persist.ReferencePersist;
|
import eu.eudat.model.persist.ReferencePersist;
|
||||||
import eu.eudat.model.persist.descriptionproperties.FieldPersist;
|
import eu.eudat.model.persist.descriptionproperties.FieldPersist;
|
||||||
|
import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionFieldSetItemPersist;
|
||||||
|
import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionFieldSetPersist;
|
||||||
import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist;
|
import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist;
|
||||||
import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
|
import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
|
||||||
import eu.eudat.query.*;
|
import eu.eudat.query.*;
|
||||||
|
@ -356,10 +360,34 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
private @NotNull PropertyDefinitionEntity buildPropertyDefinitionEntity(PropertyDefinitionPersist persist){
|
private @NotNull PropertyDefinitionEntity buildPropertyDefinitionEntity(PropertyDefinitionPersist persist){
|
||||||
PropertyDefinitionEntity data = new PropertyDefinitionEntity();
|
PropertyDefinitionEntity data = new PropertyDefinitionEntity();
|
||||||
if (persist == null) return data;
|
if (persist == null) return data;
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getFields())){
|
if (persist.getFieldSets() != null && !persist.getFieldSets().isEmpty()){
|
||||||
data.setFields(new ArrayList<>());
|
data.setFieldSets(new HashMap<>());
|
||||||
for (FieldPersist sectionPersist: persist.getFields()) {
|
for (String key: persist.getFieldSets().keySet()) {
|
||||||
data.getFields().add(this.buildFieldEntity(sectionPersist));
|
data.getFieldSets().put(key, this.buildPropertyDefinitionFieldSetEntity(persist.getFieldSets().get(key)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull PropertyDefinitionFieldSetEntity buildPropertyDefinitionFieldSetEntity(PropertyDefinitionFieldSetPersist persist){
|
||||||
|
PropertyDefinitionFieldSetEntity data = new PropertyDefinitionFieldSetEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getItems())){
|
||||||
|
data.setItems(new ArrayList<>());
|
||||||
|
for (PropertyDefinitionFieldSetItemPersist sectionPersist: persist.getItems()) {
|
||||||
|
data.getItems().add(this.buildPropertyDefinitionFieldSetItemEntity(sectionPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull PropertyDefinitionFieldSetItemEntity buildPropertyDefinitionFieldSetItemEntity(PropertyDefinitionFieldSetItemPersist persist){
|
||||||
|
PropertyDefinitionFieldSetItemEntity data = new PropertyDefinitionFieldSetItemEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
if (persist.getFields() != null && !persist.getFields().isEmpty()){
|
||||||
|
data.setFields(new HashMap<>());
|
||||||
|
for (String key: persist.getFields().keySet()) {
|
||||||
|
data.getFields().put(key, this.buildFieldEntity(persist.getFields().get(key)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -369,7 +397,6 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
FieldEntity data = new FieldEntity();
|
FieldEntity data = new FieldEntity();
|
||||||
if (persist == null) return data;
|
if (persist == null) return data;
|
||||||
|
|
||||||
data.setKey(persist.getKey());
|
|
||||||
data.setValue(persist.getValue());
|
data.setValue(persist.getValue());
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import eu.eudat.commons.JsonHandlingService;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.ExternalSelectDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.ExternalSelectDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.SelectDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.SelectDataEntity;
|
||||||
|
@ -20,6 +21,8 @@ import eu.eudat.model.builder.PrefillingBuilder;
|
||||||
import eu.eudat.model.builder.ReferenceBuilder;
|
import eu.eudat.model.builder.ReferenceBuilder;
|
||||||
import eu.eudat.model.descriptionproperties.Field;
|
import eu.eudat.model.descriptionproperties.Field;
|
||||||
import eu.eudat.model.descriptionproperties.PropertyDefinition;
|
import eu.eudat.model.descriptionproperties.PropertyDefinition;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
|
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
|
||||||
import eu.eudat.query.ReferenceQuery;
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
@ -219,15 +222,19 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
List<FieldEntity> issuedFieldEntities = definition.getAllField().stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.issued")).toList();
|
List<FieldEntity> issuedFieldEntities = definition.getAllField().stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.issued")).toList();
|
||||||
if(this.conventionService.isListNullOrEmpty(issuedFieldEntities)){
|
if(this.conventionService.isListNullOrEmpty(issuedFieldEntities)){
|
||||||
String issuedIdNode = issuedFieldEntities.getFirst().getId();
|
String issuedIdNode = issuedFieldEntities.getFirst().getId();
|
||||||
String issuedValue = description.getProperties().getFields().stream().filter(x-> x.getKey().equals(issuedIdNode)).map(Field::getValue).findFirst().orElse(null);//TODO
|
String issuedValue = description.getProperties().getFieldSets().values().stream().map(PropertyDefinitionFieldSet::getItems).flatMap(List::stream)
|
||||||
List<FieldEntity> licStartEntities = definition.getAllField().stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.distribution.license.start_date")).toList();
|
.filter(x-> x.getFields() != null && x.getFields().containsKey(issuedIdNode)).map(x-> x.getFields().get(issuedIdNode).getValue()).findFirst().orElse(null);//TODO
|
||||||
if(this.conventionService.isListNullOrEmpty(licStartEntities)) {
|
|
||||||
|
|
||||||
|
List<FieldSetEntity> licStartFieldSetsEntities = definition.getAllFieldSets().stream().filter(x-> x.getAllField() != null && x.getAllField().stream().anyMatch(y-> y.getSchematics() != null && y.getSchematics().contains("rda.dataset.distribution.license.start_date"))).toList();
|
||||||
|
for (FieldSetEntity licStartFieldSetEntity: licStartFieldSetsEntities) {
|
||||||
|
List<FieldEntity> licStartEntities = licStartFieldSetEntity.getAllField().stream().filter(x -> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.distribution.license.start_date")).toList();
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(licStartEntities)) {
|
||||||
|
this.ensureFieldSetEntity(description, licStartFieldSetEntity);
|
||||||
|
|
||||||
for (FieldEntity licStartDateNode : licStartEntities) {
|
for (FieldEntity licStartDateNode : licStartEntities) {
|
||||||
String licStartDateId = licStartDateNode.getId();
|
description.getProperties().getFieldSets().get(licStartFieldSetEntity.getId()).getItems().add(buildPropertyDefinitionFieldSetItemValue(licStartDateNode, issuedValue, parsedValues, type));
|
||||||
Field field = new Field();
|
}
|
||||||
field.setKey(licStartDateId);
|
|
||||||
field.setValue(issuedValue);
|
|
||||||
description.getProperties().getFields().add(field);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,15 +249,25 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FieldEntity> fieldEntities = definition.getAllField().stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains(prefillingMapping.getSemanticTarget())).toList();
|
List<FieldSetEntity> fieldSetsEntities = definition.getAllFieldSets().stream().filter(x-> x.getAllField() != null && x.getAllField().stream().anyMatch(y-> y.getSchematics() != null && y.getSchematics().contains(prefillingMapping.getSemanticTarget()))).toList();
|
||||||
for (FieldEntity fieldEntity: fieldEntities) {
|
for (FieldSetEntity fieldSetEntity: fieldSetsEntities) {
|
||||||
if (description.getProperties() == null) description.setProperties(new PropertyDefinition());
|
List<FieldEntity> fieldEntities = fieldSetEntity.getAllField().stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains(prefillingMapping.getSemanticTarget())).toList();
|
||||||
if (description.getProperties().getFields() == null) description.getProperties().setFields(new ArrayList<>());
|
if (!this.conventionService.isListNullOrEmpty(fieldEntities)) {
|
||||||
|
this.ensureFieldSetEntity(description, fieldSetEntity);
|
||||||
|
|
||||||
description.getProperties().getFields().add(buildFieldValue(fieldEntity, parsedValue, parsedValues, type));
|
for (FieldEntity fieldEntity : fieldEntities){
|
||||||
|
description.getProperties().getFieldSets().get(fieldSetEntity.getId()).getItems().add(buildPropertyDefinitionFieldSetItemValue(fieldEntity, parsedValue, parsedValues, type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ensureFieldSetEntity(Description description, FieldSetEntity fieldSetEntity){
|
||||||
|
if (description.getProperties() == null) description.setProperties(new PropertyDefinition());
|
||||||
|
if (description.getProperties().getFieldSets() == null) description.getProperties().setFieldSets(new HashMap<>());
|
||||||
|
if (!description.getProperties().getFieldSets().containsKey(fieldSetEntity.getId())) description.getProperties().getFieldSets().put(fieldSetEntity.getId(), new PropertyDefinitionFieldSet());
|
||||||
|
if (description.getProperties().getFieldSets().get(fieldSetEntity.getId()).getItems() == null) description.getProperties().getFieldSets().get(fieldSetEntity.getId()).setItems(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
private void applyValueToDescriptionObject(Description description, PrefillingMapping prefillingMapping, String parsedValue, List<String> parsedValues){
|
private void applyValueToDescriptionObject(Description description, PrefillingMapping prefillingMapping, String parsedValue, List<String> parsedValues){
|
||||||
switch (prefillingMapping.getTarget()){
|
switch (prefillingMapping.getTarget()){
|
||||||
|
@ -277,10 +294,11 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Field buildFieldValue(FieldEntity fieldEntity, String parsedValue, List<String> parsedValues, String type){
|
private PropertyDefinitionFieldSetItem buildPropertyDefinitionFieldSetItemValue(FieldEntity fieldEntity, String parsedValue, List<String> parsedValues, String type){
|
||||||
String id = fieldEntity.getId();
|
String id = fieldEntity.getId();
|
||||||
|
PropertyDefinitionFieldSetItem fieldSetItem = new PropertyDefinitionFieldSetItem();
|
||||||
|
fieldSetItem.setFields(new HashMap<>());
|
||||||
Field field = new Field();
|
Field field = new Field();
|
||||||
field.setKey(id);
|
|
||||||
switch (fieldEntity.getData().getFieldType()) {
|
switch (fieldEntity.getData().getFieldType()) {
|
||||||
case EXTERNAL_SELECT:
|
case EXTERNAL_SELECT:
|
||||||
case SELECT: {
|
case SELECT: {
|
||||||
|
@ -323,7 +341,8 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
field.setValue(parsedValue);
|
field.setValue(parsedValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return field;
|
fieldSetItem.getFields().put(fieldEntity.getId(), field);
|
||||||
|
return fieldSetItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getValueAsStringArray(PrefillingMapping prefillingMapping, Object value){
|
private List<String> getValueAsStringArray(PrefillingMapping prefillingMapping, Object value){
|
||||||
|
|
Loading…
Reference in New Issue