adapt import and export manager to changes in IOResult
authorKatja Luther <k.luther@bgbm.org>
Mon, 15 May 2017 08:51:32 +0000 (10:51 +0200)
committerKatja Luther <k.luther@bgbm.org>
Mon, 15 May 2017 08:51:32 +0000 (10:51 +0200)
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractIOManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ImportManager.java

index ceacc4063fd4565ce8babb0c596e13d2eebd5948..0fabf0c874dd20beac13c65e83a0117e51f8b8c6 100644 (file)
@@ -72,7 +72,7 @@ Require-Bundle: org.eclipse.osgi,
  org.eclipse.core.databinding.observable,
  org.eclipse.core.databinding.property,
  org.eclipse.jface.databinding,
- org.eclipse.jdt.annotation;bundle-version="1.1.100",
  eu.etaxonomy.taxeditor.workbench,
  org.eclipse.e4.core.di.annotations;bundle-version="1.5.0",
  org.eclipse.e4.ui.di;bundle-version="1.1.100",
index a7560e51cae643aeb56e3a548a1581527bfa94ee..f52f79c8c5ff8e9bd5a9e9032e682e066645c750 100644 (file)
@@ -177,4 +177,5 @@ viewCommandMapping.viewerName.TAXON_NODE_WIZARD = Taxon node Wizard
 command.label.CHANGE_PASSWORD = Change password\r
 wizard.name.22 = Output Model\r
 wizard.name.23 = Excel Distribution Data Update\r
+wizard.name.24 = Ris Import\r
 command.label.25 = Import Preferences
\ No newline at end of file
index 832293050fa4109c8c55c3781117cf42383813e5..dd50f92ebc9ec5543e58c2e276aad40cec0e6056 100644 (file)
@@ -178,4 +178,5 @@ viewCommandMapping.viewerName.TAXON_NODE_WIZARD = Taxonknoten-Wizard
 command.label.CHANGE_PASSWORD = Kennwort ändern
 wizard.name.22 = Output Model
 wizard.name.23 = Excel Verbreitungsdaten Update
+wizard.name.24 = Ris Import
 command.label.25 = Import Präferenzen
\ No newline at end of file
index 523addd4be5bb1ee3722b241a944740db080cbf3..506d96bc9fb1e8abb3038190b7526a5f042f0138 100644 (file)
@@ -29,7 +29,7 @@ public abstract class AbstractIOManager<CONFIGURATOR extends IIoConfigurator> {
        protected ICdmRepository applicationConfiguration;
 
        public static enum TYPE {
-               Jaxb, Tcs, Excel_Taxa, Endnote, Sdd, Abcd, SpecimenCdmExcel, Excel_Name, SpecimenSearch, Gbif, Excel_Distribution
+               Jaxb, Tcs, Excel_Taxa, Endnote, Sdd, Abcd, SpecimenCdmExcel, Excel_Name, SpecimenSearch, Gbif, Excel_Distribution, Ris
        }
 
        /**
index 9918b79a74697a47a82a5e3be7ef4419ac71c923..be72cfc8f6c46902bc4ac856768f6307be055c25 100644 (file)
@@ -35,6 +35,7 @@ import eu.etaxonomy.cdm.io.common.ExportResultType;
 import eu.etaxonomy.cdm.io.common.IExportConfigurator;
 import eu.etaxonomy.cdm.io.common.IIoConfigurator;
 import eu.etaxonomy.cdm.io.common.IoResultBase;
+import eu.etaxonomy.cdm.io.common.IoResultBase.IoInfo;
 import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
 import eu.etaxonomy.cdm.io.outputmodel.OutputModelConfigurator;
 import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator;
@@ -324,19 +325,19 @@ public class ExportManager extends AbstractIOManager<IExportConfigurator> {
                      }
                      final StringBuilder reportText = new StringBuilder();
                      if(result!=null){
-                         List<IoResultBase.Error> reports = result.getErrors();
+                         List<IoInfo> reports = result.getErrors();
                          reportText.append("Errors:\\r");
-                         for (IoResultBase.Error bs : reports) {
+                         for (IoInfo bs : reports) {
                              reportText.append(bs.getMessage() + " - " +bs.getException().getStackTrace());
                          }
-                         List<String> warnings = result.getWarnings();
+                         List<IoResultBase.IoInfo> warnings = result.getWarnings();
                          reportText.append("Warnings:\\r");
-                         for (String bs : warnings) {
+                         for (IoResultBase.IoInfo bs : warnings) {
                              reportText.append(bs);
                          }
-                         List<IoResultBase.Error> exceptions = result.getExceptions();
+                         List<IoInfo> exceptions = result.getExceptions();
                          reportText.append("Exceptions:\\r");
-                         for (IoResultBase.Error bs : exceptions) {
+                         for (IoInfo bs : exceptions) {
                              reportText.append(bs.getMessage() + " - " +bs.getException().getStackTrace());
                          }
 
index 2ce1b670c6ec372da69a595c5f5df5fe3c5ccdd8..0a8856e9de522fe88d90542136f86a733d8434d0 100644 (file)
@@ -260,6 +260,7 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
         Path path = Paths.get(importFile.toURI());
         try {
             runMoniteredOperation(configurator, Files.readAllBytes(path), type);
+
         } catch (Exception e) {
             MessagingUtils.errorDialog("Error importing input stream",
                     this,
@@ -313,6 +314,7 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
                    return DwcaImportConfigurator.NewInstance(null, null);
                case Excel_Distribution:
             return ExcelDistributionUpdateConfigurator.NewInstance(null, null, null);
+
                default:
                        MessagingUtils.notImplementedMessage(this);
                        throw new IllegalArgumentException("Import not supported yet");
@@ -558,6 +560,8 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
         return (ExcelDistributionUpdateConfigurator) getConfigurator(TYPE.Excel_Distribution);
     }
 
+
+
     /**
      * @param configurator
      * @param display
@@ -570,29 +574,29 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
         if (StringUtils.isBlank(reportTextTemp.toString())){
             reportTextTemp.append("No update result available");
             //TODO: this is a workaround because the abcd import writes the report in the report part...
-            if (!importResult.getReports().isEmpty()){
+            if (!importResult.getReports().isEmpty() && importResult.getReports().get(0) != null){
                 reportTextTemp = new StringBuffer();
                 if(importResult!=null){
                     List<byte[]> reports = importResult.getReports();
                     for (byte[] bs : reports) {
-                        reportTextTemp.append(new String(bs));
+                        if (bs != null){ reportTextTemp.append(new String(bs));}
                     }
                 }
             }
         }
         reportText = reportTextTemp;
-            display.asyncExec(new Runnable() {
-
-                @Override
-                public void run() {
-                    // display reports with possibility to save
-                    ReportTextDialog dialog = new ReportTextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
-                    dialog.setTitle(importName+" Report");
-                    dialog.setReportText(reportText.toString());
-                    dialog.open();
-                    CdmStore.getContextManager().notifyContextRefresh();
-                }
-            });
+        display.asyncExec(new Runnable() {
+
+            @Override
+            public void run() {
+                // display reports with possibility to save
+                ReportTextDialog dialog = new ReportTextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+                dialog.setTitle(importName+" Report");
+                dialog.setReportText(reportText.toString());
+                dialog.open();
+                CdmStore.getContextManager().notifyContextRefresh();
+            }
+        });
     }