[cvs] expresso commit by rimovm: Added changes to

JCorporate Ltd jcorp at jcorp2.servlets.net
Fri Nov 12 09:17:25 PST 2004


Log Message:
-----------
Added changes to getDbName()/getDataContext() to make things consistent as with the rest of the framework.

Modified Files:
--------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
        Schema.java

Revision Data
-------------
Index: Schema.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/Schema.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/Schema.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/Schema.java -u -r1.48 -r1.49
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/Schema.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/Schema.java
@@ -508,6 +508,7 @@
      * database/context.
      *
      * @return the database context that this Schema object is associated with.
+     * @deprecated Use getDataContext() instead.  Since v.5.5
      */
     public synchronized String getDBName() {
         if (StringUtil.notNull(dbKey).equals("")) {
@@ -517,6 +518,27 @@
         return dbKey;
     } /* getDBName() */
 
+
+    /**
+     * Return the name of the context/database connection
+     * that this schema is being
+     * applied to. If none is set, then we are applying to the "default"
+     * database/context.
+     *
+     * @return the database context that this Schema object
+     *  is associated with.
+     * @since Expresso 5.6
+     */
+    public synchronized String getDataContext() {
+        if (StringUtil.notNull(dbKey).equals("")) {
+            return "default";
+        }
+
+        return dbKey;
+    } /* getDBName() */
+
+
+
     /**
      * @return an an instance of this schema instance.
      */
@@ -588,9 +610,9 @@
 
             if (oneDBObject != null) {
 
-                if ( getDBName() != null ) {
+                if ( getDataContext() != null ) {
                     try {
-                        oneDBObject.setDBName(getDBName());
+                        oneDBObject.setDBName(getDataContext());
                     } catch (DBException e) {
                         log.error("cannot set data context: ", e);
                     }
@@ -704,7 +726,7 @@
      */
     protected String getSetupDefault(String paramName, String defaultValue) {
         try {
-            ConfigContext myContext = ConfigManager.getContext(getDBName());
+            ConfigContext myContext = ConfigManager.getContext(getDataContext());
             ConfigSetupDefault oneValue = null;
 
             for (Enumeration sv = myContext.getSetupDefaults().elements();
@@ -786,12 +808,24 @@
      *
      * @param   newOther The name of the context or database to use
      * @throws  DBException If there's a problem switching to the database context.
+     * @deprecated Since Expresso 5.6  Use setDataContext(String) instead.
      */
     public synchronized void setDBName(String newOther)
             throws DBException {
-        dbKey = newOther;
+        setDataContext(newOther);
     } /* setDBName(String) */
 
+    /**
+     * Set the database name/context for this schema. If setDBName is not called,
+     * the "default" db name and context is used.
+     *
+     * @param   newOther The name of the context or database to use
+     * @throws  DBException If there's a problem switching to the database context.
+     */
+    public synchronized void setDataContext(String newOther)
+            throws DBException {
+        dbKey = newOther;
+    }
 
     /**
      * Go through each DBobject in the schema and call populateDefaultValues.<p>
@@ -901,7 +935,7 @@
         String country = null;
 
         try {
-            ConfigContext myContext = ConfigManager.getContext(getDBName());
+            ConfigContext myContext = ConfigManager.getContext(getDataContext());
             language = myContext.getLanguage();
             country = myContext.getCountry();
         } catch (com.jcorporate.expresso.core.misc.ConfigurationException ce) {


More information about the cvs mailing list