プライマリ・コンテンツに移動
Oracle® Fusion Middleware Oracle SOA SuiteでのSOAアプリケーションの開発
12c (12.1.3)
E53007-05
目次へ移動
目次

前
次

F ルール・ディクショナリ・エディタのタスク・フローによって実装されるインタフェース

この付録では、ADFベースのWebアプリケーションを作成する際にMetadataDetailsおよびNLSPrefrencesのインタフェースを実装する、Oracle Business Rulesディクショナリ・エディタのタスク・フローについて説明します。これらのインタフェースはsoaComposerTemplates.jarファイルで定義されます。

この付録の内容は次のとおりです。

F.1 MetadataDetailsインタフェース

MetadataDetailsインタフェースはoracle.integration.console.metadata.model.shareパッケージの一部であり、soaComposerTemplates.jarファイルで定義されます。

次に示すように、MetadataDetailsインタフェースは3つのメソッドを定義します。

public interface MetadataDetails {
    /**
     * Retrieve the details of the metadata document
     * @return document in string format.
     */
    String getDocument();

    /**
     * Get related document.
     */
    String getRelatedDocument(final RelatedMetadataPath relatedPath);

    /**
     * Update the metadata document.
     * @param doc represents the updated document.
     */
    void setDocument(String doc) throws Exception;
}

F.1.1 getDocumentメソッド

このメソッドは、ルール・ファイルを文字列書式で取得するために使用します。このアクションを実行するには、Oracle Metadata Repository (MDS)またはファイル・システムに接続して、ルール・ファイルを文字列書式で返す必要があります。

次のコード・サンプルに、ローカル・ファイル・システムからファイルを取得する方法を示します。

private static final String RULES_FILE1 =
"file:///C:/scratch/<username>/system/mywork/linkedD/AutoAppProj/oracle/rules/credit/CreditRatingRules.rules";

   public String getDocument() {
        URL url = null;
        try {
            url = new URL(RULES_FILE1);
            return readFile(url);
        } catch (IOException e) {
            System.err.println(e);
        }
        return "";
    }

    private String readFile(URL dictURL) {
        InputStream is;
        try {
            is = dictURL.openStream();
        } catch (IOException e) {
            System.err.println(e);
            return "";
        }
        BufferedReader reader;
        try {
            reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            System.err.println(e);
            return "";
        }
        String line = null;
        StringBuilder stringBuilder = new StringBuilder();
        String ls = System.getProperty("line.separator");
        try {
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
                stringBuilder.append(ls);
            }
        } catch (IOException e) {
            System.err.println(e);
            return "";
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                System.err.println(e);
            }
        }
        return stringBuilder.toString();
    }

F.1.2 getRelatedDocumentメソッド

リンク・ディクショナリを使用する場合、このメソッドは必須です。MDSに接続して関連するディクショナリ・ファイルを検出し、そのファイルを文字列書式で返す必要があります。次のコード・サンプルに、ローカル・ファイル・システムの../oracle/rulesディレクトリ内に格納されているリンク・ディクショナリへのパスを検出する方法を示します。

public String getRelatedDocument(RelatedMetadataPath relatedMetadataPath) {
        String currPath = RULES_FILE1.substring(0, RULES_FILE1.indexOf("oracle/rules"));
        String relatedDoc = currPath + "oracle/rules/" + relatedMetadataPath.getValue();
       
        URL url = null;
        try {
            url = new URL(relatedDoc);
            return readFile(url);
        } catch (IOException e) {
            System.err.println(e);
        }
        return "";
    }

F.1.3 setDocumentメソッド

このメソッドは、ルール・ファイルを格納するために使用します。このメソッドは、文字列のdoc値を返します。この値は、ルール・ディクショナリ・エディタのタスク・フローを使用して実行されたユーザーの編集を基に更新されたディクショナリの名前です。ルール・ファイルはMDSまたはファイル・システムに格納する必要があります。次のコード・サンプルに、ローカル・ファイル・システムにドキュメントを保存する方法を示します。

public void setDocument(String string) {
        URL url = null;

        try {
            url = new URL(RULES_FILE1);
        } catch (MalformedURLException e) {
            System.err.println(e);
            return;
        }
        Writer writer = null;
        try {
            //os = new FileWriter(url.getPath());
            writer =
                    new OutputStreamWriter(new FileOutputStream(url.getPath()),
                    "UTF-8");
        } catch (FileNotFoundException e) {
            System.err.println(e);
            return;
        } catch (IOException e) {
            System.err.println(e);
            return;
        }
        try {
            writer.write(string);
        } catch (IOException e) {
            System.err.println(e);
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException ioe) {
                    System.err.println(ioe);
                }
            }
        }
    }

F.2 NLSPreferencesインタフェース

次に示すように、NLSPrefrencesインタフェースは4つのメソッドを定義します。

public interface NLSPreferences
{
   /**
    * Returns the locale to be used.
    **/
    Locale getLocale();
 
    /**
     * Return the timezone to be used.
     **/
    TimeZone getTimeZone();
 
    /**
     * Return the dateformat to be used.
     */
    String getDateFormat();
 
    /**
     * Return the time format to be used.
     */
    String getTimeFormat();
 
    /**
     * Returns the grouping seperator.
     */
    char getGroupingSeparator();
 
    /**
     * Returns the grouping seperator.
     */
   char getDecimalSeparator();
}

次のコード・サンプルに、NLSPreferencesインタフェースのサンプル実装を示します。

public class MyNLSPreferences implements NLSPreferences {
        private static final String DATE_STYLE = "yyyy-MM-dd";
        private static final String TIME_STYLE = "HH-mm-ss";
	private static final char G_SEP = ',';
	private static final char D_SEP = '.';
 
        public Locale getLocale() {
            return Locale.FRENCH;
        }
 
        public TimeZone getTimeZone() {
            return TimeZone.getTimeZone("America/Los_Angeles");
        }
 
        public String getDateFormat() {
            return DATE_STYLE;
        }
 
        public String getTimeFormat() {
            return TIME_STYLE;
        }
        
        public char getGroupingSeparator() {
	    return G_SEP;
	}
 
	public char getDecimalSeparator() {
	    return D_SEP;
        }
    }