-// $Id$
/**
* Copyright (C) 2007 EDIT
* European Distributed Institute of Taxonomy
import eu.etaxonomy.cdm.model.agent.Team;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.User;
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
import eu.etaxonomy.cdm.model.molecular.Amplification;
import eu.etaxonomy.cdm.model.molecular.Primer;
-import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.occurrence.Collection;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.model.TextHelper;
import eu.etaxonomy.taxeditor.newWizard.AmplificationGeneralWizardPage;
+import eu.etaxonomy.taxeditor.newWizard.PolytomousKeyWizardPage;
import eu.etaxonomy.taxeditor.newWizard.PrimerWizardPage;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitWizardPage;
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventWizardPage;
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceWizardPage;
+import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonWizardPage;
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailWizardPage;
/**
private CdmBase rootElement;
public EditFromSelectionWizard(EntitySelectionElement selectionElement) {
- if (CdmStore.isActive() && CdmStore.getCurrentSessionManager().isRemoting()) {
+ if (CdmStore.isActive()) {
previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
cdmEntitySession.bind();
//check if entity has already been persisted
if(entity.getId()==0){
rootElement = entity;
- cdmEntitySession.addNewCdmEntity(rootElement);
}
else{
IService<CdmBase> service = CdmStore.getService(entity);
addPage(new ReferenceWizardPage(formFactory,
selectionElement.getConversationHolder(),
(HibernateProxyHelper.deproxy(rootElement, Reference.class))));
- } else if (rootElement.isInstanceOf(Team.class)) {
+ } else if (rootElement.isInstanceOf(Team.class) && selectionElement instanceof EntitySelectionElementWithAbbreviatedTitle<?>) {
addPage(new TeamWizardPage(formFactory,
- selectionElement.getConversationHolder(), HibernateProxyHelper.deproxy(rootElement, Team.class)));
- } else if (rootElement.isInstanceOf(Person.class)) {
+ selectionElement.getConversationHolder(), HibernateProxyHelper.deproxy(rootElement, Team.class), true));
+ } else if (rootElement.isInstanceOf(Team.class) && !(selectionElement instanceof EntitySelectionElementWithAbbreviatedTitle<?>)) {
+ addPage(new TeamWizardPage(formFactory,
+ selectionElement.getConversationHolder(), HibernateProxyHelper.deproxy(rootElement, Team.class), false));
+ } else if (rootElement.isInstanceOf(Person.class)) {
addPage(new PersonWizardPage(formFactory,
selectionElement.getConversationHolder(), HibernateProxyHelper.deproxy(rootElement, Person.class)));
- } else if (rootElement.isInstanceOf(NonViralName.class)) {
+ } else if (rootElement.isInstanceOf(TaxonName.class)) {
addPage(new NonViralNameWizardPage(formFactory,
selectionElement.getConversationHolder(),
- HibernateProxyHelper.deproxy(rootElement, NonViralName.class)));
- } else if (rootElement.isInstanceOf(SpecimenOrObservationBase.class)) {
+ HibernateProxyHelper.deproxy(rootElement, TaxonName.class)));
+ } else if (rootElement.isInstanceOf(TaxonBase.class)) {
+ addPage(new TaxonWizardPage(formFactory,
+ selectionElement.getConversationHolder(),
+ HibernateProxyHelper.deproxy(rootElement, TaxonBase.class)));
+ } else if (rootElement.isInstanceOf(SpecimenOrObservationBase.class)) {
DerivedUnitFacade facade;
try {
addPage(new AmplificationGeneralWizardPage(formFactory,
selectionElement.getConversationHolder(),
HibernateProxyHelper.deproxy(rootElement, Amplification.class)));
+ } else if (rootElement instanceof PolytomousKey) {
+ addPage(new PolytomousKeyWizardPage(formFactory,
+ selectionElement.getConversationHolder(),
+ HibernateProxyHelper.deproxy(rootElement, PolytomousKey.class)));
} else {
MessagingUtils.warningDialog("Missing interface", this,
"No detail element for current selection");
IService<CdmBase> service = CdmStore.getService(rootElement);
if(rootElement.getId()!=0){
service.merge(rootElement, true);
+
+ }else{
+ rootElement = service.save(rootElement);
}
if(previousCdmEntitySession!=null){
- selectionElement.setEntity(previousCdmEntitySession.load(rootElement, true));
- }
+ selectionElement.setEntity(previousCdmEntitySession.load(rootElement, true));
+ }
+
return true;
}
super.dispose();
if(cdmEntitySession != null) {
cdmEntitySession.dispose();
+ cdmEntitySession = null;
}
if(previousCdmEntitySession!=null){
- previousCdmEntitySession.dispose();
+ previousCdmEntitySession.bind();
}
}