Project

General

Profile

« Previous | Next » 

Revision 7059456e

Added by Katja Luther almost 7 years ago

extract showResult to a method

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ImportManager.java
206 206
                monitor.beginTask("Importing data", IProgressMonitor.UNKNOWN);
207 207
                IIOService ioService = CdmApplicationState.getIOService();
208 208

  
209
                ioService.importData(configurator, data, type);
209
                ImportResult result = ioService.importData(configurator, data, type);
210 210

  
211 211
                monitor.done();
212 212

  
......
217 217
                        CdmStore.getContextManager().notifyContextRefresh();
218 218
                    }
219 219
                });
220

  
220
                showResult(configurator.getClass().getSimpleName(), display, result);
221 221
                return Status.OK_STATUS;
222 222
            }
223 223
        };
......
438 438
//	                        CdmStore.getContextManager().notifyContextRefresh();
439 439
//	                    }
440 440
//	                });
441

  
441
	                showResult("Gbif Import", display, result);
442 442
	                return Status.OK_STATUS;
443 443
	            }
444 444
	        };
......
467 467
	                        CdmStore.getContextManager().notifyContextRefresh();
468 468
	                    }
469 469
	                });
470

  
470
	                showResult("Abcd Import", display, result);
471 471
	                return Status.OK_STATUS;
472 472
	            }
473 473
	        };
......
480 480
			final List<Abcd206ImportConfigurator> abcdConfigurators) {
481 481
		 Assert.isNotNull(abcdConfigurators, "Configuration may not be null");
482 482
	        final Display display = Display.getDefault();
483
	        Job job = new Job("Import: " + " Dwca") {
483
	        Job job = new Job("Import: " + " Abcd") {
484 484

  
485 485
	            @Override
486 486
	            protected IStatus run(IProgressMonitor monitor) {
......
497 497
	                        CdmStore.getContextManager().notifyContextRefresh();
498 498
	                    }
499 499
	                });
500
	                showResult("Abcd Import", display, result);
501

  
502

  
500 503

  
501 504
	                return Status.OK_STATUS;
502 505
	            }
......
535 538
//                        CdmStore.getContextManager().notifyContextRefresh();
536 539
//                    }
537 540
//                });
538
                final StringBuffer reportText = importResult.createReport();
539
                if (StringUtils.isBlank(reportText.toString())){
540
                    reportText.append("No update result available");
541
                }
542
                    display.asyncExec(new Runnable() {
543

  
544
                        @Override
545
                        public void run() {
546
                            // display reports with possibility to save
547
                            ReportTextDialog dialog = new ReportTextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
548
                            dialog.setTitle(configurator.getClass().getSimpleName()+" Report");
549
                            dialog.setReportText(reportText.toString());
550
                            dialog.open();
551
                            CdmStore.getContextManager().notifyContextRefresh();
552
                        }
553
                    });
541
                showResult(configurator.getClass().getSimpleName(), display, importResult);
554 542

  
555 543

  
556 544
                return Status.OK_STATUS;
557 545
            }
546

  
547

  
558 548
        };
559 549

  
560 550
        return job;
......
568 558
        return (ExcelDistributionUpdateConfigurator) getConfigurator(TYPE.Excel_Distribution);
569 559
    }
570 560

  
571

  
561
    /**
562
     * @param configurator
563
     * @param display
564
     * @param importResult
565
     */
566
    private void showResult(String importName, final Display display,
567
            ImportResult importResult) {
568
        StringBuffer reportTextTemp = importResult.createReport();
569
        final StringBuffer reportText;
570
        if (StringUtils.isBlank(reportTextTemp.toString())){
571
            reportTextTemp.append("No update result available");
572
            //TODO: this is a workaround because the abcd import writes the report in the report part...
573
            if (!importResult.getReports().isEmpty()){
574
                reportTextTemp = new StringBuffer();
575
                if(importResult!=null){
576
                    List<byte[]> reports = importResult.getReports();
577
                    for (byte[] bs : reports) {
578
                        reportTextTemp.append(new String(bs));
579
                    }
580
                }
581
            }
582
        }
583
        reportText = reportTextTemp;
584
            display.asyncExec(new Runnable() {
585

  
586
                @Override
587
                public void run() {
588
                    // display reports with possibility to save
589
                    ReportTextDialog dialog = new ReportTextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
590
                    dialog.setTitle(importName+" Report");
591
                    dialog.setReportText(reportText.toString());
592
                    dialog.open();
593
                    CdmStore.getContextManager().notifyContextRefresh();
594
                }
595
            });
596
    }
572 597

  
573 598

  
574 599

  

Also available in: Unified diff