--- /dev/null
+/**
+ * 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;
+ }
+
+}
// 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 ...
*
* @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);
*
* @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);
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);
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
// 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)
* @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 {
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();
{"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,
"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,