Skip Headers
Oracle® Fusion Middleware Developer's Guide for Oracle SOA Suite
11g Release 1 (11.1.1.5.0)

Part Number E10224-09
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

I Interfaces Implemented By Rules Dictionary Editor Task Flow

Oracle Business Rules Dictionary Editor Task Flow implements two interfaces when creating an ADF-based Web application. The interfaces are defined in the soaComposerTemplates.jar file.

This appendix includes the following sections:

I.1 The MetadataDetails Interface

The MetadataDetails interface is a part of the oracle.integration.console.metadata.model.share package and is defined in the soaComposerTemplates.jar file.

The MetadataDetails interface defines three methods, as shown in Example I-1:

Example I-1 MetadataDetails Interface

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;
}

I.1.1 The getDocument Method

This method is used to retrieve the rules file in a string format. For doing this action, you must connect to the Oracle Metadata Repository (MDS) or a file system, and return the rules file in a string format.

Example I-2 shows how to get the file from a local file system:

Example I-2 getDocument Method

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();
    }

I.1.2 The getRelatedDocument Method

This method is required when you work with linked dictionaries. You must connect to MDS, find the related dictionary file, and then return it in a string format. Example I-3 shows how to find the path of the linked dictionaries that are stored within the ../oracle/rules directory in a local file system:

Example I-3 getRelatedDocument Method

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 "";
    }

I.1.3 The setDocument Method

This method is used to store the rules file. It returns a String doc value, which is the name of the updated dictionary based on user edits performed by using Rules Dictionary Editor Task Flow. You must store the rules file in MDS or a file system. Example I-4 shows how to save the document in the local file system:

Example I-4 setDocument Method

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.2 The NLSPreferences Interface

The NLSPrefrences interface defines four methods as shown in Example I-5:

Example I-5 NLSPreferences Interface

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();
}

Example I-6 is a sample implementation of the NLSPreferences interface:

Example I-6 Sample Implementation of the NLSPreferences Interface

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;
        }
    }