Improved solution
This commit is contained in:
parent
980876eb0b
commit
477364477c
|
@ -29,5 +29,10 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -54,7 +54,11 @@ public class ClassesDiscoveryGenerator extends Generator {
|
|||
}
|
||||
|
||||
protected <E extends Element> void discover(AccessType at, Package[] packages) throws Exception {
|
||||
ElementSpecilizationDiscovery<E> discovery = new ElementSpecilizationDiscovery<>(at.getTypeClass());
|
||||
/*
|
||||
* I need to get all types also the types defined in IS Model
|
||||
* to properly support the specilizations if any
|
||||
*/
|
||||
ElementSpecilizationDiscovery<E> discovery = new ElementSpecilizationDiscovery<>(at.getTypeClass(), true);
|
||||
if(Objects.nonNull(packages)) {
|
||||
Arrays.stream(packages).forEach(p -> discovery.addPackage(p));
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class TreeGenerator extends Generator {
|
|||
}
|
||||
|
||||
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());
|
||||
logger.info("Going to elaborate the following type tree\n{}", tree.toString());
|
||||
|
||||
NodeElaborator documentationNE = new NodeElaborator() {
|
||||
|
||||
|
@ -131,9 +131,6 @@ public class TreeGenerator extends Generator {
|
|||
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);
|
||||
|
|
|
@ -3,7 +3,9 @@ package org.gcube.informationsystem.utils.documentation.knowledge;
|
|||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -26,20 +28,36 @@ public class Tree {
|
|||
this.allowMultipleInheritance = allowMultipleInheritance;
|
||||
}
|
||||
|
||||
public void addNode(Type t) {
|
||||
if(root.getType().getName().compareTo(t.getName())==0) {
|
||||
public void createUsageKnowledge(Type type) {
|
||||
if(type.getAccessType() != AccessType.RESOURCE) {
|
||||
return;
|
||||
}
|
||||
ResourceType rt = (ResourceType) type;
|
||||
UsageKnowledge fk = UsageKnowledge.getFacetKnowledge();
|
||||
fk.addAll(rt.getFacets());
|
||||
UsageKnowledge rk = UsageKnowledge.getResourceKnowledge();
|
||||
rk.addAll(rt.getResources());
|
||||
}
|
||||
|
||||
public void addNode(Type type) {
|
||||
if(root.getType().getName().compareTo(type.getName())==0) {
|
||||
// Root has been already added
|
||||
return;
|
||||
}
|
||||
Set<String> superClasses = t.getSuperClasses();
|
||||
|
||||
createUsageKnowledge(type);
|
||||
|
||||
Set<String> superClasses = type.getSuperClasses();
|
||||
|
||||
String name = type.getName();
|
||||
for(String superClass : superClasses) {
|
||||
Node parent = locate.get(superClass);
|
||||
if(parent==null) {
|
||||
throw new RuntimeException("I can find parent Node for " + t.getName() + ". Missing parent is " + superClass);
|
||||
throw new RuntimeException("I can find parent Node for " + name + ". Missing parent is " + superClass);
|
||||
}
|
||||
Node node = new Node(t);
|
||||
Node node = new Node(type);
|
||||
parent.addChild(node);
|
||||
locate.put(t.getName(), node);
|
||||
locate.put(name, node);
|
||||
if(!allowMultipleInheritance) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -44,12 +44,4 @@ public class ResourceDocumentationGenerator extends EntityDocumentationGenerator
|
|||
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