Improved solution
This commit is contained in:
parent
d1d9ae4a4a
commit
ff0c6aec9d
|
@ -12,6 +12,7 @@ import java.util.Set;
|
|||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
|
@ -113,11 +114,16 @@ public class ModelKnowledge<T, NI extends NodeInformation<T>> {
|
|||
}
|
||||
}
|
||||
|
||||
protected void addMetadataUsage(T t) {
|
||||
protected void addEntityMetadataUsage(T t) {
|
||||
Type type = TypeMapper.createTypeDefinition(EntityElement.class);
|
||||
addPropertyUsage(t, type.getProperties());
|
||||
}
|
||||
|
||||
protected void addRelationMetadataUsage(T t) {
|
||||
Type type = TypeMapper.createTypeDefinition(RelationElement.class);
|
||||
addPropertyUsage(t, type.getProperties());
|
||||
}
|
||||
|
||||
protected void addPropagationConstraintUsage(T t) {
|
||||
Type type = TypeMapper.createTypeDefinition(Relation.class);
|
||||
addPropertyUsage(t, type.getProperties());
|
||||
|
@ -167,14 +173,18 @@ public class ModelKnowledge<T, NI extends NodeInformation<T>> {
|
|||
* We want to have a reference to all Base type
|
||||
*/
|
||||
if(typeName.compareTo(Resource.NAME)==0) {
|
||||
addMetadataUsage(t);
|
||||
addEntityMetadataUsage(t);
|
||||
}
|
||||
break;
|
||||
|
||||
case FACET:
|
||||
FacetType facetType = (FacetType) t;
|
||||
/*
|
||||
* Metadata is defined in parent type i.e. EntityElement.
|
||||
* We want to have a reference to all Base type
|
||||
*/
|
||||
if(typeName.compareTo(Facet.NAME)==0) {
|
||||
addMetadataUsage(t);
|
||||
addEntityMetadataUsage(t);
|
||||
}
|
||||
addPropertyUsage(t, facetType.getProperties());
|
||||
|
||||
|
@ -182,8 +192,12 @@ public class ModelKnowledge<T, NI extends NodeInformation<T>> {
|
|||
|
||||
case IS_RELATED_TO:
|
||||
IsRelatedToType isRelatedToType = (IsRelatedToType) t;
|
||||
/*
|
||||
* Metadata is defined in parent type i.e. RelationElement.
|
||||
* We want to have a reference to all Base type
|
||||
*/
|
||||
if(typeName.compareTo(IsRelatedTo.NAME)==0) {
|
||||
addMetadataUsage(t);
|
||||
addRelationMetadataUsage(t);
|
||||
addPropagationConstraintUsage(t);
|
||||
}
|
||||
addPropertyUsage(t, isRelatedToType.getProperties());
|
||||
|
@ -191,8 +205,12 @@ public class ModelKnowledge<T, NI extends NodeInformation<T>> {
|
|||
|
||||
case CONSISTS_OF:
|
||||
ConsistsOfType consistsOfType = (ConsistsOfType) t;
|
||||
/*
|
||||
* Metadata is defined in parent type i.e. RelationElement.
|
||||
* We want to have a reference to all Base type
|
||||
*/
|
||||
if(typeName.compareTo(ConsistsOf.NAME)==0) {
|
||||
addMetadataUsage(t);
|
||||
addRelationMetadataUsage(t);
|
||||
addPropagationConstraintUsage(t);
|
||||
}
|
||||
addPropertyUsage(t, consistsOfType.getProperties());
|
||||
|
|
|
@ -96,11 +96,11 @@ public class ModelKnowledgeTest{
|
|||
if(type.getAccessType()!=AccessType.PROPERTY) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<LinkedEntity> usage = (List<LinkedEntity>) usageKnowledge.getUsage(typeName);
|
||||
logger.info("{}- {}{} {}", stringBuffer.toString(), typeName, level==0 ? " (ROOT) " : "", usage!=null ? "known usage from definitions " + usage : "No known usage from definitions");
|
||||
logger.info("{}- {}{} {}", stringBuffer.toString(), typeName, level==0 ? " (ROOT) " : "", usage!=null ? "known static usage " + usage : "No known static usage");
|
||||
}else {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map.Entry<String,PropertyDefinition>> usage = (List<Entry<String, PropertyDefinition>>) usageKnowledge.getUsage(typeName);
|
||||
logger.info("{}- {}{} {}", stringBuffer.toString(), typeName, level==0 ? " (ROOT) " : "", usage!=null ? "known usage from definitions " + usage : "No known usage from definitions");
|
||||
logger.info("{}- {}{} {}", stringBuffer.toString(), typeName, level==0 ? " (ROOT) " : "", usage!=null ? "known static usage " + usage : "No known static usage");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue