# Conflicts:
#	dmp-admin/src/app/services/rest-base.ts
This commit is contained in:
annampak 2017-12-01 16:15:36 +02:00
commit 0741504473
26 changed files with 725 additions and 29 deletions

View File

@ -0,0 +1,6 @@
import { FormGenerator } from '../interfaces/FormGenerator';
import { Serializable } from '../interfaces/Serializable';
import { FormGroup } from '@angular/forms'
export abstract class DataField<T> implements Serializable<T>,FormGenerator<FormGroup>{
}

View File

@ -13,8 +13,8 @@ import entities.DatasetProfileViewstyle;
import entities.xmlmodels.modeldefinition.FieldGroup; import entities.xmlmodels.modeldefinition.FieldGroup;
import entities.xmlmodels.viewstyledefinition.Section; import entities.xmlmodels.viewstyledefinition.Section;
import entities.xmlmodels.viewstyledefinition.ViewStyleModel; import entities.xmlmodels.viewstyledefinition.ViewStyleModel;
import models.components.datasetprofile.FieldSet; import models.admin.components.datasetprofile.FieldSet;
import models.composite.DatasetProfile; import models.admin.composite.DatasetProfile;
import utilities.builders.ModelBuilder; import utilities.builders.ModelBuilder;
import utilities.builders.XmlBuilder; import utilities.builders.XmlBuilder;
import utilities.helpers.ModelBuilderCollector; import utilities.helpers.ModelBuilderCollector;
@ -52,7 +52,7 @@ public class AdminManager {
return datasetProfileViewstyle; return datasetProfileViewstyle;
} }
public static models.composite.DatasetProfile generateDatasetProfileModel(entities.DatasetProfile profile){ public static models.admin.composite.DatasetProfile generateDatasetProfileModel(entities.DatasetProfile profile){
Document viewStyleDoc = XmlBuilder.fromXml(profile.getViewstyle().getDefinition()); Document viewStyleDoc = XmlBuilder.fromXml(profile.getViewstyle().getDefinition());
Element root = (Element)viewStyleDoc.getDocumentElement(); Element root = (Element)viewStyleDoc.getDocumentElement();
entities.xmlmodels.viewstyledefinition.ViewStyleModel viewstyle= new entities.xmlmodels.viewstyledefinition.ViewStyleModel().fromXml(root); entities.xmlmodels.viewstyledefinition.ViewStyleModel viewstyle= new entities.xmlmodels.viewstyledefinition.ViewStyleModel().fromXml(root);
@ -61,7 +61,7 @@ public class AdminManager {
root = (Element)profileDoc.getDocumentElement(); root = (Element)profileDoc.getDocumentElement();
entities.xmlmodels.modeldefinition.FieldGroup fieldGroup = new entities.xmlmodels.modeldefinition.FieldGroup().fromXml(root); entities.xmlmodels.modeldefinition.FieldGroup fieldGroup = new entities.xmlmodels.modeldefinition.FieldGroup().fromXml(root);
models.composite.DatasetProfile datasetprofile = new models.composite.DatasetProfile(); models.admin.composite.DatasetProfile datasetprofile = new models.admin.composite.DatasetProfile();
datasetprofile.buildProfile(fieldGroup, viewstyle); datasetprofile.buildProfile(fieldGroup, viewstyle);
return datasetprofile; return datasetprofile;

View File

@ -0,0 +1,23 @@
package managers;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import utilities.builders.XmlBuilder;
public class UserManager {
public static models.user.composite.DatasetProfile generateDatasetProfileModel(entities.DatasetProfile profile){
Document viewStyleDoc = XmlBuilder.fromXml(profile.getViewstyle().getDefinition());
Element root = (Element)viewStyleDoc.getDocumentElement();
entities.xmlmodels.viewstyledefinition.ViewStyleModel viewstyle= new entities.xmlmodels.viewstyledefinition.ViewStyleModel().fromXml(root);
Document profileDoc = XmlBuilder.fromXml(profile.getDefinition());
root = (Element)profileDoc.getDocumentElement();
entities.xmlmodels.modeldefinition.FieldGroup fieldGroup = new entities.xmlmodels.modeldefinition.FieldGroup().fromXml(root);
models.user.composite.DatasetProfile datasetprofile = new models.user.composite.DatasetProfile();
datasetprofile.buildProfile(fieldGroup, viewstyle);
return datasetprofile;
}
}

View File

@ -1,4 +1,4 @@
package models.components.datasetprofile; package models.admin.components.datasetprofile;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;

View File

@ -0,0 +1,85 @@
package models.admin.components.datasetprofile;
import java.util.LinkedList;
import java.util.List;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import models.components.commons.Multiplicity;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class FieldSet implements ModelDefinition<entities.xmlmodels.modeldefinition.FieldSet>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldSet>{
private String id;
private int ordinal;
private Multiplicity multiplicity;
private List<Field> fields;
public List<Field> getFields() {
return fields;
}
public void setFields(List<Field> fields) {
this.fields = fields;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public Multiplicity getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Multiplicity multiplicity) {
this.multiplicity = multiplicity;
}
@Override
public entities.xmlmodels.modeldefinition.FieldSet toDatabaseDefinition(entities.xmlmodels.modeldefinition.FieldSet fieldSet) {
fieldSet.setId(this.id);
fieldSet.setOrdinal(this.ordinal);
List<entities.xmlmodels.modeldefinition.Field> modelfields = new ModelBuilder().toModelDefinition(this.fields, entities.xmlmodels.modeldefinition.Field.class);
fieldSet.setFields(modelfields);
fieldSet.setMultiplicity(this.multiplicity);
return fieldSet;
}
@Override
public void fromDatabaseDefinition(entities.xmlmodels.modeldefinition.FieldSet item) {
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.multiplicity = item.getMultiplicity();
}
@Override
public entities.xmlmodels.viewstyledefinition.FieldSet toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.FieldSet item) {
List<entities.xmlmodels.viewstyledefinition.Field> viewStylefields = new ModelBuilder().toViewStyleDefinition(this.fields, entities.xmlmodels.viewstyledefinition.Field.class);
item.setFields(viewStylefields);
item.setId(this.id);
item.setOrdinal(this.ordinal);
return item;
}
@Override
public void fromDatabaseDefinition(entities.xmlmodels.viewstyledefinition.FieldSet item) {
this.fields = new ModelBuilder().fromViewStyleDefinition(item.getFields(), Field.class);
this.id = item.getId();
this.ordinal = item.getOrdinal();
}
}

View File

@ -0,0 +1,118 @@
package models.admin.components.datasetprofile;
import java.util.List;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import entities.xmlmodels.viewstyledefinition.FieldGroup;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Group implements ModelDefinition<entities.xmlmodels.modeldefinition.FieldGroup>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldGroup>{
private String id;
private String title;
private String section;
private String value;
private int ordinal;
private String description;
private String extendedDescription;
private boolean defaultVisibility;
private int page;
private List<FieldSet> compositeFields;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getExtendedDescription() {
return extendedDescription;
}
public void setExtendedDescription(String extendedDescription) {
this.extendedDescription = extendedDescription;
}
public boolean isDefaultVisibility() {
return defaultVisibility;
}
public void setDefaultVisibility(boolean defaultVisibility) {
this.defaultVisibility = defaultVisibility;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public List<FieldSet> getCompositeFields() {
return compositeFields;
}
public void setCompositeFields(List<FieldSet> compositeFields) {
this.compositeFields = compositeFields;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
@Override
public entities.xmlmodels.viewstyledefinition.FieldGroup toDatabaseDefinition(FieldGroup item) {
item.setDefaultVisibility(this.defaultVisibility);
item.setDescription(this.description);
item.setExtendedDescription(this.extendedDescription);
item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.compositeFields, entities.xmlmodels.viewstyledefinition.FieldSet.class));
item.setId(this.id);
item.setOrdinal(this.ordinal);
item.setPage(this.page);
item.setTitle(this.title);
return item;
}
@Override
public void fromDatabaseDefinition(FieldGroup item) {
this.defaultVisibility = item.isDefaultVisibility();
this.description = item.getDescription();
this.extendedDescription = item.getExtendedDescription();
this.compositeFields = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(), FieldSet.class);
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.page = item.getPage();
this.title = item.getTitle();
}
@Override
public entities.xmlmodels.modeldefinition.FieldGroup toDatabaseDefinition(entities.xmlmodels.modeldefinition.FieldGroup item) {
item.setFieldSets(new ModelBuilder().toModelDefinition(this.compositeFields, entities.xmlmodels.modeldefinition.FieldSet.class));
return item;
}
@Override
public void fromDatabaseDefinition(entities.xmlmodels.modeldefinition.FieldGroup item) {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,92 @@
package models.admin.components.datasetprofile;
import java.util.List;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>{
private List<Section> sections;
private List<Group> fieldGroups;
private Boolean defaultVisibility;
private int page;
private int ordinal;
private String id;
private String title;
private String description;
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
public List<Group> getFieldGroups() {
return fieldGroups;
}
public void setFieldGroups(List<Group> fieldGroups) {
this.fieldGroups = fieldGroups;
}
public Boolean getDefaultVisibility() {
return defaultVisibility;
}
public void setDefaultVisibility(Boolean defaultVisibility) {
this.defaultVisibility = defaultVisibility;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
@Override
public entities.xmlmodels.viewstyledefinition.Section toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.Section item) {
item.setDefaultVisibility(this.defaultVisibility);
item.setDescription(this.description);
if(this.fieldGroups!=null)item.setFieldGroups(new ModelBuilder().toViewStyleDefinition(this.fieldGroups, entities.xmlmodels.viewstyledefinition.FieldGroup.class));
item.setId(this.id);
item.setOrdinal(this.ordinal);
item.setPage(this.page);
if(this.sections!=null)item.setSections(new ModelBuilder().toViewStyleDefinition(this.sections, entities.xmlmodels.viewstyledefinition.Section.class));
item.setTitle(this.title);
return item;
}
@Override
public void fromDatabaseDefinition(entities.xmlmodels.viewstyledefinition.Section item) {
this.defaultVisibility = item.isDefaultVisibility();
this.description = item.getDescription();
this.fieldGroups = new ModelBuilder().fromViewStyleDefinition(item.getFieldGroups(),Group.class);
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.page = item.getPage();
this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(),Section.class);
this.title = item.getTitle();
}
}

View File

@ -1,11 +1,12 @@
package models.composite; package models.admin.composite;
import models.components.datasetprofile.*;
import utilities.builders.ModelBuilder; import utilities.builders.ModelBuilder;
import utilities.helpers.ModelBuilderCollector; import utilities.helpers.ModelBuilderCollector;
import java.util.List; import java.util.List;
import models.admin.components.datasetprofile.*;
public class DatasetProfile { public class DatasetProfile {
private List<Section> sections; private List<Section> sections;

View File

@ -3,9 +3,10 @@ package models.components.commons;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
import utilities.XmlSerializable; import utilities.XmlSerializable;
public class Rule implements XmlSerializable<Rule>{ public class Rule implements XmlSerializable<Rule>,DatabaseModelDefinition{
private String ruleType; private String ruleType;
private String target; private String target;
private String ruleStyle; private String ruleStyle;

View File

@ -0,0 +1,43 @@
package models.user.components.commons;
import utilities.ModelDefinition;
public class Rule {
private String sourceField;
private String targetField;
private String requiredValue;
private String type;
public String getSourceField() {
return sourceField;
}
public void setSourceField(String sourceField) {
this.sourceField = sourceField;
}
public String getTargetField() {
return targetField;
}
public void setTargetField(String targetField) {
this.targetField = targetField;
}
public String getRequiredValue() {
return requiredValue;
}
public void setRequiredValue(String requiredValue) {
this.requiredValue = requiredValue;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Rule fromDefinitionRule(models.components.commons.Rule rule){
this.targetField = rule.getTarget();
this.requiredValue = rule.getValue();
this.type = rule.getRuleStyle();
return this;
}
}

View File

@ -0,0 +1,155 @@
package models.user.components.datasetprofile;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import models.components.commons.DefaultValue;
import models.components.commons.Multiplicity;
import models.components.commons.ViewStyle;
import models.components.commons.Visibility;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition.Field>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Field>{
private String id;
private int ordinal;
private String title;
private String value;
private String description;
private String extendedDescription;
private ViewStyle viewStyle;
private String datatype;
private boolean defaultVisibility;
private int page;
private DefaultValue defaultValue;
private Multiplicity multiplicity;
private Object data;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal(){
return ordinal;
}
public void setOrdinal(int ordinal){
this.ordinal = ordinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getExtendedDescription() {
return extendedDescription;
}
public void setExtendedDescription(String extendedDescription) {
this.extendedDescription = extendedDescription;
}
public ViewStyle getViewStyle() {
return viewStyle;
}
public void setViewStyle(ViewStyle viewStyle) {
this.viewStyle = viewStyle;
}
public boolean isDefaultVisibility() {
return defaultVisibility;
}
public void setDefaultVisibility(boolean defaultVisibility) {
this.defaultVisibility = defaultVisibility;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public DefaultValue getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(DefaultValue defaultValue) {
this.defaultValue = defaultValue;
}
public String getDatatype() {
return datatype;
}
public void setDatatype(String datatype) {
this.datatype = datatype;
}
public Multiplicity getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Multiplicity multiplicity) {
this.multiplicity = multiplicity;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
@Override
public entities.xmlmodels.modeldefinition.Field toDatabaseDefinition(entities.xmlmodels.modeldefinition.Field field) {
field.setDatatype(this.datatype);
field.setDefaultValue(this.defaultValue);
field.setId(this.id);
field.setMultiplicity(this.multiplicity);
field.setOrdinal(this.ordinal);
return field;
}
@Override
public void fromDatabaseDefinition(entities.xmlmodels.modeldefinition.Field item) {
this.datatype = item.getDatatype();
this.defaultValue = item.getDefaultValue();
this.multiplicity = item.getMultiplicity();
}
@Override
public entities.xmlmodels.viewstyledefinition.Field toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.Field field) {
field.setDefaultVisibility(this.defaultVisibility);
field.setDescription(this.description);
field.setExtendedDescription(this.extendedDescription);
field.setId(this.id);
field.setOrdinal(this.ordinal);
field.setTitle(this.title);
field.setViewStyle(this.viewStyle);
field.setData(new ModelBuilder().toFieldData(data, this.viewStyle.getRenderStyle()));
return field;
}
@Override
public void fromDatabaseDefinition(entities.xmlmodels.viewstyledefinition.Field item) {
this.defaultVisibility = item.isDefaultVisibility();
this.description = item.getDescription();
this.extendedDescription = item.getExtendedDescription();
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.title = item.getTitle();
this.viewStyle = item.getViewStyle();
this.data = item.getData();
}
}

View File

@ -1,4 +1,4 @@
package models.components.datasetprofile; package models.user.components.datasetprofile;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package models.components.datasetprofile; package models.user.components.datasetprofile;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package models.components.datasetprofile; package models.user.components.datasetprofile;
import java.util.List; import java.util.List;

View File

@ -0,0 +1,42 @@
package models.user.composite;
import utilities.builders.ModelBuilder;
import utilities.helpers.ModelBuilderCollector;
import java.util.List;
import models.user.components.datasetprofile.*;
import models.user.components.commons.Rule;
public class DatasetProfile {
private List<Section> sections;
private List<Rule> rules;
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
public List<Rule> getRules() {
return rules;
}
public void setRules(List<Rule> rules) {
this.rules = rules;
}
public void buildProfile(entities.xmlmodels.modeldefinition.FieldGroup fieldGroup,entities.xmlmodels.viewstyledefinition.ViewStyleModel viewStyle){
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
updateProfile(fieldGroup,viewStyle);
}
private void updateProfile(entities.xmlmodels.modeldefinition.FieldGroup fieldGroup,entities.xmlmodels.viewstyledefinition.ViewStyleModel viewStyle){
ModelBuilderCollector.mapUserSections(sections, fieldGroup.getFieldSets());
this.rules = ModelBuilderCollector.collectRules(viewStyle.getSections());
}
}

View File

@ -30,8 +30,8 @@ import entities.DatasetProfileViewstyle;
import entities.xmlmodels.modeldefinition.FieldGroup; import entities.xmlmodels.modeldefinition.FieldGroup;
import entities.xmlmodels.viewstyledefinition.Section; import entities.xmlmodels.viewstyledefinition.Section;
import managers.AdminManager; import managers.AdminManager;
import models.components.datasetprofile.FieldSet; import models.admin.components.datasetprofile.FieldSet;
import models.composite.DatasetProfile; import models.admin.composite.DatasetProfile;
import utilities.builders.ModelBuilder; import utilities.builders.ModelBuilder;
import utilities.builders.XmlBuilder; import utilities.builders.XmlBuilder;
import utilities.helpers.ModelBuilderCollector; import utilities.helpers.ModelBuilderCollector;
@ -66,7 +66,7 @@ public class Admin {
public ResponseEntity<Object> get(@PathVariable String id){ public ResponseEntity<Object> get(@PathVariable String id){
try{ try{
entities.DatasetProfile profile = datasetProfileDao.read(UUID.fromString(id)); entities.DatasetProfile profile = datasetProfileDao.read(UUID.fromString(id));
models.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); models.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile); return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
}catch(Exception ex){ }catch(Exception ex){
ex.printStackTrace(); ex.printStackTrace();

View File

@ -0,0 +1,42 @@
package rest.entities;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import dao.entities.DatasetProfileDao;
import dao.entities.DatasetProfileRulesetDao;
import dao.entities.DatasetProfileViewstyleDao;
import helpers.SerializerProvider;
import managers.AdminManager;
import managers.UserManager;
@RestController
@CrossOrigin
public class DatasetProfileController {
@Autowired private DatasetProfileDao datasetProfileDao;
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofile/get/{id}" }, produces="application/json")
public ResponseEntity<Object> get(@PathVariable String id){
try {
entities.DatasetProfile profile = datasetProfileDao.read(UUID.fromString(id));
models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(profile);
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
}

View File

@ -70,4 +70,7 @@ public class ModelBuilder {
if(type.equals("freetext"))return null; if(type.equals("freetext"))return null;
return null; return null;
} }
} }

View File

@ -10,10 +10,11 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import models.components.datasetprofile.FieldSet; import models.admin.components.datasetprofile.FieldSet;
import models.components.datasetprofile.Group; import models.admin.components.datasetprofile.Group;
import models.components.datasetprofile.Section; import models.admin.components.datasetprofile.Section;
import models.composite.DatasetProfile; import models.admin.composite.DatasetProfile;
import models.user.components.commons.Rule;
public class ModelBuilderCollector { public class ModelBuilderCollector {
@ -36,7 +37,7 @@ public class ModelBuilderCollector {
return fieldGroups; return fieldGroups;
} }
public static void mapSections(List<models.components.datasetprofile.Section> sections,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){ public static void mapSections(List<models.admin.components.datasetprofile.Section> sections,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){
for(Section section: sections){ for(Section section: sections){
if(!section.getSections().isEmpty()){ if(!section.getSections().isEmpty()){
mapSections(section.getSections(),fieldGroups); mapSections(section.getSections(),fieldGroups);
@ -50,7 +51,7 @@ public class ModelBuilderCollector {
return; return;
} }
private static void mapCompositeFields(List<models.components.datasetprofile.FieldSet> fieldSets,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){ private static void mapCompositeFields(List<models.admin.components.datasetprofile.FieldSet> fieldSets,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){
for(FieldSet fieldSet: fieldSets){ for(FieldSet fieldSet: fieldSets){
if(!fieldSet.getFields().isEmpty()){ if(!fieldSet.getFields().isEmpty()){
mapFields(fieldSet.getFields(),fieldGroups); mapFields(fieldSet.getFields(),fieldGroups);
@ -64,9 +65,9 @@ public class ModelBuilderCollector {
return; return;
} }
private static void mapFields(List<models.components.datasetprofile.Field> fields,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){ private static void mapFields(List<models.admin.components.datasetprofile.Field> fields,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){
for(models.components.datasetprofile.Field fielditem: fields){ for(models.admin.components.datasetprofile.Field fielditem: fields){
for(entities.xmlmodels.modeldefinition.FieldSet fieldSet:fieldGroups){ for(entities.xmlmodels.modeldefinition.FieldSet fieldSet:fieldGroups){
for(entities.xmlmodels.modeldefinition.Field fieldmodelitem : fieldSet.getFields()){ for(entities.xmlmodels.modeldefinition.Field fieldmodelitem : fieldSet.getFields()){
if(fielditem.getId()!=null&&fielditem.getId().equals(fieldmodelitem.getId())){ if(fielditem.getId()!=null&&fielditem.getId().equals(fieldmodelitem.getId())){
@ -78,4 +79,76 @@ public class ModelBuilderCollector {
} }
return; return;
} }
public static void mapUserSections(List<models.user.components.datasetprofile.Section> sections,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){
for(models.user.components.datasetprofile.Section section: sections){
if(!section.getSections().isEmpty()){
mapUserSections(section.getSections(),fieldGroups);
}
for(models.user.components.datasetprofile.Group group: section.getFieldGroups()){
if(!group.getCompositeFields().isEmpty()){
mapUserCompositeFields(group.getCompositeFields(),fieldGroups);
}
}
}
return;
}
private static void mapUserCompositeFields(List<models.user.components.datasetprofile.FieldSet> fieldSets,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){
for(models.user.components.datasetprofile.FieldSet fieldSet: fieldSets){
if(!fieldSet.getFields().isEmpty()){
mapUserFields(fieldSet.getFields(),fieldGroups);
}
for(entities.xmlmodels.modeldefinition.FieldSet fieldModelSet :fieldGroups){
if(fieldSet.getId()!=null&&fieldSet.getId().equals(fieldModelSet.getId())){
fieldSet.fromDatabaseDefinition(fieldModelSet);
}
}
}
return;
}
private static void mapUserFields(List<models.user.components.datasetprofile.Field> fields,List<entities.xmlmodels.modeldefinition.FieldSet> fieldGroups){
for(models.user.components.datasetprofile.Field fielditem: fields){
for(entities.xmlmodels.modeldefinition.FieldSet fieldSet:fieldGroups){
for(entities.xmlmodels.modeldefinition.Field fieldmodelitem : fieldSet.getFields()){
if(fielditem.getId()!=null&&fielditem.getId().equals(fieldmodelitem.getId())){
fielditem.fromDatabaseDefinition(fieldmodelitem);
break;
}
}
}
}
return;
}
public static List<Rule> collectRules(List<entities.xmlmodels.viewstyledefinition.Section> sections){
List<Rule> rules = new LinkedList();
rules.addAll(
sections
.stream()
.map(section->section.getFieldGroups())
.flatMap(List::stream)
.map(group->group.getFieldSets())
.flatMap(List::stream)
.map(fieldset->fieldset.getFields())
.flatMap(List::stream)
.map(field->getRulesFromField(field.getId(),field.getVisible()
.getRules()))
.flatMap(List::stream)
.collect(Collectors.toList()));
return rules;
}
private static List<Rule> getRulesFromField(String id,List<models.components.commons.Rule> rules){
List<Rule> modelRules = new LinkedList();
for(models.components.commons.Rule rule : rules){
Rule modelRule = new Rule().fromDefinitionRule(rule);
modelRule.setSourceField(id);
modelRules.add(modelRule);
}
return modelRules;
}
} }

View File

@ -1,5 +1,6 @@
<div [formGroup]="textFormGroup"> <div [formGroup]="textFormGroup">
<label >{{field.title}}</label> <label>{{field.description}}</label>
<input auto-complete class="form-control autocomplete" formControlName="text" [source]="values" > <div>{{field.extendedDescription}}</div>
</div> <label>{{field.title}}</label>
<input auto-complete class="form-control autocomplete" formControlName="text" [source]="values">
</div>

View File

@ -1,4 +1,6 @@
<div [formGroup]="form"> <div [formGroup]="form">
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<input type="radio" formControlName="value" value="true">Yes<br> <input type="radio" formControlName="value" value="true">Yes<br>
<input type="radio" formControlName="value" value="false">No <input type="radio" formControlName="value" value="false">No
</div> </div>

View File

@ -1,5 +1,6 @@
<div [formGroup]="form" class="form-group" > <div [formGroup]="form" class="form-group" >
<label>{{field.title}}</label> <label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<input formControlName="value" type = "checkbox"> <input formControlName="value" type = "checkbox">
</div> </div>

View File

@ -1,4 +1,6 @@
<div [formGroup]="form"> <div [formGroup]="form">
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<select class="form-control" formControlName="value"> <select class="form-control" formControlName="value">
<option *ngFor="let opt of field.data.values" [value]="opt.value">{{opt.label}}</option> <option *ngFor="let opt of field.data.values" [value]="opt.value">{{opt.label}}</option>
</select> </select>

View File

@ -1,4 +1,6 @@
<div [formGroup]="form"> <div [formGroup]="form">
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<div *ngFor="let option of this.field.data.options"> <div *ngFor="let option of this.field.data.options">
<input type="radio" formControlName="value" value="option.value">{{option.label}}<br> <input type="radio" formControlName="value" value="option.value">{{option.label}}<br>
</div> </div>

View File

@ -1 +1,3 @@
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<input class ="form-control" [formControlName]="field.key" [id]="field.key" [type]="field.type" required ="field.required"> <input class ="form-control" [formControlName]="field.key" [id]="field.key" [type]="field.type" required ="field.required">

View File

@ -29,10 +29,12 @@
<div *ngIf="this.visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form" class="form-group" [ngSwitch]="field.viewStyle.renderStyle"> <div *ngIf="this.visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form" class="form-group" [ngSwitch]="field.viewStyle.renderStyle">
<div [ngClass]="{true:'show', false:'hide'}[field.visible]"> <div [ngClass]="{true:'show', false:'hide'}[field.visible]">
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<label>{{field.title}}</label>
<div *ngSwitchCase="'freetext'"> <div *ngSwitchCase="'freetext'">
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<input class="form-control" formControlName="value"> <input class="form-control" formControlName="value">
</div> </div>