Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For now the DSL is intentionally simple because it is focused on most common tasks/behavior (for more complex and less common tasks you can use the dispatcher/delegator). This section provides a summary of the main methods; for a full reference please refer to the source file: http://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy

  • calling services:

    Code Block
    Map runService(String serviceName, Map inputMap)
    Code Block
    Map run(Map args)
    Info

    The "run" method is implemented using named parameters and supports service calls with the following style:

    Code Block
    result = run service: 'createProduct', with: [productId: 'WG-1111']
  • retrieving data

    Code Block
    EntityQuery select(...)
    Code Block
    EntityQuery from(...)
    Info

    The "select" and "from" methods can be used in the following ways:

    Code Block
    record = select().from('Product').where(productId, 'WG-1111').queryOne() // selects all the columns of the record
    record = from('Product').where(productId, 'WG-1111').queryOne() // same as above
    record = select('internalName').from('Product').where(productId, 'WG-1111').queryOne() // selects one column of the record

    For more details refer to the Javadocs of EntityQuery.

  • modifying data:

    Code Block
    GenericValue makeValue(String entityName)

    and then call the methods on the GenericValue object (remove/store etc...)

  • logging (they all accept a GString i.e. $notation):

    Code Block
    logInfo(String message)
    Code Block
    logWarning(String message)
    Code Block
    logError(String message)
  • returning from the service or event (the methods simply return a Map for services or a string for events but you still have to use the "return" keyword to return the map back; when used by events the error method adds also the error message, if specified, to the request object):

    Code Block
    def success(String message)
    Code Block
    Map failure(String message)
    Code Block
    def error(String message)

...