]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2496: Trivial cleanup in early Init Handler code and comments, including remov...
authorAron Roberts <aron@socrates.berkeley.edu>
Fri, 7 Jan 2011 01:13:02 +0000 (01:13 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Fri, 7 Jan 2011 01:13:02 +0000 (01:13 +0000)
services/common/src/main/java/org/collectionspace/services/common/init/AddIndices.java
services/common/src/main/java/org/collectionspace/services/common/init/IInitHandler.java
services/common/src/main/java/org/collectionspace/services/common/init/InitHandler.java
services/common/src/main/java/org/collectionspace/services/common/init/MakeLargeTextFields.java

index d48ad84bdda71efbfb67315a069882c01cb1d1ce..018e7082b717f67f9f291854d52a8f80445f4be0 100755 (executable)
@@ -35,27 +35,27 @@ import java.util.List;
 public class AddIndices extends InitHandler implements IInitHandler {\r
 \r
     final Logger logger = LoggerFactory.getLogger(AddIndices.class);\r
+\r
     public void onRepositoryInitialized(ServiceBindingType sbt, List<Field> fields, List<Property> properties) throws Exception {\r
-          //todo: all post-init tasks for services, or delegate to services that override.\r
-          System.out.println("\r\n\r\n~~~~~~~~~~~~~ in AddIndices.onRepositoryInitialized with ServiceBindingType: "+sbt);\r
+        //todo: all post-init tasks for services, or delegate to services that override.\r
 \r
         // call something like this:\r
-        ResultSet rs = null;\r
-        try {\r
-            String addIndex_SQL = "UPDATE TABLE ADD KEY `tablename`.`id`...";\r
-            rs = executeQuery(addIndex_SQL);\r
-            if (rs != null){\r
-                // .....\r
+        int rows = 0;\r
+        for (Field field : fields) {\r
+            try {\r
+                // MySQL\r
+                String addIndex_SQL = "CREATE INDEX " + field.getCol() + "_idx ON " + field.getTable() + " (" + field.getCol() + ")";\r
+                rows = executeUpdate(addIndex_SQL);\r
+            } catch (Exception e) {\r
+                throw e;\r
             }\r
-        } catch (Exception e){\r
-            throw e;\r
-        } finally {\r
-            closeResultSet(rs);\r
-        }\r
-        //call something like this: services.common.storage.DBUtils.addIndex(String tablename, String fields[]);\r
-        //for every field that has an authRef, do ...\r
-        //    --> Connection conn = getConnection();\r
-        //see parameter that you need for adding indices to SQL.\r
 \r
+            //call something like this: services.common.storage.DBUtils.addIndex(String tablename, String fields[]);\r
+            //for every field that has an authRef, do ...\r
+            //    --> Connection conn = getConnection();\r
+            //see parameter that you need for adding indices to SQL.\r
+\r
+        }\r
     }\r
+\r
 }\r
index b4ee4ef39456616a3561054c28ffdcd155154288..7a7483e25833aec010d0a2f354e5718400c9a430 100755 (executable)
@@ -1,6 +1,5 @@
 package org.collectionspace.services.common.init;\r
 \r
-import org.collectionspace.services.common.context.ServiceContext;\r
 import org.collectionspace.services.common.service.ServiceBindingType;\r
 import org.collectionspace.services.common.service.InitHandler.Params.Field;\r
 import org.collectionspace.services.common.service.InitHandler.Params.Property;\r
@@ -12,6 +11,7 @@ import java.util.List;
  * $LastChangedRevision:  $\r
  * $LastChangedDate:  $\r
  */\r
+\r
 public interface IInitHandler {\r
-   public void onRepositoryInitialized(ServiceBindingType sbt, List<Field> fields, List<Property> property) throws Exception;\r
+    public void onRepositoryInitialized(ServiceBindingType sbt, List<Field> fields, List<Property> property) throws Exception;\r
 }\r
index ce2fa4ff94b923122f6d40854eff4be20a387aba..fc0f40880a3c73aacdb3a479b30252f01c1a85c2 100755 (executable)
@@ -17,7 +17,6 @@
  */\r
 package org.collectionspace.services.common.init;\r
 \r
-import org.collectionspace.services.common.ServiceMain;\r
 import org.collectionspace.services.common.storage.JDBCTools;\r
 import org.collectionspace.services.common.service.ServiceBindingType;\r
 import org.collectionspace.services.common.service.InitHandler.Params.Field;\r
@@ -33,14 +32,26 @@ import java.util.List;
  *  some action on the event onRepositoryInitialized(), such as sending JDBC\r
  *  calls to the repository to add indices, etc.\r
  * @author Laramie\r
+ * $LastChangedRevision:  $\r
+ * $LastChangedDate:  $\r
  */\r
 public class InitHandler implements IInitHandler {\r
 \r
     final Logger logger = LoggerFactory.getLogger(InitHandler.class);\r
 \r
+    /**\r
+     * Callback procedure for performing post-initialization actions.\r
+     *\r
+     * See org.collectionspace.services.common.init.AddIndices for an implementation example.\r
+     *\r
+     * @param sbt a service binding type.\r
+     * @param fields A list of fields and their attributes.\r
+     * @param properties A properties bag for additional properties.\r
+     * @throws Exception\r
+     */\r
+    @Override\r
     public void onRepositoryInitialized(ServiceBindingType sbt, List<Field> fields, List<Property> properties) throws Exception {\r
-        // see org.collectionspace.services.common.init.AddIndices for a real implementation example.\r
-        System.out.println("\r\n\r\n~~~~~~~~~~~~~ in InitHandler.onRepositoryInitialized with ServiceBindingType: " + sbt);\r
+\r
         for (Field field : fields) {\r
             System.out.println("InitHandler.fields:"\r
                     + "\r\n    col: " + field.getCol()\r
index 22591e0a08d4cf7ce5c24766b8b7b0f7052d6daf..549106f7a69c4691edad39d14ea0712a96631db1 100644 (file)
@@ -40,30 +40,20 @@ public class MakeLargeTextFields extends InitHandler implements IInitHandler {
 
     final Logger logger = LoggerFactory.getLogger(MakeLargeTextFields.class);
 
+    @Override
     public void onRepositoryInitialized(ServiceBindingType sbt, List<Field> fields, List<Property> properties) throws Exception {
-          //todo: all post-init tasks for services, or delegate to services that override.
-          System.out.println("\r\n\r\n~~~~~~~~~~~~~ in MakeLargeTextFields.onRepositoryInitialized with ServiceBindingType: "+sbt);
-
-        String tableName = "nuxeo.collectionobjects_common_comments";
-        // String columnName = "item";
-        String columnDataType = "TEXT";
-
+        //todo: all post-init tasks for services, or delegate to services that override.
         int rows = 0;
         try {
             for (Field field : fields) {
                 // MySQL
                 String sql = "ALTER TABLE " + field.getTable() + " MODIFY COLUMN " + field.getCol() + " " + field.getType();
                 // PostgreSQL
-                // String sql = "ALTER TABLE " + tableName + " ALTER COLUMN " + columnName + " TYPE " + columnDataType;
+                // String sql = "ALTER TABLE " + field.getTable() + " ALTER COLUMN " + field.getCol() + " " + field.getType();
                 rows = executeUpdate(sql);
             }
-        } catch (Exception e){
+        } catch (Exception e) {
             throw e;
         }
-        //call something like this: services.common.storage.DBUtils.addIndex(String tablename, String fields[]);
-        //for every field that has an authRef, do ...
-        //    --> Connection conn = getConnection();
-        //see parameter that you need for adding indices to SQL.
-
     }
 }