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 aCyJobData
object.Add generic key, value pairs to aCyJobData
item.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 aCyJobData
item.default CyJobData
An optional method to add table data to aCyJobData
item.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 aCyJobData
item.deserialize(InputStream inputStream)
This method is used to create a newCyJobData
object from a serialized data stream retrieved from a remote execution.deserialize(Reader reader)
This method is used to create a newCyJobData
object from a serialized data stream retrieved from a remote execution.deserialize(Object object)
This method is used to create a newCyJobData
object from a serialized data object retrieved from a remote execution.Extract data from aCyJobData
object.Returns an empty instance ofCyJobData
that may be used with this service.getMapData(CyJobData data, String key)
Extract a map from aCyJobData
object.default CyNetwork
getNetworkData(CyJobData data, String key)
Optional method to extract network data from aCyJobData
object.getSerializedData(CyJobData data)
This method is used to extract the data from theCyJobData
object in a form that is appropriate for use by the job execution service.The name of the service.default CyTable
getTableData(CyJobData data, String key)
Optional method to extract table data (usually not model associated tables) from aCyJobData
object.default CyNetworkView
getViewData(CyJobData data, String key)
Optional method to extract data for aCyNetworkView
from aCyJobData
object.
-
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 ofCyJobData
that may be used with this service. Note that implementations ofCyJobData
are 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 aCyJobData
item. If the data argument is null, create a newCyJobData
object 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
CyJobData
object
-
addData
Add a single data item to aCyJobData
object. If the data argument is null, create a newCyJobData
object 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
CyJobData
object
-
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 aCyJobData
item. If the data argument is null, create a newCyJobData
object 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 classSUIDUtil
is 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
- theCyNetwork
to extract the data from.nodesAndEdges
- the list oforg.cytoscape.modelCyNode
s andorg.cytoscape.modelCyEdge
s 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
CyJobData
object
-
addData
default CyJobData addData(CyJobData data, String key, CyTable table, List<CyRow> rows, List<String> columns)An optional method to add table data to aCyJobData
item. If the data argument is null, create a newCyJobData
object initialized with the table data. If the list ofCyRow
s (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 classSUIDUtil
is 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
- theCyTable
to extract the data from.rows
- the list ofCyRow
s 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
CyJobData
object
-
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 aCyJobData
item. If the data argument is null, create a newCyJobData
object 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 theVisualProperty
s 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 classSUIDUtil
is 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
- theCyNetworkView
to extract the data from.nodesAndEdges
- the list ofCyNode
s andCyEdge
s 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
CyJobData
object
-
getData
Extract data from aCyJobData
object.- Parameters:
data
- theCyJobData
object 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 aCyJobData
object.- Parameters:
data
- theCyJobData
object 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 aCyJobData
object. -
getTableData
Optional method to extract table data (usually not model associated tables) from aCyJobData
object. -
getViewData
Optional method to extract data for aCyNetworkView
from aCyJobData
object.- Parameters:
data
- theCyJobData
object that has theCyNetworkView
key
- 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
CyJobData
store. AllVisualProperty
values will be default unless explicitly included, in which case they will be overrides.
-
getSerializedData
This method is used to extract the data from theCyJobData
object 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 theCyJobData
object for submission to the remote service.- Parameters:
data
- the input data- Returns:
- the serialized data
-
deserialize
This method is used to create a newCyJobData
object 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
CyJobData
object containing the unserialized data
-
deserialize
This method is used to create a newCyJobData
object 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
CyJobData
object containing the unserialized data
-
deserialize
This method is used to create a newCyJobData
object 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
CyJobData
object containing the unserialized data
-