public interface GraknGraph extends AutoCloseable
A Grakn Graph
This is produced by Grakn.session(String, String) and allows the user to construct and perform
basic look ups to a Grakn Graph. This also allows the execution of Graql queries.
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Reverts any changes done to the graph and closes the transaction.
|
GraknAdmin |
admin()
Returns access to the low-level details of the graph via GraknAdmin
|
void |
clear()
Closes and clears the current graph.
|
void |
close()
Closes the current transaction.
|
void |
commit()
Commits any changes to the graph and closes the transaction.
|
<T extends Concept> |
getConcept(ConceptId id)
Get the
Concept with identifier provided, if it exists. |
EntityType |
getEntityType(String label)
Get the Entity Type with the label provided, if it exists.
|
String |
getKeyspace()
Utility function to get the name of the keyspace where the graph is persisted.
|
RelationType |
getRelationType(String label)
Get the Relation Type with the label provided, if it exists.
|
<V> Collection<Resource<V>> |
getResourcesByValue(V value)
Get all Resources holding the value provided, if they exist.
|
<V> ResourceType<V> |
getResourceType(String label)
Get the Resource Type with the label provided, if it exists.
|
RoleType |
getRoleType(String label)
Get the Role Type with the label provided, if it exists.
|
RuleType |
getRuleType(String label)
Get the Rule Type with the label provided, if it exists.
|
<T extends Type> |
getType(TypeLabel label)
Get the
Type with the label provided, if it exists. |
QueryBuilder |
graql()
Returns a QueryBuilder
|
boolean |
implicitConceptsVisible()
Utility function to specify whether implicit concepts should be exposed.
|
boolean |
isClosed()
Utility function to determine whether the graph has been closed.
|
boolean |
isReadOnly()
Utility function used to check if the current transaction on the graph is a read only transaction
|
EntityType |
putEntityType(String label)
Create a new
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified label. |
EntityType |
putEntityType(TypeLabel label)
Create a new
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified label. |
RelationType |
putRelationType(String label)
Create a
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified label. |
RelationType |
putRelationType(TypeLabel label)
Create a
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified label. |
<V> ResourceType<V> |
putResourceType(String label,
ResourceType.DataType<V> dataType)
Create a new non-unique
ResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified label and data type. |
<V> ResourceType<V> |
putResourceType(TypeLabel label,
ResourceType.DataType<V> dataType)
Create a new non-unique
ResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified label and data type. |
RoleType |
putRoleType(String label)
|
RoleType |
putRoleType(TypeLabel label)
|
RuleType |
putRuleType(String label)
|
RuleType |
putRuleType(TypeLabel label)
|
void |
showImplicitConcepts(boolean flag)
Utility function to specify whether implicit and system-generated types should be returned.
|
EntityType putEntityType(String label)
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified label.label - A unique label for the EntityTypeEntityType with the provided labelGraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-EntityType.EntityType putEntityType(TypeLabel label)
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified label.label - A unique label for the EntityTypeEntityType with the provided labelGraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-EntityType.<V> ResourceType<V> putResourceType(String label, ResourceType.DataType<V> dataType)
ResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified label and data type.V - The data type of the resource type. Supported types include: String, Long, Double, Boolean.
This should match the parameter typelabel - A unique label for the ResourceTypedataType - The data type of the ResourceType.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANResourceType with the provided label and data type.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-ResourceType.ConceptException - if the is already in use by an existing ResourceType which is
unique or has a different datatype.<V> ResourceType<V> putResourceType(TypeLabel label, ResourceType.DataType<V> dataType)
ResourceType with super-type resource, or return a pre-existing
non-unique ResourceType, with the specified label and data type.V - The data type of the resource type. Supported types include: String, Long, Double, Boolean.
This should match the parameter typelabel - A unique label for the ResourceTypedataType - The data type of the ResourceType.
Supported types include: DataType.STRING, DataType.LONG, DataType.DOUBLE, and DataType.BOOLEANResourceType with the provided label and data type.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-ResourceType.ConceptException - if the is already in use by an existing ResourceType which is
unique or has a different datatype.RuleType putRuleType(String label)
RuleType with super-type rule, or return a pre-existing RuleType, with the
specified label.label - A unique label for the RuleTypeRuleType with the provided label.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RuleType.RuleType putRuleType(TypeLabel label)
RuleType with super-type rule, or return a pre-existing RuleType, with the
specified label.label - A unique label for the RuleTypeRuleType with the provided label.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RuleType.RelationType putRelationType(String label)
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified label.label - A unique label for the RelationTypeRelationType with the provided label.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RelationType.RelationType putRelationType(TypeLabel label)
RelationType with super-type relation, or return a pre-existing RelationType,
with the specified label.label - A unique label for the RelationTypeRelationType with the provided label.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RelationType.RoleType putRoleType(String label)
RoleType with super-type role, or return a pre-existing RoleType, with the
specified label.label - A unique label for the RoleTypeRoleType with the provided Id.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RoleType.RoleType putRoleType(TypeLabel label)
RoleType with super-type role, or return a pre-existing RoleType, with the
specified label.label - A unique label for the RoleTypeRoleType with the provided Id.GraphRuntimeException - if the graph is closedConceptNotUniqueException - if the is already in use by an existing non-RoleType.<T extends Concept> T getConcept(ConceptId id)
Concept with identifier provided, if it exists.id - A unique identifier for the Concept in the graph.Concept with the provided id or null if no such Concept exists.GraphRuntimeException - if the graph is closedClassCastException - if the concept is not an instance of T<T extends Type> T getType(TypeLabel label)
Type with the label provided, if it exists.label - A unique label which identifies the Type in the graph.Type with the provided label or null if no such Type exists.GraphRuntimeException - if the graph is closedClassCastException - if the type is not an instance of T<V> Collection<Resource<V>> getResourcesByValue(V value)
V - The data type of the value. Supported types include: String, Long, Double, and Boolean.value - A value which a Resource in the graph may be holding.GraphRuntimeException - if the graph is closedEntityType getEntityType(String label)
label - A unique label which identifies the Entity Type in the graph.GraphRuntimeException - if the graph is closedRelationType getRelationType(String label)
label - A unique label which identifies the Relation Type in the graph.GraphRuntimeException - if the graph is closed<V> ResourceType<V> getResourceType(String label)
V - The data type of the value. Supported types include: String, Long, Double, and Boolean.label - A unique label which identifies the Resource Type in the graph.GraphRuntimeException - if the graph is closedRoleType getRoleType(String label)
label - A unique label which identifies the Role Type in the graph.GraphRuntimeException - if the graph is closedRuleType getRuleType(String label)
label - A unique label which identifies the Rule Type in the graph.GraphRuntimeException - if the graph is closedGraknAdmin admin()
GraknAdminboolean isReadOnly()
void showImplicitConcepts(boolean flag)
flag - Specifies if implicit and system-generated types should be returned.boolean implicitConceptsVisible()
void clear()
GraphRuntimeException - if the graph is closedString getKeyspace()
boolean isClosed()
QueryBuilder graql()
QueryBuildervoid close()
GraknSession to
get a new open transaction.close in interface AutoCloseablevoid abort()
GraknSession to
get a new open transaction.void commit()
throws GraknValidationException
GraknSession to
get a new open transaction.GraknValidationException - when the transaction contains graph mutations which does not conform to the Grakn
knowledge model.Copyright © 2017 Grakn Labs Ltd. All rights reserved.