--- /dev/null
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 54,
+ "identityHash": "c5ddfa995546d7931ec2655613654949",
+ "entities": [
+ {
+ "tableName": "templates",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `regular_expression` TEXT NOT NULL, `test_text` TEXT, `transaction_description` TEXT, `transaction_description_match_group` INTEGER, `transaction_comment` TEXT, `transaction_comment_match_group` INTEGER, `date_year` INTEGER, `date_year_match_group` INTEGER, `date_month` INTEGER, `date_month_match_group` INTEGER, `date_day` INTEGER, `date_day_match_group` INTEGER)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "regularExpression",
+ "columnName": "regular_expression",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "testText",
+ "columnName": "test_text",
+ "affinity": "TEXT",
+ "notNull": false
+ },
+ {
+ "fieldPath": "transactionDescription",
+ "columnName": "transaction_description",
+ "affinity": "TEXT",
+ "notNull": false
+ },
+ {
+ "fieldPath": "transactionDescriptionMatchGroup",
+ "columnName": "transaction_description_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "transactionComment",
+ "columnName": "transaction_comment",
+ "affinity": "TEXT",
+ "notNull": false
+ },
+ {
+ "fieldPath": "transactionCommentMatchGroup",
+ "columnName": "transaction_comment_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "dateYear",
+ "columnName": "date_year",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "dateYearMatchGroup",
+ "columnName": "date_year_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "dateMonth",
+ "columnName": "date_month",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "dateMonthMatchGroup",
+ "columnName": "date_month_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "dateDay",
+ "columnName": "date_day",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "dateDayMatchGroup",
+ "columnName": "date_day_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ },
+ {
+ "tableName": "template_accounts",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `template_id` INTEGER NOT NULL, `acc` TEXT, `position` INTEGER NOT NULL, `acc_match_group` INTEGER, `currency` INTEGER, `currency_match_group` INTEGER, `amount` REAL, `amount_match_group` INTEGER, `comment` TEXT, `comment_match_group` INTEGER, `negate_amount` INTEGER, FOREIGN KEY(`template_id`) REFERENCES `templates`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`currency`) REFERENCES `currencies`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "templateId",
+ "columnName": "template_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "accountName",
+ "columnName": "acc",
+ "affinity": "TEXT",
+ "notNull": false
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "accountNameMatchGroup",
+ "columnName": "acc_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "currency",
+ "columnName": "currency",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "currencyMatchGroup",
+ "columnName": "currency_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "amount",
+ "columnName": "amount",
+ "affinity": "REAL",
+ "notNull": false
+ },
+ {
+ "fieldPath": "amountMatchGroup",
+ "columnName": "amount_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "accountComment",
+ "columnName": "comment",
+ "affinity": "TEXT",
+ "notNull": false
+ },
+ {
+ "fieldPath": "accountCommentMatchGroup",
+ "columnName": "comment_match_group",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "negateAmount",
+ "columnName": "negate_amount",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [
+ {
+ "name": "fk_template_accounts_template",
+ "unique": false,
+ "columnNames": [
+ "template_id"
+ ],
+ "createSql": "CREATE INDEX IF NOT EXISTS `fk_template_accounts_template` ON `${TABLE_NAME}` (`template_id`)"
+ },
+ {
+ "name": "fk_template_accounts_currency",
+ "unique": false,
+ "columnNames": [
+ "currency"
+ ],
+ "createSql": "CREATE INDEX IF NOT EXISTS `fk_template_accounts_currency` ON `${TABLE_NAME}` (`currency`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "templates",
+ "onDelete": "NO ACTION",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "template_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "currencies",
+ "onDelete": "NO ACTION",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "currency"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "currencies",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `position` TEXT NOT NULL, `has_gap` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "hasGap",
+ "columnName": "has_gap",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ }
+ ],
+ "views": [],
+ "setupQueries": [
+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c5ddfa995546d7931ec2655613654949')"
+ ]
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright © 2021 Damyan Ivanov.
- * This file is part of MoLe.
- * MoLe is free software: you can distribute it and/or modify it
- * under the term of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your opinion), any later version.
- *
- * MoLe is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License terms for details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package net.ktnx.mobileledger.dao;
-
-import androidx.lifecycle.LiveData;
-import androidx.room.Dao;
-import androidx.room.Delete;
-import androidx.room.Insert;
-import androidx.room.Query;
-import androidx.room.Update;
-
-import net.ktnx.mobileledger.db.TemplateAccount;
-
-import java.util.List;
-
-@Dao
-public interface PatternAccountDAO {
- @Insert
- Long insert(TemplateAccount item);
-
- @Update
- void update(TemplateAccount... items);
-
- @Delete
- void delete(TemplateAccount item);
-
- @Query("SELECT * FROM pattern_accounts WHERE pattern_id=:pattern_id")
- LiveData<List<TemplateAccount>> getPatternAccounts(Long pattern_id);
-
- @Query("SELECT * FROM pattern_accounts WHERE id = :id")
- LiveData<TemplateAccount> getPatternAccountById(Long id);
-
-// not useful for now
-// @Transaction
-// @Query("SELECT * FROM patterns")
-// List<PatternWithAccounts> getPatternsWithAccounts();
-}
+++ /dev/null
-/*
- * Copyright © 2021 Damyan Ivanov.
- * This file is part of MoLe.
- * MoLe is free software: you can distribute it and/or modify it
- * under the term of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your opinion), any later version.
- *
- * MoLe is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License terms for details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package net.ktnx.mobileledger.dao;
-
-import androidx.lifecycle.LiveData;
-import androidx.room.Dao;
-import androidx.room.Delete;
-import androidx.room.Insert;
-import androidx.room.Query;
-import androidx.room.Transaction;
-import androidx.room.Update;
-
-import net.ktnx.mobileledger.db.PatternWithAccounts;
-import net.ktnx.mobileledger.db.TemplateHeader;
-
-import java.util.List;
-
-@Dao
-public interface PatternHeaderDAO {
- @Insert()
- long insert(TemplateHeader item);
-
- @Update
- void update(TemplateHeader... items);
-
- @Delete
- void delete(TemplateHeader item);
-
- @Query("SELECT * FROM patterns ORDER BY UPPER(name)")
- LiveData<List<TemplateHeader>> getPatterns();
-
- @Query("SELECT * FROM patterns WHERE id = :id")
- LiveData<TemplateHeader> getPattern(Long id);
-
- @Transaction
- @Query("SELECT * FROM patterns WHERE id = :id")
- LiveData<PatternWithAccounts> getPatternWithAccounts(Long id);
-}
--- /dev/null
+/*
+ * Copyright © 2021 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.dao;
+
+import androidx.lifecycle.LiveData;
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.Query;
+import androidx.room.Update;
+
+import net.ktnx.mobileledger.db.TemplateAccount;
+
+import java.util.List;
+
+@Dao
+public interface TemplateAccountDAO {
+ @Insert
+ Long insert(TemplateAccount item);
+
+ @Update
+ void update(TemplateAccount... items);
+
+ @Delete
+ void delete(TemplateAccount item);
+
+ @Query("SELECT * FROM template_accounts WHERE template_id=:template_id")
+ LiveData<List<TemplateAccount>> getTemplateAccounts(Long template_id);
+
+ @Query("SELECT * FROM template_accounts WHERE id = :id")
+ LiveData<TemplateAccount> getPatternAccountById(Long id);
+
+// not useful for now
+// @Transaction
+// @Query("SELECT * FROM patterns")
+// List<PatternWithAccounts> getPatternsWithAccounts();
+}
--- /dev/null
+/*
+ * Copyright © 2021 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.dao;
+
+import androidx.lifecycle.LiveData;
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.Query;
+import androidx.room.Transaction;
+import androidx.room.Update;
+
+import net.ktnx.mobileledger.db.TemplateHeader;
+import net.ktnx.mobileledger.db.TemplateWithAccounts;
+
+import java.util.List;
+
+@Dao
+public interface TemplateHeaderDAO {
+ @Insert()
+ long insert(TemplateHeader item);
+
+ @Update
+ void update(TemplateHeader... items);
+
+ @Delete
+ void delete(TemplateHeader item);
+
+ @Query("SELECT * FROM templates ORDER BY UPPER(name)")
+ LiveData<List<TemplateHeader>> getTemplates();
+
+ @Query("SELECT * FROM templates WHERE id = :id")
+ LiveData<TemplateHeader> getTemplate(Long id);
+
+ @Transaction
+ @Query("SELECT * FROM templates WHERE id = :id")
+ LiveData<TemplateWithAccounts> getTemplateWithAccounts(Long id);
+}
import net.ktnx.mobileledger.App;
import net.ktnx.mobileledger.dao.CurrencyDAO;
-import net.ktnx.mobileledger.dao.PatternAccountDAO;
-import net.ktnx.mobileledger.dao.PatternHeaderDAO;
+import net.ktnx.mobileledger.dao.TemplateAccountDAO;
+import net.ktnx.mobileledger.dao.TemplateHeaderDAO;
import net.ktnx.mobileledger.utils.MobileLedgerDatabase;
-@Database(version = 53, entities = {TemplateHeader.class, TemplateAccount.class, Currency.class})
+@Database(version = 54, entities = {TemplateHeader.class, TemplateAccount.class, Currency.class})
abstract public class DB extends RoomDatabase {
private static DB instance;
public static DB get() {
db.execSQL(
"alter table pattern_accounts add negate_amount boolean;");
}
+ }, new Migration(53, 54) {
+ @Override
+ public void migrate(@NonNull SupportSQLiteDatabase db) {
+ db.execSQL("CREATE TABLE templates (id INTEGER PRIMARY KEY " +
+ "AUTOINCREMENT NOT NULL, name TEXT NOT NULL, " +
+ "regular_expression TEXT NOT NULL, test_text TEXT, " +
+ "transaction_description TEXT, " +
+ "transaction_description_match_group INTEGER, " +
+ "transaction_comment TEXT, " +
+ "transaction_comment_match_group INTEGER, date_year " +
+ "INTEGER, date_year_match_group INTEGER, date_month " +
+ "INTEGER, date_month_match_group INTEGER, date_day " +
+ "INTEGER, date_day_match_group INTEGER)");
+ db.execSQL(
+ "CREATE TABLE template_accounts (id INTEGER PRIMARY KEY " +
+ "AUTOINCREMENT NOT NULL, template_id INTEGER NOT NULL, " +
+ "acc TEXT, position INTEGER NOT NULL, acc_match_group " +
+ "INTEGER, currency INTEGER, currency_match_group INTEGER," +
+ " amount REAL, amount_match_group INTEGER, comment TEXT, " +
+ "comment_match_group INTEGER, negate_amount INTEGER, " +
+ "FOREIGN KEY(template_id) REFERENCES templates(id) ON " +
+ "UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY" +
+ "(currency) REFERENCES currencies(id) ON UPDATE NO ACTION" +
+ " ON DELETE NO ACTION )");
+ db.execSQL("insert into templates(id, name, regular_expression, " +
+ "test_text, transaction_description, " +
+ "transaction_description_match_group, " +
+ "transaction_comment, transaction_comment_match_group," +
+ " date_year, date_year_match_group, date_month, " +
+ "date_month_match_group, date_day, " +
+ "date_day_match_group)" +
+ " select id, name, regular_expression, test_text, " +
+ "transaction_description, " +
+ "transaction_description_match_group, " +
+ "transaction_comment, transaction_comment_match_group," +
+ " date_year, date_year_match_group, date_month, " +
+ "date_month_match_group, date_day, " +
+ "date_day_match_group from patterns");
+ db.execSQL("insert into template_accounts(id, template_id, acc, " +
+ "position, acc_match_group, currency, " +
+ "currency_match_group, amount, amount_match_group, " +
+ "amount, amount_match_group, comment, " +
+ "comment_match_group, negate_amount) select id, " +
+ "pattern_id, acc, position, acc_match_group, " +
+ "currency, " +
+ "currency_match_group, amount, amount_match_group, " +
+ "amount, amount_match_group, comment, " +
+ "comment_match_group, negate_amount from " +
+ "pattern_accounts");
+ db.execSQL("create index fk_template_accounts_template on " +
+ "template_accounts(template_id)");
+ db.execSQL("create index fk_template_accounts_currency on " +
+ "template_accounts(currency)");
+ db.execSQL("drop table pattern_accounts");
+ db.execSQL("drop table patterns");
+ }
}
})
.build();
}
}
- public abstract PatternHeaderDAO getPatternDAO();
+ public abstract TemplateHeaderDAO getPatternDAO();
- public abstract PatternAccountDAO getPatternAccountDAO();
+ public abstract TemplateAccountDAO getPatternAccountDAO();
public abstract CurrencyDAO getCurrencyDAO();
}
+++ /dev/null
-/*
- * Copyright © 2021 Damyan Ivanov.
- * This file is part of MoLe.
- * MoLe is free software: you can distribute it and/or modify it
- * under the term of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your opinion), any later version.
- *
- * MoLe is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License terms for details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package net.ktnx.mobileledger.db;
-
-import androidx.room.Embedded;
-import androidx.room.Relation;
-
-import java.util.List;
-
-public class PatternWithAccounts {
- @Embedded
- public TemplateHeader header;
- @Relation(parentColumn = "id", entityColumn = "pattern_id")
- public List<TemplateAccount> accounts;
-
- public Long getId() {
- return header.getId();
- }
-}
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(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),
@ForeignKey(childColumns = "currency", parentColumns = "id",
entity = Currency.class)
})
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")
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() {
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() {
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
--- /dev/null
+/*
+ * Copyright © 2021 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.db;
+
+import androidx.room.Embedded;
+import androidx.room.Relation;
+
+import java.util.List;
+
+public class TemplateWithAccounts {
+ @Embedded
+ public TemplateHeader header;
+ @Relation(parentColumn = "id", entityColumn = "template_id")
+ public List<TemplateAccount> accounts;
+
+ public Long getId() {
+ return header.getId();
+ }
+}
private void alertNoPatternMatch(String scanned) {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
builder.setCancelable(true)
- .setMessage(R.string.no_pattern_matches)
+ .setMessage(R.string.no_template_matches)
.setPositiveButton(R.string.add_button,
(dialog, which) -> startNewPatternActivity(scanned))
.create()
LiveData<List<TemplateHeader>> allPatterns = DB.get()
.getPatternDAO()
- .getPatterns();
+ .getTemplates();
allPatterns.observe(getViewLifecycleOwner(), patternHeaders -> {
ArrayList<TemplateHeader> matchingPatterns = new ArrayList<>();
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
builder.setCancelable(true)
- .setTitle(R.string.choose_pattern_to_apply)
+ .setTitle(R.string.choose_template_to_apply)
.setSingleChoiceItems(cursor, -1, patternNameColumn, (dialog, which) -> {
applyPattern(matchingPatterns.get(which), matchedText);
dialog.dismiss();
DB.get()
.getPatternDAO()
- .getPatternWithAccounts(patternHeader.getId())
+ .getTemplateWithAccounts(patternHeader.getId())
.observe(getViewLifecycleOwner(), entry -> {
int rowIndex = 0;
final boolean accountsInInitialState = viewModel.accountsInInitialState();
final ViewModelStoreOwner viewModelStoreOwner =
controller.getViewModelStoreOwner(R.id.template_list_navigation);
mViewModel = new ViewModelProvider(viewModelStoreOwner).get(TemplateDetailsViewModel.class);
- mViewModel.setDefaultPatternName(getString(R.string.unnamed_pattern));
+ mViewModel.setDefaultPatternName(getString(R.string.unnamed_template));
Logger.debug("flow", "PatternDetailsFragment.onCreateView(): model=" + mViewModel);
b = TemplateDetailsFragmentBinding.inflate(inflater);
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModel;
-import net.ktnx.mobileledger.dao.PatternAccountDAO;
-import net.ktnx.mobileledger.dao.PatternHeaderDAO;
+import net.ktnx.mobileledger.dao.TemplateAccountDAO;
+import net.ktnx.mobileledger.dao.TemplateHeaderDAO;
import net.ktnx.mobileledger.db.DB;
-import net.ktnx.mobileledger.db.PatternWithAccounts;
import net.ktnx.mobileledger.db.TemplateAccount;
import net.ktnx.mobileledger.db.TemplateHeader;
+import net.ktnx.mobileledger.db.TemplateWithAccounts;
import net.ktnx.mobileledger.model.TemplateDetailsItem;
import net.ktnx.mobileledger.utils.Logger;
}
DB db = DB.get();
- LiveData<PatternWithAccounts> dbList = db.getPatternDAO()
- .getPatternWithAccounts(mPatternId);
- Observer<PatternWithAccounts> observer = new Observer<PatternWithAccounts>() {
+ LiveData<TemplateWithAccounts> dbList = db.getPatternDAO()
+ .getTemplateWithAccounts(mPatternId);
+ Observer<TemplateWithAccounts> observer = new Observer<TemplateWithAccounts>() {
@Override
- public void onChanged(PatternWithAccounts src) {
+ public void onChanged(TemplateWithAccounts src) {
ArrayList<TemplateDetailsItem> l = new ArrayList<>();
TemplateDetailsItem header = TemplateDetailsItem.fromRoomObject(src.header);
TemplateDetailsItem.Header modelHeader = list.get(0)
.asHeaderItem();
- PatternHeaderDAO headerDAO = DB.get()
- .getPatternDAO();
+ TemplateHeaderDAO headerDAO = DB.get()
+ .getPatternDAO();
TemplateHeader dbHeader = modelHeader.toDBO();
if (newPattern) {
dbHeader.setId(null);
modelHeader));
- PatternAccountDAO paDAO = DB.get()
- .getPatternAccountDAO();
+ TemplateAccountDAO paDAO = DB.get()
+ .getPatternAccountDAO();
for (int i = 1; i < list.size(); i++) {
final TemplateDetailsItem.AccountRow accRowItem = list.get(i)
.asAccountRowItem();
TemplateAccount dbAccount = accRowItem.toDBO(dbHeader.getId());
- dbAccount.setPatternId(mPatternId);
+ dbAccount.setTemplateId(mPatternId);
dbAccount.setPosition(i);
if (newPattern) {
dbAccount.setId(null);
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
-import net.ktnx.mobileledger.dao.PatternHeaderDAO;
+import net.ktnx.mobileledger.dao.TemplateHeaderDAO;
import net.ktnx.mobileledger.databinding.FragmentTemplateListBinding;
import net.ktnx.mobileledger.db.DB;
import net.ktnx.mobileledger.db.TemplateHeader;
TemplatesRecyclerViewAdapter modelAdapter = new TemplatesRecyclerViewAdapter();
b.templateList.setAdapter(modelAdapter);
- PatternHeaderDAO pDao = DB.get()
- .getPatternDAO();
- LiveData<List<TemplateHeader>> templates = pDao.getPatterns();
+ TemplateHeaderDAO pDao = DB.get()
+ .getPatternDAO();
+ LiveData<List<TemplateHeader>> templates = pDao.getTemplates();
templates.observe(getViewLifecycleOwner(), modelAdapter::setTemplates);
LinearLayoutManager llm = new LinearLayoutManager(getContext());
llm.setOrientation(RecyclerView.VERTICAL);
public class MobileLedgerDatabase extends SQLiteOpenHelper {
public static final MutableLiveData<Boolean> initComplete = new MutableLiveData<>(false);
public static final String DB_NAME = "MoLe.db";
- private static final int LATEST_REVISION = 53;
+ private static final int LATEST_REVISION = 54;
private static final String CREATE_DB_SQL = "create_db";
private final Application mContext;
<TextView
android:id="@+id/nav_patterns"
style="@style/nav_button"
- android:text="@string/nav_patterns"
+ android:text="@string/nav_templates"
app:drawableStartCompat="@drawable/ic_baseline_auto_graph_24"
/>
android:layout_height="match_parent"
android:gravity="end"
android:paddingTop="@dimen/text_margin"
- android:text="@string/pattern_details_account_row_label"
+ android:text="@string/template_details_account_row_label"
app:drawableBottomCompat="@drawable/dashed_border_8dp"
/>
<TextView
android:id="@+id/template_details_account_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/pattern_details_account_name_label"
+ android:hint="@string/template_details_account_name_label"
android:inputType="text"
/>
</com.google.android.material.textfield.TextInputLayout>
android:id="@+id/template_details_account_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/pattern_details_account_comment_label"
+ android:hint="@string/template_details_account_comment_label"
android:inputType="text"
/>
</com.google.android.material.textfield.TextInputLayout>
android:id="@+id/template_details_account_amount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/pattern_details_account_amount_label"
+ android:hint="@string/template_details_account_amount_label"
android:inputType="number|numberDecimal|numberSigned"
/>
</com.google.android.material.textfield.TextInputLayout>
android:id="@+id/template_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/pattern_name_label"
+ android:hint="@string/template_name_label"
android:inputType="text"
/>
</com.google.android.material.textfield.TextInputLayout>
android:id="@+id/pattern"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/pattern_details_pattern_label"
+ android:hint="@string/template_details_pattern_label"
android:inputType="text"
/>
</com.google.android.material.textfield.TextInputLayout>
android:id="@+id/test_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/pattern_details_test_text_label"
+ android:hint="@string/template_details_test_text_label"
android:inputType="text"
/>
</com.google.android.material.textfield.TextInputLayout>
android:layout_height="wrap_content"
android:gravity="end"
android:paddingTop="@dimen/text_margin"
- android:text="@string/pattern_transaction_parameters_label"
+ android:text="@string/template_transaction_parameters_label"
app:layout_constraintTop_toBottomOf="@id/test_text_layout"
/>
<TextView
android:id="@+id/pattern_transaction_date_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/pattern_details_date_label"
+ android:text="@string/template_details_date_label"
app:layout_constraintTop_toBottomOf="@id/transaction_parameters_label"
/>
<TextView
android:id="@+id/template_details_year_source_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:text="@string/pattern_details_date_year_source_label"
+ android:text="@string/template_details_date_year_source_label"
android:textAlignment="center"
app:layout_constraintEnd_toStartOf="@id/template_details_month_source_label"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/template_details_month_source_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:text="@string/pattern_details_date_month_source_label"
+ android:text="@string/template_details_date_month_source_label"
android:textAlignment="center"
app:layout_constraintEnd_toStartOf="@id/template_details_day_source_label"
app:layout_constraintStart_toEndOf="@id/template_details_year_source_label"
android:id="@+id/template_details_day_source_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:text="@string/pattern_details_date_day_source_label"
+ android:text="@string/template_details_date_day_source_label"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/template_details_month_source_label"
--- /dev/null
+-- Copyright © 2020 Damyan Ivanov.
+-- This file is part of MoLe.
+-- MoLe is free software: you can distribute it and/or modify it
+-- under the term of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your opinion), any later version.
+--
+-- MoLe is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License terms for details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+
+-- this is handled in a Room migration
\ No newline at end of file
<string name="err_json_send_error_tail">Вероятно настроената версия на протокола не се поддържа.</string>
<string name="err_json_send_error_unsupported">Възможно е програмния интерфейс на сървъра да не се поддържа от MoLe</string>
<string name="scan_qr">Сканиране на QR код</string>
- <string name="nav_patterns">Макети</string>
+ <string name="nav_templates">Макети</string>
<string name="title_activity_templates">Макети</string>
<string name="pattern_regex_hint">Шаблон (regex)</string>
<string name="help_menu_item_title">Помощ</string>
<string name="edit_button_description">Бутон за промяна</string>
- <string name="pattern_details_account_comment_label">Бележка към сметката</string>
- <string name="pattern_details_account_amount_label">Сума</string>
+ <string name="template_details_account_comment_label">Бележка към сметката</string>
+ <string name="template_details_account_amount_label">Сума</string>
<string name="choose_template_detail_source_label">Прихващане от шаблона</string>
<string name="missing_pattern_error">Липсва шаблон</string>
<string name="missing_test_text">Липсва примерен текст</string>
<string name="pattern_without_groups">Шаблонът няма прихващания</string>
<string name="pattern_does_not_match">Шаблонът не съвпада с примерния текст</string>
- <string name="pattern_transaction_parameters_label">Данни за движението</string>
+ <string name="template_transaction_parameters_label">Данни за движението</string>
<string name="template_transaction_description_hint">Описание на движението</string>
<string name="template_transaction_comment_hint">Бележка към движението</string>
<string name="transaction_description_source_label">Източник на описанието на движението</string>
<string name="transaction_comment_source_label">Източник на бележката към движението</string>
- <string name="pattern_details_date_label">Дата на движението</string>
+ <string name="template_details_date_label">Дата на движението</string>
<string name="date_year_hint">година</string>
<string name="date_month_hint">месец</string>
<string name="date_day_hint">ден</string>
- <string name="pattern_details_date_year_source_label">година</string>
- <string name="pattern_details_date_day_source_label">ден</string>
- <string name="pattern_details_date_month_source_label">месец</string>
- <string name="unnamed_pattern">Макет без име</string>
+ <string name="template_details_date_year_source_label">година</string>
+ <string name="template_details_date_day_source_label">ден</string>
+ <string name="template_details_date_month_source_label">месец</string>
+ <string name="unnamed_template">Макет без име</string>
<string name="add_button_description">Добавяне на макет</string>
<string name="save_button_description">Запазване на макета</string>
- <string name="no_pattern_matches">Няма съвпадение с нито един макет</string>
- <string name="choose_pattern_to_apply">Избор на макет</string>
- <string name="pattern_name">Име на макет</string>
+ <string name="no_template_matches">Няма съвпадение с нито един макет</string>
+ <string name="choose_template_to_apply">Избор на макет</string>
+ <string name="template_name">Име на макет</string>
<string name="implementation_pending">Функцията още не е готова</string>
<string name="title_edit_template">Промяна на макет</string>
<string name="title_new_template">Създаване на макет</string>
<string name="account_name_is_empty">Липсва сметка</string>
<string name="pattern_is_empty">Липсва шаблон</string>
<string name="invalid_matching_group_number">Невалиден номер на прихващане</string>
- <string name="pattern_name_label">Име на макет</string>
- <string name="pattern_details_pattern_label">Шаблон</string>
- <string name="pattern_details_amount_label">Сума</string>
- <string name="pattern_details_test_text_label">Примерен текст</string>
- <string name="pattern_details_account_name_label">Сметка</string>
- <string name="pattern_details_account_row_label">Данни за сметката</string>
+ <string name="template_name_label">Име на макет</string>
+ <string name="template_details_pattern_label">Шаблон</string>
+ <string name="template_details_amount_label">Сума</string>
+ <string name="template_details_test_text_label">Примерен текст</string>
+ <string name="template_details_account_name_label">Сметка</string>
+ <string name="template_details_account_row_label">Данни за сметката</string>
<string name="account_name_source_label">Източник на името на сметката</string>
<string name="template_details_source_literal">ръчно въвеждане</string>
<string name="account_comment_source_label">Източник на бележка към сметката</string>
<string name="err_json_send_error_tail">A mismatch in the configured API version could be causing this</string>
<string name="err_json_send_error_unsupported">Perhaps the API of the backend server is not supported by MoLe</string>
<string name="scan_qr">Scan QR code</string>
- <string name="nav_patterns">Patterns</string>
- <string name="title_activity_templates">Patterns</string>
+ <string name="nav_templates">Templates</string>
+ <string name="title_activity_templates">Templates</string>
<string name="pattern_regex_hint">Pattern (regular expression)</string>
<string name="help_menu_item_title">Help</string>
<string name="edit_button_description">Edit button</string>
<string name="account_name_is_empty">Account name missing</string>
<string name="pattern_is_empty">Pattern missing</string>
<string name="invalid_matching_group_number">Invalid matching group number</string>
- <string name="pattern_name_label">Pattern name</string>
- <string name="pattern_details_pattern_label">Pattern</string>
- <string name="pattern_details_amount_label">Amount</string>
- <string name="pattern_details_test_text_label">Test text</string>
- <string name="pattern_details_account_name_label">Account name</string>
- <string name="pattern_details_account_row_label">Transaction account details</string>
+ <string name="template_name_label">Template name</string>
+ <string name="template_details_pattern_label">Pattern</string>
+ <string name="template_details_amount_label">Amount</string>
+ <string name="template_details_test_text_label">Test text</string>
+ <string name="template_details_account_name_label">Account name</string>
+ <string name="template_details_account_row_label">Transaction account details</string>
<string name="account_name_source_label">Account name source</string>
<string name="template_details_source_literal">literal</string>
<string name="account_comment_source_label">Account comment source</string>
<string name="account_amount_source_label">Amount source</string>
- <string name="pattern_details_account_comment_label">Account comment</string>
- <string name="pattern_details_account_amount_label">Amount</string>
+ <string name="template_details_account_comment_label">Account comment</string>
+ <string name="template_details_account_amount_label">Amount</string>
<string name="choose_template_detail_source_label">Pattern match group</string>
<string name="missing_pattern_error">Missing pattern</string>
<string name="missing_test_text">Missing test text</string>
<string name="pattern_without_groups">Pattern has no capturing groups</string>
<string name="pattern_does_not_match">Pattern doesn\'t match the test text</string>
- <string name="pattern_transaction_parameters_label">Transaction parameters</string>
+ <string name="template_transaction_parameters_label">Transaction parameters</string>
<string name="template_transaction_description_hint">Transaction description</string>
<string name="template_transaction_comment_hint">Transaction comment</string>
<string name="transaction_description_source_label">Transaction description source</string>
<string name="transaction_comment_source_label">Transaction comment source</string>
- <string name="pattern_details_date_label">Transaction date</string>
+ <string name="template_details_date_label">Transaction date</string>
<string name="date_year_hint">year</string>
<string name="date_month_hint">month</string>
<string name="date_day_hint">date</string>
- <string name="pattern_details_date_year_source_label">year</string>
- <string name="pattern_details_date_day_source_label">date</string>
- <string name="pattern_details_date_month_source_label">month</string>
- <string name="unnamed_pattern">Pattern with no name</string>
- <string name="add_button_description">Add pattern</string>
- <string name="save_button_description">Save pattern</string>
- <string name="no_pattern_matches">No pattern matches</string>
- <string name="choose_pattern_to_apply">Choose pattern to apply</string>
- <string name="pattern_name">Pattern name</string>
+ <string name="template_details_date_year_source_label">year</string>
+ <string name="template_details_date_day_source_label">date</string>
+ <string name="template_details_date_month_source_label">month</string>
+ <string name="unnamed_template">Template with no name</string>
+ <string name="add_button_description">Add template</string>
+ <string name="save_button_description">Save template</string>
+ <string name="no_template_matches">No template matches</string>
+ <string name="choose_template_to_apply">Choose template to apply</string>
+ <string name="template_name">Template name</string>
<string name="implementation_pending">Not implemented yet</string>
- <string name="title_edit_template">Edit pattern</string>
- <string name="title_new_template">New pattern</string>
+ <string name="title_edit_template">Edit template</string>
+ <string name="title_new_template">New template</string>
</resources>