Oracle Business Rulesディクショナリ・エディタのタスク・フローは、ADFベースのWebアプリケーションを作成する際に2つのインタフェースを実装します。これらのインタフェースはsoaComposerTemplates.jar
ファイルで定義されます。
項目は次のとおりです。
MetadataDetails
インタフェースはoracle.integration.console.metadata.model.share
パッケージの一部であり、soaComposerTemplates.jar
ファイルで定義されます。
例I-1に示すように、MetadataDetails
インタフェースは3つのメソッドを定義します。
例I-1 MetadataDetailsインタフェース
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; }
このメソッドは、ルール・ファイルを文字列書式で取得するために使用します。このアクションを実行するには、Oracle Metadata Repository(MDS)またはファイル・システムに接続して、ルール・ファイルを文字列書式で返す必要があります。
例I-2に、ローカル・ファイル・システムからファイルを取得する方法を示します。
例I-2 getDocumentメソッド
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();
}
リンク・ディクショナリを使用する場合、このメソッドは必須です。MDSに接続して関連するディクショナリ・ファイルを検出し、そのファイルを文字列書式で返す必要があります。例I-3に、ローカル・ファイル・システムの../oracle/rules
ディレクトリ内に格納されているリンク・ディクショナリへのパスを検出する方法を示します。
例I-3 getRelatedDocumentメソッド
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 ""; }
このメソッドは、ルール・ファイルを格納するために使用します。このメソッドは、文字列のdoc
値を返します。この値は、ルール・ディクショナリ・エディタのタスク・フローを使用して実行されたユーザーの編集を基に更新されたディクショナリの名前です。ルール・ファイルはMDSまたはファイル・システムに格納する必要があります。例I-4に、ローカル・ファイル・システムにドキュメントを保存する方法を示します。
例I-4 setDocumentメソッド
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); } } } }
例I-5に示すように、NLSPrefrences
インタフェースは4つのメソッドを定義します。
例I-5 NLSPreferencesインタフェース
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(); }
例I-6は、NLSPreferences
インタフェースのサンプル実装です。
例I-6 NLSPreferencesインタフェースのサンプル実装
public class MyNLSPreferences implements NLSPreferences { private static final String DATE_STYLE = "yyyy-MM-dd"; private static final String TIME_STYLE = "HH-mm-ss"; 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; } }