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:

Annotation

java
@Seca(
    service = "myService",
    event = "return",
    condition = "myField == 'TEST'",
    actions = {
        @SecaAction(service = "testService", mode = "sync", runAsUser = "system")
    }
)
public interface MyServiceReturnSeca {}

XML

text
<?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#

TagAttributeDescription
ecaserviceService name
eventTime of event.

Available options:

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

Available Options:

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

Available Options:

  • true
  • false
conditionfield-nameField to be validated
map-nameValidate an input map as an alternative to the field-name
operatorAvailable options:
  • less
  • greater
  • less-equals
  • greater-equals
  • equals
  • not-equals
  • is-empty
  • is-not-empty
  • contains
valueField value
typeObject type (default:String)
Available Options:
  • PlainString
  • String
  • BigDecimal
  • Double
  • Float
  • Long
  • Integer
  • Date
  • Time
  • Timestamp
  • Boolean
  • Object
formatFormat 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-serviceservice-nameService to be validated

This is rarely used. We recommend to rely on conditions instead.

condition-fieldfield-nameAttribute name in context
formatFormat 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-nameValidate an input map as an alternative to the field-name
to-field-namestore result as a field
to-map-namestore result as a map
typeObject type (default:String)
Available Options:
  • PlainString
  • String
  • BigDecimal
  • Double
  • Float
  • Long
  • Integer
  • Date
  • Time
  • Timestamp
  • Boolean
  • Object
setfield-nameTable field name
env-nameDefine variable name for this operation
formatFormat 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
valuevariable value
actionserviceRun service of name
modeDefinition of when to call the service – synchronous or asynchronous

Available options:

  • sync
  • async
ignore-errorignore errors thrown within the transaction
ignore-failureignore if transaction context is in a failed state
new-transactionRun service in a new transaction
result-map-namestore result as a map
result-to-contextStore result in context

Available options:

  • true
  • false
persistRestart action if attempt failed on first try.

Available options:

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


Available options:

  • true
  • false
run-as-userUser used to perform the operation
result-to-valueReturn operation result as value

Literature#

Ask the people who wrote it.

Support, development and training from the team that builds Scipio ERP.