Fixed knowledge creation
This commit is contained in:
parent
d83136ef0f
commit
980876eb0b
|
@ -19,6 +19,7 @@ import org.gcube.informationsystem.utils.documentation.knowledge.Node;
|
|||
import org.gcube.informationsystem.utils.documentation.knowledge.NodeElaborator;
|
||||
import org.gcube.informationsystem.utils.documentation.knowledge.Tree;
|
||||
import org.gcube.informationsystem.utils.documentation.model.DocumentationGenerator;
|
||||
import org.gcube.informationsystem.utils.documentation.model.entities.ResourceDocumentationGenerator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -71,12 +72,10 @@ public class TreeGenerator extends Generator {
|
|||
tree.addNode(type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void elaborateTree(final AccessType at, Tree tree, final File file) throws Exception {
|
||||
logger.debug("Going to elaborate the following type tree\n{}", tree.toString());
|
||||
|
||||
NodeElaborator ne = new NodeElaborator() {
|
||||
NodeElaborator documentationNE = new NodeElaborator() {
|
||||
|
||||
protected void writeSectionOnly(Type type, int level) throws Exception {
|
||||
DocumentationGenerator dg = getDocumentationGenerator(type);
|
||||
|
@ -108,15 +107,33 @@ public class TreeGenerator extends Generator {
|
|||
}
|
||||
};
|
||||
|
||||
tree.elaborate(ne);
|
||||
tree.elaborate(documentationNE);
|
||||
}
|
||||
|
||||
|
||||
public void createUsageKnowledge(Tree tree) throws Exception {
|
||||
|
||||
NodeElaborator usageKnowledgeNE = new NodeElaborator() {
|
||||
|
||||
@Override
|
||||
public void elaborate(Node node, int level) throws Exception {
|
||||
Type type = node.getType();
|
||||
ResourceDocumentationGenerator dg = new ResourceDocumentationGenerator(type);
|
||||
dg.createUsageKnowledge();
|
||||
}
|
||||
};
|
||||
|
||||
tree.elaborate(usageKnowledgeNE);
|
||||
}
|
||||
|
||||
public void generate() throws Exception {
|
||||
|
||||
File is = getFile(IS_MODEL_FILENAME, true);
|
||||
File file = null;
|
||||
|
||||
Tree resourcesTree = types.get(AccessType.RESOURCE);
|
||||
createUsageKnowledge(resourcesTree);
|
||||
|
||||
for(AccessType at : accessTypes) {
|
||||
Type type = TypeMapper.createTypeDefinition(at.getTypeClass());
|
||||
writeTypeToFile(type, is);
|
||||
|
|
|
@ -26,11 +26,6 @@ public class ResourceDocumentationGenerator extends EntityDocumentationGenerator
|
|||
++level;
|
||||
}
|
||||
setLevel(level);
|
||||
ResourceType rt = (ResourceType) type;
|
||||
UsageKnowledge fk = UsageKnowledge.getFacetKnowledge();
|
||||
fk.addAll(rt.getFacets());
|
||||
UsageKnowledge rk = UsageKnowledge.getResourceKnowledge();
|
||||
rk.addAll(rt.getResources());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,5 +43,13 @@ public class ResourceDocumentationGenerator extends EntityDocumentationGenerator
|
|||
addLinkedEntities(table, resources, NO_SPECIFIC_RESOURCE_RELATIONS);
|
||||
return table;
|
||||
}
|
||||
|
||||
public void createUsageKnowledge() throws Exception {
|
||||
ResourceType rt = (ResourceType) type;
|
||||
UsageKnowledge fk = UsageKnowledge.getFacetKnowledge();
|
||||
fk.addAll(rt.getFacets());
|
||||
UsageKnowledge rk = UsageKnowledge.getResourceKnowledge();
|
||||
rk.addAll(rt.getResources());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue