viewCommandMapping.viewerName.TAXON_NODE_WIZARD = Taxon node Wizard\r
command.label.CHANGE_PASSWORD = Change password\r
wizard.name.22 = Output Model\r
+wizard.name.23 = Excel Distribution Data Update\r
command.label.25 = Import Preferences
\ No newline at end of file
viewCommandMapping.viewerName.TAXON_NODE_WIZARD = Taxonknoten-Wizard
command.label.CHANGE_PASSWORD = Kennwort ändern
wizard.name.22 = Output Model
+wizard.name.23 = Excel Verbreitungsdaten Update
command.label.25 = Import Präferenzen
\ No newline at end of file
class="eu.etaxonomy.taxeditor.io.wizard.AbcdImportWizard"
id="eu.etaxonomy.taxeditor.io.import.abcd"
name="%wizard.name.3">
+ </wizard>
+ <wizard
+ category="eu.etaxonomy.taxeditor.import.category.cdm"
+ class="eu.etaxonomy.taxeditor.io.wizard.ExcelDistributionUpdateWizard"
+ id="eu.etaxonomy.taxeditor.io.import.excelDistribution"
+ name="%wizard.name.23">
</wizard>
<wizard
category="eu.etaxonomy.taxeditor.import.category.cdm"
protected ICdmRepository applicationConfiguration;
public static enum TYPE {
- Jaxb, Tcs, Excel_Taxa, Endnote, Sdd, Abcd, SpecimenCdmExcel, Excel_Name, SpecimenSearch, Gbif
+ Jaxb, Tcs, Excel_Taxa, Endnote, Sdd, Abcd, SpecimenCdmExcel, Excel_Name, SpecimenSearch, Gbif, Excel_Distribution
}
/**
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
import eu.etaxonomy.cdm.io.common.ImportResult;
import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
+import eu.etaxonomy.cdm.io.distribution.excelupdate.ExcelDistributionUpdateConfigurator;
import eu.etaxonomy.cdm.io.dwca.in.DwcaImportConfigurator;
import eu.etaxonomy.cdm.io.excel.taxa.NormalExplicitImportConfigurator;
import eu.etaxonomy.cdm.io.jaxb.JaxbImportConfigurator;
return Abcd206ImportConfigurator.NewInstance(null, null);
case Gbif:
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");
} else if (configurator instanceof CacheUpdaterConfigurator){
CacheUpdaterConfigurator config = (CacheUpdaterConfigurator) configurator;
ioService.updateCaches(config);
+ } else if (configurator instanceof ExcelDistributionUpdateConfigurator){
+ ExcelDistributionUpdateConfigurator config = (ExcelDistributionUpdateConfigurator) configurator;
+ ioService.updateDistributionData(config);
}
monitor.done();
}
+ /**
+ * @return
+ */
+ public ExcelDistributionUpdateConfigurator ExcelDistributionUpdateConfigurator() {
+ return (ExcelDistributionUpdateConfigurator) getConfigurator(TYPE.Excel_Distribution);
+ }
+
--- /dev/null
+/**
+* Copyright (C) 2017 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.taxeditor.io.wizard;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.util.UUID;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.io.distribution.excelupdate.ExcelDistributionUpdateConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @date 03.05.2017
+ *
+ */
+public class ExcelDistributionUpdateWizard extends AbstractImportWizard<ExcelDistributionUpdateConfigurator> {
+ private ExcelDistributionUpdateConfigurator configurator;
+
+ private ImportFromFileAndChooseVocIdWizardOage dataSourcePage;
+
+ private static final Logger logger = Logger.getLogger(ExcelDistributionUpdateWizard.class);
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
+ */
+ /** {@inheritDoc} */
+ @Override
+ public ExcelDistributionUpdateConfigurator getConfigurator() {
+ return configurator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ /** {@inheritDoc} */
+ @Override
+ public boolean performFinish() {
+ URI source = dataSourcePage.getUri();
+ // configurator.setSource(source);
+ configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
+ File file = new File(source);
+ FileInputStream fis = null;
+
+ try {
+ fis = new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ logger.error("Error while reading file" + source.toString());
+ }
+ try {
+ configurator.setStream(IOUtils.toByteArray(fis));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ UUID vocUuid = dataSourcePage.getVocUuid();
+
+ configurator.setAreaVocabularyUuid(vocUuid);
+ Job job = CdmStore.getImportManager().createIOServiceJob(configurator);
+ CdmStore.getImportManager().run(job);
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+ configurator = CdmStore.getImportManager().ExcelDistributionUpdateConfigurator();
+
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#addPages()
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void addPages() {
+ super.addPages();
+
+ dataSourcePage = new ImportFromFileAndChooseVocIdWizardOage("Choose NormalExplicit",
+ "Please choose an xls file in the NormalExplicit format.", new String[]{"*.xlsx", "*.xls", "*.*"});
+ addPage(dataSourcePage);
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2017 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.taxeditor.io.wizard;
+
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @date 04.05.2017
+ *
+ */
+public class ImportFromFileAndChooseVocIdWizardOage extends ImportFromFileDataSourceWizardPage {
+
+ private Combo vocabularyCombo;
+ UUID vocUuid;
+ String[][] labelAndValues;
+ /**
+ * @param title
+ * @param description
+ * @param extensions
+ */
+ protected ImportFromFileAndChooseVocIdWizardOage(String title, String description, String[] extensions) {
+ super(title, description, extensions);
+
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ Composite composite = (Composite)getControl();
+ // final Composite composite = new Composite(parent, SWT.NULL);
+
+ vocabularyCombo = new Combo(composite, SWT.DROP_DOWN);
+ List<TermVocabulary<DefinedTermBase>> vocs = CdmStore.getService(IVocabularyService.class).findByTermType(TermType.NamedArea);
+ for(TermVocabulary voc: vocs){
+ vocabularyCombo.add(voc.getLabel());
+ }
+ getLabelAndValues(vocs);
+ vocabularyCombo.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String name = vocabularyCombo.getText();
+
+ for (String[] labelAndValue: labelAndValues){
+ if (labelAndValue[0].equals(name)){
+ String uuidString = labelAndValue[1];
+ vocUuid = UUID.fromString(uuidString);
+ if (text_source.getText() != null){
+ setPageComplete(true);
+ } else{
+ setPageComplete(false);
+ }
+ }
+ }
+
+ }
+
+ });
+ //setControl(composite);
+ }
+
+ public UUID getVocUuid() {
+ return vocUuid;
+ }
+
+ public void setVocUuid(UUID vocUuid) {
+ this.vocUuid = vocUuid;
+ }
+
+ /**
+ * @return
+ */
+ private String[][] getLabelAndValues(List<TermVocabulary<DefinedTermBase>> vocs) {
+
+ labelAndValues = new String[vocs.size()][2];
+ for (int i = 0; i < vocs.size(); i++) {
+ labelAndValues[i][0] = vocs.get(i).getLabel();
+ labelAndValues[i][1] = vocs.get(i).getUuid().toString();
+ }
+ return labelAndValues;
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ boolean result = CdmUtils.isNotBlank(text_source.getText()) && vocUuid != null;
+
+ return result;
+ }
+
+}