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 theStoreand acts as a proxy for the store, delegatingOperations 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 transformPropertiesinto 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 classGraph.BuilderBuilder forGraph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)<O> GraphResult<O>execute(GraphRequest<O> request)Executes aGraphRequeston the graph and returns theGraphResult.<O> Oexecute(Output<O> operation, Context context)Performs the given output operation on the store.<O> Oexecute(Output<O> operation, User user)Performs the given output operation on the store.voidexecute(Operation operation, Context context)Performs the given operation on the store.voidexecute(Operation operation, User user)Performs the given operation on the store.GraphResult<JobDetail>executeJob(GraphRequest<?> request)Executes the givenGraphRequeston the graph as an asynchronous job and returns aGraphResultcontaining theJobDetails.JobDetailexecuteJob(Job job, Context context)Performs the given Job on the store.JobDetailexecuteJob(Job job, User user)Performs the given Job on the store.JobDetailexecuteJob(Operation operation, Context context)Performs the given operation job on the store.JobDetailexecuteJob(Operation operation, User user)Performs the given operation job on the store.List<Cache<?,?>>getCaches()GraphConfiggetConfig()Returns the currentGraphConfigthat holds the configuration for the graph.StringgetCreatedTime()StringgetDescription()Returns the description held in theGraphConfig.List<Class<? extends GraphHook>>getGraphHooks()Returns the graph hooks from theGraphConfigStringgetGraphId()GraphLibrarygetGraphLibrary()Set<Class<? extends Operation>>getNextOperations(Class<? extends Operation> operation)SchemagetSchema()Get the Store's originalSchema.StorePropertiesgetStoreProperties()Set<Class<? extends Operation>>getSupportedOperations()ViewgetView()Returns the graph view from theGraphConfig.inthashCode()booleanisSupported(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 aGraphRequeston the graph and returns theGraphResult.- Type Parameters:
O- the result type- Parameters:
request- the request to execute- Returns:
GraphResultcontaining 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 givenGraphRequeston the graph as an asynchronous job and returns aGraphResultcontaining theJobDetails. 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:
GraphResultcontaining 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- theJobto execute, which contains theOperationChainand theRepeatuser- 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- theJobto execute, which contains theOperationChainand theRepeatcontext- 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 currentGraphConfigthat 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
GraphHooks
-
getSupportedOperations
public Set<Class<? extends Operation>> getSupportedOperations()
- Returns:
- a collection of all the supported
Operations.
-
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
Operations 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
Schemaused internally by theStore. SeeStore.getOriginalSchema()andStore.getSchema()for more details.- Returns:
- the original
Schemaused 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()
-
-