extended controller to enable feature export
authorAlexander Oppermann <a.oppermann@bgbm.org>
Mon, 2 Feb 2015 15:24:24 +0000 (15:24 +0000)
committerAlexander Oppermann <a.oppermann@bgbm.org>
Mon, 2 Feb 2015 15:24:24 +0000 (15:24 +0000)
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/csv/redlist/demo/CsvDemoExport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/csv/redlist/demo/CsvDemoExportConfigurator.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/checklist/ChecklistDemoController.java

index f29e0a3d17a5a79d5b6a0e9d9049d89c893f0611..29c8e23dde17b27a15eecde9667f0cddf991282d 100644 (file)
@@ -19,6 +19,7 @@ import java.util.List;
 import java.util.Set;\r
 import java.util.UUID;\r
 \r
+import org.apache.commons.lang.StringUtils;\r
 import org.apache.log4j.Logger;\r
 import org.springframework.stereotype.Component;\r
 import org.springframework.transaction.TransactionStatus;\r
@@ -513,9 +514,13 @@ public class CsvDemoExport extends CsvDemoBase {
                        RelationshipTermBase<?> type,\r
                        boolean isProParte,\r
                        boolean isPartial) {\r
-               if (type == null){\r
-                       record.setTaxonomicStatus(name.getNomenclaturalCode().acceptedTaxonStatusLabel());\r
-               }else{\r
+               if (type == null && name.getNomenclaturalCode()!= null && name.getNomenclaturalCode().acceptedTaxonStatusLabel() != null){\r
+                       String acceptedTaxonStatusLabel = name.getNomenclaturalCode().acceptedTaxonStatusLabel();\r
+                       if(StringUtils.isEmpty(acceptedTaxonStatusLabel)){\r
+                               acceptedTaxonStatusLabel="";\r
+                       }\r
+                       record.setTaxonomicStatus(acceptedTaxonStatusLabel);\r
+               }else if(name.getNomenclaturalCode() != null && name.getNomenclaturalCode().synonymStatusLabel() != null){\r
                        String status = name.getNomenclaturalCode().synonymStatusLabel();\r
                        if (type.equals(SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF())){\r
                                status = "heterotypicSynonym";\r
index 94494a070caaec2fc92af9776125f5b3ff64cabd..89365b138cfdc5e0749b07b7f3f8739de2537805 100644 (file)
@@ -111,7 +111,7 @@ public class CsvDemoExportConfigurator extends XmlExportConfiguratorBase<CsvDemo
         * a preselection for available fields. One can still\r
         * select fields manually.\r
         * <p><p>\r
-        * Only one of the parameter should be true, otherwise you\r
+        * Only one of the parameter should be true, otherwise\r
         * all fields are set to true and will be exported.\r
         * <p><p>\r
         * In future this function might be removed.\r
index 49d473f3d48a56e62ca0f02895769d200d103a15..6a3f47c486b60fa6caebd7fc671ea107c3ac619f 100644 (file)
@@ -205,7 +205,7 @@ public class ChecklistDemoController extends AbstractController implements Resou
 \r
             List<CsvDemoRecord> recordList = new ArrayList<CsvDemoRecord>();\r
 \r
-            CsvDemoExportConfigurator config = setTaxExportConfigurator(null ,classificationUUID, null, null, null);\r
+            CsvDemoExportConfigurator config = setTaxExportConfigurator(null ,classificationUUID, null, null, null, false, false);\r
             config.setPageSize(pagerParams.getPageSize());\r
             config.setPageNumber(pagerParams.getPageIndex());\r
             config.setRecordList(recordList);\r
@@ -241,8 +241,8 @@ public class ChecklistDemoController extends AbstractController implements Resou
     public synchronized ModelAndView doExportRedlist(\r
             @RequestParam(value = "features", required = false) final UuidList featureUuids,\r
             @RequestParam(value = "clearCache", required = false) final boolean clearCache,\r
-            @RequestParam(value = "demoExport", required = false) boolean demoExport,\r
-            @RequestParam(value = "conceptExport", required = false) boolean conceptExport,\r
+            @RequestParam(value = "demoExport", required = false) final boolean demoExport,\r
+            @RequestParam(value = "conceptExport", required = false) final boolean conceptExport,\r
             @RequestParam(value = "classification", required = false) final String classificationUUID,\r
             @RequestParam(value = "area", required = false) final UuidList areas,\r
             @RequestParam(value = "downloadTokenValueId", required = false) final String downloadTokenValueId,\r
@@ -288,7 +288,7 @@ public class ChecklistDemoController extends AbstractController implements Resou
                             } catch (IOException e) {\r
                                 logger.info("Could not create file "+ e);\r
                             }\r
-                            performExport(cacheFile, featureUuids, classificationUUID, areas, downloadTokenValueId, origin, response, progressMonitorController.getMonitor(indexMonitorUuid));\r
+                            performExport(cacheFile, featureUuids, classificationUUID, areas, downloadTokenValueId, demoExport, conceptExport, origin, response, progressMonitorController.getMonitor(indexMonitorUuid));\r
                         }\r
                     };\r
                     if (priority == null) {\r
@@ -365,16 +365,18 @@ public class ChecklistDemoController extends AbstractController implements Resou
      * in system temp directory.\r
      *\r
      * @param downloadTokenValueId\r
+     * @param conceptExport \r
+     * @param demoExport \r
      * @param response\r
      * @param byteArrayOutputStream\r
      * @param config\r
      * @param defaultExport\r
      */\r
     private void performExport(File cacheFile, UuidList featureUuids,String classificationUUID, UuidList areas,\r
-            String downloadTokenValueId, String origin, HttpServletResponse response, IRestServiceProgressMonitor progressMonitor) {\r
+            String downloadTokenValueId, boolean demoExport, boolean conceptExport, String origin, HttpServletResponse response, IRestServiceProgressMonitor progressMonitor) {\r
 \r
         progressMonitor.subTask("configure export");\r
-        CsvDemoExportConfigurator config = setTaxExportConfigurator(cacheFile, classificationUUID, featureUuids, areas, progressMonitor);\r
+        CsvDemoExportConfigurator config = setTaxExportConfigurator(cacheFile, classificationUUID, featureUuids, areas, progressMonitor, demoExport, conceptExport);\r
         CdmApplicationAwareDefaultExport<?> defaultExport = (CdmApplicationAwareDefaultExport<?>) appContext.getBean("defaultExport");\r
         progressMonitor.subTask("invoke export");\r
         defaultExport.invoke(config);  //triggers export\r
@@ -392,9 +394,11 @@ public class ChecklistDemoController extends AbstractController implements Resou
      * @param areas\r
      * @param byteArrayOutputStream pass-through the stream to write out the data later.\r
      * @param progressMonitor\r
+     * @param conceptExport \r
+     * @param demoExport \r
      * @return the CsvTaxExportConfiguratorRedlist config\r
      */\r
-    private CsvDemoExportConfigurator setTaxExportConfigurator(File cacheFile, String classificationUUID, UuidList featureUuids, UuidList areas, IRestServiceProgressMonitor progressMonitor) {\r
+    private CsvDemoExportConfigurator setTaxExportConfigurator(File cacheFile, String classificationUUID, UuidList featureUuids, UuidList areas, IRestServiceProgressMonitor progressMonitor, boolean demoExport, boolean conceptExport) {\r
 \r
         @SuppressWarnings({ "unchecked", "rawtypes" })\r
         Set<UUID> classificationUUIDS = new HashSet\r
@@ -423,7 +427,11 @@ public class ChecklistDemoController extends AbstractController implements Resou
         config.setHasHeaderLines(true);\r
         config.setFieldsTerminatedBy("\t");\r
         config.setClassificationUuids(classificationUUIDS);\r
-        config.createPreSelectedExport(false, true);\r
+        if(demoExport == false && conceptExport == false){\r
+               config.createPreSelectedExport(false, true);\r
+        }else{\r
+               config.createPreSelectedExport(demoExport, conceptExport);\r
+        }\r
         if(features != null) {\r
             config.setFeatures(features);\r
         }\r