X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fdb%2FTemplateHeader.java;h=87ea4fd84050ca741f3acdfe013718cbff3c5d7a;hp=9d355d09cfc46de8309d573bf59eb3f20813248a;hb=4a44ce88b61f00c2710877cf26818db2728b5d91;hpb=e58019b5058f781dcc4860fb222808ca885ab491 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 9d355d09..87ea4fd8 100644 --- a/app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java +++ b/app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java @@ -21,13 +21,17 @@ 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 = "templates") +import java.util.UUID; + +@Entity(tableName = "templates", + indices = {@Index(name = "templates_uuid_idx", unique = true, value = "uuid")}) public class TemplateHeader extends TemplateBase { @PrimaryKey(autoGenerate = true) private long id; @@ -35,6 +39,9 @@ public class TemplateHeader extends TemplateBase { @NonNull private String name; @NonNull + @ColumnInfo + private String uuid; + @NonNull @ColumnInfo(name = "regular_expression") private String regularExpression; @ColumnInfo(name = "test_text") @@ -66,10 +73,13 @@ public class TemplateHeader extends TemplateBase { this.id = id; this.name = name; this.regularExpression = regularExpression; + this.uuid = UUID.randomUUID() + .toString(); } public TemplateHeader(TemplateHeader origin) { id = origin.id; name = origin.name; + uuid = origin.uuid; regularExpression = origin.regularExpression; testText = origin.testText; transactionDescription = origin.transactionDescription; @@ -84,6 +94,13 @@ public class TemplateHeader extends TemplateBase { dateDayMatchGroup = origin.dateDayMatchGroup; isFallback = origin.isFallback; } + @NonNull + public String getUuid() { + return uuid; + } + public void setUuid(@NonNull String uuid) { + this.uuid = uuid; + } public boolean isFallback() { return isFallback; }