List of usage examples for com.fasterxml.jackson.databind.util ISO8601Utils format
public static String format(Date date, boolean millis, TimeZone tz)
From source file:org.noorganization.instalistsynch.controller.synch.impl.RecipeSynch.java
@Override public void synchLocalToNetwork(int _groupId, Date _lastUpdate) { String lastUpdateString = ISO8601Utils.format(_lastUpdate, false, TimeZone.getTimeZone("GMT+0000")); String authToken = mSessionController.getToken(_groupId); if (authToken == null) { // todo do some caching of this action return;/*from w ww . j av a 2 s . co m*/ } List<ModelMapping> modelMappingList = mRecipeMappingController .get(ModelMapping.COLUMN.LAST_CLIENT_CHANGE + " >= ? ", new String[] { lastUpdateString }); for (ModelMapping modelMapping : modelMappingList) { if (modelMapping.isDeleted()) { // delete the item mRecipeInfoNetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); } else if (modelMapping.getServerSideUUID() == null) { // insert new RecipeInfo recipeInfo = new RecipeInfo(); Recipe recipe = mRecipeController.findById(modelMapping.getClientSideUUID()); if (recipe == null) { continue; } String uuid = mRecipeMappingController.generateUuid(); recipeInfo.setUUID(uuid); recipeInfo.setName(recipe.mName); Date lastChanged = new Date( modelMapping.getLastClientChange().getTime() - Constants.NETWORK_OFFSET); recipeInfo.setLastChanged(lastChanged); recipeInfo.setDeleted(false); mRecipeInfoNetworkController.createItem(new InsertResponse(modelMapping, uuid), _groupId, recipeInfo, authToken); } else { // update existing RecipeInfo recipeInfo = new RecipeInfo(); Recipe recipe = mRecipeController.findById(modelMapping.getClientSideUUID()); if (recipe == null) { // probably the item was deleted mRecipeInfoNetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); continue; } recipeInfo.setUUID(modelMapping.getServerSideUUID()); recipeInfo.setName(recipe.mName); Date lastChanged = new Date( modelMapping.getLastClientChange().getTime() - Constants.NETWORK_OFFSET); recipeInfo.setLastChanged(lastChanged); recipeInfo.setDeleted(false); mRecipeInfoNetworkController.updateItem( new UpdateResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, recipeInfo.getUUID(), recipeInfo, authToken); } } }
From source file:org.noorganization.instalistsynch.controller.synch.impl.ProductSynch.java
@Override public void synchLocalToNetwork(int _groupId, Date _lastUpdate) { String lastUpdateString = ISO8601Utils.format(_lastUpdate, false, TimeZone.getTimeZone("GMT+0000")); String authToken = mSessionController.getToken(_groupId); if (authToken == null) { // todo do some caching of this action return;/*from w w w . j a v a2 s. com*/ } List<ModelMapping> modelMappingList = mProductModelMapping .get(ModelMapping.COLUMN.LAST_CLIENT_CHANGE + " >= ? ", new String[] { lastUpdateString }); for (ModelMapping modelMapping : modelMappingList) { if (modelMapping.isDeleted()) { // delete the item mProductetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); } else if (modelMapping.getServerSideUUID() == null) { // insert new Product product = mProductController.findById(modelMapping.getClientSideUUID()); if (product == null) { continue; } ProductInfo productInfo = getProductInfo(product, _groupId, modelMapping); mProductetworkController.createItem(new InsertResponse(modelMapping, productInfo.getUUID()), _groupId, productInfo, authToken); } else { // update existing Product product = mProductController.findById(modelMapping.getClientSideUUID()); if (product == null) { // probably the item was deleted mProductetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); continue; } ProductInfo productInfo = getProductInfo(product, _groupId, modelMapping); mProductetworkController.updateItem( new UpdateResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, productInfo.getUUID(), productInfo, authToken); } } }
From source file:org.noorganization.instalistsynch.controller.synch.impl.TagSynch.java
@Override public void synchLocalToNetwork(int _groupId, Date _lastUpdate) { String lastUpdateString = ISO8601Utils.format(_lastUpdate, false, TimeZone.getTimeZone("GMT+0000")); String authToken = mSessionController.getToken(_groupId); if (authToken == null) { // todo do some caching of this action return;/*from w w w. jav a2s .c o m*/ } List<ModelMapping> tagModelMappingList = mTagModelMappingController .get(ModelMapping.COLUMN.LAST_CLIENT_CHANGE + " >= ? ", new String[] { lastUpdateString }); for (ModelMapping tagMapping : tagModelMappingList) { if (tagMapping.getClientSideUUID() == null) continue; if (tagMapping.isDeleted()) { // delete the item mTagNetworkController.deleteItem(new DeleteResponse(tagMapping, tagMapping.getServerSideUUID()), _groupId, tagMapping.getServerSideUUID(), authToken); } else if (tagMapping.getServerSideUUID() == null) { // insert new TagInfo tagInfo = new TagInfo(); Tag tag = mTagController.findById(tagMapping.getClientSideUUID()); if (tag == null) { continue; } String uuid = mTagModelMappingController.generateUuid(); tagInfo.setUUID(uuid); tagInfo.setName(tag.mName); Date lastChanged = new Date(tagMapping.getLastClientChange().getTime() - Constants.NETWORK_OFFSET); tagInfo.setLastChanged(lastChanged); tagInfo.setDeleted(false); mTagNetworkController.createItem(new InsertResponse(tagMapping, uuid), _groupId, tagInfo, authToken); } else { // update existing TagInfo tagInfo = new TagInfo(); Tag tag = mTagController.findById(tagMapping.getClientSideUUID()); if (tag == null) { // probably the category was deleted // delete the item mTagNetworkController.deleteItem(new DeleteResponse(tagMapping, tagMapping.getServerSideUUID()), _groupId, tagMapping.getServerSideUUID(), authToken); continue; } tagInfo.setUUID(tagMapping.getServerSideUUID()); tagInfo.setName(tag.mName); Date lastChanged = new Date(tagMapping.getLastClientChange().getTime() - Constants.NETWORK_OFFSET); tagInfo.setLastChanged(lastChanged); tagInfo.setDeleted(false); mTagNetworkController.updateItem(new UpdateResponse(tagMapping, tagMapping.getServerSideUUID()), _groupId, tagInfo.getUUID(), tagInfo, authToken); } } }
From source file:org.noorganization.instalistsynch.controller.synch.impl.ListSynch.java
@Override public void synchLocalToNetwork(int _groupId, Date _lastUpdate) { String lastUpdateString = ISO8601Utils.format(_lastUpdate, false, TimeZone.getTimeZone("GMT+0000")); String authToken = mSessionController.getToken(_groupId); if (authToken == null) { // todo do some caching of this action return;/*from w ww . j a va2s .co m*/ } List<ModelMapping> modelMappingList = mListModelMappingController .get(ModelMapping.COLUMN.LAST_CLIENT_CHANGE + " >= ? ", new String[] { lastUpdateString }); for (ModelMapping modelMapping : modelMappingList) { if (modelMapping.isDeleted()) { // delete the item mListInfoNetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); } else if (modelMapping.getServerSideUUID() == null) { // insert new ListInfo listInfo = new ListInfo(); ShoppingList list = mListController.getListById(modelMapping.getClientSideUUID()); if (list == null) { continue; } String uuid = mListModelMappingController.generateUuid(); listInfo.setUUID(uuid); listInfo.setName(list.mName); if (list.mCategory != null) { List<ModelMapping> cateModelMapping = mCategoryModelMappingController.get( ModelMapping.COLUMN.CLIENT_SIDE_UUID + " LIKE ? AND " + ModelMapping.COLUMN.GROUP_ID + " = ?", new String[] { list.mCategory.mUUID, String.valueOf(_groupId) }); if (cateModelMapping.size() == 1) { ModelMapping categoryMapping = cateModelMapping.get(0); listInfo.setCategoryUUID(categoryMapping.getServerSideUUID()); } } Date lastChanged = new Date( modelMapping.getLastClientChange().getTime() - Constants.NETWORK_OFFSET); listInfo.setLastChanged(lastChanged); listInfo.setDeleted(false); mListInfoNetworkController.createItem(new InsertResponse(modelMapping, uuid), _groupId, listInfo, authToken); } else { // update existing ListInfo listInfo = new ListInfo(); ShoppingList list = mListController.getListById(modelMapping.getClientSideUUID()); if (list == null) { // probably the item was deleted mListInfoNetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); continue; } listInfo.setUUID(modelMapping.getServerSideUUID()); listInfo.setName(list.mName); if (list.mCategory != null) { List<ModelMapping> cateModelMapping = mCategoryModelMappingController.get( ModelMapping.COLUMN.CLIENT_SIDE_UUID + " LIKE ? AND " + ModelMapping.COLUMN.GROUP_ID + " = ?", new String[] { list.mCategory.mUUID, String.valueOf(_groupId) }); if (cateModelMapping.size() == 1) { ModelMapping categoryMapping = cateModelMapping.get(0); listInfo.setCategoryUUID(categoryMapping.getServerSideUUID()); } } Date lastChanged = new Date( modelMapping.getLastClientChange().getTime() - Constants.NETWORK_OFFSET); listInfo.setLastChanged(lastChanged); listInfo.setDeleted(false); mListInfoNetworkController.updateItem( new UpdateResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, listInfo.getUUID(), listInfo, authToken); } } }
From source file:org.noorganization.instalistsynch.controller.synch.impl.ListEntrySynch.java
@Override public void synchLocalToNetwork(int _groupId, Date _lastUpdate) { String lastUpdateString = ISO8601Utils.format(_lastUpdate, false, TimeZone.getTimeZone("GMT+0000")); String authToken = mSessionController.getToken(_groupId); if (authToken == null) { // todo do some caching of this action return;//from w ww.j a v a 2s.c om } List<ModelMapping> modelMappingList = mListEntryMapping .get(ModelMapping.COLUMN.LAST_CLIENT_CHANGE + " >= ? ", new String[] { lastUpdateString }); for (ModelMapping modelMapping : modelMappingList) { if (modelMapping.isDeleted()) { // delete the item mListEntryInfoNetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); } else if (modelMapping.getServerSideUUID() == null) { // insert new ListEntry listEntry = mListController.getEntryById(modelMapping.getClientSideUUID()); if (listEntry == null) { continue; } EntryInfo listEntryInfo = getListEntryInfo(listEntry, _groupId, modelMapping); if (listEntryInfo == null) continue; mListEntryInfoNetworkController.createItem( new InsertResponse(modelMapping, listEntryInfo.getUUID()), _groupId, listEntryInfo, authToken); } else { // update existing ListEntry listEntry = mListController.getEntryById(modelMapping.getClientSideUUID()); if (listEntry == null) { // probably the item was deleted mListEntryInfoNetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); continue; } EntryInfo entryInfo = getListEntryInfo(listEntry, _groupId, modelMapping); if (entryInfo == null) continue; mListEntryInfoNetworkController.updateItem( new UpdateResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, entryInfo.getUUID(), entryInfo, authToken); } } }
From source file:org.noorganization.instalistsynch.controller.synch.impl.IngredientSynch.java
@Override public void synchLocalToNetwork(int _groupId, Date _lastUpdate) { String lastUpdateString = ISO8601Utils.format(_lastUpdate, false, TimeZone.getTimeZone("GMT+0000")); String authToken = mSessionController.getToken(_groupId); if (authToken == null) { // todo do some caching of this action return;/*from w w w . j ava 2 s .c om*/ } List<ModelMapping> modelMappingList = mIngredientModelMapping .get(ModelMapping.COLUMN.LAST_CLIENT_CHANGE + " >= ? ", new String[] { lastUpdateString }); for (ModelMapping modelMapping : modelMappingList) { if (modelMapping.isDeleted()) { // delete the item mIngredientInfoNetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); } else if (modelMapping.getServerSideUUID() == null) { // insert new Ingredient ingredient = mRecipeController.findIngredientById(modelMapping.getClientSideUUID()); if (ingredient == null) { continue; } IngredientInfo ingredientInfo = getIngredientInfo(ingredient, _groupId, modelMapping); if (ingredientInfo == null) continue; mIngredientInfoNetworkController.createItem( new InsertResponse(modelMapping, ingredientInfo.getUUID()), _groupId, ingredientInfo, authToken); } else { // update existing Ingredient ingredient = mRecipeController.findIngredientById(modelMapping.getClientSideUUID()); if (ingredient == null) { // probably the item was deleted mIngredientInfoNetworkController.deleteItem( new DeleteResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, modelMapping.getServerSideUUID(), authToken); continue; } IngredientInfo ingredientInfo = getIngredientInfo(ingredient, _groupId, modelMapping); if (ingredientInfo == null) continue; mIngredientInfoNetworkController.updateItem( new UpdateResponse(modelMapping, modelMapping.getServerSideUUID()), _groupId, ingredientInfo.getUUID(), ingredientInfo, authToken); } } }
From source file:org.noorganization.instalistsynch.controller.synch.impl.CategorySynch.java
@Override public void synchLocalToNetwork(int _groupId, Date _lastUpdate) { String lastUpdateString = ISO8601Utils.format(_lastUpdate, false, TimeZone.getTimeZone("GMT+0000")); String authToken = mSessionController.getToken(_groupId); if (authToken == null) { // todo do some caching of this action return;/* w w w. ja va 2 s . c o m*/ } List<ModelMapping> categoryMappingList = mCategoryModelMappingController .get(ModelMapping.COLUMN.LAST_CLIENT_CHANGE + " >= ? ", new String[] { lastUpdateString }); for (ModelMapping categoryMapping : categoryMappingList) { if (categoryMapping.isDeleted()) { // delete the item mCategoryInfoNetworkController.deleteItem( new DeleteResponse(categoryMapping, categoryMapping.getServerSideUUID()), _groupId, categoryMapping.getServerSideUUID(), authToken); } else if (categoryMapping.getServerSideUUID() == null) { // insert new CategoryInfo categoryInfo = new CategoryInfo(); Category category = mCategoryController.getCategoryByID(categoryMapping.getClientSideUUID()); if (category == null) { continue; } String uuid = mCategoryModelMappingController.generateUuid(); categoryInfo.setUUID(uuid); categoryInfo.setName(category.mName); Date lastChanged = new Date( categoryMapping.getLastClientChange().getTime() - Constants.NETWORK_OFFSET); categoryInfo.setLastChanged(lastChanged); categoryInfo.setDeleted(false); mCategoryInfoNetworkController.createItem(new InsertResponse(categoryMapping, uuid), _groupId, categoryInfo, authToken); } else { // update existing CategoryInfo categoryInfo = new CategoryInfo(); Category category = mCategoryController.getCategoryByID(categoryMapping.getClientSideUUID()); if (category == null) { // probably the category was deleted // delete the item mCategoryInfoNetworkController.deleteItem( new DeleteResponse(categoryMapping, categoryMapping.getServerSideUUID()), _groupId, categoryMapping.getServerSideUUID(), authToken); continue; } categoryInfo.setUUID(categoryMapping.getServerSideUUID()); categoryInfo.setName(category.mName); Date lastChanged = new Date( categoryMapping.getLastClientChange().getTime() - Constants.NETWORK_OFFSET); categoryInfo.setLastChanged(lastChanged); categoryInfo.setDeleted(false); mCategoryInfoNetworkController.updateItem( new UpdateResponse(categoryMapping, categoryMapping.getServerSideUUID()), _groupId, categoryInfo.getUUID(), categoryInfo, authToken); } } }
From source file:org.noorganization.instalistsynch.controller.synch.impl.UnitSynch.java
@Override public void synchNetworkToLocal(int _groupId, Date _sinceTime) { String authToken = mSessionController.getToken(_groupId); if (authToken == null) { return;// ww w .j a v a 2 s . c o m } String since = ISO8601Utils.format(_sinceTime, false, TimeZone.getTimeZone("GMT+0000")).concat("+0000"); mNetworkController.getList(new ChangedElementsCallback(_groupId, _sinceTime), _groupId, since, authToken); }
From source file:org.noorganization.instalistsynch.controller.synch.impl.RecipeSynch.java
@Override public void synchNetworkToLocal(int _groupId, Date _sinceTime) { String authToken = mSessionController.getToken(_groupId); if (authToken == null) { return;//from w ww . j a v a 2 s .c o m } mRecipeInfoNetworkController.getList(new GetListResponse(_groupId, _sinceTime), _groupId, ISO8601Utils.format(_sinceTime, false, TimeZone.getTimeZone("GMT+0000")).concat("+0000"), authToken); }
From source file:org.noorganization.instalistsynch.controller.synch.impl.TagSynch.java
@Override public void synchNetworkToLocal(int _groupId, Date _sinceTime) { String authToken = mSessionController.getToken(_groupId); if (authToken == null) { return;// ww w .j a v a 2s . com } mTagNetworkController.getList(new GetListResponse(_groupId, _sinceTime), _groupId, ISO8601Utils.format(_sinceTime, false, TimeZone.getTimeZone("GMT+0000")).concat("+0000"), authToken); }