use of name.abuchen.portfolio.ui.views.taxonomy.TaxonomyNode.AssignmentNode in project portfolio by buchen.
the class TaxonomyModel method addUnassigned.
private void addUnassigned(Client client) {
for (Security security : client.getSecurities()) {
Assignment assignment = new Assignment(security);
assignment.setWeight(0);
investmentVehicle2weight.put(security, assignment);
}
for (Account account : client.getAccounts()) {
Assignment assignment = new Assignment(account);
assignment.setWeight(0);
investmentVehicle2weight.put(account, assignment);
}
visitAll(node -> {
if (!(node instanceof AssignmentNode))
return;
Assignment assignment = node.getAssignment();
Assignment count = investmentVehicle2weight.get(assignment.getInvestmentVehicle());
count.setWeight(count.getWeight() + assignment.getWeight());
});
List<Assignment> unassigned = new ArrayList<>();
for (Assignment assignment : investmentVehicle2weight.values()) {
if (assignment.getWeight() >= Classification.ONE_HUNDRED_PERCENT)
continue;
Assignment a = new Assignment(assignment.getInvestmentVehicle());
a.setWeight(Classification.ONE_HUNDRED_PERCENT - assignment.getWeight());
unassigned.add(a);
assignment.setWeight(Classification.ONE_HUNDRED_PERCENT);
}
Collections.sort(unassigned, (o1, o2) -> o1.getInvestmentVehicle().toString().compareToIgnoreCase(o2.getInvestmentVehicle().toString()));
for (Assignment assignment : unassigned) unassignedNode.addChild(assignment);
}
Aggregations