import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
+import eu.etaxonomy.taxeditor.editor.view.dataimport.BioCaseEditorInput;
+import eu.etaxonomy.taxeditor.editor.view.dataimport.DataImportEditor;
+import eu.etaxonomy.taxeditor.editor.view.dataimport.DataImportEditorInput;
+import eu.etaxonomy.taxeditor.editor.view.dataimport.GbifImportEditor;
+import eu.etaxonomy.taxeditor.editor.view.dataimport.GbifImportEditorInput;
+import eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenImportEditor;
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
open(input, DerivateView.ID);
}
+ /**
+ * Opens a new {@link DataImportEditor} for the given input
+ * @param input a {@link DataImportEditorInput}
+ * @throws PartInitException
+ */
+ public static void open(DataImportEditorInput<?> input)
+ throws PartInitException {
+ if(input instanceof BioCaseEditorInput){
+ open(input, SpecimenImportEditor.ID);
+ }
+ else if(input instanceof GbifImportEditorInput){
+ open(input, GbifImportEditor.ID);
+ }
+ }
+
/**
* Taxon Editors may be opened by supplying a taxon node uuid. Session gets
* initialised here and is passed to the editor
import java.io.IOException;
import java.io.InputStream;
-import java.net.URISyntaxException;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
*/
public class BioCaseEditorInput extends DataImportEditorInput<SpecimenOrObservationBase<?>> {
+ private final URI endPoint;
+
/**
- * @param results
+ * Constructs a new BioCaseEditorInput.
+ * @param query The {@link OccurenceQuery} object holding all necessary parameters.
+ * @param endPoint If the endPoint {@link URI} is <code>null</code> then the default endPoint is used
+ * (<i>http://ww3.bgbm.org/biocase/pywrapper.cgi?dsa=Herbar</i>)
*/
- public BioCaseEditorInput(OccurenceQuery query) {
+ public BioCaseEditorInput(OccurenceQuery query, URI endPoint) {
super();
this.query = query;
+ this.endPoint = endPoint;
}
@Override
try {
//FIXME move ABCD import to cdmlib -> this will also get rid of the transient services
InputStream resultStream;
- resultStream = new BioCaseQueryServiceWrapper().query(query);
+ resultStream = new BioCaseQueryServiceWrapper().query(query, endPoint);
Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false);
TransientCdmRepository repo =
new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration());
logger.error(errorMessage, e);
} catch (IOException e) {
logger.error(errorMessage, e);
- } catch (URISyntaxException e) {
- logger.error(errorMessage, e);
}
setResults(results);
package eu.etaxonomy.taxeditor.editor.view.dataimport;
+import java.io.IOException;
+
+import org.apache.http.client.ClientProtocolException;
+import org.apache.log4j.Logger;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
+import eu.etaxonomy.cdm.ext.occurrence.gbif.DataSetResponse;
+import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper;
+import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+
public class QueryOriginalRecordCommand extends AbstractHandler {
+ private final Logger logger = Logger.getLogger(QueryOriginalRecordCommand.class);
+
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
StructuredSelection structuredSelection = (StructuredSelection)selection;
if(structuredSelection.size()==1){
Object next = structuredSelection.iterator().next();
-// if(next instanceof GbifResponse){
-// InputStream inputStream = new GbifQueryServiceWrapper().queryForOriginalRecord((GbifResponse)next);
-// BioCaseEditorInput input = new BioCaseEditorInput(query);
-// }
+ if(next instanceof GbifResponse){
+ try{
+ DataSetResponse response = new GbifQueryServiceWrapper().queryOriginalDataSet((GbifResponse)next);
+ final BioCaseEditorInput input = new BioCaseEditorInput(new OccurenceQuery(response.getUnitId()), response.getEndpoint());
+ EditorUtil.open(input);
+ Job queryJob = new Job("Querying for original record...") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ input.query();
+ return Status.OK_STATUS;
+ }
+ };
+ queryJob.schedule();
+ } catch (ClientProtocolException e) {
+ logger.error("Query for single record failed.", e);
+ } catch (IOException e) {
+ logger.error("Query for single record failed.", e);
+ } catch (PartInitException e) {
+ logger.error("Could not open editor.", e);
+ }
+ }
}
}
return null;
import org.eclipse.ui.PlatformUI;
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
query = searchPage.getQuery();
switch (providerSelectionPage.getQueryType()) {
case BIOCASE:
- input = new BioCaseEditorInput(query);
+ input = new BioCaseEditorInput(query, null);
editorId = SpecimenImportEditor.ID;
break;
case GBIF:
break;
}
try {
- page.openEditor(input, editorId, true);
+ EditorUtil.open(input);
} catch ( PartInitException e ) {
//Put your exception handler here if you wish to
}