import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IMemento;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.wb.swt.ResourceManager;
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.databaseAdmin.wizard.ImportPreferencesWizard;
import eu.etaxonomy.taxeditor.model.IContextListener;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
private Text textClassification;
private Classification classification;
+
+ private Text textReferenceString;
+
+ private Button toggleButton;
+ private boolean state;
+
+ private Button openConfigurator;
/**
* @return the classification
*/
*/
@Override
public void createPartControl(Composite parent) {
- final Composite composite = new Composite(parent, SWT.NULL);
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 4;
- composite.setLayout(gridLayout);
- Label label = new Label(composite, SWT.NONE);
+// final Composite composite = new Composite(parent, SWT.NONE);
+//
+// GridLayout gridLayout = new GridLayout();
+// gridLayout.numColumns = 3;
+// composite.setLayout(gridLayout);
+// composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+
+ Composite composite_1 = new Composite(composite, SWT.NONE);
+ GridData gd_composite_1 = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
+ gd_composite_1.widthHint = 280;
+ composite_1.setLayoutData(gd_composite_1);
+ composite_1.setLayout(new GridLayout(3, false));
+
+ Label label = new Label(composite_1, SWT.TOP);
label.setText("Classification");
- textClassification = new Text(composite, SWT.NONE);
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ textClassification = new Text(composite_1, SWT.BORDER);
textClassification.setEnabled(false);
- textClassification.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- btnBrowseClassification = new Button(composite, SWT.NONE);
+ GridData gd_textClassification = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_textClassification.widthHint = 118;
+ textClassification.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
+ btnBrowseClassification = new Button(composite_1, SWT.NONE);
btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
btnBrowseClassification.addListener(SWT.Selection, this);
- btnClear = new Button(composite, SWT.NONE);
+ btnClear = new Button(composite_1, SWT.NONE);
btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
btnClear.addListener(SWT.Selection, this);
-
- CheckboxTableViewer checkboxTableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER | SWT.FULL_SELECTION);
- table = checkboxTableViewer.getTable();
- toolkit.paintBordersFor(table);
-
-
-
+ //source reference
+
+ Label labelRef = new Label(composite_1, SWT.NONE);
+ labelRef.setText("Default import souce reference");
+ labelRef.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ textReferenceString = new Text(composite_1, SWT.NONE);
+ textReferenceString.setEnabled(true);
+ GridData gd_textReferenceString = new GridData(SWT.LEFT, SWT.CENTER, true, true, 3, 1);
+ gd_textReferenceString.widthHint = 229;
+ textReferenceString.setLayoutData(gd_textReferenceString);
+
+ //open configuration
+ openConfigurator = new Button(composite_1, SWT.PUSH);
+ openConfigurator.setText("Configuration");
+ new Label(composite_1, SWT.NONE);
+ new Label(composite_1, SWT.NONE);
+ openConfigurator.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+
+ IWizard wizard = new ImportPreferencesWizard();
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.open();
+ }
+ });
+
+ //checkbox table for result
+ Composite composite_2 = new Composite(composite, SWT.NONE);
+ GridData gd_composite_2 = new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1);
+ gd_composite_2.heightHint = 454;
+ gd_composite_2.widthHint = 403;
+ composite_2.setLayoutData(gd_composite_2);
+ composite_2.setLayout(new GridLayout(2, false));
+
+
+ CheckboxTableViewer checkboxTableViewer = CheckboxTableViewer.newCheckList(composite_2, SWT.BORDER | SWT.FULL_SELECTION);
+
+
+ table = checkboxTableViewer.getTable();
+ GridData gd_table = new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1);
+ gd_table.heightHint = 444;
+ gd_table.widthHint = 312;
+ table.setLayoutData(gd_table);
+ toolkit.paintBordersFor(table);
+ //toggle button
+ toggleButton = new Button(composite_2, SWT.PUSH);
+ GridData gd_toggleButton = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
+ gd_toggleButton.widthHint = 56;
+ toggleButton.setLayoutData(gd_toggleButton);
+ toggleButton.setText("Toggle");
+ toggleButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ state = state ? false : true;
+ for (TableItem item: getTable().getItems()){
+ item.setChecked(state);
+ }
+
+ }
+ });
createActions();
initializeToolBar();
initializeMenu();
textClassification.setText("");
}
}
+
+ /**
+ * @return
+ */
+ public String getReferenceString() {
+
+ return textReferenceString.getText();
+ }
}
package eu.etaxonomy.taxeditor.view.dataimport;
-import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
-import org.apache.http.client.ClientProtocolException;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseResponse;
import eu.etaxonomy.cdm.ext.occurrence.gbif.DataSetResponse;
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifDataSetProtocol;
-import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper;
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
import eu.etaxonomy.cdm.io.specimen.gbif.in.GbifImportConfigurator;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
public class SaveImportedSpecimenAction extends Action {
URI dataSetUri = null;
for (BioCaseResponse response:checkedAbcdResults){
- // if (!response.getDataSetUri().equals(dataSetUri)){
+ if (!response.getDataSetUri().equals(dataSetUri)){
dataSetUri = response.getDataSetUri();
- configuratorAbcd = Abcd206ImportConfigurator.NewInstance(dataSetUri, null, false);
- configuratorAbcd.addMediaAsMediaSpecimen(true);
- configuratorAbcd.setIgnoreAuthorship(true);
- configuratorAbcd.setMoveNewTaxaToDefaultClassification(false);
+
+ configuratorAbcd = PreferencesUtil.getAbcdImportConfigurationPreference(false);
+ configuratorAbcd.setSourceUri(dataSetUri);
+// configuratorAbcd.addMediaAsMediaSpecimen(true);
+// configuratorAbcd.setIgnoreAuthorship(true);
+// configuratorAbcd.setMoveNewTaxaToDefaultClassification(false);
unitIdsBioCase = new HashSet<String[]>();
bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase);
configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery);
- configuratorAbcd.setGetSiblings(true);
+ // configuratorAbcd.setGetSiblings(true);
if (dataImportView.getClassification() != null){
configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid());
}
+ if (dataImportView.getReferenceString() != null){
+ configuratorAbcd.setSourceReferenceTitle(dataImportView.getReferenceString());
+ }
+ abcdConfigurators.add(configuratorAbcd);
- //}
+ }
tripleId = response.getTripleID();
unitIdsBioCase.add(tripleId);
- }
-
- if (!unitIdsBioCase.isEmpty()){
- configuratorAbcd = Abcd206ImportConfigurator.NewInstance(dataSetUri, null, false);
- configuratorAbcd.addMediaAsMediaSpecimen(true);
- configuratorAbcd.setIgnoreAuthorship(true);
- configuratorAbcd.setMoveNewTaxaToDefaultClassification(false);
- if (configuratorAbcd != null){
- abcdConfigurators.add(configuratorAbcd);
- }
-// unitIdsBioCase = new HashSet<String[]>();
- bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase);
- configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery);
- configuratorAbcd.setGetSiblings(true);
- if (dataImportView.getClassification() != null){
- configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid());
- }
}
- for (GbifResponse response: biocaseResponses){
- try {
- dataSetResponse = new GbifQueryServiceWrapper().queryOriginalDataSet(response);
- dataSetUri = dataSetResponse.getEndpoint();
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (!response.getDataSetUri().equals(dataSetUri)){
- configuratorAbcd = Abcd206ImportConfigurator.NewInstance(dataSetUri, null, false);
- configuratorAbcd.addMediaAsMediaSpecimen(true);
- configuratorAbcd.setIgnoreAuthorship(true);
- configuratorAbcd.setMoveNewTaxaToDefaultClassification(false);
- if (configuratorAbcd != null){
- abcdConfigurators.add(configuratorAbcd);
- }
- unitIdsBioCase = new HashSet<String[]>();
- bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase);
- configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery);
- configuratorAbcd.setGetSiblings(true);
- if (dataImportView.getClassification() != null){
- configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid());
- }
- }
- tripleId = response.getTripleID();
- unitIdsBioCase.add(tripleId);
- }
+// if (!unitIdsBioCase.isEmpty()){
+// configuratorAbcd = Abcd206ImportConfigurator.NewInstance(dataSetUri, null, false);
+// configuratorAbcd.addMediaAsMediaSpecimen(true);
+// configuratorAbcd.setIgnoreAuthorship(true);
+// configuratorAbcd.setMoveNewTaxaToDefaultClassification(false);
+// if (configuratorAbcd != null){
+// abcdConfigurators.add(configuratorAbcd);
+// }
+//// unitIdsBioCase = new HashSet<String[]>();
+// bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase);
+// configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery);
+// configuratorAbcd.setGetSiblings(true);
+// if (dataImportView.getClassification() != null){
+// configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid());
+// }
+// }
+
+// for (GbifResponse response: biocaseResponses){
+// try {
+// dataSetResponse = new GbifQueryServiceWrapper().queryOriginalDataSet(response);
+// dataSetUri = dataSetResponse.getEndpoint();
+// } catch (ClientProtocolException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// } catch (IOException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// if (!response.getDataSetUri().equals(dataSetUri)){
+// configuratorAbcd = Abcd206ImportConfigurator.NewInstance(dataSetUri, null, false);
+// configuratorAbcd.addMediaAsMediaSpecimen(true);
+// configuratorAbcd.setIgnoreAuthorship(true);
+// configuratorAbcd.setMoveNewTaxaToDefaultClassification(false);
+// if (configuratorAbcd != null){
+// abcdConfigurators.add(configuratorAbcd);
+// }
+// unitIdsBioCase = new HashSet<String[]>();
+// bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase);
+// configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery);
+// configuratorAbcd.setGetSiblings(true);
+// if (dataImportView.getClassification() != null){
+// configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid());
+// }
+//
+// }
+// tripleId = response.getTripleID();
+// unitIdsBioCase.add(tripleId);
+// }
- OccurenceQuery query = new OccurenceQuery(unitIdsGbif);
- GbifImportConfigurator configurator = GbifImportConfigurator.newInstance(query);
- configurator.setSourceReferenceTitle("Import Gbif data");
// configurator.setQuery(query);
+ if (!checkedAbcdResults.isEmpty()){
+ Job bioCaseJob = CdmStore.getImportManager().createIOServiceJob(abcdConfigurators);
+ CdmStore.getImportManager().run(bioCaseJob);
+ }
- Job bioCaseJob = CdmStore.getImportManager().createIOServiceJob(abcdConfigurators);
- CdmStore.getImportManager().run(bioCaseJob);
+ if (!unitIdsGbif.isEmpty()){
+ OccurenceQuery query = new OccurenceQuery(unitIdsGbif);
+ GbifImportConfigurator configurator = GbifImportConfigurator.newInstance(query);
+ configurator.setSourceReferenceTitle("Import Gbif data");
- Job gbifJob = CdmStore.getImportManager().createIOServiceJob(configurator);
- CdmStore.getImportManager().run(gbifJob);
+ Job gbifJob = CdmStore.getImportManager().createIOServiceJob(configurator);
+ CdmStore.getImportManager().run(gbifJob);
+ }
protected String getTextForTableItem(BioCaseResponse item) {
//TODO: could be defined in user preferences...
String name = null;
- if(!((Abcd206DataHolder)item.getAbcdDataHolder()).getIdentificationList().isEmpty()){
+ if(!(((Abcd206DataHolder)item.getAbcdDataHolder()).getIdentificationList() == null) && !((Abcd206DataHolder)item.getAbcdDataHolder()).getIdentificationList().isEmpty()){
Identification identification = ((Abcd206DataHolder)item.getAbcdDataHolder()).getIdentificationList().iterator().next();
name = identification.getScientificName();
}
if (name != null){
- return name +" - "+((Abcd206DataHolder)item.getAbcdDataHolder()).getCollectionCode() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getFieldNumber() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getKindOfUnit();
+ return name +" - "+((Abcd206DataHolder)item.getAbcdDataHolder()).getCollectionCode() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getUnitID() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getKindOfUnit();
}else {
- return ((Abcd206DataHolder)item.getAbcdDataHolder()).getCollectionCode() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getFieldNumber() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getKindOfUnit();
+ return ((Abcd206DataHolder)item.getAbcdDataHolder()).getCollectionCode() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getUnitID() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getKindOfUnit();
}
}
if (unitsList != null){
for (int i = 0; i <unitsList.getLength(); i++){
Element item = (Element) unitsList.item(i);
- //dataHolder = new Abcd206DataHolder();
+ dataHolder = new Abcd206DataHolder();
+ abcdFieldGetter = new Abcd206XMLFieldGetter(dataHolder, unitAssociationWrapper.getPrefix());
+ state.setPrefix(unitAssociationWrapper.getPrefix());
Abcd206ImportParser.setUnitPropertiesXML(item, abcdFieldGetter, state);
String[] tripleIdBioCase = new String[3];
tripleIdBioCase[0] =dataHolder.getUnitID();
--- /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.view.dataimport;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * @author k.luther
+ * @param <T>
+ * @date 02.05.2017
+ *
+ */
+public class TestSpecimenImportView extends ViewPart {
+ private Text text;
+ private Text text_1;
+ public TestSpecimenImportView() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, true));
+
+ Composite composite_1 = new Composite(composite, SWT.NONE);
+ composite_1.setLayout(new GridLayout(3, false));
+
+ Label lblNewLabel = new Label(composite_1, SWT.NONE);
+ lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ lblNewLabel.setBounds(0, 0, 55, 15);
+ lblNewLabel.setText("Classification");
+
+ text = new Text(composite_1, SWT.BORDER);
+ GridData gd_text = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_text.widthHint = 118;
+ text.setLayoutData(gd_text);
+
+ Button btnNewButton = new Button(composite_1, SWT.NONE);
+ GridData gd_btnNewButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_btnNewButton.widthHint = 36;
+ btnNewButton.setLayoutData(gd_btnNewButton);
+ btnNewButton.setText("New Button");
+
+ Button btnNewButton_1 = new Button(composite_1, SWT.NONE);
+ GridData gd_btnNewButton_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_btnNewButton_1.widthHint = 33;
+ btnNewButton_1.setLayoutData(gd_btnNewButton_1);
+ btnNewButton_1.setBounds(0, 0, 75, 25);
+ btnNewButton_1.setText("New Button");
+
+ Label lblNewLabel_1 = new Label(composite_1, SWT.NONE);
+ lblNewLabel_1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ lblNewLabel_1.setBounds(0, 0, 55, 15);
+ lblNewLabel_1.setText("Default import Source Reference Title");
+
+ text_1 = new Text(composite_1, SWT.BORDER);
+ GridData gd_text_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
+ gd_text_1.widthHint = 112;
+ text_1.setLayoutData(gd_text_1);
+ text_1.setBounds(0, 0, 76, 21);
+
+ Button btnNewButton_2 = new Button(composite_1, SWT.NONE);
+ btnNewButton_2.setBounds(0, 0, 75, 25);
+ btnNewButton_2.setText("Configuration");
+ new Label(composite_1, SWT.NONE);
+ new Label(composite_1, SWT.NONE);
+
+ Composite composite_2 = new Composite(composite, SWT.NONE);
+
+ List list = new List(composite_2, SWT.BORDER);
+ list.setBounds(0, 0, 233, 68);
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setFocus() {
+ // TODO Auto-generated method stub
+
+ }
+}