Refactoring
This commit is contained in:
parent
a46b1d9ac3
commit
de836a6eeb
|
@ -9,14 +9,14 @@ import org.gcube.informationsystem.base.reference.AccessType;
|
|||
import org.gcube.informationsystem.discovery.knowledge.ModelKnowledge;
|
||||
import org.gcube.informationsystem.discovery.knowledge.UsageKnowledge;
|
||||
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;
|
||||
import org.gcube.informationsystem.utils.documentation.model.entities.ResourceDocumentationGenerator;
|
||||
import org.gcube.informationsystem.utils.documentation.model.properties.PropertyDocumentationGenerator;
|
||||
import org.gcube.informationsystem.utils.documentation.model.relations.ConsistsOfDocumentationGenerator;
|
||||
import org.gcube.informationsystem.utils.documentation.model.relations.IsRelatedToDocumentationGenerator;
|
||||
import org.gcube.informationsystem.utils.documentation.model.relations.RelationDocumentationGenerator;
|
||||
import org.gcube.informationsystem.utils.documentation.model.Documentation;
|
||||
import org.gcube.informationsystem.utils.documentation.model.entities.EntityDocumentation;
|
||||
import org.gcube.informationsystem.utils.documentation.model.entities.FacetDocumentation;
|
||||
import org.gcube.informationsystem.utils.documentation.model.entities.ResourceDocumentation;
|
||||
import org.gcube.informationsystem.utils.documentation.model.properties.PropertyDocumentation;
|
||||
import org.gcube.informationsystem.utils.documentation.model.relations.ConsistsOfDocumentation;
|
||||
import org.gcube.informationsystem.utils.documentation.model.relations.IsRelatedToDocumentation;
|
||||
import org.gcube.informationsystem.utils.documentation.model.relations.RelationDocumentation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -37,36 +37,36 @@ public class Generator {
|
|||
return modelKnowledge;
|
||||
}
|
||||
|
||||
public Class<? extends DocumentationGenerator> getDocumentationGeneratorClass(AccessType accessType)
|
||||
public Class<? extends Documentation> getDocumentationGeneratorClass(AccessType accessType)
|
||||
throws Exception {
|
||||
Class<? extends DocumentationGenerator> clz;
|
||||
Class<? extends Documentation> clz;
|
||||
switch (accessType) {
|
||||
case PROPERTY:
|
||||
clz = PropertyDocumentationGenerator.class;
|
||||
clz = PropertyDocumentation.class;
|
||||
break;
|
||||
|
||||
case ENTITY:
|
||||
clz = EntityDocumentationGenerator.class;
|
||||
clz = EntityDocumentation.class;
|
||||
break;
|
||||
|
||||
case RESOURCE:
|
||||
clz = ResourceDocumentationGenerator.class;
|
||||
clz = ResourceDocumentation.class;
|
||||
break;
|
||||
|
||||
case FACET:
|
||||
clz = FacetDocumentationGenerator.class;
|
||||
clz = FacetDocumentation.class;
|
||||
break;
|
||||
|
||||
case RELATION:
|
||||
clz = RelationDocumentationGenerator.class;
|
||||
clz = RelationDocumentation.class;
|
||||
break;
|
||||
|
||||
case IS_RELATED_TO:
|
||||
clz = IsRelatedToDocumentationGenerator.class;
|
||||
clz = IsRelatedToDocumentation.class;
|
||||
break;
|
||||
|
||||
case CONSISTS_OF:
|
||||
clz = ConsistsOfDocumentationGenerator.class;
|
||||
clz = ConsistsOfDocumentation.class;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -75,41 +75,41 @@ public class Generator {
|
|||
return clz;
|
||||
}
|
||||
|
||||
protected DocumentationGenerator getDocumentationGenerator(Type type) throws Exception {
|
||||
DocumentationGenerator dg = null;
|
||||
protected Documentation getDocumentationGenerator(Type type) throws Exception {
|
||||
Documentation dg = null;
|
||||
switch (type.getAccessType()) {
|
||||
case PROPERTY:
|
||||
dg = new PropertyDocumentationGenerator(type);
|
||||
dg = new PropertyDocumentation(type);
|
||||
dg.setLevel(0);
|
||||
break;
|
||||
|
||||
case ENTITY:
|
||||
dg = new EntityDocumentationGenerator(type);
|
||||
dg = new EntityDocumentation(type);
|
||||
dg.setLevel(0);
|
||||
break;
|
||||
|
||||
case RESOURCE:
|
||||
dg = new ResourceDocumentationGenerator(type);
|
||||
dg = new ResourceDocumentation(type);
|
||||
dg.setLevel(1);
|
||||
break;
|
||||
|
||||
case FACET:
|
||||
dg = new FacetDocumentationGenerator(type);
|
||||
dg = new FacetDocumentation(type);
|
||||
dg.setLevel(1);
|
||||
break;
|
||||
|
||||
case RELATION:
|
||||
dg = new RelationDocumentationGenerator(type);
|
||||
dg = new RelationDocumentation(type);
|
||||
dg.setLevel(0);
|
||||
break;
|
||||
|
||||
case IS_RELATED_TO:
|
||||
dg = new IsRelatedToDocumentationGenerator(type);
|
||||
dg = new IsRelatedToDocumentation(type);
|
||||
dg.setLevel(1);
|
||||
break;
|
||||
|
||||
case CONSISTS_OF:
|
||||
dg = new ConsistsOfDocumentationGenerator(type);
|
||||
dg = new ConsistsOfDocumentation(type);
|
||||
dg.setLevel(1);
|
||||
break;
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class Generator {
|
|||
}
|
||||
|
||||
protected void writeSectionOnly(Type type, File file, Integer level) throws Exception {
|
||||
DocumentationGenerator dg = getDocumentationGenerator(type);
|
||||
Documentation dg = getDocumentationGenerator(type);
|
||||
if(level!=null) {
|
||||
dg.setLevel(level);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class Generator {
|
|||
}
|
||||
|
||||
protected void writeTypeToFile(Type type, File file, Integer level) throws Exception {
|
||||
DocumentationGenerator dg = getDocumentationGenerator(type);
|
||||
Documentation dg = getDocumentationGenerator(type);
|
||||
if(level!=null) {
|
||||
dg.setLevel(level);
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ import org.slf4j.LoggerFactory;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public abstract class DocumentationGenerator {
|
||||
public abstract class Documentation {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(Documentation.class);
|
||||
|
||||
private static final int DEFAULT_NUMBER_OF_COLUMNS = 5;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public abstract class DocumentationGenerator {
|
|||
}
|
||||
|
||||
public static void setDefaultOffsetLevel(int defaultOffsetLevel) {
|
||||
DocumentationGenerator.defaultOffsetLevel = defaultOffsetLevel;
|
||||
Documentation.defaultOffsetLevel = defaultOffsetLevel;
|
||||
}
|
||||
|
||||
protected final Type type;
|
||||
|
@ -67,7 +67,7 @@ public abstract class DocumentationGenerator {
|
|||
this.resourceKnowledge = resourceKnowledge;
|
||||
}
|
||||
|
||||
protected DocumentationGenerator(Type type, AccessType requiredType) {
|
||||
protected Documentation(Type type, AccessType requiredType) {
|
||||
this.type = type;
|
||||
this.requiredType = requiredType;
|
||||
AccessType accessType = type.getAccessType();
|
||||
|
@ -76,7 +76,7 @@ public abstract class DocumentationGenerator {
|
|||
}
|
||||
this.requiredNumberOfColumns = DEFAULT_NUMBER_OF_COLUMNS;
|
||||
this.superClassToBeExcluded = null;
|
||||
this.offsetLevel = DocumentationGenerator.defaultOffsetLevel;
|
||||
this.offsetLevel = Documentation.defaultOffsetLevel;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
|
@ -8,7 +8,7 @@ import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
|||
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.model.Documentation;
|
||||
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;
|
||||
|
@ -16,16 +16,16 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class EntityDocumentationGenerator extends DocumentationGenerator {
|
||||
public class EntityDocumentation extends Documentation {
|
||||
|
||||
public EntityDocumentationGenerator(Type type) {
|
||||
public EntityDocumentation(Type type) {
|
||||
super(type, AccessType.ENTITY);
|
||||
this.requiredNumberOfColumns = 4;
|
||||
this.superClassToBeExcluded = TypeMapper.getType(EntityElement.class);
|
||||
setLevel(0);
|
||||
}
|
||||
|
||||
protected EntityDocumentationGenerator(Type type, AccessType requiredType) {
|
||||
protected EntityDocumentation(Type type, AccessType requiredType) {
|
||||
super(type, requiredType);
|
||||
}
|
||||
|
|
@ -11,9 +11,9 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class FacetDocumentationGenerator extends EntityDocumentationGenerator {
|
||||
public class FacetDocumentation extends EntityDocumentation {
|
||||
|
||||
public FacetDocumentationGenerator(Type type) {
|
||||
public FacetDocumentation(Type type) {
|
||||
super(type, AccessType.FACET);
|
||||
int level = 1;
|
||||
if(type.getName().compareTo(requiredType.getName())!=0) {
|
|
@ -11,14 +11,14 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ResourceDocumentationGenerator extends EntityDocumentationGenerator {
|
||||
public class ResourceDocumentation extends EntityDocumentation {
|
||||
|
||||
public static final String FACETS_TABLE_HEADING = "**Facets**";
|
||||
public static final String RESOURCE_RELATIONS_TABLE_HEADING = "**Resource Relations**";
|
||||
public static final String NO_SPECIFIC_FACETS = "No specific facets usage defined for this type.";
|
||||
public static final String NO_SPECIFIC_RESOURCE_RELATIONS = "No specific Resource relations defined for this type.";
|
||||
|
||||
public ResourceDocumentationGenerator(Type type) {
|
||||
public ResourceDocumentation(Type type) {
|
||||
super(type,AccessType.RESOURCE);
|
||||
int level = 1;
|
||||
if(type.getName().compareTo(requiredType.getName())!=0) {
|
|
@ -8,15 +8,15 @@ import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
|||
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.model.Documentation;
|
||||
import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class PropertyDocumentationGenerator extends DocumentationGenerator {
|
||||
public class PropertyDocumentation extends Documentation {
|
||||
|
||||
public PropertyDocumentationGenerator(Type type) {
|
||||
public PropertyDocumentation(Type type) {
|
||||
super(type, AccessType.PROPERTY);
|
||||
this.requiredNumberOfColumns = 4;
|
||||
this.superClassToBeExcluded = TypeMapper.getType(PropertyElement.class);
|
|
@ -10,9 +10,9 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ConsistsOfDocumentationGenerator extends RelationDocumentationGenerator {
|
||||
public class ConsistsOfDocumentation extends RelationDocumentation {
|
||||
|
||||
public ConsistsOfDocumentationGenerator(Type type) {
|
||||
public ConsistsOfDocumentation(Type type) {
|
||||
super(type, AccessType.CONSISTS_OF);
|
||||
int level = 1;
|
||||
if(type.getName().compareTo(requiredType.getName())!=0) {
|
|
@ -10,9 +10,9 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class IsRelatedToDocumentationGenerator extends RelationDocumentationGenerator {
|
||||
public class IsRelatedToDocumentation extends RelationDocumentation {
|
||||
|
||||
public IsRelatedToDocumentationGenerator(Type type) {
|
||||
public IsRelatedToDocumentation(Type type) {
|
||||
super(type, AccessType.IS_RELATED_TO);
|
||||
int level = 1;
|
||||
if(type.getName().compareTo(requiredType.getName())!=0) {
|
|
@ -9,7 +9,7 @@ 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.model.Documentation;
|
||||
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;
|
||||
|
@ -18,15 +18,15 @@ import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class RelationDocumentationGenerator extends DocumentationGenerator {
|
||||
public class RelationDocumentation extends Documentation {
|
||||
|
||||
public RelationDocumentationGenerator(Type type) {
|
||||
public RelationDocumentation(Type type) {
|
||||
super(type, AccessType.RELATION);
|
||||
this.superClassToBeExcluded = TypeMapper.getType(RelationElement.class);
|
||||
setLevel(0);
|
||||
}
|
||||
|
||||
protected RelationDocumentationGenerator(Type type, AccessType requiredType) {
|
||||
protected RelationDocumentation(Type type, AccessType requiredType) {
|
||||
super(type, requiredType);
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ import org.gcube.informationsystem.discovery.RegistrationProvider;
|
|||
import org.gcube.informationsystem.discovery.knowledge.ModelKnowledge;
|
||||
import org.gcube.informationsystem.tree.Tree;
|
||||
import org.gcube.informationsystem.utils.documentation.generator.TreeGenerator;
|
||||
import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator;
|
||||
import org.gcube.informationsystem.utils.documentation.model.Documentation;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -23,7 +23,7 @@ public class GenerateTest {
|
|||
|
||||
@Test
|
||||
public void testDocGeneration() throws Exception {
|
||||
DocumentationGenerator.setDefaultOffsetLevel(2);
|
||||
Documentation.setDefaultOffsetLevel(2);
|
||||
|
||||
ServiceLoader<? extends RegistrationProvider> registrationProviders = ServiceLoader
|
||||
.load(RegistrationProvider.class);
|
||||
|
|
Loading…
Reference in New Issue