Class FederatedStore
- java.lang.Object
-
- uk.gov.gchq.gaffer.store.Store
-
- uk.gov.gchq.gaffer.federatedstore.FederatedStore
-
public class FederatedStore extends Store
A Store that encapsulates a collection of sub-graphs and executes operations against them and returns results as though it was a single graph.
To create a FederatedStore you need to initialise the store with a graphId and (if graphId is not known by the
GraphLibrary
) theSchema
andStoreProperties
.- See Also:
initialise(String, Schema, StoreProperties)
,Store
,Graph
-
-
Field Summary
Fields Modifier and Type Field Description static String
FED_STORE_GRAPH_ID_VALUE_NULL_OR_EMPTY
static String
FEDERATED_STORE_PROCESSED
-
Constructor Summary
Constructors Constructor Description FederatedStore()
FederatedStore(Set<String> customPropertiesAuths, Boolean isPublicAccessAllowed, List<String> storeConfiguredGraphIds, Map<String,BiFunction> storeConfiguredMergeFunctions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExternallySupportedOperation(Class<? extends Operation> operation)
void
addGraphs(Set<String> graphAuths, String owningUserId, boolean isPublic, AccessPredicate readAccessPredicate, AccessPredicate writeAccessPredicate, GraphSerialisable... graphs)
void
addGraphs(Set<String> graphAuths, String owningUserId, boolean isPublic, GraphSerialisable... graphs)
Adds graphs to the scope of FederatedStore.void
addGraphs(FederatedAccess access, GraphSerialisable... graphs)
boolean
changeGraphAccess(User requestingUser, String graphId, FederatedAccess federatedAccess, boolean isAdmin)
boolean
changeGraphId(User requestingUser, String graphId, String newGraphId, boolean isAdmin)
Collection<String>
getAllGraphIds(User user)
List<String>
getAllGraphIds(User user, boolean userRequestingAdminUsage)
Map<String,Object>
getAllGraphsAndAuths(User user, List<String> graphIds, boolean userRequestingAdminUsage)
Set<Class<? extends Operation>>
getExternallySupportedOperations()
List<GraphSerialisable>
getGraphs(User user, List<String> graphIds, IFederationOperation operation)
Gets a collection of graph objects within FederatedStore scope from the given csv of graphIds, with visibility of the given user.Schema
getOriginalSchema()
GetSchema
for this FederatedStore (without a context)FederatedStoreProperties
getProperties()
Get this Store'sFederatedStoreProperties
.Schema
getSchema()
GetSchema
for this FederatedStore (without a context)Schema
getSchema(Context context, boolean getCompactSchema)
GetSchema
for this FederatedStore.List<String>
getStoreConfiguredGraphIds()
Map<String,BiFunction>
getStoreConfiguredMergeFunctions()
void
initialise(String graphId, Schema unused, StoreProperties properties)
Initialise this FederatedStore with any sub-graphs defined within the properties.boolean
isLimitedToLibraryProperties(User user)
The FederatedStore at time of initialisation, can set the auths required to allow users to use customStoreProperties
outside the scope of theGraphLibrary
.boolean
isLimitedToLibraryProperties(User user, boolean userRequestingAdminUsage)
boolean
remove(String graphId, User user, boolean removeCache)
Removes graphs from the scope of FederatedStore.boolean
remove(String graphId, User user, boolean removeCache, boolean asAdmin)
void
removeExternallySupportedOperation(Class<? extends Operation> operation)
void
setGraphLibrary(GraphLibrary library)
-
Methods inherited from class uk.gov.gchq.gaffer.store.Store
addOperationChainOptimisers, addOperationHandler, addOperationHandler, createContext, createStore, createStore, execute, execute, executeJob, executeJob, getCaches, getCreatedTime, getGraphId, getGraphLibrary, getJobTracker, getNextOperations, getOperationChainOptimisers, getOperationChainValidator, getOperationHandler, getSupportedOperations, handleOperation, isSupported, optimiseSchema, populateElement, runAsync, setOriginalSchema, updateJsonSerialiser, updateJsonSerialiser, validateSchemas
-
-
-
-
Field Detail
-
FEDERATED_STORE_PROCESSED
public static final String FEDERATED_STORE_PROCESSED
- See Also:
- Constant Field Values
-
FED_STORE_GRAPH_ID_VALUE_NULL_OR_EMPTY
public static final String FED_STORE_GRAPH_ID_VALUE_NULL_OR_EMPTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialise
public void initialise(String graphId, Schema unused, StoreProperties properties) throws StoreException
Initialise this FederatedStore with any sub-graphs defined within the properties.- Overrides:
initialise
in classStore
- Parameters:
graphId
- the graphId to label this FederatedStore.unused
- unusedproperties
- properties to initialise this FederatedStore with, can contain details on graphs to add to scope.- Throws:
StoreException
- if no cache has been set
-
setGraphLibrary
public void setGraphLibrary(GraphLibrary library)
- Overrides:
setGraphLibrary
in classStore
-
getProperties
public FederatedStoreProperties getProperties()
Get this Store'sFederatedStoreProperties
.- Overrides:
getProperties
in classStore
- Returns:
- the instance of
FederatedStoreProperties
, this may contain details such as database connection details.
-
addGraphs
public void addGraphs(Set<String> graphAuths, String owningUserId, boolean isPublic, GraphSerialisable... graphs) throws StorageException
Adds graphs to the scope of FederatedStore.To be used by the FederatedStore and Handlers only. Users should add graphs via the
AddGraph
operation. public access will be ignored if the FederatedStore denies this action at initialisation, will default to usual access with owningUserId and graphAuths- Parameters:
owningUserId
- the adding userIdgraphs
- the graph to addisPublic
- if this class should have public access.graphAuths
- the access auths for the graph being added- Throws:
StorageException
- if unable to put graph into storage
-
addGraphs
public void addGraphs(Set<String> graphAuths, String owningUserId, boolean isPublic, AccessPredicate readAccessPredicate, AccessPredicate writeAccessPredicate, GraphSerialisable... graphs) throws StorageException
- Throws:
StorageException
-
addGraphs
public void addGraphs(FederatedAccess access, GraphSerialisable... graphs) throws StorageException
- Throws:
StorageException
-
remove
public boolean remove(String graphId, User user, boolean removeCache)
Removes graphs from the scope of FederatedStore.
To be used by the FederatedStore and Handlers only. Users should remove graphs via the
RemoveGraph
operation.- Parameters:
graphId
- to be removed from scopeuser
- to match visibility againstremoveCache
- to remove associated caches with this graph.- Returns:
- success of removal
-
getExternallySupportedOperations
public Set<Class<? extends Operation>> getExternallySupportedOperations()
- Returns:
- a collection of all the
Operation
s supported by subgraphs.
-
removeExternallySupportedOperation
public void removeExternallySupportedOperation(Class<? extends Operation> operation)
-
addExternallySupportedOperation
public void addExternallySupportedOperation(Class<? extends Operation> operation)
-
getAllGraphIds
public Collection<String> getAllGraphIds(User user)
- Parameters:
user
- the visibility to use for getting graphIds- Returns:
- All the graphId(s) within scope of this FederatedStore and within visibility for the given user. These will be returned in random order.
-
getSchema
public Schema getSchema()
GetSchema
for this FederatedStore (without a context)This will return a merged schema of the optimised compact schemas of the stores inside this FederatedStore. It uses an empty/default
Context
, meaning it can only return results for graphs where this is valid, an empty Schema is otherwise returned. To supply aContext
, use thegetSchema()
method, or ideally use theGetSchema
operation instead.
-
getOriginalSchema
public Schema getOriginalSchema()
GetSchema
for this FederatedStore (without a context)This will return a merged schema of the original schemas of the stores inside this FederatedStore. This method uses an empty/default
Context
, meaning it can only return results for graphs where this is valid, an empty Schema is otherwise returned. To supply aContext
, use thegetSchema()
method, or ideally use theGetSchema
operation instead.- Overrides:
getOriginalSchema
in classStore
- Returns:
Schema
, empty if defaultContext
not valid
-
getSchema
public Schema getSchema(Context context, boolean getCompactSchema)
GetSchema
for this FederatedStore.This will return a merged schema of the original schemas or the optimised compact schemas of the stores inside this FederatedStore.
- Parameters:
context
- context with valid UsergetCompactSchema
- if true, gets the optimised compact schemas- Returns:
Schema
-
getGraphs
public List<GraphSerialisable> getGraphs(User user, List<String> graphIds, IFederationOperation operation)
Gets a collection of graph objects within FederatedStore scope from the given csv of graphIds, with visibility of the given user.
Graphs are returned once per operation, this does not allow an infinite loop of FederatedStores to occur.
if graphIdsCSV is null then all graph objects within FederatedStore scope are returned.
- Parameters:
user
- the users scope to get graphs for.graphIds
- the list of graphIds to get. null will return all graphs.operation
- the requesting operation, graphs are returned only once per operation.- Returns:
- the graph collection.
-
getAllGraphsAndAuths
public Map<String,Object> getAllGraphsAndAuths(User user, List<String> graphIds, boolean userRequestingAdminUsage)
-
isLimitedToLibraryProperties
public boolean isLimitedToLibraryProperties(User user)
The FederatedStore at time of initialisation, can set the auths required to allow users to use customStoreProperties
outside the scope of theGraphLibrary
.- Parameters:
user
- the user needing validation for custom property usage.- Returns:
- boolean permission
-
isLimitedToLibraryProperties
public boolean isLimitedToLibraryProperties(User user, boolean userRequestingAdminUsage)
-
changeGraphAccess
public boolean changeGraphAccess(User requestingUser, String graphId, FederatedAccess federatedAccess, boolean isAdmin) throws StorageException
- Throws:
StorageException
-
changeGraphId
public boolean changeGraphId(User requestingUser, String graphId, String newGraphId, boolean isAdmin) throws StorageException
- Throws:
StorageException
-
getStoreConfiguredMergeFunctions
public Map<String,BiFunction> getStoreConfiguredMergeFunctions()
-
-