minor changes
authorf.revilla <f.revilla@localhost>
Mon, 5 Jul 2010 08:18:11 +0000 (08:18 +0000)
committerf.revilla <f.revilla@localhost>
Mon, 5 Jul 2010 08:18:11 +0000 (08:18 +0000)
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DistributionTree.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IDescriptionService.java

index 459a0afdd6e9e893361ce6c22c8bc859472bbda5..bf018a9e2154cae46402709308161bad9a525fff 100644 (file)
@@ -206,13 +206,14 @@ public class DescriptionServiceImpl extends IdentifiableServiceBase<DescriptionB
        \r
        public DistributionTree getOrderedDistributionsB(\r
                        Set<TaxonDescription> taxonDescriptions,\r
-                       Set<NamedAreaLevel> omitLevels){\r
+                       Set<NamedAreaLevel> omitLevels,\r
+                       List<String> propertyPaths){\r
                \r
                DistributionTree tree = new DistributionTree();\r
                List<Distribution> distList = new ArrayList<Distribution>();\r
                \r
                for (TaxonDescription taxonDescription : taxonDescriptions) {\r
-                       taxonDescription = (TaxonDescription) dao.load(taxonDescription.getUuid());\r
+                       taxonDescription = (TaxonDescription) dao.load(taxonDescription.getUuid(), propertyPaths);\r
                        Set<DescriptionElementBase> elements = taxonDescription.getElements();\r
                        for (DescriptionElementBase element : elements) {\r
                                if(element.isInstanceOf(Distribution.class)){\r
index 080c7485997ae89f7bebe0d240754e620a2e8487..6d7f41f62d8f3ed30d6f4c2c20509ffa433a7975 100644 (file)
@@ -19,7 +19,7 @@ public class DistributionTree extends Tree<Distribution>{
                NamedArea area = new NamedArea();\r
                Distribution data = Distribution.NewInstance();\r
                data.setArea(area);\r
-               data.addModifyingText("test", Language.ENGLISH());\r
+               //data.addModifyingText("test", Language.ENGLISH());\r
                TreeNode<Distribution> rootElement = new TreeNode<Distribution>();\r
                List<TreeNode<Distribution>> children = new ArrayList<TreeNode<Distribution>>();\r
                \r
@@ -96,34 +96,33 @@ public class DistributionTree extends Tree<Distribution>{
                                                  NamedAreaLevel level,\r
                                                  List<NamedArea> areaHierarchieList, \r
                                                  TreeNode<Distribution> root){\r
+               boolean containsChild, sameLevel = false;\r
                TreeNode<Distribution> highestDistNode;\r
                TreeNode<Distribution> child;// the new child to add or the child to follow through the tree\r
                //if the list to merge is empty finish the execution\r
                if (areaHierarchieList.isEmpty()) {\r
                        return;\r
                }\r
-               //getting the highest area and inserting it into the tree\r
+               //getting the highest area and inserting it (if neccesary) into the tree\r
                NamedArea highestArea = areaHierarchieList.get(0);\r
-               //NamedAreaLevel highestAreaLevel = (NamedAreaLevel) HibernateProxyHelper.deproxy(highestArea.getLevel());\r
-               //NamedAreaLevel currentLevel = (NamedAreaLevel) HibernateProxyHelper.deproxy(level);\r
-               //if (highestAreaLevel.compareTo(currentLevel) == 0){//if distribution.status is relevant\r
-               \r
-               if (highestArea.getLevel().getLabel().compareTo(level.getLabel()) == 0){\r
-                       highestDistNode = new TreeNode<Distribution>(distribution);//distribution.area comes from proxy!!!!\r
+               sameLevel = highestArea.getLevel().getLabel().compareTo(level.getLabel()) == 0;\r
+               if (sameLevel){\r
+                       highestDistNode = new TreeNode<Distribution>(distribution);\r
                }else{ //if distribution.status is not relevant\r
                        Distribution data = Distribution.NewInstance(highestArea, null);\r
                        highestDistNode = new TreeNode<Distribution>(data);\r
                }\r
-               if(highestDistNode.data.getModifyingText().isEmpty()){\r
-                       highestDistNode.data.addModifyingText("test", Language.ENGLISH());\r
-               }\r
-\r
-               if (root.getChildren().isEmpty() || !containsChild(root, highestDistNode)) {\r
+               containsChild = containsChild(root, highestDistNode);\r
+               if (root.getChildren().isEmpty() || !containsChild) {\r
                        //if the highest level is not on the depth-1 of the tree we add it.\r
                        //child = highestDistNode;\r
-                       child = new TreeNode<Distribution>(highestDistNode.data);\r
-                       root.addChild(child);//child.getData().getArea().getUuid().toString().equals("8cfc1722-e1e8-49d3-95a7-9879de6de490");\r
+                       child = new TreeNode<Distribution>(highestDistNode.data); \r
+                       root.addChild(child);\r
                }else {\r
+                       //adding the sources to the child\r
+                       if(containsChild && sameLevel){\r
+                               getChild(root, highestDistNode).data.getSources().addAll(highestDistNode.data.getSources());\r
+                       }\r
                        //if the deepth-1 of the tree contains the highest area level\r
                        //get the subtree or create it in order to continuing merging\r
                        child = getChild(root,highestDistNode);\r
index f85445eced8aa0ba96358cdb36e18d4cada6e51a..20e2a5a92d3bc386847493cb84c436193543c096 100644 (file)
@@ -241,6 +241,6 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
     \r
     public List<DescriptionElementBase> getDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<? extends DescriptionElementBase> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);\r
 \r
-       public DistributionTree getOrderedDistributionsB(Set<TaxonDescription> taxonDescriptions, Set<NamedAreaLevel> levels);\r
+       public DistributionTree getOrderedDistributionsB(Set<TaxonDescription> taxonDescriptions, Set<NamedAreaLevel> levels, List<String> propertyPaths);\r
 \r
 }
\ No newline at end of file