Improving code

This commit is contained in:
Luca Frosini 2023-01-20 10:27:07 +01:00
parent 25fad84b2d
commit 82f2c26b3e
15 changed files with 211 additions and 177 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
/target/ /target/
/entities.rst
/properties.rst
/relations.rst

View File

@ -5,6 +5,11 @@
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name> <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments> <arguments>

View File

@ -1,2 +1,16 @@
eclipse.preferences.version=1 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.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

View File

@ -12,6 +12,8 @@ import java.util.ServiceLoader;
import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.Element; 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.ElementSpecilizationDiscovery;
import org.gcube.informationsystem.utils.discovery.RegistrationProvider; import org.gcube.informationsystem.utils.discovery.RegistrationProvider;
import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator; import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator;
@ -90,8 +92,8 @@ public class DocGenerator {
File f = getFile(cm); File f = getFile(cm);
for(Class<? extends E> clz : discovery.getDiscovered()) { for(Class<? extends E> clz : discovery.getDiscovered()) {
@SuppressWarnings("rawtypes") Type type = TypeMapper.createTypeDefinition(clz);
DocumentationGenerator dgInstance = cm.getDocumentationGeneratorInstance(clz); DocumentationGenerator dgInstance = cm.getDocumentationGeneratorInstance(type);
StringBuffer sb = dgInstance.generateSection(); StringBuffer sb = dgInstance.generateSection();
Files.write(f.toPath(), sb.toString().getBytes(), StandardOpenOption.APPEND); Files.write(f.toPath(), sb.toString().getBytes(), StandardOpenOption.APPEND);
} }
@ -99,8 +101,9 @@ public class DocGenerator {
protected void generateSingle(ModelTypes cm) throws Exception { protected void generateSingle(ModelTypes cm) throws Exception {
File f = getFile(cm); File f = getFile(cm);
@SuppressWarnings("rawtypes") Class<? extends Element> clz = cm.getAccessType().getTypeClass();
DocumentationGenerator dgInstance = cm.getDocumentationGeneratorInstance(cm.getAccessType().getTypeClass()); Type type = TypeMapper.createTypeDefinition(clz);
DocumentationGenerator dgInstance = cm.getDocumentationGeneratorInstance(type);
StringBuffer sb = dgInstance.generateSection(); StringBuffer sb = dgInstance.generateSection();
Files.write(f.toPath(), sb.toString().getBytes(), StandardOpenOption.APPEND); Files.write(f.toPath(), sb.toString().getBytes(), StandardOpenOption.APPEND);
} }

View File

@ -3,6 +3,8 @@ package org.gcube.informationsystem.utils.documentation;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import org.gcube.informationsystem.base.reference.AccessType; 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.DocumentationGenerator;
import org.gcube.informationsystem.utils.documentation.model.entities.EntityDocumentationGenerator; import org.gcube.informationsystem.utils.documentation.model.entities.EntityDocumentationGenerator;
import org.gcube.informationsystem.utils.documentation.model.entities.FacetDocumentationGenerator; import org.gcube.informationsystem.utils.documentation.model.entities.FacetDocumentationGenerator;
@ -51,9 +53,9 @@ public enum ModelTypes {
return dgClz; return dgClz;
} }
public DocumentationGenerator getDocumentationGeneratorInstance(Class clz) throws Exception { public DocumentationGenerator getDocumentationGeneratorInstance(Type type) throws Exception {
Constructor<? extends DocumentationGenerator> constructor = dgClz.getConstructor(clz.getClass()); Constructor<? extends DocumentationGenerator> constructor = dgClz.getConstructor(Type.class);
return constructor.newInstance(clz); return constructor.newInstance(type);
} }
public boolean discover() { public boolean discover() {

View File

@ -3,11 +3,13 @@ package org.gcube.informationsystem.utils.documentation.model;
import java.util.Map; import java.util.Map;
import java.util.Set; 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.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;
import org.gcube.informationsystem.utils.documentation.rst.Section.SectionType; 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.gcube.informationsystem.utils.documentation.rst.table.Table;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -15,20 +17,124 @@ import org.slf4j.LoggerFactory;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */
public abstract class DocumentationGenerator<E extends Element> { public abstract class DocumentationGenerator {
private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class); private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class);
protected final Class<E> clz;
protected final Type type; protected final Type type;
protected final String superClassToBeExcluded; protected final String superClassToBeExcluded;
protected DocumentationGenerator(Class<E> clz, String superClassToBeExcluded) { protected DocumentationGenerator(Type type, String superClassToBeExcluded) {
this.clz = clz; this.type = type;
this.type = TypeMapper.createTypeDefinition(clz);
this.superClassToBeExcluded = superClassToBeExcluded; 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<cellSpan; i++) {
row.appendCell(cellToSpan);
}
return row;
}
protected Row getRowCellSpan(String content, int cellSpan) {
Row row = new Row(RowType.NORMAL);
return addCellSpanToRow(row, content, cellSpan);
}
/* /*
* E.g. GCubeProperty extends Property * E.g. GCubeProperty extends Property
*/ */
@ -38,7 +144,9 @@ public abstract class DocumentationGenerator<E extends Element> {
stringBuffer.append(type.getName()); stringBuffer.append(type.getName());
stringBuffer.append("**"); stringBuffer.append("**");
Set<String> superClasses = type.getSuperClasses(); Set<String> superClasses = type.getSuperClasses();
superClasses.remove(superClassToBeExcluded); if(superClassToBeExcluded!=null) {
superClasses.remove(superClassToBeExcluded);
}
if(superClasses.size()>0){ if(superClasses.size()>0){
stringBuffer.append(" ``extends`` "); stringBuffer.append(" ``extends`` ");
boolean first = true; boolean first = true;
@ -84,7 +192,6 @@ public abstract class DocumentationGenerator<E extends Element> {
protected abstract Table getTable(); protected abstract Table getTable();
public StringBuffer generateSection() { public StringBuffer generateSection() {
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("\n"); stringBuffer.append("\n");

View File

@ -1,10 +1,9 @@
package org.gcube.informationsystem.utils.documentation.model.entities; package org.gcube.informationsystem.utils.documentation.model.entities;
import org.gcube.informationsystem.base.reference.entities.EntityElement; 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.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator; 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.Row;
import org.gcube.informationsystem.utils.documentation.rst.table.RowType; import org.gcube.informationsystem.utils.documentation.rst.table.RowType;
import org.gcube.informationsystem.utils.documentation.rst.table.Table; 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) * @author Luca Frosini (ISTI - CNR)
*/ */
public class EntityDocumentationGenerator<E extends Entity> extends DocumentationGenerator<E> { public class EntityDocumentationGenerator extends DocumentationGenerator {
public EntityDocumentationGenerator(Class<E> clz) { public EntityDocumentationGenerator(Type type) {
super(clz, TypeMapper.getType(EntityElement.class)); super(type, TypeMapper.getType(EntityElement.class));
} }
protected Row getHeadingRow() { protected Row getEntityHeadingRow() {
Row row = new Row(RowType.HEADING); Row row = new Row(RowType.HEADING);
Cell name = new Cell(); row = addCellSpanToRow(row, "Properties", 4);
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; return row;
} }
@Override @Override
protected Table getTable() { protected Table getTable() {
Table table = new Table(); Table table = new Table();
table.appendRow(getHeadingRow()); table.appendRow(getEntityHeadingRow());
table.appendRow(getPropertiesBoldRow());
return table; return table;
} }

View File

@ -1,41 +1,45 @@
package org.gcube.informationsystem.utils.documentation.model.entities; package org.gcube.informationsystem.utils.documentation.model.entities;
import org.gcube.informationsystem.model.reference.entities.Facet; import java.util.HashSet;
import org.gcube.informationsystem.utils.documentation.rst.table.Cell; import java.util.Set;
import org.gcube.informationsystem.utils.documentation.rst.table.Row;
import org.gcube.informationsystem.utils.documentation.rst.table.RowType; import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
import org.gcube.informationsystem.utils.documentation.rst.table.Table; import org.gcube.informationsystem.utils.documentation.rst.table.Table;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */
public class FacetDocumentationGenerator<F extends Facet> extends EntityDocumentationGenerator<F> { public class FacetDocumentationGenerator extends EntityDocumentationGenerator {
public FacetDocumentationGenerator(Class<F> clz) { public FacetDocumentationGenerator(Type type) {
super(clz); super(type);
}
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;
} }
@Override @Override
protected Table getTable() { protected Table getTable() {
Table table = new Table(); Table table = new Table();
table.appendRow(getHeadingRow()); table.appendRow(getEntityHeadingRow());
table.appendRow(getPropertiesBoldRow());
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());
}
return table; return table;
} }

View File

@ -1,6 +1,6 @@
package org.gcube.informationsystem.utils.documentation.model.entities; 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.Cell;
import org.gcube.informationsystem.utils.documentation.rst.table.Row; 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.RowType;
@ -9,10 +9,10 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */
public class ResourceDocumentationGenerator<R extends Resource> extends EntityDocumentationGenerator<R> { public class ResourceDocumentationGenerator extends EntityDocumentationGenerator {
public ResourceDocumentationGenerator(Class<R> clz) { public ResourceDocumentationGenerator(Type type) {
super(clz); super(type);
} }
protected Row getHeadingRow() { protected Row getHeadingRow() {

View File

@ -4,99 +4,26 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.gcube.informationsystem.base.reference.properties.PropertyElement; 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.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator; 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; import org.gcube.informationsystem.utils.documentation.rst.table.Table;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */
public class PropertyDocumentationGenerator<P extends Property> extends DocumentationGenerator<P> { public class PropertyDocumentationGenerator extends DocumentationGenerator {
public PropertyDocumentationGenerator(Class<P> clz) { public PropertyDocumentationGenerator(Type type) {
super(clz, TypeMapper.getType(PropertyElement.class)); super(type, 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;
} }
@Override @Override
protected Table getTable() { protected Table getTable() {
Table table = new Table(); Table table = new Table();
table.appendRow(getHeadingRow()); table.appendRow(getPropertiesHeadingRow());
Set<PropertyDefinition> properties = type.getProperties(); Set<PropertyDefinition> properties = type.getProperties();
if(properties!=null && properties.size()>0) { if(properties!=null && properties.size()>0) {
Set<PropertyDefinition> notMandatoryProperties = new HashSet<>(); Set<PropertyDefinition> notMandatoryProperties = new HashSet<>();
@ -119,16 +46,5 @@ public class PropertyDocumentationGenerator<P extends Property> extends Document
return table; 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;
}
} }

View File

@ -1,8 +1,6 @@
package org.gcube.informationsystem.utils.documentation.model.relations; package org.gcube.informationsystem.utils.documentation.model.relations;
import org.gcube.informationsystem.model.reference.entities.Facet; import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.utils.documentation.rst.table.Cell; 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.Row;
import org.gcube.informationsystem.utils.documentation.rst.table.RowType; 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) * @author Luca Frosini (ISTI - CNR)
*/ */
public class ConsistsOfDocumentationGenerator<CO extends ConsistsOf<Resource, Facet>> extends RelationDocumentationGenerator<CO> { public class ConsistsOfDocumentationGenerator extends RelationDocumentationGenerator {
public ConsistsOfDocumentationGenerator(Class<CO> clz) { public ConsistsOfDocumentationGenerator(Type type) {
super(clz); super(type);
} }
protected Row getHeadingRow() { protected Row getHeadingRow() {

View File

@ -1,7 +1,6 @@
package org.gcube.informationsystem.utils.documentation.model.relations; package org.gcube.informationsystem.utils.documentation.model.relations;
import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
import org.gcube.informationsystem.utils.documentation.rst.table.Cell; 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.Row;
import org.gcube.informationsystem.utils.documentation.rst.table.RowType; 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) * @author Luca Frosini (ISTI - CNR)
*/ */
public class IsRelatedToDocumentationGenerator<IRT extends IsRelatedTo<Resource, Resource>> extends RelationDocumentationGenerator<IRT> { public class IsRelatedToDocumentationGenerator extends RelationDocumentationGenerator {
public IsRelatedToDocumentationGenerator(Class<IRT> clz) { public IsRelatedToDocumentationGenerator(Type type) {
super(clz); super(type);
} }
protected Row getHeadingRow() { protected Row getHeadingRow() {

View File

@ -1,10 +1,8 @@
package org.gcube.informationsystem.utils.documentation.model.relations; package org.gcube.informationsystem.utils.documentation.model.relations;
import org.gcube.informationsystem.base.reference.relations.RelationElement; 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.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator; 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.Cell;
import org.gcube.informationsystem.utils.documentation.rst.table.Row; 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) * @author Luca Frosini (ISTI - CNR)
*/ */
public class RelationDocumentationGenerator<R extends Relation<? extends Resource, ? extends Entity>> extends DocumentationGenerator<R> { public class RelationDocumentationGenerator extends DocumentationGenerator {
public RelationDocumentationGenerator(Class<R> clz) { public RelationDocumentationGenerator(Type type) {
super(clz, TypeMapper.getType(RelationElement.class)); super(type, TypeMapper.getType(RelationElement.class));
} }
protected Row getHeadingRow() { protected Row getHeadingRow() {

View File

@ -4,16 +4,12 @@ import java.io.File;
import java.net.URL; import java.net.URL;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */
public class GenerateTest { public class GenerateTest {
private static final Logger logger = LoggerFactory.getLogger(GenerateTest.class);
@Test @Test
public void testDocGeneration() throws Exception { public void testDocGeneration() throws Exception {
URL jsonFileURL = this.getClass().getClassLoader().getResource("logback-test.xml"); URL jsonFileURL = this.getClass().getClassLoader().getResource("logback-test.xml");

View File

@ -15,7 +15,7 @@ public class TableTest {
private static final Logger logger = LoggerFactory.getLogger(TableTest.class); private static final Logger logger = LoggerFactory.getLogger(TableTest.class);
@Test // @Test
public void test() throws Exception { public void test() throws Exception {
Table table = new Table(); Table table = new Table();