com.flexive.shared.interfaces
Interface ScriptingEngine

All Known Subinterfaces:
ScriptingEngineLocal

public interface ScriptingEngine

Scripting engine

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Method Summary
 FxScriptMappingEntry createAssignmentScriptMapping(FxScriptEvent scriptEvent, long scriptId, long assignmentId, boolean active, boolean derivedUsage)
          Create a new mapping for assignments with with a given FxScriptEvent
 FxScriptMappingEntry createAssignmentScriptMapping(long scriptId, long assignmentId, boolean active, boolean derivedUsage)
          Create a new mapping for assignments with the default FxScriptEvent the script was created with
 FxScriptInfo createScript(FxScriptInfoEdit scriptInfo)
          Constructs a new script with the data provided by FxScriptInfoEdit, (the id is discarded)
 FxScriptInfo createScriptFromDropLibrary(java.lang.String dropName, java.lang.String libraryname, FxScriptInfo scriptInfo)
          Create a new script based on a script from a drop's library:
The script's code is loaded from the library, other data needed for creating the script is provided by the scriptInfo parameter (id is discarded).
 FxScriptInfo createScriptFromLibrary(java.lang.String libraryname, FxScriptInfo scriptInfo)
          Create a new script based on a script from the library:
The script's code is loaded from the library, other data needed for creating the script is provided by the scriptInfo parameter (id is discarded).
 FxScriptSchedule createScriptSchedule(FxScriptScheduleEdit scriptSchedule)
          Create a script schedule
 FxScriptMappingEntry createTypeScriptMapping(FxScriptEvent scriptEvent, long scriptId, long typeId, boolean active, boolean derivedUsage)
          Create a new mapping for types with a given FxScriptEvent
 FxScriptMappingEntry createTypeScriptMapping(long scriptId, long typeId, boolean active, boolean derivedUsage)
          Create a new mapping for types with the default FxScriptEvent the script was created with
 void executeDropRunOnceScripts(Parameter<java.lang.Boolean> param, java.lang.String dropName)
          Execute run-once scripts for drops.
 void executeDropStartupScripts(java.lang.String dropName)
          Execute start up scripts for a specific drop.
 void executeRunOnceScripts()
          Execute run-once scripts.
 void executeStartupScripts()
          Execute start up scripts.
 java.util.List<java.lang.String[]> getAvailableScriptEngines()
          Get a list containing script extension and script engine info as 2-dimensional String array
 java.util.List<java.lang.Long> getByScriptEvent(FxScriptEvent scriptEvent)
          Get scripts by their event
 java.util.List<FxScriptRunInfo> getRunOnceInformation()
          Get information about running/executed runOnce scripts (including all drops) Please note that this method will only return entries if scripts have been executed in the current VM and in the current session (information is not persisted - yet!)
 java.util.List<FxScriptInfo> getScriptInfos()
          Get all available information for all existing scripts
 java.lang.String loadScriptCode(long scriptId)
          Load a scripts code
 FxScriptMapping loadScriptMapping(long scriptId)
          Loads all assignment mappings for a specified script
 void remove(long scriptId)
          Remove a script (will remove all mappings for this script as well)
 void removeAssignmentScriptMapping(long scriptId, long assignmentId)
          Remove a mapping from a script to an assignment (directly mapped, not via inheritance!)
 void removeAssignmentScriptMappingForEvent(long scriptId, long assignmentId, FxScriptEvent event)
          Remove a mapping from a script to an assignment for a specific event (directly mapped, not via inheritance!)
 void removeScriptSchedule(long scheduleId)
          Removes an existing script schedule
 void removeTypeScriptMapping(long scriptId, long typeId)
          Remove a mapping from a script to a type (directly mapped, not via inheritance!)
 void removeTypeScriptMappingForEvent(long scriptId, long typeId, FxScriptEvent event)
          Remove a mapping from a script to a type (directly mapped, not via inheritance!) for a specific script event
 FxScriptResult runScript(long scriptId)
          Run a script
 FxScriptResult runScript(long scriptId, FxScriptBinding binding)
          Run a script with the given variable binding
 FxScriptResult runScript(java.lang.String scriptName, FxScriptBinding binding)
          Run a script with the given variable binding
 FxScriptResult runScript(java.lang.String name, FxScriptBinding binding, java.lang.String code)
          Execute a script
 FxScriptMappingEntry updateAssignmentScriptMappingForEvent(long scriptId, long assignmentId, FxScriptEvent event, boolean active, boolean derivedUsage)
          Update a mapping for assignments (activate or deactivate a mapping, toggle derived usage)
 void updateScriptCode(long scriptId, java.lang.String code)
          Convenience method to update a scripts code
 void updateScriptInfo(FxScriptInfoEdit scriptInfo)
          Update script info
 FxScriptSchedule updateScriptSchedule(FxScriptScheduleEdit scriptSchedule)
          Update an existing script schedule
 FxScriptMappingEntry updateTypeScriptMappingForEvent(long scriptId, long typeId, FxScriptEvent event, boolean active, boolean derivedUsage)
          Update a mapping for types (activate or deactivate a mapping, toggle derived usage)
 

Method Detail

loadScriptCode

java.lang.String loadScriptCode(long scriptId)
                                throws FxApplicationException
Load a scripts code

Parameters:
scriptId - requested script
Returns:
code
Throws:
FxApplicationException - on errors

getScriptInfos

java.util.List<FxScriptInfo> getScriptInfos()
                                            throws FxApplicationException
Get all available information for all existing scripts

Returns:
FxScriptInfo
Throws:
FxApplicationException - on errors

updateScriptInfo

void updateScriptInfo(FxScriptInfoEdit scriptInfo)
                      throws FxApplicationException
Update script info

Parameters:
scriptInfo - the edited script info
Throws:
FxApplicationException - on errors

updateScriptCode

void updateScriptCode(long scriptId,
                      java.lang.String code)
                      throws FxApplicationException
Convenience method to update a scripts code

Parameters:
scriptId - requested script id
code - the code
Throws:
FxApplicationException - on errors
See Also:
updateScriptInfo(FxScriptInfoEdit scriptInfo)

getByScriptEvent

java.util.List<java.lang.Long> getByScriptEvent(FxScriptEvent scriptEvent)
Get scripts by their event

Parameters:
scriptEvent - requested script event
Returns:
array of id's by event

createScript

FxScriptInfo createScript(FxScriptInfoEdit scriptInfo)
                          throws FxApplicationException
Constructs a new script with the data provided by FxScriptInfoEdit, (the id is discarded)

Parameters:
scriptInfo - script information
Returns:
FxScriptInfo for the newly created script
Throws:
FxApplicationException - on errors
Since:
3.1.1

createScriptFromLibrary

FxScriptInfo createScriptFromLibrary(java.lang.String libraryname,
                                     FxScriptInfo scriptInfo)
                                     throws FxApplicationException
Create a new script based on a script from the library:
The script's code is loaded from the library, other data needed for creating the script is provided by the scriptInfo parameter (id is discarded).

Parameters:
libraryname - name of the script in the script library
scriptInfo - script information
Returns:
FxScriptInfo for the newly created script
Throws:
FxApplicationException - on errors
Since:
3.1.1
See Also:
FxScriptEvent

createScriptFromDropLibrary

FxScriptInfo createScriptFromDropLibrary(java.lang.String dropName,
                                         java.lang.String libraryname,
                                         FxScriptInfo scriptInfo)
                                         throws FxApplicationException
Create a new script based on a script from a drop's library:
The script's code is loaded from the library, other data needed for creating the script is provided by the scriptInfo parameter (id is discarded).

Parameters:
dropName - name of the drop to use as repository
libraryname - name of the script in drop
scriptInfo - script information
Returns:
FxScriptInfo for the newly created script
Throws:
FxApplicationException - on errors
Since:
3.1.1
See Also:
FxScriptEvent

remove

void remove(long scriptId)
            throws FxApplicationException
Remove a script (will remove all mappings for this script as well)

Parameters:
scriptId - id of the script and its mappings to remove
Throws:
FxApplicationException - on errors

runScript

FxScriptResult runScript(java.lang.String scriptName,
                         FxScriptBinding binding)
                         throws FxApplicationException
Run a script with the given variable binding

Parameters:
scriptName - name of the script to run
binding - variable binding to use (all bound variables have to be serializable!)
Returns:
script result
Throws:
FxApplicationException - on errors

runScript

FxScriptResult runScript(long scriptId,
                         FxScriptBinding binding)
                         throws FxApplicationException
Run a script with the given variable binding

Parameters:
scriptId - id of the script to run
binding - variable binding to use (all bound variables have to be serializable!)
Returns:
script result
Throws:
FxApplicationException - on errors

runScript

FxScriptResult runScript(java.lang.String name,
                         FxScriptBinding binding,
                         java.lang.String code)
                         throws FxApplicationException
Execute a script

Parameters:
name - name of the script, extension is needed to choose interpreter
binding - bindings to apply
code - the script code
Returns:
last script evaluation result
Throws:
FxApplicationException - on errors

getAvailableScriptEngines

java.util.List<java.lang.String[]> getAvailableScriptEngines()
                                                             throws FxApplicationException
Get a list containing script extension and script engine info as 2-dimensional String array

Returns:
list containing script extension and script engine info as 2-dimensional String array
Throws:
FxApplicationException - on errors

runScript

FxScriptResult runScript(long scriptId)
                         throws FxApplicationException
Run a script

Parameters:
scriptId - id of the script to run
Returns:
script result
Throws:
FxApplicationException - on errors

createAssignmentScriptMapping

FxScriptMappingEntry createAssignmentScriptMapping(long scriptId,
                                                   long assignmentId,
                                                   boolean active,
                                                   boolean derivedUsage)
                                                   throws FxApplicationException
Create a new mapping for assignments with the default FxScriptEvent the script was created with

Parameters:
scriptId - id of the script
assignmentId - id of the assignment
active - mapping is active?
derivedUsage - mapping used in derived assignments?
Returns:
the created entry
Throws:
FxApplicationException - on errors

createAssignmentScriptMapping

FxScriptMappingEntry createAssignmentScriptMapping(FxScriptEvent scriptEvent,
                                                   long scriptId,
                                                   long assignmentId,
                                                   boolean active,
                                                   boolean derivedUsage)
                                                   throws FxApplicationException
Create a new mapping for assignments with with a given FxScriptEvent

Parameters:
scriptEvent - FxScriptEvent for this mapping (on create, save, remove, etc.)
scriptId - id of the script
assignmentId - id of the assignment
active - mapping is active?
derivedUsage - mapping used in derived assignments?
Returns:
the created entry
Throws:
FxApplicationException - on errors

loadScriptMapping

FxScriptMapping loadScriptMapping(long scriptId)
                                  throws FxLoadException,
                                         java.sql.SQLException
Loads all assignment mappings for a specified script

Parameters:
scriptId - the script
Returns:
the script mappings
Throws:
FxLoadException - on errors
java.sql.SQLException - on errors

createTypeScriptMapping

FxScriptMappingEntry createTypeScriptMapping(long scriptId,
                                             long typeId,
                                             boolean active,
                                             boolean derivedUsage)
                                             throws FxApplicationException
Create a new mapping for types with the default FxScriptEvent the script was created with

Parameters:
scriptId - id of the script
typeId - id of the type
active - mapping is active?
derivedUsage - mapping used in derived types?
Returns:
the created entry
Throws:
FxApplicationException - on errors

createTypeScriptMapping

FxScriptMappingEntry createTypeScriptMapping(FxScriptEvent scriptEvent,
                                             long scriptId,
                                             long typeId,
                                             boolean active,
                                             boolean derivedUsage)
                                             throws FxApplicationException
Create a new mapping for types with a given FxScriptEvent

Parameters:
scriptEvent - FxScriptEvent for this mapping (on create, save, remove, etc.)
scriptId - id of the script
typeId - id of the type
active - mapping is active?
derivedUsage - mapping used in derived types?
Returns:
the created entry
Throws:
FxApplicationException - on errors

removeAssignmentScriptMapping

void removeAssignmentScriptMapping(long scriptId,
                                   long assignmentId)
                                   throws FxApplicationException
Remove a mapping from a script to an assignment (directly mapped, not via inheritance!)

Parameters:
scriptId - id of the script
assignmentId - id of the assignment
Throws:
FxApplicationException - on errors

removeAssignmentScriptMappingForEvent

void removeAssignmentScriptMappingForEvent(long scriptId,
                                           long assignmentId,
                                           FxScriptEvent event)
                                           throws FxApplicationException
Remove a mapping from a script to an assignment for a specific event (directly mapped, not via inheritance!)

Parameters:
scriptId - id of the script
assignmentId - id of the assignment
event - the script event
Throws:
FxApplicationException - on errors

removeTypeScriptMapping

void removeTypeScriptMapping(long scriptId,
                             long typeId)
                             throws FxApplicationException
Remove a mapping from a script to a type (directly mapped, not via inheritance!)

Parameters:
scriptId - id of the script
typeId - id of the type
Throws:
FxApplicationException - on errors

removeTypeScriptMappingForEvent

void removeTypeScriptMappingForEvent(long scriptId,
                                     long typeId,
                                     FxScriptEvent event)
                                     throws FxApplicationException
Remove a mapping from a script to a type (directly mapped, not via inheritance!) for a specific script event

Parameters:
scriptId - id of the script
typeId - id of the type
event - the script event
Throws:
FxApplicationException - on errors

updateAssignmentScriptMappingForEvent

FxScriptMappingEntry updateAssignmentScriptMappingForEvent(long scriptId,
                                                           long assignmentId,
                                                           FxScriptEvent event,
                                                           boolean active,
                                                           boolean derivedUsage)
                                                           throws FxApplicationException
Update a mapping for assignments (activate or deactivate a mapping, toggle derived usage)

Parameters:
scriptId - id of the script
assignmentId - id of the assignment
event - the script event
active - mapping is active?
derivedUsage - mapping used in derived assignments?
Returns:
the updated entry
Throws:
FxApplicationException - on errors

updateTypeScriptMappingForEvent

FxScriptMappingEntry updateTypeScriptMappingForEvent(long scriptId,
                                                     long typeId,
                                                     FxScriptEvent event,
                                                     boolean active,
                                                     boolean derivedUsage)
                                                     throws FxApplicationException
Update a mapping for types (activate or deactivate a mapping, toggle derived usage)

Parameters:
scriptId - id of the script
typeId - id of the type
event - the script event
active - mapping is active?
derivedUsage - mapping used in derived types?
Returns:
the updated entry
Throws:
FxApplicationException - on errors

executeRunOnceScripts

void executeRunOnceScripts()
                           throws FxApplicationException
Execute run-once scripts. No exceptions are throws since there is no means of user feedback. If errors occur, they are written to the logfile. run-once scripts are only executed once in the lifetime of a division! consecutive calls have no effect and nothing will be executed!

Throws:
FxApplicationException - on errors

executeStartupScripts

void executeStartupScripts()
Execute start up scripts. No exceptions are throws since there is no means of user feedback. If errors occur, they are written to the logfile. start up scripts are only executed once each time the application server is started. consecutive calls *will* execute start up scripts again!


executeDropRunOnceScripts

void executeDropRunOnceScripts(Parameter<java.lang.Boolean> param,
                               java.lang.String dropName)
                               throws FxApplicationException
Execute run-once scripts for drops. run-once scripts are only executed once in the lifetime of a division! consecutive calls have no effect and nothing will be executed! param will be set to "true" once the scripts are run and will be checked to be "false" prior to run

Parameters:
param - boolean parameter to mark scripts as being run
dropName - name of the drop (WAR archive name without extension)
Throws:
FxApplicationException - if the requested drop is unknown or invalid

executeDropStartupScripts

void executeDropStartupScripts(java.lang.String dropName)
                               throws FxApplicationException
Execute start up scripts for a specific drop. To be called from a filter or the like. No exceptions are throws since there is no means of user feedback. If errors occur, they are written to the logfile. start up scripts are only executed once each time the application server is started. consecutive calls *will* execute start up scripts again!

Parameters:
dropName - name of the drop (WAR archive name without extension)
Throws:
FxApplicationException - if the requested drop is unknown or invalid

getRunOnceInformation

java.util.List<FxScriptRunInfo> getRunOnceInformation()
                                                      throws FxApplicationException
Get information about running/executed runOnce scripts (including all drops) Please note that this method will only return entries if scripts have been executed in the current VM and in the current session (information is not persisted - yet!)

Returns:
information
Throws:
FxApplicationException - on errors

createScriptSchedule

FxScriptSchedule createScriptSchedule(FxScriptScheduleEdit scriptSchedule)
                                      throws FxApplicationException
Create a script schedule

Parameters:
scriptSchedule - script schedule edit
Returns:
the created script schedule
Throws:
FxApplicationException - on errors
Since:
3.1.2

removeScriptSchedule

void removeScriptSchedule(long scheduleId)
                          throws FxApplicationException
Removes an existing script schedule

Parameters:
scheduleId - script schedule id
Throws:
FxApplicationException - on errors
Since:
3.1.2

updateScriptSchedule

FxScriptSchedule updateScriptSchedule(FxScriptScheduleEdit scriptSchedule)
                                      throws FxApplicationException
Update an existing script schedule

Parameters:
scriptSchedule - script schedule
Returns:
the updated script schedule
Throws:
FxApplicationException - on errors
Since:
3.1.2