use of com.fanap.podchat.mainmodel.Participant 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.mainmodel.Participant 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);
});
}
use of com.fanap.podchat.mainmodel.Participant in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getThreadParticipant.
public void getThreadParticipant(long offset, long count, long threadId, FunctionalListener listener) throws RoomIntegrityException {
if (!canUseDatabase())
throw new RoomIntegrityException();
worker(() -> {
List<Participant> participants = new ArrayList<>();
List<CacheThreadParticipant> listCtp = messageDao.getAllThreadParticipants(offset, count, threadId);
long participantCount = messageDao.getParticipantCount(threadId);
if (listCtp == null) {
listener.onWorkDone(participantCount, participants);
} else {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
Calendar c = Calendar.getInstance();
c.setTime(new Date());
Date nowDate = c.getTime();
for (CacheThreadParticipant threadParticipant : listCtp) {
try {
Date expireDate = format.parse(threadParticipant.getExpireDate());
long participantId = threadParticipant.getParticipantId();
if (expireDate != null) {
if (expireDate.compareTo(nowDate) < 0) {
messageDao.deleteCacheThreadParticipant(participantId);
} else {
CacheParticipant cParticipant = messageDao.getParticipant(participantId);
ChatProfileVO chatProfileVO = messageDao.getChatProfileVOById(cParticipant.getId());
if (chatProfileVO != null) {
cParticipant.setChatProfileVO(chatProfileVO);
}
List<String> roles = new ArrayList<>();
Participant participant = cacheToParticipantMapper(cParticipant, false, roles);
participants.add(participant);
}
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
listener.onWorkDone(participantCount, participants);
});
}
use of com.fanap.podchat.mainmodel.Participant in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getCacheAssistantHistoryVos.
public void getCacheAssistantHistoryVos(GetAssistantHistoryRequest request, FunctionalListener callback) throws RoomIntegrityException {
if (!canUseDatabase())
throw new RoomIntegrityException();
worker(() -> {
List<CacheAssistantHistoryVo> list = messageDao.getCacheAssistantHistory(request.getCount() > 0 ? request.getCount() : 25, request.getOffset());
List<AssistantHistoryVo> cacheResponseList = new ArrayList<>();
for (CacheAssistantHistoryVo item : list) {
AssistantHistoryVo assistantHistoryVo = new AssistantHistoryVo();
assistantHistoryVo.setActionName(item.getActionName());
assistantHistoryVo.setActionTime(item.getActionTime());
assistantHistoryVo.setActionType(item.getActionType());
Participant participant = cacheToParticipantMapper(messageDao.getParticipant(item.getParticipantVOId()), false, null);
assistantHistoryVo.setParticipantVO(participant);
cacheResponseList.add(assistantHistoryVo);
}
callback.onWorkDone(list.size(), cacheResponseList);
});
}
Aggregations