Transact

⌘K
  1. Home
  2. Transact
  3. Developer Documentation
  4. Scripting Resources
  5. Application Level Script

Application Level Script

Overview

The Application Level script is global to the Ephesoft Transact environment and is fully configurable to add additional logic. Ephesoft Transact will execute the Application Level script at the system or service level. Some common customizations to the script include:

  • Running stored procedures in the database
  • Restarting batch instances upon error
  • Executing custom imports into a batch instance
  • Sending email notifications to users

The script is executed by a cron schedule, which will tell Ephesoft Transact how frequently to execute a task. To configure an Application Level script, you will need to perform the following steps:

  1. Write the script.
  2. Determine how often Ephesoft Transact will execute the script.
  3. Add the script to the dcma-scripting-plugin.properties file, located in <Install Dir>:\Ephesoft\Application\WEB-INF\classes\META-INF\dcma-scripting-plugin\dcma-scripting-plugin-properties.

This feature provides users with an option to execute a script repeatedly in specific time intervals to automate application jobs and execute a script without initiating a batch.

Configurable Properties

Following are the configurable properties available for application level script in the dcma-scripting-plugin.properties file:

Configurable Property Type Value Options Description
Script Class Name (script.application.scriptClassName) String A valid java class name (without .java or .class extension) This value tells the name of the java script file present under a folder in Ephesoft SharedFolders. Default: MyApplicationLevelScript
Script Folder Name (script.application.scriptFolderName) String A valid folder name inside Ephesoft Shared Folders. This value specifies the folder name that contains application level script files. Default: MyApplicationLevelScript
Execution interval cron job (dcma.applicationLevelScript.cronExpression) String Valid cron expression This cron expression specifies the time interval in which the script will be executed.

 

Create the Script File

The script file is a simple java class implementing an ApplicationScripts interface.

  1. To execute a script at the application level, you must import the script project and define what the java class implements and executes.

Below is a sample of the script file structure:

import com.ephesoft.dcma.script.ApplicationScripts;

public class MyApplicationLevelScript implements ApplicationScripts {

public Object execute(String shareFolderPath) {

/**************task to done **************/

}

}
  1. Save the file with a .java extension.

Note: A default script file will be available in the application-script folder in located in Ephesoft SharedFolders for reference.

Configuration

  1. Specify the following properties in the META-INF/dcma-scripting-plugin/dcma-scripting-plugin.properties file:
    • script file name
    • folder name
    • cron expression
  2. Save and close the file.

Note: Application Level scripts are enabled by default. The script on/off switch (script.scriptSwitch) available in the properties file does not control the execution of the Application Level script. It only enables or disables execution of batch class level scripts.

Execution

  1. Navigate to Ephesoft SharedFolders and create a folder with the same name as configured in the property file.
  2. Create a script file with the same name as specified in property file. Save the file with .java extension.
  3. Create a directory folder in Ephesoft SharedFolders with the same name as specified in property file.
  4. Copy the script file to the new directory folder.
  5. You have configured and set up the Application Level script on your Ephesoft Transact server. The script will begin executing at your specified time interval.

Dependency

For this feature to function in a multi-server environment with the restore mechanism, you will need the heartbeat module to be running on all the servers.

Troubleshooting

Following are a few common error messages seen in the log files due to issues with configuration and execution:

Error Message Possible Cause
Script not found Either the script file or folder doesn’t exist as specified in the property file. Verify the script folder and folder name present in the Ephesoft SharedFolders.
Script errored out The script file was not correct. Verify the script file syntax. It must implement an ApplicationScripts interface.
Failed to compile A java compilation error occurred in the script file. Verify the java code in a java editor.