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();