Commit ea4909b8 by Kang Donghun

Merge branch 'features/abcomm_sp5_chat_UI' of…

Merge branch 'features/abcomm_sp5_chat_UI' of gitlab.agentec.jp:abook_android/abook_check into features/abcomm_sp5_chat_UI

# Conflicts:
#	ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/ChatWebviewActivity.java
parents 74da67a1 acc21972
......@@ -18,6 +18,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.ApertureMasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AppLatestVersionJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AuthLevelJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CategoriesJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ChangeRoomNameJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ChatPushDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ContentCheckDeliverableJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON;
......@@ -47,6 +48,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AddMemberGroupParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AppStoreNewLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ChangeRoomNameParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.CheckSendLogParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ContentReadingLogParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.DeleteProcessParameters;
......@@ -615,6 +617,22 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* ルーム名更新。
*
* @param sid
* @param newRoomName
* @param roomId
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public ChangeRoomNameJSON changeRoomName(String sid, String newRoomName, Integer roomId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new ChangeRoomNameParameters(sid, AcmsApis.RoomCmds.changeRoomName, newRoomName, roomId));
ChangeRoomNameJSON json = new ChangeRoomNameJSON(response.httpResponseBody);
return json;
}
/**
* ルーム作成。
*
* @param sid
......
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
public class ChangeRoomNameJSON extends AcmsCommonJSON {
public Integer status;
public ChangeRoomNameJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
if (!json.has(ABookCommConstants.KEY.HTTP_STATUS)) { return; }
status = json.getInt(ABookCommConstants.KEY.HTTP_STATUS);
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link ChangeRoomNameParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author lee-mk
* @version 1.0.0
*/
public class ChangeRoomNameParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private String newRoomName;
private Integer roomId;
/**
* {@link ChangeRoomNameParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param newRoomName ルーム名。
* @param roomId ルームID。
* @since 1.0.0
*/
public ChangeRoomNameParameters(String sid, String cmd, String newRoomName, Integer roomId) {
this.sid = sid;
this.cmd = cmd;
this.newRoomName = newRoomName;
this.roomId = roomId;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* アクションコマンドを返します。
* @return APIのアクションコマンドです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
/**
* ルーム名を返します。
* @return ルーム名です。
* @since 1.0.0
*/
public String getNewRoomName() {
return newRoomName;
}
/**
* ルームIDを返します。
* @return 変更対象のルームIDです。
* @since 1.0.0
*/
public Integer getRoomId() {
return roomId;
}
}
......@@ -184,6 +184,7 @@ public class AcmsApis {
public static final class RoomCmds {
public static final String getRoomList = "5";
public static final String createRoom = "2";
public static final String changeRoomName = "6";
}
public static final class MessageCmds {
......
......@@ -6,7 +6,7 @@ package jp.agentec.abook.abv.bl.common.constant;
public interface ABookCommConstants {
String TAG ="ABookComm";
String TAG = "ABookComm";
//AbookComm専用の共通インターフェース
interface KEY {
......@@ -27,6 +27,7 @@ public interface ABookCommConstants {
String PROFILE_URL = "profileUrl";
String GROUP_NAME = "groupName";
String GROUP_ID = "groupId";
String GROUP_PATH = "groupPath";
String GROUP_IDS = "groupIds";
String GROUP_PATH_LIST = "groupPathList";
String IS_FAVORITE = "isFavorite";
......@@ -58,7 +59,7 @@ public interface ABookCommConstants {
String ROOT_GROUP_ID = "rootGroupId";
String HTTP_STATUS = "httpStatus";
interface API_KIND {
String USER = "user";
String ROOM = "room";
......
package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.adf.util.StringUtil;
public class ChatMessageDao extends AbstractDao {
......@@ -99,6 +101,44 @@ public class ChatMessageDao extends AbstractDao {
return list;
}
public List<ChatMessageDto> searchChatMessage(int chatRoomId, String[] keywords, String userList) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" cm.chat_message_id ");
sql.append(" ,cm.chat_room_id ");
sql.append(" ,cm.shop_member_id ");
sql.append(" ,cm.message ");
sql.append(" ,cm.message_type ");
sql.append(" ,cm.image_name ");
sql.append(" ,cm.download_file_name ");
sql.append(" ,cm.save_path ");
sql.append(" ,cm.insert_date ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url ");
sql.append(" ,sm.self_flg ");
sql.append(" FROM ");
sql.append(" t_chat_message AS cm ");
sql.append(" INNER JOIN ");
sql.append(" m_shop_member AS sm ");
sql.append(" ON cm.shop_member_id = sm.shop_member_id ");
sql.append(" WHERE cm.message_type = 0 ");
List<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
whereSqlList.add("cm.message LIKE '%" + keyword + "%'");
}
String whereSql = StringUtil.join(" OR ", whereSqlList);
if (!StringUtil.isNullOrEmpty(whereSql)) {
sql.append("AND (" + whereSql + ")");
}
if (!StringUtil.isNullOrEmpty(userList)) {
sql.append(" AND cm.shop_member_id IN (" + userList + ") ");
}
sql.append("AND cm.chat_room_id = ? ");
sql.append("ORDER BY cm.insert_date DESC ");
List<ChatMessageDto> list = rawQueryGetDtoList(sql.toString(), new String[]{""+ chatRoomId}, ChatMessageDto.class);
return list;
}
public void insertChatMessage(ChatMessageDto dto) {
insert("insert or replace into t_chat_message (chat_message_id, chat_room_id, shop_member_id, message, message_type, image_name, download_file_name, save_path, insert_date) values (?,?,?,?,?,?,?,?,?)", dto.getInsertValues());
}
......
package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
......@@ -7,6 +8,7 @@ import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.StringUtil;
public class ChatRoomDao extends AbstractDao {
......@@ -86,6 +88,54 @@ public class ChatRoomDao extends AbstractDao {
return list;
}
public ChatRoomDto getChatRoom(Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" cr.chat_room_id ");
sql.append(" ,cr.chat_room_name ");
sql.append(" ,cr.type ");
sql.append(" FROM ");
sql.append(" t_chat_room AS cr ");
sql.append(" WHERE cr.chat_room_id =? ");
ChatRoomDto list = rawQueryGetDto(sql.toString(), new String[]{""+ roomId}, ChatRoomDto.class);
return list;
}
public List<ChatRoomDto> getAllChatRoombyKeyword(String[] keywords) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" cr.chat_room_id ");
sql.append(" ,cr.chat_room_name ");
sql.append(" ,cr.type ");
sql.append(" ,coalesce (cr.favorite_register_date,'') favorite_register_date");
sql.append(" ,coalesce (cr.unread_count,0) unread_count");
sql.append(" ,coalesce (cm.message,'') message");
sql.append(" ,coalesce (cm.message_type,0) message_type");
sql.append(" ,coalesce (cm.insert_date,'') insert_date");
sql.append(" ,coalesce (cr.user_count,0) user_count ");
sql.append(" FROM ");
sql.append(" t_chat_room AS cr ");
sql.append(" LEFT JOIN ");
sql.append(" ( SELECT max(insert_date) insert_date, message, message_type, chat_room_id FROM t_chat_message GROUP BY chat_room_id ) AS cm ");
sql.append(" ON cr.chat_room_id = cm.chat_room_id ");
sql.append(" LEFT JOIN r_chat_room_shop_member rcrsm ");
sql.append(" ON cr.chat_room_id = rcrsm.chat_room_id ");
sql.append(" INNER JOIN m_shop_member sm ");
sql.append(" ON rcrsm.shop_member_id = sm.shop_member_id ");
sql.append(" WHERE ");
List<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
whereSqlList.add("cr.chat_room_name LIKE '%" + keyword + "%'");
whereSqlList.add("sm.shop_member_name LIKE '%" + keyword + "%'");
}
String whereSql = StringUtil.join(" OR ", whereSqlList);
sql.append(whereSql);
sql.append(" GROUP BY cr.chat_room_id ");
sql.append(" ORDER BY CASE WHEN unread_count = 0 THEN 0 ELSE 1 END DESC, cm.insert_date DESC ");
List<ChatRoomDto> list = rawQueryGetDtoList(sql.toString(), null, ChatRoomDto.class);
return list;
}
public ChatRoomDto getFavoriteChatRoom() {
return rawQueryGetDto("select * from t_chat_room where favorite_register_date is NOT NULL", null, ChatRoomDto.class);
}
......@@ -98,6 +148,10 @@ public class ChatRoomDao extends AbstractDao {
insert("insert or replace into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date) values (?,?,?,?,?,?)", dto.getInsertValues());
}
public void updateChatRoomName(String roomName, Integer roomId) {
update("update t_chat_room set chat_room_name = ? where chat_room_id = ?", new Object[]{roomName, roomId});
}
public void insertChatRoom(List<ChatRoomDto> chatRoomDtoList) {
try {
beginTransaction();
......
......@@ -90,13 +90,13 @@ public class GroupDao extends AbstractDao {
return rawQueryGetStringList(sql.toString(), null);
}
public List<String> getUserGroupPathList(Integer shopMemberId) {
public List<GroupDto> getUserGroupPathList(Integer shopMemberId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" CASE WHEN (grandparentgroup.group_name IS NOT NULL) THEN grandparentgroup.group_name || ' / ' || parentgroup.group_name || ' / ' || usergroup.group_name ");
sql.append(" WHEN (parentgroup.group_name IS NOT NULL) THEN parentgroup.group_name || ' / ' || usergroup.group_name ");
sql.append(" ELSE usergroup.group_name ");
sql.append(" END AS group_path_list ");
sql.append(" END AS group_path, usergroup.group_id ");
sql.append(" FROM m_group usergroup ");
sql.append(" LEFT JOIN m_group parentgroup on usergroup.parent_group_id = parentgroup.group_id ");
sql.append(" LEFT JOIN m_group grandparentgroup on parentgroup.parent_group_id = grandparentgroup.group_id ");
......@@ -104,7 +104,7 @@ public class GroupDao extends AbstractDao {
sql.append(" (SELECT group_id ");
sql.append(" FROM m_shop_member sm INNER JOIN r_shop_member_group rsmg on sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE sm.shop_member_id = ? ) ");
return rawQueryGetStringList(sql.toString(), new String[] { "" + shopMemberId});
return rawQueryGetDtoList(sql.toString(), new String[] { "" + shopMemberId}, GroupDto.class);
}
private String generateGetGroupsQuery(QueryType queryType, int[] groupRelationids, int[] parentGroupIds, Boolean downloaded, String searchKeyword, SearchDivisionType searchDivisionType, boolean isOnlineSearched) {
......@@ -546,7 +546,7 @@ public class GroupDao extends AbstractDao {
public List<GroupDto> getGroupChildList(int parentId) {
List<GroupDto> list;
list = rawQueryGetDtoList("select * from m_group mg where (mg.parent_group_id = ?)", new String[]{""+ parentId}, GroupDto.class);
list = rawQueryGetDtoList("select * from m_group mg where (mg.parent_group_id = ?) ORDER BY group_name", new String[]{""+ parentId}, GroupDto.class);
return list;
}
......@@ -555,7 +555,7 @@ public class GroupDao extends AbstractDao {
}
public GroupDto getParentGroup(Integer childGroupId) {
return rawQueryGetDto("select parent.* from m_group parent inner join m_group child on child.parent_group_id = parent.group_id where child.group_id = ?",new String[]{""+ childGroupId}, GroupDto.class);
return rawQueryGetDto("select parent.* from m_group parent inner join m_group child on child.parent_group_id = parent.group_id where child.group_id = ?", new String[]{""+ childGroupId}, GroupDto.class);
}
public boolean isExistParent(int baseId) {
......@@ -563,7 +563,7 @@ public class GroupDao extends AbstractDao {
}
public List<GroupDto> getUserGroups() {
return rawQueryGetDtoList("select * from m_group where user_group_flg = 1", null, GroupDto.class);
return rawQueryGetDtoList("select * from m_group where user_group_flg = 1 ORDER BY group_name", null, GroupDto.class);
}
/**
......
......@@ -151,7 +151,7 @@ public class ShopMemberDao extends AbstractDao {
public List<ShopMemberDto> getUserInMyGroupByName(String shopMemberName) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
......@@ -170,7 +170,7 @@ public class ShopMemberDao extends AbstractDao {
public List<ShopMemberDto> getUserInAllGroupByName(String shopMemberName) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
......
......@@ -19,6 +19,8 @@ import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.ArrayUtil;
import jp.agentec.adf.util.CollectionUtil;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.StringUtil;
......@@ -43,9 +45,14 @@ public class CommunicationLogic extends AbstractLogic {
/*package*/ CommunicationLogic() {
}
public String getChatRoomList(Integer roomType) {
List<ChatRoomDto> chatRoomList = chatRoomDao.getAllChatRoom(roomType);
public String getChatRoomList(Integer roomType, String keyword) {
List<ChatRoomDto> chatRoomList;
if (StringUtil.isNullOrEmpty(keyword)) {
chatRoomList = chatRoomDao.getAllChatRoom(roomType);
} else {
String[] replacedKeyword = keyword.replaceAll(" ", " ").split(" ");
chatRoomList = chatRoomDao.getAllChatRoombyKeyword(replacedKeyword);
}
JSONArray resultJsonArray = new JSONArray();
for (ChatRoomDto chatRoomDto : chatRoomList) {
Map<String, Object> chatRoomMap = new HashMap<String, Object>();
......@@ -115,19 +122,46 @@ public class CommunicationLogic extends AbstractLogic {
return messageListStr;
}
public String searMessages(Integer roomId, String keyword, String userList) {
String[] replacedKeyword = keyword.replaceAll(" ", " ").split(" ");
List<ChatMessageDto> chatMessageDtoList = chatMessageDao.searchChatMessage(roomId, replacedKeyword, userList);
JSONArray resultJsonArray = new JSONArray();
for (ChatMessageDto chatMessageDto : chatMessageDtoList) {
Map<String, Object> chatMessageMap = new HashMap<String, Object>();
chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId);
chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName);
chatMessageMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, chatMessageDto.shopMemberId);
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, chatMessageDto.message);
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatMessageDto.messageType);
chatMessageMap.put(ABookCommConstants.KEY.INSERT_DATE, chatMessageDto.insertDate);
chatMessageMap.put(ABookCommConstants.KEY.PROFILE_URL, chatMessageDto.profileUrl);
chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg);
JSONObject jsonObject = new JSONObject(chatMessageMap);
resultJsonArray.put(jsonObject);
}
String messageListStr = resultJsonArray.toString();
return messageListStr;
}
public String getNameCardInfo(Integer shopMemberId) {
JSONObject resultJson = new JSONObject();
ShopMemberDto shopMemberDto = shopMemberDao.getShopMember(shopMemberId);
List<String> groupPathList = groupDao.getUserGroupPathList(shopMemberId);
List<GroupDto> groupPathList = groupDao.getUserGroupPathList(shopMemberId);
JSONArray groupPathArray = new JSONArray();
for (GroupDto groupDto : groupPathList){
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupMap.put(ABookCommConstants.KEY.GROUP_PATH, groupDto.groupPath);
JSONObject jsonObject = new JSONObject(groupMap);
groupPathArray.put(jsonObject);
}
resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMemberDto.shopMemberId);
resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMemberDto.shopMemberName);
resultJson.put(ABookCommConstants.KEY.PROFILE_URL, shopMemberDto.profileUrl);
resultJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
if (StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate)) {
resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
resultJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
boolean hasRegisteredDate = StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate) == false;
resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, hasRegisteredDate);
return resultJson.toString();
}
......@@ -181,11 +215,19 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
List<String> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
List<GroupDto> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
JSONArray groupPathArray = new JSONArray();
for (GroupDto groupDto : groupPathList){
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupMap.put(ABookCommConstants.KEY.GROUP_PATH, groupDto.groupPath);
JSONObject jsonObject = new JSONObject(groupMap);
groupPathArray.put(jsonObject);
}
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl);
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
......@@ -206,11 +248,19 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
List<String> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
List<GroupDto> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
JSONArray groupPathArray = new JSONArray();
for (GroupDto groupDto : groupPathList){
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupMap.put(ABookCommConstants.KEY.GROUP_PATH, groupDto.groupPath);
JSONObject jsonObject = new JSONObject(groupMap);
groupPathArray.put(jsonObject);
}
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl);
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
......@@ -262,6 +312,9 @@ public class CommunicationLogic extends AbstractLogic {
return groupDao.getAllGroups();
}
public ChatRoomDto getChatRoom(Integer roomId) {
return chatRoomDao.getChatRoom(roomId);
}
public String getFavoriteUsers() {
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserList();
......@@ -269,12 +322,20 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto favoriteUser : favoriteUsers) {
Map<String, Object> favoriteUserMap = new HashMap<String, Object>();
List<String> groupPathList = groupDao.getUserGroupPathList(favoriteUser.shopMemberId);
List<GroupDto> groupPathList = groupDao.getUserGroupPathList(favoriteUser.shopMemberId);
JSONArray groupPathArray = new JSONArray();
for (GroupDto groupDto : groupPathList){
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupMap.put(ABookCommConstants.KEY.GROUP_PATH, groupDto.groupPath);
JSONObject jsonObject = new JSONObject(groupMap);
groupPathArray.put(jsonObject);
}
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, favoriteUser.shopMemberId);
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, favoriteUser.shopMemberName);
favoriteUserMap.put(ABookCommConstants.KEY.CHECKED, "");
favoriteUserMap.put(ABookCommConstants.KEY.PROFILE_URL, favoriteUser.profileUrl);
favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
JSONObject jsonObject = new JSONObject(favoriteUserMap);
resultJsonArray.put(jsonObject);
......@@ -320,10 +381,10 @@ public class CommunicationLogic extends AbstractLogic {
GroupDto parentGroup = groupDao.getParentGroup(targetGroupId);
if (parentGroup != null) {
groupSearchData.put(ABookCommConstants.KEY.PARENT_GROUP_ID,parentGroup.groupId);
groupSearchData.put(ABookCommConstants.KEY.PARENT_GROUP_ID, parentGroup.groupId);
}
if (rootGroup != null) {
groupSearchData.put(ABookCommConstants.KEY.ROOT_GROUP_ID,rootGroup.groupId);
groupSearchData.put(ABookCommConstants.KEY.ROOT_GROUP_ID, rootGroup.groupId);
}
//グループ
......@@ -398,6 +459,14 @@ public class CommunicationLogic extends AbstractLogic {
chatRoomDao.insertChatRoom(chatRoomDto);
}
public void insertChatMessage(ChatMessageDto chatMessageDto) {
chatMessageDao.insertChatMessage(chatMessageDto);
}
public void updateChatRoomName(String roomName, Integer roomId) {
chatRoomDao.updateChatRoomName(roomName, roomId);
}
public void insertShopMember(ShopMemberDto shopMemberDto) {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
if (myInfo.shopMemberId.equals(shopMemberDto.shopMemberId)) {
......
......@@ -17,6 +17,7 @@ import java.util.Map;
import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic;
......@@ -64,6 +65,10 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
String roomName = "";
String pushSendLoginId = "";
long pushSendDate = 0;
Integer insertId = 0;
Integer messageType = 0;
Integer messageId = 0;
Log.d(TAG,"tempMsg : "+ tempMsg);
if (tempMsg.indexOf("pushSendLoginId") > 0) {
......@@ -77,6 +82,12 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
pushSendDate = json.getLong("pushSendDate");
pushMsg = json.getString("message");
//TODO pushメッセージが到着した際、新着メッセージかルーム招待か判別してDB格納が必要
//insertId = json.getString("insertId");
//ChatMessageDto chatMessageDto = new ChatMessageDto();
//chatMessageDto.chatRoomId =
//chatRoomId shopMemberId messge messageType insertDate
if (pushMsg.length() > 0) {
tempMsg = pushMsg;
}
......
......@@ -30,6 +30,8 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import org.json.adf.HTTP;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
......@@ -37,6 +39,7 @@ import java.util.Map;
import java.util.Objects;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.ChangeRoomNameJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GetFavoriteGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GetFavoriteUserJSON;
......@@ -55,7 +58,6 @@ import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.CommunicationLogic;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
......@@ -102,6 +104,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private String shopName;
private boolean isOnline;
private Long roomId;
private String roomType;
private Integer shopMemberId;
private String selectedUserIdList;
......@@ -184,7 +187,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
//ページをロード
if(roomId != 0 && roomName != null) { // by push message
String parameterData = "sid=" + sid + "&loginId=" + loginId + "&shopName=" + shopName + "&roomId=" + roomId + "&roomName=" + roomName + fixedParam;
mChatWebView.postUrl(chatWebviewUrl, parameterData.getBytes());
mChatWebView.postUrl(CHAT_ROOM_PAGE_URL, parameterData.getBytes());
}
else { // Chat
if (lastRoomName.length() > 0 && lastRoomId.length() > 0) {
......@@ -717,8 +720,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String getRoomList(String roomType) {
String chatRoomListStr = communicationLogic.getChatRoomList(Integer.parseInt(roomType));
public String getRoomList(String roomType, String keyword) {
String chatRoomListStr = communicationLogic.getChatRoomList(Integer.parseInt(roomType), keyword);
return chatRoomListStr;
}
......@@ -762,10 +765,20 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void changeRoomName(String changeRoomName) throws NetworkDisconnectedException, AcmsException {
ChangeRoomNameJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).changeRoomName(sid, changeRoomName, roomId.intValue());
if (resultJson.status != 200) { return; }
communicationLogic.updateChatRoomName(changeRoomName, roomId.intValue());
joinRoom(roomId.toString(), changeRoomName);
}
@JavascriptInterface
public void joinRoom(String joinRoomId, String joinRoomName) {
ChatRoomDto chatRoom = communicationLogic.getChatRoom(Integer.parseInt(joinRoomId));
roomId = Long.parseLong(joinRoomId);
roomName = joinRoomName;
System.out.println("-----------joinROOM ON android-------"+roomId+"-"+roomName);
roomType = chatRoom.type.toString();
mChatWebView.post(new Runnable() {
@Override
public void run() {
......@@ -775,8 +788,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException {
public String getRoomType() {
return roomType;
}
@JavascriptInterface
public void updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException {
MessageInfoListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessages(sid, roomId);
for (ChatMessageDto chatMessageDto : resultJson.chatMessageDtoArrayList) {
chatMessageDto.chatRoomId = Integer.parseInt(roomId);
......@@ -792,6 +809,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String searchMessages(String keyword, String userList) {
String messageListStr = communicationLogic.searMessages(roomId.intValue(), keyword, userList);
return messageListStr;
}
@JavascriptInterface
public String getFavoriteUsers() {
String favoriteUsersStr = communicationLogic.getFavoriteUsers();
return favoriteUsersStr;
......@@ -864,7 +887,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public void addFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = insertFavoriteUser(shopMemberId);
if (result) {
if (!result) { return; }
mChatWebView.post(new Runnable() {
@Override
public void run() {
......@@ -872,7 +895,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
});
}
}
@JavascriptInterface
public void removeFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
......@@ -939,7 +961,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
private void updateUserInfoFromServer(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getNameCard(sid,shopMemberId);
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getNameCard(sid, shopMemberId);
communicationLogic.insertShopMember(resultJson.shopMemberDto);
}
......@@ -953,7 +976,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
private boolean deleteFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).deleteFavoriteUser(sid,Integer.parseInt(shopMemberId));
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
.deleteFavoriteUser(sid, Integer.parseInt(shopMemberId));
if (result) {
List<Integer> deleteFavoriteList = new ArrayList<Integer>();
deleteFavoriteList.add(Integer.parseInt(shopMemberId));
......@@ -963,18 +987,21 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
private boolean insertFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).insertFavoriteGroup(sid,Integer.parseInt(groupId));
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
.insertFavoriteGroup(sid, Integer.parseInt(groupId));
return result;
}
private boolean deleteFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).deleteFavoriteGroup(sid,Integer.parseInt(groupId));
if (result) {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
.deleteFavoriteGroup(sid, Integer.parseInt(groupId));
if (!result) { return false; }
List<Integer> deleteFavoriteList = new ArrayList<Integer>();
deleteFavoriteList.add(Integer.parseInt(groupId));
communicationLogic.deleteavoriteGroup(deleteFavoriteList);
}
return result;
return true;
}
private void updateGroupInfoFromServer(String groupIds) throws NetworkDisconnectedException, AcmsException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment