X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fdb%2FTemplateWithAccounts.java;h=8572167ddc63677bd416080ac2741875ac7d434c;hb=3aef8f6c15117aa4ea9abd687ad2c69e0f1f25bb;hp=a40ecae924417214d543e880421fb1e3d2b92e3e;hpb=3ab99e1679326277d6ba7f8ce28f17a96dfa07aa;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/db/TemplateWithAccounts.java b/app/src/main/java/net/ktnx/mobileledger/db/TemplateWithAccounts.java index a40ecae9..8572167d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/db/TemplateWithAccounts.java +++ b/app/src/main/java/net/ktnx/mobileledger/db/TemplateWithAccounts.java @@ -20,6 +20,7 @@ package net.ktnx.mobileledger.db; import androidx.room.Embedded; import androidx.room.Relation; +import java.util.ArrayList; import java.util.List; public class TemplateWithAccounts { @@ -28,7 +29,27 @@ public class TemplateWithAccounts { @Relation(parentColumn = "id", entityColumn = "template_id") public List accounts; + public static TemplateWithAccounts from(TemplateWithAccounts o) { + TemplateWithAccounts result = new TemplateWithAccounts(); + result.header = new TemplateHeader(o.header); + result.accounts = new ArrayList<>(); + for (TemplateAccount acc : o.accounts) { + result.accounts.add(new TemplateAccount(acc)); + } + + return result; + } public Long getId() { return header.getId(); } + public TemplateWithAccounts createDuplicate() { + TemplateWithAccounts result = new TemplateWithAccounts(); + result.header = header.createDuplicate(); + result.accounts = new ArrayList<>(); + for (TemplateAccount acc : accounts) { + result.accounts.add(acc.createDuplicate()); + } + + return result; + } }