The Simple Methods user guide specifies some of the most commonly used elements and attributes. Although more are available to use, they have been omitted from this guide as they are either deprecated, or simply not used. The complete XML schema from which this guide has been derived can be found at ${ofbizInstallFolder} /framework/minilang/dtd/simple-methods.xsd
.
This is the opening tag for the Simple Method. The Simple Method can be called in either an event context from the Control Servlet (or another event), a service context through the Service Engine, or through any other component that has access to a service dispatcher.
|
Required |
The name as preferably a legal Java method name for this method. This name must be unique for the XML file it is in, as it will be used to reference this method externally. | |
|
Required |
A short description briefly describing the function of the method. | |
|
(Optional—Defaults to |
Checks if a user (UserLogin object, or | |
|
(Optional—Defaults to |
Determines whether the framework should create a transaction if none exists for the thread. |
We are able to call and process the results of static Java methods, BeanShell script and even invoke other services from our Simple Methods. These operations are available when the static method is called as an event or a service.
The <call-map-processor>
tag invokes a simple map processor from an existing Map
, creating a new Map
or adding to an existing one if the name out-Map
already exists. Resulting messages are added to the name List
, and a new List
is created if a List
with the given name does not yet exist. Note that all Lists
and Maps
exist in the same context and must have unique names. An inline simple-map-processor
can be used by putting a simple-map-processor
tag under the call-map-processor
tag. If both, an external and an inline map-processor
are specified, the external one will be called first, allowing the inline one to override its behavior.
|
Required only if external map processor is desired |
The full path and filename on the classpath of the XML file which contains an external map processor to execute. | |
|
Required only if external map processor is desired |
The name of the external map processor to execute in the specified xml-resource. | |
|
Required |
The name of a map in the method environment to use as the input map. | |
|
Required |
The name of a map in the method environment to use as the output map. Will be created if it does not exist already. If it already exists, it will be added to in place. |
The <call-service>
tag invokes a service through the Service Engine. If the specified error code is returned from the service, the event is aborted and the transaction in the current thread is rolled back. Otherwise, the remaining operations are invoked.
The <result-to-request>
and <result-to-session>
elements will be ignored when called in a service context. So, they are only used when called in an event context.
The <call-service-asynch>
tag calls a service asynchronously and ignores the result, so no return messages are used. This doesn't mean no errors will result, but they would just be system errors like database failures, and so on, which all have system error messages.
|
Required |
Name of the service to call. | |
|
Required |
Optional name of a map in the method environment to use as the input map. If you're not going to pass any parameters to the service then you can just leave off the | |
|
Optional—defaults to |
by default, will include the user login so if there is a user login for the current simple-method it will pass that in to the service. If you don't want it to pass that in, you can just set this to | |
|
Optional—defaults to true. |
If there's an error in the service, by default it will stop the current simple-method and return an error message that came from the service it called. If you don't want it to when there's an error, it can just be set to |
Looks at all of the incoming service attributes as specified in the service definition, looks for fields with the same name in the incoming map and copies those onto the outgoing map.
|
Required |
Name of the service from which to take all incoming attributes. | |
|
Required |
Incoming map to copy fields from. | |
|
Required |
Map to copy fields to. |
The following operations are designed to handle the results, or OUT
parameters from a synchronously called service.
The <results-to-map>
tag takes all of the results of the service, the outgoing maps from the service and puts them in a map of the given map-name.
Specify the name of the field in the result and then the name of the field in the context you want to put it in, and optionally the name in the map. If no field-name is specified then the result-name will be used for the field-name, that's the name of the variable that will be created in the current context for the value of that result.
|
Required |
Name of the result. May be used for the field-name. If you don't specify a field-name, this is the name of the variable that will be created in the current context for the value of that result. | |
|
Optional |
Optional field name. | |
|
Optional |
Optional map name. |
The <result-to-request>
tag is event specific. It takes the result with the given name and puts it in a request attribute with the given name here. The request-name
is optional. If this is left it off then it will put it in an attribute with the name of the result-name
.
|
Required |
Name of the result. May be used for the request attribute name. If you don't specify a | |
|
Optional |
Optional request name. |
Service specific (when the Simple Method is being called as a service). It will take the result of the service you're calling with the call-service
operation and it will put it in with the result of the current service. So result-name
is the name of the result in the service that was called using the <call-service>
tag.
These attributes are somewhat confusing: result-name
is the name of the field in the result of this service call that the value comes from; service-result-name
is the name of the field in the result of this simple-method
called as a service where the value goes to; in other words from
result-name
and to
|
Required |
Name of the field in the result of this service call that the value comes from. | |
|
Optional |
Name of the field in the result of this simple-method called as a service where the value goes to. |
<call-service service-name="createPhysicalInventory" in-map-name="createPhysicalInventoryMap"> <result-to-field result-name="physicalInventoryId" field-name="physicalInventoryId" map-name="parameters"/> <result-to-result result-name="physicalInventoryId" service-result-name="physicalInventoryId"/> </call-service>
Runs an external bsh script from the classpath if the resource is specified and then runs the inlined bsh script if any is specified. The bsh context is the current simple-method environment including maps, lists and special objects whose names are defined in the simple-method attributes.
The current env
cannot be modified, but if a Map
is returned by the bsh block the entries in the map will be put into the current env
.
Error messages go on the error list and are handled with the <check-errors>
tag.
|
Optional |
Name of a properties file on the classpath. | |
|
Optional—defaults to |
The name of the list in the method environment to check for error messages. |
<call-bsh><! [CDATA[ String password = (String) userLoginContext.get("currentPassword"); String confirmPassword = (String) userLoginContext.get("currentPasswordVerify"); String passwordHint = (String) userLoginContext.get("passwordHint"); org.ofbiz.common.login.LoginServices.checkNewPassword(newUserLogin, null, password, confirmPassword, passwordHint, error_list, true, locale); ]]></call-bsh>
The <call-simple-method>
tag calls another simple-method in the same context as the current one. In other words the called simple-method will have the same environment as the calling simple-method, including all environment fields, and either the event or service objects that the calling simple-method was called with.
|
Optional |
The full path and filename on the classpath of the XML file which contains an external simple-method to execute. This is only required if a simple-method in a different file is desired. | |
|
Required |
The name of the simple-method to execute in the specified xml-resource, or in the current XML file if no xml-resource is specified. |
Calls a method on an existing object that exists in a field in the environment or in a map in the environment. The string and field sub-elements are passed to the method as arguments in the order they are specified. If the sub-elements do not match the method arguments, an error will be returned. The return value will be put in the named field if a value is returned and if a field and (optionally) Map
name are specified.
|
Required |
The name of the field the object is in that has the method to be called. | |
|
Required |
The nameof the map the field of the object is in, that has the method to be called. If this is not specified, the field will be taken from the environment. | |
|
Required |
The name of the method to call on the given object. | |
|
Optional |
The name of the field to put the result in. If not specified, any return value will be ignored. | |
|
Optional |
The name of the map the field of the return value is in. If not specified, but the field name is, then the environment will be used to find the field in. |
Calls a static method on a class. The string and field sub-elements are passed to the method as arguments in the order they are specified. If the sub-elements do not match the method arguments, an error will be returned. The return value will be put in the named field if a value is returned and if a field and optionally a Map
name are specified.
|
Required |
The name of the class to call the static method on. | |
|
Required |
The name of the static method to call on the given class. | |
|
Optional |
The name of the field to put the result in. If not specified, any return value will be ignored. | |
|
Optional |
The name of the map the field of the returned value is in. If not specified, but the field name is, then the environment will be used to find the field in. |
The following operations are service specific, that is, they are only applicable when the Simple Method is called as a service.
The <field-to-result>
tag copies a field from a Map
to the specified service result field.
The tag is only used when the simple-method is called as a service, it is ignored otherwise.
|
Required |
The name (key) of the map field to use. | |
|
Optional |
The name of the map in the method environment. If not specified the field-name will be used to get the field from the method environment. | |
|
Optional |
The name of the request attribute to use. Defaults to the |
The following operations are event specific, that is, they are only applicable when the Simple Method is called as an event.
The following environment operations deal with moving values from one field to another.
Moves a value from one field to another field. We can also take a value, just a string constant or a string that is made up of a mixture of constant and flexible string expansion variables using the ${}
syntax, that will be put in the field. We can also specify a default value in the case that the value evaluates to an empty string, or the from field is null or empty. Then the default-value will be used. Again we can use the flexible string expander here, the ${}
syntax and such. It can also do a type conversion. So going from whatever type the source data is in, which would be a string value or whatever the variable type is for a from field, it can convert that to any of these types before setting it in the target field.
|
Required |
Name of the field to copy value to. | |
|
Optional |
Name of the field to copy value from. | |
|
Optional |
Simple value to copy in field. | |
|
Optional |
Default value to copy in field, if the value evaluates to an empty string or the from field is null or empty. | |
|
Optional |
Type to convert to, can be: PlainString, String, BigDecimal, Double, Float, List, Long, Integer, Date, Time, Timestamp, Boolean, Object. | |
|
Optional—defaults to |
Specifies whether or not to set fields that are null or empty. | |
|
Optional—defaults to |
If the source value, either from a value or from a field is empty, an empty-string, an empty list or a null value. In this case it's set to true. If you don't want to set it, if you want it to leave the target field alone when the source is empty, then you need to set this to false. |
The <clear-field>
tag clears/removes the specified field.
|
Optional |
The name of the map in the method environment. If not specified the field-name will be used to get the field from the method environment. | |
|
Required |
The name (key) of the map field to use. |
The <first-from-list>
tag will get the first entry from the given list and put it in the environment field with the given entry-name.
|
Required |
The name of the method environment field that will contain the first entry in the list. | |
|
Required |
The name of the method environment field that contains the list to get the first entry from. |
The following miscellaneous operations deal with obtaining primary or sequenced keys.
The <sequenced-id-to-env>
tag gets a sequenced ID from the Entity Engine (through the delegator) and puts it in the specified method environment field. The object will be a java.lang.Long
, but can of course be converted to a String
.
|
Required |
The name of the sequence to pass to the delegator. The same name must always be used for sequenced IDs that will be used for a certain entity field otherwise non-unique keys may result. | |
|
Required |
The name of the method environment field the sequenced ID will be put in. | |
|
Optional |
By default this is one. But if you want to have sequenced IDs that are staggered, instead of consecutive, then you can set this to something like twenty. And then it will do a random staggering for each sequenced id. Instead of picking the next value all the time it will pick something between the next value and twenty away from the next value, if stagger-max is set to twenty. So that can be used to make the sequenced Ids more difficult to guess. |
Whereas <sequenced-id-to-env>
is the primary key sequencer, <make-next-seq-id>
is the secondary key sequencer. So this would be something like an orderId
for example, where we're sequencing an orderId
automatically. And this would be something like an orderItemSequenceId
, where we have a sub-sequence that varies for order item records related back to an orderHeader
. So all of them will have the same orderId
.
|
Required |
Specify the name of the entity for a | |
|
Required |
The field that will have the sub-sequenced value. We use the | |
|
Optional—defaults to |
Since these are eventually strings we do numeric-padding so that the sort is consistent. By default we pad it with five positions. For example | |
|
Optional—defaults to |
If you want to leave some space in the sub-sequence you can use a greater increment. |
Entity Find Operations deal with retrieving data from the database.
Performs a find by primary key lookup, returning a single GenericValue
object if it's found, otherwise it returns null. This operation replaces the deprecated <find-by-primary-key>
operation.
|
Required |
Name of the entity to look for. | |
|
Required |
Name of the variable to put the GenericValue in. | |
|
Optional—defaults to |
Specifies whether or not the delegator's cache should be searched before going to the database. This results in much faster retrieval times, but can return stale data that is not the most current in the database. | |
|
Optional—defaults to |
Specifies whether to look for all primary key field names in the current context as well as in the parameters map or not. |
Performs a find-by-and
lookup, returning a list of GenericValues
if any are found, otherwise returning null. Uses name/value pairs, that will be used for the query and will all be "anded" together. The result-set-type
by default is scroll which is flexible so we can go forward. This operation replaces the deprecated <find-by-and>
operation and uses the <field-map>
sub-element to pass in lookup criteria.
|
Required |
Name of the entity to look for. | |
|
Required |
Name of the variable to put the | |
|
Optional—defaults to |
Specifies whether or not the delegator's cache should be searched before going to the database. This results in much faster retrieval times, but can return stale data that is not the most current in the database. | |
|
Optional—defaults to |
Look for from date and through date fields in the list of results coming back, and filters by the current date and time if set to true. |
Like <entity-and>
returns a list of GenericValues
if any are found, otherwise returns null.
Uses any of <condition-expression>, <condition-list>
and <condition-object>
sub-elements to specify the lookup criteria.
|
Required |
Name of the entity to look for. | |
|
Required |
Name of the variable to put the | |
|
Optional defaults to |
Specifies whether or not the delegator's cache should be searched before going to the database. This results in much faster retrieval times, but can return stale data that is not the most current in the database. | |
|
Optional defaults to |
Look for from date and through date fields in the list of results coming back and filters by the current date and time if set to true. |
The following sub-elements are used by the entity-condition operation to specify WHERE conditions, HAVING conditions, fields to select and fields to order by.
A <condition-list>
is a list of conditions that are combined with either and
or or
. The default is and
. We can have condition-lists
under condition-list
, for building fairly complex condition trees, and we may also drop in condition-objects
at any point.
<condition-list combine="and"> <condition-expr field-name="partyId" operator="equals" env-name="parameters.partyId"/> <condition-expr field-name="roleTypeId" operator="equals" env-name="parameters.roleTypeId"/> </condition-list>
The <condition-expr>
tag basically combines a field, a SQL operator and a variable or a value. The variable is actually a field in the context
: env-name
. There are some options when to ignore the condition, namely if the env-name
or value is empty or null.
<entity-condition entity-name="OrderHeaderAndRoleSummary" list-name="orderInfoList"> <condition-list combine="and"> <condition-expr field-name="partyId" operator="equals" env-name="parameters.partyId"/> <condition-expr field-name="roleTypeId" operator="equals" env-name="parameters.roleTypeId"/> <condition-expr field-name="orderTypeId" operator="equals" env-name="parameters.orderTypeId"/> <condition-expr field-name="statusId" operator="equals" env-name="parameters.statusId"/> <condition-expr field-name="orderDate" operator="greater-equals" env-name="parameters.fromDate" ignore-if-null="true"/> <condition-expr field-name="orderDate" operator="less-equals" env-name="parameters.thruDate" ignore-if-null="true"/> </condition-list> <select-field field-name="partyId"/> <select-field field-name="roleTypeId"/> <select-field field-name="totalGrandAmount"/> <select-field field-name="totalSubRemainingAmount"/> <select-field field-name="totalOrders"/> <order-by field-name="partyId"/> </entity-condition>
The <entity-count>
tag is very similar to the <entity-condition>
. Specify the entity-name
, optionally the delegator-name
if you want to override that, and then the name of the variable to put the count in. You can do the same condition-expr
(condition expression) or condition-list
which can have condition-expr
and other condition-lists
underneath it for a tree of conditions that can be arbitrarily complex. You can also use the having-condition-list
, this is the same as on the entity-condition
. What this will do basically is, rather than doing a query and getting the results back, it will just count the results and put that number in the context in the variable named by the count-name
.
If we have a GenericValue
object sitting in the context and we want to get a related entity following one of the type one relationships in the data model, then we can specify the name of the value here, relation-name
, which is the name of the relationship between the two entities, and the to-value
where it should put the result.
|
Required |
Name of a generic value sitting in the context from where you want to get a related-one generic value. | |
|
Required |
Name of the one-relation to use to relate a generic value in value-name, to a generic value in to-value. | |
|
Required |
Name of a GenericValue where to put the result. | |
|
Optional—defaults to false |
Specifies whether or not the delegator's cache should be searched before going to the database. This results in much faster retrieval times, but can return stale data that is not the most current in the database. |
<get-related>
is just like <get-related-one>
, except that instead of getting a single value back to put in the to-value
, it gets a full List
back. We start with the value object, and specify the name of the relationship. We can specify the name of a map
that will restrain the query further, beyond the field mappings and their relationship.
We can also specify how you want to order it.
|
Required |
Name of a | |
|
Required |
Name of the one-relation to use to relate | |
|
Required |
Name of a list to put the result in. | |
|
Optional |
Name of a map that will restrain the query further, beyond the field mappings and their relationship. | |
|
Optional |
This will be a list sitting in the context that has string entries in it for each field that we want it to order by. Each field in the list, or each entry in the list, will just be a string with a field name. It can be preceded by a plus or a minus to specify an ascending or descending sort. The default is ascending sort, so we just put a minus in front of the field-name if we want it to be descending. | |
|
Optional—defaults to false |
Specifies whether or not the delegator's cache should be searched before going to the database. This results in much faster retrieval times, but can return stale data that is not the most current in the database. |
The <order-value-list>
operation does not actually do anything with the database. It takes an existing List
that has been returned and sorts it.
|
Required |
Name of the list of generic value objects that we want to sort. | |
|
Required |
This will be a list sitting in the context that has string entries in it for each field that you want it to order by. Each field in the list, or each entry in the list, will just be a string with a field name. It can be preceded by a plus or a minus to specify an ascending or descending sort for that. The default is ascending sort, so you just put a minus in front of the field-name if you want it to be descending. | |
|
Optional |
Name of the output list. If it is empty, as it is optional, it will simply use the list-name. In other words it will take the ordered list and put it over top of the resource list. |
The <filter-list-by-and>
tag filters the given list by the fields in the specified map.
|
Required |
The name of the method environment field that contains the list of GenericValue objects. | |
|
Optional |
The name of the method environment field the filtered list will be put into. Defaults to the value of the | |
|
Optional |
The name of a |
The <filter-list-by-date>
tag filters the given list by the valid date using the from and thru dates in each value object.
|
Required |
The name of the method environment field that contains the list of GenericValue objects. | |
|
Optional |
The name of the method environment field the filtered list will be put into. Defaults to the value of the list-name attribute (For example, it goes to the same place it came from, replacing the old list). | |
|
Optional |
The name of a field in the method environment date to filter by. Defaults to now. | |
|
Optional—defaults to "fromDate". |
The name of the GenericValue field to use as the beginning effective date. | |
|
Optional—defaults to "thruDate". |
The name of the GenericValue field to use as the beginning effective date. | |
|
Optional—defaults to |
Specifies whether or not all GenericValue objects in the list are of the same entity. |
These operations deal with persisting, updating and removing values to and from the database.
The make-value
tag uses the delegator to construct an entity value. The resulting value will not necessarily exist in the database, but will simply be assembled using the entity-name and fields map. The resulting GenericValue
object will be placed in the method environment using the specified value-name
.
|
Required |
The name of the method environment field that contains the GenericValue object. | |
|
Required |
The name of the entity to construct an instance of. | |
|
Required |
The name of a map in the method environment that will be used for the entity fields. |
The <clone-value>
tag makes a copy of the value in the method environment field specified by value-name
. The resulting GenericValue
object will be placed in the method environment using the specified new-value-name
.
|
Required |
The name of the method environment field that contains the | |
|
Required |
The name of the method environment field that will contain the new |
The <create-value>
tag persists the specified GenericValue
object by creating a new instance of the entity in the datasource.
An error will result if an instance of the entity exists in the datasource with the same primary key.
|
Required |
The name of the method environment field that contains the GenericValue object. | |
|
Optional defaults to true |
Clears the cache. |
The <store-value>
tag persists the specified GenericValue
object by updating the instance of the entity in the datasource. An error will result if an instance of the entity does not exist in the datasource with the same primary key.
|
Required |
The name of the method environment field that contains the GenericValue object. | |
|
Optional—defaults to |
Clears the cache. |
Forces a value to refresh from the database.
|
Required |
The name of the method environment field that contains the GenericValue object. | |
|
Optional—defaults to |
Clears the cache. |
The remove-value tag removes the specified GenericValue object by removing the instance of the entity in the datasource.
|
Required |
The name of the method environment field that contains the GenericValue object. | |
|
Optional—defaults to |
Clears the cache. |
Given a value name and a relationship name, this operation follows the relationship and removes all related records, whether they be a type one or type many relationship.
For a type one relationship it will remove a single record if it exists, and for a type many relationship it will remove all the records that are related to it.
This of course can be dangerous. For example if we have a product-type entity and we do a remove-related with a certain product type value object here, and the relation name product here, it will remove all products of that type. This is of more value when we are doing something like removing an order or removing a product, and we want to remove all related elements before removing the product to resolve foreign key issues. Usually the best practice for that, is to do a remove-related on certain types of information related to the product, and then try to remove the product but not remove all related tables.
In many cases, if the product has been ordered for example, then you do not want to remove the product, and so you can do all these remove-related(s).
|
Required |
The name of the method environment field that contains the GenericValue object. | |
|
Required |
Name of a relation to use to remove related records. | |
|
Optional—defaults to |
Clears the cache. |
The <remove-by-and>
tag uses the delegator to remove entity values from the datasource and is constrained by "anding" the fields passed in the Map
. Make sure the Map
contains something, or all values will be removed.
|
Required |
The name of the entity to remove instances of. | |
|
Required |
The name of a map in the method environment that will be used for the entity fields. | |
|
Optional defaults to true |
Clears the cache. |
Looks for each primary key / non primary key field in the named map and if it exists there, it will copy it into the named value object.
|
Required |
The name of the method environment field that contains the | |
|
Required |
The name of a map in the method environment that will be used for the entity fields. | |
|
Optional—defaults to |
Specifies whether or not to set fields that are null or empty. |
The <store-list>
tag uses the delegator to store all entity values in the list. This is different than storing a single value using the <store-value>
operation in that values in the List
will be inserted if they do not exist, or updated if they do.
|
Required |
The name of the method environment field that contains the list of GenericValue objects. | |
|
Optional—defaults to |
Clears the cache. |
Control operations allow us to iterate through Lists
and Maps
, add and check errors, and return from the Simple Method.
The operations contained by the iterate tag will be executed for each of the entries in the List
, and will make the current entry available in the method environment by the entry-name specified. This tag can contain any of the simple-method operations, including the conditional/if operations. Any simple-method operation can be nested under the iterate tag.
|
Required |
The name of the method environment field that will contain each entry as we iterate through the list. | |
|
Required |
The name of the method environment field that contains the list to iterate over. |
The operations contained by the iterate-map tag will be executed for each of the entries in the map. It will run all of the operations underneath the iterate-map-element for each of the entries in the given map, setting the key for that entry and the key-name variable, and the value for that entry and the value-name variable. This tag can contain any of the simple-method operations, including the conditional/if operations. Any simple-method operation can be nested under the iterate-map tag.
|
Required |
Name of the variable to put the key in. | |
|
Required |
Name of the variable to put the value in. | |
|
Required |
Name of the map to use. |
The message lists from invoking are not checked until the <check-errors>
tag is used.
The named List
is checked and if it contains any messages they are put in the servlet request object, and the specified error code is returned to the control servlet.
|
Optional—defaults to |
Defaults to error. | |
|
Optional—defaults to |
The name of the list in the method environment to check for error messages. |
Adds an error message to the given error list from either an inline message or a message from a properties file using the sub elements <fail-message>
or <fail-property>
.
|
Optional—defaults to |
The name of the list in the method environment to add the error message to. |
These operations allow us to control the flow through the Simple Method depending on simple if
tests.
The operations contained by the <if-validate-method>
tag will only be executed if the validate method returns true. <if-validate-method>
calls a static Java method that takes a String
and returns a boolean
. This tag can contain any of the simple-method operations, including the conditional/if operations.
|
Required |
The name of the map field that will be validated. | |
|
Required |
The name of the method that will be called to validate the field. It must be a static method that takes a single | |
|
Optional |
The name of the method environment field that contains the map that the field to be validated will come from. If not specified the |
Checks if the field is an instance of the name class.
|
Required |
The name of the map field that will be validated as being an instance of the named class. | |
|
Required |
The name of the class that the named instance in field-name is supposed to belong. |
The operations contained by the <if-compare>
tag will only be executed if the comparison returns true
. This tag can contain any of the simple-method operations, including the conditional/if operations.
|
Required |
The name of the map field that will be compared. | |
|
Required |
The value that the field will be compared to. Must be a String, but can be converted to other types. | |
|
Optional |
The name of the method environment field that contains the map that the field to be validated will come from. If not specified the field-name will be treated as a method environment field name (an env-name). |
The operations contained by the <if-compare-field>
tag will only be executed if the comparison returns true. This tag can contain any of the simple-method operations, including the conditional/if operations.
|
Required |
The name of the map field that will be compared. | |
|
Optional |
The name of the method environment field that contains the map that the field to be validated will come from. If not specified the field-name will be treated as a method environment field name (an env-name). | |
|
Optional |
The name of the to-map field that the main field will be compared to. If left empty, will default to the field-name. | |
|
Optional |
The name of the method environment field that contains the map that the field to be compared will come from. If left empty will default to the method environment. It does not default to the map-name because that would make it impossible to compare a map field to an environment field. |
|
Required |
The name of the map field that will be compared. | |
|
Optional |
The name of the method environment field that contains the map that the field to be validated will come from. If not specified the field-name will be treated as a method environment field name (an |
Nested conditions are acceptable in Minilang. Consider the following example:
<if> <condition><not><if-empty field-name="parameters.groupName"/> </not></condition> <then> <entity-one entity-name="PartyGroup" value-name="partyGroup"/> <if> <condition><if-compare-field field-name="partyGroup.groupName" operator="not-equals" to-field-name="parameters.groupName"/> </condition> <then> <set-nonpk-fields value-name="partyNameHistory" map-name="partyGroup"/> <create-value value-name="partyNameHistory"/> </then> </if> </then> </if>
These operations allow us to add Debug messages, calculate values or obtain the Timestamp value for this instant.
The <log>
tag logs a message used by the OFBiz Debug
class, which uses Log4J to log to the console, a file, or some other location. The message is a concatenation of the message attribute and then all of the field and string sub-element values in the order they are specified. Possible levels, which relate to the logging levels set in debug.properties
are: verbose, timing, info, important, warning, error, fatal, always
.
The <now-timestamp-to-env>
tag creates a java.sql.Timestamp
object with the current date and time in it and puts it in a field in the method environment.
The <now-date-to-env>
tag creates a java.sql.Date
object with the current date in it and puts it in a field in the method environment.
The <set-current-user-login>
tag sets the UserLogin GenericValue
object to be used for authentication for the rest of the method. This is mostly used for calling services, and so on.
The <calculate>
tag performs the specified calculation and puts the result in an object in the field of the specified Map
.
The type of the object can be specified with the type attribute, this defaults to Double
. The calculate tag can contain <calcop>
and <number>
tags, and the <calcop>
tag can also contain these two tags to enable nested calculations. The operator specifies the operation to perform on the given field and nested calcops and numbers. It must be one of the following: get
| add
| subtract
| multiply
| divide
| negative
.
|
Required |
The name (key) of the | |
|
Optional |
The name of the map in the method environment. If not specified the | |
|
Optional—defaults to |
Specifies the type of the object. Can be | |
|
Optional—defaults to |
Rounding mode for | |
|
Optional—defaults to |
Rounding mode for | |
|
Optional—defaults to |
Initial scale to use for the internal |
<set field="productCost" value="0" type="Double" /> <calculate field-name="productCost" type="Double" decimal-scale="6"> <calcop field-name="laborCost.cost" operator="add"> <calcop field-name="materialsCost.cost" operator="get"/> <calcop field-name="routeCost.cost" operator="get"/> <calcop field-name="otherCost.cost" operator="get"/> </calcop> </calculate>