Interface Operation
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Subinterfaces:
ExportTo<T>
,IFederatedOperation
,IFederationOperation
,Input<I>
,InputOutput<I,O>
,MultiElementIdInput
,MultiEntityIdInput
,MultiInput<I_ITEM>
,Output<O>
- All Known Implementing Classes:
AddElements
,AddElementsFromFile
,AddElementsFromHdfs
,AddElementsFromKafka
,AddElementsFromSocket
,AddGraph
,AddGraph
,AddGraphWithHooks
,AddNamedOperation
,AddNamedView
,AddSchemaToLibrary
,AddStorePropertiesToLibrary
,Aggregate
,CancelScheduledJob
,ChangeGraphAccess
,ChangeGraphId
,ChangeGraphId
,Count
,CountAllElementsDefaultView
,CountGroups
,DeleteAllData
,DeleteElements
,DeleteNamedOperation
,DeleteNamedView
,DiscardOutput
,ExportToGafferResultCache
,ExportToLocalFile
,ExportToOtherAuthorisedGraph
,ExportToOtherGraph
,ExportToSet
,FederatedOperation
,Filter
,ForEach
,GenerateElements
,GenerateObjects
,GenerateSplitPointsFromSample
,GenericInput
,GetAdjacentIds
,GetAllElements
,GetAllGraphIds
,GetAllGraphIds
,GetAllGraphInfo
,GetAllGraphInfo
,GetAllJobDetails
,GetAllNamedOperations
,GetAllNamedViews
,GetDataFrameOfElements
,GetElements
,GetElementsBetweenSets
,GetElementsBetweenSetsPairs
,GetElementsInRanges
,GetElementsWithinSet
,GetExports
,GetFromEndpoint
,GetGafferResultCacheExport
,GetGraphCreatedTime
,GetGraphFrameOfElements
,GetJavaRDDOfAllElements
,GetJavaRDDOfElements
,GetJavaRDDOfElementsInRanges
,GetJobDetails
,GetJobResults
,GetProxyProperties
,GetProxyUrl
,GetRDDOfAllElements
,GetRDDOfElements
,GetRDDOfElementsInRanges
,GetSchema
,GetSetExport
,GetTraits
,GetVariable
,GetVariables
,GetWalks
,HasTrait
,If
,ImportAccumuloKeyValueFiles
,ImportFromLocalFile
,ImportJavaRDDOfElements
,ImportKeyValueJavaPairRDDToAccumulo
,ImportKeyValuePairRDDToAccumulo
,ImportRDDOfElements
,Join
,Limit
,Map
,Max
,Min
,NamedOperation
,OperationChain
,OperationChainDAO
,Reduce
,RemoveGraph
,RemoveGraph
,RemoveGraphAndDeleteAllData
,SampleDataForSplitPoints
,SampleElementsForSplitPoints
,ScoreOperationChain
,SetVariable
,Sort
,SplitStoreFromFile
,SplitStoreFromIterable
,SplitStoreFromJavaRDDOfElements
,SplitStoreFromRDDOfElements
,SummariseGroupOverRanges
,ToArray
,ToCsv
,ToEntitySeeds
,ToList
,ToMap
,ToSet
,ToSingletonList
,ToStream
,ToVertices
,Transform
,Validate
,ValidateOperationChain
,While
public interface Operation extends Closeable
AnOperation
defines an operation to be processed on a graph. All operations must to implement this interface. Operations should be written to be as generic as possible to allow them to be applied to different graph/stores. NOTE - operations should not contain the operation logic. The logic should be separated out into a operation handler. This will allow you to execute the same operation on different stores with different handlers.Operations must be JSON serialisable in order to make REST API calls.
Any fields that are required should be annotated with the
Required
annotation.Operation implementations need to implement this Operation interface and any of the following interfaces they wish to make use of:
Input
Output
InputOutput
(Use this instead of Input and Output if your operation takes both input and output.)MultiInput
(Use this in addition if you operation takes multiple inputs. This will help with json serialisation)Validatable
OperationView
GraphFilters
SeededGraphFilters
Each Operation implementation should have a corresponding unit test class that extends the OperationTest class.
Implementations should override the close method and ensure all closeable fields are closed.
All implementations should also have a static inner Builder class that implements the required builders. For example:
public static class Builder extends Operation.BaseBuilder<GetElements, Builder> implements InputOutput.Builder<GetElements, Iterable<? extends ElementId>, Iterable<? extends Element>, Builder>, MultiInput.Builder<GetElements, ElementId, Builder>, SeededGraphFilters.Builder<GetElements, Builder> { public Builder() { super(new GetElements()); } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Operation.BaseBuilder<OP extends Operation,B extends Operation.BaseBuilder<OP,?>>
static interface
Operation.Builder<OP,B extends Operation.Builder<OP,?>>
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Map<String,String>
_getNullOrOptions()
default void
addOption(String name, String value)
Adds an operation option.default void
close()
Operation implementations should ensure that all closeable fields are closed in this method.default boolean
containsOption(String name)
Gets if an operation contains an option of the given name.default String
getOption(String name)
Gets an operation option by its given name.default String
getOption(String name, String defaultValue)
Gets an operation option by its given name.Map<String,String>
getOptions()
void
setOptions(Map<String,String> options)
Operation
shallowClone()
Operation implementations should ensure a ShallowClone method is implemented.default uk.gov.gchq.koryphe.ValidationResult
validate()
Validates an operation.default void
validateRequiredFieldPresent(uk.gov.gchq.koryphe.ValidationResult result, Field field)
-
-
-
Method Detail
-
shallowClone
Operation shallowClone() throws org.apache.commons.lang3.exception.CloneFailedException
Operation implementations should ensure a ShallowClone method is implemented. Performs a shallow clone. Creates a new instance and copies the fields across. It does not clone the fields. If the operation contains nested operations, these must also be cloned.- Returns:
- shallow clone
- Throws:
org.apache.commons.lang3.exception.CloneFailedException
- if a Clone error occurs
-
getOptions
Map<String,String> getOptions()
- Returns:
- the operation options. This may contain store specific options such as authorisation strings or and other properties required for the operation to be executed. Note these options will probably not be interpreted in the same way by every store implementation.
-
setOptions
void setOptions(Map<String,String> options)
- Parameters:
options
- the operation options. This may contain store specific options such as authorisation strings or and other properties required for the operation to be executed. Note these options will probably not be interpreted in the same way by every store implementation.
-
addOption
default void addOption(String name, String value)
Adds an operation option. This may contain store specific options such as authorisation strings or and other properties required for the operation to be executed. Note these options will probably not be interpreted in the same way by every store implementation.- Parameters:
name
- the name of the optionvalue
- the value of the option
-
getOption
default String getOption(String name)
Gets an operation option by its given name.- Parameters:
name
- the name of the option- Returns:
- the value of the option
-
getOption
default String getOption(String name, String defaultValue)
Gets an operation option by its given name.- Parameters:
name
- the name of the optiondefaultValue
- the default value to return if value is null.- Returns:
- the value of the option
-
containsOption
default boolean containsOption(String name)
Gets if an operation contains an option of the given name.- Parameters:
name
- the name of the option- Returns:
- if the operation contains the option
-
close
default void close() throws IOException
Operation implementations should ensure that all closeable fields are closed in this method.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs
-
validate
default uk.gov.gchq.koryphe.ValidationResult validate()
Validates an operation. This should be used to validate that fields have been be configured correctly. By default no validation is applied. Override this method to implement validation.- Returns:
- validation result.
-
validateRequiredFieldPresent
default void validateRequiredFieldPresent(uk.gov.gchq.koryphe.ValidationResult result, Field field)
-
-