Class Graph
- java.lang.Object
-
- uk.gov.gchq.gaffer.graph.Graph
-
public final class Graph extends Object
The Graph separates the user from the
Store
. It holds an instance of theStore
and acts as a proxy for the store, delegatingOperation
s to the store.The Graph provides users with a single point of entry for executing operations on a store. This allows the underlying store to be swapped and the same operations can still be applied.
Graphs also provides a view of the data with a instance of
View
. The view filters out unwanted information and can transformProperties
into transient properties such as averages.When executing operations on a graph, an operation view would override the graph view.
- See Also:
Graph.Builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Graph.Builder
Builder forGraph
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
<O> GraphResult<O>
execute(GraphRequest<O> request)
Executes aGraphRequest
on the graph and returns theGraphResult
.<O> O
execute(Output<O> operation, Context context)
Performs the given output operation on the store.<O> O
execute(Output<O> operation, User user)
Performs the given output operation on the store.void
execute(Operation operation, Context context)
Performs the given operation on the store.void
execute(Operation operation, User user)
Performs the given operation on the store.GraphResult<JobDetail>
executeJob(GraphRequest<?> request)
Executes the givenGraphRequest
on the graph as an asynchronous job and returns aGraphResult
containing theJobDetail
s.JobDetail
executeJob(Job job, Context context)
Performs the given Job on the store.JobDetail
executeJob(Job job, User user)
Performs the given Job on the store.JobDetail
executeJob(Operation operation, Context context)
Performs the given operation job on the store.JobDetail
executeJob(Operation operation, User user)
Performs the given operation job on the store.List<Cache<?,?>>
getCaches()
GraphConfig
getConfig()
Returns the currentGraphConfig
that holds the configuration for the graph.String
getCreatedTime()
String
getDescription()
Returns the description held in theGraphConfig
.List<Class<? extends GraphHook>>
getGraphHooks()
Returns the graph hooks from theGraphConfig
String
getGraphId()
GraphLibrary
getGraphLibrary()
Set<Class<? extends Operation>>
getNextOperations(Class<? extends Operation> operation)
Schema
getSchema()
Get the Store's originalSchema
.StoreProperties
getStoreProperties()
Set<Class<? extends Operation>>
getSupportedOperations()
View
getView()
Returns the graph view from theGraphConfig
.int
hashCode()
boolean
isSupported(Class<? extends Operation> operationClass)
-
-
-
Method Detail
-
execute
public void execute(Operation operation, User user) throws OperationException
Performs the given operation on the store. If the operation does not have a view then the graph view is used.- Parameters:
operation
- the operation to be executed.user
- the user executing the operation.- Throws:
OperationException
- if an operation fails
-
execute
public void execute(Operation operation, Context context) throws OperationException
Performs the given operation on the store. If the operation does not have a view then the graph view is used. The context will be cloned and a new jobId will be created.- Parameters:
operation
- the operation to be executed.context
- the user context for the execution of the operation- Throws:
OperationException
- if an operation fails
-
execute
public <O> O execute(Output<O> operation, User user) throws OperationException
Performs the given output operation on the store. If the operation does not have a view then the graph view is used.- Type Parameters:
O
- the operation chain output type.- Parameters:
operation
- the output operation to be executed.user
- the user executing the operation.- Returns:
- the operation result.
- Throws:
OperationException
- if an operation fails
-
execute
public <O> O execute(Output<O> operation, Context context) throws OperationException
Performs the given output operation on the store. If the operation does not have a view then the graph view is used. The context will be cloned and a new jobId will be created.- Type Parameters:
O
- the operation chain output type.- Parameters:
operation
- the output operation to be executed.context
- the user context for the execution of the operation.- Returns:
- the operation result.
- Throws:
OperationException
- if an operation fails
-
execute
public <O> GraphResult<O> execute(GraphRequest<O> request) throws OperationException
Executes aGraphRequest
on the graph and returns theGraphResult
.- Type Parameters:
O
- the result type- Parameters:
request
- the request to execute- Returns:
GraphResult
containing the result and details- Throws:
OperationException
- if an operation fails
-
executeJob
public JobDetail executeJob(Operation operation, User user) throws OperationException
Performs the given operation job on the store. If the operation does not have a view then the graph view is used.- Parameters:
operation
- the operation to be executed.user
- the user executing the job.- Returns:
- the job details
- Throws:
OperationException
- thrown if the job fails to run.
-
executeJob
public JobDetail executeJob(Operation operation, Context context) throws OperationException
Performs the given operation job on the store. If the operation does not have a view then the graph view is used. The context will be cloned and a new jobId will be created.- Parameters:
operation
- the operation to be executed.context
- the user context for the execution of the operation- Returns:
- the job details
- Throws:
OperationException
- thrown if the job fails to run.
-
executeJob
public GraphResult<JobDetail> executeJob(GraphRequest<?> request) throws OperationException
Executes the givenGraphRequest
on the graph as an asynchronous job and returns aGraphResult
containing theJobDetail
s. If the operation does not have a view then the graph view is used. The context will be cloned and a new jobId will be created.- Parameters:
request
- the request to execute- Returns:
GraphResult
containing the job details- Throws:
OperationException
- thrown if the job fails to run.
-
executeJob
public JobDetail executeJob(Job job, User user) throws OperationException
Performs the given Job on the store. This should be used for Scheduled Jobs, although if no repeat is set it will act as a normal Job.- Parameters:
job
- theJob
to execute, which contains theOperationChain
and theRepeat
user
- the user running the Job.- Returns:
- the job detail.
- Throws:
OperationException
- thrown if the job fails to run.
-
executeJob
public JobDetail executeJob(Job job, Context context) throws OperationException
Performs the given Job on the store. This should be used for Scheduled Jobs, although if no repeat is set it will act as a normal Job.- Parameters:
job
- theJob
to execute, which contains theOperationChain
and theRepeat
context
- the user context for the execution of the operation- Returns:
- the job detail
- Throws:
OperationException
- thrown if the job fails to run.
-
isSupported
public boolean isSupported(Class<? extends Operation> operationClass)
- Parameters:
operationClass
- the operation class to check- Returns:
- true if the provided operation is supported.
-
getConfig
public GraphConfig getConfig()
Returns the currentGraphConfig
that holds the configuration for the graph.- Returns:
- The graph config.
-
getView
public View getView()
Returns the graph view from theGraphConfig
.- Returns:
- the graph view.
-
getDescription
public String getDescription()
Returns the description held in theGraphConfig
.- Returns:
- the description
-
getGraphHooks
public List<Class<? extends GraphHook>> getGraphHooks()
Returns the graph hooks from theGraphConfig
- Returns:
- The list of
GraphHook
s
-
getSupportedOperations
public Set<Class<? extends Operation>> getSupportedOperations()
- Returns:
- a collection of all the supported
Operation
s.
-
getNextOperations
public Set<Class<? extends Operation>> getNextOperations(Class<? extends Operation> operation)
- Parameters:
operation
- the class of the operation to check- Returns:
- a collection of all the compatible
Operation
s that could be added to an operation chain after the provided operation.
-
getSchema
public Schema getSchema()
Get the Store's originalSchema
.This is not the same as the
Schema
used internally by theStore
. SeeStore.getOriginalSchema()
andStore.getSchema()
for more details.- Returns:
- the original
Schema
used to create this graph
-
getGraphId
public String getGraphId()
- Returns:
- the graphId for this Graph.
-
getStoreProperties
public StoreProperties getStoreProperties()
- Returns:
- the StoreProperties for this Graph.
-
getGraphLibrary
public GraphLibrary getGraphLibrary()
-
getCreatedTime
public String getCreatedTime()
-
-