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

100 lines
3.0 KiB
Java

package models.user.components.datasetprofile;
import java.util.List;
import java.util.Map;
import models.user.composite.PropertiesModelBuilder;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>,PropertiesModelBuilder{
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();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.sections.forEach(item->item.fromJsonObject(properties));
this.fieldGroups.forEach(item->item.fromJsonObject(properties));
}
}