2 * Copyright © 2021 Damyan Ivanov.
3 * This file is part of MoLe.
4 * MoLe is free software: you can distribute it and/or modify it
5 * under the term of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your opinion), any later version.
9 * MoLe is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License terms for details.
14 * You should have received a copy of the GNU General Public License
15 * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
18 package net.ktnx.mobileledger.db;
20 import androidx.annotation.NonNull;
21 import androidx.room.ColumnInfo;
22 import androidx.room.Entity;
23 import androidx.room.Index;
26 create table transactions(profile varchar not null, id integer not null, data_hash varchar not
27 null, year integer not null, month integer not null, day integer not null, description varchar
28 collate NOCASE not null, comment varchar, generation integer default 0, primary key(profile,id));
29 create unique index un_transactions_data_hash on transactions(profile,data_hash);
30 create index idx_transaction_description on transactions(description);
32 @Entity(tableName = "transactions", primaryKeys = {"profile", "id"}, indices = {
33 @Index(name = "un_transactions_data_hash", unique = true, value = {"profile", "data_hash"}),
34 @Index(name = "idx_transaction_description", value = "description")
36 public class Transaction {
39 private String profile;
42 @ColumnInfo(name = "data_hash")
44 private String dataHash;
51 @ColumnInfo(collate = ColumnInfo.NOCASE)
53 private String description;
55 private String comment;
57 private int generation = 0;
58 public String getProfile() {
61 public void setProfile(String profile) {
62 this.profile = profile;
67 public void setId(int id) {
70 public String getDataHash() {
73 public void setDataHash(String dataHash) {
74 this.dataHash = dataHash;
76 public int getYear() {
79 public void setYear(int year) {
82 public int getMonth() {
85 public void setMonth(int month) {
91 public void setDay(int day) {
94 public String getDescription() {
97 public void setDescription(String description) {
98 this.description = description;
100 public String getComment() {
103 public void setComment(String comment) {
104 this.comment = comment;
106 public int getGeneration() {
109 public void setGeneration(int generation) {
110 this.generation = generation;