SECAs

Just like entity event condition actions, services can be interlinked by the event condition action model. On the service level these are referred to as Service Event Condition Actions (SECAs).  SECAs are defined inside service-eca definition files:

 

<?xml version="1.0" encoding="UTF-8"?>
<service-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/service-eca.xsd">
 
<!-- Sample SECA-->
 <eca service="myService" event="return">
    <condition field-name="myField" operator="equals" value="TEST"/>
    <action service="testService" mode="sync" run-as-user="system"/>
 </eca>

</service-eca>

 

SECA Options

Tag Attribute Description
eca service Service name
 event  Time of event.

Available options:

  • global-commit
  • global-commit-post-run
  • global-rollback
  • auth
  • in-validate
  • out-validate
  • invoke
  • commit
  • return
 run-on-error Continue with event, even if the operation that is triggering the event results in error.

Available Options:

  • true
  • false
 run-on-failure Continue with event, even if the operation that is triggering the event results in a failed state.

Available Options:

  • true
  • false
condition field-name Field to be validated
map-name Validate an input map as an alternative to the field-name
operator  Available options:

  • less
  • greater
  • less-equals
  • greater-equals
  • equals
  • not-equals
  • is-empty
  • is-not-empty
  • contains
value  Field value
type  Object type (default:String)
Available Options:

  • PlainString
  • String
  • BigDecimal
  • Double
  • Float
  • Long
  • Integer
  • Date
  • Time
  • Timestamp
  • Boolean
  • Object
format Format value before validation.

Available options:

  • append
  • to-upper
  • to-lower
  • hash-code
  • long
  • double
  • upper-first-char
  • lower-first-char
  • db-to-java
  • java-to-db
condition-service service-name Service to be validated

This is rarely used. We recommend to rely on conditions instead.
 condition-field field-name Attribute name in context
 format Format value before validation.

Available options:

  • append
  • to-upper
  • to-lower
  • hash-code
  • long
  • double
  • upper-first-char
  • lower-first-char
  • db-to-java
  • java-to-db
map-name Validate an input map as an alternative to the field-name
to-field-name store result as a field
to-map-name store result as a map
type  Object type (default:String)
Available Options:

  • PlainString
  • String
  • BigDecimal
  • Double
  • Float
  • Long
  • Integer
  • Date
  • Time
  • Timestamp
  • Boolean
  • Object
 set field-name  Table field name
env-name Define variable name for this operation
format Format value before storing as part of the variable.Available options:

  • append
  • to-upper
  • to-lower
  • hash-code
  • long
  • double
  • upper-first-char
  • lower-first-char
  • db-to-java
  • java-to-db
 value variable value
 action service Run service of name
mode Definition of when to call the service – synchronous or asynchronous

Available options:

  • sync
  • async
ignore-error ignore errors thrown within the transaction
ignore-failure ignore if transaction context is in a failed state
new-transaction Run service in a new transaction
result-map-name store result as a map
result-to-context Store result in context

Available options:

  • true
  • false
persist Restart action if attempt failed on first try.

Available options:

  • true
  • false
result-to-result If true, copies the action’s result Map into the service’s result Map.


Available options:

  • true
  • false
run-as-user User used to perform the operation
result-to-value Return operation result as value

 

Literature