eu.etaxonomy.cdm.io.specimen,
eu.etaxonomy.cdm.io.specimen.abcd206.in,
eu.etaxonomy.cdm.io.specimen.excel.in,
+ eu.etaxonomy.cdm.io.specimen.gbif.in,
eu.etaxonomy.cdm.io.taxonx,
eu.etaxonomy.cdm.io.tcsxml,
eu.etaxonomy.cdm.io.tcsxml.in,
} else if (obj instanceof Collection) {
return (T) load((Collection<T>)obj, recursive, update);
} else if(obj instanceof Pager) {
- load(((Pager)obj).getRecords(), recursive, update);
- return obj;
+ load(((Pager)obj).getRecords(), recursive, update);
+ return obj;
} else if(obj instanceof MergeResult) {
return (T) load((MergeResult<CdmBase>)obj, recursive, update);
}
return map;
}
- public <T extends Object> Collection<T> load(Collection<T> collection, boolean recursive, boolean update){
+ public <T extends Object> Collection<T> load(Collection<T> collection, boolean recursive, boolean update){
Collection<T> loadedCollection;
if(isRecursiveEnabled && recursive) {
CdmBase cachedCdmEntityInSubGraph = cdmCacher.getFromCache(cdmEntityInSubGraph);
if(cachedCdmEntityInSubGraph != null) {
- if(cachedCdmEntityInSubGraph != cdmEntityInSubGraph) {
+ if(!cachedCdmEntityInSubGraph.equals(cdmEntityInSubGraph)) {
// exception : is the case where
// the field has been already initialised, cached and
// is not the same as the one in the cache, in which case we set the value
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/bioinfweb-commons-bio-2.0.0-preview-1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/bioinfweb-commons-core-2.0.0-preview-1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/bioinfweb-commons-swing-2.0.0-preview-1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/sequencing-1.9.2-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/tic-core-2.0.0-preview-1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/tic-swt-2.0.0-preview-1.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
-import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
import eu.etaxonomy.cdm.io.reference.endnote.in.EndnoteImportConfigurator;
import eu.etaxonomy.cdm.io.sdd.in.SDDImportConfigurator;
import eu.etaxonomy.cdm.io.service.IIOService;
+import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportState;
import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenCdmExcelImportConfigurator;
+import eu.etaxonomy.cdm.io.specimen.gbif.in.GbifImportConfigurator;
+import eu.etaxonomy.cdm.io.specimen.gbif.in.GbifImportState;
import eu.etaxonomy.cdm.io.tcsxml.in.TcsXmlImportConfigurator;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
}
- /*public Job createIOServiceJob(final DwcaImportConfigurator configurator) {
+ public Job createIOServiceJob(final GbifImportConfigurator<GbifImportState, InputStream> configurator) {
Assert.isNotNull(configurator, "Configuration may not be null");
final Display display = Display.getDefault();
Job job = new Job("Import: " + " Dwca") {
return job;
- }*/
+ }
+
+ public Job createIOServiceJob(final Abcd206ImportConfigurator<Abcd206ImportState, InputStream> configurator) {
+ Assert.isNotNull(configurator, "Configuration may not be null");
+ final Display display = Display.getDefault();
+ Job job = new Job("Import: " + " Dwca") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("Importing data", IProgressMonitor.UNKNOWN);
+ IIOService ioService = CdmApplicationState.getIOService();
+
+ ImportResult result = ioService.importDataFromStream(configurator);
+ monitor.done();
+
+ display.asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ CdmStore.getContextManager().notifyContextRefresh();
+ }
+ });
+
+ return Status.OK_STATUS;
+ }
+ };
+
+ return job;
+
+ }
+
+ public Job createIOServiceJob(
+ final List<Abcd206ImportConfigurator> abcdConfigurators) {
+ Assert.isNotNull(abcdConfigurators, "Configuration may not be null");
+ final Display display = Display.getDefault();
+ Job job = new Job("Import: " + " Dwca") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("Importing data", IProgressMonitor.UNKNOWN);
+ IIOService ioService = CdmApplicationState.getIOService();
+
+ ImportResult result = ioService.importDataFromStream(abcdConfigurators);
+ monitor.done();
+
+ display.asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ CdmStore.getContextManager().notifyContextRefresh();
+ }
+ });
+
+ return Status.OK_STATUS;
+ }
+ };
+
+ return job;
+ }
+
+
}
}
- protected static ClassificationChooserWizardPage createPage(){
+ public static ClassificationChooserWizardPage createPage(){
return new ClassificationChooserWizardPage("Configure import destinations", "Note: Selecting no classification will create a default one.");
}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
+import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
import eu.etaxonomy.taxeditor.ui.element.RootElement;
+import eu.etaxonomy.taxeditor.webapp.ICDMServerError;
/**
* @author pplitzner
* @date Mar 30, 2016
*
*/
-public abstract class AbstractEntityCollectionElementWizardPage extends WizardPage implements
+public abstract class AbstractEntityCollectionElementWizardPage extends WizardPage implements
IPropertyChangeListener {
protected CdmFormFactory formFactory;
+
protected RootElement rootElement;
protected AbstractEntityCollectionElementWizardPage(String pageName) {
super(pageName);
+
}
/**
public void dispose() {
rootElement.removeElements();
formFactory.removePropertyChangeListener(this);
+
super.dispose();
}
selection_reuseExistingName.setEnabled(enabled);
if (!enabled){
setTaxon(selection_reuseExistingTaxon.getEntity());
- }
- if (isCreateNew()){
- textNewTaxonName.setEnabled(enabled);
- if (!enabled){
- setTaxon(selection_reuseExistingTaxon.getEntity());
- } else{
- textNewTaxonName.setText(null);
- }
-
- complete = !textNewTaxonName.getText().isEmpty();
- }
+ }else{
+ textNewTaxonName.setText(null);
+ }
+ complete = !textNewTaxonName.getText().isEmpty();
+
} else if (eventSource == selection_reuseExistingName) {
boolean enabled = selection_reuseExistingName.getEntity() == null;
public String getTaxonName() {
return textNewTaxonName.getText();
}
+ public Taxon getTaxon() {
+ return selection_reuseExistingTaxon.getEntity();
+ }
public Reference getReference(){
return selection_SecRef.getSelection();
}
public Taxon createTaxon() {
- String taxonName = ((TaxonNodeDetailElement) getDetailElement()).getTaxonName();
- Reference reference = ((TaxonNodeDetailElement) getDetailElement()).getReference();
- NonViralName parseReferencedName = ParseHandler.parseReferencedName(taxonName, null);
- return Taxon.NewInstance(parseReferencedName, reference);
+ if (((TaxonNodeDetailElement) getDetailElement()).getTaxon() == null){
+ String taxonName = ((TaxonNodeDetailElement) getDetailElement()).getTaxonName();
+ Reference reference = ((TaxonNodeDetailElement) getDetailElement()).getReference();
+ NonViralName parseReferencedName = ParseHandler.parseReferencedName(taxonName, null);
+ return Taxon.NewInstance(parseReferencedName, reference);
+ } else{
+ return ((TaxonNodeDetailElement) getDetailElement()).getTaxon();
+ }
}
/*
import org.eclipse.swt.SWT;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.store.CdmStore;
interactionDescription = formFactory.createMultiLineTextWithLabel(this,
"Relationship to the taxon:", 200, SWT.WRAP);
+ entity = HibernateProxyHelper.deproxy(entity, TaxonInteraction.class);
interactionDescription.setText(entity.getDescription(CdmStore
.getDefaultLanguage()));
}
package eu.etaxonomy.taxeditor.ui.section.name;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
import org.eclipse.jface.wizard.Wizard;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.name.NameRelationship;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* <p>NameRelationshipWizard class.</p>
* @created Jun 1, 2010
* @version 1.0
*/
-public class NameRelationshipWizard extends Wizard implements IConversationEnabled{
+public class NameRelationshipWizard extends Wizard implements IConversationEnabled, ICdmEntitySessionEnabled{
private static NameRelationshipDetailSection callingSection;
+ private ICdmEntitySession cdmEntitySession;
+ private ICdmEntitySession previousCdmEntitySession;
+ private CdmBase rootElement;
+
/**
* <p>Constructor for NameRelationshipWizard.</p>
*
*/
public NameRelationshipWizard(NameRelationshipDetailSection callingSection) {
NameRelationshipWizard.callingSection = callingSection;
+ rootElement = callingSection.getEntity();
+ if (CdmStore.isActive() && CdmStore.getCurrentSessionManager().isRemoting()) {
+ previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
+ cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+ cdmEntitySession.bind();
+ }
}
private NameRelationshipWizardPage page;
return page.isPageComplete();
}
-
+ @Override
+ public void dispose() {
+ super.dispose();
+ if(cdmEntitySession != null) {
+ cdmEntitySession.dispose();
+ }
+ if(previousCdmEntitySession!=null){
+ previousCdmEntitySession.bind();
+ }
+ }
/**
* <p>getNameRelationship</p>
/** {@inheritDoc} */
public void update(CdmDataChangeMap changeEvents) {}
+
+ @Override
+ public ICdmEntitySession getCdmEntitySession() {
+ return cdmEntitySession;
+ }
+
+ @Override
+ public java.util.Collection<CdmBase> getRootEntities() {
+ return Collections.singleton(rootElement);
+ }
+
+ @Override
+ public Map<Object, List<String>> getPropertyPathsMap() {
+ return null;
+ }
}
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
// }
// }
+
+
+
+
+
}
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.Collections;
+import java.util.Comparator;
import java.util.HashSet;
+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 org.eclipse.jface.text.source.Annotation;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IWorkbenchPart;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.api.service.ITermService;
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
+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.dwca.in.DwcaImportConfigurator;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+import eu.etaxonomy.cdm.io.specimen.gbif.in.*;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
public class SaveImportedSpecimenAction extends Action {
private final Logger logger = Logger.getLogger(SaveImportedSpecimenAction.class);
+
+ private Comparator<GbifResponse> comparator;
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
Table table = dataImportView.getTable();
Collection<GbifResponse> checkedResults = new HashSet<GbifResponse>();
Object data;
- Set<String[]> unitIds = new HashSet<String[]>();
+ Set<String[]> unitIdsGbif = new HashSet<String[]>();
+ Set<String[]> unitIdsBioCase = new HashSet<String[]>();
+ List<GbifResponse> biocaseResponses = new ArrayList<GbifResponse>();
+
for(TableItem item:table.getItems()){
if(item.getChecked()){
//Save Specimen
}
}
}
+ String[] tripleId ;
for (GbifResponse response:checkedResults){
if (response != null){
- /*String[] tripleId = response.getTripleID();
- unitIds.add(tripleId);
- */
+ tripleId = response.getTripleID();
+
+ if (response.getDataSetProtocol().equals(GbifDataSetProtocol.BIOCASE)){
+ biocaseResponses.add(response);
+
+ }else{
+ unitIdsGbif.add(tripleId);
+ }
+
+
}
}
+ Collections.sort(biocaseResponses, getComparator());
+ URI dataSetUri = null;
+ Abcd206ImportConfigurator configuratorAbcd;
+ List<Abcd206ImportConfigurator> abcdConfigurators = new ArrayList<Abcd206ImportConfigurator>();
+ DataSetResponse dataSetResponse;
+ OccurenceQuery bioCaseOccurrenceQuery = null;
+ 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);
+ if (configuratorAbcd != null){
+ abcdConfigurators.add(configuratorAbcd);
+ }
+ unitIdsBioCase = new HashSet<String[]>();
+ bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase);
+ configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery);
+ }
+ tripleId = response.getTripleID();
+ unitIdsBioCase.add(tripleId);
+ }
+
+ OccurenceQuery query = new OccurenceQuery(unitIdsGbif);
+ GbifImportConfigurator configurator = GbifImportConfigurator.newInstance(query);
+ configurator.setSourceReferenceTitle("Import Gbif data");
- DwcaImportConfigurator configurator = DwcaImportConfigurator.NewInstance(null, null);
- /* OccurenceQuery query = new OccurenceQuery(unitIds);
- configurator.setQuery(query);
- */
- /*Job job = CdmStore.getImportManager().createIOServiceJob(configurator);
- CdmStore.getImportManager().run(job);
- */
+
+
+ // configurator.setQuery(query);
+
+ Job bioCaseJob = CdmStore.getImportManager().createIOServiceJob(abcdConfigurators);
+ CdmStore.getImportManager().run(bioCaseJob);
+
+ Job gbifJob = CdmStore.getImportManager().createIOServiceJob(configurator);
+ CdmStore.getImportManager().run(gbifJob);
+
+
}
}
}
}
}
-
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#getText()
*/
public String getText() {
return "Import";
}
-
+
+ private Comparator<GbifResponse> getComparator(){
+ if (comparator == null){
+ comparator = new GbifResponseComparator();
+ }
+ return comparator;
+ }
+
+
}