Skip to content

Creating your first Job

Starting point for creating all types of integration jobs and services aside from creating a SOAP web service. Refer to Creating a SOAP web service for details on how to do this.

Install Talend using the instructions in Getting Started, then follow the steps below to create your very first Integration with Formbird.

Creating a Job

To create a new Job: Navigate to the Repository View, right-click "Job Designs", and select "Create job". Once created, the new Job will open in the main View.

Items used

Type Name
Routines FormbirdRoutine
Components tJava

Setup Job

Create a new Job, and name it "CreateAsset". This Job inserts an Asset Document into Formbird.

  1. Setup your Job's Context Variables

  2. Select the Jobs Context tab, and create the Context Variables as defined in Contexts and Configuration Files section of this documentation. Specify your actual Formbird URLs and credentials during setup in order to run the Job within Talend Studio.

  3. Add a tJava component to the Job, and copy the following code to it.

  4. Under the component's Advanced settings panel, add:

    ```java import org.apache.log4j.Logger;

    import com.fieldtec.webclient.config.WebclientConfig; import com.fieldtec.webclient.model.Document; import com.fieldtec.webclient.service.FieldtecService; import com.fieldtec.webclient.service.impl.FieldtecServiceImpl; import com.fieldtec.webclient.util.UtilJson; ```

  5. Under the component's Basic settings panel, add:

    ```java Logger logger = Logger.getLogger(context.loggerName); String method = jobName + "." + currentComponent;

    FieldtecService ftService = null;

    try { // Initialise ftService (always synchronize context and then setup webclientConfig) context.synchronizeContext(); FormbirdRoutine.setupWebClientConfig(context); ftService = new FieldtecServiceImpl();

    String assetTemplateId = "5ba9bbee5b116026f1b23dad";
    
    com.fieldtec.webclient.model.Document doc = new Document();
    doc.setValue("assetId","123");
    doc.setValue("name","asset name");
    doc.setValue("description","asset description");
    doc.setValue(FormbirdRoutine.KEY_SYSTEMHEADER_TEMPLATE_ID,assetTemplateId);
    
    // Insert document
    Document responseDocument = ftService.insert(doc);
    if (responseDocument != null) {
        // Get documentId to return
        logger.info("Inserted: " + responseDocument.getValue(FormbirdRoutine.KEY_DOCUMENT_ID));
        logger.info(UtilJson.prettyPrint(responseDocument));
    } else {
        // Handle error
        logger.error("Error inserting document");
    }
    

    } finally { if (ftService != null) { ftService.close(); } } ```

  6. Run the new Job

  7. Select the Jobs Run tab, and select Run. Make sure your Formbird URLs and credentials are correct and point to a running Formbird environment.

Congratulations! You have integrated with Formbird!

You should see the following output logged to the Run tab console:

Starting job CreateAsset at 17:46 12/12/2018.

[statistics] connecting to socket on port 3467
[statistics] connected
[INFO ]: fieldtec - setupWebClientConfig setup webClientConfig
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.authenticateHttpClient opening httpClient
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.authenticateHttpClient httpClient opened
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.authenticateHttpClient time taken: 1379ms
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.insert.1.request.document: 
{
  "assetId": "123",
  "name": "asset name",
  "description": "asset description",
  "systemHeader": {
    "templateId": "5ba9bbee5b116026f1b23dad"
  }
}
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.insert.1.request.url (POST): http://localhost:3000/api/document
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.insert HttpClient.execute time taken: 39ms
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.insert.2.response HTTP statusCode: 200
[DEBUG]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.convertToObject.1
[DEBUG]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.convertFromJsonObject.1
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.convertFromJsonObject time taken: 1ms
[DEBUG]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.insert.5
[INFO ]: fieldtec - Inserted: aeb1ab50-fdd9-11e8-adb9-cd0289110043
[INFO ]: fieldtec - {
  "documentId": "aeb1ab50-fdd9-11e8-adb9-cd0289110043",
  "systemHeader": {
    "serverUpdatedDate": "2018-12-12T06:46:41.561Z",
    "versionId": "aeb4b890-fdd9-11e8-adb9-cd0289110043",
    "summaryName": "",
    "createdDate": "2018-12-12T06:46:41.561Z",
    "keyIds": [],
    "serverCreatedDate": "2018-12-12T06:46:41.561Z",
    "excludeGeneralSearch": false,
    "createdBy": "58252e2235210743e370c6c5",
    "systemType": "document",
    "templateId": "5ba9bbee5b116026f1b23dad",
    "summaryDescription": "",
    "currentVersion": true
  },
  "assetId": "123",
  "name": "asset name",
  "description": "asset description",
  "_id": "5c10aed18be61c1d94a943cc"
}
[INFO ]: fieldtec - class com.fieldtec.webclient.service.impl.FieldtecServiceImpl.close httpClient closed
[statistics] disconnected
Job CreateAsset ended at 17:46 12/12/2018. [exit code=0]