/**
- *
- */
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
package eu.etaxonomy.taxeditor.newWizard;
import java.util.Map;
import eu.etaxonomy.cdm.api.service.dto.CreateTaxonDTO;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.common.LanguageString;
+import eu.etaxonomy.cdm.model.reference.NamedSource;
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus;
+import eu.etaxonomy.cdm.persistence.dto.MergeResult;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeWizardPage;
/**
- * <p>NewTaxonNodeWizard class.</p>
+ * NewTaxonNodeWizard class.
*
* @author n.hoffmann
* @created Sep 15, 2009
private boolean isOpenInEditor = false;
private boolean success = true;
- /**
- * <p>Constructor for AbstractNewEntityWizard.</p>
- *
- * @param <T> a T object.
- */
@Inject
public NewTaxonNodeWizard(){
setWindowTitle(Messages.TaxonNodeWizardPage_new);
try{
UpdateResult result;
TaxonNode parent = getParentEntity();
- Map<Language, LanguageString> nodes = ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).getMultiLanguageTextExcludedNotes();
- UUID refUuid = parent.getReference() != null? parent.getReference().getUuid(): null;
-
- TaxonNodeStatus status = null;
- if( ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).isUnplaced()){
- status = TaxonNodeStatus.UNPLACED;
- }else if( ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).isPlacementDoubtful()){
- status = TaxonNodeStatus.DOUBTFUL;
- }else if (((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).isExcluded()){
- status = TaxonNodeStatus.EXCLUDED;
+
+ Map<Language, LanguageString> notes = ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).getMultiLanguageTextExcludedNotes();
+ NamedSource source = parent.getSource().checkEmpty()? null: parent.getSource();
+
+ TaxonNodeStatus status = ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).getTaxonNodeStatus();
+ if (status == null){
+ notes = null;
}
- result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, refUuid, parent.getMicroReference(),
- status, nodes);
+
+ result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(),
+ taxon, source, parent.getMicroReference(), status, notes);
if (result.isOk()){
this.setEntity((TaxonNode)result.getCdmEntity());
- CdmApplicationState.getCurrentDataChangeService()
- .fireChangeEvent(new CdmChangeEvent(Action.Create, result.getUpdatedObjects(), NewTaxonNodeWizard.class), true);
+ CdmApplicationState.getCurrentDataChangeService()
+ .fireChangeEvent(new CdmChangeEvent(Action.Create, result.getUpdatedObjects(), NewTaxonNodeWizard.class), true);
}else{
setSuccess(false);
}
}
-// @Override
-// protected TaxonNode createNewEntity() {
-// if(getSelection() != null){
-// Object selectedObject = getSelection().getFirstElement();
-// if(selectedObject instanceof TaxonNodeDto){
-// TaxonNodeDto taxonNodeDto = (TaxonNodeDto) selectedObject;
-// TaxonNode node = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeDto.getUuid());
-// Reference sec = node.getTaxon() != null? node.getTaxon().getSec():null;
-// Taxon newTaxon = Taxon.NewInstance(TaxonNameFactory.NewNameInstance(PreferencesUtil.getPreferredNomenclaturalCode(), null), sec);
-// TaxonNode child = node.addChildTaxon(newTaxon, null, null);
-//
-// return child;
-//
-// }
-// }
-//
-// return null;
-// }
-
-
- /**
- * <p>
- * openInEditor
- * </p>
- *
- * @return a boolean.
- */
public boolean openInEditor() {
return isOpenInEditor ;
}
this.isOpenInEditor = isOpenInEditor;
}
- /**
- * <p>openEmpty</p>
- *
- * @return a boolean.
- */
public boolean openEmpty(){
return openInEditor() && openEmptyEditor;
}
- /**
- * <p>getTaxonNode</p>
- *
- * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
- */
public TaxonNode getTaxonNode(){
if(generatedTaxonNodeUuid != null){
return CdmStore.getService(ITaxonNodeService.class).load(generatedTaxonNodeUuid);
this.wizardPageListener = wizardPageListener;
}
-
public boolean isSuccess() {
return success;
}
-
public void setSuccess(boolean success) {
this.success = success;
}
}
}
}
-
-
-}
+}
\ No newline at end of file