From 271986fc76e09040f3cfc6822e03ec14cce2816e Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Thu, 15 Oct 2009 20:14:21 +0000 Subject: [PATCH] CSPACE-520, CSPACE-472: Edited descriptions of default ID Generator instances, to allow that field to serve as optional help text. Added priority field (not currently wired). Lists of instances are now returned in sorted order. --- .../services/id/IDResource.java | 10 +- .../services/id/IDServiceJdbcImpl.java | 7 +- .../db/mysql/create_id_generators_table.sql | 7 +- .../resources/db/mysql/load_id_generators.sql | 98 +++++++++++-------- 4 files changed, 71 insertions(+), 51 deletions(-) diff --git a/services/id/service/src/main/java/org/collectionspace/services/id/IDResource.java b/services/id/service/src/main/java/org/collectionspace/services/id/IDResource.java index 41328a8a1..f7a187d9e 100644 --- a/services/id/service/src/main/java/org/collectionspace/services/id/IDResource.java +++ b/services/id/service/src/main/java/org/collectionspace/services/id/IDResource.java @@ -537,7 +537,6 @@ public class IDResource { Element generatorRoot = null; String generatorStr = ""; Document generatorDoc = null; - IDGeneratorInstance instance = null; for (String csidValue : generators.keySet() ) { listitem = root.addElement(ID_GENERATOR_LIST_ITEM_NAME); @@ -545,15 +544,16 @@ 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()); + // Retrieve the matching ID generator instance by CSID, + // and then pull out several of its values. + displayname.addText(generators.get(csidValue).getDisplayName()); description = listitem.addElement("description"); - description.addText(instance.getDescription()); + description.addText(generators.get(csidValue).getDescription()); generator = listitem.addElement("idgenerator"); // Using the CSID as a key, get the XML string // representation of the ID generator. - generatorStr = instance.getGeneratorState(); + generatorStr = generators.get(csidValue).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 diff --git a/services/id/service/src/main/java/org/collectionspace/services/id/IDServiceJdbcImpl.java b/services/id/service/src/main/java/org/collectionspace/services/id/IDServiceJdbcImpl.java index 8ee6824f8..3e33dc06a 100644 --- a/services/id/service/src/main/java/org/collectionspace/services/id/IDServiceJdbcImpl.java +++ b/services/id/service/src/main/java/org/collectionspace/services/id/IDServiceJdbcImpl.java @@ -87,7 +87,7 @@ import java.sql.Statement; // May at some point instead use // org.jboss.resteasy.spi.NotFoundException import java.util.ArrayList; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.collectionspace.services.common.repository.BadRequestException; @@ -629,7 +629,7 @@ public class IDServiceJdbcImpl implements IDService { logger.debug("> in readIDGeneratorsList"); Map generators = - new HashMap(); + new LinkedHashMap(); Connection conn = null; try { @@ -639,7 +639,8 @@ public class IDServiceJdbcImpl implements IDService { ResultSet rs = stmt.executeQuery( "SELECT csid, displayname, description, " + - "id_generator_state FROM id_generators"); + "id_generator_state FROM id_generators " + + "ORDER BY displayname ASC, priority ASC"); boolean moreRows = rs.next(); if (! moreRows) { diff --git a/services/id/service/src/main/resources/db/mysql/create_id_generators_table.sql b/services/id/service/src/main/resources/db/mysql/create_id_generators_table.sql index 2d311b39b..ddf141307 100644 --- a/services/id/service/src/main/resources/db/mysql/create_id_generators_table.sql +++ b/services/id/service/src/main/resources/db/mysql/create_id_generators_table.sql @@ -21,8 +21,8 @@ * Creates the "id_generators" table, used by the ID Service, * and sets the access permissions of that table. * - * $LastChangedRevision: 302 $ - * $LastChangedDate: 2009-07-15 17:42:23 -0700 (Wed, 15 Jul 2009) $ + * $LastChangedRevision$ + * $LastChangedDate$ */ /* @@ -39,7 +39,8 @@ CREATE TABLE `id_generators` ( `csid` varchar(80) PRIMARY KEY, `displayname` varchar(80), `description` varchar(500), - `id_generator_state` varchar(8000), + `priority` smallint(1) DEFAULT 9 NOT NULL, + `id_generator_state` varchar(8000) NOT NULL, `last_generated_id` varchar(255), `modified` timestamp NOT NULL default CURRENT_TIMESTAMP diff --git a/services/id/service/src/main/resources/db/mysql/load_id_generators.sql b/services/id/service/src/main/resources/db/mysql/load_id_generators.sql index adb8d4bd0..1f3799d50 100644 --- a/services/id/service/src/main/resources/db/mysql/load_id_generators.sql +++ b/services/id/service/src/main/resources/db/mysql/load_id_generators.sql @@ -21,14 +21,19 @@ * Loads a default set of data into the "id_generators" table, * used by the ID Service. * - * $LastChangedRevision: 302 $ - * $LastChangedDate: 2009-09-25 15:51:39 -0700 (Fri, 25 Sep 2009) $ + * $LastChangedRevision$ + * $LastChangedDate$ */ /* - * NOTE: For numeric sequence parts whose first generated - * value is expected to start at the initial value (such as '1'), - * enter '-1' for the current value. + * Note: in the priority column, values range from '1' (highest) + * to '9' (lowest). + */ + +/* + * NOTE: In the id_generator_state column, for numeric sequence parts + * whose first generated value should start at the initial value + * (such as '1'), enter '-1' for the * * Otherwise, the first generated value will be the next value * in the sequence after the initial value (e.g. '2', if the @@ -40,13 +45,13 @@ USE `cspace`; -- ACCESSION_LOT_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('1a67470b-19b1-4ae3-88d4-2a0aa936270e', 'Accession Activity Number', - 'Generates accession lot or activity numbers, to identify accession -activities in which a lot of one or more collection objects is -acquired by the institution.', + 'Identifies accession activities, in which a lot of +one or more collection objects is acquired by the institution.', + '9', '', ' @@ -68,13 +73,14 @@ acquired by the institution.', -- ACCESSION_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('9dd92952-c384-44dc-a736-95e435c1759c', 'Accession Number', - 'Generates accession numbers, to identify individual -collection objects individually acquired by the museum. This -generator is used for collection objects without parts.', + 'Identifies individual collection objects formally +acquired by the institution. Used for collection objects +without parts.', + '9', '', ' @@ -105,13 +111,14 @@ generator is used for collection objects without parts.', -- ARCHIVES_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('70586d30-9dca-4a07-a3a2-1976fe898028', 'Archives Number', - 'Generates archives numbers, to identify accession activities + 'Identifies archives-related accession activities, in which a lot of one or more collection objects is formally acquired for the archives.', + '9', '', ' @@ -137,13 +144,14 @@ acquired for the archives.', -- EVALUATION_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('d2d80822-25c7-4c7c-a105-fc40cdb0c50f', 'Evaluation Number', - 'Generates evaluation numbers, to identify intake activities + 'Identifies evaluation-related intake activities, in which a lot of one or more collection objects is formally acquired for evaluation.', + '9', '', ' @@ -169,13 +177,13 @@ acquired for evaluation.', -- INTAKE_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('8088cfa5-c743-4824-bb4d-fb11b12847f7', 'Intake Number', - 'Generates intake activity numbers, to identify intake activities -in which a lot of one or more collection objects enters -the institution for evaluation.', + 'Identifies intake activities, in which a lot of one +or more collection objects enters the institution.', + '9', '', ' @@ -201,14 +209,14 @@ the institution for evaluation.', -- INTAKE_OBJECT_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('a91db555-5c53-4996-9918-6712351397a0', 'Intake Object Number', - 'Generates intake numbers, to identify individual -collection objects that enter the institution through -intake activities, before they are either returned to -their owner or formally acquired by the institution.', + 'Identifies individual collection objects that enter +the institution through intake activities, before they are +either returned to their owner or formally acquired.', + '9', '', ' @@ -243,12 +251,14 @@ their owner or formally acquired by the institution.', -- LIBRARY_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('80fedaf6-1647-4f30-9f53-a75a3cac2ffd', 'Library Number', - 'Generates library numbers, in which a lot of one or more -collection objects is formally acquired for the library.', + 'Identifies library-related accession activities, +in which a lot of one or more collection objects is +formally acquired for the library.', + '9', '', ' @@ -274,12 +284,13 @@ collection objects is formally acquired for the library.', -- LOANS_IN_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('ed87e7c6-0678-4f42-9d33-f671835586ef', 'Loans-in Number', - 'Generates loans-in numbers, to identify individual -collection objects that are received on loan.', + 'Identifies individual collection objects that are +received on loan.', + '9', '', ' @@ -314,13 +325,14 @@ collection objects that are received on loan.', -- STUDY_NUMBER INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('0518132e-dd8c-4773-8fa9-07c9af4444ee', 'Study Number', - 'Generates study numbers, to identify intake activities -in which a lot of one or more collection objects is formally -acquired for study.', + 'Identifies study-related intake activities, +in which a lot of one or more collection objects is +formally acquired for study.', + '9', '', ' @@ -345,14 +357,20 @@ acquired for study.', -- UUID +/* + * Note: these are Type 4 UUIDs, whose generation is based on + * random and pseudo-random parts. + */ + INSERT INTO `id_generators` - (csid, displayname, description, last_generated_id, id_generator_state) + (csid, displayname, description, priority, last_generated_id, id_generator_state) VALUES ('1fa40353-05b8-4ae6-82a6-44a18b4f3c12', 'UUID', - 'Generates universally unique identifiers (UUIDs), which may be -used for CollectionSpace IDs (CSIDs) and other purposes. (These are -Type 4 UUIDs, whose generation is based on random and pseudo-random parts.)', + 'Universally unique identifiers (UUIDs), which may be +used for CollectionSpace IDs (CSIDs) and any other relevant +purposes.', + '9', '', ' -- 2.47.3