Search in sources :

Example 11 with Assignment

use of name.abuchen.portfolio.model.Classification.Assignment in project portfolio by buchen.

the class ClientFactory method assignSecurities.

private static boolean assignSecurities(Client client, Taxonomy taxonomy) {
    boolean hasAssignments = false;
    int rank = 0;
    for (Security security : client.getSecurities()) {
        Classification classification = taxonomy.getClassificationById(security.getIndustryClassification());
        if (classification != null) {
            Assignment assignment = new Assignment(security);
            assignment.setRank(rank++);
            classification.addAssignment(assignment);
            hasAssignments = true;
        }
    }
    return hasAssignments;
}
Also used : Assignment(name.abuchen.portfolio.model.Classification.Assignment)

Example 12 with Assignment

use of name.abuchen.portfolio.model.Classification.Assignment in project portfolio by buchen.

the class ClientFactory method buildTree.

private static void buildTree(Classification node, Category category) {
    int rank = 0;
    for (Category child : category.getChildren()) {
        Classification classification = new Classification(node, child.getUUID(), child.getName());
        classification.setWeight(child.getPercentage() * Values.Weight.factor());
        classification.setRank(rank++);
        node.addChild(classification);
        buildTree(classification, child);
    }
    for (Object element : category.getElements()) {
        Assignment assignment = element instanceof Account ? new Assignment((Account) element) : new Assignment((Security) element);
        assignment.setRank(rank++);
        node.addAssignment(assignment);
    }
}
Also used : Assignment(name.abuchen.portfolio.model.Classification.Assignment)

Aggregations

Assignment (name.abuchen.portfolio.model.Classification.Assignment)12 Classification (name.abuchen.portfolio.model.Classification)6 InvestmentVehicle (name.abuchen.portfolio.model.InvestmentVehicle)4 Security (name.abuchen.portfolio.model.Security)4 ArrayList (java.util.ArrayList)3 Account (name.abuchen.portfolio.model.Account)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)2 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)2 Client (name.abuchen.portfolio.model.Client)2 Portfolio (name.abuchen.portfolio.model.Portfolio)2 Unit (name.abuchen.portfolio.model.Transaction.Unit)2 Money (name.abuchen.portfolio.money.Money)2 LocalDate (java.time.LocalDate)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1