60 lines
1.8 KiB
Java
60 lines
1.8 KiB
Java
package org.gcube.informationsystem.utils.documentation.model.entities;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
|
|
import org.gcube.informationsystem.base.reference.AccessType;
|
|
import org.gcube.informationsystem.types.reference.Type;
|
|
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
|
|
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
|
import org.gcube.informationsystem.utils.documentation.knowledge.Knowledge;
|
|
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, AccessType.FACET);
|
|
}
|
|
|
|
@Override
|
|
protected Table getTable() {
|
|
Table table = new Table();
|
|
table.appendRow(getEntityHeadingRow());
|
|
table.appendRow(getPropertyFieldsBoldRow());
|
|
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());
|
|
}
|
|
|
|
table.appendRow(getKnownUsageBoldRow());
|
|
table.appendRow(getSourceTargetBoldRow());
|
|
|
|
Knowledge k = Knowledge.getInstace();
|
|
List<LinkedEntity> usage = k.getUsage(type.getName());
|
|
addLinkedEntities(table, usage);
|
|
|
|
return table;
|
|
}
|
|
|
|
|
|
}
|