From: Aron Roberts Date: Wed, 8 Aug 2012 00:53:38 +0000 (-0700) Subject: CSPACE-5440: Allow multiple fields of the same name, across different tables, to... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=07ca24ec099555b73d7d4d77373abf8799f61025;p=tmp%2Fjakarta-migration.git CSPACE-5440: Allow multiple fields of the same name, across different tables, to be indexed at startup. --- diff --git a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java b/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java index bb9eb6489..f189d1166 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java +++ b/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java @@ -24,7 +24,7 @@ public class CollectionSpaceServiceContextListener implements ServletContextList svcMain.retrieveAllWorkspaceIds(); - // Create required indexes / indices in tables not associated + // Create required indexes (aka indices) in tables not associated // with any specific tenant. svcMain.createRequiredIndices(); // diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java index 2ff40364e..3a93a231b 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java @@ -207,7 +207,7 @@ public class ServiceMain { } /** - * Create required indices (aka indexes) in database tables not associated + * Create required indexes (aka indices) in database tables not associated * with any specific tenant. * * @throws Exception @@ -220,11 +220,11 @@ public class ServiceMain { final String NUXEO_FULLTEXT_TABLE_NAME = "fulltext"; final String NUXEO_HIERARCHY_TABLE_NAME = "hierarchy"; - Map indexableFields = new HashMap(); - indexableFields.put("tenantid", COLLECTIONSPACE_CORE_TABLE_NAME); - indexableFields.put("updatedat", COLLECTIONSPACE_CORE_TABLE_NAME); - indexableFields.put("jobid", NUXEO_FULLTEXT_TABLE_NAME); - indexableFields.put("name", NUXEO_HIERARCHY_TABLE_NAME); + Map> fieldsToIndex = new HashMap>(); + fieldsToIndex.put(1, new ArrayList(Arrays.asList(COLLECTIONSPACE_CORE_TABLE_NAME, "tenantid"))); + fieldsToIndex.put(2, new ArrayList(Arrays.asList(COLLECTIONSPACE_CORE_TABLE_NAME, "updatedat"))); + fieldsToIndex.put(3, new ArrayList(Arrays.asList(NUXEO_FULLTEXT_TABLE_NAME, "jobid"))); + fieldsToIndex.put(4, new ArrayList(Arrays.asList(NUXEO_HIERARCHY_TABLE_NAME, "name"))); // Invoke existing post-init code to create these indexes, // sending in the set of values above, in contrast to @@ -232,10 +232,10 @@ public class ServiceMain { DataSource dataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME); AddIndices addindices = new AddIndices(); List fields = new ArrayList(); - for (Map.Entry entry : indexableFields.entrySet()) { + for (Map.Entry> entry : fieldsToIndex.entrySet()) { Field field = new Field(); - field.setCol(entry.getKey()); - field.setTable(entry.getValue()); + field.setTable(entry.getValue().get(0)); // Table name from List item 0 + field.setCol(entry.getValue().get(1)); // Column name from List item 1 fields.add(field); } addindices.onRepositoryInitialized(dataSource, null, fields, null);