ユーザー定義インジケーターのJavaアーカイブを作成 - Cloud - 7.3

Talend Studioユーザーガイド

Version
Cloud
7.3
Language
日本語
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
ジョブデザインと開発
Last publication date
2024-02-13
対象製品...

Big Data Platform

Cloud API Services Platform

Cloud Big Data Platform

Cloud Data Fabric

Cloud Data Management Platform

Data Fabric

Data Management Platform

Data Services Platform

MDM Platform

Real-Time Big Data Platform

ユーザー定義インジケーターにJavaアーカイブを作成する前に、ワークスペースプラグインのコンパイルとテストの対象となるターゲットプラットフォームをEclipseで定義する必要があります。

始める前に

Profilingパースペクティブを選択済みであること。

手順

  1. ターゲットプラットフォームを定義します。
    1. Eclipseで、[Preferences] (環境設定)を選択して[Preferences] (環境設定)ウィンドウを表示します。
    2. [Plug-in Development] (プラグイン開発)を展開して[Target Platform] (ターゲットプラットフォーム)を選択し、[Add...] (追加...)をクリックしてターゲット定義を作成するためのビューを開きます。
    3. [Nothing: Start with an empty target definition] (なし: 空のターゲット定義で始める)オプションを選択し、[Next] (次へ)をクリックします。
    4. [Name] (名前)フィールドに新しいターゲット定義の名前を入力し、[Next] (次へ)をクリックします。
    5. [Add Content] (コンテンツを追加)リストから[Installation] (インストール)を選択し、[Next] (次へ)をクリックします。
    6. [Browse...] (参照...)ボタンを使ってインストールディレクトリーのパスを設定し、[Next] (次へ)をクリックします。

      場所のリストに新しいターゲット定義が表示されます。

    7. [Finish] (終了)をクリックしてダイアログボックスを閉じます。
  2. ユーザー定義インジケーターのJavaアーカイブを作成
    1. Eclipseでは、project from GITをご覧ください。

      このJavaプロジェクトには、インジケーターエディターの[Indicator Category] (インジケーターカテゴリー)ビューにリスト表示されたインジケーターカテゴリーに対応する4つのJavaクラスがあります。

      どのJavaクラスもUserDefIndicatorImplインジケーターを拡張します。下の図は、MyAvgLength Javaクラスを使った例を示したものです。

      package test.udi;
      
      import org.talend.dataquality.indicators.sql.impl.UserDefIndicatorImpl;
      
      /**
       * @author mzhao
       * 
       * A very simple example of a java implementation of a user defined indicator. This indicator returns a user defined
       * real value. It implements the minimum number of required methods.
       */
      public class MyAvgLength extends UserDefIndicatorImpl {
      
          private double length = 0;
      
          @Override
          public boolean reset() {
              super.reset();
              length = 0;
              return true;
          }
      
          @Override
          public boolean handle(Object data) {
              super.handle(data);
              // an indicator which computes the average text length on data which are more than 2 characters (this means that
              // text values with less than 2 characters are not taken into account).
              int dataLength = (data != null) ? data.toString().length() : 0;
              if (dataLength > 2) {
                  length += dataLength;
              }
              return true;
          }
      
          /*
           * (non-Javadoc)
           * 
           * @see org.talend.dataquality.indicators.impl.IndicatorImpl#finalizeComputation()
           */
          @Override
          public boolean finalizeComputation() {
              value = String.valueOf(this.length / (this.getCount() - this.getNullCount()));
              return super.finalizeComputation();
          }
      
      }
    2. 必要に応じて、各@Overrideに続くメソッドのコードを編集してください。
    3. オプション: 次のメソッドをコードで使い、インジケーターのパラメーターを取得します。
      メソッド 説明
      ndicatorParameters IndicatorParametersオブジェクトを返します
      omain ドメインオブジェクトを返します
      JavaUDIIndicatorParameter パラメーターを定義するキー/値の各ペアを保存するJavaUDIIndicatorParameterのリストを返します。
    4. 変更を保存します。
    5. Eclipseを使用してこの新しいJavaアーカイブをエクスポートします。

タスクの結果

以上で、Profilingパースペクティブで作成するどのJavaインジケーターにもJavaアーカイブを添付できるようになります。