diff --git a/cspace-ui/pahma/build.properties b/cspace-ui/pahma/build.properties index 05268f81e7..ef928c12fb 100644 --- a/cspace-ui/pahma/build.properties +++ b/cspace-ui/pahma/build.properties @@ -3,4 +3,4 @@ tenant.ui.basename=/cspace/${tenant.shortname} tenant.ui.profile.plugin.package.name=cspace-ui-plugin-profile-pahma tenant.ui.profile.plugin.library.name=cspaceUIPluginProfilePAHMA -tenant.ui.profile.plugin.version=3.0.0-d.5 +tenant.ui.profile.plugin.version=3.0.0-d.8 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 dbd183ddd4..2388cb7a92 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 @@ -117,6 +117,8 @@ private static void mirrorToStdOut(String str) { private static final String DROP_OBJECTS_SQL_COMMENT = "-- drop all the objects before dropping roles"; private static final String CSPACE_JEESERVER_HOME = "CSPACE_JEESERVER_HOME"; + private static final String CSPACE_UTILS_SCHEMANAME = "utils"; + private ServiceMain() { // Intentionally blank } @@ -770,7 +772,7 @@ public void firePostInitHandlers() throws Exception { Object o = instantiate(initHandlerClassname, IInitHandler.class); if (o != null && o instanceof IInitHandler){ IInitHandler handler = (IInitHandler)o; - handler.onRepositoryInitialized(JDBCTools.NUXEO_DATASOURCE_NAME, repositoryName, cspaceInstanceId, + handler.onRepositoryInitialized(JDBCTools.CSADMIN_NUXEO_DATASOURCE_NAME, repositoryName, cspaceInstanceId, sbt, fields, props); //The InitHandler may be the default one, // or specialized classes which still implement this interface and are registered in tenant-bindings.xml. @@ -957,7 +959,8 @@ private HashSet createNuxeoDatabases() throws Exception { JDBCTools.createNewDatabaseUser(JDBCTools.CSADMIN_DATASOURCE_NAME, repositoryName, cspaceInstanceId, dbType, readerUser, readerPW); } // Create the database - createDatabaseWithRights(dbType, dbName, nuxeoUser, nuxeoPW, readerUser, readerPW); + createDatabaseWithRights(dbType, dbName, nuxeoUser, nuxeoPW, readerUser); + createUtilsSchemaWithRights(dbType, nuxeoUser, repositoryName, cspaceInstanceId); initRepositoryDatabaseVersion(JDBCTools.NUXEO_DATASOURCE_NAME, repositoryName, cspaceInstanceId); } nuxeoDBsChecked.add(dbName); @@ -984,7 +987,7 @@ private HashSet createNuxeoDatabases() throws Exception { * @throws Exception */ private void createDatabaseWithRights(DatabaseProductType dbType, String dbName, String ownerName, - String ownerPW, String readerName, String readerPW) throws Exception { + String ownerPW, String readerName) throws Exception { Connection conn = null; Statement stmt = null; @@ -1009,30 +1012,56 @@ private void createDatabaseWithRights(DatabaseProductType dbType, String dbName, } // Note that select rights for reader must be granted after // Nuxeo startup. - } else if (dbType == DatabaseProductType.MYSQL) { - sql = "CREATE database " + dbName + " DEFAULT CHARACTER SET utf8"; - stmt.executeUpdate(sql); - sql = "GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + ownerName + "'@'localhost' IDENTIFIED BY '" - + ownerPW + "' WITH GRANT OPTION"; + } else { + throw new UnsupportedOperationException(String.format("", dbType)); + } + } catch (Exception e) { + String errMsg = String.format("The following SQL statement failed using credentials from datasource '%s': %s", + JDBCTools.CSADMIN_DATASOURCE_NAME, sql); + logger.error("createDatabaseWithRights failed on exception: " + e.getLocalizedMessage()); + if (errMsg != null) { + logger.error(errMsg); + } + throw e; // propagate + } finally { // close resources + try { + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } + } catch (SQLException se) { + se.printStackTrace(); + } + } + } + + /* + * For a specific repo/db, create a schema for misc SQL functions + */ + private void createUtilsSchemaWithRights(DatabaseProductType dbType, String ownerName, + String repositoryName, String cspaceInstanceId) throws Exception { + Connection conn = null; + Statement stmt = null; + + String sql = null; + try { + conn = JDBCTools.getConnection(JDBCTools.CSADMIN_NUXEO_DATASOURCE_NAME, repositoryName, cspaceInstanceId); + stmt = conn.createStatement(); + if (dbType == DatabaseProductType.POSTGRESQL) { + sql = "CREATE SCHEMA IF NOT EXISTS " + CSPACE_UTILS_SCHEMANAME + " AUTHORIZATION " + ownerName; stmt.executeUpdate(sql); if (logger.isDebugEnabled()) { - logger.debug("Created db: '" + dbName + "' with owner: '" + ownerName + "'"); - } - if (readerName != null) { - sql = "GRANT SELECT ON " + dbName + ".* TO '" + readerName + "'@'localhost' IDENTIFIED BY '" - + readerPW + "' WITH GRANT OPTION"; - stmt.executeUpdate(sql); - if (logger.isDebugEnabled()) { - logger.debug(" Granted SELECT rights on: '" + dbName + "' to reader: '" + readerName + "'"); - } + logger.debug("Created SCHEMA: '" + CSPACE_UTILS_SCHEMANAME + "' with owner: '" + ownerName + "'"); } } else { - throw new UnsupportedOperationException("createDatabaseWithRights only supports PSQL - MySQL NYI!"); + throw new UnsupportedOperationException("CollectionSpace supports only PostgreSQL database servers."); } } catch (Exception e) { String errMsg = String.format("The following SQL statement failed using credentials from datasource '%s': %s", - JDBCTools.CSADMIN_DATASOURCE_NAME, sql); - logger.error("createDatabaseWithRights failed on exception: " + e.getLocalizedMessage()); + JDBCTools.CSADMIN_NUXEO_DATASOURCE_NAME, sql); + logger.error("createUtilsSchemaWithRights() failed with exception: " + e.getLocalizedMessage()); if (errMsg != null) { logger.error(errMsg); } diff --git a/services/common/src/main/resources/db/postgresql/grant_pahma_reporters_privileges.sql b/services/common/src/main/resources/db/postgresql/grant_pahma_reporters_privileges.sql index 7bee1875d9..11540b4a0e 100644 --- a/services/common/src/main/resources/db/postgresql/grant_pahma_reporters_privileges.sql +++ b/services/common/src/main/resources/db/postgresql/grant_pahma_reporters_privileges.sql @@ -4,7 +4,8 @@ BEGIN SELECT * FROM pg_catalog.pg_group WHERE groname = 'reporters_pahma') THEN - - GRANT SELECT ON ALL TABLES IN SCHEMA public TO GROUP reporters_pahma; + ELSE + CREATE ROLE reporters_pahma with nologin; END IF; + GRANT SELECT ON ALL TABLES IN SCHEMA public TO GROUP reporters_pahma; END $$; diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/pahmaGroupNAGPRAexcel.jrxml b/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/pahmaGroupNAGPRAexcel.jrxml index 8e5177f373..80e50842ac 100644 --- a/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/pahmaGroupNAGPRAexcel.jrxml +++ b/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/pahmaGroupNAGPRAexcel.jrxml @@ -63,7 +63,7 @@ COALESCE(STRING_AGG(DISTINCT getdispl(fcoll.item),'␥'),'') AS "Field_collector COALESCE(scd.datedisplaydate,'') AS "Field_collection_date", COALESCE(REGEXP_REPLACE(cc.fieldcollectionnote, E'[\\n\\r]+', '¶', 'g' ),'') AS "Field_collection_note", COALESCE(cp.pahmatmslegacydepartment,'') AS "Legacy_department", -COALESCE(STRING_AGG(DISTINCT nal.item,'␥'),'') AS "Museums_NAGPRA_category_determinations", +COALESCE(STRING_AGG(DISTINCT getdispl(nc.item),'␥'),'') AS "Museums_NAGPRA_category_determinations", COALESCE(STRING_AGG(DISTINCT getdispl(inv.item),'␥'),'') AS "NAGPRA_inventory", COALESCE(STRING_AGG(DISTINCT acc.accnumber,'␥'),'') AS "Accession_numbers", COALESCE(STRING_AGG(DISTINCT acc.accdate, '␥'),'') AS "Accession_dates", @@ -107,8 +107,8 @@ JOIN hierarchy h1 ON (cc.id=h1.id) LEFT OUTER JOIN hierarchy hn ON (cc.id=hn.parentid AND hn.name='collectionobjects_common:objectNameList' AND (hn.pos=0)) LEFT OUTER JOIN objectnamegroup ong ON (ong.id=hn.id) LEFT OUTER JOIN collectionobjects_common_briefdescriptions bd ON (bd.id=cc.id AND (bd.pos=0)) -LEFT OUTER JOIN collectionobjects_anthropology_nagpraapplicabilitylist nal ON (nal.id=cc.id) -LEFT OUTER JOIN collectionobjects_anthropology_nagprainventorynamelist inv ON (inv.id=cc.id) +LEFT OUTER JOIN collectionobjects_nagpra_nagpracategories nc ON (nc.id=cc.id) +LEFT OUTER JOIN collectionobjects_nagpra_nagprainventorynames inv ON (inv.id=cc.id) LEFT OUTER JOIN collectionobjects_pahma_pahmafieldcollectionplacelist fcp ON (fcp.id=cc.id AND (fcp.pos=0 OR fcp.pos IS NULL)) LEFT OUTER JOIN places_common pcfcp ON (pcfcp.shortidentifier=REGEXP_REPLACE(fcp.item, '^.*item:name\((.*?)\)''.*', '\1')) LEFT OUTER JOIN hierarchy pcsidfcp ON (pcfcp.id=pcsidfcp.id) diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/pahmaRepatriationNAGPRA.jrxml b/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/pahmaRepatriationNAGPRA.jrxml index 6a2a15698c..bf24fc2c3a 100644 --- a/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/pahmaRepatriationNAGPRA.jrxml +++ b/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/pahmaRepatriationNAGPRA.jrxml @@ -17,22 +17,22 @@ + + + 2021NAGPRASAMPLE + + + + urn:cspace:pahma.cspace.berkeley.edu:vocabularies:name(pahmaNagpraCodeLegacies):item:name(pahmaNagpraCodeLegacies10)' 10: not reportable' + + + Repat notes for MN 2021NAGPRASAMPLE + + + urn:cspace:pahma.cspace.berkeley.edu:vocabularies:name(nagpraPahmaApplicabilities):item:name(nagpraPahmaApplicabilities01)'affiliated human skeletal remains (HSR)' + + + + urn:cspace:pahma.cspace.berkeley.edu:orgauthorities:name(organization):item:name(NAGPRA1611346562666)'NAGPRA' + RH note for PAHMA-NAGPRA Staff + + true + + + 1/1/2001 + 2001-01-02T00:00:00.000Z + + + + 1 + + 2001 + + + + 1 + urn:cspace:pahma.cspace.berkeley.edu:vocabularies:name(dateera):item:name(ce)'CE' + + + + + + 2001-01-01T00:00:00.000Z + + + true + urn:cspace:pahma.cspace.berkeley.edu:orgauthorities:name(organization):item:name(PAHMANAGPRAStaff1611346539517)'PAHMA-NAGPRA Staff' + + + + PAHMA cultural determination notes for 2021NAGPRASAMPLE + + + urn:cspace:pahma.cspace.berkeley.edu:vocabularies:name(nagpraPahmaInventoryNames):item:name(nagpraPahmaInventoryNames01)'AK-Alaska' + + + + urn:cspace:pahma.cspace.berkeley.edu:vocabularies:name(nagpradetermtype):item:name(unknown1)'unknown1' + urn:cspace:pahma.cspace.berkeley.edu:personauthorities:name(person):item:name(NatashaJohnson1611346486489)'Natasha Johnson' + CD note for 2021NAGPRASAMPLE + urn:cspace:pahma.cspace.berkeley.edu:orgauthorities:name(organization):item:name(KaagwaantaanClanofKlukwan1611346415910)'Kaagwaantaan Clan of Klukwan' + + + + diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/payloads/pahmaRepatriationNAGPRA.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/payloads/pahmaRepatriationNAGPRA.xml index 5a87186290..f96755b6e2 100644 --- a/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/payloads/pahmaRepatriationNAGPRA.xml +++ b/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/pahma/payloads/pahmaRepatriationNAGPRA.xml @@ -12,6 +12,9 @@ true false false + + text/csv + text/csv diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/ucbg/payloads/ucbgLabelOrder.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/ucbg/payloads/ucbgLabelOrder.xml index d868d2343d..59b33a3f5f 100644 --- a/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/ucbg/payloads/ucbgLabelOrder.xml +++ b/services/report/3rdparty/jasper-cs-report/src/main/resources/tenants/ucbg/payloads/ucbgLabelOrder.xml @@ -2,11 +2,12 @@ Label Orders - ucbgLabelOrder.jrxml + ucbgLabelOrder.jasper CollectionObject - false + + true false false true