[cvs] expresso commit by mtraum: DBTool now has the ability to add a schema

JCorporate Ltd jcorp at jcorporate.com
Wed Apr 27 22:56:53 UTC 2005


Log Message:
-----------
DBTool now has the ability to add a schema (Mark Kikken)

Modified Files:
--------------
    expresso/expresso-web/expresso/doc:
        ChangeLog.xml
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/utility:
        DBTool.java

Revision Data
-------------
Index: ChangeLog.xml
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/expresso/doc/ChangeLog.xml,v
retrieving revision 1.303
retrieving revision 1.304
diff -Lexpresso-web/expresso/doc/ChangeLog.xml -Lexpresso-web/expresso/doc/ChangeLog.xml -u -r1.303 -r1.304
--- expresso-web/expresso/doc/ChangeLog.xml
+++ expresso-web/expresso/doc/ChangeLog.xml
@@ -6,6 +6,13 @@
 	<project name="Expresso">
 		<version name="5.6.1" releaseDate="Not released yet">
 			<comment>Continued Updates</comment>
+			<new-feature title="DBTool now has the ability to add a schema">
+				<explanation>DBTool is a command line tool to create database tables and populate values based on a schema. Prior to this addition, it
+				would only do this for ExpressoSchema unless a schema record was manually entered into the database. Now, DBTool is a one stop solution
+				for generation of your applications database from the command line.
+                </explanation>
+				<contributor>Mark Kikken</contributor>
+			</new-feature>
 			<bug-fix title="Internationalization (i18n) fixes for DBMaint">
 				<explanation>Many strings in DBMaint have been i18n'd</explanation>
 				<contributor>Nahuel Espindola, Francesco Galli</contributor>
Index: DBTool.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/utility/DBTool.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/utility/DBTool.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/utility/DBTool.java -u -r1.59 -r1.60
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/utility/DBTool.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/utility/DBTool.java
@@ -1542,6 +1542,7 @@
                     SuperUser.SUPER_USER);
 
             String setup = (String) commandArgs.get("setup");
+            String schemaClass = (String) commandArgs.get("register");
             String poolTest = (String) commandArgs.get("pooltest");
             String testMode = (String) commandArgs.get("test");
             String generate = (String) commandArgs.get("generate");
@@ -1565,6 +1566,13 @@
                 ConfigManager.destroy();
                 return;
             }
+            if (schemaClass != null) {
+                registerSchema(schemaClass);
+
+                System.out.println("Exiting....");
+                ConfigManager.destroy();
+                return;
+            }
             if (config != null) {
                 chooseConfig(dbName);
 
@@ -1959,6 +1967,7 @@
         System.out.println(" ");
         System.out.println("Optional arguments:");
         System.out.println("\tsetup=yes: Initial system setup");
+        System.out.println("\tregister=schemaClassName: Register a schema");
         System.out.println("\tconfig=yes: Enter/edit Setup/configuration " +
                 "values");
         System.out.println("\ttest=yes: Invoke test mode");
@@ -2706,6 +2715,34 @@
             RequestRegistry.revertUser();
         }
     } /* setupSecurity(PrintWriter, Vector, String) */
+    
+	/**
+	 * Registers a schema with expresso. Basicly just adds a record to the
+	 * SchemaList table. You will have to call setup again to generate all
+	 * tables & permissions.
+	 * 
+	 * @param schemaClass
+	 *            the full classname of the schema to register
+	 * @throws ClassNotFoundException
+	 * @throws IllegalAccessException
+	 * @throws InstantiationException
+	 * @throws DBException
+	 */
+	protected static void registerSchema(String schemaClass) throws InstantiationException, IllegalAccessException, ClassNotFoundException, DBException {
+		// Just test if the class exists:
+		Schema schema = (Schema) Class.forName(schemaClass).newInstance();
+
+		SchemaList dbo;
+		dbo = new SchemaList();
+
+		dbo.setField(SchemaList.FLD_SCHEMA_CLASS, schemaClass);
+		dbo.setField(SchemaList.FLD_DESCRIP, schema.getDefaultDescription());
+		dbo.setField(SchemaList.FLD_COMPONENT_CODE, schema
+				.getDefaultComponentCode());
+		dbo.addIfNeeded();
+		System.out.println("Registered schema: " + schema.getDefaultDescription());
+
+	}
 
 
 } /* DBTool */


More information about the cvs mailing list