use of com.fanap.podchat.model.TagVo in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method prepareTagList.
private List<TagVo> prepareTagList() {
List<CacheTagVo> tags = messageDao.getCacheTagVos();
List<TagVo> tagVos = new ArrayList<>();
for (CacheTagVo item : tags) {
TagVo tag = CacheTagVoToTagVoMapper(item);
long allUnreadCount = 0;
List<CacheTagParticipantVO> cacheTagParticipants = messageDao.getCacheTagParticipantVosByTagId(item.getTagId());
List<TagParticipantVO> tagParticipants = new ArrayList<>();
for (CacheTagParticipantVO cacheTagParticipantVO : cacheTagParticipants) {
TagParticipantVO cache = cacheTagParticipantVOToTagParticipantVOMapper(cacheTagParticipantVO);
if (messageDao.getThreadById(cacheTagParticipantVO.getThreadId()) != null) {
Thread thread = threadVoToThreadMapper(messageDao.getThreadById(cacheTagParticipantVO.getThreadId()), null);
cache.setConversationVO(thread);
// TODO it should be save in db. can save it when save tags on db
if (thread.getUnreadCount() > 0)
allUnreadCount = allUnreadCount + thread.getUnreadCount();
}
tagParticipants.add(cache);
}
tag.setTagParticipants(tagParticipants);
tag.setAllUnreadCount(allUnreadCount);
tagVos.add(tag);
}
return tagVos;
}
use of com.fanap.podchat.model.TagVo in project pod-chat-android-sdk by FanapSoft.
the class TagManager method prepareTagResponse.
public static ChatResponse<TagResult> prepareTagResponse(ChatMessage chatMessage) {
TagVo tag = App.getGson().fromJson(chatMessage.getContent(), TagVo.class);
TagResult tagResult = new TagResult(tag);
ChatResponse<TagResult> finalResponse = new ChatResponse<>();
finalResponse.setResult(tagResult);
finalResponse.setUniqueId(chatMessage.getUniqueId());
finalResponse.setSubjectId(chatMessage.getSubjectId());
return finalResponse;
}
use of com.fanap.podchat.model.TagVo in project pod-chat-android-sdk by FanapSoft.
the class TagManager method getTags.
private static List<TagVo> getTags(ChatMessage chatMessage) {
List<TagVo> tags = App.getGson().fromJson(chatMessage.getContent(), new TypeToken<ArrayList<TagVo>>() {
}.getType());
for (TagVo tag : tags) {
if (!Util.isNullOrEmpty(tag.getTagParticipants())) {
long unreadCount = 0;
for (TagParticipantVO tagParticipant : tag.getTagParticipants()) if (tagParticipant.getConversationVO() != null)
unreadCount = unreadCount + tagParticipant.getConversationVO().getUnreadCount();
tag.setAllUnreadCount(unreadCount);
}
}
return tags;
}
use of com.fanap.podchat.model.TagVo in project pod-chat-android-sdk by FanapSoft.
the class TagCacheTest method testIfTagsAreSame.
// @Test
// public void testIfTagParticipantsAreSame() {
// populateServerTags();
//
// populateCacheTags();
// assert serverTags.size() > 0;
// assert cacheTags.size() > 0;
// assert serverTags.size() == cacheTags.size();
//
// }
@Test
public void testIfTagsAreSame() {
populateServerTags();
populateCacheTags();
assert serverTags.size() > 0;
assert cacheTags.size() > 0;
assert serverTags.size() == cacheTags.size();
for (TagVo serverTag : serverTags) {
if (serverTag == null)
continue;
System.out.println(">>>>>>>>>>> Server Tag " + serverTag.getTagId());
TagVo tagInCache = cacheTags.stream().filter(cacheTag -> cacheTag.getTagId() == serverTag.getTagId()).findFirst().get();
System.out.println(">>>>>>>>>>> Cache Tag " + tagInCache.getTagName());
Assert.assertEquals(serverTag.getTagId(), tagInCache.getTagId());
Assert.assertEquals(serverTag.getTagName(), tagInCache.getTagName());
// Assert.assertEquals(serverTag.getOwner(), tagInCache.getOwner());
Assert.assertEquals(serverTag.getAllUnreadCount(), tagInCache.getAllUnreadCount());
Assert.assertEquals(serverTag.isActive(), tagInCache.isActive());
System.out.println(">>>>>>>>>>>TagParticipants in cache" + tagInCache.getTagParticipants().size());
System.out.println(">>>>>>>>>>>TagParticipants in server" + serverTag.getTagParticipants().size());
System.out.println(">>>>>>>>>>>Tags are same");
}
}
Aggregations