cleanup and javadoc
authorAndreas Müller <a.mueller@bgbm.org>
Mon, 4 Jul 2022 19:43:06 +0000 (21:43 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Mon, 4 Jul 2022 19:43:06 +0000 (21:43 +0200)
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/StringComparator.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmApplicationAwareDefaultExport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/IImportConfigurator.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/ImportConfiguratorBase.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/IoStateBase.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/XmlImportConfiguratorBase.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/XmlImportState.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/descriptive/word/out/WordTermExport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/in/SDDImportConfigurator.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/in/SDDImportState.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/service/IOServiceImpl.java

index 2c6cf3721cd0a56bbadbb22d35425a906010fec3..0e2617b04669daece011b57beef8ef60e3202d81 100644 (file)
@@ -11,6 +11,8 @@ package eu.etaxonomy.cdm.common;
 import java.util.Comparator;
 
 /**
+ * Compares two {@link String}s null safe using the String.compareTo method.
+ *
  * @author a.mueller
  * @since 10.01.2020
  */
index 0b0dce608e00f2f1e1e18a2d8e7c4ada1d221928..3b23ae266fbe8b55f3c7dccc875dc63d658a1a42 100644 (file)
-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-\r
-package eu.etaxonomy.cdm.io.common;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;\r
-import org.springframework.beans.BeansException;\r
-import org.springframework.context.ApplicationContext;\r
-import org.springframework.context.ApplicationContextAware;\r
-import org.springframework.stereotype.Component;\r
-\r
-import eu.etaxonomy.cdm.api.service.IService;\r
-import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;\r
-import eu.etaxonomy.cdm.common.monitor.SubProgressMonitor;\r
-import eu.etaxonomy.cdm.io.common.events.IIoObserver;\r
-import eu.etaxonomy.cdm.model.common.CdmBase;\r
-\r
-/**\r
- * This class is an default exporter class that is a spring bean and therefore it knows all other IO classes that are beans\r
- *\r
- * @author a.mueller\r
- * @since 20.06.2008\r
- */\r
-@Component("defaultExport")\r
-public class CdmApplicationAwareDefaultExport<T extends IExportConfigurator>\r
-        implements ICdmExporter<T>, ApplicationContextAware {\r
-\r
-    private static final Logger logger = LogManager.getLogger(CdmApplicationAwareDefaultExport.class);\r
-\r
-       protected ApplicationContext applicationContext;\r
-\r
-       @Override\r
-    public void setApplicationContext(ApplicationContext applicationContext)\r
-                       throws BeansException {\r
-               this.applicationContext = applicationContext;\r
-       }\r
-\r
-\r
-       //Constants\r
-       final static boolean OBLIGATORY = true;\r
-       final static boolean FACULTATIVE = false;\r
-       final int modCount = 1000;\r
-\r
-       private final IService service = null;\r
-\r
-       //different type of stores that are used by the known imports\r
-       Map<String, MapWrapper<? extends CdmBase>> stores = new HashMap<>();\r
-\r
-       public CdmApplicationAwareDefaultExport(){\r
-               stores.put(ICdmIO.TEAM_STORE, new MapWrapper<>(service));\r
-               stores.put(ICdmIO.REFERENCE_STORE, new MapWrapper<>(service));\r
-               stores.put(ICdmIO.NOMREF_STORE, new MapWrapper<>(service));\r
-               stores.put(ICdmIO.TAXONNAME_STORE, new MapWrapper<>(service));\r
-               stores.put(ICdmIO.TAXON_STORE, new MapWrapper<>(service));\r
-               stores.put(ICdmIO.SPECIMEN_STORE, new MapWrapper<>(service));\r
-       }\r
-\r
-\r
-       @Override\r
-    public ExportResult invoke(T config){\r
-           ExportResult result;\r
-           if (config.getCheck().equals(IExportConfigurator.CHECK.CHECK_ONLY)){\r
-                   result = ExportResult.NewInstance(config.getResultType());\r
-                   boolean success =  doCheck(config);\r
-                   if (! success){\r
-                       result.setAborted();\r
-                   }\r
-               }else if (config.getCheck().equals(IExportConfigurator.CHECK.CHECK_AND_EXPORT)){\r
-                   boolean success = doCheck(config);\r
-                   if (success){\r
-                       result = doExport(config);\r
-                   }else{\r
-                       result = ExportResult.NewInstance(config.getResultType());\r
-                   result.setAborted();\r
-                   }\r
-               }else if (config.getCheck().equals(IExportConfigurator.CHECK.EXPORT_WITHOUT_CHECK)){\r
-                       result = doExport(config);\r
-               }else{\r
-                   result = ExportResult.NewInstance(config.getResultType());\r
-            String message = "Unknown CHECK type";\r
-            logger.error(message);\r
-            result.addError(message);\r
-               }\r
-               return result;\r
-       }\r
-\r
-\r
-    public ExportResult execute(T config) {\r
-           ExportResult result = ExportResult.NewInstance(config.getResultType());\r
-           if (config.getCheck().equals(IExportConfigurator.CHECK.CHECK_ONLY)){\r
-               boolean success =  doCheck(config);\r
-            if (! success){\r
-                result.setAborted();\r
-            }\r
-        } else if (config.getCheck().equals(IExportConfigurator.CHECK.CHECK_AND_EXPORT)){\r
-            boolean success = doCheck(config);\r
-            if (success){\r
-                result = doExport(config);\r
-            }else{\r
-                result.setAborted();\r
-            }\r
-        } else if (config.getCheck().equals(IExportConfigurator.CHECK.EXPORT_WITHOUT_CHECK)){\r
-            result = doExport(config);\r
-        } else{\r
-            String message = "Unknown CHECK type";\r
-            logger.error(message);\r
-            result.addError(message);\r
-        }\r
-           return result;\r
-       }\r
-\r
-       @SuppressWarnings("unchecked")\r
-       protected <S extends IExportConfigurator> boolean doCheck(S  config){\r
-\r
-           boolean result = true;\r
-\r
-               //check\r
-               if (config == null){\r
-                       logger.warn("CdmExportConfiguration is null");\r
-//                     result.setState(ExportResultState.ABORTED);\r
-                       return false;\r
-               }else if (! config.isValid()){\r
-                       logger.warn("CdmExportConfiguration is not valid");\r
-//                     result.setState(ExportResultState.ABORTED);\r
-            return false;\r
-               }\r
-               System.out.println("Start checking Source ("+ config.getSourceNameString() + ") ...");\r
-\r
-               ExportStateBase state = config.getNewState();\r
-               state.initialize(config);\r
-\r
-               //do check for each class\r
-               for (Class<ICdmExport> ioClass: config.getIoClassList()){\r
-                       try {\r
-                               String ioBeanName = getComponentBeanName(ioClass);\r
-                               ICdmIO cdmIo = applicationContext.getBean(ioBeanName, ICdmIO.class);\r
-                               if (cdmIo != null){\r
-                                       registerObservers(config, cdmIo);\r
-                                       result &= cdmIo.check(state);\r
-                                       unRegisterObservers(config, cdmIo);\r
-                               }else{\r
-                                   String message = "cdmIO for class " + (ioClass == null ? "(null)" : ioClass.getSimpleName()) + " was null";\r
-                                       logger.error(message);\r
-                                       return false;\r
-                               }\r
-                       } catch (Exception e) {\r
-                                       logger.error(e);\r
-                                       e.printStackTrace();\r
-                                       return false;\r
-                       }\r
-               }\r
-\r
-               //return\r
-               System.out.println("End checking Source ("+ config.getSourceNameString() + ") for export from Cdm");\r
-               return result;\r
-\r
-       }\r
-\r
-\r
-       private void registerObservers(IExportConfigurator config, ICdmIO io){\r
-               for (IIoObserver observer : config.getObservers()){\r
-                       io.addObserver(observer);\r
-               }\r
-       }\r
-\r
-       private void unRegisterObservers(IExportConfigurator config, ICdmIO io){\r
-               for (IIoObserver observer : config.getObservers()){\r
-                       io.removeObserver(observer);\r
-               }\r
-       }\r
-\r
-\r
-\r
-       /**\r
-        * Executes the whole\r
-        */\r
-       protected <CONFIG extends T>  ExportResult doExport(CONFIG config){\r
-               //validate\r
-               if (config == null){\r
-                   ExportResult result = ExportResult.NewInstance(null);\r
-                   String message = "Configuration is null";\r
-                       logger.error(message);\r
-                       result.addError(message);\r
-                       result.setAborted();\r
-                       return result;\r
-               }\r
-               ExportResult result = ExportResult.NewInstance(config.getResultType());\r
-               if (! config.isValid()){\r
-                       String message = "Configuration is not valid";\r
-                   logger.error(message);\r
-                   result.addError(message);\r
-                       result.setAborted();\r
-                       return result;\r
-               }\r
-\r
-               ExportStateBase state = config.getNewState();\r
-               state.initialize(config);\r
-               state.setResult(result);\r
-\r
-               List<ICdmExport> ioList = makeIoList(state, config);\r
-\r
-               List<Integer> stepCounts = countSteps(state, ioList);\r
-               Integer totalCount = stepCounts.get(stepCounts.size()-1);\r
-               config.getProgressMonitor().beginTask(config.getUserFriendlyIOName() != null? config.getUserFriendlyIOName():"Start Export", totalCount);\r
-               config.getProgressMonitor().worked(1);\r
-               IProgressMonitor parentMonitor = SubProgressMonitor\r
-                       .NewStarted(config.getProgressMonitor(), 99, "Process data", totalCount);\r
-\r
-               //do invoke for each class\r
-               for (int i = 0; i< ioList.size(); i++){\r
-                   ICdmExport export = ioList.get(i);\r
-                   Integer counts = stepCounts.get(i);\r
-                       try {\r
-                           String ioName = export.getClass().getSimpleName();\r
-                           SubProgressMonitor ioMonitor = SubProgressMonitor\r
-                                   .NewStarted(parentMonitor, counts, ioName, counts );\r
-//                         state.getConfig().setProgressMonitor(ioMonitor);\r
-                           state.setCurrentIO(export);\r
-                               export.invoke(state);\r
-                               ioMonitor.done();\r
-                       } catch (Exception e) {\r
-                               String message = "Unexpected exception in " + export.getClass().getSimpleName()+ ": " + e.getMessage();\r
-                               logger.error(message);\r
-                               e.printStackTrace();\r
-                       result.addException(e, message);\r
-                       }\r
-               }\r
-\r
-               System.out.println("End export from source '" + config.getSourceNameString()\r
-                               + "' to destination '" + config.getDestinationNameString() + "' "\r
-                               + "("+ result.toString() + ")"\r
-                               ) ;\r
-               return result;\r
-       }\r
-\r
-       /**\r
-     * @param state\r
-     * @param ioList\r
-     * @return\r
-     */\r
-    private List<Integer> countSteps(ExportStateBase state, List<ICdmExport> ioList) {\r
-        //do invoke for each class\r
-        List<Integer> result = new ArrayList<>();\r
-        int sum = 0;\r
-        for (ICdmExport export: ioList){\r
-            int count = 1;\r
-            try {\r
-//                state.setCurrentIO(export);\r
-                count = ((Long)export.countSteps(state)).intValue();\r
-            } catch (Exception e) {\r
-                String message = "Unexpected exception when count steps for progress monitoring " + export.getClass().getSimpleName()+ ": " + e.getMessage();\r
-                logger.error(message);\r
-                e.printStackTrace();\r
-                state.getResult().addException(e, message);\r
-            }\r
-            result.add(count);\r
-            sum += count;\r
-        }\r
-        result.add(sum);\r
-        return result;\r
-    }\r
-\r
-\r
-    /**\r
-     * @param state\r
-     * @param config\r
-     * @return\r
-     */\r
-    private <CONFIG extends T>  List<ICdmExport> makeIoList(ExportStateBase state, CONFIG config) {\r
-\r
-        List<ICdmExport> result = new ArrayList<>();\r
-\r
-        for (Class<ICdmExport> ioClass: config.getIoClassList()){\r
-            try {\r
-                String ioBeanName = getComponentBeanName(ioClass);\r
-                ICdmExport cdmIo = applicationContext.getBean(ioBeanName, ICdmExport.class);\r
-                if (cdmIo != null){\r
-                    result.add(cdmIo);\r
-                }else{\r
-                    String message = "cdmIO was null: " + ioBeanName;\r
-                    logger.error(message);\r
-                    state.getResult().addError(message);\r
-                }\r
-            } catch (Exception e) {\r
-                    String message = "Unexpected exception in " + ioClass.getSimpleName()+ ": " + e.getMessage();\r
-                    logger.error(message);\r
-                    e.printStackTrace();\r
-                    state.getResult().addException(e, message);\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-\r
-    private String getComponentBeanName(Class<ICdmExport> ioClass){\r
-               Component component = ioClass.getAnnotation(Component.class);\r
-               String ioBean = component.value();\r
-               if ("".equals(ioBean)){\r
-                       ioBean = ioClass.getSimpleName();\r
-                       ioBean = ioBean.substring(0, 1).toLowerCase() + ioBean.substring(1); //make camelcase\r
-               }\r
-               return ioBean;\r
-       }\r
-\r
-}\r
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.cdm.io.common;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+import eu.etaxonomy.cdm.api.service.IService;
+import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
+import eu.etaxonomy.cdm.common.monitor.SubProgressMonitor;
+import eu.etaxonomy.cdm.io.common.events.IIoObserver;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+
+/**
+ * This class is an default exporter class that is a spring bean and therefore it knows all other IO classes that are beans
+ *
+ * @author a.mueller
+ * @since 20.06.2008
+ */
+@Component("defaultExport")
+public class CdmApplicationAwareDefaultExport<T extends IExportConfigurator>
+        implements ICdmExporter<T>, ApplicationContextAware {
+
+    private static final Logger logger = LogManager.getLogger(CdmApplicationAwareDefaultExport.class);
+
+       protected ApplicationContext applicationContext;
+
+       @Override
+    public void setApplicationContext(ApplicationContext applicationContext)
+                       throws BeansException {
+               this.applicationContext = applicationContext;
+       }
+
+       //Constants
+       final static boolean OBLIGATORY = true;
+       final static boolean FACULTATIVE = false;
+       final int modCount = 1000;
+
+       private final IService service = null;
+
+       //different type of stores that are used by the known imports
+       Map<String, MapWrapper<? extends CdmBase>> stores = new HashMap<>();
+
+       public CdmApplicationAwareDefaultExport(){
+               stores.put(ICdmIO.TEAM_STORE, new MapWrapper<>(service));
+               stores.put(ICdmIO.REFERENCE_STORE, new MapWrapper<>(service));
+               stores.put(ICdmIO.NOMREF_STORE, new MapWrapper<>(service));
+               stores.put(ICdmIO.TAXONNAME_STORE, new MapWrapper<>(service));
+               stores.put(ICdmIO.TAXON_STORE, new MapWrapper<>(service));
+               stores.put(ICdmIO.SPECIMEN_STORE, new MapWrapper<>(service));
+       }
+
+
+       @Override
+    public ExportResult invoke(T config){
+           ExportResult result;
+           if (config.getCheck().equals(IExportConfigurator.CHECK.CHECK_ONLY)){
+                   result = ExportResult.NewInstance(config.getResultType());
+                   boolean success =  doCheck(config);
+                   if (! success){
+                       result.setAborted();
+                   }
+               }else if (config.getCheck().equals(IExportConfigurator.CHECK.CHECK_AND_EXPORT)){
+                   boolean success = doCheck(config);
+                   if (success){
+                       result = doExport(config);
+                   }else{
+                       result = ExportResult.NewInstance(config.getResultType());
+                   result.setAborted();
+                   }
+               }else if (config.getCheck().equals(IExportConfigurator.CHECK.EXPORT_WITHOUT_CHECK)){
+                       result = doExport(config);
+               }else{
+                   result = ExportResult.NewInstance(config.getResultType());
+            String message = "Unknown CHECK type";
+            logger.error(message);
+            result.addError(message);
+               }
+               return result;
+       }
+
+
+    public ExportResult execute(T config) {
+           ExportResult result = ExportResult.NewInstance(config.getResultType());
+           if (config.getCheck().equals(IExportConfigurator.CHECK.CHECK_ONLY)){
+               boolean success =  doCheck(config);
+            if (! success){
+                result.setAborted();
+            }
+        } else if (config.getCheck().equals(IExportConfigurator.CHECK.CHECK_AND_EXPORT)){
+            boolean success = doCheck(config);
+            if (success){
+                result = doExport(config);
+            }else{
+                result.setAborted();
+            }
+        } else if (config.getCheck().equals(IExportConfigurator.CHECK.EXPORT_WITHOUT_CHECK)){
+            result = doExport(config);
+        } else{
+            String message = "Unknown CHECK type";
+            logger.error(message);
+            result.addError(message);
+        }
+           return result;
+       }
+
+       @SuppressWarnings("unchecked")
+       protected <S extends IExportConfigurator> boolean doCheck(S  config){
+
+           boolean result = true;
+
+               //check
+               if (config == null){
+                       logger.warn("CdmExportConfiguration is null");
+//                     result.setState(ExportResultState.ABORTED);
+                       return false;
+               }else if (! config.isValid()){
+                       logger.warn("CdmExportConfiguration is not valid");
+//                     result.setState(ExportResultState.ABORTED);
+            return false;
+               }
+               System.out.println("Start checking Source ("+ config.getSourceNameString() + ") ...");
+
+               ExportStateBase state = config.getNewState();
+               state.initialize(config);
+
+               //do check for each class
+               for (Class<ICdmExport> ioClass: config.getIoClassList()){
+                       try {
+                               String ioBeanName = getComponentBeanName(ioClass);
+                               ICdmIO cdmIo = applicationContext.getBean(ioBeanName, ICdmIO.class);
+                               if (cdmIo != null){
+                                       registerObservers(config, cdmIo);
+                                       result &= cdmIo.check(state);
+                                       unRegisterObservers(config, cdmIo);
+                               }else{
+                                   String message = "cdmIO for class " + (ioClass == null ? "(null)" : ioClass.getSimpleName()) + " was null";
+                                       logger.error(message);
+                                       return false;
+                               }
+                       } catch (Exception e) {
+                                       logger.error(e);
+                                       e.printStackTrace();
+                                       return false;
+                       }
+               }
+
+               //return
+               System.out.println("End checking Source ("+ config.getSourceNameString() + ") for export from Cdm");
+               return result;
+
+       }
+
+
+       private void registerObservers(IExportConfigurator config, ICdmIO io){
+               for (IIoObserver observer : config.getObservers()){
+                       io.addObserver(observer);
+               }
+       }
+
+       private void unRegisterObservers(IExportConfigurator config, ICdmIO io){
+               for (IIoObserver observer : config.getObservers()){
+                       io.removeObserver(observer);
+               }
+       }
+
+
+
+       /**
+        * Executes the whole
+        */
+       protected <CONFIG extends T>  ExportResult doExport(CONFIG config){
+               //validate
+               if (config == null){
+                   ExportResult result = ExportResult.NewInstance(null);
+                   String message = "Configuration is null";
+                       logger.error(message);
+                       result.addError(message);
+                       result.setAborted();
+                       return result;
+               }
+               ExportResult result = ExportResult.NewInstance(config.getResultType());
+               if (! config.isValid()){
+                       String message = "Configuration is not valid";
+                   logger.error(message);
+                   result.addError(message);
+                       result.setAborted();
+                       return result;
+               }
+
+               ExportStateBase state = config.getNewState();
+               state.initialize(config);
+               state.setResult(result);
+
+               List<ICdmExport> ioList = makeIoList(state, config);
+
+               List<Integer> stepCounts = countSteps(state, ioList);
+               Integer totalCount = stepCounts.get(stepCounts.size()-1);
+               config.getProgressMonitor().beginTask(config.getUserFriendlyIOName() != null? config.getUserFriendlyIOName():"Start Export", totalCount);
+               config.getProgressMonitor().worked(1);
+               IProgressMonitor parentMonitor = SubProgressMonitor
+                       .NewStarted(config.getProgressMonitor(), 99, "Process data", totalCount);
+
+               //do invoke for each class
+               for (int i = 0; i< ioList.size(); i++){
+                   ICdmExport export = ioList.get(i);
+                   Integer counts = stepCounts.get(i);
+                       try {
+                           String ioName = export.getClass().getSimpleName();
+                           SubProgressMonitor ioMonitor = SubProgressMonitor
+                                   .NewStarted(parentMonitor, counts, ioName, counts );
+//                         state.getConfig().setProgressMonitor(ioMonitor);
+                           state.setCurrentIO(export);
+                               export.invoke(state);
+                               ioMonitor.done();
+                       } catch (Exception e) {
+                               String message = "Unexpected exception in " + export.getClass().getSimpleName()+ ": " + e.getMessage();
+                               logger.error(message);
+                               e.printStackTrace();
+                       result.addException(e, message);
+                       }
+               }
+
+               System.out.println("End export from source '" + config.getSourceNameString()
+                               + "' to destination '" + config.getDestinationNameString() + "' "
+                               + "("+ result.toString() + ")"
+                               ) ;
+               return result;
+       }
+
+       /**
+     * @param state
+     * @param ioList
+     * @return
+     */
+    private List<Integer> countSteps(ExportStateBase state, List<ICdmExport> ioList) {
+        //do invoke for each class
+        List<Integer> result = new ArrayList<>();
+        int sum = 0;
+        for (ICdmExport export: ioList){
+            int count = 1;
+            try {
+//                state.setCurrentIO(export);
+                count = ((Long)export.countSteps(state)).intValue();
+            } catch (Exception e) {
+                String message = "Unexpected exception when count steps for progress monitoring " + export.getClass().getSimpleName()+ ": " + e.getMessage();
+                logger.error(message);
+                e.printStackTrace();
+                state.getResult().addException(e, message);
+            }
+            result.add(count);
+            sum += count;
+        }
+        result.add(sum);
+        return result;
+    }
+
+
+    /**
+     * @param state
+     * @param config
+     * @return
+     */
+    private <CONFIG extends T>  List<ICdmExport> makeIoList(ExportStateBase state, CONFIG config) {
+
+        List<ICdmExport> result = new ArrayList<>();
+
+        for (Class<ICdmExport> ioClass: config.getIoClassList()){
+            try {
+                String ioBeanName = getComponentBeanName(ioClass);
+                ICdmExport cdmIo = applicationContext.getBean(ioBeanName, ICdmExport.class);
+                if (cdmIo != null){
+                    result.add(cdmIo);
+                }else{
+                    String message = "cdmIO was null: " + ioBeanName;
+                    logger.error(message);
+                    state.getResult().addError(message);
+                }
+            } catch (Exception e) {
+                    String message = "Unexpected exception in " + ioClass.getSimpleName()+ ": " + e.getMessage();
+                    logger.error(message);
+                    e.printStackTrace();
+                    state.getResult().addException(e, message);
+            }
+        }
+        return result;
+    }
+
+
+    private String getComponentBeanName(Class<ICdmExport> ioClass){
+               Component component = ioClass.getAnnotation(Component.class);
+               String ioBean = component.value();
+               if ("".equals(ioBean)){
+                       ioBean = ioClass.getSimpleName();
+                       ioBean = ioBean.substring(0, 1).toLowerCase() + ioBean.substring(1); //make camelcase
+               }
+               return ioBean;
+       }
+
+}
index ebf46b8c16162397c9c5bbf39757ea30ad119108..94231cfdcc7361f1a7fdd894f4c95b0b0c2e11aa 100644 (file)
-/**\r
-* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-\r
-package eu.etaxonomy.cdm.io.common;\r
-\r
-import java.util.UUID;\r
-\r
-import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
-import eu.etaxonomy.cdm.database.ICdmDataSource;\r
-import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;\r
-import eu.etaxonomy.cdm.model.agent.Person;\r
-import eu.etaxonomy.cdm.model.name.NomenclaturalCode;\r
-import eu.etaxonomy.cdm.model.reference.Reference;\r
-\r
-/**\r
- * @author a.mueller\r
- * @since 29.01.2009\r
- */\r
-public interface IImportConfigurator extends IIoConfigurator {\r
-\r
-    public static enum SOURCE_TYPE {\r
-        URI,\r
-        INPUTSTREAM\r
-    }\r
-    public static enum CHECK{\r
-        CHECK_ONLY,\r
-        IMPORT_WITHOUT_CHECK,\r
-        CHECK_AND_IMPORT;\r
-\r
-        public boolean isImport(){\r
-            return this == IMPORT_WITHOUT_CHECK || this == CHECK_AND_IMPORT ;\r
-        }\r
-    }\r
-\r
-    public static enum EDITOR{\r
-        NO_EDITORS,  //leaves out createdBy and updatedBy information\r
-        EDITOR_AS_ANNOTATION,//save createdBy and updatedBy in annotations\r
-        EDITOR_AS_EDITOR, //save createdBy and updatedBy in createdBy and updatedBy\r
-    }\r
-\r
-    public static enum DO_REFERENCES{\r
-        NONE,\r
-        NOMENCLATURAL,\r
-        CONCEPT_REFERENCES,\r
-        ALL;\r
-\r
-        public DO_REFERENCES invers(){\r
-               if (this == DO_REFERENCES.NONE){\r
-                       return ALL;\r
-               }else if (this == ALL){\r
-                       return NONE;\r
-               }else if (this == NOMENCLATURAL){  //don't change\r
-                       return NOMENCLATURAL;\r
-               }else if (this == CONCEPT_REFERENCES){  //don't change\r
-                       return CONCEPT_REFERENCES;\r
-               }else{\r
-                       throw new RuntimeException("inverse for DO_REFERENCE type: " + this + " not yet handled");\r
-               }\r
-        }\r
-    }\r
-\r
-\r
-\r
-    public boolean isValid();\r
-\r
-    /**\r
-     * Factory method. Creates a new state for the import type and adds this configuration to it.\r
-     * @return\r
-     */\r
-    public <STATE extends ImportStateBase> STATE getNewState();\r
-\r
-    /* ****************** GETTER/SETTER **************************/\r
-\r
-    /**\r
-     * @return the doReferences\r
-     */\r
-    public CHECK getCheck();\r
-\r
-    /**\r
-     * @param doReferences the doReferences to set\r
-     */\r
-    public void setCheck(CHECK check);\r
-\r
-    /**\r
-     * @return the editor\r
-     */\r
-    public EDITOR getEditor();\r
-\r
-    /**\r
-     * @param editor sets the way how editing (created, updated) information is handled\r
-     */\r
-    public void setEditor(EDITOR editor);\r
-\r
-    /**\r
-     * The destination data source for the import\r
-     * Don't use when using a spring data source\r
-     * @return\r
-     */\r
-    public ICdmDataSource getDestination();\r
-\r
-    public void setDestination(ICdmDataSource destination);\r
-\r
-    @Override\r
-    public DbSchemaValidation getDbSchemaValidation();\r
-\r
-    @Override\r
-    public void setDbSchemaValidation(\r
-            DbSchemaValidation dbSchemaValidation);\r
-\r
-    /**\r
-     * The reference that represents the source. E.g. if the import source is a database\r
-     * the returned reference should be of type eu.etaxonomy.cdm.model.reference.Database and\r
-     * should represent the according database.\r
-     * If the import comes from a file (e.g. XML) the returned value should best represent the\r
-     * source of this file (e.g. if the source of an XML file is a certain database this database\r
-     * should be mentioned as the source. Otherwise a eu.etaxonomy.cdm.model.reference.Generic\r
-     * reference with the name of the XML file should be returned value\r
-     * @return\r
-     */\r
-    public Reference getSourceReference();\r
-\r
-\r
-\r
-    /**\r
-     * Any object that represents the Source. The implementing class must cast this to\r
-     * the correct class type\r
-     * @return\r
-     */\r
-    public Object getSource();\r
-\r
-    //public abstract void setSource(Object url);\r
-\r
-    public void setSourceReference(Reference sourceReference);\r
-\r
-    public String getSourceReferenceTitle();\r
-\r
-    public void setSourceReferenceTitle(String sourceReferenceTitle);\r
-\r
-    public Person getCommentator();\r
-\r
-    public void setCommentator(Person commentator);\r
-\r
-    public NomenclaturalCode getNomenclaturalCode();\r
-\r
-    public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode);\r
-\r
-    public Class<ICdmImport>[] getIoClassList();\r
-\r
-    public Object getSourceSecId();\r
-\r
-     /**\r
-      * If this import implicitly represents a classification in the destination CDM database\r
-      * one can define the classification's uuid here. The congrete import class must support this\r
-      * functionality otherwise it will have no effect.\r
-      * @return\r
-      */\r
-    public UUID getClassificationUuid();\r
-    public void setClassificationUuid(UUID treeUuid);\r
-\r
-    /**\r
-      * If one wants do define the uuid of the accepted taxa (except for missaplied names) this can be\r
-      * done here\r
-      * @return\r
-      */\r
-     public UUID getSecUuid();\r
-    public void setSecUuid(UUID secUuid);\r
-\r
-\r
-    /**\r
-     * Returns the transformer used during import\r
-     * @return\r
-     */\r
-    public IInputTransformer getTransformer();\r
-\r
-    /**\r
-     * Sets the transformer used during import\r
-     * @param transformer\r
-     */\r
-    public void setTransformer(IInputTransformer transformer);\r
-\r
-\r
-    /**\r
-     * Defines if term loading should take place if a new application controller\r
-     * is created. Usually should return false as imports run into existing databases.\r
-     * However, some imports like the current implementation of the JAXB import require\r
-     * to create ALL data anew and import the data itself. Therefore they need to\r
-     * allow omitting term loading.\r
-     * This may be replaced by a more sophisticated solution in future.\r
-     * @return\r
-     */\r
-    public boolean isOmitTermLoading();\r
-\r
-    /**\r
-     * Defines if the database will be created anew. Usually should return false as imports\r
-     * run into existing databases.\r
-     * However, some imports like the current implementation of the JAXB import require\r
-     * to create ALL data anew. Therefore they need to allow to create all data anew.\r
-     * This may be replaced by a more sophisticated solution in future.\r
-     * @return\r
-     */\r
-    public boolean isCreateNew();\r
-\r
-}
+/**
+* Copyright (C) 2009 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.common;
+
+import java.util.UUID;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
+import eu.etaxonomy.cdm.model.agent.Person;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.cdm.model.reference.Reference;
+
+/**
+ * @author a.mueller
+ * @since 29.01.2009
+ */
+public interface IImportConfigurator extends IIoConfigurator {
+
+    public static enum SOURCE_TYPE {
+        URI,
+        INPUTSTREAM
+    }
+    public static enum CHECK{
+        CHECK_ONLY,
+        IMPORT_WITHOUT_CHECK,
+        CHECK_AND_IMPORT;
+
+        public boolean isImport(){
+            return this == IMPORT_WITHOUT_CHECK || this == CHECK_AND_IMPORT ;
+        }
+    }
+
+    public static enum EDITOR{
+        NO_EDITORS,  //leaves out createdBy and updatedBy information
+        EDITOR_AS_ANNOTATION,//save createdBy and updatedBy in annotations
+        EDITOR_AS_EDITOR, //save createdBy and updatedBy in createdBy and updatedBy
+    }
+
+    public static enum DO_REFERENCES{
+        NONE,
+        NOMENCLATURAL,
+        CONCEPT_REFERENCES,
+        ALL;
+
+        public DO_REFERENCES invers(){
+               if (this == DO_REFERENCES.NONE){
+                       return ALL;
+               }else if (this == ALL){
+                       return NONE;
+               }else if (this == NOMENCLATURAL){  //don't change
+                       return NOMENCLATURAL;
+               }else if (this == CONCEPT_REFERENCES){  //don't change
+                       return CONCEPT_REFERENCES;
+               }else{
+                       throw new RuntimeException("inverse for DO_REFERENCE type: " + this + " not yet handled");
+               }
+        }
+    }
+
+    public boolean isValid();
+
+    /**
+     * Factory method. Creates a new state for the import type and adds this configuration to it.
+     * @return
+     */
+    public <STATE extends ImportStateBase> STATE getNewState();
+
+    /* ****************** GETTER/SETTER **************************/
+
+    public CHECK getCheck();
+    public void setCheck(CHECK check);
+
+    /**
+     * @return the editor
+     */
+    public EDITOR getEditor();
+
+    /**
+     * @param editor sets the way how editing (created, updated) information is handled
+     */
+    public void setEditor(EDITOR editor);
+
+    /**
+     * The destination data source for the import
+     * Don't use when using a spring data source
+     * @return
+     */
+    public ICdmDataSource getDestination();
+
+    public void setDestination(ICdmDataSource destination);
+
+    @Override
+    public DbSchemaValidation getDbSchemaValidation();
+
+    @Override
+    public void setDbSchemaValidation(
+            DbSchemaValidation dbSchemaValidation);
+
+    /**
+     * The reference that represents the source. E.g. if the import source is a database
+     * the returned reference should be of type eu.etaxonomy.cdm.model.reference.Database and
+     * should represent the according database.
+     * If the import comes from a file (e.g. XML) the returned value should best represent the
+     * source of this file (e.g. if the source of an XML file is a certain database this database
+     * should be mentioned as the source. Otherwise a eu.etaxonomy.cdm.model.reference.Generic
+     * reference with the name of the XML file should be returned value
+     * @return
+     */
+    public Reference getSourceReference();
+
+    /**
+     * Any object that represents the Source. The implementing class must cast this to
+     * the correct class type
+     * @return
+     */
+    public Object getSource();
+
+    //public abstract void setSource(Object url);
+
+    public void setSourceReference(Reference sourceReference);
+
+    public String getSourceReferenceTitle();
+
+    public void setSourceReferenceTitle(String sourceReferenceTitle);
+
+    public Person getCommentator();
+
+    public void setCommentator(Person commentator);
+
+    public NomenclaturalCode getNomenclaturalCode();
+
+    public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode);
+
+    public Class<ICdmImport>[] getIoClassList();
+
+    public Object getSourceSecId();
+
+     /**
+      * If this import implicitly represents a classification in the destination CDM database
+      * one can define the classification's uuid here. The congrete import class must support this
+      * functionality otherwise it will have no effect.
+      * @return
+      */
+    public UUID getClassificationUuid();
+    public void setClassificationUuid(UUID treeUuid);
+
+    /**
+     * If one wants do define the uuid of the accepted taxa (except for missaplied names) this can be
+     * done here
+     */
+    public UUID getSecUuid();
+    public void setSecUuid(UUID secUuid);
+
+    /**
+     * Returns the transformer used during import
+     */
+    public IInputTransformer getTransformer();
+    /**
+     * Sets the transformer used during import
+     * @param transformer
+     */
+    public void setTransformer(IInputTransformer transformer);
+
+    /**
+     * Defines if term loading should take place if a new application controller
+     * is created. Usually should return false as imports run into existing databases.
+     * However, some imports like the current implementation of the JAXB import require
+     * to create ALL data anew and import the data itself. Therefore they need to
+     * allow omitting term loading.
+     * This may be replaced by a more sophisticated solution in future.
+     * @return
+     */
+    public boolean isOmitTermLoading();
+
+    /**
+     * Defines if the database will be created anew. Usually should return false as imports
+     * run into existing databases.
+     * However, some imports like the current implementation of the JAXB import require
+     * to create ALL data anew. Therefore they need to allow to create all data anew.
+     * This may be replaced by a more sophisticated solution in future.
+     * @return
+     */
+    public boolean isCreateNew();
+}
\ No newline at end of file
index 2eadf616a3005d306b9d5852e65a63b2712f98d7..da94417c4759d05c0142c385b8a55f789bddb085 100644 (file)
@@ -350,5 +350,4 @@ public abstract class ImportConfiguratorBase<STATE extends ImportStateBase, SOUR
     public void setRegisterAuditing(boolean registerAuditing) {
         this.hibernateConfig.setRegisterEnvers(registerAuditing);
     }
-
-}
+}
\ No newline at end of file
index 836bf37a55c5f19096eed64e10f3b020b14883f4..2364ca412c983569bd0d75d250908b6bc250dd56 100644 (file)
@@ -1,63 +1,57 @@
-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.cdm.io.common;\r
-\r
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;\r
-\r
-import eu.etaxonomy.cdm.common.IoResultBase;\r
-\r
-/**\r
- * @author a.mueller\r
- * @since 11.05.2009\r
- */\r
-public abstract class IoStateBase<CONFIG\r
-        extends IIoConfigurator, IO extends ICdmIO, RESULT extends IoResultBase> {\r
-\r
-       @SuppressWarnings("unused")\r
-       private static final Logger logger = LogManager.getLogger(IoStateBase.class);\r
-\r
-       private IO currentIO;\r
-\r
-       protected CONFIG config;\r
-\r
-       private RESULT result;\r
-\r
-    //TODO config not necessary ones it it implemented in constructor for IOs too.\r
-       public void initialize(CONFIG config){\r
-           this.config = config;\r
-       }\r
-\r
-       public CONFIG getConfig() {\r
-               return config;\r
-       }\r
-       public void setConfig(CONFIG config) {\r
-               this.config = config;\r
-       }\r
-\r
-       public void setCurrentIO(IO currentIO) {\r
-               this.currentIO = currentIO;\r
-       }\r
-       public IO getCurrentIO() {\r
-               return currentIO;\r
-       }\r
-\r
-    public RESULT getResult() {\r
-        return result;\r
-    }\r
-    public void setResult(RESULT result) {\r
-        this.result = result;\r
-    }\r
-\r
-//    public IProgressMonitor getCurrentMonitor() {\r
-//        return currentMonitor;\r
-//    }\r
-//    public void setCurrentMonitor(IProgressMonitor currentMonitor) {\r
-//        this.currentMonitor = currentMonitor;\r
-//    }\r
-}\r
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.common;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import eu.etaxonomy.cdm.common.IoResultBase;
+
+/**
+ * @author a.mueller
+ * @since 11.05.2009
+ */
+public abstract class IoStateBase<CONFIG
+        extends IIoConfigurator, IO extends ICdmIO, RESULT extends IoResultBase> {
+
+       @SuppressWarnings("unused")
+       private static final Logger logger = LogManager.getLogger(IoStateBase.class);
+
+       private IO currentIO;
+
+       protected CONFIG config;
+
+       private RESULT result;
+
+    //TODO config not necessary ones it it implemented in constructor for IOs too.
+       public void initialize(CONFIG config){
+           this.config = config;
+       }
+
+       public CONFIG getConfig() {
+               return config;
+       }
+       public void setConfig(CONFIG config) {
+               this.config = config;
+       }
+
+       public void setCurrentIO(IO currentIO) {
+               this.currentIO = currentIO;
+       }
+       public IO getCurrentIO() {
+               return currentIO;
+       }
+
+    public RESULT getResult() {
+        return result;
+    }
+    public void setResult(RESULT result) {
+        this.result = result;
+    }
+}
\ No newline at end of file
index 20d4d6df6a1a81d4cea3ea20fb59bfd4e3c5f30c..0cdeab5c30c983916ecb52ef8d0dc2415f923f17 100644 (file)
@@ -1,24 +1,25 @@
-/**\r
-* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.cdm.io.common;\r
-\r
-import eu.etaxonomy.cdm.common.URI;\r
-import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;\r
-\r
-/**\r
- * @author a.mueller\r
- * @since 28.06.2011\r
- */\r
-//<ImportConfiguratorBase, XmlImportBase>\r
-public abstract class XmlImportConfiguratorBase<STATE extends XmlImportState> extends ImportConfiguratorBase<STATE, URI> {\r
-\r
-       public XmlImportConfiguratorBase(IInputTransformer transformer) {\r
-               super(transformer);\r
-       }\r
+/**
+* Copyright (C) 2009 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.common;
+
+import eu.etaxonomy.cdm.common.URI;
+import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
+
+/**
+ * @author a.mueller
+ * @since 28.06.2011
+ */
+//<ImportConfiguratorBase, XmlImportBase>
+public abstract class XmlImportConfiguratorBase<STATE extends XmlImportState>
+        extends ImportConfiguratorBase<STATE, URI> {
+
+       public XmlImportConfiguratorBase(IInputTransformer transformer) {
+               super(transformer);
+       }
 }
\ No newline at end of file
index 286753015b9775f295e1ddba38704b57780aaa49..26d987060ceb8242fc003f4d1836b0e07c6f253f 100644 (file)
@@ -1,49 +1,38 @@
-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
-* http://www.e-taxonomy.eu\r
-* \r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-\r
-package eu.etaxonomy.cdm.io.common;\r
-\r
-import javax.xml.stream.XMLEventReader;\r
-\r
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;\r
-\r
-/**\r
- * @author a.mueller\r
- * @since 11.05.2009\r
- */\r
-public class XmlImportState<CONFIG extends XmlImportConfiguratorBase, IO extends XmlImportBase> extends ImportStateBase<CONFIG, IO> {\r
-       @SuppressWarnings("unused")\r
-       private static final Logger logger = LogManager.getLogger(XmlImportState.class);\r
-\r
-       private XMLEventReader reader;\r
-\r
-       \r
-       public XmlImportState(CONFIG config) {\r
-               super(config);\r
-       }\r
-\r
-       \r
-\r
-       /**\r
-        * @return the reader\r
-        */\r
-       public XMLEventReader getReader() {\r
-               return reader;\r
-       }\r
-\r
-       public void setReader(XMLEventReader reader) {\r
-               this.reader = reader;\r
-               \r
-       }\r
-\r
-\r
-\r
-       \r
-\r
-}\r
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.common;
+
+import javax.xml.stream.XMLEventReader;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ * @author a.mueller
+ * @since 11.05.2009
+ */
+public class XmlImportState<CONFIG extends XmlImportConfiguratorBase, IO extends XmlImportBase>
+        extends ImportStateBase<CONFIG, IO> {
+
+    @SuppressWarnings("unused")
+       private static final Logger logger = LogManager.getLogger(XmlImportState.class);
+
+       private XMLEventReader reader;
+
+       public XmlImportState(CONFIG config) {
+               super(config);
+       }
+
+       public XMLEventReader getReader() {
+               return reader;
+       }
+       public void setReader(XMLEventReader reader) {
+               this.reader = reader;
+       }
+}
\ No newline at end of file
index 0f7c1ef7c2c806ddbaf3f8cdfa7c6dca9668b071..a1c0710f0248f824541e3690dd29a45aa94b3dbe 100644 (file)
@@ -123,12 +123,10 @@ public class WordTermExport extends CdmExportBase<WordTermExportConfigurator, Wo
             }
             addChildNode(childNode, mainDocumentPart, indent+1);
         }
-
     }
 
     @Override
     protected boolean isIgnore(WordTermExportState state) {
         return false;
     }
-
-}
+}
\ No newline at end of file
index ed74eaef25dd65ca4502630de6595897226a448e..27e06810b57e59dffa07414ebe79a84bb6fbbb88 100644 (file)
-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-\r
-package eu.etaxonomy.cdm.io.sdd.in;\r
-\r
-import java.io.InputStream;\r
-import java.net.MalformedURLException;\r
-import eu.etaxonomy.cdm.common.URI;\r
-import java.net.URL;\r
-\r
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;\r
-import org.jdom.Element;\r
-import org.jdom.Namespace;\r
-\r
-import eu.etaxonomy.cdm.common.XmlHelp;\r
-import eu.etaxonomy.cdm.database.ICdmDataSource;\r
-import eu.etaxonomy.cdm.io.common.IImportConfigurator;\r
-import eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator;\r
-import eu.etaxonomy.cdm.io.common.XmlImportConfiguratorBase;\r
-import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;\r
-import eu.etaxonomy.cdm.io.sdd.SDDTransformer;\r
-import eu.etaxonomy.cdm.model.reference.Reference;\r
-import eu.etaxonomy.cdm.model.reference.ReferenceFactory;\r
-\r
-/**\r
- * @author h.fradin\r
- * @since 24.10.2008\r
- */\r
-public class SDDImportConfigurator extends XmlImportConfiguratorBase<SDDImportState> implements IImportConfigurator, IMatchingImportConfigurator {\r
-    private static final long serialVersionUID = -960998183005112130L;\r
-\r
-    private static final Logger logger = LogManager.getLogger(SDDImportConfigurator.class);\r
-\r
-       //TODO\r
-       private static IInputTransformer defaultTransformer = new SDDTransformer();\r
-\r
-       private boolean doMatchTaxa = true;\r
-\r
-       //xml xmlNamespace\r
-       Namespace sddNamespace;\r
-\r
-       @Override\r
-    protected void makeIoClassList(){\r
-               ioClassList = new Class[]{\r
-                               SDDImport.class\r
-               };\r
-       };\r
-\r
-       public static SDDImportConfigurator NewInstance(URI uri, ICdmDataSource destination){\r
-               return new SDDImportConfigurator(uri, destination);\r
-       }\r
-\r
-\r
-       /**\r
-        * @param berlinModelSource\r
-        * @param sourceReference\r
-        * @param destination\r
-        */\r
-       private SDDImportConfigurator(URI uri, ICdmDataSource destination) {\r
-               super(defaultTransformer);\r
-               setSource(uri);\r
-               setDestination(destination);\r
-       }\r
-\r
-\r
-       @Override\r
-    public SDDImportState getNewState() {\r
-               return new SDDImportState(this);\r
-       }\r
-\r
-\r
-       /**\r
-        * @return\r
-        */\r
-       public Element getSourceRoot(){\r
-               try {\r
-                       URL url;\r
-                       url = getSource().toURL();\r
-                       Object o = url.getContent();\r
-                       InputStream is = (InputStream)o;\r
-                       Element root = XmlHelp.getRoot(is);\r
-                       makeNamespaces(root);\r
-                       return root;\r
-               } catch (MalformedURLException e) {\r
-                       e.printStackTrace();\r
-               }catch (Exception e) {\r
-                       // TODO Auto-generated catch block\r
-                       e.printStackTrace();\r
-               }\r
-               return null;\r
-       }\r
-\r
-       private boolean makeNamespaces(Element root){\r
-               sddNamespace = root.getNamespace();\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       public Reference getSourceReference() {\r
-               //TODO\r
-               if (this.sourceReference == null){\r
-                       logger.warn("getSource Reference not yet fully implemented");\r
-                       sourceReference = ReferenceFactory.newDatabase();\r
-                       sourceReference.setTitleCache("XXX", true);\r
-               }\r
-               return sourceReference;\r
-       }\r
-\r
-       @Override\r
-    public String getSourceNameString() {\r
-               if (this.getSource() == null){\r
-                       return null;\r
-               }else{\r
-                       return this.getSource().toString();\r
-               }\r
-       }\r
-\r
-       public Namespace getSddNamespace() {\r
-               return sddNamespace;\r
-       }\r
-\r
-       public void setSddNamespace(Namespace xmlNamespace) {\r
-               this.sddNamespace = xmlNamespace;\r
-       }\r
-\r
-       /**\r
-        * @param doMatchTaxa the doMatchTaxa to set\r
-        */\r
-       @Override\r
-    public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa) {\r
-               this.doMatchTaxa = doMatchTaxa;\r
-       }\r
-\r
-       /**\r
-        * @return the doMatchTaxa\r
-        */\r
-       @Override\r
-    public boolean isReuseExistingTaxaWhenPossible() {\r
-               return doMatchTaxa;\r
-       }\r
-}\r
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.cdm.io.sdd.in;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.jdom.Element;
+import org.jdom.Namespace;
+
+import eu.etaxonomy.cdm.common.URI;
+import eu.etaxonomy.cdm.common.XmlHelp;
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+import eu.etaxonomy.cdm.io.common.IImportConfigurator;
+import eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator;
+import eu.etaxonomy.cdm.io.common.XmlImportConfiguratorBase;
+import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
+import eu.etaxonomy.cdm.io.sdd.SDDTransformer;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
+
+/**
+ * @author h.fradin
+ * @since 24.10.2008
+ */
+public class SDDImportConfigurator extends XmlImportConfiguratorBase<SDDImportState>
+        implements IImportConfigurator, IMatchingImportConfigurator {
+
+    private static final long serialVersionUID = -960998183005112130L;
+    private static final Logger logger = LogManager.getLogger(SDDImportConfigurator.class);
+
+       //TODO
+       private static IInputTransformer defaultTransformer = new SDDTransformer();
+
+       private boolean doMatchTaxa = true;
+
+       //xml xmlNamespace
+       Namespace sddNamespace;
+
+       @Override
+    protected void makeIoClassList(){
+               ioClassList = new Class[]{
+                               SDDImport.class
+               };
+       };
+
+       public static SDDImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
+               return new SDDImportConfigurator(uri, destination);
+       }
+
+
+       /**
+        * @param berlinModelSource
+        * @param sourceReference
+        * @param destination
+        */
+       private SDDImportConfigurator(URI uri, ICdmDataSource destination) {
+               super(defaultTransformer);
+               setSource(uri);
+               setDestination(destination);
+       }
+
+
+       @Override
+    public SDDImportState getNewState() {
+               return new SDDImportState(this);
+       }
+
+
+       /**
+        * @return
+        */
+       public Element getSourceRoot(){
+               try {
+                       URL url;
+                       url = getSource().toURL();
+                       Object o = url.getContent();
+                       InputStream is = (InputStream)o;
+                       Element root = XmlHelp.getRoot(is);
+                       makeNamespaces(root);
+                       return root;
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+               }catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               return null;
+       }
+
+       private boolean makeNamespaces(Element root){
+               sddNamespace = root.getNamespace();
+               return true;
+       }
+
+       @Override
+       public Reference getSourceReference() {
+               //TODO
+               if (this.sourceReference == null){
+                       logger.warn("getSource Reference not yet fully implemented");
+                       sourceReference = ReferenceFactory.newDatabase();
+                       sourceReference.setTitleCache("XXX", true);
+               }
+               return sourceReference;
+       }
+
+       @Override
+    public String getSourceNameString() {
+               if (this.getSource() == null){
+                       return null;
+               }else{
+                       return this.getSource().toString();
+               }
+       }
+
+       public Namespace getSddNamespace() {
+               return sddNamespace;
+       }
+
+       public void setSddNamespace(Namespace xmlNamespace) {
+               this.sddNamespace = xmlNamespace;
+       }
+
+       /**
+        * @param doMatchTaxa the doMatchTaxa to set
+        */
+       @Override
+    public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa) {
+               this.doMatchTaxa = doMatchTaxa;
+       }
+
+       /**
+        * @return the doMatchTaxa
+        */
+       @Override
+    public boolean isReuseExistingTaxaWhenPossible() {
+               return doMatchTaxa;
+       }
+}
index df3783c0f2121f8a54125b453a754dd3b118e3b8..c3a6afc8654ddb9eb48224c1be31dca39f511e8d 100644 (file)
@@ -1,30 +1,28 @@
-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
-* http://www.e-taxonomy.eu\r
-* \r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-\r
-package eu.etaxonomy.cdm.io.sdd.in;\r
-\r
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;\r
-\r
-import eu.etaxonomy.cdm.io.common.XmlImportState;\r
-\r
-/**\r
- * @author a.mueller\r
- * @since 11.05.2009\r
- * @version 1.0\r
- */\r
-public class SDDImportState extends XmlImportState<SDDImportConfigurator, SDDImport>{\r
-       @SuppressWarnings("unused")\r
-       private static final Logger logger = LogManager.getLogger(SDDImportState.class);\r
-\r
-       public SDDImportState(SDDImportConfigurator config) {\r
-               super(config);\r
-       }\r
-\r
-\r
-}\r
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.sdd.in;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import eu.etaxonomy.cdm.io.common.XmlImportState;
+
+/**
+ * @author a.mueller
+ * @since 11.05.2009
+ */
+public class SDDImportState extends XmlImportState<SDDImportConfigurator, SDDImport>{
+
+       @SuppressWarnings("unused")
+       private static final Logger logger = LogManager.getLogger(SDDImportState.class);
+
+       public SDDImportState(SDDImportConfigurator config) {
+               super(config);
+       }
+}
\ No newline at end of file
index e6a9eb48e6d1883b7d5dbfa87603a70095aff556..98dbafae46eaed02ed4e237dc915d0d71c5b2c6f 100644 (file)
@@ -57,11 +57,6 @@ public class IOServiceImpl implements IIOService {
 
     @Autowired
     IProgressMonitorService progressMonitorService;
-//
-//    @Autowired
-//    @Qualifier("defaultUpdate")
-//    CdmApplicationAwareDefaultUpdate cdmUpdate;
-
 
     @Override
     public ExportResult export(IExportConfigurator config) {
@@ -69,7 +64,6 @@ public class IOServiceImpl implements IIOService {
         return cdmExport.execute(config);
     }
 
-
     @Override
     public UUID monitImportData(final IImportConfigurator configurator, final byte[] importData, final SOURCE_TYPE type) {
         RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
@@ -111,24 +105,6 @@ public class IOServiceImpl implements IIOService {
         return uuid;
     }
 
-//    @Override
-//    public UUID monitUpdateData(final IImportConfigurator configurator) {
-//        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
-//            @Override
-//            public Serializable doRun(IRemotingProgressMonitor monitor) {
-//
-//                configurator.setProgressMonitor(monitor);
-//                ImportResult result =updateData((SecundumForSubtreeConfigurator)configurator);
-//
-//                return result;
-//            }
-//        };
-//        UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread);
-//        monitorThread.setPriority(3);
-//        monitorThread.start();
-//        return uuid;
-//    }
-
     @Override
     public ImportResult importData(IImportConfigurator configurator, byte[] importData, SOURCE_TYPE type) {
         ImportResult result;