diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-10-29 11:57:42 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-10-29 11:57:42 +0300 |
commit | 11f07f5b7e5ac4088cf98c866ebaf3806d5bccbc (patch) | |
tree | 37904d3037c083d6bbc35841019bbf0ef22a22cd /app/src/main/java/it/niedermann/nextcloud/deck/persistence | |
parent | 5efa3495cfb59c2637da6d47bf1f754d71f80482 (diff) |
#715 Use java.time.*
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/persistence')
14 files changed, 84 insertions, 80 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java index ab0debcba..e62b9b64b 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java @@ -212,7 +212,7 @@ public class SyncManager { if (response != null && !response.isMaintenanceEnabled()) { if (response.getDeckVersion().isSupported(appContext)) { long accountId = callbackAccountId; - Date lastSyncDate = LastSyncUtil.getLastSyncDate(callbackAccountId); + Instant lastSyncDate = LastSyncUtil.getLastSyncDate(callbackAccountId); Date now = DateUtil.nowInGMT(); final SyncHelper syncHelper = new SyncHelper(serverAdapter, dataBaseAdapter, lastSyncDate); @@ -1734,7 +1734,7 @@ public class SyncManager { Stack stack = dataBaseAdapter.getStackByLocalIdDirectly(movedCard.getCard().getStackId()); FullBoard board = dataBaseAdapter.getFullBoardByLocalIdDirectly(accountId, stack.getBoardId()); Account account = dataBaseAdapter.getAccountByIdDirectly(movedCard.getCard().getAccountId()); - new SyncHelper(serverAdapter, dataBaseAdapter, new Date()).setResponseCallback(new IResponseCallback<Boolean>(account) { + new SyncHelper(serverAdapter, dataBaseAdapter, Instant.now()).setResponseCallback(new IResponseCallback<Boolean>(account) { @Override public void onResponse(Boolean response) { // doNothing(); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/SyncHelper.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/SyncHelper.java index 6f7c0d9c0..2af9792c2 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/SyncHelper.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/SyncHelper.java @@ -1,6 +1,6 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers; -import java.util.Date; +import java.time.Instant; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -20,16 +20,16 @@ public class SyncHelper { private Account account; private long accountId; private IResponseCallback<Boolean> responseCallback; - private Date lastSync; + private Instant lastSync; - public SyncHelper(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, Date lastSync) { + public SyncHelper(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, Instant lastSync) { this.serverAdapter = serverAdapter; this.dataBaseAdapter = dataBaseAdapter; this.lastSync = lastSync; } // Sync Server -> App - public <T extends IRemoteEntity> void doSyncFor(final AbstractSyncDataProvider<T> provider){ + public <T extends IRemoteEntity> void doSyncFor(final AbstractSyncDataProvider<T> provider) { provider.registerChildInParent(provider); provider.getAllFromServer(serverAdapter, dataBaseAdapter, accountId, new IResponseCallback<List<T>>(account) { @Override @@ -49,8 +49,8 @@ public class SyncHelper { provider.createInDB(dataBaseAdapter, accountId, entityFromServer); } else { //TODO: how to handle deletes? what about archived? - if (existingEntity.getStatus() != DBStatus.UP_TO_DATE.getId()){ - DeckLog.log("Conflicting changes on entity: "+existingEntity); + if (existingEntity.getStatus() != DBStatus.UP_TO_DATE.getId()) { + DeckLog.log("Conflicting changes on entity: " + existingEntity); // TODO: what to do? } else { // if (existingEntity.getLastModified().getTime() == entityFromServer.getLastModified().getTime()) { @@ -63,7 +63,7 @@ public class SyncHelper { provider.goDeeper(SyncHelper.this, existingEntity, entityFromServer, responseCallback); } - provider.handleDeletes(serverAdapter, dataBaseAdapter, accountId, response); + provider.handleDeletes(serverAdapter, dataBaseAdapter, accountId, response); provider.doneGoingDeeper(responseCallback, true); } else { @@ -81,17 +81,18 @@ public class SyncHelper { } // Sync App -> Server - public <T extends IRemoteEntity> void doUpSyncFor(AbstractSyncDataProvider<T> provider){ + public <T extends IRemoteEntity> void doUpSyncFor(AbstractSyncDataProvider<T> provider) { doUpSyncFor(provider, null); } - public <T extends IRemoteEntity> void doUpSyncFor(AbstractSyncDataProvider<T> provider, CountDownLatch countDownLatch){ + + public <T extends IRemoteEntity> void doUpSyncFor(AbstractSyncDataProvider<T> provider, CountDownLatch countDownLatch) { List<T> allFromDB = provider.getAllChangedFromDB(dataBaseAdapter, accountId, lastSync); if (allFromDB != null && !allFromDB.isEmpty()) { for (T entity : allFromDB) { - if (entity.getId()!=null) { + if (entity.getId() != null) { if (entity.getStatusEnum() == DBStatus.LOCAL_DELETED) { provider.deleteOnServer(serverAdapter, accountId, getDeleteCallback(provider, entity), entity, dataBaseAdapter); - if (countDownLatch != null){ + if (countDownLatch != null) { countDownLatch.countDown(); } } else { @@ -103,7 +104,7 @@ public class SyncHelper { } } else { provider.goDeeperForUpSync(this, serverAdapter, dataBaseAdapter, responseCallback); - if (countDownLatch != null){ + if (countDownLatch != null) { countDownLatch.countDown(); } } @@ -135,7 +136,7 @@ public class SyncHelper { update.setStatus(DBStatus.UP_TO_DATE.getId()); provider.updateInDB(dataBaseAdapter, accountId, update, false); provider.goDeeperForUpSync(SyncHelper.this, serverAdapter, dataBaseAdapter, responseCallback); - if (countDownLatch != null){ + if (countDownLatch != null) { countDownLatch.countDown(); } } @@ -144,7 +145,7 @@ public class SyncHelper { public void onError(Throwable throwable) { super.onError(throwable); responseCallback.onError(throwable); - if (countDownLatch != null){ + if (countDownLatch != null) { countDownLatch.countDown(); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AbstractSyncDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AbstractSyncDataProvider.java index 42b034026..11fb38a66 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AbstractSyncDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AbstractSyncDataProvider.java @@ -1,7 +1,7 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; +import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import java.util.List; import it.niedermann.nextcloud.deck.DeckLog; @@ -27,17 +27,18 @@ public abstract class AbstractSyncDataProvider<T extends IRemoteEntity> { } } - public void handleDeletes(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, List<T> entitiesFromServer){ + public void handleDeletes(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, List<T> entitiesFromServer) { // do nothing as a default. } /** * Searches each entry of <code>listB</code> in list <code>listA</code> and returns the missing ones + * * @param listA List * @param listB List * @return all entries of <code>listB</code> missing in <code>listA</code> */ - public static <T extends IRemoteEntity> List<T> findDelta(List<T> listA, List<T> listB){ + public static <T extends IRemoteEntity> List<T> findDelta(List<T> listA, List<T> listB) { List<T> delta = new ArrayList<>(); for (T b : listB) { if (b == null) { @@ -56,7 +57,7 @@ public abstract class AbstractSyncDataProvider<T extends IRemoteEntity> { break; } } - if (!found){ + if (!found) { delta.add(b); } } @@ -67,10 +68,11 @@ public abstract class AbstractSyncDataProvider<T extends IRemoteEntity> { children.add(child); } - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<T>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<T>> responder, Instant lastSync) { return; } - public void getAllFromServer(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, IResponseCallback<List<T>> responder, Date lastSync) { + + public void getAllFromServer(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, IResponseCallback<List<T>> responder, Instant lastSync) { // Overridden, because we also need the DB-Adapter at some points here (see ACL data provider) getAllFromServer(serverAdapter, accountId, responder, lastSync); } @@ -87,7 +89,7 @@ public abstract class AbstractSyncDataProvider<T extends IRemoteEntity> { public abstract void deleteInDB(DataBaseAdapter dataBaseAdapter, long accountId, T t); - public void deletePhysicallyInDB(DataBaseAdapter dataBaseAdapter, long accountId, T t){ + public void deletePhysicallyInDB(DataBaseAdapter dataBaseAdapter, long accountId, T t) { deleteInDB(dataBaseAdapter, accountId, t); } @@ -121,7 +123,7 @@ public abstract class AbstractSyncDataProvider<T extends IRemoteEntity> { stillGoingDeeper = true; } - public abstract List<T> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync); + public abstract List<T> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync); public void goDeeperForUpSync(SyncHelper syncHelper, ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, IResponseCallback<Boolean> callback) { //do nothing diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AccessControlDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AccessControlDataProvider.java index aab3aeb09..6dde6b45c 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AccessControlDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AccessControlDataProvider.java @@ -1,6 +1,6 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; -import java.util.Date; +import java.time.Instant; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -29,7 +29,7 @@ public class AccessControlDataProvider extends AbstractSyncDataProvider<AccessCo } @Override - public void getAllFromServer(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, IResponseCallback<List<AccessControl>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, IResponseCallback<List<AccessControl>> responder, Instant lastSync) { AsyncUtil.awaitAsyncWork(acl.size(), latch -> { for (AccessControl accessControl : acl) { if (accessControl.getType() == TYPE_GROUP) { @@ -177,7 +177,7 @@ public class AccessControlDataProvider extends AbstractSyncDataProvider<AccessCo } @Override - public List<AccessControl> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<AccessControl> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return dataBaseAdapter.getLocallyChangedAccessControl(accountId, board.getLocalId()); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/ActivityDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/ActivityDataProvider.java index a3785ca78..dc5eb40c2 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/ActivityDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/ActivityDataProvider.java @@ -1,7 +1,7 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; +import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import java.util.List; import it.niedermann.nextcloud.deck.api.IResponseCallback; @@ -20,7 +20,7 @@ public class ActivityDataProvider extends AbstractSyncDataProvider<Activity> { } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<Activity>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<Activity>> responder, Instant lastSync) { serverAdapter.getActivitiesForCard(card.getId(), responder); } @@ -65,7 +65,7 @@ public class ActivityDataProvider extends AbstractSyncDataProvider<Activity> { } @Override - public List<Activity> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<Activity> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return new ArrayList<>(); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AttachmentDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AttachmentDataProvider.java index 43fe55c4a..781f7b1f4 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AttachmentDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/AttachmentDataProvider.java @@ -4,7 +4,7 @@ import android.net.Uri; import java.io.File; import java.io.IOException; -import java.util.Date; +import java.time.Instant; import java.util.List; import it.niedermann.nextcloud.deck.DeckLog; @@ -32,7 +32,7 @@ public class AttachmentDataProvider extends AbstractSyncDataProvider<Attachment> } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<Attachment>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<Attachment>> responder, Instant lastSync) { responder.onResponse(attachments); } @@ -104,7 +104,7 @@ public class AttachmentDataProvider extends AbstractSyncDataProvider<Attachment> } @Override - public List<Attachment> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<Attachment> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return dataBaseAdapter.getLocallyChangedAttachmentsByLocalCardIdDirectly(accountId, card.getLocalId()); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/BoardDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/BoardDataProvider.java index 45ea6cff6..5b458471f 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/BoardDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/BoardDataProvider.java @@ -1,8 +1,8 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -21,12 +21,12 @@ import it.niedermann.nextcloud.deck.persistence.sync.helpers.util.AsyncUtil; public class BoardDataProvider extends AbstractSyncDataProvider<FullBoard> { - public BoardDataProvider(){ + public BoardDataProvider() { super(null); } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<FullBoard>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<FullBoard>> responder, Instant lastSync) { serverAdapter.getBoards(responder); } @@ -45,15 +45,15 @@ public class BoardDataProvider extends AbstractSyncDataProvider<FullBoard> { } private void handleOwner(DataBaseAdapter dataBaseAdapter, long accountId, FullBoard entity) { - if (entity.getOwner()!=null) { - User owner = createOrUpdateUser(dataBaseAdapter,accountId, entity.getOwner()); + if (entity.getOwner() != null) { + User owner = createOrUpdateUser(dataBaseAdapter, accountId, entity.getOwner()); entity.getBoard().setOwnerId(owner.getLocalId()); } } private void handleUsers(DataBaseAdapter dataBaseAdapter, long accountId, FullBoard entity) { dataBaseAdapter.deleteBoardMembershipsOfBoard(entity.getLocalId()); - if (entity.getUsers()!=null && !entity.getUsers().isEmpty()) { + if (entity.getUsers() != null && !entity.getUsers().isEmpty()) { for (User user : entity.getUsers()) { if (user == null) { continue; @@ -66,7 +66,7 @@ public class BoardDataProvider extends AbstractSyncDataProvider<FullBoard> { private User createOrUpdateUser(DataBaseAdapter dataBaseAdapter, long accountId, User remoteUser) { User owner = dataBaseAdapter.getUserByUidDirectly(accountId, remoteUser.getUid()); - if (owner == null){ + if (owner == null) { dataBaseAdapter.createUser(accountId, remoteUser); } else { dataBaseAdapter.updateUser(accountId, remoteUser, false); @@ -86,7 +86,7 @@ public class BoardDataProvider extends AbstractSyncDataProvider<FullBoard> { // ## merge labels (created at board creation): // the server creates four default labels. if a board is copied, they will also be copied. At sync, after creating the board, the labels are already there. // this merges the created default ones with the ones i already have. - if (entity!= null && entity.getLabels() != null) { + if (entity != null && entity.getLabels() != null) { for (Label label : entity.getLabels()) { // does this label exist and unknown to server yet? Label existing = dataBaseAdapter.getLabelByBoardIdAndTitleDirectly(entity.getLocalId(), label.getTitle()); @@ -108,19 +108,19 @@ public class BoardDataProvider extends AbstractSyncDataProvider<FullBoard> { @Override public void goDeeper(SyncHelper syncHelper, FullBoard existingEntity, FullBoard entityFromServer, IResponseCallback<Boolean> callback) { List<Label> labels = entityFromServer.getLabels(); - if (labels != null && !labels.isEmpty()){ + if (labels != null && !labels.isEmpty()) { syncHelper.doSyncFor(new LabelDataProvider(this, existingEntity.getBoard(), labels)); } List<AccessControl> acl = entityFromServer.getParticipants(); - if (acl != null && !acl.isEmpty()){ - for (AccessControl ac : acl){ + if (acl != null && !acl.isEmpty()) { + for (AccessControl ac : acl) { ac.setBoardId(existingEntity.getLocalId()); } syncHelper.doSyncFor(new AccessControlDataProvider(this, existingEntity, acl)); } - if (entityFromServer.getStacks() != null && !entityFromServer.getStacks().isEmpty()){ + if (entityFromServer.getStacks() != null && !entityFromServer.getStacks().isEmpty()) { syncHelper.doSyncFor(new StackDataProvider(this, existingEntity)); } } @@ -131,7 +131,7 @@ public class BoardDataProvider extends AbstractSyncDataProvider<FullBoard> { } @Override - public List<FullBoard> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<FullBoard> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return dataBaseAdapter.getLocallyChangedBoards(accountId); } @@ -149,7 +149,7 @@ public class BoardDataProvider extends AbstractSyncDataProvider<FullBoard> { List<Long> localBoardIDsWithChangedACL = dataBaseAdapter.getBoardIDsOfLocallyChangedAccessControl(accountId); for (Long boardId : localBoardIDsWithChangedACL) { - syncHelper.doUpSyncFor(new AccessControlDataProvider(this, dataBaseAdapter.getFullBoardByLocalIdDirectly(accountId, boardId) ,new ArrayList<>())); + syncHelper.doUpSyncFor(new AccessControlDataProvider(this, dataBaseAdapter.getFullBoardByLocalIdDirectly(accountId, boardId), new ArrayList<>())); } Set<Long> syncedBoards = new HashSet<>(); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardDataProvider.java index 376948d54..15b8b2b74 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/CardDataProvider.java @@ -1,8 +1,8 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.List; import it.niedermann.nextcloud.deck.DeckLog; @@ -37,7 +37,7 @@ public class CardDataProvider extends AbstractSyncDataProvider<FullCard> { } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<FullCard>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<FullCard>> responder, Instant lastSync) { List<FullCard> result = new ArrayList<>(); if (stack.getCards() == null || stack.getCards().isEmpty()) { @@ -151,7 +151,7 @@ public class CardDataProvider extends AbstractSyncDataProvider<FullCard> { public void createOnServer(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, IResponseCallback<FullCard> responder, FullCard entity) { entity.getCard().setStackId(stack.getId()); // if (board != null && stack != null && board.getId() != null && stack.getId() != null) { - serverAdapter.createCard(board.getId(), stack.getId(), entity.getCard(), responder); + serverAdapter.createCard(board.getId(), stack.getId(), entity.getCard(), responder); // } else DeckLog.error("Skipped card creation due to missing remote ID"); } @@ -173,7 +173,7 @@ public class CardDataProvider extends AbstractSyncDataProvider<FullCard> { } @Override - public List<FullCard> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<FullCard> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { if (board == null || stack == null) { // no cards changed! // (see call from StackDataProvider: goDeeperForUpSync called with null for board.) diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/DeckCommentsDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/DeckCommentsDataProvider.java index a26a790a1..06ef3030d 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/DeckCommentsDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/DeckCommentsDataProvider.java @@ -1,8 +1,8 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.List; import it.niedermann.nextcloud.deck.DeckLog; @@ -24,7 +24,7 @@ public class DeckCommentsDataProvider extends AbstractSyncDataProvider<OcsCommen } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<OcsComment>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<OcsComment>> responder, Instant lastSync) { serverAdapter.getCommentsForRemoteCardId(card.getId(), new IResponseCallback<OcsComment>(responder.getAccount()) { @Override public void onResponse(OcsComment response) { @@ -134,7 +134,7 @@ public class DeckCommentsDataProvider extends AbstractSyncDataProvider<OcsCommen } @Override - public List<OcsComment> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<OcsComment> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return new OcsComment(dataBaseAdapter.getLocallyChangedCommentsByLocalCardIdDirectly(accountId, card.getLocalId())).split(); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/LabelDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/LabelDataProvider.java index 90d633bce..8cd2f9eea 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/LabelDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/LabelDataProvider.java @@ -1,6 +1,6 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; -import java.util.Date; +import java.time.Instant; import java.util.List; import it.niedermann.nextcloud.deck.DeckLog; @@ -20,7 +20,7 @@ public class LabelDataProvider extends AbstractSyncDataProvider<Label> { super(parent); this.board = board; this.labels = labels; - if (this.labels!= null && board != null){ + if (this.labels != null && board != null) { for (Label label : labels) { label.setBoardId(board.getLocalId()); } @@ -28,7 +28,7 @@ public class LabelDataProvider extends AbstractSyncDataProvider<Label> { } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<Label>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<Label>> responder, Instant lastSync) { responder.onResponse(labels); } @@ -54,7 +54,7 @@ public class LabelDataProvider extends AbstractSyncDataProvider<Label> { dataBaseAdapter.updateLabel(entity, setStatus); } - private IResponseCallback<Label> getLabelUniqueHandler(DataBaseAdapter dataBaseAdapter, Label entitiy, IResponseCallback<Label> responder){ + private IResponseCallback<Label> getLabelUniqueHandler(DataBaseAdapter dataBaseAdapter, Label entitiy, IResponseCallback<Label> responder) { return new IResponseCallback<Label>(responder.getAccount()) { @Override public void onResponse(Label response) { @@ -63,7 +63,7 @@ public class LabelDataProvider extends AbstractSyncDataProvider<Label> { @Override public void onError(Throwable throwable) { - if (HandledServerErrors.LABELS_TITLE_MUST_BE_UNIQUE == HandledServerErrors.fromThrowable(throwable)){ + if (HandledServerErrors.LABELS_TITLE_MUST_BE_UNIQUE == HandledServerErrors.fromThrowable(throwable)) { DeckLog.log(throwable.getCause().getMessage() + ": " + entitiy.toString()); dataBaseAdapter.deleteLabelPhysically(entitiy); responder.onResponse(entitiy); @@ -96,7 +96,7 @@ public class LabelDataProvider extends AbstractSyncDataProvider<Label> { } @Override - public List<Label> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<Label> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return labels; } @@ -109,7 +109,7 @@ public class LabelDataProvider extends AbstractSyncDataProvider<Label> { public void handleDeletes(ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, long accountId, List<Label> entitiesFromServer) { List<Label> deletedLabels = findDelta(labels, dataBaseAdapter.getFullBoardByLocalIdDirectly(accountId, board.getLocalId()).getLabels()); for (Label deletedLabel : deletedLabels) { - if (deletedLabel.getId()!=null){ + if (deletedLabel.getId() != null) { // preserve new, unsynced card. dataBaseAdapter.deleteLabelPhysically(deletedLabel); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/OcsProjectDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/OcsProjectDataProvider.java index a32fcb89d..b9bfb8b31 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/OcsProjectDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/OcsProjectDataProvider.java @@ -1,7 +1,7 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; +import java.time.Instant; import java.util.Collections; -import java.util.Date; import java.util.List; import it.niedermann.nextcloud.deck.DeckLog; @@ -15,13 +15,14 @@ import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.DataBaseAdapter public class OcsProjectDataProvider extends AbstractSyncDataProvider<OcsProject> { private Card card; + public OcsProjectDataProvider(AbstractSyncDataProvider<?> parent, Card card) { super(parent); this.card = card; } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<OcsProject>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<OcsProject>> responder, Instant lastSync) { serverAdapter.getProjectsForCard(card.getId(), new IResponseCallback<OcsProjectList>(responder.getAccount()) { @Override public void onResponse(OcsProjectList response) { @@ -70,7 +71,7 @@ public class OcsProjectDataProvider extends AbstractSyncDataProvider<OcsProject> for (OcsProjectResource resource : entity.getResources()) { resource.setProjectId(entity.getLocalId()); resource.setLocalId(dataBaseAdapter.createProjectResourceDirectly(accountId, resource)); - if ("deck-card".equals(resource.getType())){ + if ("deck-card".equals(resource.getType())) { dataBaseAdapter.assignCardToProjectIfMissng(accountId, entity.getLocalId(), resource.getId()); } } @@ -93,7 +94,7 @@ public class OcsProjectDataProvider extends AbstractSyncDataProvider<OcsProject> } @Override - public List<OcsProject> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<OcsProject> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return Collections.emptyList(); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/StackDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/StackDataProvider.java index ba305dc0a..6a8e1f227 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/StackDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/StackDataProvider.java @@ -1,7 +1,7 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; +import java.time.Instant; import java.util.Collections; -import java.util.Date; import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentSkipListSet; @@ -27,7 +27,7 @@ public class StackDataProvider extends AbstractSyncDataProvider<FullStack> { } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<FullStack>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<FullStack>> responder, Instant lastSync) { serverAdapter.getStacks(board.getId(), responder); } @@ -56,12 +56,12 @@ public class StackDataProvider extends AbstractSyncDataProvider<FullStack> { @Override public void goDeeper(SyncHelper syncHelper, FullStack existingEntity, FullStack entityFromServer, IResponseCallback<Boolean> callback) { - boolean serverHasCards = entityFromServer.getCards() != null && !entityFromServer.getCards().isEmpty(); - boolean weHaveCards = existingEntity.getCards() != null && !existingEntity.getCards().isEmpty(); - if (serverHasCards || weHaveCards){ + boolean serverHasCards = entityFromServer.getCards() != null && !entityFromServer.getCards().isEmpty(); + boolean weHaveCards = existingEntity.getCards() != null && !existingEntity.getCards().isEmpty(); + if (serverHasCards || weHaveCards) { existingEntity.setCards(entityFromServer.getCards()); List<Card> cards = existingEntity.getCards(); - if (cards != null ){ + if (cards != null) { for (Card card : cards) { card.setStackId(existingEntity.getLocalId()); } @@ -91,8 +91,8 @@ public class StackDataProvider extends AbstractSyncDataProvider<FullStack> { } @Override - public List<FullStack> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { - if (board == null){ + public List<FullStack> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { + if (board == null) { // no stacks changed! // (see call from BoardDataProvider: goDeeperForUpSync called with null for board.) // so we can just skip this one and proceed with cards. @@ -105,7 +105,7 @@ public class StackDataProvider extends AbstractSyncDataProvider<FullStack> { @Override public void goDeeperForUpSync(SyncHelper syncHelper, ServerAdapter serverAdapter, DataBaseAdapter dataBaseAdapter, IResponseCallback<Boolean> callback) { List<FullCard> changedCards = dataBaseAdapter.getLocallyChangedCardsDirectly(callback.getAccount().getId()); - if (changedCards != null && !changedCards.isEmpty()){ + if (changedCards != null && !changedCards.isEmpty()) { for (FullCard changedCard : changedCards) { long stackId = changedCard.getCard().getStackId(); boolean alreadySynced = syncedStacks.contains(stackId); @@ -137,7 +137,7 @@ public class StackDataProvider extends AbstractSyncDataProvider<FullStack> { List<FullStack> localStacks = dataBaseAdapter.getFullStacksForBoardDirectly(accountId, board.getLocalId()); List<FullStack> delta = findDelta(entitiesFromServer, localStacks); for (FullStack stackToDelete : delta) { - if (stackToDelete.getId() == null){ + if (stackToDelete.getId() == null) { // not pushed up yet so: continue; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/UserDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/UserDataProvider.java index 60c906bda..279ce9e55 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/UserDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/UserDataProvider.java @@ -1,6 +1,6 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers; -import java.util.Date; +import java.time.Instant; import java.util.List; import it.niedermann.nextcloud.deck.api.IResponseCallback; @@ -27,7 +27,7 @@ public class UserDataProvider extends AbstractSyncDataProvider<User> { } @Override - public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<User>> responder, Date lastSync) { + public void getAllFromServer(ServerAdapter serverAdapter, long accountId, IResponseCallback<List<User>> responder, Instant lastSync) { responder.onResponse(users); } @@ -67,7 +67,7 @@ public class UserDataProvider extends AbstractSyncDataProvider<User> { } @Override - public List<User> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<User> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return null; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/partial/BoardWithStacksAndLabelsUpSyncDataProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/partial/BoardWithStacksAndLabelsUpSyncDataProvider.java index 278971a9d..5f2c79ad3 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/partial/BoardWithStacksAndLabelsUpSyncDataProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/helpers/providers/partial/BoardWithStacksAndLabelsUpSyncDataProvider.java @@ -1,7 +1,7 @@ package it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.partial; +import java.time.Instant; import java.util.Collections; -import java.util.Date; import java.util.List; import it.niedermann.nextcloud.deck.api.IResponseCallback; @@ -20,7 +20,7 @@ public class BoardWithStacksAndLabelsUpSyncDataProvider extends BoardDataProvide } @Override - public List<FullBoard> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync) { + public List<FullBoard> getAllChangedFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Instant lastSync) { return Collections.singletonList(board); } |