no message

This commit is contained in:
Ioannis Kalyvas 2018-01-30 13:07:51 +02:00
parent f1ee3095f9
commit 627644a237
9 changed files with 233 additions and 178 deletions

View File

@ -71,7 +71,7 @@ public class DatasetManager {
private static void propertiesModelToString(DatasetWizardModel datasetWizardModel,eu.eudat.entities.Dataset dataset){
Map<String,Object> values = new HashMap();
PropertiesModel properties = datasetWizardModel.getProperties();
PagedDatasetProfile properties = datasetWizardModel.getDatasetProfileDefinition();
properties.toMap(values);
JSONObject jobject = new JSONObject(values);
dataset.setProperties(jobject.toString());

View File

@ -38,7 +38,6 @@ public class DatasetWizardModel implements DataModel<Dataset> {
private List<DataRepository> dataRepositories;
private List<ExternalDatasetListingModel> externalDatasets;
private DatasetProfileListingModel profile;
private PropertiesModel properties;
public UUID getId() {
return id;
@ -88,14 +87,6 @@ public class DatasetWizardModel implements DataModel<Dataset> {
this.status = status;
}
public PropertiesModel getProperties() {
return properties;
}
public void setProperties(PropertiesModel properties) {
this.properties = properties;
}
public Date getCreated() {
return created;
}

View File

@ -10,162 +10,192 @@ import eu.eudat.models.components.commons.DefaultValue;
import eu.eudat.models.components.commons.Multiplicity;
import eu.eudat.models.components.commons.ViewStyle;
import eu.eudat.models.components.commons.Visibility;
import eu.eudat.models.properties.PropertiesGenerator;
import eu.eudat.models.user.composite.PropertiesModelBuilder;
import eu.eudat.utilities.ModelDefinition;
import eu.eudat.utilities.ViewStyleDefinition;
import eu.eudat.utilities.builders.ModelBuilder;
public class Field implements Comparable,PropertiesModelBuilder,ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field>{
private String id;
private Integer ordinal;
private String value;
private ViewStyle viewStyle;
private String datatype;
private int page;
private DefaultValue defaultValue;
private Multiplicity multiplicity;
private Object data;
private List<Field> multiplicityItems;
private List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> validations;
private Visibility visible;
public List<Field> getMultiplicityItems() {
return multiplicityItems;
}
public void setMultiplicityItems(List<Field> multiplicityItems) {
this.multiplicityItems = multiplicityItems;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field>, PropertiesGenerator {
private String id;
private Integer ordinal;
private String value;
private ViewStyle viewStyle;
private String datatype;
private int page;
private DefaultValue defaultValue;
private Multiplicity multiplicity;
private Object data;
private List<Field> multiplicityItems;
private List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> validations;
private Visibility visible;
public int getOrdinal(){
return ordinal;
}
public List<Field> getMultiplicityItems() {
return multiplicityItems;
}
public void setOrdinal(int ordinal){
this.ordinal = ordinal;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public ViewStyle getViewStyle() {
return viewStyle;
}
public void setViewStyle(ViewStyle viewStyle) {
this.viewStyle = viewStyle;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public void setMultiplicityItems(List<Field> multiplicityItems) {
this.multiplicityItems = multiplicityItems;
}
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 void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public Multiplicity getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Multiplicity multiplicity) {
this.multiplicity = multiplicity;
}
public String getId() {
return id;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public void setId(String id) {
this.id = id;
}
public Visibility getVisible() {
return visible;
}
public int getOrdinal() {
return ordinal;
}
public void setVisible(Visibility visible) {
this.visible = visible;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public List<Integer> getValidations() {
return this.validations.stream().map(item->(int)item.getValue()).collect(Collectors.toList());
}
public String getValue() {
return value;
}
public void setValidations(List<Integer> validations) {
this.validations = eu.eudat.models.admin.components.datasetprofile.Field.ValidationType.fromIntegers(validations);
}
public void setValue(String value) {
this.value = value;
}
public ViewStyle getViewStyle() {
return viewStyle;
}
public void setViewStyle(ViewStyle viewStyle) {
this.viewStyle = viewStyle;
}
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;
}
public Visibility getVisible() {
return visible;
}
public void setVisible(Visibility visible) {
this.visible = visible;
}
public List<Integer> getValidations() {
return this.validations.stream().map(item -> (int) item.getValue()).collect(Collectors.toList());
}
public void setValidations(List<Integer> validations) {
this.validations = eu.eudat.models.admin.components.datasetprofile.Field.ValidationType.fromIntegers(validations);
}
public Field cloneForMultiplicity(String key, Map<String, Object> properties){
Field newField = new Field();
newField.id = key;
newField.ordinal = this.ordinal;
newField.value = (String)properties.get(key);
newField.viewStyle = this.viewStyle;
newField.datatype = this.datatype;
newField.page = this.page;
newField.defaultValue = this.defaultValue;
newField.data = this.data;
newField.validations = this.validations;
return newField;
}
public Field cloneForMultiplicity(String key, Map<String, Object> properties) {
Field newField = new Field();
newField.id = key;
newField.ordinal = this.ordinal;
newField.value = (String) properties.get(key);
newField.viewStyle = this.viewStyle;
newField.datatype = this.datatype;
newField.page = this.page;
newField.defaultValue = this.defaultValue;
newField.data = this.data;
newField.validations = this.validations;
return newField;
}
@Override
public eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field field) {
field.setId(this.id);
field.setOrdinal(this.ordinal);
field.setViewStyle(this.viewStyle);
field.setData(new ModelBuilder().toFieldData(data, this.viewStyle.getRenderStyle()));
field.setDefaultValue(this.defaultValue);
field.setVisible(this.visible);
field.setValidations(this.validations);
return field;
}
@Override
public void fromDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field item) {
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.viewStyle = item.getViewStyle();
this.data = item.getData();
this.defaultValue = item.getDefaultValue();
this.visible= item.getVisible();
this.validations = item.getValidations();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.value = (String)properties.get(this.id);
this.multiplicityItems = new LinkedList<Field>();
List<String> compositeKeys = properties.keySet().stream().filter(keys->keys.startsWith("multiple_"+this.getId())).collect(Collectors.toList());
for (String key : compositeKeys) {
this.multiplicityItems.add(this.cloneForMultiplicity(key, properties));
}
@Override
public eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field field) {
field.setId(this.id);
field.setOrdinal(this.ordinal);
field.setViewStyle(this.viewStyle);
field.setData(new ModelBuilder().toFieldData(data, this.viewStyle.getRenderStyle()));
field.setDefaultValue(this.defaultValue);
field.setVisible(this.visible);
field.setValidations(this.validations);
return field;
}
}
@Override
public int compareTo(Object o) {
return this.ordinal.compareTo(((Field)o).getOrdinal());
}
@Override
public void fromJsonObject(Map<String, Object> properties, String path) {
this.value = (String)properties.get(path);
}
@Override
public void fromDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field item) {
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.viewStyle = item.getViewStyle();
this.data = item.getData();
this.defaultValue = item.getDefaultValue();
this.visible = item.getVisible();
this.validations = item.getValidations();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.value = (String) properties.get(this.id);
this.multiplicityItems = new LinkedList<Field>();
List<String> compositeKeys = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList());
for (String key : compositeKeys) {
this.multiplicityItems.add(this.cloneForMultiplicity(key, properties));
}
}
@Override
public int compareTo(Object o) {
return this.ordinal.compareTo(((Field) o).getOrdinal());
}
@Override
public void fromJsonObject(Map<String, Object> properties, String path) {
this.value = (String) properties.get(path);
}
@Override
public void toMap(Map<String, Object> fieldValues) {
fieldValues.put(this.id, this.value);
}
@Override
public void toMap(Map<String, Object> fieldValues, int index) {
fieldValues.put(this.id, this.value);
}
}

View File

@ -1,18 +1,16 @@
package eu.eudat.models.user.components.datasetprofile;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import eu.eudat.models.components.commons.Multiplicity;
import eu.eudat.models.properties.PropertiesGenerator;
import eu.eudat.models.user.composite.PropertiesModelBuilder;
import eu.eudat.utilities.ModelDefinition;
import eu.eudat.utilities.ViewStyleDefinition;
import eu.eudat.utilities.builders.ModelBuilder;
public class FieldSet implements Comparable,PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.FieldSet>{
public class FieldSet implements Comparable,PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.FieldSet>,PropertiesGenerator {
private String id;
private Integer ordinal;
private String title;
@ -181,5 +179,20 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ViewStyleDef
}
@Override
public void toMap(Map<String, Object> fieldValues) {
fieldValues.put("commentFieldValue" + this.id, this.commentFieldValue);
this.fields.forEach(item -> item.toMap(fieldValues));
Map<String, Object> multiplicity = new HashMap<String, Object>();
if (this.multiplicityItems != null) {
this.multiplicityItems.forEach(item -> item.toMap(fieldValues, this.multiplicityItems.indexOf(item)));
}
//fieldValues.put(this.id,multiplicity);
}
@Override
public void toMap(Map<String, Object> fieldValues, int index) {
this.fields.forEach(item -> item.toMap(fieldValues, index));
//this.multiplicityItems.forEach(item->item.toMap(fieldValues,index));
}
}

View File

@ -4,13 +4,14 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import eu.eudat.models.properties.PropertiesGenerator;
import eu.eudat.models.user.composite.PropertiesModelBuilder;
import eu.eudat.utilities.ViewStyleDefinition;
import eu.eudat.utilities.builders.ModelBuilder;
public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section>,PropertiesModelBuilder{
public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section>,PropertiesModelBuilder,PropertiesGenerator {
private List<Section> sections;
private List<FieldSet> fieldSets;
private List<FieldSet> compositeFields;
private Boolean defaultVisibility;
private String page;
private Integer ordinal;
@ -25,12 +26,12 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
this.sections = sections;
}
public List<FieldSet> getFieldSets() {
return fieldSets;
public List<FieldSet> getCompositeFields() {
return compositeFields;
}
public void setFieldSets(List<FieldSet> fieldSets) {
this.fieldSets = fieldSets;
public void setCompositeFields(List<FieldSet> compositeFields) {
this.compositeFields = compositeFields;
}
public Boolean getDefaultVisibility() {
@ -74,7 +75,7 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
public eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section item) {
item.setDefaultVisibility(this.defaultVisibility);
item.setDescription(this.description);
if(this.fieldSets!=null)item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.fieldSets, eu.eudat.entities.xmlmodels.datasetprofiledefinition.FieldSet.class));
if(this.compositeFields!=null)item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.compositeFields, eu.eudat.entities.xmlmodels.datasetprofiledefinition.FieldSet.class));
item.setId(this.id);
item.setOrdinal(this.ordinal);
item.setPage(this.page);
@ -86,7 +87,7 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
public void fromDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section item) {
this.defaultVisibility = item.isDefaultVisibility();
this.description = item.getDescription();
this.fieldSets = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(),FieldSet.class);
this.compositeFields = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(),FieldSet.class);
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.page = item.getPage();
@ -96,7 +97,7 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.sections.forEach(item->item.fromJsonObject(properties));
this.fieldSets.forEach(item->item.fromJsonObject(properties));
this.compositeFields.forEach(item->item.fromJsonObject(properties));
}
@Override
public int compareTo(Object o) {
@ -108,5 +109,14 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
}
@Override
public void toMap(Map<String, Object> fieldValues) {
this.sections.forEach(item->item.toMap(fieldValues));
this.compositeFields.forEach(item->item.toMap(fieldValues));
}
@Override
public void toMap(Map<String, Object> fieldValues, int index) {
}
}

View File

@ -1,16 +1,18 @@
package eu.eudat.models.user.composite;
import eu.eudat.models.admin.components.datasetprofile.Page;
import eu.eudat.models.properties.PropertiesGenerator;
import eu.eudat.models.user.components.commons.Rule;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by ikalyvas on 1/19/2018.
*/
public class PagedDatasetProfile {
public class PagedDatasetProfile implements PropertiesGenerator {
private List<DatasetProfilePage> pages;
private List<Rule> rules;
private int status;
@ -54,4 +56,13 @@ public class PagedDatasetProfile {
return this;
}
@Override
public void toMap(Map<String, Object> fieldValues) {
this.pages.forEach(item->item.getSections().forEach(sectionItem->sectionItem.toMap(fieldValues)));
}
@Override
public void toMap(Map<String, Object> fieldValues, int index) {
}
}

View File

@ -158,7 +158,7 @@ export class DatasetWizardComponent {
}
submit() {
this.datasetWizardService.saveDataset(this.formGroup.value, this.formGroup.get('datasetProfileDefinition').value).subscribe(data => {
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(data => {
this.router.navigateByUrl("/datasets/dmp/" + this.datasetWizardModel.dmp.id);
});
}

View File

@ -24,7 +24,7 @@ export class Section extends BaseModel implements Serializable<Section>, FormGen
this.id = item.id;
this.title = item.title;
this.description = item.description;
this.compositeFields = JsonSerializer.fromJSONArray(item.fieldSets, CompositeField);
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
return this;
}

View File

@ -44,10 +44,10 @@ export class DatasetWizardService {
return this.http.post<DatasetWizardModel>(this.actionUrl + 'createOrUpdate', datasetModel, { headers: this.headers });
}
public saveDataset(datasetWizard: DatasetWizardModel, formValue) {
/* public saveDataset(datasetWizard: DatasetWizardModel, formValue) {
datasetWizard.properties = formValue;
return this.createDataset(datasetWizard)
}
} */
public getDefinition(id: String): Observable<DatasetProfileDefinitionModel> {
return this.http.get<DatasetProfileDefinitionModel>(this.actionUrl + 'get/' + id, { headers: this.headers });