Commit a6ff1c56 by Lee Munkyeong

チャットルーム詳細実装

parent ceddbc2f
......@@ -26,6 +26,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.FixPushMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.LogSendFlagJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MessageInfoListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MyInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.NewAppStoreLoginJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON;
......@@ -38,7 +39,6 @@ import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.SceneEntryJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ServerTimeZoneJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ServiceOptionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ShopMemberListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.WorkerGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AbstractAcmsLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters;
......@@ -54,6 +54,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.EnterpriseNewLoginParamete
import jp.agentec.abook.abv.bl.acms.client.parameters.GetApertureMasterDataParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetContentParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetEnqueteReplyParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetMessagesParameters;
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.NewAppStoreLoginParameters;
......@@ -62,7 +63,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.PostEnqueteReplyParameters
import jp.agentec.abook.abv.bl.acms.client.parameters.SendPushMessageParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ServerTimeParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.UpdateDeviceTokenParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.createRoomParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.CreateRoomParameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.acms.type.LoginStatus;
import jp.agentec.abook.abv.bl.acms.type.RequirePasswordChangeCode;
......@@ -567,8 +568,8 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public GroupListJSON getGroupInfo(String sid,String groupId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new AcmsParameters(sid,AcmsApis.Cmds.getGroupInfo,groupId));
public GroupListJSON getGroupInfo(String sid,String groupId,String updatedDate) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new AcmsParameters(sid,AcmsApis.Cmds.getGroupInfo,groupId,updatedDate));
GroupListJSON json = new GroupListJSON(response.httpResponseBody);
return json;
}
......@@ -581,13 +582,27 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public CreatedRoomJSON createRoom(String sid, Integer roomType, String inviteMemberIds, String newRoomName) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new createRoomParameters(sid,AcmsApis.Cmds.createRoom,roomType,inviteMemberIds,newRoomName));
public CreatedRoomJSON createRoom(String sid, String roomType, String inviteMemberIds, String newRoomName) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new CreateRoomParameters(sid,AcmsApis.Cmds.createRoom,roomType,inviteMemberIds,newRoomName));
CreatedRoomJSON json = new CreatedRoomJSON(response.httpResponseBody);
return json;
}
/**
* ルーム作成。
*
* @param sid
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public MessageInfoListJSON getMessages(String sid, String roomId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetMessage, new GetMessagesParameters(sid,AcmsApis.Cmds.getMessages,roomId,"0"));
MessageInfoListJSON json = new MessageInfoListJSON(response.httpResponseBody);
return json;
}
/**
* 作業報告データ送信
* @param sid
* @param operationId
......
......@@ -22,7 +22,7 @@ public class CreatedRoomJSON extends AcmsCommonJSON {
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
private static final String DEL_FLG = "del_flg";
private static final String TYPE = "type";
private static final String ROOM_TYPE = "roomType";
public ArrayList<ShopMemberDto> attendUsers;
public ChatRoomDto chatRoomDto;
......@@ -46,7 +46,7 @@ public class CreatedRoomJSON extends AcmsCommonJSON {
chatRoomDto.userCount = groupListJsonArray.length();
chatRoomDto.chatRoomId = createdRoomJson.getInt(ROOM_ID);
chatRoomDto.chatRoomName = createdRoomJson.getString(ROOM_NAME);
chatRoomDto.type = createdRoomJson.getInt(TYPE);
chatRoomDto.type = createdRoomJson.getInt(ROOM_TYPE);
chatRoomDto.unreadCount = 0;
......
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.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.adf.util.DateTimeUtil;
public class MessageInfoListJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String MESSAGE_INFO_LIST = "messageInfoList";
private static final String MESSAGE = "message";
private static final String MESSAGE_ID = "messageId";
private static final String SHOP_ID = "shopId";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MESSAGE_TYPE = "messageType";
private static final String TIME = "time";
private static final String CRYPTED_MEMBER_NAME = "cryptedMemberName";
public ArrayList<ChatMessageDto> chatMessageDtoList;
public MessageInfoListJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
// メッセージ情報を取得
if (!json.has(Body)) { return; }
JSONArray messageInfoList = json.getJSONObject(Body).getJSONArray(MESSAGE_INFO_LIST);
if (messageInfoList == null) { return; }
chatMessageDtoList = new ArrayList<ChatMessageDto>();
for (int listCount = 0; listCount < messageInfoList.length(); listCount++) {
if (messageInfoList.getJSONObject(listCount).length() == 0) {
break;
}
ChatMessageDto chatMessageDto = new ChatMessageDto();
JSONObject messageInfoJSON = messageInfoList.getJSONObject(listCount);
if (messageInfoJSON == null) { continue; }
chatMessageDto.shopMemberId = messageInfoJSON.getInt(SHOP_MEMBER_ID);
chatMessageDto.chatMessageId = messageInfoJSON.getInt(MESSAGE_ID);
chatMessageDto.message = messageInfoJSON.getString(MESSAGE);
chatMessageDto.messageType = messageInfoJSON.getInt(MESSAGE_TYPE);
if (messageInfoJSON.has(TIME)) {
chatMessageDto.insertDate = DateTimeUtil.millToDateString(messageInfoJSON.getJSONObject(TIME).getLong(TIME));
}
chatMessageDtoList.add(chatMessageDto);
}
}
}
......@@ -16,6 +16,8 @@ public class AcmsParameters extends HttpParameterObject {
private String sid;
private String cmd;
private String groupId;
private String updatedDate;
/**
* {@link AcmsParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
......@@ -36,10 +38,11 @@ public class AcmsParameters extends HttpParameterObject {
this.cmd = cmd;
}
public AcmsParameters(String sid, String cmd, String groupId) {
public AcmsParameters(String sid, String cmd, String groupId, String updatedDate) {
this.sid = sid;
this.cmd = cmd;
this.groupId = groupId;
this.updatedDate = updatedDate;
}
/**
......@@ -60,6 +63,10 @@ public class AcmsParameters extends HttpParameterObject {
return cmd;
}
public String getUpdatedDate() {
return updatedDate;
}
public String getGroupId() {
return groupId;
}
......
......@@ -5,36 +5,36 @@ import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link createRoomParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* ただし、このクラスはログイン状態の確認用として使われる {@link CreateRoomParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author Taejin Hong
* @version 1.0.0
*/
public class createRoomParameters extends HttpParameterObject {
public class CreateRoomParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private Integer roomType;
private String roomType;
private String inviteMemberIds;
private String newRoomName;
/**
* {@link createRoomParameters} のインスタンスを初期化します。
* {@link CreateRoomParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @since 1.0.0
*/
public createRoomParameters(String sid) {
public CreateRoomParameters(String sid) {
this.sid = sid;
}
/**
* {@link createRoomParameters} のインスタンスを初期化します。
* {@link CreateRoomParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public createRoomParameters(String sid, String cmd, Integer roomType, String inviteMemberIds, String newRoomName) {
public CreateRoomParameters(String sid, String cmd, String roomType, String inviteMemberIds, String newRoomName) {
this.sid = sid;
this.cmd = cmd;
this.roomType = roomType;
......@@ -60,7 +60,7 @@ public class createRoomParameters extends HttpParameterObject {
return cmd;
}
public Integer getRoomType() {
public String getRoomType() {
return roomType;
}
......
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link GetMessagesParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author Taejin Hong
* @version 1.0.0
*/
public class GetMessagesParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private String roomId;
private String lineNum;
/**
* {@link GetMessagesParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @since 1.0.0
*/
public GetMessagesParameters(String sid) {
this.sid = sid;
}
/**
* {@link GetMessagesParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public GetMessagesParameters(String sid, String cmd, String roomId, String lineNum) {
this.sid = sid;
this.cmd = cmd;
this.roomId = roomId;
this.lineNum = lineNum;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
public String getRoomId() {
return roomId;
}
public String getLineNum() {
return lineNum;
}
}
......@@ -172,12 +172,14 @@ public class AcmsApis {
public static final String ApiGetChatPushData = "push";
public static final String ApigetChatRooms = "room";
public static final String ApigetUser = "user";
public static final String ApigetMessage = "message";
public static final class Cmds {
public static final String getRoomList = "5";
public static final String getMyInfo = "9";
public static final String getGroupInfo = "10";
public static final String createRoom = "2";
public static final String getMessages = "2";
}
// download
......@@ -226,7 +228,7 @@ public class AcmsApis {
methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiGetApertureMasterData) || methodName.equals(ApiQuickReportSearch) || methodName.equals(ApiQuickReportRevision)
|| methodName.equals(ApiGetProcessData) || methodName.equals(ApiDeleteProcess)) {
apiValue = Constant.ApiValue.checkapi;
} else if (methodName.equals(ApiGetChatPushData) || methodName.equals(ApigetChatRooms) || methodName.equals(ApigetUser)) { // pushActionはchatapiを指定
} else if (methodName.equals(ApiGetChatPushData) || methodName.equals(ApigetChatRooms) || methodName.equals(ApigetUser) || methodName.equals(ApigetMessage)) { // pushActionはchatapiを指定
apiValue = Constant.ApiValue.chatapi;
}
......
......@@ -67,7 +67,7 @@ public class ChatMessageDao extends AbstractDao {
}
public void insertChatMessage(ChatMessageDto dto) {
insert("insert 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());
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());
}
public void insertChatMessage(List<ChatMessageDto> chatMessageDtoList) {
......
......@@ -94,7 +94,7 @@ public class ChatRoomDao extends AbstractDao {
}
public void insertChatRoom(ChatRoomDto dto) {
insert("insert into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date) values (?,?,?,?,?,?)", dto.getInsertValues());
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 insertChatRoom(List<ChatRoomDto> chatRoomDtoList) {
......
......@@ -61,7 +61,7 @@ public class ShopMemberDao extends AbstractDao {
public void insertShopMember(ShopMemberDto dto) {
try {
beginTransaction();
insert("insert into m_shop_member (shop_member_id, shop_member_name, profile_url, favorite_register_date, self_flg) values (?,?,?,?,?)", dto.getInsertValues());
insert("insert or replace into m_shop_member (shop_member_id, shop_member_name, profile_url, favorite_register_date, self_flg) values (?,?,?,?,?)", dto.getInsertValues());
for (Integer groupId : dto.groupIdList) {
insert("insert into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", dto.getGroupIds());
}
......
......@@ -103,6 +103,10 @@ public class CommunicationLogic extends AbstractLogic {
chatMessageDao.insertChatMessage(insertMessageList);
}
public void insertMessageList(List<ChatMessageDto> messageList) {
chatMessageDao.insertChatMessage(messageList);
}
public void insertChatRoom(ChatRoomDto chatRoomDto) {
chatRoomDao.insertChatRoom(chatRoomDto);
}
......
......@@ -41,6 +41,7 @@ import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MessageInfoListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MyInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ShopMemberListJSON;
......@@ -52,6 +53,7 @@ import jp.agentec.abook.abv.bl.common.exception.AcmsException;
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.ContentReadingLogDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
......@@ -711,15 +713,24 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public void updateGroupInfo() throws NetworkDisconnectedException, AcmsException {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,"0");
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,"0","1900010115");
communicationLogic.updateGroup(resultJson.groupList);
}
@JavascriptInterface
public void createRoom(Integer roomType, String userIdList, String encodedRoomName) throws NetworkDisconnectedException, AcmsException {
public void createChatRoom(String roomType, String userIdList, String encodedRoomName) throws NetworkDisconnectedException, AcmsException {
CreatedRoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).createRoom(sid, roomType, userIdList, encodedRoomName);
communicationLogic.insertChatRoom(resultJson.chatRoomDto);
}
@JavascriptInterface
public void updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException {
MessageInfoListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessages(sid, roomId);
for (ChatMessageDto chatMessageDto : resultJson.chatMessageDtoList) {
chatMessageDto.chatRoomId = Integer.parseInt(roomId);
}
communicationLogic.insertMessageList(resultJson.chatMessageDtoList);
}
}
/**
......
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