use of com.fanap.podchat.cachemodel.CacheAssistantVo in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method insertCacheAssistantVo.
private void insertCacheAssistantVo(AssistantVo assistantVo) {
CacheAssistantVo cacheFile = new CacheAssistantVo();
cacheFile.setRoles(assistantVo.getRoles());
cacheFile.setBlock(assistantVo.getBlock());
if (assistantVo.getParticipantVO() != null) {
Participant participant = assistantVo.getParticipantVO();
CacheParticipant pInCache = messageDao.getParticipant(participant.getId());
CacheParticipant cacheParticipant;
if (pInCache != null) {
cacheParticipant = new CacheParticipant(participant, pInCache.getThreadId());
} else {
cacheParticipant = new CacheParticipant(participant, 0);
}
cacheFile.setParticipantVOId(cacheParticipant.getId());
cacheFile.setInviteeId(cacheParticipant.getId());
messageDao.insertParticipant(cacheParticipant);
if (participant.getChatProfileVO() != null) {
participant.getChatProfileVO().setId(participant.getId());
messageDao.insertChatProfile(participant.getChatProfileVO());
}
}
cacheFile.setContactType(assistantVo.getContactType());
messageDao.insertCacheAssistantVo(cacheFile);
}
use of com.fanap.podchat.cachemodel.CacheAssistantVo in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getCacheAssistantVos.
public void getCacheAssistantVos(GetAssistantRequest request, FunctionalListener callback) throws RoomIntegrityException {
if (!canUseDatabase())
throw new RoomIntegrityException();
worker(() -> {
List<CacheAssistantVo> list = messageDao.getCacheAssistantVos(request.getCount() > 0 ? request.getCount() : 25, request.getOffset());
List<AssistantVo> cachResponseList = new ArrayList<>();
for (CacheAssistantVo item : list) {
AssistantVo assistantVo = new AssistantVo();
assistantVo.setRoles((ArrayList<String>) item.getRoles());
assistantVo.setBlock(item.isBlock());
assistantVo.setContactType(item.getContactType());
Participant participant = cacheToParticipantMapper(messageDao.getParticipant(item.getParticipantVOId()), false, null);
ChatProfileVO profileVO = messageDao.getChatProfileVOById(participant.getId());
participant.setChatProfileVO(profileVO);
assistantVo.setParticipantVO(participant);
cachResponseList.add(assistantVo);
}
callback.onWorkDone(list.size(), cachResponseList);
});
}
use of com.fanap.podchat.cachemodel.CacheAssistantVo in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getCacheBlockedAssistantVos.
public void getCacheBlockedAssistantVos(GetBlockedAssistantsRequest request, FunctionalListener callback) throws RoomIntegrityException {
if (!canUseDatabase())
throw new RoomIntegrityException();
worker(() -> {
List<CacheAssistantVo> list = messageDao.getCacheBlockedAssistantVos(request.getCount() > 0 ? request.getCount() : 25, request.getOffset());
List<AssistantVo> cacheResponseList = new ArrayList<>();
for (CacheAssistantVo item : list) {
AssistantVo assistantVo = new AssistantVo();
assistantVo.setRoles((ArrayList<String>) item.getRoles());
assistantVo.setBlock(item.isBlock());
assistantVo.setContactType(item.getContactType());
Participant participant = cacheToParticipantMapper(messageDao.getParticipant(item.getParticipantVOId()), false, null);
ChatProfileVO profileVO = messageDao.getChatProfileVOById(participant.getId());
participant.setChatProfileVO(profileVO);
assistantVo.setParticipantVO(participant);
cacheResponseList.add(assistantVo);
}
callback.onWorkDone(list.size(), cacheResponseList);
});
}
Aggregations