import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
/**
* @author pplitzner
boolean isEditable = true;
Object rowObject = matrix.getBodyDataProvider().getRowObject(rowPosition);
- if(rowObject instanceof TaxonNode){
+ if(rowObject instanceof TaxonNodeDto){
configLabels.addLabel(CharacterMatrix.LABEL_TAXON_ROW);
}
else if(rowObject instanceof TaxonRowWrapperDTO){
import java.util.List;
import ca.odell.glazedlists.TreeList;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
import eu.etaxonomy.cdm.model.name.Rank;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* The tree format defines how to build the hierarchy path for the
public void getPath(List path, Object element) {
if(element instanceof RowWrapperDTO){
//TODO: check for multiple taxon nodes in multiple classifications
- TaxonNode taxonNode = ((RowWrapperDTO) element).getTaxonNode();
+ TaxonNodeDto taxonNode = ((RowWrapperDTO) element).getTaxonNode();
addPathRecursive(path, taxonNode);
}
path.add(element);
}
- private void addPathRecursive(List path, TaxonNode node){
- if(node!=null
- && node.getParent()!=null
- && node.getTaxon()!=null
- && node.getTaxon().getName()!=null
- && node.getTaxon().getName().getRank()!=null){
- Rank rank = node.getTaxon().getName().getRank();
- if(maxRank!=null && maxRank.equals(rank)){
+ private void addPathRecursive(List path, TaxonNodeDto node){
+ if(node!=null){
+ if(maxRank!=null && node.getRankOrderIndex()==maxRank.getOrderIndex()){
path.add(node);
return;
}
- addPathRecursive(path, node.getParent());
- path.add(node);
+ TaxonNode parent = CdmStore.getService(ITaxonNodeService.class).load(node.getParentUUID());
+ if(parent!=null){
+ TaxonNodeDto parentNodeDto = new TaxonNodeDto(parent);
+ addPathRecursive(path, parentNodeDto);
+ path.add(node);
+ }
}
}
import java.util.Comparator;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.model.common.MarkerType;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.taxon.TaxonNaturalComparator;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.cdm.model.taxon.TaxonNodeByNameComparator;
-import eu.etaxonomy.cdm.model.taxon.TaxonNodeByRankAndNameComparator;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByRankAndNameComparator;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoNaturalComparator;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @author pplitzner
*/
public class MatrixRowComparator implements Comparator<Object>{
- private Comparator<TaxonNode> comparator;
+ private Comparator<TaxonNodeDto> comparator;
+ private ITaxonNodeService taxonNodeService;
public MatrixRowComparator() {
+ taxonNodeService = CdmStore.getService(ITaxonNodeService.class);
if (PreferencesUtil.isNodesSortedNaturally()){
- comparator = new TaxonNaturalComparator();
+ comparator = new TaxonNodeDtoNaturalComparator();
} else if (PreferencesUtil.isNodesSortedByName()){
- comparator = new TaxonNodeByNameComparator();
+ comparator = new TaxonNodeDtoByNameComparator();
}else {
- comparator = new TaxonNodeByRankAndNameComparator();
+ comparator = new TaxonNodeDtoByRankAndNameComparator();
}
}
@Override
public int compare(Object o1, Object o2) {
- if(o1 instanceof TaxonNode){
+ if(o1 instanceof TaxonNodeDto){
if(o2 instanceof RowWrapperDTO){
return 1;
}
}
else{
- if(o2 instanceof TaxonNode){
+ if(o2 instanceof TaxonNodeDto){
return -1;
}
}
- if(o1 instanceof TaxonNode && o2 instanceof TaxonNode){
- return comparator.compare((TaxonNode)o1, (TaxonNode)o2);
+ if(o1 instanceof TaxonNodeDto && o2 instanceof TaxonNodeDto){
+ return comparator.compare((TaxonNodeDto)o1, (TaxonNodeDto)o2);
}
if(o1 instanceof RowWrapperDTO && o2 instanceof RowWrapperDTO){
RowWrapperDTO rowWrapper1 = (RowWrapperDTO)o1;
if(rowWrapper1.equals(rowWrapper2)){
return 0;
}
- TaxonNode node1 = rowWrapper1.getTaxonNode().getParent();
- TaxonNode node2 = rowWrapper2.getTaxonNode().getParent();
+ TaxonNodeDto node1 = taxonNodeService.dto(rowWrapper1.getTaxonNode().getParentUUID());
+ TaxonNodeDto node2 = taxonNodeService.dto(rowWrapper2.getTaxonNode().getParentUUID());
if(node1!=null && node2!=null){
//compare by taxon node
int compare = comparator.compare(node1, node2);
import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
import eu.etaxonomy.cdm.model.common.MarkerType;
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
import eu.etaxonomy.taxeditor.store.CdmStore;
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, UISynchronize sync) {
CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject();
DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
- TaxonNode node = (TaxonNode) matrixPart.getSelection().getFirstElement();
+ TaxonNodeDto node = (TaxonNodeDto) matrixPart.getSelection().getFirstElement();
TaxonRowWrapperDTO taxonRowWrapperDTO = CdmStore.getService(IDescriptiveDataSetService.class)
.createTaxonDescription(descriptiveDataSet.getUuid(), node.getUuid(), getMarkerType(), getMarkerFlag());
+ matrixPart.getMatrix().getCdmEntitiySession().load(taxonRowWrapperDTO.getDescription(), true);
matrixPart.getMatrix().getDescriptions().add(taxonRowWrapperDTO);
}
boolean canExecute = false;
IStructuredSelection selection = ((CharacterMatrixPart)activePart.getObject()).getSelection();
canExecute = selection.size()==1
- && selection.getFirstElement() instanceof TaxonNode;
+ && selection.getFirstElement() instanceof TaxonNodeDto;
menuItem.setVisible(canExecute);
return canExecute;
}
import eu.etaxonomy.cdm.model.location.NamedArea;
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
/**
* Converts the supplemental information (taxon and specimen data)
@Override
public Object canonicalToDisplayValue(Object canonicalValue) {
String displayValue = "";
- if(HibernateProxyHelper.isInstanceOf(canonicalValue, TaxonNode.class)){
- TaxonNode node = (TaxonNode)canonicalValue;
- displayValue = node.getTaxon().getName().getTitleCache();
+ if(canonicalValue instanceof TaxonNodeDto){
+ TaxonNodeDto node = (TaxonNodeDto)canonicalValue;
+ displayValue = node.getTaxonTitleCache();
}
else if(HibernateProxyHelper.isInstanceOf(canonicalValue, FieldUnit.class)){
FieldUnit fieldUnit = HibernateProxyHelper.deproxy(canonicalValue, FieldUnit.class);