package org.gcube.informationsystem.utils.documentation.model.relations; import java.util.Set; import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.base.reference.relations.RelationElement; import org.gcube.informationsystem.types.TypeMapper; import org.gcube.informationsystem.types.reference.Type; import org.gcube.informationsystem.types.reference.entities.EntityType; import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; import org.gcube.informationsystem.types.reference.relations.RelationType; import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator; import org.gcube.informationsystem.utils.documentation.rst.table.Cell; import org.gcube.informationsystem.utils.documentation.rst.table.Row; import org.gcube.informationsystem.utils.documentation.rst.table.RowType; import org.gcube.informationsystem.utils.documentation.rst.table.Table; /** * @author Luca Frosini (ISTI - CNR) */ public class RelationDocumentationGenerator extends DocumentationGenerator { public RelationDocumentationGenerator(Type type) { super(type, AccessType.RELATION); this.superClassToBeExcluded = TypeMapper.getType(RelationElement.class); setLevel(0); } protected RelationDocumentationGenerator(Type type, AccessType requiredType) { super(type, requiredType); } protected Row getTypeDefinitionRow(RelationType relationType) { Row row = new Row(RowType.NORMAL); Cell source = new Cell(); source.setText(relationType.getSource().getName()); row.appendCell(source); Cell relation = new Cell(); relation.setText(relationType.getName()); row.appendCell(relation); Cell multiplicity = new Cell(); multiplicity.setText("0..n"); row.appendCell(multiplicity); Cell target = new Cell(); target.setText(relationType.getTarget().getName()); row.appendCell(target); Cell description = new Cell(); description.setText(relationType.getDescription()); row.appendCell(description); for(int i=row.getCells().size(); i relationType = (RelationType) type; table.appendRow(getTypeDefinitionRow(relationType)); table.appendRow(getRowCellSpan("**Properties**", requiredNumberOfColumns)); Set properties = type.getProperties(); table = addPropertyRows(table, properties); return table; } }