TIF ENOVIA/3DExperience Connector - Custom Job

You may in some cases need to create a job having customized logic. This is done by defining the class implementing the custom job logic inside the Executor tag as shown below.

<Job>
    <Executor>com.acme.integration.executor.MyJobExecutor</Executor>
</Job>

The class must implement the interface com.technia.tif.enovia.job.JobExecutor.

This interface is defined like below.

package com.technia.tif.enovia.job;

import com.technia.tif.core.ConfigurationException;
import com.technia.tif.core.ExtractionException;
import com.technia.tif.core.ValidationException;
import com.technia.tif.core.annotation.API;

/**
 *
 * @author Technia
 * @since 31 okt 2012
 */
@API
public interface JobExecutor {

    /**
     * Executes the job using the provided data as input for the execution
     *
     * @param job The job to be executed
     * @throws ConfigurationException May be thrown to indicate error in the
     *         configuration
     * @throws ExtractionException May be thrown to indicate error while
     *         extracting data
     * @throws ValidationException May be thrown to indicate error when
     *         validating the data being used/sent.
     */
    void perform(EnoviaJob job) throws ExtractionException,
                               ConfigurationException,
                               ValidationException;
}

Custom jobs support job events for handling errors etc. Read more in the [Job Events] chapter.

Transaction Type

By default, TIF does not start a transaction inside the ENOVIA/3DEXPERIENCE database for the custom executor.

To change it, you can do so like the example below illustrates.

<Job>
    <Executor className="com.acme.MyExecutor" txType="read" />
    ...
</Job>

The below table describes values that are accepted for the attribute txType.

Value Description

none

Does not start transaction.

read

Starts read transaction.

update

Starts update transaction.

Store Payload

It is possible to store outbound payload that is visible in Admin UI. Use com.technia.tif.enovia.job.log.Logger.

For example:

import com.technia.tif.enovia.job.EnoviaJob;
import com.technia.tif.enovia.job.JobExecutor;
import com.technia.tif.enovia.job.log.Logger;
import com.technia.tif.enovia.payload.PayloadUtils;

public class MyJobExecutor implements JobExecutor {

    @Override
    public void perform(EnoviaJob job) {
        Logger.storeOutboundPayload(job, new PayloadDataBuffer().append("Hello World!"));
    }

}

Access Input Payload

Input payload provided by parent job can be accessed using com.technia.tif.enovia.payload.PayloadUtils utility class.

Example code:

package com.acme.tif.executor;

import com.technia.tif.core.ExtractionException;
import com.technia.tif.enovia.job.EnoviaJob;
import com.technia.tif.enovia.job.JobExecutor;
import com.technia.tif.enovia.payload.PayloadData;
import com.technia.tif.enovia.payload.PayloadUtils;

import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

public class MyJobExecutor implements JobExecutor {

    @Override
    public void perform(EnoviaJob job) throws ExtractionException {
        PayloadData data = PayloadUtils.getInputPayload(job);
        try (InputStream in = data.getInputStream()) {
            // TODO: Do something with the input stream, e.g:
            String string = IOUtils.toString(in, data.getEncoding());
        } catch (IOException e) {
            throw new ExtractionException(e);
        }
    }

}