]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-520: ID Service generates full lists that now include nearly all pertinent...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 15 Oct 2009 05:14:43 +0000 (05:14 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 15 Oct 2009 05:14:43 +0000 (05:14 +0000)
services/id/service/src/main/java/org/collectionspace/services/id/IDGeneratorInstance.java [new file with mode: 0644]
services/id/service/src/main/java/org/collectionspace/services/id/IDResource.java
services/id/service/src/main/java/org/collectionspace/services/id/IDService.java
services/id/service/src/main/java/org/collectionspace/services/id/IDServiceJdbcImpl.java
services/id/service/src/test/java/org/collectionspace/services/id/test/IDServiceJdbcImplTest.java

diff --git a/services/id/service/src/main/java/org/collectionspace/services/id/IDGeneratorInstance.java b/services/id/service/src/main/java/org/collectionspace/services/id/IDGeneratorInstance.java
new file mode 100644 (file)
index 0000000..2664e46
--- /dev/null
@@ -0,0 +1,62 @@
+/**    
+ * 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 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.
+ */
+package org.collectionspace.services.id;
+
+/**
+ * IDGeneratorInstance.
+ *
+ * $LastChangedRevision: 850 $
+ * $LastChangedDate: 2009-10-12 15:17:09 -0700 (Mon, 12 Oct 2009) $
+ */
+public class IDGeneratorInstance {
+
+    private String displayName;
+    private String description;
+    private String generatorState;
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getGeneratorState() {
+        return generatorState;
+    }
+
+    public void setGeneratorState(String generatorState) {
+        this.generatorState = generatorState;
+    }
+
+}
index f21642c2009b56d9e1579e0faec94cad719c3423..41328a8a198092f58d14686c39bbb2b11e31444e 100644 (file)
@@ -340,7 +340,8 @@ public class IDResource {
         // or may not be a good idea.
         try {
 
-            Map<String,String> generators = service.readIDGeneratorsList();
+            Map<String,IDGeneratorInstance> generators =
+                    service.readIDGeneratorsList();
 
             // @TODO Filtering by role will likely take place here ...
 
@@ -474,7 +475,8 @@ public class IDResource {
      *
      * @return  A summary list of ID generator instances.
      */
-    private String formattedSummaryList(Map<String,String> generators) {
+    private String formattedSummaryList(
+        Map<String,IDGeneratorInstance> generators) {
 
         Document doc = DocumentHelper.createDocument();
         Element root = doc.addElement(ID_GENERATOR_LIST_NAME);
@@ -517,7 +519,8 @@ public class IDResource {
      *
      * @return  A full list of ID generator instances.
      */
-    private String formattedFullList(Map<String,String> generators) {
+    private String formattedFullList(
+        Map<String,IDGeneratorInstance> generators) {
 
         Document doc = DocumentHelper.createDocument();
         Element root = doc.addElement(ID_GENERATOR_LIST_NAME);
@@ -528,10 +531,13 @@ public class IDResource {
         Element listitem = null;
         Element csid = null;
         Element uri = null;
+        Element displayname = null;
+        Element description = null;
         Element generator = null;
         Element generatorRoot = null;
         String generatorStr = "";
         Document generatorDoc = null;
+        IDGeneratorInstance instance = null;
         for (String csidValue : generators.keySet() )
         {
             listitem = root.addElement(ID_GENERATOR_LIST_ITEM_NAME);
@@ -539,10 +545,15 @@ public class IDResource {
             csid.addText(csidValue);
             uri = listitem.addElement("uri");
             uri.addText(getRelativePath(csidValue));
+            instance = generators.get(csidValue);
+            displayname = listitem.addElement("displayname");
+            displayname.addText(instance.getDisplayName());
+            description = listitem.addElement("description");
+            description.addText(instance.getDescription());
             generator = listitem.addElement("idgenerator");
             // Using the CSID as a key, get the XML string
             // representation of the ID generator.
-            generatorStr = generators.get(csidValue);
+            generatorStr = instance.getGeneratorState();
             // Convert the XML string representation of the
             // ID generator to a new XML document, copy its
             // root element, and append it to the relevant location
index 4fad0e29a646c85ddb2a0a90eb02f0c7126a7740..26a1a8a466ad54c33e26d11f0abba172c0c7cc77 100644 (file)
@@ -69,7 +69,8 @@ public interface IDService {
     
     // Read a list of objects (aka read multiple)
     // and return a list (map) of those objects and their identifiers.
-    public Map<String,String> readIDGeneratorsList() throws IllegalStateException;
+    public Map<String,IDGeneratorInstance> readIDGeneratorsList()
+        throws IllegalStateException;
 
     // Update
      public void updateIDGenerator(String csid, String serializedIDGenerator)
index 7ae3ef4fd37f4197b31dfa26244e507a51cb960a..8ee6824f85d25ab87912acf1cd3223391e0e165b 100644 (file)
@@ -623,11 +623,13 @@ public class IDServiceJdbcImpl implements IDService {
        * @throws  IllegalStateException if a storage-related error occurred.
        */
     @Override
-    public Map<String,String> readIDGeneratorsList() throws IllegalStateException {
+    public Map<String,IDGeneratorInstance> readIDGeneratorsList()
+            throws IllegalStateException {
 
                logger.debug("> in readIDGeneratorsList");
 
-               Map<String,String> generators = new HashMap<String,String>();
+               Map<String,IDGeneratorInstance> generators =
+            new HashMap<String,IDGeneratorInstance>();
 
                Connection conn = null;
                try {
@@ -636,15 +638,21 @@ public class IDServiceJdbcImpl implements IDService {
                        Statement stmt = conn.createStatement();
 
                        ResultSet rs = stmt.executeQuery(
-                         "SELECT csid, id_generator_state FROM id_generators");
+                         "SELECT csid, displayname, description, " +
+              "id_generator_state FROM id_generators");
 
                        boolean moreRows = rs.next();
                        if (! moreRows) {
                                return generators;
                        }
 
+            IDGeneratorInstance instance = null;
             while (moreRows = rs.next()) {
-                generators.put(rs.getString(1), rs.getString(2));
+                instance = new IDGeneratorInstance();
+                instance.setDisplayName(rs.getString(2));
+                instance.setDescription(rs.getString(3));
+                instance.setGeneratorState(rs.getString(4));
+                generators.put(rs.getString(1), instance);
             }
 
                        rs.close();
index 35ab978df32d13aba45e59959b1d6e354c06991a..f6f2874faa293d51ad422fd555a8c5707b2d1bb2 100644 (file)
@@ -93,7 +93,7 @@ public class IDServiceJdbcImplTest {
         {"hasRequiredDatabaseTable", "createIDGenerator", "readIDGenerator"})
     public void readIDGeneratorsList() throws IllegalStateException {
 
-        Map<String,String> generators = jdbc.readIDGeneratorsList();
+        Map<String,IDGeneratorInstance> generators = jdbc.readIDGeneratorsList();
 
         // @TODO Replace this placeholder test, which just
         // verifies that no error occurred while retrieving the list,
@@ -106,7 +106,7 @@ public class IDServiceJdbcImplTest {
           "readIDGeneratorsList"})
     public void readIDGeneratorsSummaryList() throws IllegalStateException {
 
-        Map<String,String> generators = jdbc.readIDGeneratorsList();
+        Map<String,IDGeneratorInstance> generators = jdbc.readIDGeneratorsList();
 
         // @TODO Replace this placeholder test, which just
         // verifies that no error occurred while retrieving the list,