Difference between revisions of "Custom Tasks"

From Lingoport Wiki
Jump to: navigation, search
(Syntax of Task element)
(Custom Tasks)
Line 39: Line 39:
 
* '''url''' - the location of the jar file that contains the custom task
 
* '''url''' - the location of the jar file that contains the custom task
 
* '''class''' - the class library that is to be used
 
* '''class''' - the class library that is to be used
* '''method''' - the method that is to be called
+
* '''method''' - the method that is to be called. This method has either no arguments or the <code>com.lingoport.lrm.customtask.LRMContext</code> argument.
 
* '''onerrorresumenext''' - if '''false''' then the process continues if there is an error that is thrown. If '''true''' then the process will stop with an error.
 
* '''onerrorresumenext''' - if '''false''' then the process continues if there is an error that is thrown. If '''true''' then the process will stop with an error.
   
Line 51: Line 51:
 
</pre>
 
</pre>
   
=== Expected Arguments ===
+
== LRM Context Argument ==
  +
The <code>com.lingoport.lrm.customtask.LRMContext</code> argument is a map containing dynamic information for a particular stage. You can view the information for each of the custom task stages by adding the following task to each stage (changing the location of your LRM home if needed):
The calling method can have either no arguments or the
 
  +
<pre>
  +
<task url="file:/var/lib/jenkins/lingoport/lrm-server-3.0/samples/CustomTask/lrm-customtasktest.jar"
  +
class="com.lingoport.lrm.customtask.test.CustomTaskTest"
  +
method="testLRMContextArg"
  +
onerrorresumenext="true"/>
  +
</pre>
  +
  +
The log file will contain the LRMContext information.

Revision as of 23:12, 27 April 2016

Custom Tasks

The config_custom_tasks.xml configuration file contains the specific stages where a plugin can be called. Dynamic information is available to the plugin through the LRM Context object (com.lingoport.lrm.customtask.LRMContext). The lrm-customtasktest.jar, located in the samples/CustomTask/ folder of your install directory, contains methods for testing out these different stages.

Configuration

The config_custom_tasks.xml has elements for each stage of the LRM process that allows for custom tasks. The stages are:

custom-tasks>
	<stages>
		<prep-kit>
			<before-send-locale>
			    <!-- Tasks that will run BEFORE files are uploaded to the specified L10n Vendor -->
                        </before-send-locale>
			<after-send-locale>
			     <!-- Tasks that will run AFTER files have been successfully uploaded to the specified L10n Vendor -->
			</after-send-locale>
		</prep-kit>
		<notification>
			<before-notify-changes>	
			    <!-- Tasks that will run BEFORE the Notify Changes email is sent -->					   
			</before-notify-changes>
			<before-late-prep-kits>
			    <!-- Tasks that will run BEFORE the Late Prep Kit email is sent -->
			</before-late-prep-kits>
		</notification>
		<import-kit>
			<before-import-locale>
                            <!-- Tasks that will run BEFORE files for a specific locale are imported -->
			</before-import-locale>
			<after-import-locale>
			     <!-- Tasks that will run AFTER files for a specific locale have been imported successfully -->
			</after-import-locale>
		</import-kit>
	</stages>
</custom-tasks>

Syntax of Task element

The task element has the following attributes:

  • url - the location of the jar file that contains the custom task
  • class - the class library that is to be used
  • method - the method that is to be called. This method has either no arguments or the com.lingoport.lrm.customtask.LRMContext argument.
  • onerrorresumenext - if false then the process continues if there is an error that is thrown. If true then the process will stop with an error.

Example using the lrm-customtasktest.jar located in the install directory under samples/CustomTask

<task url="file:/C:/Lingoport/LRM-Server-3.0/samples/CustomTask/lrm-customtasktest.jar"
     class="com.lingoport.lrm.customtask.test.CustomTaskTest" 
     method="testNoArgs"
     onerrorresumenext="true"/>

LRM Context Argument

The com.lingoport.lrm.customtask.LRMContext argument is a map containing dynamic information for a particular stage. You can view the information for each of the custom task stages by adding the following task to each stage (changing the location of your LRM home if needed):

<task url="file:/var/lib/jenkins/lingoport/lrm-server-3.0/samples/CustomTask/lrm-customtasktest.jar"
      class="com.lingoport.lrm.customtask.test.CustomTaskTest" 
      method="testLRMContextArg"
      onerrorresumenext="true"/>

The log file will contain the LRMContext information.