Versions Compared

Key

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

...

Info

The new documentation is at Mini-language Reference page. There is still no documentation for Map processor though, the one below can be used

...

Table of Contents

...

Anchor
introduction
introduction
Introduction

...

The Mini-Language concept in Open For Business is similar to the Gang of Four Interpreter pattern, or the Mark Grand Little Language pattern. This is also the central theme of the Building Parsers with Java book by Steven John Metsker which the OFBiz Rule Engine is based on. The idea is to create simple languages that simplify complex or frequently performed tasks.

...

Anchor
smap
smap
The Simple Map Processor Mini-Language

...

Anchor
smapo
smapo
Simple Map Processor Overview

The Simple Map Processor Mini-Language performs two primary tasks: validation and conversion. It does this in a context of moving values from one Map to another. The input map will commonly contain Strings, but can contain other object types like Integer, Long, Float, Double, java.sql.Date, Time, and Timestamp.

Panel

(info) NOTE: The reference information for the simple-map-processor has been moved to annotations in the http://ofbiz.apache.org/dtds/simple-methods.xsd file. The idea is to now to use an XML completion tool in development. If you are interested by this issue take a look at https://issues.apache.org/jira/browse/OFBIZ-571

As static documentation you may find a simple-methods.html generated file in attachments. This file may be out of date but with the attached simple-methods.xsl file you are able to generate an updated file. In such case please feel free to put a comment below in order to let us know, thanks.

Anchor
smapex
smapex
Simple Map Processors Example

Note that fail-message is used here for the purpose of demonstration but in general it's better to use fail-property because fail-message is not localisable

Code Block
<simple-map-processors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
	<simple-map-processor name="update">
		<make-in-string field="estimatedStartDate">
			<in-field field="estimatedStartYear"><constant>-</constant>
			<in-field field="estimatedStartMonth"><constant>-</constant>
			<in-field field="estimatedStartDay"><constant>T</constant>
			<in-field field="estimatedStartHour"><constant>:</constant>
			<in-field field="estimatedStartMinute"><constant>:</constant>
			<in-field field="estimatedStartSecond">
		</make-in-string>
		<process field="workEffortId"><copy replace="false"/></process>
		<process field="scopeEnumId"><copy/></process>
		<process field="currentStatusId">
			<copy/>
			<not-empty>
                <!-- Note that fail-message is used here for the purpose of demonstration but in general it's better to use fail-property because fail-message is not localisable -->
				<fail-message message="Status is missing."/>
                                <!-- Note that fail-message is used here for the purpose of demonstration;
                                but in general it's better to use fail-property because fail-message is not localisable -->
			</not-empty>
		</process>
		<process field="priority">
			<convert type="Long">
				<fail-message message="Priority is not a valid whole number."/>
			</convert>
		</process>
		<process field="estimatedStartDate">
			<compare-field operator="less" field="estimatedCompletionDate" type="Timestamp" format="yyyy-MM-dd'T'HH:mm:ss">
				<fail-message message="Estimated Start date/time must be BEFORE End date/time."/>
			</compare-field>
			<convert type="Timestamp" format="yyyy-MM-dd'T'HH:mm:ss">
				<fail-message message="Estimated Start Date is not a valid Date-Time."/>
			</convert>
		</process>
		<process field="estimatedCompletionDate">
			<convert type="Timestamp">
				<fail-message message="Estimated Completion Date is not a valid Date-Time."/>
			</convert>
		</process>
		<process field="estimatedMilliSeconds">
			<convert type="Double">
				<fail-message message="Estimated Milli-seconds is not a valid number."/>
			</convert>
		</process>
	</simple-map-processor>
	<simple-map-processor name="delete">
		<process field="workEffortId">
			<copy/>
			<not-empty>
				<fail-message message="Work Effort ID is missing."/>
			</not-empty>
		</process>
	</simple-map-processor>
</simple-map-processors>

The Simple Method Mini-Language

  • Simple Method Overview
  • Special Context Access Syntax
  • Call Operations
  • Java Call Operations
  • Control and Error Handling Operations
  • Event Specific Operations
  • Service Specific Operations
  • Method Environment Operations
  • Entity Engine Misc. Operations
  • Entity Engine Find Operations
  • Entity Engine Value Operations
  • Entity Engine List Operations
  • Entity Engine Transaction Operations
  • Conditional (If) Operations
  • Other Operations
  • Simple Methods Example

...

Simple Method Overview
Anchor
simpmeth
simpmeth

The Simple Method Mini-Language is a simple way to implement an event that is invoked by the Control Servlet or a service that is invoked by the Service Engine. A Simple Method can be invoked through the static methods on the SimpleMethod class, or as an event through an entry in the controller configuration XML file like the following:

...

Panel

(info) NOTE: The reference information for simple-method has been moved to annotations in the http://ofbiz.apache.org/dtds/simple-methods.xsd file. The idea is to now to use an XML completion tool in development. If you are interested by this issue take a look at https://issues.apache.org/jira/browse/OFBIZ-571

As static documentation you may find a simple-methods.html generated file in attachments with reference information. This file may be out of date but with the also attached simple-methods.xsl file you are able to generate an updated file. In such case please feel free to put a comment below in order to let us know about that, thanks.

Special Context Access Syntax

In strings and field names a special syntax is supported to flexibly access Map member, List elements and to insert environment values into string constants.

...

Okay, enough of the general stuff, you may find in the XSD file descriptions of the available operations. Here is simply a categorized list of them.

...

Call Operations

call-map-processor
set-service-fields
call-service
call-service-asynch
script
call-bsh
call-simple-method

...

Java Call Operations

create-object
call-object-method
call-class-method

...

Control and Error Handling Operations

check-errors
add-error
return

...

Event Specific Operations

field-to-request
field-to-session
request-to-field
request-parameters-to-list
session-to-field
webapp-property-to-field

Service Specific Operations

field-to-result

...

Method Environment Operations

map-to-map
field-to-list
list-to-list
order-map-list
set
string-append
string-to-list
to-string
clear-field
first-from-list

All operations in red below have been be replaced by the set operation
field-to-field (deprecated, do not use anymore)
env-to-env (deprecated, do not use anymore)
env-to-field (deprecated, do not use anymore)
field-to-env (deprecated, do not use anymore)
string-to-field (deprecated, do not use anymore)

...

Control Operations

iterate
iterate-map
loop
first-from-list

...

Entity Engine Misc. Operations

now-timestamp
now-date-to-env
sequenced-id
make-next-seq-id
entity-data

Entity Engine Find Operations

find-by-primary-key
find-by-and
entity-one
entity-and
entity-condition
entity-count
get-related-one
get-related
order-value-list
filter-list-by-and
filter-list-by-date

Entity Engine Value Operations

make-value
clone-value
create-value
store-value
refresh-value
remove-value
remove-related
remove-by-and
clear-cache-line
clear-entity-caches
set-pk-fields
set-nonpk-fields

Entity Engine List Operations

store-list
remove-list

Entity Engine Transaction Operations

transaction-begin
transaction-commit
transaction-rollback

Conditional (If) Operations

if
if-validate-method
if-instance-of
if-compare
if-compare-field
if-regexp
if-empty
if-not-empty
if-has-permission
check-permission
check-id
assert
while

Other Operations

property-to-field
log
calculate
set-current-user-login
set-calendar

...

Code Block
<calculate field="a">
<calcop operator="get" field="b"/>
<calcop operator="divide">
<calcop operator="multiply">
<calcop operator="add" field="c">
<calcop operator="get" field="x"/>
<number value="2"/>
</calcop>
<calcop operator="negative" field="d"/>
</calcop>
<calcop operator="get" field="e"/>
</calcop>
</calculate>

...

Simple Methods Example

Note that fail-message is used here for the purpose of demonstration but in general it's better to use fail-property because fail-message is not localisable

...