Skip to content

Tutorial Talend Component Kit 4: Implementation of the Dataset and store of a Jira Input

Simon Neidig edited this page Dec 11, 2019 · 1 revision

In part three of the "Tutorial -- Talend Component Kit " the structure of an input component of the "Talend Component Kit " was considered along with its responsibilities. In this tutorial the datastore, the dataset and the corresponding configuration will be implemented to ensure the provision of the user input.

After the fourth part you can:

  • Implement datastore
  • Implement dataset
  • Implement configuration

1. Datastore

As learned in the previous part, the datastore contains the data required for the connection to the backend. However, not only the data is provided, but also the corresponding part of the user interface is implemented.

1.1 Layout creation

When the implementation of the datastore is started, it is recommended to first determine the relevant data and then to transfer them into the layout of the user interface. In the case of the Jira input component we need the URL of the Jira installation, the user name and the password of the user.

The layout is declared in the class "src→main→java→de.odisys.talend.components→datastore→CustomDatastore " above the start of the class. Annotations are used here. Possible layouts are:

  • @GridLayout
  • @AutoLayout
  • @VerticalLayout
  • @HorizontalLayout

In the following tutorial we will use the GridLayout, as this provides the required functionality. Here it is possible to create a new line in the layout with each definition "@GridLayout.Row(), ". All attributes that are in the list are then listed in a row one after the other.

@DataStore("CustomDatastore")
@GridLayout({
        @GridLayout.Row({"baseurl"}),
        @GridLayout.Row({"username", "password"})
})

Figure 1 shows the final layout in "Talend Open Studio for Data Integration ".

1.2 Processing the input via the layout

After the layout has been defined, all attributes used in the layout must be implemented as attributes with the annotation "@Option ". For the password, an additional annotation "@Credential " allows the input to be made unrecognizable.

@Option
@Credential
@Documentation("")
private String password;

If all attributes are declared, a complete and an empty constructor, and the getter/setter methods have been added, the following CustomDatastore class results:

@DataStore("CustomDatastore")
@GridLayout({
        @GridLayout.Row({"baseurl"}),
        @GridLayout.Row({"username", "password"})
})
@Documentation("")
public class CustomDatastore implements Serializable {
    @Option
    @Documentation("")
    private String baseurl;

    @Option
    @Documentation("")
    private String username;

    @Option
    @Credential
    @Documentation("")
    private String password;

    public CustomDatastore(String url, String username, String password) {
        this.baseurl = url;
        this.username = username;
        this.password = password;
    }

    public CustomDatastore(){}

    public String getUrl() { return baseurl; }
    public String getUsername() { return username; }
    public String getPassword() { return password; }
    public void setBaseurl(String baseurl) { this.baseurl = baseurl; }
    public void setUsername(String username) { this.username = username; }
    public void setPassword(String password) { this.password = password; }
}

1.3 Declare the attributes in the config file

In the last step the display name must be declared for all attributes, in our case the URL, the username and the password in the config-file belonging to the datastore. The "._displayName " is the name that is displayed to the user as an attribute name in "Talend Open Studio for Data Integration ".

It is also possible to use "._placeholder " to declare the placeholder, i.e. the value displayed in the input field if the user has not yet made an entry.

For our Jira component, the datastore config file located at "src→main→ressources→de.odisys.talend.components→datastore→Messages.properties " looks like this:

CustomDatastore.password._displayName = Password
CustomDatastore.username._displayName = Username
CustomDatastore.baseurl._displayName = Base URL

2. Dataset

As learned in part three, the dataset contains the datastore and data required for processing the data. The first functionality of our Jira component is to output information about a given Jira board. Therefore, processing the data requires the ID of the board for which the information is to be returned.

The implementation of the dataset is described below. Since the procedure is equivalent to that of the datastore, the description is kept short. If you are unclear, please refer to section 1.

2.1 Layout creation

Our layout should therefore contain the datastore and a project ID and looks like this:

@DataSet("CustomDataset")
@GridLayout({
    @GridLayout.Row({ "datastore" }),
    @GridLayout.Row({"projectId"})
})

This results in the following layout for user input in "Talend Open Studio for DataIntegration ":

Abb. 1: Finales Layout in Talend Open Studio for Data Integration

2.2 Processing the input via the layout

Together with the declaration of the attributes the Dataset class shown below results. This class is implemented under "src→main→java→de.odisys.talend.components→dataset→CustomDataset ". Nice to see in the code that the datastore is a part of the dataset, as described in the previous part of the tutorial.

@DataSet("CustomDataset")
@GridLayout({
    @GridLayout.Row({ "datastore" }),
    @GridLayout.Row({"projectId"})
})
@Documentation("")
public class CustomDataset implements Serializable {
    @Option
    @Documentation("")
    private CustomDatastore datastore;

    @Option
    @TextArea
    @Documentation("")
    private String projectId;

    public CustomDataset(CustomDatastore datastore, String projectId) {
        this.datastore = datastore;
        this.projectId = projectId;
    }

    public CustomDataset(){}

    public CustomDatastore getDatastore() { return datastore; }
    public String getProjectId() { return projectId; }
    public void setDatastore(CustomDatastore datastore) { this.datastore = datastore; }
    public void setProjectId(String projectId) { this.projectId = projectId; }
}

2.3 Declare the attributes in the config file

As already happened for the datastore, we must define at least the "._displayName " for all attributes of the dataset, ideally also the "._placeholder " in the config file.

The config file for the dataset can be found at "src→main→ressources→de.odisys.talend.components→dataset→Messages.properties "

CustomDataset.projectId._displayName=Project Id
CustomDataset.datastore._displayName=Datastore

3. Configuration

The configuration class is again a summary of the dataset with other configuration settings that will be passed to the source and partition mapper later. Since we don't have any great configurations in our case, you could omit this class and pass the dataset directly to the source and partition mapper.

Since the class belongs to the conventions of the "Talend Component Kit " we will implement it in this tutorial anyway.

It makes sense to use it if you implement several input components and want to use a dataset in several components.

3.1 Implementation

The layout of the class contains only the dataset. This is also the only attribute of the class. The final implementation of the class, located at "src→main→java→de.odisys.talend.components→source→OdiSysInputMapperConfiguration ", looks like this:

@GridLayout({
        @GridLayout.Row({"dataset"})
})
@Documentation("")
public class OdiSysInputMapperConfiguration implements Serializable {
    @Option
    @Documentation("")
    private CustomDataset dataset;

    public CustomDataset getDataset() {
        return dataset;
    }

    public void setDataset(CustomDataset dataset) { this.dataset = dataset; }
}

3.2 Declare in config file

The attributes of the configuration class must be declared in the config file of the source, as already done for datastore and dataset. In our case it only contains the attribute Dataset. The configuration file is located at "src→main→ressources→de.odisys.talend.components→source→Messages.properties "

OdiSysInputMapperConfiguration.dataset._displayName=dataset

4. Further tutorials

In the next part of the tutorial you will learn the Implementation of the Source and the Partition Mapper of the Jira input component:

Here you can find the previous tutorials: