Class ModelKnowledge<T,TI extends TypeInformation<T>>
- java.lang.Object
-
- org.gcube.informationsystem.model.knowledge.ModelKnowledge<T,TI>
-
public class ModelKnowledge<T,TI extends TypeInformation<T>> extends Object
- Author:
- Luca Frosini (ISTI - CNR)
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<AccessType,UsageKnowledge<LinkedEntity>>erTypesUsageThe entity/relation types usage.protected Map<String,AccessType>locateA map to locate types.protected UsageKnowledge<Map.Entry<String,PropertyDefinition>>propertyUsageThe property usage.protected Map<AccessType,Tree<T>>treesThe trees of types.protected TItypeInformationThe type information.
-
Constructor Summary
Constructors Constructor Description ModelKnowledge(TI typeInformation)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAllType(Collection<T> types)Adds all types to the knowledge base.protected voidaddAllUsage(Collection<LinkedEntity> linkedEntities, UsageKnowledge<LinkedEntity> relationUsage, UsageKnowledge<LinkedEntity> targetEntityUsage)Adds all usages of a collection of linked entities.protected voidaddEntityMetadataUsage(T t)Adds the entity metadata usage for a type.protected voidaddPropagationConstraintUsage(T t)Adds the propagation constraint usage for a type.protected voidaddPropertyUsage(T t, Set<PropertyDefinition> properties)Adds the property usage for a type.protected voidaddRelationMetadataUsage(T t)Adds the relation metadata usage for a type.voidaddType(T t)Adds a type to the knowledge base.protected voidaddUsage(LinkedEntity linkedEntity, UsageKnowledge<LinkedEntity> relationUsage, UsageKnowledge<LinkedEntity> targetEntityUsage)Adds a usage of a linked entity.UsageKnowledge<LinkedEntity>getConsistsOfUsage()Returns the "consists of" usage.UsageKnowledge<LinkedEntity>getERTypesUsage(AccessType accessType)Returns the usage knowledge for the given entity/relation type.UsageKnowledge<LinkedEntity>getFacetUsage()Returns the facet usage.UsageKnowledge<LinkedEntity>getIsRelatedToUsage()Returns the "is related to" usage.UsageKnowledge<?>getModelTypesUsage(AccessType accessType)Returns the usage knowledge for the given model type.Node<T>getNodeByName(String typeName)Return the node for the type if it is contained in the KnowledgeUsageKnowledge<Map.Entry<String,PropertyDefinition>>getPropertyUsage()Returns the property usage.UsageKnowledge<LinkedEntity>getResourceUsage()Returns the resource usage.Tree<T>getTree(AccessType accessType)Returns the tree for the given access type.TgetTypeByName(String typeName)Return the type if it is contained in the Knowledgeprotected voidreset()Resets the knowledge base.
-
-
-
Field Detail
-
typeInformation
protected TI extends TypeInformation<T> typeInformation
The type information.
-
trees
protected Map<AccessType,Tree<T>> trees
The trees of types.
-
propertyUsage
protected UsageKnowledge<Map.Entry<String,PropertyDefinition>> propertyUsage
The property usage.
-
erTypesUsage
protected Map<AccessType,UsageKnowledge<LinkedEntity>> erTypesUsage
The entity/relation types usage.
-
locate
protected Map<String,AccessType> locate
A map to locate types.
-
-
Constructor Detail
-
ModelKnowledge
public ModelKnowledge(TI typeInformation)
Creates a new instance.- Parameters:
typeInformation- The type information.
-
-
Method Detail
-
reset
protected void reset()
Resets the knowledge base.
-
addUsage
protected void addUsage(LinkedEntity linkedEntity, UsageKnowledge<LinkedEntity> relationUsage, UsageKnowledge<LinkedEntity> targetEntityUsage)
Adds a usage of a linked entity.- Parameters:
linkedEntity- The linked entity.relationUsage- The relation usage.targetEntityUsage- The target entity usage.
-
addAllUsage
protected void addAllUsage(Collection<LinkedEntity> linkedEntities, UsageKnowledge<LinkedEntity> relationUsage, UsageKnowledge<LinkedEntity> targetEntityUsage)
Adds all usages of a collection of linked entities.- Parameters:
linkedEntities- The linked entities.relationUsage- The relation usage.targetEntityUsage- The target entity usage.
-
addPropertyUsage
protected void addPropertyUsage(T t, Set<PropertyDefinition> properties)
Adds the property usage for a type.- Parameters:
t- The type.properties- The properties.
-
addEntityMetadataUsage
protected void addEntityMetadataUsage(T t)
Adds the entity metadata usage for a type.- Parameters:
t- The type.
-
addRelationMetadataUsage
protected void addRelationMetadataUsage(T t)
Adds the relation metadata usage for a type.- Parameters:
t- The type.
-
addPropagationConstraintUsage
protected void addPropagationConstraintUsage(T t)
Adds the propagation constraint usage for a type.- Parameters:
t- The type.
-
addAllType
public void addAllType(Collection<T> types)
Adds all types to the knowledge base.- Parameters:
types- The types to add.
-
addType
public void addType(T t)
Adds a type to the knowledge base.- Parameters:
t- The type to add.
-
getTree
public Tree<T> getTree(AccessType accessType)
Returns the tree for the given access type.- Parameters:
accessType- The access type.- Returns:
- The tree.
-
getModelTypesUsage
public UsageKnowledge<?> getModelTypesUsage(AccessType accessType)
Returns the usage knowledge for the given model type.- Parameters:
accessType- The access type.- Returns:
- The usage knowledge.
-
getERTypesUsage
public UsageKnowledge<LinkedEntity> getERTypesUsage(AccessType accessType)
Returns the usage knowledge for the given entity/relation type.- Parameters:
accessType- The access type.- Returns:
- The usage knowledge.
-
getPropertyUsage
public UsageKnowledge<Map.Entry<String,PropertyDefinition>> getPropertyUsage()
Returns the property usage.- Returns:
- The property usage.
-
getResourceUsage
public UsageKnowledge<LinkedEntity> getResourceUsage()
Returns the resource usage.- Returns:
- The resource usage.
-
getFacetUsage
public UsageKnowledge<LinkedEntity> getFacetUsage()
Returns the facet usage.- Returns:
- The facet usage.
-
getIsRelatedToUsage
public UsageKnowledge<LinkedEntity> getIsRelatedToUsage()
Returns the "is related to" usage.- Returns:
- The "is related to" usage.
-
getConsistsOfUsage
public UsageKnowledge<LinkedEntity> getConsistsOfUsage()
Returns the "consists of" usage.- Returns:
- The "consists of" usage.
-
getTypeByName
public T getTypeByName(String typeName) throws RuntimeException
Return the type if it is contained in the Knowledge- Parameters:
typeName- the type we are looking for- Returns:
- the Type
- Throws:
RuntimeException- if the type is not found.
-
getNodeByName
public Node<T> getNodeByName(String typeName) throws RuntimeException
Return the node for the type if it is contained in the Knowledge- Parameters:
typeName- the type we are looking for- Returns:
- the Type
- Throws:
RuntimeException- if the type is not found.
-
-