import org.apache.log4j.Logger;
import org.eclipse.core.commands.ExecutionException;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
import org.unitils.dbunit.annotation.DataSet;
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.OriginalSourceType;
+import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.description.TextData;
import eu.etaxonomy.cdm.model.name.BotanicalName;
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @author cmathew
Set<Synonym> synonyms = taxon.getSynonyms();
for(Synonym synonym : synonyms) {
- taxonService.deleteSynonym(synonym.getUuid(), taxon.getUuid(), null);
+ taxonService.deleteSynonym(synonym.getUuid(), null);
}
taxonNodeService.merge(taxonNode);
taxonService.merge(taxon);
}
+ @Ignore
+ @Test
+ public void addDescription() {
+ UUID taxonNodeUuid = UUID.fromString("ce54c396-3694-47f2-abb0-1d7b7e057985");
+
+ TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid);
+ Taxon taxon = taxonNode.getTaxon();
+ TaxonDescription description = TaxonDescription.NewInstance(taxon);
+
+
+ TextData textData = TextData.NewInstance();
+
+ textData.setFeature(Feature.ECOLOGY());
+ description.addElement(textData);
+
+ DescriptionElementSource descriptionElementSource = DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
+ textData.addSource(descriptionElementSource);
+
+
+ CdmStore.getService(ITaxonNodeService.class).merge(taxonNode);
+
+ description.getId();
+ }
+
+
+ @Test
+ public void addTaxonNodeCascadeProblem() {
+ UUID taxonNodeUuid = UUID.fromString("ce54c396-3694-47f2-abb0-1d7b7e057985");
+
+ TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid);
+ Taxon childTaxon = Taxon.NewInstance(null, null);
+ TaxonNode childTaxonNode = taxonNode.addChildTaxon(childTaxon, null, null);
+ Taxon grandChildTaxon = Taxon.NewInstance(null, null);
+ TaxonNode grandChildTaxonNode = childTaxonNode.addChildTaxon(grandChildTaxon, null, null);
+
+ CdmStore.getService(ITaxonNodeService.class).merge(grandChildTaxonNode,true);
+
+ Assert.assertEquals(taxonNode.getChildNodes().get(0).getId(), childTaxonNode.getId());
+
+ Assert.assertTrue(childTaxonNode.treeIndex() != null);
+ Assert.assertEquals(taxonNode.getChildNodes().get(0).treeIndex(), childTaxonNode.treeIndex());
+ Assert.assertFalse(childTaxon.getId() == 0);
+ Assert.assertEquals(taxonNode.getChildNodes().get(0).getTaxon().getId(), childTaxon.getId());
+
+ Assert.assertTrue(grandChildTaxonNode.treeIndex() != null);
+ Assert.assertEquals(taxonNode.getChildNodes().get(0).getChildNodes().get(0).getId(), grandChildTaxonNode.getId());
+ Assert.assertFalse(grandChildTaxon.getId() == 0);
+ Assert.assertEquals(taxonNode.getChildNodes().get(0).getChildNodes().get(0).getTaxon().getId(), grandChildTaxon.getId());
+ }
+
}