Package org.cytoscape.jobs
Interface CyJobDataService
public interface CyJobDataService
The main interface for the marshalling and unmarshalling
of data to be exchanged with remote services. Implementations of
this interface will often be independent of the remote service (e.g. a JSON implementation of
CyJobDataService may be used for multiple backend services). Not all of the methods will be
provided by every implementation (see the default methods below).Cytoscape Backwards Compatibility (SPI Interface): We expect that this interface will be implemented. Therefore to maintain backwards compatibility this interface will only be modified for major version updates.
Module: jobs-api
To use this in your app, include the following dependency in your POM:
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>jobs-api</artifactId>
</dependency>-
Method Summary
Modifier and TypeMethodDescriptionAdd a single data item to aCyJobDataobject.Add generic key, value pairs to aCyJobDataitem.default CyJobDataaddData(CyJobData data, String key, CyNetwork network, List<? extends CyIdentifiable> nodesAndEdges, List<String> nodeColumns, List<String> edgeColumns) An optional method to add network data to aCyJobDataitem.default CyJobDataAn optional method to add table data to aCyJobDataitem.default CyJobDataaddData(CyJobData data, String key, CyNetworkView networkView, List<? extends CyIdentifiable> nodesAndEdges, List<VisualProperty<?>> properties) An optional method to add network view data to aCyJobDataitem.deserialize(InputStream inputStream) This method is used to create a newCyJobDataobject from a serialized data stream retrieved from a remote execution.deserialize(Reader reader) This method is used to create a newCyJobDataobject from a serialized data stream retrieved from a remote execution.deserialize(Object object) This method is used to create a newCyJobDataobject from a serialized data object retrieved from a remote execution.Extract data from aCyJobDataobject.Returns an empty instance ofCyJobDatathat may be used with this service.getMapData(CyJobData data, String key) Extract a map from aCyJobDataobject.default CyNetworkgetNetworkData(CyJobData data, String key) Optional method to extract network data from aCyJobDataobject.getSerializedData(CyJobData data) This method is used to extract the data from theCyJobDataobject in a form that is appropriate for use by the job execution service.The name of the service.default CyTablegetTableData(CyJobData data, String key) Optional method to extract table data (usually not model associated tables) from aCyJobDataobject.default CyNetworkViewgetViewData(CyJobData data, String key) Optional method to extract data for aCyNetworkViewfrom aCyJobDataobject.
-
Method Details
-
getServiceName
String getServiceName()The name of the service. This is usually the classname and is the name that should be registered with OSGi.- Returns:
- the service name
-
getDataInstance
CyJobData getDataInstance()Returns an empty instance ofCyJobDatathat may be used with this service. Note that implementations ofCyJobDataare not meant to be compatible even though they implement a small common subset of methods.- Returns:
- an empty
CyJobData
-
addData
Add generic key, value pairs to aCyJobDataitem. If the data argument is null, create a newCyJobDataobject initialized with mapData.- Parameters:
data- if not null, add mapData to this data object.key- a key string used to retrieve the datamapData- the data to add.- Returns:
- data if provided, else a new
CyJobDataobject
-
addData
Add a single data item to aCyJobDataobject. If the data argument is null, create a newCyJobDataobject initialized with mapData.- Parameters:
data- if not null, add item to this data object.key- a key string used to retrieve the dataitem- the data to add.- Returns:
- data if provided, else a new
CyJobDataobject
-
addData
default CyJobData addData(CyJobData data, String key, CyNetwork network, List<? extends CyIdentifiable> nodesAndEdges, List<String> nodeColumns, List<String> edgeColumns) An optional method to add network data to aCyJobDataitem. If the data argument is null, create a newCyJobDataobject initialized with the network data. If the list of nodes and edges (nodesAndEdges is provided, the network data will be restricted to this list. The list of nodeColumns and edgeColumns will restrict the attributes to those columns. For implementations that intent to use a column other than the SUID to map the data back, by convention the key column should be the first column in the list and the list should not be empty.
NOTE: it is important that implementations of this method deal with the mapping of network, node, and edge SUIDs, which will change across sessions. Typically, this will be done by adding a new column in the appropriate HIDDEN_ATTRS table with the name or id of the job. A utility classSUIDUtilis provided to support one possible mechanism to do this- Parameters:
data- if not null, add the model data to this data object.key- a key string used to retrieve the datanetwork- theCyNetworkto extract the data from.nodesAndEdges- the list oforg.cytoscape.modelCyNodes andorg.cytoscape.modelCyEdges to encode. If null or empty, the entire network will be addednodeColumns- the list of columns to include for node dataedgeColumns- the list of columns to include for edge data- Returns:
- data if provided, else a new
CyJobDataobject
-
addData
default CyJobData addData(CyJobData data, String key, CyTable table, List<CyRow> rows, List<String> columns) An optional method to add table data to aCyJobDataitem. If the data argument is null, create a newCyJobDataobject initialized with the table data. If the list ofCyRows (rows is is provided, the table data will be restricted to these rows. The list of columns will restrict the data to those columns. For implementations that intent to use a column other than the SUID to map the data back, by convention the key column should be the first column in the list and the list should not be empty.
NOTE: it is important that implementations of this method deal with the mapping of SUIDs, which will change across sessions. Typically, this will be done by adding a new column in the appropriate HIDDEN_ATTRS table with the name or id of the job. A utility classSUIDUtilis provided to support one possible mechanism to do this- Parameters:
data- if not null, add the model data to this data object.key- a key string used to retrieve the datatable- theCyTableto extract the data from.rows- the list ofCyRows to encode. If null or empty, the entire table will be addedcolumns- the list of columns to include from table- Returns:
- data if provided, else a new
CyJobDataobject
-
addData
default CyJobData addData(CyJobData data, String key, CyNetworkView networkView, List<? extends CyIdentifiable> nodesAndEdges, List<VisualProperty<?>> properties) An optional method to add network view data to aCyJobDataitem. If the data argument is null, create a newCyJobDataobject initialized with the network view data. If the list of nodes and edges (nodesAndEdges is provided, the view data will be restricted to this list. The list of properties will restrict theVisualPropertys to only those in the list. NOTE: it is important that implementations of this method deal with the mapping of network, node, and edge SUIDs, which will change across sessions. Typically, this will be done by adding a new column in the appropriate HIDDEN_ATTRS table with the name or id of the job. A utility classSUIDUtilis provided to support one possible mechanism to do this- Parameters:
data- if not null, add the model data to this data object.key- a key string used to retrieve the datanetworkView- theCyNetworkViewto extract the data from.nodesAndEdges- the list ofCyNodes andCyEdges to encode. If null or empty, the entire network view will be addedproperties- the list of visual properties to include- Returns:
- data if provided, else a new
CyJobDataobject
-
getData
Extract data from aCyJobDataobject.- Parameters:
data- theCyJobDataobject that has the datakey- the key that accesses the data- Returns:
- the untyped data, or null if the data doesn't exist. Note that it is up to the consumer to determine if this object is of the correct type.
-
getMapData
Extract a map from aCyJobDataobject.- Parameters:
data- theCyJobDataobject that has the mapkey- the key that accesses the map- Returns:
- the map itself, or null if the data doesn't exist.
-
getNetworkData
Optional method to extract network data from aCyJobDataobject. -
getTableData
Optional method to extract table data (usually not model associated tables) from aCyJobDataobject. -
getViewData
Optional method to extract data for aCyNetworkViewfrom aCyJobDataobject.- Parameters:
data- theCyJobDataobject that has theCyNetworkViewkey- the key that accesses the table- Returns:
- the returned view or null if it doesn't exist.
Note that this will only include view data for the nodes and edges
specified in the
CyJobDatastore. AllVisualPropertyvalues will be default unless explicitly included, in which case they will be overrides.
-
getSerializedData
This method is used to extract the data from theCyJobDataobject in a form that is appropriate for use by the job execution service. This method will be called byCyJobExecutionService.executeJob(CyJob, String, Map, CyJobData)method to serialize all of the data in theCyJobDataobject for submission to the remote service.- Parameters:
data- the input data- Returns:
- the serialized data
-
deserialize
This method is used to create a newCyJobDataobject from a serialized data object retrieved from a remote execution. This method will be called from theCyJobExecutionService.fetchResults(CyJob, CyJobData)to unmarshal the data sent by the finished job.- Parameters:
object- the serialized data object- Returns:
- a the
CyJobDataobject containing the unserialized data
-
deserialize
This method is used to create a newCyJobDataobject from a serialized data stream retrieved from a remote execution. This method will be called from theCyJobExecutionService.fetchResults(CyJob, CyJobData)to unmarshal the data sent by the finished job.- Parameters:
object- the serialized data stream- Returns:
- a the
CyJobDataobject containing the unserialized data
-
deserialize
This method is used to create a newCyJobDataobject from a serialized data stream retrieved from a remote execution. This method will be called from theCyJobExecutionService.fetchResults(CyJob, CyJobData)to unmarshal the data sent by the finished job.- Parameters:
object- the serialized data stream- Returns:
- a the
CyJobDataobject containing the unserialized data
-