- added new DataImportEditor for displaying/editing results of specimen search wizard
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / dataimport / wizard / SpecimenSearchWizard.java
1 // $Id$
2 /**
3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.dataimport.wizard;
11
12 import java.io.IOException;
13 import java.net.URISyntaxException;
14 import java.util.List;
15
16 import org.apache.http.client.ClientProtocolException;
17 import org.apache.log4j.Logger;
18 import org.eclipse.jface.viewers.IStructuredSelection;
19 import org.eclipse.jface.wizard.Wizard;
20 import org.eclipse.ui.IImportWizard;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPage;
23 import org.eclipse.ui.PartInitException;
24 import org.eclipse.ui.PlatformUI;
25
26 import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
27 import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper;
28 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
29 import eu.etaxonomy.taxeditor.dataimport.DataImportEditor;
30 import eu.etaxonomy.taxeditor.dataimport.SpecimenEditorInput;
31
32 /**
33 * @author pplitzner
34 * @date 11.09.2013
35 *
36 */
37 public class SpecimenSearchWizard extends Wizard implements IImportWizard {
38 private static final Logger logger = Logger.getLogger(SpecimenSearchWizard.class);
39
40 private BioCaseQueryServiceWrapper bioCaseQueryServiceWrapper;
41 private BioCaseQuery query;
42 private List<SpecimenOrObservationBase> results;
43
44 /**
45 *
46 */
47 public SpecimenSearchWizard() {
48 query = new BioCaseQuery();
49 bioCaseQueryServiceWrapper = new BioCaseQueryServiceWrapper();
50 this.results = getResults();
51 }
52
53
54 /* (non-Javadoc)
55 * @see org.eclipse.jface.wizard.Wizard#performFinish()
56 */
57 @Override
58 public boolean performFinish() {
59 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
60
61 try {
62 SpecimenEditorInput input = new SpecimenEditorInput(results);
63 input.getToolTipText();
64 page.openEditor(input, DataImportEditor.ID, true);
65 } catch ( PartInitException e ) {
66 //Put your exception handler here if you wish to
67 }
68 return true;
69 }
70
71 /* (non-Javadoc)
72 * @see org.eclipse.jface.wizard.Wizard#addPages()
73 */
74 @Override
75 public void addPages() {
76 addPage(new SpecimenSearchWizardPage("Specimen Search", results));
77 }
78
79 public List<SpecimenOrObservationBase> getResults(){
80 try {
81 return bioCaseQueryServiceWrapper.query(query);
82 } catch (ClientProtocolException e) {
83 // TODO Auto-generated catch block
84 e.printStackTrace();
85 } catch (IOException e) {
86 // TODO Auto-generated catch block
87 e.printStackTrace();
88 } catch (URISyntaxException e) {
89 // TODO Auto-generated catch block
90 e.printStackTrace();
91 }
92 return null;
93 }
94
95 /* (non-Javadoc)
96 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
97 */
98 @Override
99 public void init(IWorkbench workbench, IStructuredSelection selection) {
100 }
101
102 /**
103 * @return the query
104 */
105 public BioCaseQuery getQuery() {
106 return query;
107 }
108
109 }