Java Driver API reference

Java Driver API reference consists of two sections:

Query section

Query section consists of the following methods:

TypeDB Driver methods

Instantiating a TypeDB Core client

Syntax
TypeDB.coreClient(String address, int parallelisation);
Description

In order to communicate with TypeDB Core databases via sessions and transactions, we first need to instantiate a TypeDB Core client. The created object connects our application with the running TypeDB server.

Input parameters
Name Description Type Required Default Value

address

The address (host:port) on which the TypeDB server is running

String

True

parallelisation

The number of threads to use for server communication

int

False

Scales based on host machine’s number of available CPU cores

Returns

Instantiating a TypeDB cluster client

Syntax
TypeDB.clusterClient(Set<String> addresses, TypeDBCredential credential, int parallelisation);
Description

In order to communicate with TypeDB cluster (TypeDB Enterprise & TypeDB Cloud) databases via sessions and transactions, we first need to instantiate a TypeDB Cluster client. The created object connects our application with the running TypeDB cluster.

When instantiating a TypeDB cluster client, it is sufficient to supply the address of just one server, as the addresses of the other servers will be relayed back to the client. However, to avoid failure in the unlikely event that the single server whose address is provided fails before communicating the addresses of the others, it is best practice to supply addresses of all the servers.

Input parameters
Name Description Type Required Default Value

addresses

Addresses (host:port) on which TypeDB cluster nodes are running

Set of String

True

credential

User credential and TLS encryption setting

TypeDBCredential

True

parallelisation

The number of threads to use for server communication

int

False

Scales based on host machine’s number of available CPU cores

Returns

Client methods

Create a session for a database

Syntax
client.session(String database, Session.Type sessionType, TypeDBOptions options);
Description

Opens a communication tunnel (session) to the given database on the running TypeDB server.

For more information on the methods, available with sessions, see the Session methods section.

Input parameters
Name Description Type Required Default Value

database

The name of the database with which the session connects.

String

True

N/A

type

The type of session to be created (DATA or SCHEMA)

SessionType

True

N/A

options

Options for the session.

TypeDBOptions

False

N/A

Returns

Retrieve all databases

Syntax
client.databases().all();
Description

Retrieves all databases running on the TypeDB server.

Returns
  • List<Database>

Check if a database exists

Syntax
client.databases().contains(String database);
Description

Checks if a database with the given name exists

Input parameters
Name Description Type Required Default Value

database

The database name to be checked.

String

True

N/A

Create a database

Syntax
client.databases().create(String database);
Description

Create a database with the given name.

Input parameters
Name Description Type Required Default Value

database

The name of the database to be created.

String

True

N/A

Returns
  • void

Retrieve a database

Syntax
client.databases().get(String database);
Description

Retrieve a database with the given name.

Input parameters
Name Description Type Required Default Value

database

The name of the database to retrieve.

String

True

N/A

Returns
  • Database

Delete a database

Syntax
client.databases().get(String database).delete();
Description

Deletes a database with the given name.

Input parameters
Name Description Type Required Default Value

database

The name of the database to be deleted.

String

True

N/A

Returns
  • void

Retrieve all users

Syntax
client.users().all();
Description

Retrieves all users running on the TypeDB server.

Returns
  • List<user>

Check if a user exists

Syntax
client.users().contains(String user);
Description

Checks if a user with the given name exists

Input parameters
Name Description Type Required Default Value

user

The user name to be checked.

String

True

N/A

Create a user

Syntax
client.users().create(String user);
Description

Create a user with the given name.

Input parameters
Name Description Type Required Default Value

user

The name of the user to be created.

String

True

N/A

Returns
  • void

Retrieve a user

Syntax
client.users().get(String user);
Description

Retrieve a user with the given name.

Input parameters
Name Description Type Required Default Value

user

The name of the user to retrieve.

String

True

N/A

Returns
  • user

Delete a user

Syntax
client.users().delete(String username);
Description

Deletes a user with the given name.

Input parameters
Name Description Type Required Default Value

user

The name of the user to be deleted.

String

True

N/A

Returns
  • void

Set a user’s password

Syntax
client.users().passwordSet(String username, String password);
Description

Deletes a user with the given name.

Input parameters
Name Description Type Required Default Value

user

The name of the user to update the password of.

String

True

N/A

password

User’s new password.

String

True

N/A

Returns
  • void

Close a client

Syntax
client.close();
Description

Closes the client. Before instantiating a new client, the client that’s currently open should first be closed.

Returns
  • void

Session methods

Open a transaction

Syntax
session.transaction(Transaction.Type transactionType, TypeDBOptions options);
Description

Opens a transaction to perform read or write queries on the database connected to the session.

Input parameters
Name Description Type Required Default Value

transactionType

The type of transaction to be created (READ or WRITE).

Transaction.Type

True

options

Options for the session.

[TypeDBOptions]

False

N/A

Returns

Check if a session is open

Syntax
session.isOpen();
Description

Checks whether a session is presently open.

Returns
  • boolean

Check the session’s type

Syntax
session.type();
Description

Checks the current session’s type (SCHEMA or DATA)

Returns
  • Session.Type

Get the session’s database

Syntax
session.database();
Description

Returns the database of the session.

Returns
  • Database object

Retrieve name of the database in the session

Syntax
session.database().name();
Description

Returns the current database name as a string.

Returns
  • String

Retrieve schema of the database in the session

Syntax
session.database().schema();
Description

Returns a full schema text as a valid TypeQL define query string.

Returns
  • String

Delete a database of the session

Syntax
session.database().delete();
Description

Deletes the database of the current session.

Returns
  • void

Close a session

Syntax
session.close();
Description

Closes the session. Before opening a new session, the session currently open should first be closed.

Returns
  • void

Transaction methods

Check the transaction’s type

Syntax
transaction.type();
Description

Checks the transaction’s type (READ or WRITE)

Returns
  • Transaction.Type

Check if the transaction is open

Syntax
transaction.isOpen();
Returns
  • boolean

Access Concept API methods

Syntax
transaction.concepts();
Description

Gets the ConceptManager for this Transaction, providing access to all Concept methods.

Returns

Logic methods

Syntax
transaction.logic();
Description

Gets the LogicManager for this Transaction, providing access to all Logic methods.

Returns

Access Query API methods

Syntax
transaction.query();
Description

Gets the [QueryManager]  for this Transaction, from which any TypeQL query can be executed.

Returns
  • [QueryManager]

Commit a write transaction

Syntax
transaction.commit();
Description

Commits the changes made via this transaction to the TypeDB database. Whether or not the transaction is commited successfully, it gets closed after the commit call.

Returns
  • void

Rollback a write transaction

Syntax
transaction.rollback();
Description

Rolls back the uncommitted changes made via this transaction.

Returns
  • void

Close a read transaction

Syntax
transaction.close();
Description

Closes the transaction.

Returns
  • void

QueryManager methods

Execute a TypeQL Match (Get) query

Syntax
transaction.query().match(TypeQLMatch query, TypeDBOptions options);
Description

Performs a TypeQL Match (Get) query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Match (Get) query to be executed.

TypeQLMatch

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Stream<[ConceptMap] >

Execute a TypeQL Match Aggregate query

Syntax
transaction.query().match(TypeQLMatch.Aggregate query, TypeDBOptions options);
Description

Performs a TypeQL Match Aggregate query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Match Aggregate query to be executed.

TypeQLMatch.Aggregate

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • [QueryFuture] <[Numeric] >

Execute a TypeQL Match Group query

Syntax
transaction.query().match(TypeQLMatch.Group query, TypeDBOptions options);
Description

Performs a TypeQL Match Group query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Match Group query to be executed.

TypeQLMatch.Group

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Stream<[ConceptMapGroup] >

Execute a TypeQL Match Group Aggregate query

Syntax
transaction.query().match(TypeQLMatch.Group.Aggregate query, TypeDBOptions options);
Description

Performs a TypeQL Match Group Aggregate query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Match Group Aggregate query to be executed.

TypeQLMatch.Group.Aggregate

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Stream<[NumericGroup] >

Execute a TypeQL Insert query

Syntax
transaction.query().insert(TypeQLInsert query, TypeDBOptions options);
Description

Performs a TypeQL Insert query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Insert query to be executed.

TypeQLInsert

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Stream<[ConceptMap] >

Execute a TypeQL Delete query

Syntax
transaction.query().delete(TypeQLDelete query, TypeDBOptions options);
Description

Performs a TypeQL Delete query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Delete query to be executed.

TypeQLDelete

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • [QueryFuture]

Execute a TypeQL Update query

Syntax
transaction.query().update(TypeQLUpdate query, TypeDBOptions options);
Description

Performs a TypeQL Update query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Update query to be executed.

TypeQLUpdate

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Stream<[ConceptMap] >

Execute a TypeQL Explain query

Syntax
transaction.query().explain(ConceptMap.Explainable explainable, TypeDBOptions options);
Description

Performs a TypeQL Explain query in the transaction.

Input parameters
Name Description Type Required Default Value

explainable

The Explainable to be explained.

[ConceptMap.Explainable]

True

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Stream<[Explanation] >

Execute a TypeQL Define query

Syntax
transaction.query().define(TypeQLDefine query, TypeDBOptions options);
Description

Performs a TypeQL Define query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Define query to be executed.

TypeQLDefine

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • [QueryFuture]

Execute a TypeQL Undefine query

Syntax
transaction.query().undefine(TypeQLUndefine query, TypeDBOptions options);
Description

Performs a TypeQL Undefine query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Undefine query to be executed.

TypeQLUndefine

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • [QueryFuture]

Options

The transaction query options object TypeDBOptions can be used to override the default server behaviour query processing. Use TypeDBOptions.core() to create a new TypeDB Core options object, or TypeDBOptions.cluster() for cluster client for TypeDB Enterprise & TypeDB Cloud.

The options are:

  • infer: whether to enable inference for the provided query (only settable at transaction level and above, and only affects read transactions) (default: false).

  • explain: whether to enable explanations for the provided query (only affects read transactions) (default: false).

  • parallel: whether the server should use parallel or single-threaded execution (default: true).

  • prefetchSize: a guideline number of answers that the server should send before the client issues a fresh request (default: 50).

  • traceInference: if enabled, outputs reasoning tracing graphs in the logging directory. Should be used with parallel = false. (default: false).

  • prefetch: if enabled, the first batch of answers is streamed to the client even without an explicit request for it (default: true if query type is match, otherwise false).

  • sessionIdleTimeoutMillis: this timeout allows the server to close sessions if a client terminates or becomes unresponsive (default: 30_000).

  • transactionTimeoutMillis: this timeout will automatically kill transactions, preventing memory leaks in unclosed transactions (default: 300_000).

  • schemaLockAcquireTimeoutMillis: how long the client should wait if opening a session or transaction is blocked by a schema write lock (default: 10_000).

TypeDBClusterOptions has an additional option:

  • readAnyReplica: enables reading data from any replica, potentially boosting read throughput (default: false).

Explicitly enable or disable inference

Syntax
options.setInfer(boolean enabled)
Description

Override the server defaults to enable or disable inference for the provided query (only settable at transaction level and above, and only affects read transactions).

Input parameters
Name Description Type Required Default Value

enabled

explicitly set inference on or off for this query

boolean

True

Returns

Explicitly enable or disable explanations

Syntax
options.setExplain(boolean enabled)
Description

Override the server defaults to enable or disable explanation availability for the provided query (only affects read transactions).

Input parameters
Name Description Type Required Default Value

enabled

explicitly set explanations on or off for this query

boolean

True

Returns

Force the server parallelism

Syntax
options.setParallel(boolean parallel)
Description

Override the server defaults to use parallel or single-threaded query execution

Input parameters
Name Description Type Required Default Value

parallel

use parallel or single-threaded query execution

boolean

True

Returns

Explicitly set query prefetch to a certain size

Syntax
options.setPrefetchSize(int size)
Description

Override the server defaults for answer batch streaming. This tells the server to pre-compute and stream this number of answers at a time. These are buffered in the client until read. A larger batch size causes the server to compute more answers at a time, blocking the transaction until the batch is computed.

Input parameters
Name Description Type Required Default Value

size

int

True

Returns

Trace and log reasoning inference

Syntax
options.setTraceInference(boolean traceInference)
Description

Create reasoning traces as graphs logged in the logging directory. Should be used with parallel = false

Input parameters
Name Description Type Required Default Value

traceInference

trace reasoning execution as graphs in log directory

boolean

True

Returns

Explicitly enable or disable prefetch

Syntax
options.setPrefetch(boolean prefetch)
Description

If enabled, the first batch of answers is streamed to the client even without an explicit request for it

Input parameters
Name Description Type Required Default Value

prefetch

if set to true, the first batch of answers is streamed to the client even without an explicit request for it

boolean

True

Returns

Override default session idle timeout

Syntax
options.setSessionIdleTimeoutMillis(int timeout)
Description

This timeout allows the server to close sessions if a client terminates or becomes unresponsive

Input parameters
Name Description Type Required Default Value

timeout

int

True

Returns

Override default transaction timeout

Syntax
options.setTransactionTimeoutMillis(int timeout)
Description

This timeout automatically closes transactions that exceed the configured time. This prevents memory leaks caused by transactions accidentally left unclosed, and kills unresponsive transactions.

Input parameters
Name Description Type Required Default Value

timeout

int

True

Returns

Override default schema lock acquire timeout

Syntax
options.setSchemaLockAcquireTimeoutMillis(int timeout)
Description

This timeout allows the server to close sessions if a client terminates or becomes unresponsive

Input parameters
Name Description Type Required Default Value

timeout

int

True

Returns

Enable reading data from any replica

Syntax
clusterOptions.setReadAnyReplica(bool readAnyReplica)
Description

Used to enable reading data from any replica, potentially boosting read throughput

Input parameters
Name Description Type Required Default Value

readAnyReplica

boolean

True

Returns

Response section

Response section consists of the following methods:

Answer methods

ConceptMap methods

Retrieve a mapping of variables to concepts
Syntax
conceptMap.map();
Description

Produces a Map where keys are query variables, and values are concepts.

Returns
Retrieve concepts
Syntax
conceptMap.concepts();
Description

Return a collection of all the concepts in this ConceptMap.

Returns
Retrieve a concept corresponding to a specific variable
Syntax
conceptMap.get(String var)
Description

Retrieve a concept for a given variable name

Input parameters
Name Description Type Required Default Value

var

The string representation of a variable

String

Returns
Retrieve explainable concepts
Syntax
conceptMap.explainables()
Description

Gets the Explainables object for this ConceptMap, exposing which of the Concepts in this ConceptMap are explainable

Numeric methods

Retrieve numeric value of an aggregate answer as a long
Syntax
numeric.asLong();
Returns
  • long

Retrieve numeric value of an aggregate answer as a double
Syntax
numeric.asDouble();
Returns
  • double

Retrieve numeric value of an aggregate answer
Syntax
numeric.asNumber();
Returns
  • Number

Checks if the type of an aggregate answer is a long
Syntax
numeric.isLong();
Returns
  • boolean

Checks if the type of an aggregate answer is a double
Syntax
numeric.isDouble();
Returns
  • boolean

ConceptMapGroup methods

Checks if the type of an aggregate answer is not a number
Syntax
conceptMapGroup.isNaN();
Returns
  • boolean

Retrieve the concept that is the group owner
Syntax
conceptMapGroup.owner();
Returns
Retrieve the ConceptMaps of the group
Syntax
conceptMapGroup.conceptMaps();
Returns

Numeric Group methods

Retrieve the concept that is the group owner
Syntax
numericGroup.owner();
Returns
Retrieve the Numeric answer of the group
Syntax
numericGroup.numeric();
Returns
  • [Numeric]

Explainables methods

Retrieve explainable relation
Syntax
conceptMap.explainables().relation(String variable);
Description

Retrieves the explainable relation with the given variable name.

Input parameters
Name Description Type Required Default Value

variable

The string representation of a variable

String

Returns
  • [ConceptMap.Explainable]

Retrieve explainable attribute
Syntax
conceptMap.explainables().attribute(String variable);
Description

Retrieves the explainable attribute with the given variable name.

Input parameters
Name Description Type Required Default Value

variable

The string representation of a variable

String

Returns
  • [ConceptMap.Explainable]

Retrieve explainable ownership
Syntax
conceptMap.explainables().ownership(String ownerVar, String attributeVar);
Description

Retrieves the explainable attribute ownership with the pair of (owner, attribute) variable names.

Input parameters
Name Description Type Required Default Value

variable

The string representation of a variable

String

Returns
  • [ConceptMap.Explainable]

Retrieve explainable relations
Syntax
conceptMap.explainables().relations();
Description

Retrieves all of this ConceptMap’s explainable relations.

Returns
  • Map<String, [ConceptMap.Explainable] >

Retrieve explainable attributes
Syntax
conceptMap.explainables().attributes();
Description

Retrieves all of this ConceptMap’s explainable attributes.

Returns
  • Map<String, [ConceptMap.Explainable] >

Retrieve explainable ownerships
Syntax
conceptMap.explainables().ownerships();
Description

Retrieves all of this ConceptMap’s explainable attribute ownerships.

Returns
  • Map<Pair<String, String>, [ConceptMap.Explainable] >

Explainable methods

Retrieve conjunction
Syntax
explainable.conjunction()
Description

Retrieves the subquery of the original query that is actually being explained.

Returns
  • String

Retrieve ID
Syntax
explainable.id()
Description

Retrieves the unique ID that identifies this Explainable.

Returns
  • long

Explanation methods

Retrieve the rule
Syntax
explanation.rule();
Description

Retrieves the Rule for this Explanation.

Returns
  • Rule

Retrieve the conclusion
Syntax
explanation.conclusion()
Description

Retrieves the Conclusion for this Explanation.

Returns
  • ConceptMap

Retrieve the condition
Syntax
explanation.condition()
Description

Retrieves the Condition for this Explanation.

Returns
  • ConceptMap

Retrieve the variable mapping
Syntax
explanation.variableMapping()
Description

Retrieves the mapping between rule variables and query variables for this Explanation.

Returns
  • Map<String, Set<String>>

Concept methods

Concept is inherited and extended by Value, Type and Data.

Get a Remote version of the concept.

Syntax
concept.asRemote(tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • Concept.Remote

Check if concept is a Type (Local)

Syntax
concept.isType();
Returns
  • boolean

Check if concept is a Thing (Local)

Syntax
concept.isThing();
Returns
  • boolean

Check if concept is a Value (Local)

Syntax
concept.isValue();
Returns
  • boolean

Check if concept is an EntityType (Local)

Syntax
concept.isEntityType();
Returns
  • boolean

Check if concept is an AttributeType (Local)

Syntax
concept.isAttributeType();
Returns
  • boolean

Check if concept is a RelationType (Local)

Syntax
concept.isRelationType();
Returns
  • boolean

Check if concept is a RoleType (Local)

Syntax
concept.isRoleType();
Returns
  • boolean

Check if concept is an Entity (Local)

Syntax
concept.isEntity();
Returns
  • boolean

Check if concept is an Attribute (Local)

Syntax
concept.isAttribute();
Returns
  • boolean

Check if concept is a Relation (Local)

Syntax
concept.isRelation();
Returns
  • boolean

Cast the concept as Type (Local)

Syntax
concept.asType();
Description

Casts the concept as Type so that we can call the Type methods on it.

Returns

Cast the concept as Thing (Local)

Syntax
concept.asThing();
Description

Casts the concept as Thing so that we can call the Thing methods on it.

Returns

Cast the concept as Value (Local)

Syntax
concept.asValue();
Description

Casts the concept object as Value so that we can use it as value.

Returns
  • string

  • long

  • float

  • boolean

  • date

Cast the concept as EntityType (Local)

Syntax
concept.asEntityType();
Description

Casts the concept as EntityType so that we can call the EntityType methods on it.

Returns

Cast the concept as AttributeType (Local)

Syntax
concept.asAttributeType();
Description

Casts the concept as AttributeType so that we can call the AttributeType methods on it.

Returns

Cast the concept as RelationType (Local)

Syntax
concept.asRelationType();
Description

Casts the concept as RelationType so that we can call the RelationType methods on it.

Returns

Cast the concept as RoleType (Local)

Syntax
concept.asRoleType();
Description

Casts the concept as RoleType so that we can call the RoleType methods on it.

Returns

Cast the concept as Entity (Local)

Syntax
concept.asEntity();
Description

Casts the concept as Entity so that we can call the Entity methods on it.

Returns
  • [Entity]

Cast the concept as Attribute (Local)

Syntax
concept.asAttribute();
Description

Casts the concept as Attribute so that we can call the Attribute methods on it.

Returns
  • [Attribute]

Cast the concept as Relation (Local)

Syntax
concept.asRelation();
Description

Casts the concept as Relation so that we can call the Relation methods on it.

Returns
  • [Relation]

Delete concept

Syntax
concept.asRemote(Transaction tx).delete();
Returns
  • void

Check if the concept has been deleted

Syntax
concept.asRemote(Transaction tx).isDeleted()
Returns
  • boolean

Retrieve a concept as JSON

Syntax
concept.toJSON();
Returns
  • JSON

ConceptManager methods

Retrieve the root ThingType

Syntax
transaction.concepts().getRootThingType();
Description

Retrieves the root ThingType, "thing".

Returns
  • [ThingType]

Retrieve the root EntityType

Syntax
transaction.concepts().getRootEntityType();
Description

Retrieves the root EntityType, "entity".

Returns
  • [EntityType]

Retrieve the root RelationType

Syntax
transaction.concepts().getRootRelationType();
Description

Retrieves the root RelationType, "relation".

Returns
  • [RelationType]

Retrieve the root AttributeType

Syntax
transaction.concepts().getRootAttributeType();
Description

Retrieves the root AttributeType, "attribute".

Returns
  • [AttributeType]

Retrieve an EntityType

Syntax
transaction.concepts().getEntityType(String label);
Description

Retrieves an EntityType by its label.

Input parameters
Name Description Type Required Default Value

label

The label of the EntityType to retrieve.

string

True

N/A

Returns
  • [EntityType]

Create or retrieve an EntityType

Syntax
transaction.concepts().putEntityType(String label);
Description

Creates a new EntityType if none exists with the given label, otherwise retrieves the existing one.

Input parameters
Name Description Type Required Default Value

label

The label of the EntityType to create or retrive.

string

True

N/A

Returns
  • [EntityType]

Retrieve a RelationType

Syntax
transaction.concepts().getRelationType(String label);
Description

Retrieves a RelationType by its label.

Input parameters
Name Description Type Required Default Value

label

The label of the RelationType to retrieve.

string

True

N/A

Returns
  • [RelationType]

Create or retrieve a RelationType

Syntax
transaction.concepts().putRelationType(String label);
Description

Creates a new RelationType if none exists with the given label, otherwise retrieves the existing one.

Input parameters
Name Description Type Required Default Value

label

The label of the RelationType to create or retrive.

string

True

N/A

Returns
  • [RelationType]

Retrieve an AttributeType

Syntax
transaction.concepts().getAttributeType(String label);
Description

Retrieves an AttributeType by its label.

Input parameters
Name Description Type Required Default Value

label

The label of the AttributeType to retrieve.

string

True

N/A

Returns
  • [AttributeType]

Create or retrieve an AttributeType

Syntax
transaction.concepts().putAttributeType(String label, AttributeType.ValueType valueType)
Description

Creates a new AttributeType if none exists with the given label, or retrieves the existing one.

Input parameters
Name Description Type Required Default Value

label

The label of the AttributeType to create or retrieve.

string

True

N/A

valueType

The value type of the AttributeType to create or retrieve.

AttributeType.ValueType (STRING | DATETIME | LONG | DOUBLE | BOOLEAN)

True

N/A

Returns
  • [AttributeType]

Retrieve a Thing

Syntax
transaction.concepts().getThing(String iid);
Description

Retrieves the Thing that has the given TypeDB internal ID.

Input parameters
Name Description Type Required Default Value

iid

The IID of the concept to retrieve.

string

True

N/A

Returns
  • [Thing]

Retrieve a ThingType

Syntax
transaction.concepts().getThingType(String label);
Description

Retrieves a ThingType by its label.

Input parameters
Name Description Type Required Default Value

label

The label of the ThingType to retrieve.

string

True

N/A

Returns
  • [ThingType]

Future methods

Get the query result

Syntax
future.get()
Description

Waits for the query to finish execution, and returns its result, if present.

Returns
  • Returns according to type of query executed

Map the query result

Syntax
future.map(function)
Description

Transforms the QueryFuture into a new QueryFuture by running the supplied function on the query result when it is returned.

Returns
  • Return type of supplied function

Type methods

Type has all the Concept methods plus what follows.

Get a Remote version of the type.

Syntax
type.asRemote(tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • Type.Remote

Retrieve label (Local)

Syntax
type.getLabel().name();
Description

Retrieves the unique label of the type.

Returns
  • String

Check if type is abstract (Local)

Syntax
type.isAbstract();
Description

Checks if the type is prevented from having data instances (i.e., abstract).

Returns
  • boolean

Check if type is a root type (Local)

Syntax
type.isRoot();
Description

Checks if the type is a root type.

Returns
  • boolean

Rename label

Syntax
type.asRemote(Transaction tx).setLabel(String label);
Description

Renames the label of the type. The new label must remain unique.

Input parameters
Name Description Type Required Default Value

label

The new label to be given to the type.

String

True

N/A

Returns
  • void

Retrieve direct supertype

Syntax
type.asRemote(Transaction tx).getSupertype();
Description

Retrieves the most immediate supertype of the type.

Returns
  • [Type]

  • null

Retrieve all supertypes

Syntax
type.asRemote(Transaction tx).getSupertypes();
Description

Retrieves all supertypes of the type.

Returns
  • Stream<[Type] >

Retrieve all subtypes

Syntax
type.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the type.

Returns
  • Stream<[Type] >

ThingType methods

ThingType has all the Type methods plus what follows.

Get a Remote version of the ThingType.
Syntax
thingType.asRemote(tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • ThingType.Remote

Retrieve direct supertype
Syntax
thingType.asRemote(Transaction tx).getSupertype();
Description

Retrieves the most immediate supertype of the ThingType.

Returns
  • [ThingType]

  • null

Retrieve all supertypes
Syntax
thingType.asRemote(Transaction tx).getSupertypes();
Description

Retrieves all supertypes of the ThingType.

Returns
  • Stream<[ThingType] >

Retrieve all subtypes
Syntax
thingType.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the ThingType.

Returns
  • Stream<[ThingType] >

Retrieve instances
Syntax
thingType.asRemote(Transaction tx).getInstances();
Returns
  • Stream<[Thing] >

Set abstract
Syntax
thingType.asRemote(Transaction tx).setAbstract();
Description

Set a ThingType to be abstract, meaning it cannot have instances.

Returns
  • void

Unset abstract
Syntax
thingType.asRemote(Transaction tx).unsetAbstract();
Description

Set a ThingType to be non-abstract, meaning it can have instances.

Returns
  • void

Add new playable role
Syntax
thingType.asRemote(Transaction tx).setPlays(RoleType roleType, RoleType overriddenType);
Description

Allows the instances of this type to play the given role.

Input parameters
Name Description Type Required Default Value

roleType

The role to be played by the instances of this type.

[RoleType]

True

N/A

overriddenType

The role type that this role overrides, if applicable.

[RoleType]

False

None

Returns
  • void

Add attribute ownership
Syntax
thingType.asRemote(Transaction tx).setOwns(AttributeType attributeType, Set<TypeQLToken.Annotation> annotations);
Description

Allows the instances of this type to own the given AttributeType.

Input parameters
Name Description Type Required Default Value

attributeType

The AttributeType to be owned by the instances of this type.

[AttributeType]

True

N/A

annotations

Adds annotations (KEY or UNIQUE) to the ownership.

set of Annotation

False

Collections.emptySet();

Returns
  • void

Add attribute ownership (overriden)
Syntax
thingType.asRemote(Transaction tx).setOwns(AttributeType attributeType, AttributeType overriddenType, Set<TypeQLToken.Annotation> annotations);
Description

Allows the instances of this type to own the given AttributeType.

Input parameters
Name Description Type Required Default Value

attributeType

The AttributeType to be owned by the instances of this type.

[AttributeType]

True

N/A

overriddenType

The AttributeType that this attribute ownership overrides, if applicable.

[AttributeType]

False

None

annotations

Adds annotations (KEY or UNIQUE) to the ownership.

set of Annotation

False

Collections.emptySet();

Returns
  • void

Retrieve playable roles
Syntax
thingType.asRemote(Transaction tx).getPlays();
Description

Retrieves all direct and inherited roles that are allowed to be played by the instances of this type.

Returns
  • Stream<[RoleType] >

Retrieve playable roles
Syntax
thingType.asRemote(Transaction tx).getPlaysExplicit();
Description

Retrieves all direct roles that are allowed to be played by the instances of this type.

Returns
  • Stream<[RoleType] >

Retrieve attributes
Syntax
thingType.asRemote(Transaction tx).getOwns(Set<TypeQLToken.Annotation> annotations);
Description

Retrieves attribute types that the instances of this type are allowed to own directly or via inheritance.

Input parameters
Name Description Type Required Default Value

annotations

Only retrieve attribute types owned with annotations (KEY or UNIQUE).

set of Annotation

False

Collections.emptySet();

Returns
  • Stream<[AttributeType] >

Retrieve attributes
Syntax
thingType.asRemote(Transaction tx).getOwnsExplicit(Set<TypeQLToken.Annotation> annotations);
Description

Retrieves attribute types that the instances of this type are allowed to own directly.

Input parameters
Name Description Type Required Default Value

annotations

Only retrieve attribute types owned with annotations (KEY or UNIQUE).

set of Annotation

False

Collections.emptySet();

Returns
  • Stream<[AttributeType] >

Retrieve attributes
Syntax
thingType.asRemote(Transaction tx).getOwns(AttributeType.ValueType valueType, Set<TypeQLToken.Annotation> annotations);
Description

Retrieves attribute types that the instances of this type are allowed to own directly or via inheritance.

Input parameters
Name Description Type Required Default Value

valueType

If specified, only attribute types of this ValueType will be retrieved.

AttributeType.ValueType

False

None

annotations

Only retrieve attribute types owned with annotations (KEY or UNIQUE).

set of Annotation

False

Collections.emptySet();

Returns
  • Stream<[AttributeType] >

Retrieve attributes
Syntax
thingType.asRemote(Transaction tx).getOwnsExplicit(AttributeType.ValueType valueType, Set<TypeQLToken.Annotation> annotations);
Description

Retrieves attribute types that the instances of this type are allowed to own directly.

Input parameters
Name Description Type Required Default Value

valueType

If specified, only attribute types of this ValueType will be retrieved.

AttributeType.ValueType

False

None

annotations

Only retrieve attribute types owned with annotations (KEY or UNIQUE).

set of Annotation

False

Collections.emptySet();

Returns
  • Stream<[AttributeType] >

Remove role
Syntax
thingType.asRemote(Transaction tx).unsetPlays(RoleType role);
Description

Disallows the instances of this type from playing the given role.

Input parameters
Name Description Type Required Default Value

role

The role to not be played by the instances of this type.

[RoleType]

True

N/A

Returns
  • void

Remove attribute
Syntax
thingType.asRemote(Transaction tx).unsetOwns(AttributeType attributeType);
Description

Disallows the instances of this type from owning the given AttributeType.

Input parameters
Name Description Type Required Default Value

attributeType

The AttributeType to not be owned by the type.

[AttributeType]

True

N/A

Returns
  • void

EntityType methods

EntityType has all the ThingType methods plus what follows.

Create instance
Syntax
entityType.asRemote(Transaction tx).create();
Description

Creates and returns a new instance of this EntityType.

Returns
  • [Entity]

Set supertype
Syntax
entityType.asRemote(Transaction tx).setSupertype(EntityType entityType);
Description

Sets the supplied EntityType as the supertype of the current EntityType

Input parameters
Name Description Type Required Default Value

entityType

The EntityType to set as the supertype of this EntityType

EntityType

True

N/A

Returns
  • void

Retrieve all subtypes
Syntax
type.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the EntityType.

Returns
  • Stream<[EntityType] >

Retrieve all instances of this EntityType
Syntax
type.asRemote(Transaction tx).getInstances();
Description

Retrieves all direct and indirect Entity objects that are instances of this Type.

Returns
  • Stream<[Entity] >

Get a Remote version of the EntityType.
Syntax
entityType.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • EntityType.Remote

RelationType methods

RelationType has all the ThingType methods plus what follows.

Create instance
Syntax
relationType.asRemote(Transaction tx).create();
Description

Creates and returns an instance of this RelationType.

Returns
  • [Relation]

Retrieve roles
Syntax
relationType.asRemote(Transaction tx).getRelates();
Description

Retrieve roles that this RelationType relates to directly or via inheritance.

Returns
  • [Stream] <[RoleType] >

Retrieve direct roles
Syntax
relationType.asRemote(Transaction tx).getRelatesExplicit();
Description

Retrieve roles that this RelationType relates to directly.

Returns
  • [Stream] <[RoleType] >

Retrieve specific role
Syntax
relationType.asRemote(Transaction tx).getRelates(String label);
Description

Retrieve the role that this RelationType relates to, if it exists, with the specified label.

Input parameters
Name Description Type Required Default Value

label

Label of the role we wish to retrieve.

string

True

Returns
  • [RoleType]

Set new role
Syntax
relationType.asRemote(Transaction tx).setRelates(String label, String overriddenRoleLabel);
Description

Sets the new role that this RelationType relates to. If we are setting an overriding type this way, we have to also pass the overridden type as a second argument.

Input parameters
Name Description Type Required Default Value

label

The new role for the RelationType to relate to.

string

True

N/A

overriddenRoleLabel

The label being overridden, if applicable

string

False

N/A

Returns
  • void

Remove role
Syntax
relationType.asRemote(Transaction tx).unsetRelates(RoleType role);
Description

Disallows this RelationType from relating to the given role.

Input parameters
Name Description Type Required Default Value

role

The role to not relate to the relation type.

RoleType

True

N/A

Returns
  • void

Set supertype
Syntax
relationType.asRemote(Transaction tx).setSupertype(RelationType relationType);
Description

Sets the supplied RelationType as the supertype of the current RelationType

Input parameters
Name Description Type Required Default Value

relationType

The RelationType to set as the supertype of this RelationType

RelationType

True

N/A

Returns
  • void

Retrieve all subtypes
Syntax
type.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the RelationType.

Returns
  • Stream<[RelationType] >

Retrieve all instances of this RelationType
Syntax
type.asRemote(Transaction tx).getInstances();
Description

Retrieves all direct and indirect Relations that are instances of this Type.

Returns
  • Stream<[Relation] >

Get a Remote version of the RelationType.
Syntax
relationType.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RelationType.Remote

RoleType methods

RoleType has all the Type methods plus what follows.

Get a Remote version of the role type.
Syntax
roleType.asRemote(tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RoleType.Remote

Retrieve scope (Local)
Syntax
roleType.getLabel().scope();
Description

Retrieves the scope (defined relation label) of the role type.

Returns
  • String

Retrieve scoped label (Local)
Syntax
roleType.getLabel().scopedName();
Description

Retrieves the scoped label (relation:role) of the role type.

Returns
  • String

Retrieve direct supertype
Syntax
type.asRemote(Transaction tx).getSupertype();
Description

Retrieves the most immediate supertype of the role type.

Returns
  • [RoleType]

  • null

Retrieve all supertypes
Syntax
type.asRemote(Transaction tx).getSupertypes();
Description

Retrieves all supertypes of the role type.

Returns
  • Stream<[RoleType] >

Retrieve all subtypes
Syntax
type.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the type.

Returns
  • Stream<[RoleType] >

Retrieve relation
Syntax
role.asRemote(Transaction tx).getRelationType();
Description

Retrieves the Relation instance that this role is directly related to.

Returns
  • [RelationType] >

Retrieve relation types
Syntax
role.asRemote(Transaction tx).getRelationTypes();
Description

Retrieves the RelationTypes that this role is related to.

Returns
  • Stream<[RelationType] >

Retrieve role players
Syntax
role.asRemote(Transaction tx).getPlayers();
Description

Retrieves the ThingTypes whose instances play this role.

Returns
  • Stream<[ThingType](/docs/concept-api/type?tab=java)>

AttributeType methods

AttributeType has all the ThingType methods plus what follows.

Retrieve valuetype (Local)
Syntax
attributeType.getValueType();
Description

Retrieves the valuetype of this AttributeType.

Returns
  • AttributeType.ValueType (STRING | DATETIME | LONG | DOUBLE | BOOLEAN)

Set supertype
Syntax
attributeType.asRemote(Transaction tx).setSupertype(AttributeType attributeType);
Description

Sets the supplied AttributeType as the supertype of the current AttributeType

Input parameters
Name Description Type Required Default Value

attributeType

The AttributeType to set as the supertype of this AttributeType

AttributeType

True

N/A

Returns
  • void

Retrieve all subtypes
Syntax
attributeType.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the AttributeType.

Returns
Retrieve all instances of this AttributeType
Syntax
attributeType.asRemote(Transaction tx).getInstances();
Description

Retrieves all direct and indirect Attributes that are instances of this Type.

Returns
Retrieve direct and inherited owners of this Type of Attribute
Syntax
attributeType.asRemote(Transaction tx).getOwners(Set<TypeQLToken.Annotation> annotations);
Description

Retrieve all Things that own an attribute of this type.
Optionally, filtered by annotations provided.

Input parameters
Name Description Type Required Default Value

annotations

Only retrieve things that have an attribute of this type with annotations (KEY or UNIQUE).

set of Annotation

False

Collections.emptySet();

Returns
Retrieve direct owners of this Type of Attribute
Syntax
attributeType.asRemote(Transaction tx).getOwnersExplicit(Set<TypeQLToken.Annotation> annotations);
Description

Retrieve all Things that directly own an attribute of this type.
Optionally, filtered by annotations provided.

Input parameters
annotations

Only retrieve things that have an attribute of this type with annotations (KEY or UNIQUE).

set of Annotation

False

Collections.emptySet();

Returns
Get a Remote version of the AttributeType.
Syntax
attributeType.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • AttributeType.Remote

Check if value is of type boolean
Syntax
attributeType.isBoolean();
Description

Returns true if the value for attributes of this type is of type boolean. Otherwise, returns false.

Check if value is of type long
Syntax
attributeType.isLong();
Description

Returns true if the value for attributes of this type is of type long. Otherwise, returns false.

Check if value is of type double
Syntax
attributeType.isDouble();
Description

Returns true if the value for attributes of this type is of type double. Otherwise, returns false.

Check if value is of type string
Syntax
attributeType.isString();
Description

Returns true if the value for attributes of this type is of type string. Otherwise, returns false.

Check if value is of type datetime
Syntax
attributeType.isDateTime();
Description

Returns true if the value for attributes of this type datetime. Otherwise, returns false.

BooleanAttributeType methods

BooleanAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
booleanAttributeType.asRemote(Transaction tx).put(boolean value);
Description

Puts and returns a new instance of this BooleanAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

boolean

True

N/A

Returns
  • BooleanAttribute object

Get instance
Syntax
booleanAttributeType.asRemote(Transaction tx).get(Boolean value);
Description

Returns the instance, if it exists, of this BooleanAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

boolean

True

N/A

Returns
  • BooleanAttribute object

Set supertype
Syntax
booleanAttributeType.asRemote(Transaction tx).setSupertype(AttributeType.Boolean booleanAttributeType);
Description

Sets the supplied BooleanAttributeType as the supertype of the current BooleanAttributeType

Input parameters
Name Description Type Required Default Value

booleanAttributeType

The AttributeType to set as the supertype of this BooleanAttributeType

BooleanAttributeType

True

N/A

Returns
  • void

Retrieve all subtypes
Syntax
booleanAttributeType.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the BooleanAttributeType.

Returns
Retrieve all instances of this BooleanAttributeType
Syntax
booleanAttributeType.asRemote(Transaction tx).getInstances();
Description

Retrieves all direct and indirect BooleanAttributes that are instances of this Type.

Returns
Get a Remote version of the BooleanAttributeType.
Syntax
booleanAttributeType.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • BooleanAttributeType.Remote

LongAttributeType methods

LongAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
longAttributeType.asRemote(Transaction tx).put(long value);
Description

Puts and returns a new instance of this LongAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

long

True

N/A

Returns
  • LongAttribute

Get instance
Syntax
longAttributeType.asRemote(Transaction tx).get(long value);
Description

Returns the instance, if it exists, of this LongAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

long

True

N/A

Returns
  • LongAttribute

Set Supertype
Syntax
attributeType.asRemote(Transaction tx).setSupertype(AttributeType.Long longAttributeType);
Description

Sets the supplied LongAttributeType as the supertype of the current LongAttributeType

Input parameters
Name Description Type Required Default Value

longAttributeType

The AttributeType to set as the supertype of this LongAttributeType

LongAttributeType

True

N/A

Returns
  • void

Retrieve all subtypes
Syntax
type.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the LongAttributeType.

Returns
  • Stream<[AttributeType.Long] >

Retrieve all instances of this LongAttributeType
Syntax
type.asRemote(Transaction tx).getInstances();
Description

Retrieves all direct and indirect LongAttributes that are instances of this Type.

Returns
  • Stream<[LongAttribute] >

Get a Remote version of the LongAttributeType.
Syntax
longAttributeType.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • LongAttributeType.Remote

DoubleAttributeType methods

DoubleAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
doubleAttributeType.asRemote(Transaction tx).put(double value);
Description

Puts and returns a new instance of this DoubleAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

double

True

N/A

Returns
  • DoubleAttribute

Get instance
Syntax
doubleAttributeType.asRemote(Transaction tx).get(double value);
Description

Returns the instance, if it exists, of this DoubleAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

long

True

N/A

Returns
  • DoubleAttribute

Set Supertype
Syntax
attributeType.asRemote(Transaction tx).setSupertype(AttributeType.Double doubleAttributeType);
Description

Sets the supplied DoubleAttributeType as the supertype of the current DoubleAttributeType

Input parameters
Name Description Type Required Default Value

doubleAttributeType

The AttributeType to set as the supertype of this DoubleAttributeType

DoubleAttributeType

True

N/A

Returns
  • void

Retrieve all subtypes
Syntax
type.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the DoubleAttributeType.

Returns
  • Stream<[AttributeType.Double] >

Retrieve all instances of this DoubleAttributeType
Syntax
type.asRemote(Transaction tx).getInstances();
Description

Retrieves all direct and indirect DoubleAttributes that are instances of this Type.

Returns
  • Stream<[DoubleAttribute] >

Get a Remote version of the DoubleAttributeType.
Syntax
doubleAttributeType.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • DoubleAttributeType.Remote

StringAttributeType methods

StringAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
stringAttributeType.asRemote(Transaction tx).put(String value);
Description

Puts and returns a new instance of this StringAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

string

True

N/A

Returns
  • StringAttribute

Get instance
Syntax
stringAttributeType.asRemote(Transaction tx).get(String value);
Description

Returns the instance, if it exists, of this StringAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

string

True

N/A

Returns
  • StringAttribute

Retrieve regex
Syntax
stringAttributeType.asRemote(Transaction tx).getRegex();
Description

Retrieves the regex that all instances of this StringAttributeType must conform to.

Returns
  • string

  • null

Set regex
Syntax
stringAttributeType.asRemote(Transaction tx).setRegex(String regex);
Description

Set the regex that all instances of this StringAttributeType must conform to.

Input parameters
Name Description Type Required Default Value

regex

The regex that all instances of this StringAttributeType must conform to.

string

True

N/A

Returns
  • void

Set Supertype
Syntax
attributeType.asRemote(Transaction tx).setSupertype(AttributeType.String stringAttributeType);
Description

Sets the supplied StringAttributeType as the supertype of the current StringAttributeType

Input parameters
Name Description Type Required Default Value

stringAttributeType

The AttributeType to set as the supertype of this StringAttributeType

StringAttributeType

True

N/A

Returns
  • void

Retrieve all subtypes
Syntax
type.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the StringAttributeType.

Returns
  • Stream<[AttributeType.String] >

Retrieve all instances of this StringAttributeType
Syntax
type.asRemote(Transaction tx).getInstances();
Description

Retrieves all direct and indirect StringAttributes that are instances of this Type.

Returns
  • Stream<[StringAttribute] >

Get a Remote version of the StringAttributeType.
Syntax
stringAttributeType.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • StringAttributeType.Remote

DateTimeAttributeType methods

DateTimeAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
datetimeAttributeType.asRemote(Transaction tx).put(LocalDateTime value);
Description

Puts and returns a new instance of this DateTimeAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

LocalDateTime

True

N/A

Returns
  • DateTimeAttribute object

Get instance
Syntax
datetimeAttributeType.asRemote(Transaction tx).get(LocalDateTime value);
Description

Returns the instance, if it exists, of this DateTimeAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

LocalDateTime

True

N/A

Returns
  • DateTimeAttribute object

Set Supertype
Syntax
attributeType.asRemote(Transaction tx).setSupertype(AttributeType.DateTime datetimeAttributeType);
Description

Sets the supplied DateTimeAttributeType as the supertype of the current DateTimeAttributeType

Input parameters
Name Description Type Required Default Value

dateTimeAttributeType

The AttributeType to set as the supertype of this DateTimeAttributeType

DateTimeAttributeType

True

N/A

Returns
  • void

Retrieve all subtypes
Syntax
type.asRemote(Transaction tx).getSubtypes();
Description

Retrieves all direct and indirect subtypes of the DateTimeAttributeType.

Returns
  • Stream<[AttributeType.DateTime] >

Retrieve all instances of this DateTimeAttributeType
Syntax
type.asRemote(Transaction tx).getInstances();
Description

Retrieves all direct and indirect DateTimeAttributes that are instances of this Type.

Returns
  • Stream<[DateTimeAttribute] >

Get a Remote version of the DateTimeAttributeType.
Syntax
dateTimeAttributeType.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • DateTimeAttributeType.Remote

Rule methods

Retrieve label (Local)

Syntax
rule.getLabel();
Description

Retrieves the unique label of the rule.

Returns
  • String

Get a Remote version of the rule.

Syntax
rule.asRemote(tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • Rule.Remote

Retrieve the when body (Local)

Syntax
rule.getWhen();
Description

Retrieves the statements that constructs the when body of the rule.

Returns
  • string

Retrieve the then body (Local)

Syntax
rule.getThen();
Description

Retrieves the single statement that constructs the then body of the rule.

Returns
  • string

Rename label

Syntax
rule.asRemote(Transaction tx).setLabel(String label);
Description

Renames the label of the rule. The new label must remain unique.

Input parameters
Name Description Type Required Default Value

label

The new label to be given to the rule.

String

True

N/A

Returns
  • void

Delete rule

Syntax
rule.asRemote(Transaction tx).delete();
Returns
  • null

Check if the rule has been deleted

Syntax
rule.asRemote(Transaction tx).isDeleted();
Returns
  • boolean

LogicManager

Retrieve a Rule
Syntax
transaction.logic().getRule(String label);
Description

Retrieves the Rule that has the given label.

Input parameters
Name Description Type Required Default Value

label

The label of the Rule to create or retrive.

String

True

N/A

Returns
  • [Rule]

Create or retrieve a Rule
Syntax
transaction.logic().putRule(String label, Pattern when, Pattern then);
Description

Creates a new Rule if none exists with the given label, or retrieves the existing one.

Input parameters
Name Description Type Required Default Value

label

The label of the Rule to create or retrive.

String

True

N/A

when

The pattern describing the when body of the rule.

[com.vaticle.typeql.lang.pattern.Pattern]

True

N/A

then

The pattern describing the then body of the rule.

[com.vaticle.typeql.lang.pattern.Pattern]

True

N/A

Returns
  • [Rule]


Data methods

Data has all the Concept methods plus what follows.

Retrieves internal ID (Local)

Syntax
thing.getIID();
Description

Retrieves the unique id of the Thing.

Returns
  • string

Get a Remote version of the Thing.

Syntax
thing.asRemote(tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • Thing.Remote

Retrieve type (Local)

Syntax
thing.getType();
Description

Retrieves the type which this Thing belongs to.

Returns
  • [ThingType]

Check if inferred (Local)

Syntax
thing.isInferred();
Description

Checks if this Thing is inferred by a [Reasoning Rule] .

Returns
  • boolean

Assign attribute

Syntax
thing.asRemote(Transaction tx).setHas(Attribute<?> attribute);
Description

Assigns an Attribute to be owned by this Thing.

Input parameters
Name Description Type Required Default Value

attribute

The Attribute to be owned by this Thing.

[Attribute<?>]

True

N/A

Returns
  • [Thing]

Unassign attribute

Syntax
thing.asRemote(Transaction tx).unsetHas(Attribute<?> attribute);
Description

Unassigns an Attribute from this Thing.

Input parameters
Name Description Type Required Default Value

attribute

The Attribute to be disowned from this Thing.

[Attribute]

True

N/A

Returns
  • [Thing]

Retrieve attributes

Syntax
thing.asRemote(Transaction tx).getHas(Set<TypeQLToken.Annotation> annotations);
Description

Retrieves the Attributes that this Thing owns.
Optionally, filtered by annotations provided.

Input parameters
Name Description Type Required Default Value

annotations

Only retrieve attributes with annotations (KEY or UNIQUE).

set of Annotation

False

Collections.emptySet();

Returns
  • Stream<[Attribute<?>] >

Retrieve attributes

Syntax
thing.asRemote(Transaction tx).getHas(AttributeType attributeType);
Description

Retrieves the Attributes that this Thing owns, optionally filtered by one or more AttributeTypes.

Input parameters
Name Description Type Required Default Value

attributeType

The AttributeType to filter the attributes by.

[AttributeType]

False

None

Returns
  • Stream<[Attribute] >

Retrieve attributes

Syntax
thing.asRemote(Transaction tx).getHas(AttributeType... attributeTypes);
Description

Retrieves the Attributes that this Thing owns, optionally filtered by one or more AttributeTypes.

Input parameters
Name Description Type Required Default Value

attributeTypes

The AttributeTypes to filter the attributes by.

[AttributeType…​]

False

(empty array)

Returns
  • Stream<[Attribute] >

Retrieve roles

Syntax
thing.asRemote(Transaction tx).getPlaying();
Description

Retrieves the roles that this Thing is currently playing.

Returns
  • Stream of [RoleType]

Retrieve relations

Syntax
thing.asRemote(Transaction tx).getRelations(RoleType... roleTypes);
Description

Retrieves all the Relations which this Thing plays a role in, optionally filtered by one or more given roles.

Input parameters
Name Description Type Required Default Value

roleTypes

The list of roles to filter the relations by.

[RoleType…​]

False

N/A

Returns
  • Stream<[Relation] >

Retrieve a Thing as JSON.

Syntax
thing.toJSON();
Returns
  • JSON

Entity methods

Entity has all the Data methods plus what follows.

Retrieve type (Local)
Syntax
entity.getType();
Description

Retrieves the type which this Entity belongs to.

Returns
  • [EntityType]

Get a Remote version of the Entity.
Syntax
entity.asRemote(tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • Entity.Remote

Relation methods

Relation has all the Data methods plus what follows.

Retrieve type (Local)
Syntax
relation.getType();
Description

Retrieves the type which this Relation belongs to.

Returns
  • [RelationType]

Retrieve role players per role
Syntax
relation.asRemote(Transaction tx).getPlayersByRoleType();
Description

Retrieves a map of all instances involved in the Relation and the role each play.

Returns
  • Map<[RoleType] , List<[Thing] >>

Retrieve role types currently played
Syntax
relation.asRemote(Transaction tx).getRelating();
Description

Retrieves all role types currently played in this Relation.

Returns
  • Stream<[RoleType] >

Retrieve role players
Syntax
relation.asRemote(Transaction tx).getPlayers(RoleType... roleTypes);
Description

Retrieves all roleplayers of this this Relation, optionally filtered by given role types.

Input parameters
Name Description Type Required Default Value

role

The roles to filter the role players by.

[RoleType…​]

False

N/A

Returns
  • Stream<[Thing] >

Add roleplayer
Syntax
relation.asRemote(Transaction tx).addPlayer(RoleType role, Thing thing);
Description

Adds a new roleplayer to play the given role in this Relation.

Input parameters
Name Description Type Required Default Value

role

The role to be played by the thing

[RoleType]

True

N/A

thing

The thing to play the role

[Thing]

True

N/A

Returns
  • void

Remove a roleplayer
Syntax
relation.asRemote(Transaction tx).removePlayer(RoleType role, Thing thing);
Description

Removes the association of the given instance that plays the given role in this Relation.

Input parameters
Name Description Type Required Default Value

role

The role to no longer be played by the thing in this Relation.

[RoleType]

True

N/A

thing

The instance to no longer play the role in this Relation.

[Thing]

True

N/A

Returns
  • void

Get a Remote version of the Relation.
Syntax
relation.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • Relation.Remote

Attribute methods

Attribute has all the Data methods plus what follows.

Retrieve type (Local)
Syntax
attribute.getType();
Description

Retrieves the type which this Attribute belongs to.

Returns
Retrieve value (Local)
Syntax
attribute.getValue();
Description

Retrieves the value which the Attribute instance holds.

Returns
  • string

  • long

  • float

  • boolean

  • date

Retrieve owners
Syntax
attribute.asRemote(Transaction tx).getOwners(Type ownerType);
Description

Retrieves the instances that own this Attribute.

Input parameters
Name Description Type Required Default Value

ownerType

If specified, filter results for only owners of the given type

Type

False

N/A

Returns
Get a Remote version of the Attribute.
Syntax
concept.asRemote(Transaction tx);
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • Attribute.Remote

Check if value is of type boolean (Local)
Syntax
attribute.isBoolean();
Description

Returns true if the attribute value is of type boolean. Otherwise, returns false.

Returns
  • boolean

Check if value is of type long (Local)
Syntax
attribute.isLong();
Description

Returns true if the attribute value is of type long. Otherwise, returns false.

Returns
  • boolean

Check if value is of type double (Local)
Syntax
attribute.isDouble();
Description

Returns true if the attribute value is of type double. Otherwise, returns false.

Returns
  • boolean

Check if value is of type string (Local)
Syntax
attribute.isString();
Description

Returns true if the attribute value is of type string. Otherwise, returns false.

Returns
  • boolean

Check if value is of type datetime (Local)
Syntax
attribute.isDateTime();
Description

Returns true if the attribute value is of type datetime. Otherwise, returns false.

Returns
  • boolean

Retrieve an attribute as JSON.
Syntax
attribute.toJSON();
Returns
  • JSON with fields type, value_type and value

Value methods

Value has all the concept methods plus what follows.

Retrieve value (Local)

Syntax
value.getValue();
Description

Retrieves the value which the value variable holds.

Returns
  • string

  • long

  • float

  • boolean

  • date

Retrieve valuetype (Local)

Syntax
value.getValueType();
Description

Retrieves the valuetype of the value in value variable.

Returns
  • ValueType (STRING | DATETIME | LONG | DOUBLE | BOOLEAN)