X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fdb%2FTemplateHeader.java;h=9d355d09cfc46de8309d573bf59eb3f20813248a;hb=5df10dc0b58df4d4be4e9ab34f1e0f477ca46766;hp=301b100c19dab93fb8080817669e25dd7c3cf11a;hpb=d95839304defead7c7d605cab2e612f1227cbfed;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java b/app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java index 301b100c..9d355d09 100644 --- a/app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java +++ b/app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java @@ -21,19 +21,16 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.room.ColumnInfo; import androidx.room.Entity; -import androidx.room.Index; import androidx.room.PrimaryKey; import net.ktnx.mobileledger.utils.Misc; import org.jetbrains.annotations.NotNull; -@Entity(tableName = "patterns", - indices = {@Index(name = "un_patterns_id", value = "id", unique = true)}) +@Entity(tableName = "templates") public class TemplateHeader extends TemplateBase { @PrimaryKey(autoGenerate = true) - @NonNull - private Long id; + private long id; @ColumnInfo(name = "name") @NonNull private String name; @@ -62,12 +59,37 @@ public class TemplateHeader extends TemplateBase { private Integer dateDay; @ColumnInfo(name = "date_day_match_group") private Integer dateDayMatchGroup; + @ColumnInfo(name = "is_fallback") + private boolean isFallback; public TemplateHeader(@NotNull Long id, @NonNull String name, @NonNull String regularExpression) { this.id = id; this.name = name; this.regularExpression = regularExpression; } + public TemplateHeader(TemplateHeader origin) { + id = origin.id; + name = origin.name; + regularExpression = origin.regularExpression; + testText = origin.testText; + transactionDescription = origin.transactionDescription; + transactionDescriptionMatchGroup = origin.transactionDescriptionMatchGroup; + transactionComment = origin.transactionComment; + transactionCommentMatchGroup = origin.transactionCommentMatchGroup; + dateYear = origin.dateYear; + dateYearMatchGroup = origin.dateYearMatchGroup; + dateMonth = origin.dateMonth; + dateMonthMatchGroup = origin.dateMonthMatchGroup; + dateDay = origin.dateDay; + dateDayMatchGroup = origin.dateDayMatchGroup; + isFallback = origin.isFallback; + } + public boolean isFallback() { + return isFallback; + } + public void setFallback(boolean fallback) { + isFallback = fallback; + } public String getTestText() { return testText; } @@ -104,11 +126,10 @@ public class TemplateHeader extends TemplateBase { public void setDateDay(Integer dateDay) { this.dateDay = dateDay; } - @NonNull - public Long getId() { + public long getId() { return id; } - public void setId(@NonNull Long id) { + public void setId(long id) { this.id = id; } @NonNull @@ -178,4 +199,10 @@ public class TemplateHeader extends TemplateBase { Misc.equalIntegers(dateYear, o.dateYear) && Misc.equalIntegers(dateYearMatchGroup, o.dateYearMatchGroup); } + public TemplateHeader createDuplicate() { + TemplateHeader dup = new TemplateHeader(this); + dup.id = 0; + + return dup; + } }