Package org.apache.ofbiz.base.util
Interface ScriptHelper
- All Known Implementing Classes:
ScriptHelperImpl
public interface ScriptHelper
A script helper object. The OFBiz scripting framework will include an
instance of this class in the script's bindings.
The scripting language will determine how the helper is used. Most
languages will access it as a variable:
partyValue = ofbiz.findOne("Party");
while other languages might access it as a native method or function:
partyValue = findOne("Party");
-
Method Summary
Modifier and TypeMethodDescriptioncreateServiceMap
(String serviceName, Map<String, ? extends Object> inputMap) Extracts service IN parameters frominputMap
and returns them in a newMap
.void
Sets the event/service status to error status.evalString
(String original) Evaluates aString
and returns the result.void
Sets the event/service status to failure status.Returns aList
ofGenericValue
s.Finds aGenericValue
by primary key.Finds aGenericValue
by primary key.void
Logs an error message.void
Logs an info message.void
logWarning
(String message) Logs a warning message.Creates a new, emptyGenericValue
.Creates a new, emptyGenericValue
.runService
(String serviceName, Map<String, ? extends Object> inputMap) Runs a service synchronously.runService
(String serviceName, Map<String, ? extends Object> inputMap, Map<String, ? extends Object> args) Runs a service synchronously.void
success()
Sets the event/service status to success status.void
Sets the event/service status to success status.
-
Method Details
-
createServiceMap
Map<String,? extends Object> createServiceMap(String serviceName, Map<String, ? extends Object> inputMap) throws ScriptExceptionExtracts service IN parameters frominputMap
and returns them in a newMap
.- Parameters:
serviceName
-inputMap
-- Returns:
- The matching service parameters
- Throws:
ScriptException
-
error
Sets the event/service status to error status.- Parameters:
message
-
-
evalString
Evaluates aString
and returns the result.- Parameters:
original
-- Returns:
-
failure
Sets the event/service status to failure status.- Parameters:
message
-
-
findList
List<Map<String,Object>> findList(String entityName, Map<String, ? extends Object> fields) throws ScriptExceptionReturns aList
ofGenericValue
s.- Parameters:
entityName
-fields
-- Returns:
- Throws:
ScriptException
-
findOne
Finds aGenericValue
by primary key. The helper will construct a primary key from existing variables.- Parameters:
entityName
-- Returns:
- Throws:
ScriptException
-
findOne
Map<String,Object> findOne(String entityName, Map<String, ? extends Object> fields, Map<String, throws ScriptException? extends Object> args) Finds aGenericValue
by primary key. The helper will construct a primary key from existing variables and/orfields
.- Parameters:
entityName
-fields
-args
-- Returns:
- Throws:
ScriptException
-
logError
Logs an error message.- Parameters:
message
-
-
logInfo
Logs an info message.- Parameters:
message
-
-
logWarning
Logs a warning message.- Parameters:
message
-
-
makeValue
Creates a new, emptyGenericValue
.- Parameters:
entityName
-- Returns:
- Throws:
ScriptException
-
makeValue
Creates a new, emptyGenericValue
.- Parameters:
entityName
-fields
-- Returns:
- Throws:
ScriptException
-
runService
Map<String,? extends Object> runService(String serviceName, Map<String, ? extends Object> inputMap) throws ScriptExceptionRuns a service synchronously.- Parameters:
serviceName
-inputMap
-- Returns:
- Throws:
ScriptException
-
runService
Map<String,? extends Object> runService(String serviceName, Map<String, ? extends Object> inputMap, Map<String, throws ScriptException? extends Object> args) Runs a service synchronously.- Parameters:
serviceName
-inputMap
-args
-- Returns:
- Throws:
ScriptException
-
success
void success()Sets the event/service status to success status. -
success
Sets the event/service status to success status.- Parameters:
message
-
-