eu.etaxonomy.taxeditor.editor.internal,
eu.etaxonomy.taxeditor.editor.name,
eu.etaxonomy.taxeditor.editor.name.handler,
+ eu.etaxonomy.taxeditor.editor.name.operation,
eu.etaxonomy.taxeditor.editor.view.concept,
eu.etaxonomy.taxeditor.editor.view.dataimport,
eu.etaxonomy.taxeditor.editor.view.descriptive,
label="Open Associated Derivates"
style="push">
<visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
+ checkEnabled="false">
+ <and>
+ <reference
+ definitionId="isCdmStoreConnected">
+ </reference>
+ <reference
+ definitionId="isTaxonNode">
+ </reference>
+ </and>
</visibleWhen>
</command>
<separator
TaxonNode taxonNode = getCdmEntitySession().remoteLoad(service,taxonNodeUuid, null);
- taxonNode = getCdmEntitySession().load(taxonNode);
+
if(taxonNode == null){
MessagingUtils.warningDialog("Not yet implemented", TaxonEditorInput.class, "Selected element is not type TaxonBase.");
}
TaxonNameBase<?, ?> name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
ITaxonTreeNode parentNode = CdmStore.getService(IClassificationService.class).getTreeNodeByUuid(parentNodeUuid);
- parentNode = getCdmEntitySession().load(parentNode);
Taxon newTaxon = Taxon.NewInstance(name, parentNode.getReference());
TaxonNode newTaxonNode = parentNode.addChildTaxon(newTaxon, parentNode.getReference(), parentNode.getMicroReference());
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import org.eclipse.core.commands.common.NotDefinedException;
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.Page;
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
Page.NAME);
Taxon taxon = editor.getTaxon();
HomotypicalGroup group = taxon.getHomotypicGroup();
- TaxonNameBase newSynonymName = ParseHandler.createEmptyName();
-
+ NonViralName newSynonymName = ParseHandler.createEmptyName();
+
AbstractPostOperation operation;
try {
- operation = new CreateSynonymInExistingHomotypicalGroupOperation(event.getCommand().getName(),
+ operation = new CreateSynonymInExistingHomotypicalGroupOperation(event.getCommand().getName(),
editor.getUndoContext(), taxon, group, newSynonymName, editor);
EditorUtil.executeOperation(operation);
} catch (NotDefinedException e) {
MessagingUtils.error(getClass(), e);
}
-
+
return null;
}
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.Page;
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
Page.NAME);
ISelection menuSelection = HandlerUtil.getCurrentSelection(event);
-
+
Object selecteObject = ((StructuredSelection) menuSelection).getFirstElement();
-
+
if(! (selecteObject instanceof Synonym)){
return null;
}
-
-
+
+
Synonym synonym = (Synonym) selecteObject;
-
+
HomotypicalGroup group = synonym.getHomotypicGroup();
-
- TaxonNameBase newSynonymName = ParseHandler.createEmptyName();
-
+
+ NonViralName newSynonymName = ParseHandler.createEmptyName();
+
AbstractPostOperation operation;
-
+
try {
operation = new CreateSynonymInExistingHomotypicalGroupOperation(event.getCommand().getName(), editor.getUndoContext(),
editor.getTaxon(), group, newSynonymName, editor);
} catch (NotDefinedException e) {
logger.warn("Command name not set");
}
-
+
return null;
}
}
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
editor = EditorUtil.getActiveMultiPageTaxonEditor();
Shell shell = HandlerUtil.getActiveShell(event);
Synonym synonym = (Synonym) EditorUtil.getSelection(event).getFirstElement();
-
+
// Force user to save taxon - not really necessary though, is it?
if (!EditorUtil.forceUserSave(editor, shell)) {
return null;
}
-
+
try {
SwapSynonymAndAcceptedOperation operation = new SwapSynonymAndAcceptedOperation(event.getCommand().getName(), editor.getUndoContext(),
- editor.getTaxon(), synonym, this);
-
+ editor.getTaxon(), synonym, this, editor);
+
EditorUtil.executeOperation(operation);
-
+
} catch (NotDefinedException e) {
logger.warn("Command name not set");
- }
+ }
return null;
}
public boolean postOperation(CdmBase objectAffectedByOperation) {
// Redraw existing editor
//((IPostOperationEnabled) editor).postOperation(null);
-
+
editor.doSave(EditorUtil.getMonitor());
editor.close(true);
-
+
if (objectAffectedByOperation instanceof Taxon) {
-
+
taxon = (Taxon) objectAffectedByOperation;
-
-
+
+
}
return true;
}
public boolean onComplete() {
Display display = Display.getCurrent();
display.asyncExec(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
try {
EditorUtil.openTaxonBase(taxon.getUuid());
-
+
} catch (Exception e) {
MessagingUtils.warningDialog("Could not open editor for taxon", this, e.getMessage());
}
-
+
}
});
return true;
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.cdm.remote.dto.tdwg.voc.TaxonName;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
*/
public class ChangeHomotypicalGroupBasionymOperation extends
AbstractPostTaxonOperation {
- private TaxonBase taxonBase;
+ private final TaxonBase taxonBase;
/**
* <p>Constructor for ChangeHomotypicalGroupBasionymOperation.</p>
public ChangeHomotypicalGroupBasionymOperation(String text,
IUndoContext undoContext, Taxon taxon, TaxonBase taxonBase, IPostOperationEnabled postOperationEnabled) {
super(text, undoContext, taxon, postOperationEnabled);
-
+
this.taxonBase = taxonBase;
}
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
TaxonNameBase<?, ?> name = taxonBase.getName();
-
+
monitor.worked(20);
name = HibernateProxyHelper.deproxy(name, TaxonNameBase.class);
HomotypicalGroup group = HibernateProxyHelper.deproxy(name.getHomotypicalGroup(), HomotypicalGroup.class);
TaxonNameBase oldBasionym = name.getBasionym();
-
+
name.setAsGroupsBasionym();
-
+
monitor.worked(40);
oldBasionym = HibernateProxyHelper.deproxy(oldBasionym, TaxonNameBase.class);
if (oldBasionym != null){
postExecute(oldBasionymTaxonBase);
}
}
+
return postExecute(taxonBase);
}
// TODO replace w method from cdmlib
// FIXME this is also old code: reimplement
// CdmUtil.setGroupBasionym(synonym.getName());
-
+
return postExecute(taxonBase);
}
-
-
+
+
}
import org.eclipse.core.runtime.IStatus;
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
AbstractPostTaxonOperation {
private final HomotypicalGroup group;
- private final TaxonNameBase newSynonymName;
+ private final NonViralName newSynonymName;
private SynonymRelationship synonymRelationship;
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
*/
public CreateSynonymInExistingHomotypicalGroupOperation(String label,
- IUndoContext undoContext, Taxon taxon, HomotypicalGroup group, TaxonNameBase newSynonymName, IPostOperationEnabled postOperationEnabled) {
+ IUndoContext undoContext, Taxon taxon, HomotypicalGroup group, NonViralName newSynonymName, IPostOperationEnabled postOperationEnabled) {
super(label, undoContext, taxon, postOperationEnabled);
this.group = group;
this.newSynonymName = newSynonymName;
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
// Find misapplication relation, save citation information
- for (TaxonRelationship relationship : element.getTaxonRelations()) {
- if (relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())
- && relationship.getFromTaxon().equals(misapplication)) {
- citation = relationship.getCitation();
- microcitation = relationship.getCitationMicroReference();
- }
- }
+// for (TaxonRelationship relationship : element.getTaxonRelations()) {
+// if (relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())
+// && relationship.getFromTaxon().equals(misapplication)) {
+// citation = relationship.getCitation();
+// microcitation = relationship.getCitationMicroReference();
+// }
+// }
monitor.worked(20);
// Remove misapplied name relation from taxon
element.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
ICdmApplicationConfiguration controller;
- controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
+ controller = CdmStore.getCurrentApplicationConfiguration();
ITaxonService service = controller.getTaxonService();
TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
NameDeletionConfigurator nameConfig = new NameDeletionConfigurator();
nameConfig.setRemoveAllNameRelationships(true);
config.setNameDeletionConfig(nameConfig);
- service.deleteTaxon(misapplication, config, null);
+ service.deleteTaxon(misapplication.getUuid(), config, null);
monitor.worked(40);
return postExecute(null);
ITaxonService service = controller.getTaxonService();\r
\r
\r
- DeleteResult result = service.deleteTaxon(element, configurator, classification);\r
+ DeleteResult result = service.deleteTaxon(element.getUuid(), configurator, classification.getUuid());\r
if (result.isError()){\r
MessageDialog.openError(null, "Delete failed", result.getExceptions().get(0).getMessage());\r
}\r
import org.eclipse.core.runtime.IStatus;
import eu.etaxonomy.cdm.api.service.ITaxonService;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
*/
public SwapSynonymAndAcceptedOperation(String label, IUndoContext undoContext,
- Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled) {
- super("Swap Synonym And Accepted Taxon Operation", undoContext, taxon, postOperationEnabled);
+ Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled,
+ ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
+ super("Swap Synonym And Accepted Taxon Operation", undoContext, taxon, postOperationEnabled, cdmEntitySessionEnabled);
this.synonym = synonym;
}
monitor.worked(20);
- CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym, element);
+ UpdateResult result = CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym.getUuid(), element.getUuid());
monitor.worked(40);
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
/**
* <p>DeleteDescriptionHandler class.</p>
IWorkbenchPart part = HandlerUtil.getActivePart(event);
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
+ ICdmEntitySessionEnabled cdmEntitySessionEnabled = (part instanceof ICdmEntitySessionEnabled) ? (ICdmEntitySessionEnabled) part : null;
try {
String label = event.getCommand().getName();
// TaxonDescription
if(object instanceof TaxonDescription){
- operations.add(new DeleteTaxonDescriptionOperation(label, undoContext, (TaxonDescription) object, postOperationEnabled));
+ operations.add(new DeleteTaxonDescriptionOperation(label, undoContext, (TaxonDescription) object, postOperationEnabled, cdmEntitySessionEnabled));
}
else if(object instanceof SpecimenDescription){
- operations.add(new DeleteSpecimenDescriptionOperation(label, undoContext, (SpecimenDescription) object, postOperationEnabled));
+ operations.add(new DeleteSpecimenDescriptionOperation(label, undoContext, (SpecimenDescription) object, postOperationEnabled, cdmEntitySessionEnabled)) ;
}
// DescriptionElementBase
else if(object instanceof DescriptionElementBase){
- operations.add(new DeleteDescriptionElementOperation(label, undoContext, (DescriptionElementBase) object, postOperationEnabled));
+ operations.add(new DeleteDescriptionElementOperation(label, undoContext, (DescriptionElementBase) object, postOperationEnabled, cdmEntitySessionEnabled));
}
else if(object instanceof FeatureNodeContainer){
List<DescriptionElementBase> descriptions = ((FeatureNodeContainer) object).getDescriptionElementsForEntireBranch();
for(DescriptionElementBase description : descriptions){
- operations.add(new DeleteDescriptionElementOperation(label, undoContext, description, postOperationEnabled));
+ operations.add(new DeleteDescriptionElementOperation(label, undoContext, description, postOperationEnabled, cdmEntitySessionEnabled));
}
}
// Media
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
/**
* <p>DeleteDescriptionElementOperation class.</p>
* @version 1.0
*/
public class DeleteDescriptionElementOperation extends AbstractPostTaxonOperation {
-
- private DescriptionElementBase element;
+
+ private final DescriptionElementBase element;
private DescriptionBase description = null;
/**
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
*/
public DeleteDescriptionElementOperation(String label, IUndoContext undoContext,
- DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, postOperationEnabled);
-
+ DescriptionElementBase element, IPostOperationEnabled postOperationEnabled,
+ ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
+ super(label, undoContext, postOperationEnabled, cdmEntitySessionEnabled);
+
this.element = element;
}
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
description = element.getInDescription();
-
+
monitor.worked(20);
-
+
// Remove element from description
if (description == null) {
MessagingUtils.error(this.getClass(), "Couldn't find element's description!", null);
throws ExecutionException {
description.addElement(element);
-
+
return postExecute(element);
}
}
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
private final SpecimenDescription description;
- public DeleteSpecimenDescriptionOperation(String label, IUndoContext undoContext,
- SpecimenDescription description, IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, description.getDescribedSpecimenOrObservation(), postOperationEnabled);
+ public DeleteSpecimenDescriptionOperation(String label,
+ IUndoContext undoContext,
+ SpecimenDescription description,
+ IPostOperationEnabled postOperationEnabled,
+ ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
+ super(label, undoContext, description.getDescribedSpecimenOrObservation(), postOperationEnabled, cdmEntitySessionEnabled);
this.description = description;
}
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import eu.etaxonomy.cdm.api.service.DeleteResult;
import eu.etaxonomy.cdm.api.service.IDescriptionService;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
*/
- public DeleteTaxonDescriptionOperation(String label, IUndoContext undoContext,
- TaxonDescription description, IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, postOperationEnabled);
+ public DeleteTaxonDescriptionOperation(String label,
+ IUndoContext undoContext,
+ TaxonDescription description,
+ IPostOperationEnabled postOperationEnabled,
+ ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
+ super(label, undoContext, postOperationEnabled, cdmEntitySessionEnabled);
this.description = description;
element = description.getTaxon();
throws ExecutionException {
monitor.worked(20);
- element.removeDescription(description);
- monitor.worked(40);
- CdmStore.getService(IDescriptionService.class).delete(description);
+ if (description != null){
+ DeleteResult deleteResult = CdmStore.getService(IDescriptionService.class).deleteDescription(description.getUuid());
+ return postExecute(description);
+ }
+ return null;
- return postExecute(description);
}
/* (non-Javadoc)
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
import eu.etaxonomy.cdm.model.name.NonViralName;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation;
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
/**
*/
public class CreateSynonymInExisitingHomotypicalGroupOperationTest extends AbstractTaxeditorOperationTestBase {
- private TaxonNameBase newSynonymName;
+ private NonViralName newSynonymName;
private HomotypicalGroup homotypicalGroup;
private NonViralName<?> taxonName;
-
+
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
-
+
taxonName = NonViralName.NewInstance(null);
taxon = Taxon.NewInstance(taxonName, null);
-
+
homotypicalGroup = HomotypicalGroup.NewInstance();
newSynonymName = NonViralName.NewInstance(null);
-
+
operation = new CreateSynonymInExistingHomotypicalGroupOperation("Create Synonym In Existing Homotypical Group",
undoContext, taxon, homotypicalGroup, newSynonymName, postOperation);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- *
+ *
* Homotypic group is the Taxons homotypic group, so we expect the synonym to be homotypic to the accepted taxon.
- *
- * @throws ExecutionException
+ *
+ * @throws ExecutionException
*/
@Test
- public void testExecuteTaxonHomotypicGroup() throws ExecutionException {
+ public void testExecuteTaxonHomotypicGroup() throws ExecutionException {
homotypicalGroup.addTypifiedName(taxonName);
operation.execute(monitor, info);
-
+
Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0);
Assert.assertTrue("Taxon should have a homotypic synonym now", taxon.getHomotypicSynonymsByHomotypicGroup().size() > 0);
}
-
+
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- *
+ *
* Homotypic group is not the accepted taxons. Heterotypic synonym should be created.
- *
- * @throws ExecutionException
+ *
+ * @throws ExecutionException
*/
@Test
- public void testExecuteSynonymHomotypicGroup() throws ExecutionException {
+ public void testExecuteSynonymHomotypicGroup() throws ExecutionException {
// test heterotypic synonym
operation.execute(monitor, info);
-
+
Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0);
Assert.assertTrue("Taxon should have a homotypic group", taxon.getHomotypicSynonymyGroups().size() > 0);
Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonymRelations().toArray(new SynonymRelationship[0])[0].getType());
}
-
+
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testUndoTaxonHomotypicGroup() throws ExecutionException {
homotypicalGroup.addTypifiedName(taxonName);
-
+
operation.execute(monitor, info);
operation.undo(monitor, info);
-
+
Assert.assertTrue("There should not be synonym relationships for the taxon", taxon.getSynonyms().size() == 0);
}
-
+
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testUndoSynonymHomotypicGroup() throws ExecutionException {
operation.execute(monitor, info);
operation.undo(monitor, info);
-
+
Assert.assertTrue("There should not be synonym relationships for the taxon", taxon.getSynonyms().size() == 0);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testRedoTaxonHomotypicGroup() throws ExecutionException {
homotypicalGroup.addTypifiedName(taxonName);
-
+
operation.execute(monitor, info);
- operation.undo(monitor, info);
+ operation.undo(monitor, info);
operation.redo(monitor, info);
-
+
Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0);
Assert.assertTrue("Taxon should have a homotypic synonym now", taxon.getHomotypicSynonymsByHomotypicGroup().size() > 0);
}
-
+
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testRedoSynonymHomotypicGroup() throws ExecutionException {
operation.execute(monitor, info);
- operation.undo(monitor, info);
+ operation.undo(monitor, info);
operation.redo(monitor, info);
-
+
Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0);
Assert.assertTrue("Taxon should have a homotypic group", taxon.getHomotypicSynonymyGroups().size() > 0);
Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonymRelations().toArray(new SynonymRelationship[0])[0].getType());
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
private static DescriptionElementBase descriptionElement;
private static TaxonDescription description;
-
+
/**
* @throws java.lang.Exception
*/
public static void setUpBeforeClass() throws Exception {
taxon = Taxon.NewInstance(null, null);
descriptionElement = TextData.NewInstance();
-
+
description = TaxonDescription.NewInstance();
-
+
description.addElement(descriptionElement);
-
+
taxon.addDescription(description);
-
-
- operation = new DeleteDescriptionElementOperation("", undoContext, descriptionElement, postOperation);
+
+
+ operation = new DeleteDescriptionElementOperation("", undoContext, descriptionElement, postOperation, cdmEntitySessionEnabled);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
operation.execute(monitor, info);
-
+
Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() == 0);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
operation.undo(monitor, info);
-
+
Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() > 0);
Assert.assertEquals(descriptionElement, taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().toArray(new DescriptionElementBase[0])[0]);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
operation.redo(monitor, info);
-
+
Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() == 0);
}
}
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
-import eu.etaxonomy.taxeditor.editor.name.operation.SwapSynonymAndAcceptedOperation;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
public class SwapSynonymAndAcceptedOperationTest extends AbstractTaxeditorOperationTestBase {
private static final Logger logger = Logger
.getLogger(SwapSynonymAndAcceptedOperationTest.class);
-
+
private static AbstractPostOperation operation;
private static Taxon taxon;
private static NonViralName<?> oldTaxonName;
-
+
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
-
+
(new DefaultTermInitializer()).initialize();
-
+
// Create the original accepted taxon
oldTaxonName = NonViralName.NewInstance(null);
taxon = Taxon.NewInstance(oldTaxonName, null);
-
+
// Create its parent taxon
parentTaxon = Taxon.NewInstance(NonViralName.NewInstance(null), null);
parentTaxon.addTaxonomicChild(taxon, null, null);
// Give it a child taxon
childTaxon = Taxon.NewInstance(NonViralName.NewInstance(null), null);
childTaxon.setTaxonomicParent(taxon, null, null);
-
+
// Create a homotypic synonym for the accepted taxon
taxon.addHomotypicSynonymName(NonViralName.NewInstance(null), null, null);
// homotypicSynonym = Synonym.NewInstance(NonViralName.NewInstance(null), null);
// HomotypicalGroup acceptedHomotypicalGroup = HomotypicalGroup.NewInstance();
// acceptedHomotypicalGroup.addTypifiedName(oldTaxon.getName());
// acceptedHomotypicalGroup.addTypifiedName(homotypicSynonym.getName());
-
+
// Create a heterotypic synonym that will be used to create the new accepted taxon
oldSynonymName = NonViralName.NewInstance(null);
oldHeterotypicSynonym = Synonym.NewInstance(oldSynonymName, null);
heteroypicalGroup = HomotypicalGroup.NewInstance();
heteroypicalGroup.addTypifiedName(oldHeterotypicSynonym.getName());
taxon.addSynonym(oldHeterotypicSynonym, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
-
+
// Create a misapplication
misapplication = Taxon.NewInstance(NonViralName.NewInstance(null), null);
- taxon.addMisappliedName(misapplication, null, null);
-
+ taxon.addMisappliedName(misapplication, null, null);
+
// Create a concept relation
concept = Taxon.NewInstance(NonViralName.NewInstance(null), null);
conceptRelationshipType = TaxonRelationshipType.CONGRUENT_TO();
- concept.addTaxonRelation(taxon, conceptRelationshipType, null, null);
-
+ concept.addTaxonRelation(taxon, conceptRelationshipType, null, null);
+
// Create a description
description = TaxonDescription.NewInstance();
taxon.addDescription(description);
-
+
operation = new SwapSynonymAndAcceptedOperation
- (null, undoContext, taxon, oldHeterotypicSynonym, postOperation);
+ (null, undoContext, taxon, oldHeterotypicSynonym, postOperation, cdmEntitySessionEnabled);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testExecute() throws ExecutionException {
operation.execute(null, null);
-
- // New taxon has correct name?
+
+ // New taxon has correct name?
Assert.assertEquals(taxon.getName(), oldSynonymName);
-
+
// New taxon has correct parent?
Assert.assertEquals(taxon.getTaxonomicParent(), parentTaxon);
-
+
// New taxon has correct child?
Assert.assertTrue(taxon.getTaxonomicChildren().contains(childTaxon));
-
+
// New taxon has 2 synonyms?
Assert.assertEquals(taxon.getSynonyms().size(), 2);
-
+
// New taxon has a synonym with the name of the previous accepted taxon?
Assert.assertTrue(taxon.getSynonymNames().contains(oldTaxonName));
-
+
// New taxon has misapplication?
Assert.assertTrue(taxon.getMisappliedNames().contains(misapplication));
-
+
// New taxon has 1 concept relation?
int conceptRelCount = 0;
for (TaxonRelationship relation : taxon.getTaxonRelations()) {
conceptRelCount++;
}
Assert.assertEquals(conceptRelCount, 1);
-
+
// New taxon has description?
taxon.getDescriptions().contains(description);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testUndo() throws ExecutionException {
operation.undo(null, null);
-
+
// Assert.assertEquals(oldHomotypicalGroup, synonym.getHomotypicGroup());
}
-
+
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testRedo() throws ExecutionException {
operation.redo(null, null);
-
+
// Assert.assertEquals(newHomotypicalGroup, synonym.getHomotypicGroup());
}