]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-1230: Automatically add/update reports on startup. (#344)
authorRay Lee <ray.lee@lyrasis.org>
Wed, 3 May 2023 04:32:54 +0000 (00:32 -0400)
committerGitHub <noreply@github.com>
Wed, 3 May 2023 04:32:54 +0000 (00:32 -0400)
27 files changed:
services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java
services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java
services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java
services/common/src/main/cspace/config/services/tenants/publicart/publicart-tenant-bindings.delta.xml
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml
services/common/src/main/java/org/collectionspace/services/common/query/QueryManager.java
services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java
services/jaxb/src/main/java/org/collectionspace/services/jaxb/InvocableJAXBSchema.java
services/report/3rdparty/build.xml
services/report/3rdparty/jasper-cs-report/src/main/resources/Acq_List_Basic.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/CC_List_Basic.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/Exhibition_List_Basic.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/Group_List_Basic.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/LoansIn_List_Basic.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/LoansOut_List_Basic.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/acq_basic.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/coreAcquisition.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/coreGroupObject.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/coreIntake.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/coreLoanIn.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/coreLoanOut.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/coreObjectExit.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/object_valuation.xml [new file with mode: 0644]
services/report/3rdparty/jasper-cs-report/src/main/resources/systematicInventory.xml [new file with mode: 0644]
services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java
services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java
services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java

index 82244d93ed6c62039780720c884aabf6995e117c..abc0e7ea13d2c4ba83e2cb14f401ab427559191f 100644 (file)
@@ -3,23 +3,32 @@ package org.collectionspace.services.jaxrs;
 import static org.nuxeo.elasticsearch.ElasticSearchConstants.ES_ENABLED_PROPERTY;
 
 import javax.servlet.ServletContextEvent;
+import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.jboss.resteasy.core.Dispatcher;
 import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap;
-
+import org.jboss.resteasy.specimpl.PathSegmentImpl;
+import org.collectionspace.authentication.AuthN;
 import org.collectionspace.authentication.CSpaceTenant;
 import org.collectionspace.services.account.Tenant;
 import org.collectionspace.services.account.TenantResource;
 import org.collectionspace.services.authorization.AuthZ;
+import org.collectionspace.services.client.AbstractCommonListUtils;
 import org.collectionspace.services.client.AuthorityClient;
-
+import org.collectionspace.services.client.CollectionSpaceClient;
+import org.collectionspace.services.client.PayloadOutputPart;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.client.ReportClient;
+import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.config.ConfigUtils;
 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
+import org.collectionspace.services.common.query.UriInfoImpl;
 import org.collectionspace.services.common.vocabulary.AuthorityResource;
 
 import org.collectionspace.services.config.service.AuthorityInstanceType;
@@ -28,51 +37,73 @@ import org.collectionspace.services.config.service.ServiceBindingType.AuthorityI
 import org.collectionspace.services.config.service.Term;
 import org.collectionspace.services.config.service.TermList;
 import org.collectionspace.services.config.tenant.TenantBindingType;
+import org.collectionspace.services.config.types.PropertyItemType;
+import org.collectionspace.services.config.types.PropertyType;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.jaxb.AbstractCommonList.ListItem;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-
+import org.collectionspace.services.report.ReportResource;
 import org.nuxeo.elasticsearch.ElasticSearchComponent;
 import org.nuxeo.elasticsearch.api.ElasticSearchService;
 import org.nuxeo.runtime.api.Framework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+import java.io.File;
 import java.lang.reflect.Constructor;
-import java.util.Date;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.List;
-import java.util.logging.Level;
+import java.util.Set;
 
 public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
+       private static final Logger logger = LoggerFactory.getLogger(CSpaceResteasyBootstrap.class);
 
-       java.util.logging.Logger logger = java.util.logging.Logger.getAnonymousLogger();
-       static final String RESET_AUTHORITIES_PROPERTY = "org.collectionspace.services.authorities.reset";
+       private static final String RESET_AUTHORITIES_PROPERTY = "org.collectionspace.services.authorities.reset";
        private static final String RESET_ELASTICSEARCH_INDEX_PROPERTY = "org.collectionspace.services.elasticsearch.reset";
+       private static final String RESET_REPORTS_PROPERTY = "org.collectionspace.services.reports.reset";
        private static final String QUICK_BOOT_PROPERTY = "org.collectionspace.services.quickboot";
+       private static final String REPORT_PROPERTY = "report";
 
        @Override
-       public void  contextInitialized(ServletContextEvent event) {
+       public void contextInitialized(ServletContextEvent event) {
                try {
                        //
-               // This call to super instantiates and initializes our JAX-RS application class.
-               // The application class is org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication.
-               //
-                       logger.log(Level.INFO, String.format("%tc [INFO] Starting up the CollectionSpace Services' JAX-RS application.", new Date()));
+                       // This call to super instantiates and initializes our JAX-RS application class.
+                       // The application class is org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication.
+                       //
+                       logger.info("Starting up the CollectionSpace Services JAX-RS application.");
                        super.contextInitialized(event);
                        CollectionSpaceJaxRsApplication app = (CollectionSpaceJaxRsApplication)deployment.getApplication();
                        Dispatcher disp = deployment.getDispatcher();
                        disp.getDefaultContextObjects().put(ResourceMap.class, app.getResourceMap());
 
-                       String quickBoot = System.getProperty(QUICK_BOOT_PROPERTY, Boolean.FALSE.toString()); // Property can be set in the tomcat/bin/setenv.sh (or setenv.bat) file
+                       // Property can be set in the tomcat/bin/setenv.sh (or setenv.bat) file
+                       String quickBoot = System.getProperty(QUICK_BOOT_PROPERTY, Boolean.FALSE.toString());
+
                        if (Boolean.valueOf(quickBoot) == false) {
-                               String resetAuthsString = System.getProperty(RESET_AUTHORITIES_PROPERTY, Boolean.FALSE.toString()); // Property can be set in the tomcat/bin/setenv.sh (or setenv.bat) file
-                               initializeAuthorities(app.getResourceMap(), Boolean.valueOf(resetAuthsString));
+                               // The below properties can be set in the tomcat/bin/setenv.sh (or setenv.bat) file.
+                               String resetAuthsString = System.getProperty(RESET_AUTHORITIES_PROPERTY, Boolean.FALSE.toString());
+                               String resetElasticsearchIndexString = System.getProperty(RESET_ELASTICSEARCH_INDEX_PROPERTY, Boolean.FALSE.toString());
+                               String resetReportsString = System.getProperty(RESET_REPORTS_PROPERTY, Boolean.TRUE.toString());
 
-                               String resetElasticsearchIndexString = System.getProperty(RESET_ELASTICSEARCH_INDEX_PROPERTY, Boolean.FALSE.toString()); // Property can be set in the tomcat/bin/setenv.sh (or setenv.bat) file
+                               initializeAuthorities(app.getResourceMap(), Boolean.valueOf(resetAuthsString));
 
                                if (Boolean.valueOf(resetElasticsearchIndexString) == true) {
                                        resetElasticSearchIndex();
                                }
+
+                               if (Boolean.valueOf(resetReportsString) == true) {
+                                       resetReports();
+                               }
                        }
 
-                       logger.log(Level.INFO, String.format("%tc [INFO] CollectionSpace Services' JAX-RS application started.", new Date()));
+                       logger.info("CollectionSpace Services JAX-RS application started.");
                } catch (Exception e) {
                        e.printStackTrace();
                        throw new RuntimeException(e);
@@ -82,9 +113,125 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
 
        @Override
        public void contextDestroyed(ServletContextEvent event) {
-               logger.log(Level.INFO, "[INFO] Shutting down the CollectionSpace Services' JAX-RS application.");
+               logger.info("Shutting down the CollectionSpace Services JAX-RS application.");
                //Do something if needed.
-               logger.log(Level.INFO, "[INFO] CollectionSpace Services' JAX-RS application stopped.");
+               logger.info("CollectionSpace Services JAX-RS application stopped.");
+       }
+
+       public void resetReports() throws Exception {
+               logger.info("Resetting reports");
+
+               TenantBindingConfigReaderImpl tenantBindingConfigReader = ServiceMain.getInstance().getTenantBindingConfigReader();
+               Hashtable<String, TenantBindingType> tenantBindingsTable = tenantBindingConfigReader.getTenantBindings(false);
+
+               for (TenantBindingType tenantBinding : tenantBindingsTable.values()) {
+                       ServiceBindingType reportServiceBinding = null;
+
+                       for (ServiceBindingType serviceBinding : tenantBinding.getServiceBindings()) {
+                               if (serviceBinding.getName().toLowerCase().trim().equals(ReportClient.SERVICE_NAME)) {
+                                       reportServiceBinding = serviceBinding;
+
+                                       break;
+                               }
+                       }
+
+                       Set<String> reportNames = new HashSet<String>();
+
+                       if (reportServiceBinding != null) {
+                               for (PropertyType property : reportServiceBinding.getProperties()) {
+                                       for (PropertyItemType item : property.getItem()) {
+                                               if (item.getKey().equals(REPORT_PROPERTY)) {
+                                                       reportNames.add(item.getValue());
+                                               }
+                                       }
+                               }
+                       }
+
+                       if (reportNames.size() > 0) {
+                               CSpaceTenant tenant = new CSpaceTenant(tenantBinding.getId(), tenantBinding.getName());
+
+                               resetTenantReports(tenant, reportNames);
+                       }
+               }
+       }
+
+       private void resetTenantReports(CSpaceTenant tenant, Set<String> reportNames) throws Exception {
+               logger.info("Resetting reports for tenant {}", tenant.getId());
+
+               AuthZ.get().login(tenant);
+
+               CollectionSpaceJaxRsApplication app = (CollectionSpaceJaxRsApplication) deployment.getApplication();
+               ResourceMap resourceMap = app.getResourceMap();
+               ReportResource reportResource = (ReportResource) resourceMap.get(ReportClient.SERVICE_NAME);
+
+               for (String reportName : reportNames) {
+                       File reportMetadataFile = ReportResource.getReportMetadataFile(reportName);
+
+                       if (!reportMetadataFile.exists()) {
+                               logger.warn(
+                                       "Metadata file not found for report {} at {}",
+                                       reportName, reportMetadataFile.getAbsolutePath());
+
+                               continue;
+                       }
+
+                       String payload = new String(Files.readAllBytes(reportMetadataFile.toPath()));
+                       String reportFilename = reportName + ".jrxml";
+
+                       UriInfo uriInfo = new UriInfoImpl(
+                               new URI(""),
+                               new URI(""),
+                               "",
+                               "pgSz=0&filename=" + URLEncoder.encode(reportFilename, StandardCharsets.UTF_8.toString()),
+                               Arrays.asList((PathSegment) new PathSegmentImpl("", false))
+                       );
+
+                       AbstractCommonList list = reportResource.getList(uriInfo);
+
+                       if (list.getTotalItems() == 0) {
+                               logger.info("Adding report " + reportName);
+
+                               try {
+                                       reportResource.create(resourceMap, null, payload);
+                               } catch(Exception e) {
+                                       logger.error(e.getMessage(), e);
+                               }
+                       } else {
+                               for (ListItem item : list.getListItem()) {
+                                       String csid = AbstractCommonListUtils.ListItemGetCSID(item);
+
+                                       // Update an existing report iff:
+                                       // - it was created autmatically (i.e., by the SPRING_ADMIN user)
+                                       // - it was last updated automatically (i.e., by the SPRING_ADMIN user)
+                                       // - it is not soft-deleted
+
+                                       PoxPayloadOut reportPayload = reportResource.getResourceFromCsid(null, null, csid);
+                                       PayloadOutputPart corePart = reportPayload.getPart(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA);
+
+                                       String createdBy = corePart.asElement().selectSingleNode(CollectionSpaceClient.COLLECTIONSPACE_CORE_CREATED_BY).getText();
+                                       String updatedBy = corePart.asElement().selectSingleNode(CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_BY).getText();
+                                       String workflowState = corePart.asElement().selectSingleNode(CollectionSpaceClient.COLLECTIONSPACE_CORE_WORKFLOWSTATE).getText();
+
+                                       if (
+                                               createdBy.equals(AuthN.SPRING_ADMIN_USER)
+                                               && updatedBy.equals(AuthN.SPRING_ADMIN_USER)
+                                               && !workflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)
+                                       ) {
+                                               logger.info("Updating report {} with csid {}", reportName, csid);
+
+                                               try {
+                                                       reportResource.update(resourceMap, null, csid, payload);
+                                               } catch (Exception e) {
+                                                       logger.error(e.getMessage(), e);
+                                               }
+                                       } else {
+                                               logger.info(
+                                                       "Not updating report {} with csid {} - it was not auto-created, or was updated or soft-deleted",
+                                                       reportName, csid);
+                                       }
+                               }
+                       }
+               }
        }
 
        public void resetElasticSearchIndex() throws Exception {
@@ -97,7 +244,7 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
                ElasticSearchComponent es = (ElasticSearchComponent) Framework.getService(ElasticSearchService.class);
 
                for (String repositoryName : es.getRepositoryNames()) {
-                       logger.log(Level.INFO, String.format("%tc [INFO] Rebuilding Elasticsearch index for repository %s", new Date(), repositoryName));
+                       logger.info("Rebuilding Elasticsearch index for repository {}", repositoryName);
 
                        es.dropAndInitRepositoryIndex(repositoryName);
                }
@@ -118,7 +265,7 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
                                        String repositoryName = ConfigUtils.getRepositoryName(tenantBinding, servicesRepoDomainName);
                                        String docType = NuxeoUtils.getTenantQualifiedDocType(tenantBinding.getId(), serviceBinding.getObject().getName());
 
-                                       logger.log(Level.INFO, String.format("%tc [INFO] Starting Elasticsearch reindexing for docType %s in repository %s", new Date(), docType, repositoryName));
+                                       logger.info("Starting Elasticsearch reindexing for docType {} in repository {}", docType, repositoryName);
 
                                        es.runReindexingWorker(repositoryName, String.format("SELECT ecm:uuid FROM %s", docType));
                                }
@@ -137,8 +284,7 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
        for (TenantBindingType tenantBindings : tenantBindingsTable.values()) {
                        CSpaceTenant tenant = new CSpaceTenant(tenantBindings.getId(), tenantBindings.getName());
                        if (shouldInitializeAuthorities(tenant, reset) == true) {
-                               logger.log(Level.INFO, String.format("Initializing vocabularies and authorities of tenant '%s'.",
-                                               tenant.getId()));
+                               logger.info("Initializing vocabularies and authorities of tenant '{}'.", tenant.getId());
                        for (ServiceBindingType serviceBinding : tenantBindings.getServiceBindings()) {
                                AuthorityInstanceList element = serviceBinding.getAuthorityInstanceList();
                                if (element != null && element.getAuthorityInstance() != null) {
@@ -147,7 +293,7 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
                                                try {
                                                        initializeAuthorityInstance(resourceMap, authorityInstance, serviceBinding, tenant, reset);
                                                } catch (Exception e) {
-                                                       logger.log(Level.SEVERE, "Could not initialize authorities and authority terms: " + e.getMessage());
+                                                       logger.error("Could not initialize authorities and authority terms: " + e.getMessage());
                                                        throw e;
                                                }
                                        }
@@ -234,14 +380,14 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
                }
 
                if (status == Response.Status.OK.getStatusCode()) {
-                       logger.log(Level.FINE, String.format("Authority of type '%s' with the short ID of '%s' existed already.",
-                                       serviceName, authorityInstance.getTitleRef()));
+                       logger.debug("Authority of type '{}' with the short ID of '{}' existed already.",
+                                       serviceName, authorityInstance.getTitleRef());
                } else if (status == Response.Status.CREATED.getStatusCode()) {
-                       logger.log(Level.FINE, String.format("Created a new authority of type '%s' with the short ID of '%s'.",
-                                       serviceName, authorityInstance.getTitleRef()));
+                       logger.debug("Created a new authority of type '{}' with the short ID of '{}'.",
+                                       serviceName, authorityInstance.getTitleRef());
                } else {
-                       logger.log(Level.WARNING, String.format("Unknown status '%d' encountered when creating or fetching authority of type '%s' with the short ID of '%s'.",
-                                       serviceName, authorityInstance.getTitleRef()));
+                       logger.warn("Unknown status '{}' encountered when creating or fetching authority of type '{}' with the short ID of '{}'.",
+                                       status, serviceName, authorityInstance.getTitleRef());
                }
 
                //
@@ -289,8 +435,8 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
                        String xmlPayload = client.createAuthorityItemInstance(termShortId, termDisplayName);
                        try {
                                authorityResource.createAuthorityItem(resourceMap, null, authoritySpecifier, xmlPayload);
-                               logger.log(Level.FINE, String.format("Tenant:%s:Created a new term '%s:%s' in the authority of type '%s' with the short ID of '%s'.",
-                                               tenant.getName(), termDisplayName, termShortId, serviceName, authorityInstance.getTitleRef()));
+                               logger.debug("Tenant:{}:Created a new term '{}:{}' in the authority of type '{}' with the short ID of '{}'.",
+                                               tenant.getName(), termDisplayName, termShortId, serviceName, authorityInstance.getTitleRef());
                        } catch (CSWebApplicationException e) {
                                response = e.getResponse();
                                status = response.getStatus();
index ff98d369418eed91afb6c52e4c96e7e292af08f8..503d62d521b75e411865023bd282a454a1dca670 100644 (file)
@@ -96,6 +96,7 @@ public class BatchResource extends NuxeoBasedResource {
             MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
             DocumentHandler handler = createDocumentHandler(ctx);
             String docType = queryParams.getFirst(IQueryManager.SEARCH_TYPE_DOCTYPE);
+            String filename = queryParams.getFirst(IQueryManager.SEARCH_TYPE_FILENAME);
             List<String> modes = queryParams.get(IQueryManager.SEARCH_TYPE_INVOCATION_MODE);
             String whereClause = null;
             DocumentFilter documentFilter = null;
@@ -108,6 +109,13 @@ public class BatchResource extends NuxeoBasedResource {
                 documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
             }
 
+            if (filename != null && !filename.isEmpty()) {
+                whereClause = QueryManager.createWhereClauseForInvocableByFilename(
+                        common_part, filename);
+                documentFilter = handler.getDocumentFilter();
+                documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
+            }
+
             if (modes != null && !modes.isEmpty()) {
                 whereClause = QueryManager.createWhereClauseForInvocableByMode(
                                common_part, modes);
index f287539c4ca23212467262e04097bf8746d29665..3c23228e4f65a881c1f2db04d66f1d6138b13680 100644 (file)
@@ -35,17 +35,18 @@ public interface IQueryManager {
        final static String SEARCH_TERM_SEPARATOR = " ";
        final static String SEARCH_LIKE = " LIKE ";
        final static String SEARCH_ILIKE = " ILIKE ";
-    final static String SEARCH_TYPE_KEYWORDS = "keywords";
-    final static String SEARCH_TYPE_KEYWORDS_KW = "kw";
-    final static String SEARCH_TYPE_KEYWORDS_AS = "as";
-    final static String SEARCH_TYPE_PARTIALTERM = "pt";
-    final static String SEARCH_TYPE_DOCTYPE = "doctype";
-    final static String SEARCH_TYPE_INVOCATION_MODE = "mode";
-    final static String SEARCH_TYPE_INVOCATION = "inv";
+       final static String SEARCH_TYPE_KEYWORDS = "keywords";
+       final static String SEARCH_TYPE_KEYWORDS_KW = "kw";
+       final static String SEARCH_TYPE_KEYWORDS_AS = "as";
+       final static String SEARCH_TYPE_PARTIALTERM = "pt";
+       final static String SEARCH_TYPE_DOCTYPE = "doctype";
+       final static String SEARCH_TYPE_FILENAME = "filename";
+       final static String SEARCH_TYPE_INVOCATION_MODE = "mode";
+       final static String SEARCH_TYPE_INVOCATION = "inv";
        final static String SEARCH_QUALIFIER_AND = SEARCH_TERM_SEPARATOR + "AND" + SEARCH_TERM_SEPARATOR;
        final static String SEARCH_QUALIFIER_OR = SEARCH_TERM_SEPARATOR + "OR" + SEARCH_TERM_SEPARATOR;
-    final static String DEFAULT_SELECT_CLAUSE = "SELECT * FROM ";
-    final static String CSID_QUERY_PARAM = "csid";
+       final static String DEFAULT_SELECT_CLAUSE = "SELECT * FROM ";
+       final static String CSID_QUERY_PARAM = "csid";
 
 
        //
@@ -161,6 +162,16 @@ public interface IQueryManager {
         */
        public String createWhereClauseForInvocableByDocType(String schema, String docType);
 
+
+       /**
+        * Creates a filtering where clause from filename, for invocables.
+        *
+        * @param schema  the schema name for this invocable
+        * @param docType the filename
+        * @return        the where clause
+        */
+       public String createWhereClauseForInvocableByFilename(String schema, String filename);
+
        /**
         * Creates a filtering where clause from invocation mode, for invocables.
         *
index 5d29790e85e0d28dd9aa1aaba2b7ffc7d69503ed..8071b49362dff11d806da69e67592a038cfca770 100644 (file)
@@ -1,13 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <tenant:TenantBindingConfig
-        xmlns:merge="http://xmlmerge.el4j.elca.ch"
-        xmlns:tenant="http://collectionspace.org/services/config/tenant">
+               xmlns:merge="http://xmlmerge.el4j.elca.ch"
+               xmlns:tenant="http://collectionspace.org/services/config/tenant">
 
-    <!-- Add your changes, if any, within the following tag pair. -->
-    <!-- The value of the 'id' attribute, below, should match the corresponding -->
-    <!-- value in cspace/config/services/tenants/publicart-tenant-bindings-proto.xml -->
+       <!-- Add your changes, if any, within the following tag pair. -->
+       <!-- The value of the 'id' attribute, below, should match the corresponding -->
+       <!-- value in cspace/config/services/tenants/publicart-tenant-bindings-proto.xml -->
 
-    <tenant:tenantBinding id="5000">
-    </tenant:tenantBinding>
+       <tenant:tenantBinding id="5000">
+               <tenant:serviceBindings merge:matcher="id" id="Reports">
+                       <service:properties xmlns:service="http://collectionspace.org/services/config/service" xmlns:types="http://collectionspace.org/services/config/types">
+                               <types:item merge:matcher="skip" merge:action="insert">
+                                       <types:key>report</types:key>
+                                       <types:value>obj_current_place_details</types:value>
+                               </types:item>
+                               <types:item merge:matcher="skip" merge:action="insert">
+                                       <types:key>report</types:key>
+                                       <types:value>tombstone_with_budget</types:value>
+                               </types:item>
+                       </service:properties>
+               </tenant:serviceBindings>
+       </tenant:tenantBinding>
 
 </tenant:TenantBindingConfig>
index 7c33d2cfcec9ad47f7ccbc03b47b4a2bba01a434..19bf9dc3af5dd87cfe4fb02ef3f60df7292cae68 100644 (file)
                        <service:initHandler xmlns:service="http://collectionspace.org/services/config/service">
                                <service:classname>org.collectionspace.services.report.nuxeo.ReportPostInitHandler</service:classname>
                                <service:params>
-                   <service:property>
-                           <service:key>readerRoleName</service:key>
-                           <service:value>reader</service:value>
-                   </service:property>
+                                       <service:property>
+                                               <service:key>readerRoleName</service:key>
+                                               <service:value>reader</service:value>
+                                       </service:property>
                                </service:params>
                        </service:initHandler>
-                       <service:properties xmlns:service="http://collectionspace.org/services/config/service">
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:displayName>XML</types:displayName>
-                         <types:value>application/xml</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:displayName>HTML</types:displayName>
-                         <types:value>text/html</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:displayName>PDF</types:displayName>
-                         <types:value>application/pdf</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:value>text/csv</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:value>text/tab-separated-values</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:value>application/msword</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:value>application/vnd.openxmlformats-officedocument.wordprocessingml.document</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:value>application/vnd.ms-excel</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:value>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:value>application/vnd.ms-powerpoint</types:value>
-                       </types:item>
-                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>outputMIME</types:key>
-                         <types:value>application/vnd.openxmlformats-officedocument.presentationml.presentation</types:value>
-                       </types:item>
-               </service:properties>
+                       <service:properties xmlns:service="http://collectionspace.org/services/config/service" xmlns:types="http://collectionspace.org/services/config/types">
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:displayName>XML</types:displayName>
+                                       <types:value>application/xml</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:displayName>HTML</types:displayName>
+                                       <types:value>text/html</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:displayName>PDF</types:displayName>
+                                       <types:value>application/pdf</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:value>text/csv</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:value>text/tab-separated-values</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:value>application/msword</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:value>application/vnd.openxmlformats-officedocument.wordprocessingml.document</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:value>application/vnd.ms-excel</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:value>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:value>application/vnd.ms-powerpoint</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>outputMIME</types:key>
+                                       <types:value>application/vnd.openxmlformats-officedocument.presentationml.presentation</types:value>
+                               </types:item>
+
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>accessions</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>acq_basic</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>Acq_List_Basic</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>box_list</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>CC_List_Basic</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>coreAcquisition</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>coreGroupObject</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>coreIntake</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>coreLoanIn</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>coreLoanOut</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>coreObjectExit</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>deaccessions</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>deed_of_gift</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>Exhibition_List_Basic</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>Group_List_Basic</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>incoming_loan</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>incoming_loan_letter</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>LoansIn_List_Basic</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>LoansOut_List_Basic</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>obj_computed_location</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>object_valuation</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>outgoing_loan_letter</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>referral</types:value>
+                               </types:item>
+                               <types:item>
+                                       <types:key>report</types:key>
+                                       <types:value>systematicInventory</types:value>
+                               </types:item>
+                       </service:properties>
                        <service:object xmlns:service="http://collectionspace.org/services/config/service" name="Report"
                                version="1.0">
                                <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="reports-system"
index f53394013d2cc66e9de1a3b57073313ffc840c80..8de9f311db3d4d658808cb68003d5f78ad605ddd 100644 (file)
@@ -109,6 +109,17 @@ public class QueryManager {
                return queryManager.createWhereClauseForInvocableByDocType(schema, docType);
        }
 
+       /**
+        * Creates a filtering where clause from filename, for invocables.
+        *
+        * @param schema  the schema name for this invocable
+        * @param docType the filename
+        * @return        the where clause
+        */
+       static public String createWhereClauseForInvocableByFilename(String schema, String filename) {
+               return queryManager.createWhereClauseForInvocableByFilename(schema, filename);
+       }
+
        /**
         * Creates a filtering where clause from invocation mode, for invocables.
         *
index 65fa50e7cea14902761cf5e8d9439b520bcefd32..4bc2e39c156f3e71b9041d433dea727de270772d 100644 (file)
@@ -280,18 +280,44 @@ public class QueryManagerNuxeoImpl implements IQueryManager {
         * @return the string
         */
        @Override
-       public String createWhereClauseForInvocableByDocType(String schema,
-                       String docType) {
-               String trimmed = (docType == null) ? "" : docType.trim();
+       public String createWhereClauseForInvocableByDocType(String schema, String docType) {
+               String trimmed = sanitizeNXQLString(docType);
+
                if (trimmed.isEmpty()) {
                        throw new RuntimeException("No docType specified.");
                }
+
                if (schema == null || schema.isEmpty()) {
                        throw new RuntimeException("No match schema specified.");
                }
-               String wClause = schema + ":" + InvocableJAXBSchema.FOR_DOC_TYPES
-                               + " = '" + trimmed + "'";
-               return wClause;
+
+               String whereClause = schema + ":" + InvocableJAXBSchema.FOR_DOC_TYPES + " = '" + trimmed + "'";
+
+               return whereClause;
+       }
+
+       /**
+        * Creates a filtering where clause from filename, for invocables.
+        *
+        * @param schema  the schema name for this invocable
+        * @param docType the filename
+        * @return        the where clause
+        */
+       @Override
+       public String createWhereClauseForInvocableByFilename(String schema, String filename) {
+               String trimmed = sanitizeNXQLString(filename);
+
+               if (trimmed.isEmpty()) {
+                       throw new RuntimeException("No filename specified.");
+               }
+
+               if (schema == null || schema.isEmpty()) {
+                       throw new RuntimeException("No match schema specified.");
+               }
+
+               String whereClause = schema + ":" + InvocableJAXBSchema.FILENAME + " = '" + trimmed + "'";
+
+               return whereClause;
        }
 
        /**
@@ -338,6 +364,13 @@ public class QueryManagerNuxeoImpl implements IQueryManager {
                return "";
        }
 
+       private String sanitizeNXQLString(String input) {
+               String trimmed = (input == null) ? "" : input.trim();
+               String escaped = unescapedSingleQuote.matcher(trimmed).replaceAll("\\\\'");
+
+               return escaped;
+       }
+
        /**
         * @param input
         * @return true if there were any chars filtered, that will require a backup
@@ -389,5 +422,4 @@ public class QueryManagerNuxeoImpl implements IQueryManager {
 
                return NuxeoUtils.getByNameWhereClause(csid);
        }
-
 }
index 0a71f85c990512a1f7a1c314675a98e35335316d..161e11a87a330b184ada5db1668ee7ebdcbceca9 100644 (file)
@@ -1,9 +1,10 @@
 /**
- * 
+ *
  */
 package org.collectionspace.services.jaxb;
 
 public interface InvocableJAXBSchema {
+    final static String FILENAME = "filename";
     final static String FOR_DOC_TYPES = "forDocTypes";
     final static String SUPPORTS_SINGLE_DOC = "supportsSingleDoc";
     final static String SUPPORTS_DOC_LIST = "supportsDocList";
index 0456a6a89dc06e0f9a1c80f1d194d198af9e99cf..2148d169e00d99f201aedba64d19342c7e10f4e2 100644 (file)
@@ -73,7 +73,7 @@
             <arg value="${mvn.opts}" />
         </exec>
     </target>
-    
+
     <target name="clean" depends="clean-unix,clean-windows"
   description="Delete target directories" >
         <delete dir="${build}"/>
             <arg value="${mvn.opts}" />
         </exec>
     </target>
-    
-    <!-- 
+
+    <!--
          Preserve the legacy name for this target, while noting that
          legacy name is no longer descriptive of its purpose.
      -->
     <target name="deploy_jasper_samples" depends="deploy_report_files" />
 
     <target name="deploy_report_files"
-        description="Deploy report files">
+        description="Deploy report files and metadata files">
         <copy todir="${jee.server.cspace}/cspace/reports" overwrite="true">
             <fileset dir="${basedir}/jasper-cs-report/src/main/resources"
-                includes="*.jrxml"/>
+                includes="*.jrxml,*.xml"/>
         </copy>
     </target>
-    
+
     <target name="undeploy_report_files"
       depends="undeploy_source_report_files,undeploy_compiled_report_files"
       description="Undeploy report files">
     </target>
-    
+
        <!-- Removes only the source reports that originated from the source directory.  Ones added
                manually remain.
        -->
     <target name="undeploy_source_report_files"
-      description="Undeploy source (.jrxml) report files">
+      description="Undeploy source (.jrxml) report files and metadata (.xml) files">
       <delete failonerror="false">
-        <fileset dir="${jee.server.cspace}/cspace/reports" includes="*.jrxml">
+        <fileset dir="${jee.server.cspace}/cspace/reports" includes="*.jrxml,*.xml">
                        <present targetdir="${basedir}/jasper-cs-report/src/main/resources" />
                </fileset>
       </delete>
     </target>
-    
+
     <target name="undeploy_compiled_report_files"
       description="Undeploy compiled (.jasper) report files">
       <delete failonerror="false">
     <target name="deploy" depends="install,deploy_report_files"
       description="Deploy report-related artifacts">
       <!--
-        The following ant call is obsolete.  The Nuxeo artifacts are now created 
+        The following ant call is obsolete.  The Nuxeo artifacts are now created
         and deployed using the "csmake" tool.
         <ant antfile="nuxeo-platform-cs-report/build.xml" target="deploy" inheritall="false"/>
       -->
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/Acq_List_Basic.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/Acq_List_Basic.xml
new file mode 100644 (file)
index 0000000..d7d92ac
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Acquisition Basic List</name>
+    <notes>Catalog info for objects related to an acquisition record. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Acquisition</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>Acq_List_Basic.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/CC_List_Basic.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/CC_List_Basic.xml
new file mode 100644 (file)
index 0000000..2d505a8
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Condition Check Basic List</name>
+    <notes>Catalog info for objects related to a condition check record. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Conditioncheck</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>CC_List_Basic.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/Exhibition_List_Basic.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/Exhibition_List_Basic.xml
new file mode 100644 (file)
index 0000000..33fd557
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Exhibition Basic List</name>
+    <notes>Catalog info for objects related to a exhibition record. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Exhibition</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>Exhibition_List_Basic.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/Group_List_Basic.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/Group_List_Basic.xml
new file mode 100644 (file)
index 0000000..1a48067
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Group Basic List</name>
+    <notes>Catalog info for objects related to a group record. Runs on a group of objects, a single object, or selected objects.</notes>
+    <forDocTypes>
+      <forDocType>CollectionObject</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>true</supportsDocList>
+    <supportsGroup>true</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>Group_List_Basic.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/LoansIn_List_Basic.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/LoansIn_List_Basic.xml
new file mode 100644 (file)
index 0000000..a6f4885
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Loan In Basic List</name>
+    <notes>Catalog info for objects related to a loan in record. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Loanin</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>LoansIn_List_Basic.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/LoansOut_List_Basic.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/LoansOut_List_Basic.xml
new file mode 100644 (file)
index 0000000..6f1c661
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Loan Out Basic List</name>
+    <notes>Catalog info for objects related to a loan out record. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Loanout</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>LoansOut_List_Basic.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/acq_basic.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/acq_basic.xml
new file mode 100644 (file)
index 0000000..0af836c
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Acquisition Summary</name>
+    <notes>An acquisition summary report. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Acquisition</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>acq_basic.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/coreAcquisition.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/coreAcquisition.xml
new file mode 100644 (file)
index 0000000..04e6cad
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Acquisition Ethnographic Object List</name>
+    <notes>Core acquisition report. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Acquisition</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>coreAcquisition.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/coreGroupObject.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/coreGroupObject.xml
new file mode 100644 (file)
index 0000000..aff1b74
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Group Object Ethnographic Object List</name>
+    <notes>Core group object report. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Group</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>coreGroupObject.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/coreIntake.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/coreIntake.xml
new file mode 100644 (file)
index 0000000..f81674f
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Intake Ethnographic Object List</name>
+    <notes>Core intake report. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Intake</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>coreIntake.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/coreLoanIn.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/coreLoanIn.xml
new file mode 100644 (file)
index 0000000..39c9173
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Loan In Ethnographic Object List</name>
+    <notes>Core loan in report. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Loanin</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>coreLoanIn.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/coreLoanOut.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/coreLoanOut.xml
new file mode 100644 (file)
index 0000000..5567a43
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Loan Out Ethnographic Object List</name>
+    <notes>Core loan out report. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>Loanout</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>coreLoanOut.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/coreObjectExit.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/coreObjectExit.xml
new file mode 100644 (file)
index 0000000..56e3812
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Object Exit Ethnographic Object List</name>
+    <notes>Core object exit report. Runs on a single record only.</notes>
+    <forDocTypes>
+      <forDocType>ObjectExit</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>true</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>false</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>coreObjectExit.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/object_valuation.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/object_valuation.xml
new file mode 100644 (file)
index 0000000..8d59920
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Object Valuation</name>
+    <notes>Returns latest valuation information for selected objects. Runs on selected objects, or all objects.</notes>
+    <forDocTypes>
+      <forDocType>CollectionObject</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>false</supportsSingleDoc>
+    <supportsDocList>true</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>true</supportsNoContext>
+    <outputMIME>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</outputMIME>
+    <filename>object_valuation.jrxml</filename>
+  </ns2:reports_common>
+</document>
diff --git a/services/report/3rdparty/jasper-cs-report/src/main/resources/systematicInventory.xml b/services/report/3rdparty/jasper-cs-report/src/main/resources/systematicInventory.xml
new file mode 100644 (file)
index 0000000..ea5b90e
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<document name="report">
+  <ns2:reports_common xmlns:ns2="http://collectionspace.org/services/report">
+    <name>Systematic Inventory</name>
+    <notes>Generate a checklist for performing an inventory on a range of storage locations. Runs on all records, using the provided start and end locations.</notes>
+    <forDocTypes>
+      <forDocType>Locationitem</forDocType>
+    </forDocTypes>
+    <supportsSingleDoc>false</supportsSingleDoc>
+    <supportsDocList>false</supportsDocList>
+    <supportsGroup>false</supportsGroup>
+    <supportsNoContext>true</supportsNoContext>
+    <outputMIME>application/pdf</outputMIME>
+    <filename>systematicInventory.jrxml</filename>
+  </ns2:reports_common>
+</document>
index 9062e150e8ed7540b7867499ae1d30ee4cacf229..4434075bc6feec64b799983d96b6d409218d6db6 100644 (file)
@@ -1,4 +1,4 @@
-/**    
+/**
  * ReportClient.java
  *
  * {Purpose of This Class}
@@ -38,63 +38,60 @@ import org.collectionspace.services.report.ReportsCommon;
  * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684
  */
 public class ReportClient extends AbstractCommonListPoxServiceClientImpl<ReportProxy, ReportsCommon> {
-
-    public static final String SERVICE_NAME = "reports";
-    public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
-    public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+       public static final String SERVICE_NAME = "reports";
+       public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
+       public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
        public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
-    public static final String PDF_MIME_TYPE = "application/pdf";
-    public static final String CSV_MIME_TYPE = "text/csv";
-    public static final String TSV_MIME_TYPE = "text/tab-separated-values";
-    public static final String MSWORD_MIME_TYPE = "application/msword";
-    public static final String OPEN_DOCX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
-    public static final String MSEXCEL_MIME_TYPE = "application/vnd.ms-excel";
-    public static final String OPEN_XLSX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
-    public static final String MSPPT_MIME_TYPE = "application/vnd.ms-powerpoint";
-    public static final String OPEN_PPTX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
-    public static final String DEFAULT_REPORT_OUTPUT_MIME = PDF_MIME_TYPE;
-    public static final String COMPILED_REPORT_EXTENSION = ".jasper";
-    public static final String REPORT_DECSRIPTION_EXTENSION = ".jrxml";
+       public static final String PDF_MIME_TYPE = "application/pdf";
+       public static final String CSV_MIME_TYPE = "text/csv";
+       public static final String TSV_MIME_TYPE = "text/tab-separated-values";
+       public static final String MSWORD_MIME_TYPE = "application/msword";
+       public static final String OPEN_DOCX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
+       public static final String MSEXCEL_MIME_TYPE = "application/vnd.ms-excel";
+       public static final String OPEN_XLSX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
+       public static final String MSPPT_MIME_TYPE = "application/vnd.ms-powerpoint";
+       public static final String OPEN_PPTX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
+       public static final String DEFAULT_REPORT_OUTPUT_MIME = PDF_MIME_TYPE;
+       public static final String COMPILED_REPORT_EXTENSION = ".jasper";
+       public static final String REPORT_DECSRIPTION_EXTENSION = ".jrxml";
+       public static final String REPORT_METADATA_EXTENSION = ".xml";
 
-    public ReportClient() throws Exception {
+       public ReportClient() throws Exception {
                super();
        }
 
-    public ReportClient(String clientPropertiesFilename) throws Exception {
+       public ReportClient(String clientPropertiesFilename) throws Exception {
                super(clientPropertiesFilename);
        }
 
        @Override
-    public String getServiceName() {
-        return SERVICE_NAME;
-    }
+       public String getServiceName() {
+               return SERVICE_NAME;
+       }
 
-    @Override
+       @Override
        public String getServicePathComponent() {
-        return SERVICE_PATH_COMPONENT;
-    }
+               return SERVICE_PATH_COMPONENT;
+       }
 
        @Override
        public Class<ReportProxy> getProxyClass() {
                return ReportProxy.class;
        }
-       
+
        /*
         * Proxied service calls
         */
-       
-    /**
-     * @return
-     * @see org.collectionspace.services.client.ReportProxy#getReport()
-     */
-    public Response readListFiltered(
-                       String docType, String mode) {
-        return getProxy().readListFiltered(docType, mode);
-    }
-    
-    public Response publishReport(String csid,
-               InvocationContext invContext) {
-       return getProxy().publishReport(csid, invContext);
-    }
-    
+
+       /**
+        * @return
+        * @see org.collectionspace.services.client.ReportProxy#getReport()
+        */
+       public Response readListFiltered(String docType, String mode) {
+               return getProxy().readListFiltered(docType, mode);
+       }
+
+       public Response publishReport(String csid, InvocationContext invContext) {
+               return getProxy().publishReport(csid, invContext);
+       }
 }
index 74b2cde66de237d62dbcbab15c853eb62f561642..2092608ddf694c2118d5f862f73b7dadde1ac5e1 100644 (file)
@@ -23,6 +23,7 @@
  */
 package org.collectionspace.services.report;
 
+import java.io.File;
 import java.io.InputStream;
 import java.util.List;
 
@@ -37,7 +38,9 @@ import org.collectionspace.services.client.ReportClient;
 import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.NuxeoBasedResource;
 import org.collectionspace.services.common.ResourceMap;
+import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.ServiceMessages;
+import org.collectionspace.services.common.api.JEEServerDeployment;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
@@ -68,6 +71,8 @@ import javax.ws.rs.core.Response.Status;
 public class ReportResource extends NuxeoBasedResource {
     final Logger logger = LoggerFactory.getLogger(ReportResource.class);
 
+    private static String REPORTS_FOLDER = "reports";
+
     @Override
     protected String getVersionString() {
        final String lastChangeRevision = "$LastChangedRevision: 1982 $";
@@ -94,6 +99,7 @@ public class ReportResource extends NuxeoBasedResource {
             MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
             DocumentHandler handler = createDocumentHandler(ctx);
             String docType = queryParams.getFirst(IQueryManager.SEARCH_TYPE_DOCTYPE);
+            String filename = queryParams.getFirst(IQueryManager.SEARCH_TYPE_FILENAME);
             List<String> modes = queryParams.get(IQueryManager.SEARCH_TYPE_INVOCATION_MODE);
             String whereClause = null;
             DocumentFilter documentFilter = null;
@@ -104,6 +110,12 @@ public class ReportResource extends NuxeoBasedResource {
                 documentFilter = handler.getDocumentFilter();
                 documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
             }
+            if (filename != null && !filename.isEmpty()) {
+                whereClause = QueryManager.createWhereClauseForInvocableByFilename(
+                        common_part, filename);
+                documentFilter = handler.getDocumentFilter();
+                documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
+            }
             if (modes != null && !modes.isEmpty()) {
                 whereClause = QueryManager.createWhereClauseForInvocableByMode(
                                common_part, modes);
@@ -329,4 +341,29 @@ public class ReportResource extends NuxeoBasedResource {
         return result;
     }
 
+    private static String getReportBasePath() {
+        return (
+            ServiceMain.getInstance().getServerRootDir() +
+            File.separator +
+            JEEServerDeployment.CSPACE_DIR_NAME +
+            File.separator +
+            REPORTS_FOLDER +
+            File.separator
+        );
+    }
+
+    public static File getReportSourceFile(String reportName) {
+        return new File(
+            getReportBasePath() + reportName + ReportClient.REPORT_DECSRIPTION_EXTENSION);
+    }
+
+    public static File getReportCompiledFile(String reportName) {
+        return new File(
+            getReportBasePath() + reportName + ReportClient.COMPILED_REPORT_EXTENSION);
+    }
+
+    public static File getReportMetadataFile(String reportName) {
+        return new File(
+            getReportBasePath() + reportName + ReportClient.REPORT_METADATA_EXTENSION);
+    }
 }
index 867d8d90d80c41f08632ce6da805b3c86f676e3c..9e8de598a0ac5c60bd7dbad7e0b5b9c1146cf74f 100644 (file)
@@ -71,6 +71,7 @@ import org.collectionspace.services.report.ResourceActionGroupList;
 import org.collectionspace.services.report.ReportsCommon.ForRoles;
 import org.collectionspace.services.report.MIMEType;
 import org.collectionspace.services.report.MIMETypeItemType;
+import org.collectionspace.services.report.ReportResource;
 import org.collectionspace.services.report.ReportsCommon;
 import org.collectionspace.services.report.ReportsOuputMimeList;
 import org.collectionspace.services.client.PoxPayloadIn;
@@ -117,7 +118,6 @@ public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler<Report
                private final Logger logger = LoggerFactory.getLogger(ReportDocumentModelHandler.class);
 
                private static final Pattern INVALID_CSID_PATTERN = Pattern.compile("[^\\w\\-]");
-    private static String REPORTS_FOLDER = "reports";
     private static String CSID_LIST_SEPARATOR = ",";
 
     private static String REPORTS_STD_CSID_PARAM = "csid";
@@ -346,52 +346,51 @@ public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler<Report
 
        }
 
-    private InputStream buildReportResult(String reportCSID,
-               HashMap<String, Object> params, String reportFileName, String outputMimeType, StringBuffer outReportFileName)
-                               throws Exception {
-               Connection conn = null;
-               InputStream result = null;
+    private InputStream buildReportResult(
+                       String reportCSID,
+                       HashMap<String, Object> params,
+                       String reportFileName,
+                       String outputMimeType,
+                       StringBuffer outReportFileName
+               ) throws Exception {
+
+                       Connection conn = null;
+                       InputStream result = null;
 
        try {
-               String fileNameBase = Tools.getFilenameBase(reportFileName);
-               String compiledReportFilename = fileNameBase+ReportClient.COMPILED_REPORT_EXTENSION;
-               String reportDescriptionFilename = fileNameBase+ReportClient.REPORT_DECSRIPTION_EXTENSION;
-
-                       String basePath = ServiceMain.getInstance().getServerRootDir() +
-                                                               File.separator + JEEServerDeployment.CSPACE_DIR_NAME +
-                                                               File.separator + REPORTS_FOLDER +
-                                                               // File.separator + tenantName +
-                                                               File.separator; // + reportFileName;
-
-                       String compiledFilePath = basePath+compiledReportFilename;
-                       File f = new File(compiledFilePath);
-                       if(!f.exists()) { // Need to compile the file
-                               // First verify that there is a source file.
-                               String sourceFilePath = basePath+reportDescriptionFilename;
-                               File f2 = new File(sourceFilePath);
-                               if(!f2.exists()) { // Missing source file - error!
-                                       logger.error("Report for csid={} is missing the specified source file: {}",
-                                                                       reportCSID, sourceFilePath);
-                                       throw new RuntimeException("Report is missing the specified source file!");
-                               }
+                               String reportName = Tools.getFilenameBase(reportFileName);
+                               File reportCompiledFile = ReportResource.getReportCompiledFile(reportName);
 
-                               logger.info("Report for csid={} is not compiled. Compiling first, and saving to: {}",
-                                       reportCSID, compiledFilePath);
+                               if (!reportCompiledFile.exists()) {
+                                       // Need to compile the file.
 
-                               JasperDesign design = JRXmlLoader.load(sourceFilePath);
+                                       File reportSourceFile = ReportResource.getReportSourceFile(reportName);
 
-                               design.setScriptletClass("org.collectionspace.services.report.jasperreports.CSpaceReportScriptlet");
+                                       if(!reportSourceFile.exists()) {
+                                               logger.error("Report for csid={} is missing source file: {}",
+                                                               reportCSID, reportSourceFile.getAbsolutePath());
 
-                               JasperCompileManager.compileReportToFile(design, compiledFilePath);
-                       }
+                                               throw new RuntimeException("Report is missing source file");
+                                       }
 
-                       conn = getConnection();
+                                       logger.info("Report for csid={} is not compiled. Compiling first, and saving to: {}",
+                                                       reportCSID, reportCompiledFile.getAbsolutePath());
 
-            if (logger.isTraceEnabled()) {
-               logger.trace("ReportResource for csid=" + reportCSID
-                               +" output as "+outputMimeType+" using report file: "+compiledFilePath);
-            }
-                       FileInputStream fileStream = new FileInputStream(compiledFilePath);
+                                       JasperDesign design = JRXmlLoader.load(reportSourceFile.getAbsolutePath());
+
+                                       design.setScriptletClass("org.collectionspace.services.report.jasperreports.CSpaceReportScriptlet");
+
+                                       JasperCompileManager.compileReportToFile(design, reportCompiledFile.getAbsolutePath());
+                               }
+
+                               conn = getConnection();
+
+                               if (logger.isTraceEnabled()) {
+                                       logger.trace("ReportResource for csid=" + reportCSID
+                                                       + " output as " + outputMimeType + " using report file: " + reportCompiledFile.getAbsolutePath());
+                               }
+
+                       FileInputStream fileStream = new FileInputStream(reportCompiledFile);
 
                        // export report to pdf and build a response with the bytes
                        //JasperExportManager.exportReportToPdf(jasperprint);