51 lines
1.6 KiB
Java
51 lines
1.6 KiB
Java
package org.gcube.informationsystem.utils.documentation.model.properties;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
|
import org.gcube.informationsystem.types.TypeMapper;
|
|
import org.gcube.informationsystem.types.reference.Type;
|
|
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
|
import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator;
|
|
import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public class PropertyDocumentationGenerator extends DocumentationGenerator {
|
|
|
|
public PropertyDocumentationGenerator(Type type) {
|
|
super(type, TypeMapper.getType(PropertyElement.class));
|
|
}
|
|
|
|
@Override
|
|
protected Table getTable() {
|
|
|
|
Table table = new Table();
|
|
table.appendRow(getPropertiesHeadingRow());
|
|
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;
|
|
}
|
|
|
|
|
|
}
|