Package sg.dex.starfish.util
Class ProvUtil
- java.lang.Object
-
- sg.dex.starfish.util.ProvUtil
-
public class ProvUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProvUtil.ActivityType
static class
ProvUtil.AgentIdType
-
Constructor Summary
Constructors Constructor Description ProvUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,Object>
associatedWith(String agentId, String activityId)
Returns a Map representing an associatedWith Relationship, which connects the agentID with the activityIdstatic Map<String,Object>
createActivities(Map<String,Object>... acts)
Returns a list of Activitiesstatic Map<String,Object>
createActivity(String actId, ProvUtil.ActivityType activityType)
Returns an Activity identified by activity id and typestatic Map<String,Object>
createActivity(String actId, ProvUtil.ActivityType activityType, Map<String,Object> actEntries)
Returns an Activity identified by activity id and typestatic Map<String,Object>
createAgent(String agentId, ProvUtil.AgentIdType agentType)
Returns a Map representing an entity, given the id and typestatic Map<String,Object>
createAgents(Map<String,Object>... age)
Returns a Map representing a list of agentsstatic Map<String,Object>
createAssetDependency(Asset ast)
Returns a Entity referring to asset in the argumentstatic Map<String,Object>
createDependencies(String params, String resultParamName)
Create dependencies.static Map<String,Object>
createInvokeProvenance(String actId, String agentId, Collection<Asset> assetDependencies, String params, String resultParamName)
Create default provenance metadata for publishing an asset created using invoke.static Map<String,Object>
createPublishProvenance(String agentId)
Create default provenance metadata for publishing an asset.static Map<String,Object>
createPublishProvenance(String actId, String agentId)
Create default provenance metadata for publishing an assetstatic Map<String,Object>
createThisInput()
Returns a Entity referring to "this", the asset being registeredstatic Map<String,Object>
defaultPrefix()
Create a default namespace which includes the prefix and path for Ocean protocol schemastatic Map<String,Object>
derivedFrom(Collection<Asset> entities)
Returns a Map representing an derived by Relationship, which connects the dependent entitiesstatic Map<String,Object>
generatedBy(String activityId)
Returns a Map representing an generatedBy Relationship, which connects the entityid with the activityId
-
-
-
Field Detail
-
OPF
public static String OPF
-
-
Method Detail
-
defaultPrefix
public static Map<String,Object> defaultPrefix()
Create a default namespace which includes the prefix and path for Ocean protocol schema- Returns:
- a Map with prefixes respective IRIs used in this document
-
createThisInput
public static Map<String,Object> createThisInput()
Returns a Entity referring to "this", the asset being registered- Returns:
- Map
-
createAssetDependency
public static Map<String,Object> createAssetDependency(Asset ast)
Returns a Entity referring to asset in the argument- Parameters:
ast
- dependent asset- Returns:
- Map
-
createAgent
public static Map<String,Object> createAgent(String agentId, ProvUtil.AgentIdType agentType)
Returns a Map representing an entity, given the id and type- Parameters:
agentId
- the agent IdagentType
- the type of account (e.g. ethereum account)- Returns:
- Map
-
createAgents
public static Map<String,Object> createAgents(Map<String,Object>... age)
Returns a Map representing a list of agents- Parameters:
age
- age- Returns:
- Map
-
associatedWith
public static Map<String,Object> associatedWith(String agentId, String activityId)
Returns a Map representing an associatedWith Relationship, which connects the agentID with the activityId- Parameters:
agentId
- the agent IdactivityId
- the activity Id- Returns:
- Map
-
generatedBy
public static Map<String,Object> generatedBy(String activityId)
Returns a Map representing an generatedBy Relationship, which connects the entityid with the activityId- Parameters:
activityId
- the activity Id- Returns:
- Map
-
derivedFrom
public static Map<String,Object> derivedFrom(Collection<Asset> entities)
Returns a Map representing an derived by Relationship, which connects the dependent entities- Parameters:
entities
- list of entities that the generated entity is derived from- Returns:
- Map
-
createActivity
public static Map<String,Object> createActivity(String actId, ProvUtil.ActivityType activityType)
Returns an Activity identified by activity id and type- Parameters:
actId
- the activity IdactivityType
- The type of activity (e.g. publish or operation)- Returns:
- Map
-
createActivity
public static Map<String,Object> createActivity(String actId, ProvUtil.ActivityType activityType, Map<String,Object> actEntries)
Returns an Activity identified by activity id and type- Parameters:
actId
- the activity IdactivityType
- The type of activity (e.g. publish or operation)actEntries
- an array of activities- Returns:
- Map
-
createActivities
public static Map<String,Object> createActivities(Map<String,Object>... acts)
Returns a list of Activities- Parameters:
acts
- array of activities- Returns:
- Map
-
createPublishProvenance
public static Map<String,Object> createPublishProvenance(String agentId)
Create default provenance metadata for publishing an asset. This create a random activity ID for tracking the provenance- Parameters:
agentId
- the agent identifier- Returns:
- Map
-
createPublishProvenance
public static Map<String,Object> createPublishProvenance(String actId, String agentId)
Create default provenance metadata for publishing an asset- Parameters:
actId
- the activity IdagentId
- the agent identifier- Returns:
- the prov metadata encoded in a Map
-
createDependencies
public static Map<String,Object> createDependencies(String params, String resultParamName)
Create dependencies. There are 2 sets of dependencies: one that are assets, and the second which is JSON payloads.- Parameters:
params
- the param string sent to the invoke rest APIresultParamName
- the param name of the generated asset- Returns:
- the input and output encoded as a Map
-
createInvokeProvenance
public static Map<String,Object> createInvokeProvenance(String actId, String agentId, Collection<Asset> assetDependencies, String params, String resultParamName)
Create default provenance metadata for publishing an asset created using invoke.- Parameters:
actId
- the activity IdagentId
- the agent identifierassetDependencies
- the list of assets that consumed by the operationparams
- the argument string passed to the operationresultParamName
- the name of the result argument for the generated asset- Returns:
- Map
-
-