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 |
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.
|
<T extends OntologyConcept> |
getOntologyConcept(Label label)
Get the
OntologyConcept with the label provided, if it exists. |
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.
|
Role |
getRole(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(Label 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(Label label)
Create a new
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified label. |
EntityType |
putEntityType(String label)
Create a new
EntityType with super-type entity, or return a pre-existing EntityType,
with the specified label. |
RelationType |
putRelationType(Label label)
Create a
RelationType with super-type relation, or return a pre-existing RelationType,
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. |
<V> ResourceType<V> |
putResourceType(Label 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(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. |
Role |
putRole(Label label)
|
Role |
putRole(String label)
|
RuleType |
putRuleType(Label label)
|
RuleType |
putRuleType(String 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 labelGraphOperationException - if the graph is closedPropertyNotUniqueException - if the is already in use by an existing non-EntityType.EntityType putEntityType(Label 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 labelGraphOperationException - if the graph is closedPropertyNotUniqueException - 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.GraphOperationException - if the graph is closedPropertyNotUniqueException - if the is already in use by an existing non-ResourceType.GraphOperationException - if the is already in use by an existing ResourceType which is
unique or has a different datatype.<V> ResourceType<V> putResourceType(Label 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.GraphOperationException - if the graph is closedPropertyNotUniqueException - if the is already in use by an existing non-ResourceType.GraphOperationException - 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.GraphOperationException - if the graph is closedPropertyNotUniqueException - if the is already in use by an existing non-RuleType.RuleType putRuleType(Label 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.GraphOperationException - if the graph is closedPropertyNotUniqueException - 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.GraphOperationException - if the graph is closedPropertyNotUniqueException - if the is already in use by an existing non-RelationType.RelationType putRelationType(Label 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.GraphOperationException - if the graph is closedPropertyNotUniqueException - if the is already in use by an existing non-RelationType.Role putRole(String label)
label - A unique label for the RoleRole with the provided Id.GraphOperationException - if the graph is closedPropertyNotUniqueException - if the is already in use by an existing non-Role.Role putRole(Label label)
label - A unique label for the RoleRole with the provided Id.GraphOperationException - if the graph is closedPropertyNotUniqueException - if the is already in use by an existing non-Role.@CheckReturnValue <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.GraphOperationException - if the graph is closedClassCastException - if the concept is not an instance of T@CheckReturnValue <T extends OntologyConcept> T getOntologyConcept(Label label)
OntologyConcept with the label provided, if it exists.label - A unique label which identifies the OntologyConcept in the graph.OntologyConcept with the provided label or null if no such OntologyConcept exists.GraphOperationException - if the graph is closedClassCastException - if the type is not an instance of T@CheckReturnValue <T extends Type> T getType(Label 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.GraphOperationException - if the graph is closedClassCastException - if the type is not an instance of T@CheckReturnValue <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.GraphOperationException - if the graph is closed@CheckReturnValue EntityType getEntityType(String label)
label - A unique label which identifies the Entity Type in the graph.GraphOperationException - if the graph is closed@CheckReturnValue RelationType getRelationType(String label)
label - A unique label which identifies the Relation Type in the graph.GraphOperationException - if the graph is closed@CheckReturnValue <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.GraphOperationException - if the graph is closed@CheckReturnValue Role getRole(String label)
label - A unique label which identifies the Role Type in the graph.GraphOperationException - if the graph is closed@CheckReturnValue RuleType getRuleType(String label)
label - A unique label which identifies the Rule Type in the graph.GraphOperationException - if the graph is closed@CheckReturnValue GraknAdmin admin()
GraknAdmin@CheckReturnValue boolean isReadOnly()
void showImplicitConcepts(boolean flag)
flag - Specifies if implicit and system-generated types should be returned.@CheckReturnValue boolean implicitConceptsVisible()
@CheckReturnValue String getKeyspace()
@CheckReturnValue boolean isClosed()
@CheckReturnValue 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 InvalidGraphException
GraknSession to
get a new open transaction.InvalidGraphException - when the transaction contains graph mutations which does not conform to the Grakn
knowledge model.Copyright © 2017 Grakn Labs Ltd. All rights reserved.