Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
e6962b05e2
|
@ -7,6 +7,7 @@
|
|||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
||||
<properties>
|
||||
<project.http.version>1.19.0</project.http.version>
|
||||
<project.oauth.version>1.19.0</project.oauth.version>
|
||||
|
@ -35,7 +36,6 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>dmp-backend</groupId> -->
|
||||
<!-- <artifactId>dmp-backend-commons</artifactId> -->
|
||||
|
@ -250,11 +250,17 @@
|
|||
<!-- <version>0.7.0</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-oauth2</artifactId>
|
||||
<version>v2-rev75-1.19.0</version>
|
||||
</dependency>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava-jdk5</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.http-client</groupId>
|
||||
<artifactId>google-http-client-jackson2</artifactId>
|
||||
|
@ -294,6 +300,26 @@
|
|||
<version>23.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Swagger for providing a minimal (descriptive) UI for the rest API -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
<!-- <exclusions> -->
|
||||
<!-- <exclusion> -->
|
||||
<!-- <groupId>com.google.guava</groupId> -->
|
||||
<!-- <artifactId>guava</artifactId> -->
|
||||
<!-- </exclusion> -->
|
||||
<!-- </exclusions> -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Various libs -->
|
||||
<dependency>
|
||||
|
@ -335,7 +361,7 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package models.admin.components.datasetprofile;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
|
@ -13,9 +15,9 @@ import utilities.ModelDefinition;
|
|||
import utilities.ViewStyleDefinition;
|
||||
import utilities.builders.ModelBuilder;
|
||||
|
||||
public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition.Field>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Field>{
|
||||
public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition.Field>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Field>,Comparable{
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private Integer ordinal;
|
||||
private String title;
|
||||
private String value;
|
||||
private String description;
|
||||
|
@ -122,6 +124,8 @@ public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition
|
|||
}
|
||||
@Override
|
||||
public entities.xmlmodels.modeldefinition.Field toDatabaseDefinition(entities.xmlmodels.modeldefinition.Field field) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "field_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
field.setDatatype(this.datatype);
|
||||
field.setDefaultValue(this.defaultValue);
|
||||
field.setId(this.id);
|
||||
|
@ -137,6 +141,8 @@ public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition
|
|||
}
|
||||
@Override
|
||||
public entities.xmlmodels.viewstyledefinition.Field toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.Field field) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "field_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
field.setDefaultVisibility(this.defaultVisibility);
|
||||
field.setDescription(this.description);
|
||||
field.setExtendedDescription(this.extendedDescription);
|
||||
|
@ -159,6 +165,10 @@ public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition
|
|||
this.viewStyle = item.getViewStyle();
|
||||
this.data = item.getData();
|
||||
this.visible = item.getVisible();
|
||||
}
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return this.ordinal.compareTo(((Field)o).ordinal);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package models.admin.components.datasetprofile;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
|
||||
import models.components.commons.Multiplicity;
|
||||
|
@ -10,9 +12,9 @@ import utilities.ModelDefinition;
|
|||
import utilities.ViewStyleDefinition;
|
||||
import utilities.builders.ModelBuilder;
|
||||
|
||||
public class FieldSet implements ModelDefinition<entities.xmlmodels.modeldefinition.FieldSet>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldSet>{
|
||||
public class FieldSet implements Comparable,ModelDefinition<entities.xmlmodels.modeldefinition.FieldSet>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldSet>{
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private Integer ordinal;
|
||||
private Multiplicity multiplicity;
|
||||
private List<Field> fields;
|
||||
|
||||
|
@ -50,6 +52,8 @@ public class FieldSet implements ModelDefinition<entities.xmlmodels.modeldefinit
|
|||
|
||||
@Override
|
||||
public entities.xmlmodels.modeldefinition.FieldSet toDatabaseDefinition(entities.xmlmodels.modeldefinition.FieldSet fieldSet) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "fieldSet_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
fieldSet.setId(this.id);
|
||||
fieldSet.setOrdinal(this.ordinal);
|
||||
List<entities.xmlmodels.modeldefinition.Field> modelfields = new ModelBuilder().toModelDefinition(this.fields, entities.xmlmodels.modeldefinition.Field.class);
|
||||
|
@ -66,7 +70,9 @@ public class FieldSet implements ModelDefinition<entities.xmlmodels.modeldefinit
|
|||
}
|
||||
|
||||
@Override
|
||||
public entities.xmlmodels.viewstyledefinition.FieldSet toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.FieldSet item) {
|
||||
public entities.xmlmodels.viewstyledefinition.FieldSet toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.FieldSet item) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "fieldSet_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
List<entities.xmlmodels.viewstyledefinition.Field> viewStylefields = new ModelBuilder().toViewStyleDefinition(this.fields, entities.xmlmodels.viewstyledefinition.Field.class);
|
||||
item.setFields(viewStylefields);
|
||||
item.setId(this.id);
|
||||
|
@ -80,6 +86,11 @@ public class FieldSet implements ModelDefinition<entities.xmlmodels.modeldefinit
|
|||
this.id = item.getId();
|
||||
this.ordinal = item.getOrdinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return this.ordinal.compareTo(((FieldSet)o).ordinal);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package models.admin.components.datasetprofile;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
|
||||
import entities.xmlmodels.viewstyledefinition.FieldGroup;
|
||||
|
@ -84,6 +86,8 @@ public class Group implements ModelDefinition<entities.xmlmodels.modeldefinition
|
|||
}
|
||||
@Override
|
||||
public entities.xmlmodels.viewstyledefinition.FieldGroup toDatabaseDefinition(FieldGroup item) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "group_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
item.setDefaultVisibility(this.defaultVisibility);
|
||||
item.setDescription(this.description);
|
||||
item.setExtendedDescription(this.extendedDescription);
|
||||
|
@ -96,6 +100,7 @@ public class Group implements ModelDefinition<entities.xmlmodels.modeldefinition
|
|||
}
|
||||
@Override
|
||||
public void fromDatabaseDefinition(FieldGroup item) {
|
||||
|
||||
this.defaultVisibility = item.isDefaultVisibility();
|
||||
this.description = item.getDescription();
|
||||
this.extendedDescription = item.getExtendedDescription();
|
||||
|
|
|
@ -2,16 +2,18 @@ package models.admin.components.datasetprofile;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import utilities.ModelDefinition;
|
||||
import utilities.ViewStyleDefinition;
|
||||
import utilities.builders.ModelBuilder;
|
||||
|
||||
public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>{
|
||||
public class Section implements Comparable,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>{
|
||||
private List<Section> sections;
|
||||
private List<Group> fieldGroups;
|
||||
private Boolean defaultVisibility;
|
||||
private int page;
|
||||
private int ordinal;
|
||||
private Integer ordinal;
|
||||
private String id;
|
||||
private String title;
|
||||
private String description;
|
||||
|
@ -66,6 +68,7 @@ public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyle
|
|||
}
|
||||
@Override
|
||||
public entities.xmlmodels.viewstyledefinition.Section toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.Section item) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "section_"+RandomStringUtils.random(5, true, true);
|
||||
item.setDefaultVisibility(this.defaultVisibility);
|
||||
item.setDescription(this.description);
|
||||
if(this.fieldGroups!=null)item.setFieldGroups(new ModelBuilder().toViewStyleDefinition(this.fieldGroups, entities.xmlmodels.viewstyledefinition.FieldGroup.class));
|
||||
|
@ -78,6 +81,7 @@ public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyle
|
|||
}
|
||||
@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);
|
||||
|
@ -87,6 +91,10 @@ public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyle
|
|||
this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(),Section.class);
|
||||
this.title = item.getTitle();
|
||||
}
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return this.ordinal.compareTo(((Section)o).getOrdinal());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,11 @@ public class Field implements PropertiesGenerator{
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
public void toMap(Map<String,String> fieldValues){
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models.properties;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -13,6 +14,15 @@ import utilities.builders.ModelBuilder;
|
|||
|
||||
public class FieldSet implements PropertiesGenerator{
|
||||
private List<Field> fields;
|
||||
private List<FieldSet> multiplicityItems;
|
||||
|
||||
public List<FieldSet> getMultiplicityItems() {
|
||||
return multiplicityItems;
|
||||
}
|
||||
|
||||
public void setMultiplicityItems(List<FieldSet> multiplicityItems) {
|
||||
this.multiplicityItems = multiplicityItems;
|
||||
}
|
||||
|
||||
public List<Field> getFields() {
|
||||
return fields;
|
||||
|
@ -23,8 +33,19 @@ public class FieldSet implements PropertiesGenerator{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void toMap(Map<String, String> fieldValues) {
|
||||
public void toMap(Map<String, Object> fieldValues) {
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,8 +21,13 @@ public class Group implements PropertiesGenerator{
|
|||
this.compositeFields = compositeFields;
|
||||
}
|
||||
@Override
|
||||
public void toMap(Map<String, String> fieldValues) {
|
||||
public void toMap(Map<String, Object> fieldValues) {
|
||||
this.compositeFields.forEach(item->item.toMap(fieldValues));
|
||||
}
|
||||
@Override
|
||||
public void toMap(Map<String, Object> fieldValues, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,5 +3,6 @@ package models.properties;
|
|||
import java.util.Map;
|
||||
|
||||
public interface PropertiesGenerator {
|
||||
void toMap(Map<String,String> fieldValues);
|
||||
void toMap(Map<String,Object> fieldValues);
|
||||
void toMap(Map<String,Object> fieldValues,int index);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,15 @@ public class PropertiesModel implements PropertiesGenerator{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void toMap(Map<String, String> fieldValues) {
|
||||
public void toMap(Map<String, Object> fieldValues) {
|
||||
this.sections.forEach(item->item.toMap(fieldValues));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toMap(Map<String, Object> fieldValues, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,8 +25,13 @@ public class Section implements PropertiesGenerator{
|
|||
this.fieldGroups = fieldGroups;
|
||||
}
|
||||
@Override
|
||||
public void toMap(Map<String, String> fieldValues) {
|
||||
public void toMap(Map<String, Object> fieldValues) {
|
||||
this.sections.forEach(item->item.toMap(fieldValues));
|
||||
this.fieldGroups.forEach(item->item.toMap(fieldValues));
|
||||
}
|
||||
@Override
|
||||
public void toMap(Map<String, Object> fieldValues, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
package models.user.components.datasetprofile;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.util.stream.Collectors;
|
||||
|
||||
import models.components.commons.DefaultValue;
|
||||
import models.components.commons.Multiplicity;
|
||||
import models.components.commons.ViewStyle;
|
||||
import models.components.commons.Visibility;
|
||||
import models.user.composite.PropertiesModelBuilder;
|
||||
import utilities.ModelDefinition;
|
||||
import utilities.ViewStyleDefinition;
|
||||
import utilities.builders.ModelBuilder;
|
||||
|
||||
public class Field implements PropertiesModelBuilder, ModelDefinition<entities.xmlmodels.modeldefinition.Field>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Field>{
|
||||
public class Field implements Comparable,PropertiesModelBuilder, ModelDefinition<entities.xmlmodels.modeldefinition.Field>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Field>{
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private Integer ordinal;
|
||||
private String title;
|
||||
private String value;
|
||||
private String description;
|
||||
|
@ -30,7 +27,17 @@ public class Field implements PropertiesModelBuilder, ModelDefinition<entities.x
|
|||
private DefaultValue defaultValue;
|
||||
private Multiplicity multiplicity;
|
||||
private Object data;
|
||||
private List<Field> multiplicityItems;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -115,6 +122,23 @@ public class Field implements PropertiesModelBuilder, ModelDefinition<entities.x
|
|||
this.data = data;
|
||||
}
|
||||
|
||||
public Field cloneForMultiplicity(String id, Map<String, Object> properties){
|
||||
Field newField = new Field();
|
||||
newField.id = id;
|
||||
newField.ordinal = this.ordinal;
|
||||
newField.title = this.title;
|
||||
newField.value = (String)properties.get(id);
|
||||
newField.description = this.description;
|
||||
newField.extendedDescription = this.extendedDescription;
|
||||
newField.viewStyle = this.viewStyle;
|
||||
newField.datatype = this.datatype;
|
||||
newField.defaultVisibility = this.defaultVisibility;
|
||||
newField.page = this.page;
|
||||
newField.defaultValue = this.defaultValue;
|
||||
newField.data = this.data;
|
||||
|
||||
return newField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public entities.xmlmodels.modeldefinition.Field toDatabaseDefinition(entities.xmlmodels.modeldefinition.Field field) {
|
||||
|
@ -157,7 +181,20 @@ public class Field implements PropertiesModelBuilder, ModelDefinition<entities.x
|
|||
@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, int index) {
|
||||
this.value = (String)properties.get("multiple_"+this.id+"_"+index);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
package models.user.components.datasetprofile;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.fasterxml.classmate.util.ResolvedTypeCache.Key;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
|
||||
import models.components.commons.Multiplicity;
|
||||
|
@ -12,13 +15,14 @@ import utilities.ModelDefinition;
|
|||
import utilities.ViewStyleDefinition;
|
||||
import utilities.builders.ModelBuilder;
|
||||
|
||||
public class FieldSet implements PropertiesModelBuilder, ModelDefinition<entities.xmlmodels.modeldefinition.FieldSet>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldSet>{
|
||||
public class FieldSet implements Comparable,PropertiesModelBuilder, ModelDefinition<entities.xmlmodels.modeldefinition.FieldSet>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldSet>{
|
||||
private String id;
|
||||
private int ordinal;
|
||||
private Integer ordinal;
|
||||
private Multiplicity multiplicity;
|
||||
private List<Field> fields;
|
||||
|
||||
private List<FieldSet> multiplicityItems;
|
||||
public List<Field> getFields() {
|
||||
Collections.sort(this.fields);
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
@ -49,6 +53,20 @@ public class FieldSet implements PropertiesModelBuilder, ModelDefinition<entitie
|
|||
public void setMultiplicity(Multiplicity multiplicity) {
|
||||
this.multiplicity = multiplicity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<FieldSet> getMultiplicityItems() {
|
||||
return multiplicityItems;
|
||||
}
|
||||
|
||||
public void setMultiplicityItems(List<FieldSet> multiplicityItems) {
|
||||
this.multiplicityItems = multiplicityItems;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public entities.xmlmodels.modeldefinition.FieldSet toDatabaseDefinition(entities.xmlmodels.modeldefinition.FieldSet fieldSet) {
|
||||
|
@ -84,8 +102,45 @@ public class FieldSet implements PropertiesModelBuilder, ModelDefinition<entitie
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromJsonObject(Map<String, Object> properties) {
|
||||
this.fields.forEach(item->item.fromJsonObject(properties));
|
||||
public void fromJsonObject(Map<String, Object> properties) {
|
||||
this.multiplicityItems = new LinkedList<FieldSet>();
|
||||
this.fields.forEach(item->{
|
||||
item.fromJsonObject(properties);
|
||||
});
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
private FieldSet cloneForMultiplicity(String id, Map<String, Object> properties){
|
||||
FieldSet newFieldSet = new FieldSet();
|
||||
newFieldSet.id = id;
|
||||
newFieldSet.ordinal = this.ordinal;
|
||||
newFieldSet.fields = new LinkedList();
|
||||
this.fields.forEach(item->{
|
||||
newFieldSet.fields.add(item.cloneForMultiplicity("multiple_"+item.getId()+"_"+this.fields.indexOf(item), properties));
|
||||
});
|
||||
|
||||
return newFieldSet;
|
||||
}
|
||||
|
||||
private void createMultiplicityFields(List<FieldSet> fieldSet,Field field){
|
||||
FieldSet newFieldSet = new FieldSet();
|
||||
newFieldSet.fields = new LinkedList<Field>();
|
||||
newFieldSet.fields.add(field);
|
||||
fieldSet.add(newFieldSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return this.ordinal.compareTo(((FieldSet)o).getOrdinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models.user.components.datasetprofile;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -72,6 +73,7 @@ public class Group implements PropertiesModelBuilder, ModelDefinition<entities.x
|
|||
this.page = page;
|
||||
}
|
||||
public List<FieldSet> getCompositeFields() {
|
||||
Collections.sort(this.compositeFields);
|
||||
return compositeFields;
|
||||
}
|
||||
public void setCompositeFields(List<FieldSet> compositeFields) {
|
||||
|
@ -122,4 +124,9 @@ public class Group implements PropertiesModelBuilder, ModelDefinition<entities.x
|
|||
this.compositeFields.forEach(item->item.fromJsonObject(properties));
|
||||
|
||||
}
|
||||
@Override
|
||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models.user.components.datasetprofile;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -8,16 +9,17 @@ import utilities.ModelDefinition;
|
|||
import utilities.ViewStyleDefinition;
|
||||
import utilities.builders.ModelBuilder;
|
||||
|
||||
public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>,PropertiesModelBuilder{
|
||||
public class Section implements Comparable,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>,PropertiesModelBuilder{
|
||||
private List<Section> sections;
|
||||
private List<Group> fieldGroups;
|
||||
private Boolean defaultVisibility;
|
||||
private int page;
|
||||
private int ordinal;
|
||||
private Integer ordinal;
|
||||
private String id;
|
||||
private String title;
|
||||
private String description;
|
||||
public List<Section> getSections() {
|
||||
Collections.sort(sections);
|
||||
return sections;
|
||||
}
|
||||
public void setSections(List<Section> sections) {
|
||||
|
@ -94,6 +96,15 @@ public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyle
|
|||
this.sections.forEach(item->item.fromJsonObject(properties));
|
||||
this.fieldGroups.forEach(item->item.fromJsonObject(properties));
|
||||
}
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return this.ordinal.compareTo(((Section)o).getOrdinal());
|
||||
}
|
||||
@Override
|
||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -45,5 +45,11 @@ public class DatasetProfile implements PropertiesModelBuilder{
|
|||
this.sections.forEach(item->item.fromJsonObject(properties));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,4 +4,5 @@ import java.util.Map;
|
|||
|
||||
public interface PropertiesModelBuilder {
|
||||
void fromJsonObject(Map<String,Object> properties);
|
||||
void fromJsonObject(Map<String,Object> properties,int index);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class Admin {
|
|||
modelDefinition.setViewstyle(viewStyleDefinition);
|
||||
datasetProfileDao.create(modelDefinition);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(profile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"reason\":\""+ex.getMessage()+"\"}");
|
||||
|
|
|
@ -57,7 +57,7 @@ public class DatasetProfileController {
|
|||
public ResponseEntity<Object> postDataset(@PathVariable String id,@RequestBody PropertiesModel properties){
|
||||
try {
|
||||
entities.Dataset dataset = datasetDao.read(UUID.fromString(id));
|
||||
Map<String,String> values = new HashMap();
|
||||
Map<String,Object> values = new HashMap();
|
||||
properties.toMap(values);
|
||||
JSONObject jobject = new JSONObject(values);
|
||||
dataset.setProperties(jobject.toString());
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package swagger;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableWebMvc
|
||||
public class SwaggerConfig extends WebMvcConfigurerAdapter {
|
||||
@Bean
|
||||
public Docket api() {
|
||||
System.out.println("Initializing Swagger 2...");
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
System.out.println("Overriding resource handlers");
|
||||
registry.addResourceHandler("swagger-ui.html")
|
||||
.addResourceLocations("classpath*:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath*:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:cache="http://www.springframework.org/schema/cache"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc
|
||||
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.1.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
|
||||
|
||||
<context:property-placeholder location="classpath*:**/dmp.properties" />
|
||||
|
||||
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
|
||||
|
||||
<context:component-scan base-package="swagger" />
|
||||
|
||||
<context:component-scan base-package="rest" />
|
||||
|
||||
<context:component-scan base-package="proxy" />
|
||||
|
||||
|
||||
<bean id="proxy" class="proxy.Proxy">
|
||||
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
|
@ -57,6 +57,33 @@
|
|||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
|
||||
<!-- This mapping is for swagger -->
|
||||
<servlet>
|
||||
<servlet-name>swagger</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<!-- <init-param> -->
|
||||
<!-- <param-name>contextConfigLocation</param-name> -->
|
||||
<!-- <param-value></param-value> -->
|
||||
<!-- </init-param> -->
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>default</servlet-name>
|
||||
<url-pattern>/swagger-ui.html</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>swagger</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- this listener is for checking required stuff upon deployment of the webapp -->
|
||||
<listener>
|
||||
<listener-class>
|
||||
|
@ -104,4 +131,5 @@
|
|||
</filter-mapping>
|
||||
|
||||
|
||||
|
||||
</web-app>
|
Loading…
Reference in New Issue