From 82f2c26b3e9810f14b03c1246a5468e9fb548b52 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 20 Jan 2023 10:27:07 +0100 Subject: [PATCH] Improving code --- .gitignore | 3 + .project | 5 + .settings/org.eclipse.jdt.core.prefs | 14 ++ .../utils/documentation/DocGenerator.java | 11 +- .../utils/documentation/ModelTypes.java | 8 +- .../model/DocumentationGenerator.java | 125 ++++++++++++++++-- .../EntityDocumentationGenerator.java | 31 ++--- .../entities/FacetDocumentationGenerator.java | 54 ++++---- .../ResourceDocumentationGenerator.java | 8 +- .../PropertyDocumentationGenerator.java | 94 +------------ .../ConsistsOfDocumentationGenerator.java | 10 +- .../IsRelatedToDocumentationGenerator.java | 9 +- .../RelationDocumentationGenerator.java | 10 +- .../utils/documentation/GenerateTest.java | 4 - .../utils/documentation/table/TableTest.java | 2 +- 15 files changed, 211 insertions(+), 177 deletions(-) diff --git a/.gitignore b/.gitignore index b83d222..cc1421b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /target/ +/entities.rst +/properties.rst +/relations.rst diff --git a/.project b/.project index f3b61bf..0a4c45e 100644 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ + + org.eclipse.jdt.core.javabuilder + + + org.eclipse.m2e.core.maven2Builder diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 4ede96d..3a0745f 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,2 +1,16 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/DocGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/DocGenerator.java index f83d7c9..aeb52c2 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/DocGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/DocGenerator.java @@ -12,6 +12,8 @@ import java.util.ServiceLoader; import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.base.reference.Element; +import org.gcube.informationsystem.types.TypeMapper; +import org.gcube.informationsystem.types.reference.Type; import org.gcube.informationsystem.utils.discovery.ElementSpecilizationDiscovery; import org.gcube.informationsystem.utils.discovery.RegistrationProvider; import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator; @@ -90,8 +92,8 @@ public class DocGenerator { File f = getFile(cm); for(Class clz : discovery.getDiscovered()) { - @SuppressWarnings("rawtypes") - DocumentationGenerator dgInstance = cm.getDocumentationGeneratorInstance(clz); + Type type = TypeMapper.createTypeDefinition(clz); + DocumentationGenerator dgInstance = cm.getDocumentationGeneratorInstance(type); StringBuffer sb = dgInstance.generateSection(); Files.write(f.toPath(), sb.toString().getBytes(), StandardOpenOption.APPEND); } @@ -99,8 +101,9 @@ public class DocGenerator { protected void generateSingle(ModelTypes cm) throws Exception { File f = getFile(cm); - @SuppressWarnings("rawtypes") - DocumentationGenerator dgInstance = cm.getDocumentationGeneratorInstance(cm.getAccessType().getTypeClass()); + Class clz = cm.getAccessType().getTypeClass(); + Type type = TypeMapper.createTypeDefinition(clz); + DocumentationGenerator dgInstance = cm.getDocumentationGeneratorInstance(type); StringBuffer sb = dgInstance.generateSection(); Files.write(f.toPath(), sb.toString().getBytes(), StandardOpenOption.APPEND); } diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/ModelTypes.java b/src/main/java/org/gcube/informationsystem/utils/documentation/ModelTypes.java index 4454fd8..f11ebe0 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/ModelTypes.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/ModelTypes.java @@ -3,6 +3,8 @@ package org.gcube.informationsystem.utils.documentation; import java.lang.reflect.Constructor; import org.gcube.informationsystem.base.reference.AccessType; +import org.gcube.informationsystem.types.TypeMapper; +import org.gcube.informationsystem.types.reference.Type; import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator; import org.gcube.informationsystem.utils.documentation.model.entities.EntityDocumentationGenerator; import org.gcube.informationsystem.utils.documentation.model.entities.FacetDocumentationGenerator; @@ -51,9 +53,9 @@ public enum ModelTypes { return dgClz; } - public DocumentationGenerator getDocumentationGeneratorInstance(Class clz) throws Exception { - Constructor constructor = dgClz.getConstructor(clz.getClass()); - return constructor.newInstance(clz); + public DocumentationGenerator getDocumentationGeneratorInstance(Type type) throws Exception { + Constructor constructor = dgClz.getConstructor(Type.class); + return constructor.newInstance(type); } public boolean discover() { diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/model/DocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/model/DocumentationGenerator.java index 45a3048..a644460 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/model/DocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/model/DocumentationGenerator.java @@ -3,11 +3,13 @@ package org.gcube.informationsystem.utils.documentation.model; import java.util.Map; import java.util.Set; -import org.gcube.informationsystem.base.reference.Element; -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.rst.Section; import org.gcube.informationsystem.utils.documentation.rst.Section.SectionType; +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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,20 +17,124 @@ import org.slf4j.LoggerFactory; /** * @author Luca Frosini (ISTI - CNR) */ -public abstract class DocumentationGenerator { +public abstract class DocumentationGenerator { private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class); - protected final Class clz; protected final Type type; protected final String superClassToBeExcluded; - protected DocumentationGenerator(Class clz, String superClassToBeExcluded) { - this.clz = clz; - this.type = TypeMapper.createTypeDefinition(clz); + protected DocumentationGenerator(Type type, String superClassToBeExcluded) { + this.type = type; this.superClassToBeExcluded = superClassToBeExcluded; } + protected Row getPropertiesBoldRow() { + Row row = new Row(RowType.NORMAL); + Cell name = new Cell(); + name.setText("**Name**"); + row.appendCell(name); + Cell type = new Cell(); + type.setText("**Type**"); + row.appendCell(type); + Cell attributes = new Cell(); + attributes.setText("**Attributes**"); + row.appendCell(attributes); + Cell description = new Cell(); + description.setText("**Description**"); + row.appendCell(description); + return row; + } + + + protected Row getPropertiesHeadingRow() { + Row row = new Row(RowType.HEADING); + Cell name = new Cell(); + name.setText("Name"); + row.appendCell(name); + Cell type = new Cell(); + type.setText("Type"); + row.appendCell(type); + Cell attributes = new Cell(); + attributes.setText("Attributes"); + row.appendCell(attributes); + Cell description = new Cell(); + description.setText("Description"); + row.appendCell(description); + return row; + } + + protected String getPropertyAttributes(PropertyDefinition propertyDefinition) { + StringBuffer stringBuffer = new StringBuffer(); + + boolean mandatory = propertyDefinition.isMandatory(); + stringBuffer.append("``Mandatory:"); + stringBuffer.append(mandatory); + + boolean readOnly = propertyDefinition.isReadonly(); + stringBuffer.append("`` ``ReadOnly:"); + stringBuffer.append(readOnly); + + boolean notNull = propertyDefinition.isNotnull(); + stringBuffer.append("`` ``NotNull:"); + stringBuffer.append(notNull); + + String regex = propertyDefinition.getRegexp(); + if(regex!=null && regex.compareTo("")!=0) { + stringBuffer.append("`` ``Regex:"); + stringBuffer.append(regex); + } + + Integer max = propertyDefinition.getMax(); + if(max!=null) { + stringBuffer.append("`` ``Max:"); + stringBuffer.append(max); + } + + Integer min = propertyDefinition.getMin(); + if(min!=null) { + stringBuffer.append("`` ``Min:"); + stringBuffer.append(min); + } + stringBuffer.append("``"); + return stringBuffer.toString(); + } + + protected Row getPropertyRow(PropertyDefinition propertyDefinition) { + Row row = new Row(RowType.NORMAL); + Cell name = new Cell(); + name.setText(propertyDefinition.getName()); + row.appendCell(name); + Cell type = new Cell(); + type.setText(propertyDefinition.getType()); + row.appendCell(type); + Cell attributes = new Cell(); + attributes.setText(getPropertyAttributes(propertyDefinition)); + row.appendCell(attributes); + Cell description = new Cell(); + description.setText(propertyDefinition.getDescription()); + row.appendCell(description); + return row; + } + + protected Row getNoPropertyRow() { + return getRowCellSpan("This type does not define any additional attributes.", 4); + } + + protected Row addCellSpanToRow(Row row, String content, int cellSpan) { + Cell cellToSpan = new Cell(); + cellToSpan.setText(content); + for(int i=0; i { stringBuffer.append(type.getName()); stringBuffer.append("**"); Set superClasses = type.getSuperClasses(); - superClasses.remove(superClassToBeExcluded); + if(superClassToBeExcluded!=null) { + superClasses.remove(superClassToBeExcluded); + } if(superClasses.size()>0){ stringBuffer.append(" ``extends`` "); boolean first = true; @@ -84,7 +192,6 @@ public abstract class DocumentationGenerator { protected abstract Table getTable(); - public StringBuffer generateSection() { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("\n"); diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/EntityDocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/EntityDocumentationGenerator.java index fbaad90..236ab23 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/EntityDocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/EntityDocumentationGenerator.java @@ -1,10 +1,9 @@ package org.gcube.informationsystem.utils.documentation.model.entities; import org.gcube.informationsystem.base.reference.entities.EntityElement; -import org.gcube.informationsystem.model.reference.entities.Entity; import org.gcube.informationsystem.types.TypeMapper; +import org.gcube.informationsystem.types.reference.Type; 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; @@ -12,33 +11,23 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table; /** * @author Luca Frosini (ISTI - CNR) */ -public class EntityDocumentationGenerator extends DocumentationGenerator { +public class EntityDocumentationGenerator extends DocumentationGenerator { - public EntityDocumentationGenerator(Class clz) { - super(clz, TypeMapper.getType(EntityElement.class)); + public EntityDocumentationGenerator(Type type) { + super(type, TypeMapper.getType(EntityElement.class)); } - - protected Row getHeadingRow() { + + protected Row getEntityHeadingRow() { Row row = new Row(RowType.HEADING); - Cell name = new Cell(); - name.setText("Name"); - row.appendCell(name); - Cell type = new Cell(); - type.setText("Type"); - row.appendCell(type); - Cell attributes = new Cell(); - attributes.setText("Attributes"); - row.appendCell(attributes); - Cell description = new Cell(); - description.setText("Description"); - row.appendCell(description); + row = addCellSpanToRow(row, "Properties", 4); return row; } - + @Override protected Table getTable() { Table table = new Table(); - table.appendRow(getHeadingRow()); + table.appendRow(getEntityHeadingRow()); + table.appendRow(getPropertiesBoldRow()); return table; } diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/FacetDocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/FacetDocumentationGenerator.java index 908cd5f..ff3e8c4 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/FacetDocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/FacetDocumentationGenerator.java @@ -1,41 +1,45 @@ package org.gcube.informationsystem.utils.documentation.model.entities; -import org.gcube.informationsystem.model.reference.entities.Facet; -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 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 class FacetDocumentationGenerator extends EntityDocumentationGenerator { - public FacetDocumentationGenerator(Class clz) { - super(clz); - } - - protected Row getHeadingRow() { - Row row = new Row(RowType.HEADING); - Cell name = new Cell(); - name.setText("Name"); - row.appendCell(name); - Cell type = new Cell(); - type.setText("Type"); - row.appendCell(type); - Cell attributes = new Cell(); - attributes.setText("Attributes"); - row.appendCell(attributes); - Cell description = new Cell(); - description.setText("Description"); - row.appendCell(description); - return row; + public FacetDocumentationGenerator(Type type) { + super(type); } @Override protected Table getTable() { Table table = new Table(); - table.appendRow(getHeadingRow()); + table.appendRow(getEntityHeadingRow()); + table.appendRow(getPropertiesBoldRow()); + 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()); + } return table; } diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/ResourceDocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/ResourceDocumentationGenerator.java index 9c6757b..03846de 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/ResourceDocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/ResourceDocumentationGenerator.java @@ -1,6 +1,6 @@ package org.gcube.informationsystem.utils.documentation.model.entities; -import org.gcube.informationsystem.model.reference.entities.Resource; +import org.gcube.informationsystem.types.reference.Type; 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; @@ -9,10 +9,10 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table; /** * @author Luca Frosini (ISTI - CNR) */ -public class ResourceDocumentationGenerator extends EntityDocumentationGenerator { +public class ResourceDocumentationGenerator extends EntityDocumentationGenerator { - public ResourceDocumentationGenerator(Class clz) { - super(clz); + public ResourceDocumentationGenerator(Type type) { + super(type); } protected Row getHeadingRow() { diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/model/properties/PropertyDocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/model/properties/PropertyDocumentationGenerator.java index 95b2244..4acac5d 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/model/properties/PropertyDocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/model/properties/PropertyDocumentationGenerator.java @@ -4,99 +4,26 @@ import java.util.HashSet; import java.util.Set; import org.gcube.informationsystem.base.reference.properties.PropertyElement; -import org.gcube.informationsystem.model.reference.properties.Property; 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.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 PropertyDocumentationGenerator

extends DocumentationGenerator

{ +public class PropertyDocumentationGenerator extends DocumentationGenerator { - public PropertyDocumentationGenerator(Class

clz) { - super(clz, TypeMapper.getType(PropertyElement.class)); - } - - protected Row getHeadingRow() { - Row row = new Row(RowType.HEADING); - Cell name = new Cell(); - name.setText("Name"); - row.appendCell(name); - Cell type = new Cell(); - type.setText("Type"); - row.appendCell(type); - Cell attributes = new Cell(); - attributes.setText("Attributes"); - row.appendCell(attributes); - Cell description = new Cell(); - description.setText("Description"); - row.appendCell(description); - return row; - } - - protected String getPropertyAttributes(PropertyDefinition propertyDefinition) { - StringBuffer stringBuffer = new StringBuffer(); - - boolean mandatory = propertyDefinition.isMandatory(); - stringBuffer.append("``Mandatory:"); - stringBuffer.append(mandatory); - - boolean readOnly = propertyDefinition.isReadonly(); - stringBuffer.append("`` ``ReadOnly:"); - stringBuffer.append(readOnly); - - boolean notNull = propertyDefinition.isNotnull(); - stringBuffer.append("`` ``NotNull:"); - stringBuffer.append(notNull); - - String regex = propertyDefinition.getRegexp(); - if(regex!=null && regex.compareTo("")!=0) { - stringBuffer.append("`` ``Regex:"); - stringBuffer.append(regex); - } - - Integer max = propertyDefinition.getMax(); - if(max!=null) { - stringBuffer.append("`` ``Max:"); - stringBuffer.append(max); - } - - Integer min = propertyDefinition.getMin(); - if(min!=null) { - stringBuffer.append("`` ``Min:"); - stringBuffer.append(min); - } - stringBuffer.append("``"); - return stringBuffer.toString(); - } - - protected Row getPropertyRow(PropertyDefinition propertyDefinition) { - Row row = new Row(RowType.NORMAL); - Cell name = new Cell(); - name.setText(propertyDefinition.getName()); - row.appendCell(name); - Cell type = new Cell(); - type.setText(propertyDefinition.getType()); - row.appendCell(type); - Cell attributes = new Cell(); - attributes.setText(getPropertyAttributes(propertyDefinition)); - row.appendCell(attributes); - Cell description = new Cell(); - description.setText(propertyDefinition.getDescription()); - row.appendCell(description); - return row; + public PropertyDocumentationGenerator(Type type) { + super(type, TypeMapper.getType(PropertyElement.class)); } @Override protected Table getTable() { Table table = new Table(); - table.appendRow(getHeadingRow()); + table.appendRow(getPropertiesHeadingRow()); Set properties = type.getProperties(); if(properties!=null && properties.size()>0) { Set notMandatoryProperties = new HashSet<>(); @@ -119,16 +46,5 @@ public class PropertyDocumentationGenerator

extends Document return table; } - - protected Row getNoPropertyRow() { - Row row = new Row(RowType.NORMAL); - Cell noProp = new Cell(); - noProp.setText("This type does not define any additional attributes."); - row.appendCell(noProp); - row.appendCell(noProp); - row.appendCell(noProp); - row.appendCell(noProp); - return row; - } } diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/ConsistsOfDocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/ConsistsOfDocumentationGenerator.java index 74444a4..5ed3b94 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/ConsistsOfDocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/ConsistsOfDocumentationGenerator.java @@ -1,8 +1,6 @@ package org.gcube.informationsystem.utils.documentation.model.relations; -import org.gcube.informationsystem.model.reference.entities.Facet; -import org.gcube.informationsystem.model.reference.entities.Resource; -import org.gcube.informationsystem.model.reference.relations.ConsistsOf; +import org.gcube.informationsystem.types.reference.Type; 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; @@ -11,10 +9,10 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table; /** * @author Luca Frosini (ISTI - CNR) */ -public class ConsistsOfDocumentationGenerator> extends RelationDocumentationGenerator { +public class ConsistsOfDocumentationGenerator extends RelationDocumentationGenerator { - public ConsistsOfDocumentationGenerator(Class clz) { - super(clz); + public ConsistsOfDocumentationGenerator(Type type) { + super(type); } protected Row getHeadingRow() { diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/IsRelatedToDocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/IsRelatedToDocumentationGenerator.java index a1fb38a..8e07d05 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/IsRelatedToDocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/IsRelatedToDocumentationGenerator.java @@ -1,7 +1,6 @@ package org.gcube.informationsystem.utils.documentation.model.relations; -import org.gcube.informationsystem.model.reference.entities.Resource; -import org.gcube.informationsystem.model.reference.relations.IsRelatedTo; +import org.gcube.informationsystem.types.reference.Type; 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; @@ -10,10 +9,10 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table; /** * @author Luca Frosini (ISTI - CNR) */ -public class IsRelatedToDocumentationGenerator> extends RelationDocumentationGenerator { +public class IsRelatedToDocumentationGenerator extends RelationDocumentationGenerator { - public IsRelatedToDocumentationGenerator(Class clz) { - super(clz); + public IsRelatedToDocumentationGenerator(Type type) { + super(type); } protected Row getHeadingRow() { diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/RelationDocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/RelationDocumentationGenerator.java index 055bf7e..09b7b26 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/RelationDocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/model/relations/RelationDocumentationGenerator.java @@ -1,10 +1,8 @@ package org.gcube.informationsystem.utils.documentation.model.relations; import org.gcube.informationsystem.base.reference.relations.RelationElement; -import org.gcube.informationsystem.model.reference.entities.Entity; -import org.gcube.informationsystem.model.reference.entities.Resource; -import org.gcube.informationsystem.model.reference.relations.Relation; import org.gcube.informationsystem.types.TypeMapper; +import org.gcube.informationsystem.types.reference.Type; 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; @@ -14,10 +12,10 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table; /** * @author Luca Frosini (ISTI - CNR) */ -public class RelationDocumentationGenerator> extends DocumentationGenerator { +public class RelationDocumentationGenerator extends DocumentationGenerator { - public RelationDocumentationGenerator(Class clz) { - super(clz, TypeMapper.getType(RelationElement.class)); + public RelationDocumentationGenerator(Type type) { + super(type, TypeMapper.getType(RelationElement.class)); } protected Row getHeadingRow() { diff --git a/src/test/java/org/gcube/informationsystem/utils/documentation/GenerateTest.java b/src/test/java/org/gcube/informationsystem/utils/documentation/GenerateTest.java index 9515c4b..92667db 100644 --- a/src/test/java/org/gcube/informationsystem/utils/documentation/GenerateTest.java +++ b/src/test/java/org/gcube/informationsystem/utils/documentation/GenerateTest.java @@ -4,16 +4,12 @@ import java.io.File; import java.net.URL; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @author Luca Frosini (ISTI - CNR) */ public class GenerateTest { - private static final Logger logger = LoggerFactory.getLogger(GenerateTest.class); - @Test public void testDocGeneration() throws Exception { URL jsonFileURL = this.getClass().getClassLoader().getResource("logback-test.xml"); diff --git a/src/test/java/org/gcube/informationsystem/utils/documentation/table/TableTest.java b/src/test/java/org/gcube/informationsystem/utils/documentation/table/TableTest.java index 0628750..5b8edb2 100644 --- a/src/test/java/org/gcube/informationsystem/utils/documentation/table/TableTest.java +++ b/src/test/java/org/gcube/informationsystem/utils/documentation/table/TableTest.java @@ -15,7 +15,7 @@ public class TableTest { private static final Logger logger = LoggerFactory.getLogger(TableTest.class); - @Test + // @Test public void test() throws Exception { Table table = new Table();