]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-889: Allow predicates in includeField xpaths for csv export.
authorRay Lee <ray.lee@lyrasis.org>
Tue, 28 Jul 2020 03:54:03 +0000 (23:54 -0400)
committerRay Lee <ray.lee@lyrasis.org>
Tue, 28 Jul 2020 03:54:03 +0000 (23:54 -0400)
services/export/service/src/main/java/org/collectionspace/services/export/CsvExportWriter.java

index 3630f356a7295fce33781789ad553682b38f7517..bcdb38948d2fa2b567b6454272690956b65596e3 100644 (file)
@@ -1,9 +1,7 @@
 package org.collectionspace.services.export;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -22,14 +20,11 @@ import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.invocable.Field;
 import org.collectionspace.services.common.invocable.InvocationContext;
 import org.collectionspace.services.config.service.ServiceBindingType;
-import org.collectionspace.services.config.service.ServiceObjectType;
 import org.dom4j.Element;
-import org.dom4j.Namespace;
 import org.dom4j.Node;
-import org.dom4j.VisitorSupport;
 
 public class CsvExportWriter extends AbstractExportWriter {
-       private static final Pattern VALID_FIELD_XPATH_PATTERN = Pattern.compile("^\\w+:(\\w+\\/)*(\\w+)$");
+       private static final Pattern VALID_FIELD_XPATH_PATTERN = Pattern.compile("^\\w+:(\\w+\\/)*(\\w+)(\\[.*\\])?$");
        private static final String VALUE_DELIMITER_PARAM_NAME = "delimiter";
 
        private CSVPrinter csvPrinter;
@@ -148,7 +143,7 @@ public class CsvExportWriter extends AbstractExportWriter {
                                else {
                                        textValue = node.getText();
 
-                                       boolean isRefName = isRefField(docType, partName, fieldName);
+                                       boolean isRefName = isRefField(docType, partName, fieldName.replaceFirst("\\[.*\\]", ""));
 
                                        if (isRefName && StringUtils.isNotEmpty(textValue)) {
                                                textValue = RefNameUtils.getDisplayName(textValue);