X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fdb%2FTemplateAccount.java;h=8651e3fee09ba66ac857788e30a62e0e04894e84;hb=32ad05360ecf167803ef0bf9c7938c52b348123e;hp=92b290805ba3866689971846082e2dccbb046df0;hpb=d95839304defead7c7d605cab2e612f1227cbfed;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java b/app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java index 92b29080..8651e3fe 100644 --- a/app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java @@ -26,22 +26,23 @@ import androidx.room.PrimaryKey; import org.jetbrains.annotations.NotNull; -@Entity(tableName = "pattern_accounts", - indices = {@Index(name = "un_pattern_accounts", unique = true, value = "id"), - @Index(name = "fk_pattern_accounts_pattern", value = "pattern_id"), - @Index(name = "fk_pattern_accounts_currency", value = "currency") - }, foreignKeys = {@ForeignKey(childColumns = "pattern_id", parentColumns = "id", - entity = TemplateHeader.class), +@Entity(tableName = "template_accounts", + indices = {@Index(name = "fk_template_accounts_template", value = "template_id"), + @Index(name = "fk_template_accounts_currency", value = "currency") + }, foreignKeys = {@ForeignKey(childColumns = "template_id", parentColumns = "id", + entity = TemplateHeader.class, onDelete = ForeignKey.CASCADE, + onUpdate = ForeignKey.RESTRICT), @ForeignKey(childColumns = "currency", parentColumns = "id", - entity = Currency.class) + entity = Currency.class, onDelete = ForeignKey.RESTRICT, + onUpdate = ForeignKey.RESTRICT) }) public class TemplateAccount extends TemplateBase { - @NonNull - @ColumnInfo(name = "pattern_id") - private Long patternId; @PrimaryKey(autoGenerate = true) @NotNull private Long id; + @NonNull + @ColumnInfo(name = "template_id") + private Long templateId; @ColumnInfo(name = "acc") private String accountName; @ColumnInfo(name = "position") @@ -63,9 +64,9 @@ public class TemplateAccount extends TemplateBase { private Integer accountCommentMatchGroup; @ColumnInfo(name = "negate_amount") private Boolean negateAmount; - public TemplateAccount(@NotNull Long id, @NonNull Long patternId, @NonNull Long position) { + public TemplateAccount(@NotNull Long id, @NonNull Long templateId, @NonNull Long position) { this.id = id; - this.patternId = patternId; + this.templateId = templateId; this.position = position; } public Long getId() { @@ -80,11 +81,11 @@ public class TemplateAccount extends TemplateBase { public void setNegateAmount(Boolean negateAmount) { this.negateAmount = negateAmount; } - public @NotNull Long getPatternId() { - return patternId; + public @NotNull Long getTemplateId() { + return templateId; } - public void setPatternId(@NonNull Long patternId) { - this.patternId = patternId; + public void setTemplateId(@NonNull Long templateId) { + this.templateId = templateId; } @NonNull public String getAccountName() {