diff options
author | desperateCoder <echotodevnull@gmail.com> | 2020-12-11 11:25:06 +0300 |
---|---|---|
committer | desperateCoder <echotodevnull@gmail.com> | 2020-12-11 11:25:06 +0300 |
commit | 5b04770b6d0b7aac72c96f94da278d290bd68b64 (patch) | |
tree | 09e2e43ac8f3718e2c90474912ec9c450edbede3 /app | |
parent | 420d65466414afb0b0df55bca4be92beb5d30301 (diff) |
#597 filter widget: delete and update filter
Diffstat (limited to 'app')
4 files changed, 21 insertions, 5 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java index 0238c848c..36c9bffb1 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java @@ -1062,6 +1062,13 @@ public class DataBaseAdapter { public Long createFilterWidget(FilterWidget filterWidget) { long widgetId = db.getFilterWidgetDao().insert(filterWidget); + filterWidget.setId(widgetId); + insertFilterWidgetDecendants(filterWidget); + return widgetId; + } + + private void insertFilterWidgetDecendants(FilterWidget filterWidget) { + long widgetId = filterWidget.getId(); for (FilterWidgetAccount account : filterWidget.getAccounts()) { account.setFilterWidgetId(widgetId); long accountId = db.getFilterWidgetAccountDao().insert(account); @@ -1086,17 +1093,17 @@ public class DataBaseAdapter { sort.setFilterWidgetId(widgetId); db.getFilterWidgetSortDao().insert(sort); } - return widgetId; } public void deleteFilterWidget(Long filterWidgetId) { - // TODO - throw new UnsupportedOperationException("Not yet implemented"); + db.getFilterWidgetDao().delete(filterWidgetId); } public void updateFilterWidget(FilterWidget filterWidget) { - // TODO - throw new UnsupportedOperationException("Not yet implemented"); + db.getFilterWidgetSortDao().deleteByFilterWidgetId(filterWidget.getId()); + db.getFilterWidgetAccountDao().deleteByFilterWidgetId(filterWidget.getId()); + db.getFilterWidgetDao().update(filterWidget); + insertFilterWidgetDecendants(filterWidget); } public List<FilterWidgetCard> getCardsForFilterWidget(Long filterWidgetId) { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetAccountDao.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetAccountDao.java index acddf9a19..772bef866 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetAccountDao.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetAccountDao.java @@ -1,10 +1,13 @@ package it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.widgets.filter; import androidx.room.Dao; +import androidx.room.Query; import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetAccount; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.GenericDao; @Dao public interface FilterWidgetAccountDao extends GenericDao<FilterWidgetAccount> { + @Query("DELETE FROM FilterWidgetAccount WHERE filterWidgetId = :filterWidgetId") + void deleteByFilterWidgetId (Long filterWidgetId); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetDao.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetDao.java index 97d1f6236..9ade30145 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetDao.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetDao.java @@ -1,10 +1,13 @@ package it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.widgets.filter; import androidx.room.Dao; +import androidx.room.Query; import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidget; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.GenericDao; @Dao public interface FilterWidgetDao extends GenericDao<FilterWidget> { + @Query("DELETE FROM filterwidget WHERE id = :filterWidgetId") + void delete (Long filterWidgetId); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetSortDao.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetSortDao.java index 0136dc956..fb9d4ca9c 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetSortDao.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/widgets/filter/FilterWidgetSortDao.java @@ -1,10 +1,13 @@ package it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.widgets.filter; import androidx.room.Dao; +import androidx.room.Query; import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetSort; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.GenericDao; @Dao public interface FilterWidgetSortDao extends GenericDao<FilterWidgetSort> { + @Query("DELETE FROM FilterWidgetSort WHERE filterWidgetId = :filterWidgetId") + void deleteByFilterWidgetId (Long filterWidgetId); } |