Create Jobs Programmatically

TIF jobs can be created from a Java class. This is done by using com.technia.tif.enovia.client.asynch.CreateNewJob.

Example:

package com.technia.tif.examples;

import com.technia.tif.enovia.client.asynch.CreateNewJob;

public class JobCreator {

    public void createJob() {
        // Input
        String objectId = "1.2.3.4";
        String jobCfg = "tvc:jobcfg/PartData.xml";
        String queue = "part-queue";

        Map<String, String[]> params = new HashMap<>();
        params.put("key", new String[] { "value "});

        // Set exclusive flag as true if you want to trigger a job 
        // *only if* there is no other *uncompleted* job triggered 
        // with the same combination of object id and job configuration.
        ExclusiveMode exclusiveMode = ExclusiveMode.NON_EXCLUSIVE;

        // Create TIF Job
        CreateNewJob action = new CreateNewJob(exclusiveMode);


        // Object id of the object in context for the job
        action.setObjectId(objectId);

        // Which job to execute
        action.setJobCfg(jobCfg);

        // Optional: Queue to post job on
        action.setQueueName(queue);

        // Optional: Parameters to pass to the job
        action.setParamMap(params);

        // Using request parameters
        // action.setParamMap(RequestUtils.getRequestMap(req));

        // Create the job object
        //
        // NOTE: *In case of exclusive job*, the returned jobObjectId 
        // might be null if the job was not triggered!!! See
        // comments regarding exclusive variable.
        String jobObjectId = action.run();
    }
}