\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
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
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