Overview - Common API - Client API - Admin API - Runtime API
Factory
Use the Factory to create instances of Resource: transactions, participants and assets.
Applications should retrieve instances of the Factory from BusinessNetworkDefinition#getFactory
Details
- Module common
See also
Method Summary
Name | Returns | Description |
---|---|---|
newConcept | Resource |
Create a new Concept with a given namespace and type name |
newEvent | Resource |
Create a new event object |
newRelationship | Relationship |
Create a new Relationship with a given namespace, type and identifier |
newResource | Resource |
Create a new Resource with a given namespace, type name and id |
newTransaction | Resource |
Create a new transaction object |
Method Details
newResource
Resource newResource( String ns, String type, String id, [Object options] )
Create a new Resource with a given namespace, type name and id
Returns
Resource - the new instance
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
ns | String | Yes | the namespace of the Resource |
type | String | Yes | the type of the Resource |
id | String | Yes | the identifier |
options | Object | Yes | an optional set of options |
Sub-options
Name | Type | Mandatory | Description |
---|---|---|---|
options.disableValidation | boolean | Yes | pass true if you want the factory to return a Resource instead of a ValidatedResource. Defaults to false. |
options.generate | String | Yes | Pass one of:
|
options.includeOptionalFields | boolean | Yes | if options.generate is specified, whether optional fields should be generated. |
options.allowEmptyId | boolean | Yes | if options.allowEmptyId is specified as true, a zero length string for id is allowed (allows it to be filled in later). |
newConcept
Resource newConcept( String ns, String type, [Object options] )
Create a new Concept with a given namespace and type name
Returns
Resource - the new instance
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
ns | String | Yes | the namespace of the Concept |
type | String | Yes | the type of the Concept |
options | Object | Yes | an optional set of options |
Sub-options
Name | Type | Mandatory | Description |
---|---|---|---|
options.disableValidation | boolean | Yes | pass true if you want the factory to return a Concept instead of a ValidatedConcept. Defaults to false. |
options.generate | String | Yes | Pass one of:
|
options.includeOptionalFields | boolean | Yes | if options.generate is specified, whether optional fields should be generated. |
newRelationship
Relationship newRelationship( String ns, String type, String id )
Create a new Relationship with a given namespace, type and identifier. A relationship is a typed pointer to an instance. I.e the relationship with namespace = 'org.acme'
, type = 'Vehicle'
and id = 'ABC' creates
a pointer that points at an instance of org.acme.Vehicle with the id ABC.
Returns
Relationship - the new relationship instance
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
ns | String | Yes | the namespace of the Resource |
type | String | Yes | the type of the Resource |
id | String | Yes | the identifier |
newTransaction
Resource newTransaction( String ns, String type, [String id], [Object options] )
Create a new transaction object. The identifier of the transaction is set to a UUID.
Returns
Resource - A resource for the new transaction.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
ns | String | Yes | the namespace of the transaction. |
type | String | Yes | the type of the transaction. |
id | String | Yes | an optional identifier for the transaction; if you do not specify one then an identifier will be automatically generated. |
options | Object | Yes | an optional set of options |
Sub-options
Name | Type | Mandatory | Description |
---|---|---|---|
options.generate | String | Yes | Pass one of:
|
options.includeOptionalFields | boolean | Yes | if options.generate is specified, whether optional fields should be generated. |
options.allowEmptyId | boolean | Yes | if options.allowEmptyId is specified as true, a zero length string for id is allowed (allows it to be filled in later). |
newEvent
Resource newEvent( String ns, String type, [String id], [Object options] )
Create a new event object. The identifier of the event is set to a UUID.
Returns
Resource - A resource for the new event.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
ns | String | Yes | the namespace of the event. |
type | String | Yes | the type of the event. |
id | String | Yes | an optional identifier for the event; if you do not specify one then an identifier will be automatically generated. |
options | Object | Yes | an optional set of options |
Sub-options
Name | Type | Mandatory | Description |
---|---|---|---|
options.generate | String | Yes | Pass one of:
|
options.includeOptionalFields | boolean | Yes | if options.generate is specified, whether optional fields should be generated. |
options.allowEmptyId | boolean | Yes | if options.allowEmptyId is specified as true, a zero length string for id is allowed (allows it to be filled in later). |