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 properties = type.getProperties(); if(properties!=null && properties.size()>0) { Set 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 usage = k.getUsage(type.getName()); addLinkedEntities(table, usage); return table; } }