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){ private static void propertiesModelToString(DatasetWizardModel datasetWizardModel,eu.eudat.entities.Dataset dataset){
Map<String,Object> values = new HashMap(); Map<String,Object> values = new HashMap();
PropertiesModel properties = datasetWizardModel.getProperties(); PagedDatasetProfile properties = datasetWizardModel.getDatasetProfileDefinition();
properties.toMap(values); properties.toMap(values);
JSONObject jobject = new JSONObject(values); JSONObject jobject = new JSONObject(values);
dataset.setProperties(jobject.toString()); dataset.setProperties(jobject.toString());

View File

@ -38,7 +38,6 @@ public class DatasetWizardModel implements DataModel<Dataset> {
private List<DataRepository> dataRepositories; private List<DataRepository> dataRepositories;
private List<ExternalDatasetListingModel> externalDatasets; private List<ExternalDatasetListingModel> externalDatasets;
private DatasetProfileListingModel profile; private DatasetProfileListingModel profile;
private PropertiesModel properties;
public UUID getId() { public UUID getId() {
return id; return id;
@ -88,14 +87,6 @@ public class DatasetWizardModel implements DataModel<Dataset> {
this.status = status; this.status = status;
} }
public PropertiesModel getProperties() {
return properties;
}
public void setProperties(PropertiesModel properties) {
this.properties = properties;
}
public Date getCreated() { public Date getCreated() {
return created; 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.Multiplicity;
import eu.eudat.models.components.commons.ViewStyle; import eu.eudat.models.components.commons.ViewStyle;
import eu.eudat.models.components.commons.Visibility; import eu.eudat.models.components.commons.Visibility;
import eu.eudat.models.properties.PropertiesGenerator;
import eu.eudat.models.user.composite.PropertiesModelBuilder; import eu.eudat.models.user.composite.PropertiesModelBuilder;
import eu.eudat.utilities.ModelDefinition; import eu.eudat.utilities.ModelDefinition;
import eu.eudat.utilities.ViewStyleDefinition; import eu.eudat.utilities.ViewStyleDefinition;
import eu.eudat.utilities.builders.ModelBuilder; import eu.eudat.utilities.builders.ModelBuilder;
public class Field implements Comparable,PropertiesModelBuilder,ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field>{ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field>, PropertiesGenerator {
private String id; private String id;
private Integer ordinal; private Integer ordinal;
private String value; private String value;
private ViewStyle viewStyle; private ViewStyle viewStyle;
private String datatype; private String datatype;
private int page; private int page;
private DefaultValue defaultValue; private DefaultValue defaultValue;
private Multiplicity multiplicity; private Multiplicity multiplicity;
private Object data; private Object data;
private List<Field> multiplicityItems; private List<Field> multiplicityItems;
private List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> validations; private List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> validations;
private Visibility visible; 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 int getOrdinal(){
return ordinal;
}
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 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() { public List<Field> getMultiplicityItems() {
return visible; return multiplicityItems;
} }
public void setVisible(Visibility visible) { public void setMultiplicityItems(List<Field> multiplicityItems) {
this.visible = visible; this.multiplicityItems = multiplicityItems;
} }
public List<Integer> getValidations() { public void setOrdinal(Integer ordinal) {
return this.validations.stream().map(item->(int)item.getValue()).collect(Collectors.toList()); this.ordinal = ordinal;
} }
public void setValidations(List<Integer> validations) { public String getId() {
this.validations = eu.eudat.models.admin.components.datasetprofile.Field.ValidationType.fromIntegers(validations); 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 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 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){ public Field cloneForMultiplicity(String key, Map<String, Object> properties) {
Field newField = new Field(); Field newField = new Field();
newField.id = key; newField.id = key;
newField.ordinal = this.ordinal; newField.ordinal = this.ordinal;
newField.value = (String)properties.get(key); newField.value = (String) properties.get(key);
newField.viewStyle = this.viewStyle; newField.viewStyle = this.viewStyle;
newField.datatype = this.datatype; newField.datatype = this.datatype;
newField.page = this.page; newField.page = this.page;
newField.defaultValue = this.defaultValue; newField.defaultValue = this.defaultValue;
newField.data = this.data; newField.data = this.data;
newField.validations = this.validations; newField.validations = this.validations;
return newField; return newField;
} }
@Override @Override
public eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field field) { public eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field field) {
field.setId(this.id); field.setId(this.id);
field.setOrdinal(this.ordinal); field.setOrdinal(this.ordinal);
field.setViewStyle(this.viewStyle); field.setViewStyle(this.viewStyle);
field.setData(new ModelBuilder().toFieldData(data, this.viewStyle.getRenderStyle())); field.setData(new ModelBuilder().toFieldData(data, this.viewStyle.getRenderStyle()));
field.setDefaultValue(this.defaultValue); field.setDefaultValue(this.defaultValue);
field.setVisible(this.visible); field.setVisible(this.visible);
field.setValidations(this.validations); field.setValidations(this.validations);
return field; 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 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; package eu.eudat.models.user.components.datasetprofile;
import java.util.Collections; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import eu.eudat.models.components.commons.Multiplicity; import eu.eudat.models.components.commons.Multiplicity;
import eu.eudat.models.properties.PropertiesGenerator;
import eu.eudat.models.user.composite.PropertiesModelBuilder; import eu.eudat.models.user.composite.PropertiesModelBuilder;
import eu.eudat.utilities.ModelDefinition; import eu.eudat.utilities.ModelDefinition;
import eu.eudat.utilities.ViewStyleDefinition; import eu.eudat.utilities.ViewStyleDefinition;
import eu.eudat.utilities.builders.ModelBuilder; 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 String id;
private Integer ordinal; private Integer ordinal;
private String title; private String title;
@ -180,6 +178,21 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ViewStyleDef
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@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.List;
import java.util.Map; import java.util.Map;
import eu.eudat.models.properties.PropertiesGenerator;
import eu.eudat.models.user.composite.PropertiesModelBuilder; import eu.eudat.models.user.composite.PropertiesModelBuilder;
import eu.eudat.utilities.ViewStyleDefinition; import eu.eudat.utilities.ViewStyleDefinition;
import eu.eudat.utilities.builders.ModelBuilder; 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<Section> sections;
private List<FieldSet> fieldSets; private List<FieldSet> compositeFields;
private Boolean defaultVisibility; private Boolean defaultVisibility;
private String page; private String page;
private Integer ordinal; private Integer ordinal;
@ -25,12 +26,12 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
this.sections = sections; this.sections = sections;
} }
public List<FieldSet> getFieldSets() { public List<FieldSet> getCompositeFields() {
return fieldSets; return compositeFields;
} }
public void setFieldSets(List<FieldSet> fieldSets) { public void setCompositeFields(List<FieldSet> compositeFields) {
this.fieldSets = fieldSets; this.compositeFields = compositeFields;
} }
public Boolean getDefaultVisibility() { 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) { public eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section item) {
item.setDefaultVisibility(this.defaultVisibility); item.setDefaultVisibility(this.defaultVisibility);
item.setDescription(this.description); 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.setId(this.id);
item.setOrdinal(this.ordinal); item.setOrdinal(this.ordinal);
item.setPage(this.page); 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) { public void fromDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section item) {
this.defaultVisibility = item.isDefaultVisibility(); this.defaultVisibility = item.isDefaultVisibility();
this.description = item.getDescription(); 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.id = item.getId();
this.ordinal = item.getOrdinal(); this.ordinal = item.getOrdinal();
this.page = item.getPage(); this.page = item.getPage();
@ -96,7 +97,7 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
@Override @Override
public void fromJsonObject(Map<String, Object> properties) { public void fromJsonObject(Map<String, Object> properties) {
this.sections.forEach(item->item.fromJsonObject(properties)); this.sections.forEach(item->item.fromJsonObject(properties));
this.fieldSets.forEach(item->item.fromJsonObject(properties)); this.compositeFields.forEach(item->item.fromJsonObject(properties));
} }
@Override @Override
public int compareTo(Object o) { public int compareTo(Object o) {
@ -107,6 +108,15 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@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; package eu.eudat.models.user.composite;
import eu.eudat.models.admin.components.datasetprofile.Page; import eu.eudat.models.admin.components.datasetprofile.Page;
import eu.eudat.models.properties.PropertiesGenerator;
import eu.eudat.models.user.components.commons.Rule; import eu.eudat.models.user.components.commons.Rule;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* Created by ikalyvas on 1/19/2018. * Created by ikalyvas on 1/19/2018.
*/ */
public class PagedDatasetProfile { public class PagedDatasetProfile implements PropertiesGenerator {
private List<DatasetProfilePage> pages; private List<DatasetProfilePage> pages;
private List<Rule> rules; private List<Rule> rules;
private int status; private int status;
@ -54,4 +56,13 @@ public class PagedDatasetProfile {
return this; 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() { 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); 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.id = item.id;
this.title = item.title; this.title = item.title;
this.description = item.description; this.description = item.description;
this.compositeFields = JsonSerializer.fromJSONArray(item.fieldSets, CompositeField); this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
return this; return this;
} }

View File

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