/* package */TaxonomyModel(Client client, Taxonomy taxonomy)
{
this.taxonomy = taxonomy;
this.snapshot = ClientSnapshot.create(client, Dates.today());
Classification root = taxonomy.getRoot();
rootNode = new ClassificationNode(null, root);
LinkedList<TaxonomyNode> stack = new LinkedList<TaxonomyNode>();
stack.add(rootNode);
while (!stack.isEmpty())
{
TaxonomyNode m = stack.pop();
Classification classification = m.getClassification();
for (Classification c : classification.getChildren())
{
TaxonomyNode cm = new ClassificationNode(m, c);
stack.push(cm);
m.getChildren().add(cm);
}
for (Assignment assignment : classification.getAssignments())
m.getChildren().add(new AssignmentNode(m, assignment));
Collections.sort(m.getChildren(), new Comparator<TaxonomyNode>()
{
@Override
public int compare(TaxonomyNode o1, TaxonomyNode o2)
{
return o1.getRank() > o2.getRank() ? 1 : o1.getRank() == o2.getRank() ? 0 : -1;
}
});
}
unassignedNode = new UnassignedContainerNode(rootNode, new Classification(root, Classification.UNASSIGNED_ID,
Messages.LabelWithoutClassification));
rootNode.getChildren().add(unassignedNode);
// add unassigned
addUnassigned(client);