cleanup
authorAndreas Müller <a.mueller@bgbm.org>
Sat, 4 Jul 2020 12:39:05 +0000 (14:39 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Sat, 4 Jul 2020 12:39:05 +0000 (14:39 +0200)
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/ExcelUtils.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmApplicationAwareDefaultImport.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/distribution/excelupdate/ExcelDistributionUpdate.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/common/ExcelImportBase.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/excel/in/ExtensionTypeExcelImport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/excel/in/NamedAreaLevelExcelImport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/excel/in/SpecimenCdmExcelImport.java

index ac0dd6645bef0e217ca1322e625bc22258f2df6a..a0fdb294d79f3629feeb0f09f8292b2205a23d61 100644 (file)
@@ -6,7 +6,6 @@
 * 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.common;
 
 import java.io.FileNotFoundException;
@@ -22,7 +21,6 @@ import java.util.Locale;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
-import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
@@ -33,7 +31,6 @@ import org.apache.poi.ss.usermodel.WorkbookFactory;
 /**
  * @author n.hoffmann
  * @since 18.11.2008
- * @version 1.0
  */
 public class ExcelUtils {
        private static final Logger logger = Logger.getLogger(ExcelUtils.class);
@@ -43,7 +40,6 @@ public class ExcelUtils {
        return parseXLS(uri, null);
     }
 
-
        /** Reads all rows of an Excel worksheet */
     public static List<Map<String, String>> parseXLS(URI uri, String worksheetName) throws FileNotFoundException {
         try {
@@ -57,7 +53,6 @@ public class ExcelUtils {
             ioe.printStackTrace();
             throw new RuntimeException(message);
         }
-
     }
 
     /** Reads all rows of an Excel worksheet */
@@ -145,7 +140,6 @@ public class ExcelUtils {
                                recordList.add(headers);
                        }
                }
-
        } catch(Exception ioe) {
                logger.error("Error reading the Excel file.");
                ioe.printStackTrace();
@@ -153,22 +147,21 @@ public class ExcelUtils {
        return recordList;
     }
 
-
        public static String getCellValue(Cell cell) {
                try {
-                       if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING ){
+                       if (cell.getCellType() == Cell.CELL_TYPE_STRING ){
                                return cell.getStringCellValue();
-                       }else if (cell.getCellType() == HSSFCell.CELL_TYPE_BLANK){
+                       }else if (cell.getCellType() == Cell.CELL_TYPE_BLANK){
                                return "";
-                       }else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC){
+                       }else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC){
                                return getNumericCellValue(cell);
-                       }else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN){
+                       }else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN){
                                Boolean cellValue = cell.getBooleanCellValue();
                                String value = String.valueOf(cellValue);
                                return value;
-                       }else if (cell.getCellType() == HSSFCell.CELL_TYPE_ERROR){
+                       }else if (cell.getCellType() == Cell.CELL_TYPE_ERROR){
                                return "-error-";
-                       }else if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA){
+                       }else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA){
                                try {
                                        String strValue = cell.getStringCellValue();
                                        if ("".equals(strValue)){
@@ -200,18 +193,14 @@ public class ExcelUtils {
        private static String getExcelColString(int colNr){
                int first = colNr / 26;
                int second = colNr % 26;
-//             char a = Integer.valueOf(first).shortValue();
                String firstStr = String.valueOf((first > 0 ? (char)(first +64) :""));
                String secondStr = String.valueOf((char)(second + 64));
                return firstStr +  secondStr;
        }
 
-
        /**
         * Returns the numeric cell value. In case the cell is formatted as
         * a date it returns a date (using the dates toString() method.
-        * @param cell
-        * @return
         */
        private static String getNumericCellValue(Cell cell) {
                Double number = cell.getNumericCellValue();
@@ -233,7 +222,6 @@ public class ExcelUtils {
 
                        return result;
                }
-//             System.out.println(d);
 
                if (number.intValue() == number){
                        return String.valueOf(number.intValue());
@@ -242,12 +230,8 @@ public class ExcelUtils {
                }
        }
 
-
        /**
         * Returns false, if row is null or has no values
-        * @param row
-        * @param notEmpty
-        * @return
         */
        private static boolean checkIsEmptyRow(Row row) {
                if (row == null){
index f5f0260b06d8f5e199a335495b69610bc6ed4b91..fe797c377046a558bced2682d7c06e8e9d7b7cae 100644 (file)
@@ -70,7 +70,7 @@ public class CdmApplicationAwareDefaultImport<T extends IImportConfigurator> imp
     public ImportResult invoke(IImportConfigurator config){\r
         ImportResult result = new ImportResult();\r
         if (config.getCheck().equals(IImportConfigurator.CHECK.CHECK_ONLY)){\r
-            boolean success =  doCheck(config);\r
+            boolean success = doCheck(config);\r
             if (! success){\r
                 result.setAborted();\r
             }\r
index 8c17bfc4d5eb2f99c6b863b888a82fde9b575599..c7fa7cf1632d3bdfae7fb124118163abee11f2a2 100644 (file)
@@ -97,10 +97,8 @@ public abstract class ImportConfiguratorBase<STATE extends ImportStateBase, SOUR
 /* *****************CONSTRUCTOR *****************************/
 
        protected ImportConfiguratorBase(IInputTransformer transformer){
-               super();
                setDbSchemaValidation(DbSchemaValidation.VALIDATE);
                this.transformer = transformer;
-
        }
 
        abstract protected void makeIoClassList();
index 07526eb80974c0b6a2cc0edce17a6e6742584484..c935b371a1633dc78b111b0fc4f7343b496a7e0e 100644 (file)
@@ -18,7 +18,8 @@ import eu.etaxonomy.cdm.common.IoResultBase;
  * @author a.mueller\r
  * @since 11.05.2009\r
  */\r
-public abstract class IoStateBase<CONFIG extends IIoConfigurator, IO extends ICdmIO, RESULT extends IoResultBase> {\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 = Logger.getLogger(IoStateBase.class);\r
@@ -29,8 +30,6 @@ public abstract class IoStateBase<CONFIG extends IIoConfigurator, IO extends ICd
 \r
        private RESULT result;\r
 \r
-\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
@@ -50,7 +49,6 @@ public abstract class IoStateBase<CONFIG extends IIoConfigurator, IO extends ICd
                return currentIO;\r
        }\r
 \r
-\r
     public RESULT getResult() {\r
         return result;\r
     }\r
@@ -58,14 +56,10 @@ public abstract class IoStateBase<CONFIG extends IIoConfigurator, IO extends ICd
         this.result = result;\r
     }\r
 \r
-\r
 //    public IProgressMonitor getCurrentMonitor() {\r
 //        return currentMonitor;\r
 //    }\r
 //    public void setCurrentMonitor(IProgressMonitor currentMonitor) {\r
 //        this.currentMonitor = currentMonitor;\r
 //    }\r
-\r
-\r
-\r
 }\r
index d570d090accd78f79930eff86cc9c70b048c9939..a62ca8c8e31a887183eef5159da859d0895b0b76 100644 (file)
@@ -322,7 +322,7 @@ public class ExcelDistributionUpdate
         return false;
     }
     @Override
-    protected boolean needsNomenclaturalCode() {
+    protected boolean requiresNomenclaturalCode() {
         return false;
     }
 
index 4410bc5549fd1fec8d4443f2c88a8b85b8a6b40c..db67e4773d7b63ec15ace8b68228a6066e87f469 100755 (executable)
@@ -65,7 +65,7 @@ public abstract class ExcelImportBase<STATE extends ExcelImportState<CONFIG, ROW
        configurator = state.getConfig();
 
                NomenclaturalCode nc = getConfigurator().getNomenclaturalCode();
-               if (nc == null && needsNomenclaturalCode()) {
+               if (nc == null && requiresNomenclaturalCode()) {
                        logger.error("Nomenclatural code could not be determined. Skip invoke.");
                        state.setUnsuccessfull();
                        return;
@@ -74,8 +74,10 @@ public abstract class ExcelImportBase<STATE extends ExcelImportState<CONFIG, ROW
 
                byte[] data = null;
                // read and save all rows of the excel worksheet
-               if ((state.getConfig() instanceof NormalExplicitImportConfigurator || state.getConfig() instanceof ExcelDistributionUpdateConfigurator || state.getConfig() instanceof TaxonListImportConfigurator) &&
-                       (state.getConfig().getStream() != null || state.getConfig().getStream() != null)){
+               if ((state.getConfig() instanceof NormalExplicitImportConfigurator
+                       || state.getConfig() instanceof ExcelDistributionUpdateConfigurator
+                       || state.getConfig() instanceof TaxonListImportConfigurator) && (state.getConfig().getStream() != null
+                       || state.getConfig().getStream() != null)){
                    data =  state.getConfig().getStream();
                } else{
                    source = state.getConfig().getSource();
@@ -107,7 +109,7 @@ public abstract class ExcelImportBase<STATE extends ExcelImportState<CONFIG, ROW
        return;
        }
 
-       protected boolean needsNomenclaturalCode() {
+       protected boolean requiresNomenclaturalCode() {
                return true;
        }
 
index 47dc3f64cd3f41b881da0bad6a9cd3da729465c7..252ff670b351516c872cf00e8dee4a69b3559519 100644 (file)
@@ -142,7 +142,7 @@ public class ExtensionTypeExcelImport
        }
 
        @Override
-       protected boolean needsNomenclaturalCode() {
+       protected boolean requiresNomenclaturalCode() {
                return false;
        }
 
index 3c9882926689102379ad56b4124a3dab0e7f2b06..dbab9484eadcf2f566e261d656483299536a1adf 100644 (file)
@@ -157,7 +157,7 @@ public class NamedAreaLevelExcelImport
        }
 
        @Override
-       protected boolean needsNomenclaturalCode() {
+       protected boolean requiresNomenclaturalCode() {
                return false;
        }
 
index 8264d8414d81e6ce27b051d7a10c86039666a8eb..ec0f737af5578a155024ed1b17e6f7eb010ffc47 100644 (file)
@@ -939,7 +939,7 @@ public class SpecimenCdmExcelImport
        }
 
        @Override
-       protected boolean needsNomenclaturalCode() {
+       protected boolean requiresNomenclaturalCode() {
                return false;
        }