Search in sources :

Example 26 with Participant

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);
    });
}
Also used : ChatProfileVO(com.fanap.podchat.chat.user.profile.ChatProfileVO) CacheThreadParticipant(com.fanap.podchat.cachemodel.CacheThreadParticipant) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) Participant(com.fanap.podchat.mainmodel.Participant) CacheCallParticipant(com.fanap.podchat.call.persist.CacheCallParticipant) AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) CacheAssistantVo(com.fanap.podchat.cachemodel.CacheAssistantVo) ArrayList(java.util.ArrayList) CacheAssistantVo(com.fanap.podchat.cachemodel.CacheAssistantVo)

Example 27 with Participant

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);
    });
}
Also used : ChatProfileVO(com.fanap.podchat.chat.user.profile.ChatProfileVO) CacheThreadParticipant(com.fanap.podchat.cachemodel.CacheThreadParticipant) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) Participant(com.fanap.podchat.mainmodel.Participant) CacheCallParticipant(com.fanap.podchat.call.persist.CacheCallParticipant) AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) CacheAssistantVo(com.fanap.podchat.cachemodel.CacheAssistantVo) ArrayList(java.util.ArrayList) CacheAssistantVo(com.fanap.podchat.cachemodel.CacheAssistantVo)

Example 28 with Participant

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);
    });
}
Also used : ChatProfileVO(com.fanap.podchat.chat.user.profile.ChatProfileVO) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) Date(java.util.Date) CacheThreadParticipant(com.fanap.podchat.cachemodel.CacheThreadParticipant) CacheThreadParticipant(com.fanap.podchat.cachemodel.CacheThreadParticipant) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) Participant(com.fanap.podchat.mainmodel.Participant) CacheCallParticipant(com.fanap.podchat.call.persist.CacheCallParticipant) ParseException(java.text.ParseException) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) SimpleDateFormat(java.text.SimpleDateFormat)

Example 29 with Participant

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);
    });
}
Also used : CacheThreadParticipant(com.fanap.podchat.cachemodel.CacheThreadParticipant) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) Participant(com.fanap.podchat.mainmodel.Participant) CacheCallParticipant(com.fanap.podchat.call.persist.CacheCallParticipant) ArrayList(java.util.ArrayList) CacheAssistantHistoryVo(com.fanap.podchat.cachemodel.CacheAssistantHistoryVo) CacheAssistantHistoryVo(com.fanap.podchat.cachemodel.CacheAssistantHistoryVo) AssistantHistoryVo(com.fanap.podchat.chat.assistant.model.AssistantHistoryVo)

Aggregations

Participant (com.fanap.podchat.mainmodel.Participant)29 CacheParticipant (com.fanap.podchat.cachemodel.CacheParticipant)22 CacheCallParticipant (com.fanap.podchat.call.persist.CacheCallParticipant)18 CacheThreadParticipant (com.fanap.podchat.cachemodel.CacheThreadParticipant)17 ArrayList (java.util.ArrayList)15 PinMessageVO (com.fanap.podchat.mainmodel.PinMessageVO)8 ChatResponse (com.fanap.podchat.model.ChatResponse)7 ResultParticipant (com.fanap.podchat.model.ResultParticipant)7 ThreadVo (com.fanap.podchat.cachemodel.ThreadVo)6 ChatProfileVO (com.fanap.podchat.chat.user.profile.ChatProfileVO)6 Thread (com.fanap.podchat.mainmodel.Thread)6 ResultAddParticipant (com.fanap.podchat.model.ResultAddParticipant)6 CacheMessageVO (com.fanap.podchat.cachemodel.CacheMessageVO)5 CacheReplyInfoVO (com.fanap.podchat.cachemodel.CacheReplyInfoVO)5 GapMessageVO (com.fanap.podchat.cachemodel.GapMessageVO)5 MessageVO (com.fanap.podchat.mainmodel.MessageVO)5 OutPutParticipant (com.fanap.podchat.model.OutPutParticipant)5 ReplyInfoVO (com.fanap.podchat.model.ReplyInfoVO)5 IOException (java.io.IOException)5 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)4