argos/dmp-backend/src/main/java/models/admin/components/datasetprofile/Section.java

101 lines
3.0 KiB
Java
Raw Normal View History

package models.admin.components.datasetprofile;
2017-11-27 14:40:16 +01:00
import java.util.List;
2017-12-12 09:36:43 +01:00
import org.apache.commons.lang3.RandomStringUtils;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
2017-12-12 09:36:43 +01:00
public class Section implements Comparable,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>{
2017-11-27 14:40:16 +01:00
private List<Section> sections;
private List<Group> fieldGroups;
private Boolean defaultVisibility;
private int page;
2017-12-12 09:36:43 +01:00
private Integer ordinal;
2017-11-27 14:40:16 +01:00
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) {
2017-12-13 13:01:43 +01:00
if(this.id == null||this.id.isEmpty())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));
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) {
2017-12-12 09:36:43 +01:00
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();
}
2017-12-12 09:36:43 +01:00
@Override
public int compareTo(Object o) {
return this.ordinal.compareTo(((Section)o).getOrdinal());
}
2017-11-27 14:40:16 +01:00
}