]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5943: Add many comments.
authorAron Roberts <aron@socrates.berkeley.edu>
Fri, 29 Mar 2013 02:24:28 +0000 (19:24 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Fri, 29 Mar 2013 02:24:28 +0000 (19:24 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/common/storage/PreparedStatementBuilder.java
services/common/src/main/java/org/collectionspace/services/common/storage/PreparedStatementSimpleBuilder.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java

index 6e75f726065657036bbb903158a4c3933d8f7f79..5f1eeef91c06156897c4f19e350b1a8f010dfe20 100644 (file)
@@ -697,13 +697,16 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
     }
     
     protected String getInAuthorityValue() {
-        // FIXME: Replace this placeholder / stub
+        // FIXME: Replace this placeholder / stub with actual code
+        // to obtain the relevant inAuthority value
         return AuthorityResource.PARENT_WILDCARD;
     }
     
     @Override
     public Map<String,String> getJDBCQueryParams() {
-        // FIXME: Get all of the following values from appropriate external constants
+        // FIXME: Get all of the following values from appropriate external constants.
+        // At present, these are duplicated in both RepositoryJavaClientImpl
+        // and in AuthorityItemDocumentModelHandler.
         final String TERM_GROUP_TABLE_NAME_PARAM = "TERM_GROUP_TABLE_NAME";
         final String IN_AUTHORITY_PARAM = "IN_AUTHORITY";
         
index e99d704043335823ef8923f326b6a977da79ca9f..756517a32750e0b003a438a99779edfb067e7e39 100644 (file)
@@ -1,5 +1,35 @@
 /**
- * Per http://stackoverflow.com/a/7127189
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright © 2009-2013 The Regents of the University of California 
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * PreparedStatementBuilder
+ * 
+ * Simple workaround for the inability to create a JDBC
+ * PreparedStatement without having a current Connection
+ * 
+ * See http://stackoverflow.com/a/7127189
+ * and http://blog.stackoverflow.com/2009/06/stack-overflow-creative-commons-data-dump/
  */
 
 package org.collectionspace.services.common.storage;
@@ -16,21 +46,32 @@ public class PreparedStatementBuilder
         this.sql = sql;
     }
 
+   /**
+    * A 'virtual' method to be overridden, in which to declare setup directives
+    * to be applied to a PreparedStatement; for instance, to add values to
+    * replaceable parameters or otherwise modify the statement's behavior.
+    * 
+    * (The PreparedStatement will not yet exist at the time this method is overridden.)
+    * 
+    * @param preparedStatement a JDBC PreparedStatement.
+    * @throws SQLException 
+    */
     protected void preparePrepared(final PreparedStatement preparedStatement) 
             throws SQLException {
-        // This virtual method lets us declare how, when we generate our
-        // PreparedStatement, we want it to be set up.
-
-        // Note that at the time this method is overridden, the 
-        // PreparedStatement has not yet been created.
     }
 
+    /**
+     * Build a PreparedStatement by obtaining it from a JDBC Connection,
+     * then applying setup directives.
+     * 
+     * @param conn a JDBC connection
+     * @return a JDBC PreparedStatement, with any 
+     * @throws SQLException 
+     */
     public PreparedStatement build(final Connection conn)
             throws SQLException
     {
-        // Fetch the PreparedStatement
         final PreparedStatement returnable = conn.prepareStatement(sql);
-        // Perform setup directives
         preparePrepared(returnable);
         return returnable;
     }
index a71f9ec14cfc9b7516e2a52ef2cb7aeb995a7d45..662ba912175817fe6dd4305e87221c5574bd84db 100644 (file)
@@ -1,3 +1,35 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright © 2009-2013 The Regents of the University of California 
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * PreparedStatementSimpleBuilder
+ * 
+ * Specialization of PreparedStatementBuilder that simply applies a
+ * set of String values, in order, to each of the replaceable parameters
+ * in a PreparedStatement.
+ */
+
 package org.collectionspace.services.common.storage;
 
 import java.sql.PreparedStatement;
index 8fb2305dcdb49cef9fea27cb634bc35ad243564b..538860e7befd3706c87f4731dcbe507f40d93b0d 100644 (file)
@@ -919,13 +919,17 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
         final String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM);
         
-        // FIXME: Get all of the following values from appropriate external constants
+        // FIXME: Get all of the following values from appropriate external constants.
+        // At present, these are duplicated in both RepositoryJavaClientImpl
+        // and in AuthorityItemDocumentModelHandler.
         final String TERM_GROUP_TABLE_NAME_PARAM = "TERM_GROUP_TABLE_NAME";
         final String IN_AUTHORITY_PARAM = "IN_AUTHORITY";
         final String PARENT_WILDCARD = "_ALL_"; // Get this from AuthorityResource or equivalent
                 
         // FIXME: Replace this placeholder query with an actual query resulting
         // from CSPACE-5945 work
+        
+        // Start with the default query
         String selectStatement =
                 "SELECT DISTINCT hierarchy.id as id"
                 + " FROM hierarchy ";
@@ -940,8 +944,9 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                 " WHERE (tg.termdisplayname ILIKE ?) ";
         
         List<String> params = new ArrayList<>();
-        params.add(partialTerm + JDBCTools.SQL_WILDCARD);
+        params.add(partialTerm + JDBCTools.SQL_WILDCARD); // Value for replaceable parameter 1 in the query
         
+        // Restrict the query to filter out deleted records, if requested
         String includeDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_NONDELETED);
         if (includeDeleted != null && includeDeleted.equalsIgnoreCase(Boolean.FALSE.toString())) {
             joinClauses = joinClauses
@@ -952,7 +957,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         }
 
         // If a particular authority is specified, restrict the query further
-        // to records within that authority
+        // to return only records within that authority
         String inAuthorityValue = (String) handler.getJDBCQueryParams().get(IN_AUTHORITY_PARAM);
         if (Tools.notBlank(inAuthorityValue)) {
             // Handle the '_ALL_' case for inAuthority
@@ -964,10 +969,10 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
                    + "   ON commonschema.id = hierarchy.id ";
                 whereClause = whereClause
                     + " AND (commonschema.inauthority = ?)";
-                params.add(inAuthorityValue);
+                params.add(inAuthorityValue); // Value for replaceable parameter 2 in the query
             }
         }
-                
+        
         String sql = selectStatement + joinClauses + whereClause;
         
         // FIXME: Look into whether the following performance concern around
@@ -996,7 +1001,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             String id;
             crs.beforeFirst();
             while (crs.next()) {
-                id = crs.getString(1);
+                id = crs.getString(1); // There is only one column returned in this filter query
                 if (Tools.notBlank(id)) {
                     docIds.add(id);
                 }