Revision 65a3658c
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.store/fragment.e4xmi | ||
---|---|---|
107 | 107 |
<elements xsi:type="commands:Command" xmi:id="_l-AGEKjzEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.openReferencingObjectsView" commandName="%command.name.OPEN_REFERENCING_OBJECTS_VIEW"/> |
108 | 108 |
<elements xsi:type="commands:Command" xmi:id="_TwGSwKkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.workbench.command.importSpecimens" commandName="Import specimens"/> |
109 | 109 |
<elements xsi:type="commands:Command" xmi:id="_QbHeEKmQEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.store.command.importAbcd" commandName="Import ABCD"/> |
110 |
<elements xsi:type="commands:Command" xmi:id="_tpPnUKmfEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importExcelDistribution" commandName="Import Excel Distribution"/> |
|
110 | 111 |
</fragments> |
111 | 112 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application"> |
112 | 113 |
<elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/> |
... | ... | |
116 | 117 |
<elements xsi:type="commands:Handler" xmi:id="_fKcuoKjzEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.handler.defaultHandler.OpenReferencingObjectsViewHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.defaultHandler.OpenReferencingObjectsViewHandler" command="_l-AGEKjzEeejedk4mZQIGw"/> |
117 | 118 |
<elements xsi:type="commands:Handler" xmi:id="_WyDA0KkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.view.dataimport.e4.handler.OpenSpecimenImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.dataimport.e4.handler.OpenSpecimenImportWizard" command="_TwGSwKkVEeejedk4mZQIGw"/> |
118 | 119 |
<elements xsi:type="commands:Handler" xmi:id="_2yHUgKmYEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.io.e4.abcd.OpenAbcdImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.abcd.OpenAbcdImportWizard" command="_QbHeEKmQEeeDJPU_cUTI2g"/> |
120 |
<elements xsi:type="commands:Handler" xmi:id="_6slh0KmfEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.distribution.OpenExcelDistributionImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.excel.distribution.OpenExcelDistributionImportWizard" command="_tpPnUKmfEeeTAPHmaMLwQQ"/> |
|
119 | 121 |
</fragments> |
120 | 122 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_qT4hgIfTEeecZ4F2Y9Z0Og" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu.window" positionInList="before:eu.etaxonomy.taxeditor.application.windowMenu.last"> |
121 | 123 |
<elements xsi:type="menu:Menu" xmi:id="_LT3P8IfcEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.menu.termeditor" label="Term Editor"> |
... | ... | |
133 | 135 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_ITE10KkVEeejedk4mZQIGw" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu.file" positionInList="before:eu.etaxonomy.taxeditor.application.handledmenuitem.export"> |
134 | 136 |
<elements xsi:type="menu:Menu" xmi:id="_QC5O8KkaEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.store.menu.import" label="Import (E4)"> |
135 | 137 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_UL4dkKkaEeejedk4mZQIGw" coreExpressionId="isCdmStoreConnected"/> |
136 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_RUOtQKkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.importspecimens" label="Import specimens" command="_TwGSwKkVEeejedk4mZQIGw"/>
|
|
138 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_RUOtQKkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.importspecimens" label="Specimens" command="_TwGSwKkVEeejedk4mZQIGw"/>
|
|
137 | 139 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_NO718KmQEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importAbcd" label="ABCD" command="_QbHeEKmQEeeDJPU_cUTI2g"/> |
140 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_-h0G8KmfEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.exceldistribution" label="Excel Distribution" command="_tpPnUKmfEeeTAPHmaMLwQQ"/> |
|
138 | 141 |
</elements> |
139 | 142 |
</fragments> |
140 | 143 |
</fragment:ModelFragments> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/GenericConfiguratorWizardPageE4.java | ||
---|---|---|
45 | 45 |
private List<String> ignoreMethods; |
46 | 46 |
|
47 | 47 |
@Inject |
48 |
private GenericConfiguratorWizardPageE4() {
|
|
48 |
public GenericConfiguratorWizardPageE4() {
|
|
49 | 49 |
super("Configuration"); |
50 | 50 |
} |
51 | 51 |
|
52 |
public void init(String title, String description, IIoConfigurator configurator, List<String> ignoreMethods){
|
|
52 |
private void init(String title, String description, IIoConfigurator configurator, List<String> ignoreMethods){
|
|
53 | 53 |
this.setTitle(title); |
54 | 54 |
this.setDescription(description); |
55 | 55 |
this.configurator = configurator; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/ImportFromFileAndChooseVocIdWizardPageE4.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.io.e4; |
|
10 |
|
|
11 |
import java.util.List; |
|
12 |
import java.util.UUID; |
|
13 |
|
|
14 |
import javax.inject.Inject; |
|
15 |
|
|
16 |
import org.eclipse.swt.SWT; |
|
17 |
import org.eclipse.swt.events.SelectionAdapter; |
|
18 |
import org.eclipse.swt.events.SelectionEvent; |
|
19 |
import org.eclipse.swt.layout.GridData; |
|
20 |
import org.eclipse.swt.widgets.Combo; |
|
21 |
import org.eclipse.swt.widgets.Composite; |
|
22 |
import org.eclipse.swt.widgets.Label; |
|
23 |
|
|
24 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
25 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
26 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
27 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
28 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
29 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
30 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author k.luther |
|
34 |
* @date 04.05.2017 |
|
35 |
* |
|
36 |
*/ |
|
37 |
public class ImportFromFileAndChooseVocIdWizardPageE4 extends ImportFromFileDataSourceWizardPageE4 { |
|
38 |
|
|
39 |
private Combo vocabularyCombo; |
|
40 |
UUID vocUuid; |
|
41 |
String[][] labelAndValues; |
|
42 |
|
|
43 |
@Inject |
|
44 |
public ImportFromFileAndChooseVocIdWizardPageE4() { |
|
45 |
super(); |
|
46 |
setTitle("Choose Excel File"); |
|
47 |
setDescription("Please choose an xls file in the Distribution Update format."); |
|
48 |
setExtensions(new String[]{"*.xlsx", "*.xls", "*.*"}); |
|
49 |
|
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public void createControl(Composite parent) { |
|
54 |
super.createControl(parent); |
|
55 |
Composite composite = (Composite)getControl(); |
|
56 |
// final Composite composite = new Composite(parent, SWT.NULL); |
|
57 |
GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); |
|
58 |
composite.setLayoutData(gridData); |
|
59 |
Label label = new Label(composite, SWT.NONE); |
|
60 |
label.setText(Messages.ImportFromFileAndChooseVocIdWizardPage_AreaVoc); |
|
61 |
label.setToolTipText(Messages.ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip); |
|
62 |
vocabularyCombo = new Combo(composite, SWT.DROP_DOWN); |
|
63 |
List<TermVocabulary<DefinedTermBase>> vocs = CdmStore.getService(IVocabularyService.class).findByTermType(TermType.NamedArea, null); |
|
64 |
for(TermVocabulary voc: vocs){ |
|
65 |
vocabularyCombo.add(voc.getLabel()); |
|
66 |
} |
|
67 |
getLabelAndValues(vocs); |
|
68 |
vocabularyCombo.select(0); |
|
69 |
vocabularyCombo.addSelectionListener(new SelectionAdapter(){ |
|
70 |
|
|
71 |
@Override |
|
72 |
public void widgetSelected(SelectionEvent e) { |
|
73 |
String name = vocabularyCombo.getText(); |
|
74 |
|
|
75 |
for (String[] labelAndValue: labelAndValues){ |
|
76 |
if (labelAndValue[0].equals(name)){ |
|
77 |
String uuidString = labelAndValue[1]; |
|
78 |
vocUuid = UUID.fromString(uuidString); |
|
79 |
setPageComplete(isPageComplete()); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
} |
|
84 |
|
|
85 |
}); |
|
86 |
} |
|
87 |
|
|
88 |
public UUID getVocUuid() { |
|
89 |
return vocUuid; |
|
90 |
} |
|
91 |
|
|
92 |
public void setVocUuid(UUID vocUuid) { |
|
93 |
this.vocUuid = vocUuid; |
|
94 |
} |
|
95 |
|
|
96 |
private String[][] getLabelAndValues(List<TermVocabulary<DefinedTermBase>> vocs) { |
|
97 |
|
|
98 |
labelAndValues = new String[vocs.size()][2]; |
|
99 |
for (int i = 0; i < vocs.size(); i++) { |
|
100 |
labelAndValues[i][0] = vocs.get(i).getLabel(); |
|
101 |
labelAndValues[i][1] = vocs.get(i).getUuid().toString(); |
|
102 |
} |
|
103 |
return labelAndValues; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public boolean isPageComplete() { |
|
108 |
boolean result = CdmUtils.isNotBlank(text_source.getText()) && vocUuid != null; |
|
109 |
|
|
110 |
return result; |
|
111 |
} |
|
112 |
|
|
113 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/ImportFromFileDataSourceWizardPageE4.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
/** |
32 | 32 |
* |
33 |
* @author n.hoffmann
|
|
34 |
* @created 04.08.2009
|
|
35 |
* @version 1.0
|
|
33 |
* @author pplitzner
|
|
34 |
* @since Oct 5, 2017
|
|
35 |
* |
|
36 | 36 |
*/ |
37 | 37 |
public class ImportFromFileDataSourceWizardPageE4 extends WizardPage { |
38 | 38 |
|
39 |
/** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */ |
|
40 | 39 |
public static final String PAGE_NAME = "CdmXmlDataSourceWizardPage"; |
41 | 40 |
|
42 | 41 |
private String[] extensions = {"*.xml"}; |
... | ... | |
54 | 53 |
|
55 | 54 |
setDescription("Select XML file."); |
56 | 55 |
|
57 |
this.extensions = new String[]{"*.xml","*.*"};
|
|
56 |
setExtensions(new String[]{"*.xml","*.*"});
|
|
58 | 57 |
} |
59 | 58 |
|
59 |
public void setExtensions(String[] extensions) { |
|
60 |
this.extensions = extensions; |
|
61 |
} |
|
62 |
|
|
60 | 63 |
/** {@inheritDoc} */ |
61 | 64 |
@Override |
62 | 65 |
public void createControl(Composite parent) { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/excel/distribution/ExcelDistributionUpdateWizardE4.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.io.e4.excel.distribution; |
|
10 |
|
|
11 |
import java.io.File; |
|
12 |
import java.io.FileInputStream; |
|
13 |
import java.io.FileNotFoundException; |
|
14 |
import java.io.IOException; |
|
15 |
import java.net.URI; |
|
16 |
import java.util.ArrayList; |
|
17 |
import java.util.List; |
|
18 |
import java.util.UUID; |
|
19 |
|
|
20 |
import javax.inject.Inject; |
|
21 |
|
|
22 |
import org.apache.commons.io.IOUtils; |
|
23 |
import org.apache.log4j.Logger; |
|
24 |
import org.eclipse.core.runtime.jobs.Job; |
|
25 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
|
26 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
|
27 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
28 |
|
|
29 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
30 |
import eu.etaxonomy.cdm.io.distribution.excelupdate.ExcelDistributionUpdateConfigurator; |
|
31 |
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4; |
|
32 |
import eu.etaxonomy.taxeditor.io.e4.GenericConfiguratorWizardPageE4; |
|
33 |
import eu.etaxonomy.taxeditor.io.e4.ImportFromFileAndChooseVocIdWizardPageE4; |
|
34 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
35 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
36 |
|
|
37 |
/** |
|
38 |
* @author k.luther |
|
39 |
* @date 03.05.2017 |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class ExcelDistributionUpdateWizardE4 extends AbstractImportWizardE4<ExcelDistributionUpdateConfigurator> { |
|
43 |
|
|
44 |
|
|
45 |
private ExcelDistributionUpdateConfigurator configurator; |
|
46 |
|
|
47 |
private ImportFromFileAndChooseVocIdWizardPageE4 dataSourcePage; |
|
48 |
|
|
49 |
private static final Logger logger = Logger.getLogger(ExcelDistributionUpdateWizardE4.class); |
|
50 |
|
|
51 |
@Inject |
|
52 |
public ExcelDistributionUpdateWizardE4(IEclipseContext context, EPartService partService) { |
|
53 |
super(context, partService); |
|
54 |
} |
|
55 |
|
|
56 |
/** {@inheritDoc} */ |
|
57 |
@Override |
|
58 |
public ExcelDistributionUpdateConfigurator getConfigurator() { |
|
59 |
return configurator; |
|
60 |
} |
|
61 |
|
|
62 |
/** {@inheritDoc} */ |
|
63 |
@Override |
|
64 |
public boolean performFinish() { |
|
65 |
URI source = dataSourcePage.getUri(); |
|
66 |
// configurator.setSource(source); |
|
67 |
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE); |
|
68 |
File file = new File(source); |
|
69 |
FileInputStream fis = null; |
|
70 |
|
|
71 |
try { |
|
72 |
fis = new FileInputStream(file); |
|
73 |
} catch (FileNotFoundException e) { |
|
74 |
logger.error("Error while reading file" + source.toString()); |
|
75 |
} |
|
76 |
try { |
|
77 |
configurator.setStream(IOUtils.toByteArray(fis)); |
|
78 |
} catch (IOException e) { |
|
79 |
// TODO Auto-generated catch block |
|
80 |
e.printStackTrace(); |
|
81 |
} |
|
82 |
UUID vocUuid = dataSourcePage.getVocUuid(); |
|
83 |
|
|
84 |
configurator.setAreaVocabularyUuid(vocUuid); |
|
85 |
//CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM); |
|
86 |
Job job = CdmStore.getImportManager().createIOServiceJob(configurator); |
|
87 |
CdmStore.getImportManager().run(job); |
|
88 |
|
|
89 |
return true; |
|
90 |
} |
|
91 |
|
|
92 |
/** {@inheritDoc} */ |
|
93 |
@Override |
|
94 |
public void init() { |
|
95 |
configurator = CdmStore.getImportManager().ExcelDistributionUpdateConfigurator(); |
|
96 |
|
|
97 |
} |
|
98 |
|
|
99 |
/** {@inheritDoc} */ |
|
100 |
@Override |
|
101 |
public void addPages() { |
|
102 |
addConfiguratorPage(); |
|
103 |
addDataSourcePage(); |
|
104 |
|
|
105 |
|
|
106 |
} |
|
107 |
@Override |
|
108 |
protected void addConfiguratorPage(){ |
|
109 |
List<String> ignoreMethods = new ArrayList<>(); |
|
110 |
ignoreMethods.add("setIgnoreNull"); |
|
111 |
ignoreMethods.add("setInteractWithUser"); |
|
112 |
ignoreMethods.add("setUseClassification"); |
|
113 |
pageConfiguration = ContextInjectionFactory.make(GenericConfiguratorWizardPageE4.class, context); |
|
114 |
pageConfiguration.initImport(getConfigurator(), ignoreMethods, Messages.ExcelDistributionUpdateWizard_ConfiguratorWizard_label); |
|
115 |
addPage(pageConfiguration); |
|
116 |
} |
|
117 |
|
|
118 |
private void addDataSourcePage(){ |
|
119 |
dataSourcePage = ContextInjectionFactory.make(ImportFromFileAndChooseVocIdWizardPageE4.class, context); |
|
120 |
addPage(dataSourcePage); |
|
121 |
} |
|
122 |
|
|
123 |
|
|
124 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/excel/distribution/OpenExcelDistributionImportWizard.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.io.e4.excel.distribution; |
|
10 |
|
|
11 |
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4; |
|
12 |
import eu.etaxonomy.taxeditor.io.e4.AbstractOpenImportWizard; |
|
13 |
|
|
14 |
/** |
|
15 |
* @author pplitzner |
|
16 |
* @since Oct 5, 2017 |
|
17 |
* |
|
18 |
*/ |
|
19 |
public class OpenExcelDistributionImportWizard extends AbstractOpenImportWizard { |
|
20 |
|
|
21 |
/** |
|
22 |
* {@inheritDoc} |
|
23 |
*/ |
|
24 |
@Override |
|
25 |
protected Class<? extends AbstractImportWizardE4> getImportWizardClass() { |
|
26 |
return ExcelDistributionUpdateWizardE4.class; |
|
27 |
} |
|
28 |
|
|
29 |
} |
Also available in: Unified diff
ref #7005 Migrate Excel distribution import