Revision 5f152d2b
Added by Patrick Plitzner over 9 years ago
- added new DataImportEditor for GbifResponses
- allows querying for original record via context menu
.gitattributes | ||
---|---|---|
482 | 482 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/OpenRelatedConceptHandler.java -text |
483 | 483 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java -text |
484 | 484 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java -text |
485 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/BioCaseEditorInput.java -text |
|
485 | 486 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java -text |
486 | 487 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorInput.java -text |
488 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditor.java -text |
|
489 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditorInput.java -text |
|
490 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/QueryOriginalRecordCommand.java -text |
|
487 | 491 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/QueryType.java -text |
488 | 492 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SaveSpecimenCommand.java -text |
489 | 493 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditor.java -text |
490 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditorInput.java -text |
|
491 | 494 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenProviderSelectionWizardPage.java -text |
492 | 495 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizard.java -text |
493 | 496 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizardPage.java -text |
eu.etaxonomy.taxeditor.editor/plugin.xml | ||
---|---|---|
71 | 71 |
id="eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenImportEditor" |
72 | 72 |
name="Specimen Import Editor"> |
73 | 73 |
</editor> |
74 |
<editor |
|
75 |
class="eu.etaxonomy.taxeditor.editor.view.dataimport.GbifImportEditor" |
|
76 |
default="false" |
|
77 |
id="eu.etaxonomy.taxeditor.editor.view.dataimport.GbifImportEditor" |
|
78 |
name="Gbif Import Editor"> |
|
79 |
</editor> |
|
74 | 80 |
</extension> |
75 | 81 |
<extension |
76 | 82 |
point="org.eclipse.ui.views"> |
... | ... | |
577 | 583 |
style="push"> |
578 | 584 |
</command> |
579 | 585 |
</menuContribution> |
586 |
<menuContribution |
|
587 |
locationURI="popup:eu.etaxonomy.taxeditor.editor.view.dataimport.GbifImportEditor"> |
|
588 |
<command |
|
589 |
commandId="eu.etaxonomy.taxeditor.editor.view.dataimport.SaveSpecimenCommand" |
|
590 |
label="Save Specimen" |
|
591 |
style="push"> |
|
592 |
</command> |
|
593 |
<command |
|
594 |
commandId="eu.etaxonomy.taxeditor.editor.view.dataimport.QueryOriginalRecordCommand" |
|
595 |
label="Query original data record" |
|
596 |
style="push"> |
|
597 |
</command> |
|
598 |
</menuContribution> |
|
580 | 599 |
|
581 | 600 |
|
582 | 601 |
|
... | ... | |
1107 | 1126 |
id="eu.etaxonomy.taxeditor.editor.view.dataimport.SaveSpecimenCommand" |
1108 | 1127 |
name="Save Specimen"> |
1109 | 1128 |
</command> |
1129 |
<command |
|
1130 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.dataimport.QueryOriginalRecordCommand" |
|
1131 |
id="eu.etaxonomy.taxeditor.editor.view.dataimport.QueryOriginalRecordCommand" |
|
1132 |
name="Query original data record"> |
|
1133 |
</command> |
|
1110 | 1134 |
|
1111 | 1135 |
</extension> |
1112 | 1136 |
<extension |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/BioCaseEditorInput.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2014 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.editor.view.dataimport; |
|
11 |
|
|
12 |
import java.io.IOException; |
|
13 |
import java.io.InputStream; |
|
14 |
import java.net.URISyntaxException; |
|
15 |
import java.util.ArrayList; |
|
16 |
import java.util.Collection; |
|
17 |
|
|
18 |
import org.apache.http.client.ClientProtocolException; |
|
19 |
import org.eclipse.swt.widgets.Display; |
|
20 |
|
|
21 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; |
|
22 |
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper; |
|
23 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
24 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator; |
|
25 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
26 |
import eu.etaxonomy.taxeditor.editor.view.dataimport.transientServices.TransientCdmRepository; |
|
27 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author pplitzner |
|
31 |
* @date 25.02.2014 |
|
32 |
* |
|
33 |
*/ |
|
34 |
public class BioCaseEditorInput extends DataImportEditorInput<SpecimenOrObservationBase<?>> { |
|
35 |
|
|
36 |
private final OccurenceQuery query; |
|
37 |
|
|
38 |
/** |
|
39 |
* @param results |
|
40 |
*/ |
|
41 |
public BioCaseEditorInput(OccurenceQuery query) { |
|
42 |
super(); |
|
43 |
this.query = query; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public void query(){ |
|
48 |
String errorMessage = "Could not execute query " + query; |
|
49 |
|
|
50 |
Collection<SpecimenOrObservationBase<?>> results = new ArrayList<SpecimenOrObservationBase<?>>(); |
|
51 |
try { |
|
52 |
InputStream resultStream; |
|
53 |
resultStream = new BioCaseQueryServiceWrapper().query(query); |
|
54 |
Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false); |
|
55 |
TransientCdmRepository repo = |
|
56 |
new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration()); |
|
57 |
configurator.setCdmAppController(repo); |
|
58 |
|
|
59 |
CdmDefaultImport<Abcd206ImportConfigurator> importer = new CdmDefaultImport<Abcd206ImportConfigurator>(); |
|
60 |
importer.invoke(configurator); |
|
61 |
results = repo.getUnits(); |
|
62 |
setResults(results); |
|
63 |
} catch (ClientProtocolException e) { |
|
64 |
logger.error(errorMessage, e); |
|
65 |
} catch (IOException e) { |
|
66 |
logger.error(errorMessage, e); |
|
67 |
} catch (URISyntaxException e) { |
|
68 |
logger.error(errorMessage, e); |
|
69 |
} |
|
70 |
|
|
71 |
setResults(results); |
|
72 |
|
|
73 |
Display.getDefault().asyncExec(new Runnable() { |
|
74 |
|
|
75 |
@Override |
|
76 |
public void run() { |
|
77 |
CdmStore.getContextManager().notifyContextRefresh(); |
|
78 |
} |
|
79 |
}); |
|
80 |
} |
|
81 |
|
|
82 |
/* (non-Javadoc) |
|
83 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
84 |
*/ |
|
85 |
@Override |
|
86 |
public String getName() { |
|
87 |
return "[BioCASE] " + query.toString(); |
|
88 |
} |
|
89 |
|
|
90 |
/* (non-Javadoc) |
|
91 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
92 |
*/ |
|
93 |
@Override |
|
94 |
public String getToolTipText() { |
|
95 |
return "[BioCASE] " + query.toString(); |
|
96 |
} |
|
97 |
|
|
98 |
/* (non-Javadoc) |
|
99 |
* @see java.lang.Object#hashCode() |
|
100 |
*/ |
|
101 |
@Override |
|
102 |
public int hashCode() { |
|
103 |
final int prime = 31; |
|
104 |
int result = 1; |
|
105 |
result = prime * result + ((query == null) ? 0 : query.hashCode()); |
|
106 |
return result; |
|
107 |
} |
|
108 |
|
|
109 |
/* (non-Javadoc) |
|
110 |
* @see java.lang.Object#equals(java.lang.Object) |
|
111 |
*/ |
|
112 |
@Override |
|
113 |
public boolean equals(Object obj) { |
|
114 |
if (this == obj) { |
|
115 |
return true; |
|
116 |
} |
|
117 |
if (obj == null) { |
|
118 |
return false; |
|
119 |
} |
|
120 |
if (getClass() != obj.getClass()) { |
|
121 |
return false; |
|
122 |
} |
|
123 |
BioCaseEditorInput other = (BioCaseEditorInput) obj; |
|
124 |
if (query == null) { |
|
125 |
if (other.query != null) { |
|
126 |
return false; |
|
127 |
} |
|
128 |
} else if (!query.equals(other.query)) { |
|
129 |
return false; |
|
130 |
} |
|
131 |
return true; |
|
132 |
} |
|
133 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
30 | 30 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
31 |
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity; |
|
32 | 31 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
33 | 32 |
import eu.etaxonomy.taxeditor.model.IContextListener; |
34 | 33 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider; |
... | ... | |
43 | 42 |
* @date 20.09.2013 |
44 | 43 |
* |
45 | 44 |
*/ |
46 |
public abstract class DataImportEditor<T extends IIdentifiableEntity> extends EditorPart implements IPartContentHasFactualData, IDirtyMarkableSelectionProvider,
|
|
45 |
public abstract class DataImportEditor<T> extends EditorPart implements IPartContentHasFactualData, IDirtyMarkableSelectionProvider, |
|
47 | 46 |
IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener{ |
48 | 47 |
|
49 | 48 |
private ConversationHolder conversation; |
... | ... | |
54 | 53 |
* Constructs a new DataImportEditor and registers it to listen to context changes |
55 | 54 |
*/ |
56 | 55 |
public DataImportEditor() { |
57 |
CdmStore.getContextManager().addContextListener(this); |
|
58 | 56 |
} |
59 | 57 |
|
60 | 58 |
/* (non-Javadoc) |
... | ... | |
64 | 62 |
public void createPartControl(Composite parent) { |
65 | 63 |
|
66 | 64 |
Table table = new Table(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); |
67 |
table.setHeaderVisible(true);//TODO: set header title as BioCase query
|
|
65 |
table.setHeaderVisible(true);//TODO: set header title as query |
|
68 | 66 |
table.setLinesVisible(true); |
69 | 67 |
tableViewer = new TableViewer(table); |
70 | 68 |
|
... | ... | |
96 | 94 |
*/ |
97 | 95 |
@Override |
98 | 96 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
97 |
CdmStore.getContextManager().addContextListener(this); |
|
99 | 98 |
setSite(site); |
100 | 99 |
setInput(input); |
101 | 100 |
setPartName(input.getName()); |
... | ... | |
147 | 146 |
tableViewer.getTable().removeAll(); |
148 | 147 |
Collection<T> results = ((DataImportEditorInput<T>) editorInput).getResults(); |
149 | 148 |
if(results!=null){ |
150 |
for(T specimen:results){
|
|
149 |
for(T item:results){
|
|
151 | 150 |
TableItem tableItem = new TableItem(tableViewer.getTable(), SWT.NONE); |
152 |
tableItem.setText(specimen.generateTitle());
|
|
153 |
tableItem.setData(specimen);
|
|
151 |
tableItem.setText(getTextForTableItem(item));
|
|
152 |
tableItem.setData(item);
|
|
154 | 153 |
} |
155 | 154 |
} |
156 | 155 |
} |
157 | 156 |
} |
158 | 157 |
|
158 |
protected abstract String getTextForTableItem(T item); |
|
159 |
|
|
159 | 160 |
/* (non-Javadoc) |
160 | 161 |
* @see eu.etaxonomy.taxeditor.model.IContextListener#workbenchShutdown(org.eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor) |
161 | 162 |
*/ |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorInput.java | ||
---|---|---|
17 | 17 |
import org.eclipse.ui.IPersistableElement; |
18 | 18 |
|
19 | 19 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
20 |
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity; |
|
21 | 20 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
22 | 21 |
|
23 | 22 |
/** |
... | ... | |
25 | 24 |
* @date 25.02.2014 |
26 | 25 |
* |
27 | 26 |
*/ |
28 |
public abstract class DataImportEditorInput<T extends IIdentifiableEntity> implements IEditorInput {
|
|
27 |
public abstract class DataImportEditorInput<T> implements IEditorInput { |
|
29 | 28 |
|
30 | 29 |
protected static Logger logger = Logger.getLogger(DataImportEditorInput.class); |
31 | 30 |
|
... | ... | |
101 | 100 |
|
102 | 101 |
@Override |
103 | 102 |
public abstract boolean equals(Object obj); |
103 |
|
|
104 |
|
|
105 |
public abstract void query(); |
|
104 | 106 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditor.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2014 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.editor.view.dataimport; |
|
11 |
|
|
12 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse; |
|
13 |
|
|
14 |
/** |
|
15 |
* @author pplitzner |
|
16 |
* @date 27.05.2014 |
|
17 |
* |
|
18 |
*/ |
|
19 |
public class GbifImportEditor extends DataImportEditor<GbifResponse>{ |
|
20 |
|
|
21 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.dataimport.GbifImportEditor"; |
|
22 |
|
|
23 |
/** |
|
24 |
* Required for extension point |
|
25 |
*/ |
|
26 |
public GbifImportEditor() { |
|
27 |
super(); |
|
28 |
} |
|
29 |
|
|
30 |
/* (non-Javadoc) |
|
31 |
* @see eu.etaxonomy.taxeditor.editor.view.dataimport.DataImportEditor#getTextForTableItem(java.lang.Object) |
|
32 |
*/ |
|
33 |
@Override |
|
34 |
protected String getTextForTableItem(GbifResponse item) { |
|
35 |
return item.getDerivedUnitFacade().innerDerivedUnit().generateTitle(); |
|
36 |
} |
|
37 |
|
|
38 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditorInput.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2014 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.editor.view.dataimport; |
|
11 |
|
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Collection; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
|
16 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; |
|
17 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse; |
|
18 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author pplitzner |
|
22 |
* @date 27.05.2014 |
|
23 |
* |
|
24 |
*/ |
|
25 |
public class GbifImportEditorInput extends DataImportEditorInput<GbifResponse> { |
|
26 |
|
|
27 |
private final OccurenceQuery query; |
|
28 |
|
|
29 |
/** |
|
30 |
* @param query |
|
31 |
*/ |
|
32 |
public GbifImportEditorInput(OccurenceQuery query) { |
|
33 |
super(); |
|
34 |
this.query = query; |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public void query(){ |
|
39 |
String errorMessage = "Could not execute query " + query; |
|
40 |
// try{ |
|
41 |
// Collection<GbifResponse> results = new GbifQueryServiceWrapper().query(query); |
|
42 |
Collection<GbifResponse> results = new ArrayList<GbifResponse>(); |
|
43 |
DerivedUnitFacade facade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
44 |
facade.setLocality("outbanks of seashore"); |
|
45 |
GbifResponse gbifResponse = new GbifResponse(facade, "endPointURL"); |
|
46 |
results.add(gbifResponse); |
|
47 |
setResults(results); |
|
48 |
// } catch (ClientProtocolException e) { |
|
49 |
// logger.error(errorMessage, e); |
|
50 |
// } catch (IOException e) { |
|
51 |
// logger.error(errorMessage, e); |
|
52 |
// } catch (URISyntaxException e) { |
|
53 |
// logger.error(errorMessage, e); |
|
54 |
// } |
|
55 |
} |
|
56 |
|
|
57 |
|
|
58 |
/* (non-Javadoc) |
|
59 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
60 |
*/ |
|
61 |
@Override |
|
62 |
public String getName() { |
|
63 |
return "[GBIF] " + query.toString(); |
|
64 |
} |
|
65 |
|
|
66 |
/* (non-Javadoc) |
|
67 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
68 |
*/ |
|
69 |
@Override |
|
70 |
public String getToolTipText() { |
|
71 |
return "[GBIF] " + query.toString(); |
|
72 |
} |
|
73 |
|
|
74 |
/* (non-Javadoc) |
|
75 |
* @see java.lang.Object#hashCode() |
|
76 |
*/ |
|
77 |
@Override |
|
78 |
public int hashCode() { |
|
79 |
final int prime = 31; |
|
80 |
int result = 1; |
|
81 |
result = prime * result + ((query == null) ? 0 : query.hashCode()); |
|
82 |
return result; |
|
83 |
} |
|
84 |
|
|
85 |
/* (non-Javadoc) |
|
86 |
* @see java.lang.Object#equals(java.lang.Object) |
|
87 |
*/ |
|
88 |
@Override |
|
89 |
public boolean equals(Object obj) { |
|
90 |
if (this == obj) { |
|
91 |
return true; |
|
92 |
} |
|
93 |
if (obj == null) { |
|
94 |
return false; |
|
95 |
} |
|
96 |
if (getClass() != obj.getClass()) { |
|
97 |
return false; |
|
98 |
} |
|
99 |
GbifImportEditorInput other = (GbifImportEditorInput) obj; |
|
100 |
if (query == null) { |
|
101 |
if (other.query != null) { |
|
102 |
return false; |
|
103 |
} |
|
104 |
} else if (!query.equals(other.query)) { |
|
105 |
return false; |
|
106 |
} |
|
107 |
return true; |
|
108 |
} |
|
109 |
|
|
110 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/QueryOriginalRecordCommand.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.editor.view.dataimport; |
|
2 |
|
|
3 |
import org.eclipse.core.commands.AbstractHandler; |
|
4 |
import org.eclipse.core.commands.ExecutionEvent; |
|
5 |
import org.eclipse.core.commands.ExecutionException; |
|
6 |
import org.eclipse.jface.viewers.ISelection; |
|
7 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
8 |
import org.eclipse.ui.IWorkbenchWindow; |
|
9 |
import org.eclipse.ui.PlatformUI; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse; |
|
12 |
|
|
13 |
public class QueryOriginalRecordCommand extends AbstractHandler { |
|
14 |
|
|
15 |
/* (non-Javadoc) |
|
16 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
17 |
*/ |
|
18 |
@Override |
|
19 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
20 |
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
|
21 |
final ISelection selection = window.getActivePage().getSelection(); |
|
22 |
if(selection instanceof StructuredSelection){ |
|
23 |
StructuredSelection structuredSelection = (StructuredSelection)selection; |
|
24 |
if(structuredSelection.size()==1){ |
|
25 |
Object next = structuredSelection.iterator().next(); |
|
26 |
if(next instanceof GbifResponse){ |
|
27 |
String endPoint = ((GbifResponse) next).getEndPointQuery(); |
|
28 |
} |
|
29 |
} |
|
30 |
} |
|
31 |
return null; |
|
32 |
} |
|
33 |
|
|
34 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SaveSpecimenCommand.java | ||
---|---|---|
34 | 34 |
if(next instanceof SpecimenOrObservationBase){ |
35 | 35 |
IWorkbenchPart activePart = AbstractUtility.getActivePart(); |
36 | 36 |
if(activePart instanceof DataImportEditor){ |
37 |
SpecimenImportEditor dataImportEditor = (SpecimenImportEditor)activePart;
|
|
37 |
DataImportEditor dataImportEditor = (DataImportEditor)activePart;
|
|
38 | 38 |
CdmStore.getService(IOccurrenceService.class).saveOrUpdate((SpecimenOrObservationBase<?>) next); |
39 | 39 |
dataImportEditor.getConversationHolder().commit(true); |
40 | 40 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditor.java | ||
---|---|---|
22 | 22 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenImportEditor"; |
23 | 23 |
|
24 | 24 |
/** |
25 |
* |
|
25 |
* Required for extension point
|
|
26 | 26 |
*/ |
27 | 27 |
public SpecimenImportEditor() { |
28 | 28 |
super(); |
29 | 29 |
} |
30 |
|
|
31 |
/* (non-Javadoc) |
|
32 |
* @see eu.etaxonomy.taxeditor.editor.view.dataimport.DataImportEditor#getTextForTableItem(eu.etaxonomy.cdm.model.common.IIdentifiableEntity) |
|
33 |
*/ |
|
34 |
@Override |
|
35 |
protected String getTextForTableItem(SpecimenOrObservationBase<?> item) { |
|
36 |
return item.generateTitle(); |
|
37 |
} |
|
30 | 38 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditorInput.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2014 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.editor.view.dataimport; |
|
11 |
|
|
12 |
import java.io.IOException; |
|
13 |
import java.io.InputStream; |
|
14 |
import java.net.URISyntaxException; |
|
15 |
import java.util.ArrayList; |
|
16 |
import java.util.Collection; |
|
17 |
|
|
18 |
import org.apache.http.client.ClientProtocolException; |
|
19 |
import org.eclipse.swt.widgets.Display; |
|
20 |
|
|
21 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
|
22 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; |
|
23 |
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper; |
|
24 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper; |
|
25 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
26 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator; |
|
27 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
28 |
import eu.etaxonomy.taxeditor.editor.view.dataimport.transientServices.TransientCdmRepository; |
|
29 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
30 |
|
|
31 |
/** |
|
32 |
* @author pplitzner |
|
33 |
* @date 25.02.2014 |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class SpecimenImportEditorInput extends DataImportEditorInput<SpecimenOrObservationBase<?>> { |
|
37 |
|
|
38 |
private final OccurenceQuery query; |
|
39 |
private final QueryType queryType; |
|
40 |
|
|
41 |
/** |
|
42 |
* @param results |
|
43 |
*/ |
|
44 |
public SpecimenImportEditorInput(OccurenceQuery query, QueryType queryType) { |
|
45 |
super(); |
|
46 |
this.query = query; |
|
47 |
this.queryType = queryType; |
|
48 |
} |
|
49 |
|
|
50 |
public void query(){ |
|
51 |
String errorMessage = "Could not execute query " + query; |
|
52 |
|
|
53 |
Collection<SpecimenOrObservationBase<?>> results = new ArrayList<SpecimenOrObservationBase<?>>(); |
|
54 |
try { |
|
55 |
InputStream resultStream; |
|
56 |
switch (queryType) { |
|
57 |
case GBIF: |
|
58 |
Collection<DerivedUnitFacade> facades = new GbifQueryServiceWrapper().query(query); |
|
59 |
for(DerivedUnitFacade facade:facades){ |
|
60 |
results.add(facade.innerDerivedUnit()); |
|
61 |
} |
|
62 |
break; |
|
63 |
case BIOCASE: |
|
64 |
resultStream = new BioCaseQueryServiceWrapper().query(query); |
|
65 |
Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false); |
|
66 |
TransientCdmRepository repo = |
|
67 |
new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration()); |
|
68 |
configurator.setCdmAppController(repo); |
|
69 |
|
|
70 |
CdmDefaultImport<Abcd206ImportConfigurator> importer = new CdmDefaultImport<Abcd206ImportConfigurator>(); |
|
71 |
importer.invoke(configurator); |
|
72 |
results = repo.getUnits(); |
|
73 |
setResults(results); |
|
74 |
break; |
|
75 |
} |
|
76 |
} catch (ClientProtocolException e) { |
|
77 |
logger.error(errorMessage, e); |
|
78 |
} catch (IOException e) { |
|
79 |
logger.error(errorMessage, e); |
|
80 |
} catch (URISyntaxException e) { |
|
81 |
logger.error(errorMessage, e); |
|
82 |
} |
|
83 |
|
|
84 |
setResults(results); |
|
85 |
|
|
86 |
Display.getDefault().asyncExec(new Runnable() { |
|
87 |
|
|
88 |
@Override |
|
89 |
public void run() { |
|
90 |
CdmStore.getContextManager().notifyContextRefresh(); |
|
91 |
} |
|
92 |
}); |
|
93 |
} |
|
94 |
|
|
95 |
/* (non-Javadoc) |
|
96 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
97 |
*/ |
|
98 |
@Override |
|
99 |
public String getName() { |
|
100 |
return queryType + " " + query.toString(); |
|
101 |
} |
|
102 |
|
|
103 |
/* (non-Javadoc) |
|
104 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
105 |
*/ |
|
106 |
@Override |
|
107 |
public String getToolTipText() { |
|
108 |
return query.toString(); |
|
109 |
} |
|
110 |
|
|
111 |
/* (non-Javadoc) |
|
112 |
* @see java.lang.Object#hashCode() |
|
113 |
*/ |
|
114 |
@Override |
|
115 |
public int hashCode() { |
|
116 |
final int prime = 31; |
|
117 |
int result = 1; |
|
118 |
result = prime * result + ((query == null) ? 0 : query.hashCode()); |
|
119 |
return result; |
|
120 |
} |
|
121 |
|
|
122 |
/* (non-Javadoc) |
|
123 |
* @see java.lang.Object#equals(java.lang.Object) |
|
124 |
*/ |
|
125 |
@Override |
|
126 |
public boolean equals(Object obj) { |
|
127 |
if (this == obj) { |
|
128 |
return true; |
|
129 |
} |
|
130 |
if (obj == null) { |
|
131 |
return false; |
|
132 |
} |
|
133 |
if (getClass() != obj.getClass()) { |
|
134 |
return false; |
|
135 |
} |
|
136 |
SpecimenImportEditorInput other = (SpecimenImportEditorInput) obj; |
|
137 |
if (query == null) { |
|
138 |
if (other.query != null) { |
|
139 |
return false; |
|
140 |
} |
|
141 |
} else if (!query.equals(other.query)) { |
|
142 |
return false; |
|
143 |
} |
|
144 |
return true; |
|
145 |
} |
|
146 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizard.java | ||
---|---|---|
16 | 16 |
import org.eclipse.core.runtime.jobs.Job; |
17 | 17 |
import org.eclipse.jface.viewers.IStructuredSelection; |
18 | 18 |
import org.eclipse.jface.wizard.Wizard; |
19 |
import org.eclipse.swt.widgets.Display; |
|
19 | 20 |
import org.eclipse.ui.IImportWizard; |
20 | 21 |
import org.eclipse.ui.IWorkbench; |
21 | 22 |
import org.eclipse.ui.IWorkbenchPage; |
... | ... | |
57 | 58 |
@Override |
58 | 59 |
public boolean performFinish() { |
59 | 60 |
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
60 |
|
|
61 |
query = searchPage.getQuery(); |
|
62 |
final SpecimenImportEditorInput input = new SpecimenImportEditorInput(query, providerSelectionPage.getQueryType()); |
|
63 |
Job queryJob = new Job("Query specimen provider") { |
|
64 |
|
|
65 |
@Override |
|
66 |
protected IStatus run(IProgressMonitor monitor) { |
|
67 |
input.query(); |
|
68 |
return Status.OK_STATUS; |
|
69 |
} |
|
70 |
}; |
|
71 |
queryJob.schedule(); |
|
72 |
try { |
|
73 |
page.openEditor(input, SpecimenImportEditor.ID, true); |
|
74 |
} catch ( PartInitException e ) { |
|
75 |
//Put your exception handler here if you wish to |
|
76 |
} |
|
61 |
DataImportEditorInput<?> input = null; |
|
62 |
String editorId = null; |
|
63 |
query = searchPage.getQuery(); |
|
64 |
switch (providerSelectionPage.getQueryType()) { |
|
65 |
case BIOCASE: |
|
66 |
input = new BioCaseEditorInput(query); |
|
67 |
editorId = SpecimenImportEditor.ID; |
|
68 |
break; |
|
69 |
case GBIF: |
|
70 |
input = new GbifImportEditorInput(query); |
|
71 |
editorId = GbifImportEditor.ID; |
|
72 |
break; |
|
73 |
} |
|
74 |
try { |
|
75 |
page.openEditor(input, editorId, true); |
|
76 |
} catch ( PartInitException e ) { |
|
77 |
//Put your exception handler here if you wish to |
|
78 |
} |
|
79 |
Job queryJob = new QueryJob("Query specimen provider", input); |
|
80 |
queryJob.schedule(); |
|
77 | 81 |
return true; |
78 | 82 |
} |
79 | 83 |
|
... | ... | |
95 | 99 |
searchPage = new SpecimenSearchWizardPage("Specimen Search"); |
96 | 100 |
} |
97 | 101 |
|
102 |
private class QueryJob extends Job{ |
|
103 |
|
|
104 |
private final DataImportEditorInput<?> input; |
|
105 |
|
|
106 |
/** |
|
107 |
* @param name |
|
108 |
*/ |
|
109 |
public QueryJob(String name, DataImportEditorInput<?> input) { |
|
110 |
super(name); |
|
111 |
this.input = input; |
|
112 |
} |
|
113 |
|
|
114 |
/* (non-Javadoc) |
|
115 |
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) |
|
116 |
*/ |
|
117 |
@Override |
|
118 |
protected IStatus run(IProgressMonitor monitor) { |
|
119 |
input.query(); |
|
120 |
Display.getDefault().asyncExec(new Runnable() { |
|
121 |
|
|
122 |
@Override |
|
123 |
public void run() { |
|
124 |
CdmStore.getContextManager().notifyContextRefresh(); |
|
125 |
} |
|
126 |
}); |
|
127 |
return Status.OK_STATUS; |
|
128 |
} |
|
129 |
|
|
130 |
} |
|
98 | 131 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
24 | 24 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException; |
25 | 25 |
import eu.etaxonomy.cdm.api.service.ITermService; |
26 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.agent.Person; |
27 | 28 |
import eu.etaxonomy.cdm.model.agent.Team; |
28 | 29 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
... | ... | |
168 | 169 |
if(input instanceof TreeNode){ |
169 | 170 |
input = ((TreeNode) input).getValue(); |
170 | 171 |
} |
172 |
if(input instanceof GbifResponse){ |
|
173 |
input = ((GbifResponse) input).getDerivedUnitFacade(); |
|
174 |
} |
|
171 | 175 |
if (input.getClass().equals(DerivedUnit.class)) { |
172 | 176 |
DerivedUnit derivedUnit = (DerivedUnit)input; |
173 | 177 |
try { |
Also available in: Unified diff