5.8.2 Preparing the custom function

If you choose to use the custom function, create the following two items, which are used for the custom function:

The following describes the procedure for creating the items above.

Organization of this subsection
(1) Creating the transformation function definition file
(2) Creating a Java program

(1) Creating the transformation function definition file

  1. From the Eclipse menu, select File, New, and then Other.
    The New dialog box appears.
  2. Select XML, and then XML File. Then, click the Next button.
    The XML page appears.

    [Figure]

  3. Specify the directory that will contain the transformation function definition file and the desired transformation function definition file. Then, click the Next button.
    In this example, the directory that will store the transformation function definition file is HCSCTE_HelloBusinessProcess (HCSCTE project folder), and the transformation function definition file to be used is transfunc.xml.
    The Create XML File From page appears.

    [Figure]

  4. Select the Create XML file from an XML schema file radio button, and then click the Next button.
    The Select XML Schema File page appears.

    [Figure]

  5. Click the Import Files button.
    The Import dialog box appears.
  6. For From directory, specify the following directory:

    service-platform-installation-directory\CSCTE\resources\customfunc

    [Figure]

  7. Select the check boxes of customfunc and customfunction_XMLSchema.xsd.
  8. For Into folder, specify the folder to which the schema file will be imported.
    In this example, specify HCSCTE_HelloBusinessProcess.
  9. Click the Finish button.
    The Select XML Schema File page appears again.
  10. Click the Next button.
    The Select Root Element page appears.

    [Figure]

  11. From Root element drop-down list, select customFunc, and then click the Finish button.
    A model file of the transformation function definition file is generated.

    [Figure]

  12. Define necessary information for the model transformation function definition file.
    To add an element, select and right-click the parent item in the node column. Select the position at which to add the element.
    You can edit the information of the element in the content column.
    The following shows the information to be defined.

    [Figure]

    Table 5-12 Information to be defined in the transformation function definition file

    ElementInformation to be defined
    xmlversion="1.0" encoding="UTF-8"
    func:customFunc--
    xmlns:funchttp://www.hitachi.co.jp/soft/xml/cosminexus/cscdt/functions
    xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance
    xsi:schemaLocationhttp://www.hitachi.co.jp/soft/xml/cosminexus/cscdt/functions customfunction_XMLSchema.xsd
    func:jar--
    nameCustomFunctions.jar
    func:package--
    namesample.transform.CustomFunction
    func:class--
    nameCustomFunctions
    func:method--
    namechangeCase
    func:commentThe alphabetic characters included in the transform-from string are output to the transform-to string by changing all lowercase letters to uppercase letters, or vise versa, according to the specified transformation flag.
    func:arguments--
    func:argument--
    nametext
    func:commentTransform-from string
    func:argument--
    nameflag
    func:commentTransformation flag (upper | lower)
    func:method--
    namecurrentDateTime
    func:commentThe current date and time is output in yyyy/MM/dd HH:mm:ss.SSS format.
    Legend:
    --: Nothing needs to be defined.

  13. From the Eclipse menu, select File, and then Save.
    The transformation function definition file has now been created.

(2) Creating a Java program

In the CustomFunction sample program, you create a custom function that calls the following Java program.

Figure 5-4 Java program called by the custom function

[Figure]

The CustomFunction sample program provides a source file (CustomFunctions.java) that contains the Java code above. Import and package this source file to create a Java program to be called by the custom function.

The following is the procedure for creating a Java program.

  1. From the Eclipse menu, select Window, Open Perspective, and then Other.
    The Open Perspective dialog box opens.
  2. Select Java, and then click the OK button.
    The Java perspective opens.
  3. From the Eclipse menu, select File, and then Import.
    The Select page appears.
  4. In the tree view, select General, and then Existing Projects into Workspace.

    [Figure]

  5. Click the Next button.
    The Import Projects page appears.

    [Figure]

  6. Select the Select root directory radio button, and then click the Browse button.
    The dialog box for selecting a directory opens.
  7. Select the directory that contains the CustomFunction sample program, and then click the OK button. In this example, the directory to select is as follows: service-platform-installation-directory\CSCTE\Samples\CustomFunctions\CustomFunction\CustomFunctions
    The Import Projects page appears again.
  8. Select the Copy projects into workspace check box.

    [Figure]

  9. Click the Finish button.
    Import of the Java program is completed.
  10. In the Package Explorer view, under the CustomFunctions project, right-click build.xml. Then, select Run, and then Ant Build.
    The Java program is packaged, and then a JAR file (CustomFunctions.jar) is created in the following directory:
    eclipse-workspace-directory\CustomFunctions\build\lib
    If Ant Build does not appear, from the Eclipse menu, select Run, External Tools, and then Open External Tools Dialog. In the dialog box that appears, specify the Ant Build settings.
  11. Copy the created JAR file to the following location:

    service-platform-installation-directory\CSC\userlib\customfunc

    The Java program has now been created.