Commit e8258333 by Lee Munkyeong

Merge branch 'features/abcomm_sp5_chat_UI' into 'features/abcomm_sp5'

Features/abcomm sp5 chat ui

See merge request !95
parents 8d3bc5b8 d1d19fdf
......@@ -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;
......@@ -64,6 +66,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.GetMessagesParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetNameCardParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetOperationDataParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.InviteUsersParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.NewAppStoreLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.PasswordChangeParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.PostEnqueteReplyParameters;
......@@ -615,6 +618,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
......@@ -630,6 +649,22 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* ユーザ招待。
*
* @param sid
* @param roomId
* @param roomName
* @param userIds
* @return 成功有無
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public boolean inviteUsers(String sid, Integer roomId, String roomName, String userIds) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new InviteUsersParameters(sid, AcmsApis.UserCmds.inviteUsers, roomId, roomName, userIds));
return response.httpResponseCode == 200;
}
/**
* お気に入りユーザ追加。。
*
* @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);
}
}
......@@ -60,6 +60,7 @@ public class GroupListJSON extends AcmsCommonJSON {
ShopMemberDto shopMemberDto = new ShopMemberDto();
shopMemberDto.shopMemberId = groupMember.getInt(ABookCommConstants.KEY.SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = groupMember.getString(ABookCommConstants.KEY.MEMBER_NAME);
shopMemberDto.delFlg = groupMember.getInt(ABookCommConstants.KEY.DEL_FLG);
if (groupMember.has(ABookCommConstants.KEY.PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = groupMember.getString(ABookCommConstants.KEY.PROFILE_IMAGE_PATH);
}
......
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;
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* @author Lee-mk
* @version 1.0.0
*/
public class InviteUsersParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private Integer newRoomId;
private String newRoomName;
private String loginIdList;
/**
* {@link InviteUsersParameters} のインスタンスを初期化します。
* @param sid
* @param cmd
* @param roomId
* @param newRoomName
* @param loginIdList
* @since 1.0.0
*/
public InviteUsersParameters(String sid, String cmd, Integer newRoomId, String newRoomName, String loginIdList) {
this.sid = sid;
this.cmd = cmd;
this.newRoomId = newRoomId;
this.newRoomName = newRoomName;
this.loginIdList = loginIdList;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return コマンド。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
/**
* roomIdを返します。
* @return roomId。
* @since 1.0.0
*/
public Integer getNewRoomId() {
return newRoomId;
}
/**
* newRoomNameを返します。
* @return newRoomName。
* @since 1.0.0
*/
public String getNewRoomName() {
return newRoomName;
}
/**
* loginIdListを返します。
* @return loginIdList。
* @since 1.0.0
*/
public String getLoginIdList() {
return loginIdList;
}
}
......@@ -176,6 +176,7 @@ public class AcmsApis {
public static final String ApigetFavorite = "favorite";
public static final class UserCmds {
public static final String inviteUsers = "3";
public static final String getMyInfo = "9";
public static final String getGroupInfo = "10";
public static final String getNameCard = "11";
......@@ -184,6 +185,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 {
......
......@@ -27,12 +27,14 @@ 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";
String CHILD_GROUP_LIST = "childGroupList";
String GROUP_USER_LIST = "groupUserList";
String BODY = "body";
String CHECKED = "checked";
String CHAT_ROOM_INFO = "chatRoomInfo";
String ROOM_ID = "roomId";
......@@ -57,7 +59,7 @@ public interface ABookCommConstants {
String ROOT_GROUP_ID = "rootGroupId";
String HTTP_STATUS = "httpStatus";
interface API_KIND {
String USER = "user";
String ROOM = "room";
......@@ -73,7 +75,14 @@ public interface ABookCommConstants {
Integer OFF = 0;
Integer ON = 1;
}
interface DEL_FLAG {
Integer EXIST = 0;
Integer DELETE = 1;
}
Integer GROUP_REQUEST_ALL = 0;
}
interface SIZE {
Integer MAX_FAVORITE_COUNT = 100;
}
}
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 {
......@@ -43,6 +45,10 @@ public class ChatRoomDao extends AbstractDao {
if (column != -1) {
dto.userCount = cursor.getInt(column);
}
column = cursor.getColumnIndex("view_flg");
if (column != -1) {
dto.viewFlg = cursor.getInt(column);
}
column = cursor.getColumnIndex("favorite_register_date");
if (column != -1) {
dto.favoriteRegisterDate = cursor.getString(column);
......@@ -80,12 +86,62 @@ public class ChatRoomDao extends AbstractDao {
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(" WHERE cr.type =? ");
sql.append(" AND (cr.view_flg IS null OR cr.view_flg != 1 )");
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(), new String[]{""+ roomType}, ChatRoomDto.class);
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(" AND (cr.view_flg IS null OR cr.view_flg != 1 )");
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);
}
......@@ -95,7 +151,20 @@ public class ChatRoomDao extends AbstractDao {
}
public void insertChatRoom(ChatRoomDto dto) {
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());
Integer chatRoomId = dto.chatRoomId;
if (dto.unreadCount == 0) {
insert("insert or replace into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date, view_flg) values (?,?,?,?,?,?, (select view_flg from t_chat_room where chat_room_id =" + chatRoomId + "))", dto.getInsertValues());
} else {
insert("insert or replace into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date, view_flg) values (?,?,?,?,?,?,0)", 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 changeRoomViewFlg(Integer roomId) {
update("update t_chat_room set view_flg = 1 where chat_room_id = ?", new String[]{"" + roomId});
}
public void insertChatRoom(List<ChatRoomDto> chatRoomDtoList) {
......@@ -127,8 +196,8 @@ public class ChatRoomDao extends AbstractDao {
public void deleteChatRoom() {
try {
beginTransaction();
delete("t_chat_room", null, null);
delete("r_chat_room_shop_member", null, null);
delete("t_chat_room", null, null);
commit();
} catch (Exception e) {
rollback();
......
......@@ -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;
}
......@@ -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);
}
/**
......
......@@ -113,10 +113,34 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getSelectedUsers(String userIdList) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
sql.append(" FROM ");
sql.append(" m_shop_member AS sm ");
sql.append(" WHERE sm.shop_member_id IN ( "+userIdList+" )");
sql.append(" AND sm.self_flg != 1");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getfavoriteUserList() {
return rawQueryGetDtoList("select * from m_shop_member where favorite_register_date NOT NULL", null, ShopMemberDto.class);
}
public List<ShopMemberDto> getfavoriteUserListNotInRoom(Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT * ");
sql.append(" FROM m_shop_member sm ");
sql.append(" WHERE favorite_register_date NOT NULL ");
sql.append(" AND sm.shop_member_id NOT IN");
sql.append(" (SELECT shop_member_id FROM r_chat_room_shop_member WHERE chat_room_id = ?)");
return rawQueryGetDtoList(sql.toString(), new String[] {"" + roomId}, ShopMemberDto.class);
}
public List<ShopMemberDto> getUserListByGroupId(Integer groupId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
......@@ -135,7 +159,7 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getUserInMyGroupByName(String shopMemberName) {
public List<ShopMemberDto> getUserListNotInRoomByGroupId(Integer groupId, Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" sm.shop_member_id ");
......@@ -146,6 +170,25 @@ public class ShopMemberDao extends AbstractDao {
sql.append(" m_shop_member AS sm ");
sql.append(" INNER JOIN r_shop_member_group AS rsmg ");
sql.append(" ON sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE rsmg.group_id =?");
sql.append(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_id NOT IN (SELECT shop_member_id FROM r_chat_room_shop_member WHERE chat_room_id = ?)");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{"" + groupId, "" + roomId}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getUserInMyGroupByName(String shopMemberName) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
sql.append(" ,sm.favorite_register_date");
sql.append(" FROM ");
sql.append(" m_shop_member AS sm ");
sql.append(" INNER JOIN r_shop_member_group AS rsmg ");
sql.append(" ON sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_group WHERE user_group_flg = 1)");
sql.append(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_name LIKE '%"+shopMemberName+"%' ");
......@@ -154,9 +197,29 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getUserInMyGroupNotInRoomByName(String shopMemberName, Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
sql.append(" ,sm.favorite_register_date");
sql.append(" FROM ");
sql.append(" m_shop_member AS sm ");
sql.append(" INNER JOIN r_shop_member_group AS rsmg ");
sql.append(" ON sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_group WHERE user_group_flg = 1)");
sql.append(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_id NOT IN (SELECT shop_member_id FROM r_chat_room_shop_member WHERE chat_room_id = ?)");
sql.append(" AND sm.shop_member_name LIKE '%"+shopMemberName+"%' ");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{"" + roomId}, ShopMemberDto.class);
return list;
}
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");
......@@ -172,6 +235,25 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getUserInAllGroupNotInRoomByName(String shopMemberName, Integer roomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
sql.append(" ,sm.favorite_register_date");
sql.append(" FROM ");
sql.append(" m_shop_member AS sm ");
sql.append(" INNER JOIN r_shop_member_group AS rsmg ");
sql.append(" ON sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" AND sm.self_flg != 1");
sql.append(" AND sm.shop_member_name LIKE '%"+shopMemberName+"%' ");
sql.append(" AND sm.shop_member_id NOT IN (SELECT shop_member_id FROM r_chat_room_shop_member WHERE chat_room_id = ?) ");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[] {"" + roomId}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getMyGroupUsers() {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
......@@ -194,6 +276,29 @@ public class ShopMemberDao extends AbstractDao {
return count > 0;
}
public boolean deleteShopMember(ShopMemberDto dto) {
long count = update("delete from m_shop_member where shop_member_id=?", new String[] {"" + dto.shopMemberId});
return count > 0;
}
public void deleteShopMemberByList(List<ShopMemberDto> dtoList) {
try {
beginTransaction();
for (ShopMemberDto dto : dtoList) {
update("delete from r_shop_member_group where shop_member_id=?", new String[] {"" + dto.shopMemberId});
update("delete from r_chat_room_shop_member where shop_member_id=?", new String[] {"" + dto.shopMemberId});
update("delete from m_shop_member where shop_member_id=?", new String[] {"" + dto.shopMemberId});
}
commit();
} catch (Exception e) {
rollback();
Logger.e("insertShopMember failed.", e);
throw new RuntimeException(e);
} finally {
}
}
public boolean updateFavoriteUser(ShopMemberDto dto) {
long count = update("update m_shop_member set favorite_register_date=? where shop_member_id=?", new Object[]{dto.favoriteRegisterDate, dto.shopMemberId});
return count > 0;
......@@ -202,6 +307,8 @@ public class ShopMemberDao extends AbstractDao {
public void deleteShopMember() {
try {
beginTransaction();
delete("r_collaboration_member", null, null);
delete("r_shop_member_group", null, null);
delete("m_shop_member", null, null);
commit();
} catch (Exception e) {
......
......@@ -21,6 +21,7 @@ public class TChatRoom extends SQLiteTableScript {
sql.append(" , type INTEGER NOT NULL ");
sql.append(" , unread_count INTEGER ");
sql.append(" , user_count INTEGER ");
sql.append(" , view_flg INTEGER ");
sql.append(" , favorite_register_date VARCHAR2(64) ");
sql.append(" , PRIMARY KEY (chat_room_id) ");
sql.append(" ) ");
......
......@@ -13,6 +13,7 @@ public class ChatRoomDto extends AbstractDto {
public Integer unreadCount = 0;
public Integer userCount;
public String message;
public Integer viewFlg;
public Integer messageType;
public String insertDate;
public ChatMessageDto lastMessageInfo;
......
......@@ -9,6 +9,7 @@ public class ShopMemberDto extends AbstractDto {
public String profileUrl;
public String favoriteRegisterDate;
public Integer selfFlg;
public Integer delFlg;
public ArrayList<Integer> groupIdList;
@Override
......
......@@ -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>();
......@@ -64,9 +71,9 @@ public class CommunicationLogic extends AbstractLogic {
JSONArray attendUsers = new JSONArray();
for (ShopMemberDto user : userList) {
Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put(ABookCommConstants.KEY.INSERT_DATE, user.shopMemberId);
userMap.put(ABookCommConstants.KEY.INSERT_DATE, user.profileUrl);
userMap.put(ABookCommConstants.KEY.INSERT_DATE, user.shopMemberName);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, user.shopMemberId);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, user.profileUrl);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, user.shopMemberName);
JSONObject jsonObject = new JSONObject(userMap);
attendUsers.put(jsonObject);
}
......@@ -79,6 +86,20 @@ public class CommunicationLogic extends AbstractLogic {
return roomListToStr;
}
public String getUsersInRoom(Integer roomId) {
List<ShopMemberDto> userList = shopMemberDao.getUserInRoom(roomId);
JSONArray attendUsers = new JSONArray();
for (ShopMemberDto user : userList) {
Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, user.shopMemberId);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, user.profileUrl);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, user.shopMemberName);
JSONObject jsonObject = new JSONObject(userMap);
attendUsers.put(jsonObject);
}
String attendUsersStr = attendUsers.toString();
return attendUsersStr;
}
public String getMessages(Integer roomId) {
List<ChatMessageDto> chatMessageDtoList = chatMessageDao.getChatMessage(roomId);
......@@ -92,7 +113,29 @@ public class CommunicationLogic extends AbstractLogic {
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_IMAGE_PATH, chatMessageDto.profileUrl);
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 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);
......@@ -104,11 +147,19 @@ public class CommunicationLogic extends AbstractLogic {
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);
resultJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
boolean hasRegisteredDate = StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate) == false;
resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, hasRegisteredDate);
......@@ -140,6 +191,38 @@ public class CommunicationLogic extends AbstractLogic {
Map<String, Object> myGroupUserMap = new HashMap<String, Object>();
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, groupUser.shopMemberId);
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, groupUser.shopMemberName);
myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, "");
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, groupUser.profileUrl);
myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser);
if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(myGroupUserMap);
groupUserArray.put(jsonObject);
}
groupUserJson.put(ABookCommConstants.KEY.GROUP_USER_LIST, groupUserArray);
myGroupUsersJson.put(groupUserJson);
}
String myInfoStr = myGroupUsersJson.toString();
return myInfoStr;
}
public String getMyGroupUsersNotInRoom(Integer roomId) {
List<GroupDto> myGroupIds = groupDao.getUserGroups();
JSONArray myGroupUsersJson = new JSONArray();
for (GroupDto groupDto : myGroupIds) {
JSONObject groupUserJson = new JSONObject();
groupUserJson.put(ABookCommConstants.KEY.GROUP_ID, groupDto.groupId);
groupUserJson.put(ABookCommConstants.KEY.GROUP_NAME, groupDto.groupName);
List<ShopMemberDto> groupUsers = shopMemberDao.getUserListNotInRoomByGroupId(groupDto.groupId, roomId);
JSONArray groupUserArray = new JSONArray();
for (ShopMemberDto groupUser : groupUsers) {
Map<String, Object> myGroupUserMap = new HashMap<String, Object>();
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, groupUser.shopMemberId);
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, groupUser.shopMemberName);
myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, "");
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, groupUser.profileUrl);
myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser);
if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) {
......@@ -163,11 +246,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 {
......@@ -181,6 +272,37 @@ public class CommunicationLogic extends AbstractLogic {
return searchUserStr;
}
public String getMyGroupUserNotInRoomByName(String shopMemberName, Integer roomId) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInMyGroupNotInRoomByName(shopMemberName, roomId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
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, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
String searchUserStr = resultJsonArray.toString();
return searchUserStr;
}
public String getAllGroupShopMemberByName(String shopMemberName) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInAllGroupByName(shopMemberName);
......@@ -188,11 +310,51 @@ 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 {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
String searchUserStr = resultJsonArray.toString();
return searchUserStr;
}
public String getAllGroupShopMemberNotInRoomByName(String shopMemberName, Integer roomId) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInAllGroupNotInRoomByName(shopMemberName, roomId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
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, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
......@@ -244,6 +406,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();
......@@ -251,11 +416,50 @@ 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, groupPathArray);
favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
JSONObject jsonObject = new JSONObject(favoriteUserMap);
resultJsonArray.put(jsonObject);
}
String favoriteUsersStr = resultJsonArray.toString();
return favoriteUsersStr;
}
public String getFavoriteUsersNotInRoom(Integer roomId) {
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserListNotInRoom(roomId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto favoriteUser : favoriteUsers) {
Map<String, Object> favoriteUserMap = new HashMap<String, Object>();
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);
......@@ -283,6 +487,12 @@ public class CommunicationLogic extends AbstractLogic {
return favoriteGroupsStr;
}
public Integer getFavoriteCount() {
List<GroupDto> favoriteGroups = groupDao.getFavoriteGroup();
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserList();
return favoriteGroups.size() + favoriteUsers.size();
}
public String getGroupSearchData(Integer groupId) {
//レスポンスになるJSON
......@@ -343,6 +553,7 @@ public class CommunicationLogic extends AbstractLogic {
shopMemberMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
shopMemberMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
shopMemberMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl);
shopMemberMap.put(ABookCommConstants.KEY.CHECKED, "");
shopMemberMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupDao.getUserGroupPathList(shopMember.shopMemberId));
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
......@@ -378,6 +589,23 @@ public class CommunicationLogic extends AbstractLogic {
chatRoomDao.insertChatRoom(chatRoomDto);
}
public void addUserInRoom(String userIds, Integer roomId) {
String[] userIdArray = userIds.split(",");
List<Integer> userIdList = new ArrayList<Integer>();
for (String userId : userIdArray) {
userIdList.add(Integer.parseInt(userId));
}
chatRoomDao.insertChatRoomUsers(userIdList, roomId);
}
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)) {
......@@ -391,14 +619,25 @@ public class CommunicationLogic extends AbstractLogic {
public void insertShopMember(List<ShopMemberDto> shopMemberDtoList) {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
List<ShopMemberDto> insertList = new ArrayList<ShopMemberDto>();
List<ShopMemberDto> deleteList = new ArrayList<ShopMemberDto>();
for (ShopMemberDto shopMemberDto : shopMemberDtoList) {
//TODO ユーザ最新化処理必要
//if (ABookCommConstants.FLAG.DEL_FLAG.EXIST.equals(shopMemberDto.delFlg)) {
if (myInfo.shopMemberId.equals(shopMemberDto.shopMemberId)) {
shopMemberDto.selfFlg = 1;
} else {
shopMemberDto.selfFlg = 0;
}
insertList.add(shopMemberDto);
//} else {
// deleteList.add(shopMemberDto);
//}
}
shopMemberDao.insertShopMember(shopMemberDtoList);
shopMemberDao.insertShopMember(insertList);
//shopMemberDao.deleteShopMemberByList(deleteList);
}
public void updateGroup(List<GroupDto> GroupList) {
......@@ -481,4 +720,27 @@ public class CommunicationLogic extends AbstractLogic {
}
groupDao.updateFavoriteGroupList(groupDtos);
}
public void clearAllData() {
chatMessageDao.deleteChatMessage();
chatRoomDao.deleteChatRoom();
shopMemberDao.deleteShopMember();
}
public void roomDisplayOff(Integer roomId) {
chatRoomDao.changeRoomViewFlg(roomId);
}
public String getUserList(String userIdList) {
List<ShopMemberDto> selectedUsers = shopMemberDao.getSelectedUsers(userIdList);
JSONArray attendUsers = new JSONArray();
for (ShopMemberDto dto : selectedUsers) {
Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, dto.shopMemberId);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, dto.profileUrl);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, dto.shopMemberName);
JSONObject jsonObject = new JSONObject(userMap);
attendUsers.put(jsonObject);
}
return attendUsers.toString();
};
}
......@@ -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;
}
......
......@@ -13,6 +13,7 @@ import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.webkit.CookieManager;
......@@ -29,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;
......@@ -36,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;
......@@ -51,9 +55,9 @@ import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
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;
......@@ -85,6 +89,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private final String NETWORK_ERROR_PLACE_HOLDER = "file:///android_asset/chat/public_new/chat.html";
//private final String NETWORK_ERROR_PLACE_HOLDER = "file:///android_asset/chat/public/networkError.html";
private final String CHAT_PAGE_URL = "file:///android_asset/chat/public_new/chat.html";
private final String CHAT_ROOM_PAGE_URL = "file:///android_asset/chat/public_new/chat_room.html";
private final String DEFAULT_CHECKSUM = "0000000000";
//AISDevelop
......@@ -98,7 +104,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private String shopName;
private boolean isOnline;
private Long roomId;
private String roomType;
private Integer shopMemberId;
private String selectedUserIdList;
public AlertDialog myAlertDialog;
......@@ -132,6 +140,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
if (AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).checkSid(sid)) {
isOnline = true;
chatWebviewUrl = CHAT_PAGE_URL;
communicationLogic.clearAllData();
updateMyInfoFromServer();
updateAllGroupInfo();
updateFavoriteInfo();
......@@ -179,7 +188,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) {
......@@ -539,12 +548,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
// 最後のチャットのルーム
PreferenceUtil.putUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMID, String.valueOf(roomId));
mChatWebView.loadUrl(String.format("javascript:getLoginParameter('%s', '%s', '%s', '%s', '%s', '%s');", sid, loginId, shopName, roomId, roomName, localLanguage));
mChatWebView.loadUrl(String.format("javascript:getLoginParameter('%s', '%s', '%s', '%s', '%s', '%s', '%s');", sid, loginId, shopName, roomId, roomName, localLanguage, shopMemberId));
} else {
if (lastRoomName.length() > 0 && lastRoomId.length() > 0) {
mChatWebView.loadUrl(String.format("javascript:getLoginParameter('%s', '%s', '%s', '%s', '%s', '%s');", sid, loginId, shopName, lastRoomId, lastRoomName, localLanguage));
mChatWebView.loadUrl(String.format("javascript:getLoginParameter('%s', '%s', '%s', '%s', '%s', '%s', '%s');", sid, loginId, shopName, lastRoomId, lastRoomName, localLanguage, shopMemberId));
} else {
mChatWebView.loadUrl(String.format("javascript:getLoginParameter('%s', '%s', '%s', undefined, undefined, '%s');", sid, loginId, shopName, localLanguage));
mChatWebView.loadUrl(String.format("javascript:getLoginParameter('%s', '%s', '%s', undefined, undefined, '%s', '%s');", sid, loginId, shopName, localLanguage, shopMemberId));
}
}
}
......@@ -699,9 +708,21 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String getRoomList(String roomType) {
public void saveSelectedUserList(String userIdList) {
Log.d("userIdList " , userIdList );
selectedUserIdList = userIdList;
}
String chatRoomListStr = communicationLogic.getChatRoomList(Integer.parseInt(roomType));
@JavascriptInterface
public String getSelectedUserList() {
String userList = communicationLogic.getUserList(selectedUserIdList);
Log.d("getSelectedUserList " , userList );
return userList;
}
@JavascriptInterface
public String getRoomList(String roomType, String keyword) {
String chatRoomListStr = communicationLogic.getChatRoomList(Integer.parseInt(roomType), keyword);
return chatRoomListStr;
}
......@@ -709,7 +730,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
public void updateRoomList() throws NetworkDisconnectedException, AcmsException {
Map<String, Object> chatRoomList;
RoomListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getRoomList(sid);
communicationLogic.deleteChatRoomList();
//communicationLogic.deleteChatRoomList();
communicationLogic.insertChatRoomList(resultJson.roomList);
}
......@@ -741,12 +762,63 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
mChatWebView.loadUrl(String.format("javascript:CHAT_UI.joinRoom('%s', '%s');", chatRoomId, chatRoomName));
}
});
}
@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 updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException {
public void joinRoom(String joinRoomId, String joinRoomName) {
ChatRoomDto chatRoom = communicationLogic.getChatRoom(Integer.parseInt(joinRoomId));
roomId = Long.parseLong(joinRoomId);
roomName = joinRoomName;
roomType = chatRoom.type.toString();
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_ROOM_PAGE_URL);
}
});
}
@JavascriptInterface
public void roomDisplayOff() {
communicationLogic.roomDisplayOff(roomId.intValue());
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_PAGE_URL);
}
});
}
@JavascriptInterface
public void inviteUsers(String userIds) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).inviteUsers(sid, roomId.intValue(), roomName, userIds);
if (!result) { return; }
communicationLogic.addUserInRoom(userIds, roomId.intValue());
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_ROOM_PAGE_URL);
}
});
}
@JavascriptInterface
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);
......@@ -762,36 +834,72 @@ 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;
}
@JavascriptInterface
public String getFavoriteUsersNotInRoom() {
String favoriteUsersStr = communicationLogic.getFavoriteUsersNotInRoom(roomId.intValue());
return favoriteUsersStr;
}
@JavascriptInterface
public String getMyInfo() {
String myInfoStr = communicationLogic.getMyInfo();
return myInfoStr;
}
@JavascriptInterface
public String getUsersInRoom(String roomId) {
String attendUsers = communicationLogic.getUsersInRoom(Integer.parseInt(roomId));
return attendUsers;
}
@JavascriptInterface
public String getMyGroupUsers() {
String myGroupUsersStr = communicationLogic.getMyGroupUsers();
return myGroupUsersStr;
}
@JavascriptInterface
public String getMyGroupUsersNotInRoom() {
String myGroupUsersStr = communicationLogic.getMyGroupUsersNotInRoom(roomId.intValue());
return myGroupUsersStr;
}
@JavascriptInterface
public String getMyGroupShopMemberByName(String shopMemberName) {
String searchUserStr = communicationLogic.getMyGroupUserByName(shopMemberName);
return searchUserStr;
}
@JavascriptInterface
public String getMyGroupShopMemberNotInRoomByName(String shopMemberName) {
String searchUserStr = communicationLogic.getMyGroupUserNotInRoomByName(shopMemberName, roomId.intValue());
return searchUserStr;
}
@JavascriptInterface
public String getAllGroupShopMemberByName(String shopMemberName) {
String searchUserStr = communicationLogic.getAllGroupShopMemberByName(shopMemberName);
return searchUserStr;
}
@JavascriptInterface
public String getAllGroupShopMemberNotInRoomByName(String shopMemberName) {
String searchUserStr = communicationLogic.getAllGroupShopMemberNotInRoomByName(shopMemberName, roomId.intValue());
return searchUserStr;
}
@JavascriptInterface
public String getGroupByName(String groupName) {
String searchGroupStr = communicationLogic.getGroupByName(groupName);
return searchGroupStr;
......@@ -826,15 +934,28 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void addFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = insertFavoriteUser(shopMemberId);
if (!result) { return; }
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
public boolean addFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
Integer favoriteCount = communicationLogic.getFavoriteCount();
if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT ) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:alert('" + "お気に入りは最大100件までです。" + "');");
}
});
return false;
} else {
boolean result = insertFavoriteUser(shopMemberId);
if (!result) { return false; }
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
return true;
}
}
@JavascriptInterface
......@@ -851,15 +972,29 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void addFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = insertFavoriteGroup(groupId);
if (result) {
public boolean addFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
Integer favoriteCount = communicationLogic.getFavoriteCount();
if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
mChatWebView.loadUrl("javascript:alert('" + "お気に入りは最大100件までです。" + "');");
}
});
return false;
} else {
boolean result = insertFavoriteGroup(groupId);
if (result) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
return true;
}
return false;
}
}
......@@ -896,7 +1031,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private void updateMyInfoFromServer() throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
communicationLogic.insertMyInfo(resultJson.shopMemberDto);
if (resultJson.shopMemberDto != null) {
communicationLogic.insertMyInfo(resultJson.shopMemberDto);
}
}
private void updateUserInfoFromServer(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
......@@ -906,8 +1043,11 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
private boolean insertFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
.insertFavoriteUser(sid, Integer.parseInt(shopMemberId));
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).insertFavoriteUser(sid,Integer.parseInt(shopMemberId));
if (!result) { return false; }
List<Integer> shopMeberIds = new ArrayList<>();
shopMeberIds.add(Integer.parseInt(shopMemberId));
communicationLogic.updateFavoriteUser(shopMeberIds);
return result;
}
......@@ -945,24 +1085,31 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
SharedPreferences pref = getSharedPreferences(ABookCommConstants.TAG,MODE_PRIVATE);
for (String groupId : groupIds.split(",")) {
checkSumList.add(pref.getString(groupId,DEFAULT_CHECKSUM));
//checkSumList.add(pref.getString(groupId,DEFAULT_CHECKSUM));
checkSumList.add(DEFAULT_CHECKSUM);
}
String checkSumListStr = StringUtil.join(",",checkSumList);
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid, groupIds, checkSumListStr);
if (CollectionUtil.isNotEmpty(resultJson.groupList)) {
SharedPreferences.Editor editor = pref.edit();
communicationLogic.updateGroup(resultJson.groupList);
if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) {
editor.putString(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString(), resultJson.allGroupLastUpdateDate);
} else {
for (GroupDto groupDto : resultJson.groupList) {
editor.putString(Integer.toString(groupDto.groupId), groupDto.updateDate);
if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) {
checkSumListStr = DEFAULT_CHECKSUM;
}
try {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,groupIds,checkSumListStr);
if (CollectionUtil.isNotEmpty(resultJson.groupList)) {
SharedPreferences.Editor editor = pref.edit();
communicationLogic.updateGroup(resultJson.groupList);
if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) {
editor.putString(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString(),resultJson.allGroupLastUpdateDate);
} else {
for (GroupDto groupDto : resultJson.groupList) {
editor.putString(Integer.toString(groupDto.groupId),groupDto.updateDate);
}
}
editor.commit();
}
editor.commit();
} catch (AcmsException e) {
e.printStackTrace();
}
}
private void updateFavoriteUser() throws NetworkDisconnectedException, AcmsException {
......
......@@ -10,6 +10,7 @@ import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.Constant.ExceptionDetailMessage;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
......@@ -24,6 +25,7 @@ import jp.agentec.abook.abv.bl.download.ContentRefresher;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.PasswordLockInfoDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.CommunicationLogic;
import jp.agentec.abook.abv.bl.logic.ContractLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic;
......@@ -41,6 +43,7 @@ import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.adf.util.StringUtil;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.Gravity;
......@@ -66,7 +69,7 @@ public class LoginActivity extends ABVLoginActivity {
private static final String TAG = "LoginActivity";
private UserAuthenticateLogic userAuthenticateLogic;
private CommunicationLogic communicationLogic;
private MemberInfoDao memberInfoDao;
private ContractLogic contractLogic;
......@@ -99,6 +102,7 @@ public class LoginActivity extends ABVLoginActivity {
contractLogic = AbstractLogic.getLogic(ContractLogic.class);
userAuthenticateLogic = AbstractLogic.getLogic(UserAuthenticateLogic.class);
communicationLogic = AbstractLogic.getLogic(CommunicationLogic.class);
memberInfoDao = AbstractDao.getDao(MemberInfoDao.class);
imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
......@@ -635,6 +639,7 @@ public class LoginActivity extends ABVLoginActivity {
// ユーザ変更があった場合、チャットのルーム情報をクリアする
clearChatLastRoom();
abookCommClear();
//ユーザ変更があった場合、FetchDateをクリアする
AcmsDao dao = AbstractDao.getDao(AcmsDao.class);
......@@ -715,4 +720,11 @@ public class LoginActivity extends ABVLoginActivity {
// 最後のチャットのルーム
PreferenceUtil.putUserPref(getApplicationContext(), UserPrefKey.CHAT_LAST_ROOMID, "");
}
// AbookComm関連のデータをクリア
private void abookCommClear() {
//CheckSumクリア
deleteSharedPreferences(ABookCommConstants.TAG);
communicationLogic.clearAllData();
}
}
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