Transaction
Purpose¶
XML transaction manipulation and processing.
Note
TI stands for TransactionInfo and is the most commonly used business transaction manipulated by Platform 6. For backward compatibility a TransactionInfo transaction has a dataPartition (TRANSACTION) and a dataType (TransactionInfo).
Methods¶
Binding name: p6.transaction
Method: TransactionPK buildPK(String dataType, String... itemIds)
Build a transaction item primary key (TransactionPK
) from it’s constituent parts.
The dataType is a free text string without constraint. If you create a transaction from a bundled script,
it is important to use as a prefix the application key (ie. myApp.TransactionInfo
).
This way you will be able to use specific filters inside views and also for the transaction tag mechanism.
Method: TransactionPK buildTIPK(String... itemIds)
Build a transaction item primary key (TransactionPK
) for a TransactionInfo using supplied itemIds
.
Method: String getUsingPipelineRequest()
Get the XML transaction as a String using the primary key values in the current pipeline.
Pipeline keys used are:
- platform6.request.dataType
- platform6.request.ids
Method: TransactionPK getPKUsingPipelineRequest()
Get the primary key of the transaction using the primary key values in the current pipeline.
Method: String get(TransactionPK pk)
Get the XML transaction as a String using the supplied item primary key.
Method: List<ItemLink> getItemLinks(TransactionPK pk, String viewId)
Get the itemLinks of a transaction.
The ItemLink contains the following fields:
- ids: array of ids
- view: the view id
- type
Method: String exists(TransactionPK pk)
Return the XML transaction as a String using the supplied item primary key or null if not found.
Method: String remove(TransactionPK pk)
Remove the XML transaction and return it’s content as a String using the supplied item primary key or null if not found.
Method: TransactionPK put(String xml, TransactionPK pk)
Stores the supplied XML transaction using the supplied item primary key.
Method: TransactionPK putTI(String xml, String... itemIds)
Stores the supplied XML as a TransactionInfo using supplied itemIds
.
Method: TransactionPK saveTI(String xml, String... itemIds)
Projects the supplied XML (validates against a data model and stores) as a TransactionInfo using supplied itemIds
.
Method: TransactionPK save(String xml, String dataModelName, TransactionPK pk)
Projects the supplied XML (using the supplied data model for content validation) using the supplied item primary key.
Method: TransactionPK saveAndRouteTI(String xml, String endpointUrl, String... itemIds)
Projects the supplied XML as a TransactionInfo using supplied itemIds
and sends as a camel Exchange to the given Platform 6 routing endpoint.
Method: TransactionPK saveAndRoute(String xml, String dataModelName, TransactionPK pk, String endpointUrl)
Projects the supplied XML (using the supplied data model for content validation) using the supplied item primary key and sends as a camel Exchange to the given Platform 6 routing endpoint.
Method: TransactionPK route(TransactionPK pk, String endpointUrl)
Sends the supplied item primary key as a camel Exchange to the given Platform 6 routing endpoint.
Method: boolean validate(String xml, String schemaUri)
Validate the supplied XML against the schema found at the supplied URI.
Any errors are added to the pipeline as entry errors
encoded as a String.
Method: updateFlags(TransactionPK pk, String viewId, Map<String, Boolean> flags)
Update the flags inside a transaction. Set a flag to true to add the flag and false to remove the flag. The transaction’s flags are returned by the method.
Method: GPathResult getAsXML(TransactionPK pk)
Returns the parsed XML of the transaction.
Method: GPathResult getTIAsXML(String... itemsIds)
Returns the parsed XML of the TransactionInfo
transaction based on the itemIds.
Examples¶
def pk = p6.transaction.buildPK("TransactionInfo", "123", "456")
println pk
pk = p6.transaction.buildTIPK("Invoice_FTP-000464_9777cdd0-70d6-46d5-a130-1498222529210")
println pk
def serialBean = p6.transaction.getSerialForm( pk )
println serialBean
def miXml = p6.transaction.get(pk)
println miXml
def xml = p6.transaction.exists(pk)
println xml
# Retrieve the parsed XML of the transaction
xml = p6.transaction.getAsXML(pk)
println xml
xml = p6.transaction.getTIAsXML("id1", "id2")
println xml
pk = p6.transaction.buildTIPK("Invoice_FTP-000464_9777cdd0-70d6-46d5-a130-1498222529210-copy")
xml = p6.transaction.exists(pk)
println xml
pk = p6.transaction.put("<xml></xml>", pk)
println pk
pk = p6.transaction.remove(pk)
println pk
pk = p6.transaction.putTI("<xml></xml>", "Invoice_FTP-000464_9777cdd0-70d6-46d5-a130-1498222529210-copy")
println pk
pk = p6.transaction.saveTI(miXml, "Invoice_FTP-000464_9777cdd0-70d6-46d5-a130-1498222529210-copy")
println pk
pk = p6.transaction.save(miXml, "TransactionInfo", pk)
println pk
pk = p6.transaction.saveAndRoute(miXml, "TransactionInfo", pk, "direct:p6router.1")
println pk
def valid = p6.transaction.validate(miXml, "file://${P6_DATA}/resources/schemas/pidx_v1_0/PIDX-Invoice-2002-02-14-V1-0.xsd")
println valid
# Unmark as unread
p6.transaction.updateFlags(pk, "p6_demo.Transactions", ["eunread": false])
# Mark as visible and unread
p6.transaction.updateFlags(pk, "p6_demo.Transactions", ["eunread": true, "aavisible": true])