48 lines
1.4 KiB
Java
48 lines
1.4 KiB
Java
package org.gcube.informationsystem.utils.documentation.model.entities;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
import org.gcube.informationsystem.types.reference.Type;
|
|
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
|
import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public class FacetDocumentationGenerator extends EntityDocumentationGenerator {
|
|
|
|
public FacetDocumentationGenerator(Type type) {
|
|
super(type);
|
|
}
|
|
|
|
@Override
|
|
protected Table getTable() {
|
|
Table table = new Table();
|
|
table.appendRow(getEntityHeadingRow());
|
|
table.appendRow(getPropertiesBoldRow());
|
|
Set<PropertyDefinition> properties = type.getProperties();
|
|
if(properties!=null && properties.size()>0) {
|
|
Set<PropertyDefinition> notMandatoryProperties = new HashSet<>();
|
|
for(PropertyDefinition propertyDefinition : properties) {
|
|
if(propertyDefinition.isMandatory()) {
|
|
/*
|
|
* Adding Mandatory properties first in the table
|
|
*/
|
|
table.appendRow(getPropertyRow(propertyDefinition));
|
|
}else {
|
|
notMandatoryProperties.add(propertyDefinition);
|
|
}
|
|
}
|
|
for(PropertyDefinition propertyDefinition : notMandatoryProperties) {
|
|
table.appendRow(getPropertyRow(propertyDefinition));
|
|
}
|
|
}else {
|
|
table.appendRow(getNoPropertyRow());
|
|
}
|
|
return table;
|
|
}
|
|
|
|
|
|
}
|