Commit ca1b03fd by Lee Munkyeong

ルーム一覧API連動

parent b50f0193
......@@ -31,6 +31,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ProcessDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RequirePasswordChangeJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ResultJSON;
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;
......@@ -525,6 +526,21 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* チャットルーム一覧情報を取得する。
*
* @param sid
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public RoomListJSON getRoomList(String sid) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new AcmsParameters(sid,AcmsApis.Cmds.getRoomList));
RoomListJSON json = new RoomListJSON(response.httpResponseBody);
return json;
}
/**
* 作業報告データ送信
* @param sid
* @param operationId
......
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.abook.abv.bl.dto.ChatRoomDto;
public class RoomListJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String ChatRoomInfoList = "chatRoomInfoList";
private static final String MessageInsertDate = "messageInsertDate";
private static final String RoomId = "roomId";
private static final String RoomName = "roomName";
private static final String RoomType = "roomType";
private static final String LastMessageInfo = "lastMessageInfo";
private static final String Message = "message";
private static final String MessageId = "messageId";
private static final String ShopMemberId = "shopMemberId";
private static final String MessageType = "messageType";
private static final String UnreadCount = "unreadCount";
private static final String AttendUsers = "attendUsers";
public ArrayList<ChatRoomDto> roomList;
public RoomListJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (json.has(Body)) {
JSONArray roomListJsonArray = json.getJSONObject(Body).getJSONArray(ChatRoomInfoList);
if (roomListJsonArray != null) {
roomList = new ArrayList<ChatRoomDto>();
for (int listCount = 0; listCount < roomListJsonArray.length(); listCount++) {
if (roomListJsonArray.getJSONObject(listCount).length() == 0) {
break;
}
ChatRoomDto chatRoomDto = new ChatRoomDto();
ChatMessageDto chatMessageDto = new ChatMessageDto();
chatRoomDto.chatRoomId = roomListJsonArray.getJSONObject(listCount).getInt(RoomId);
chatRoomDto.chatRoomName = roomListJsonArray.getJSONObject(listCount).getString(RoomName);
chatRoomDto.type = roomListJsonArray.getJSONObject(listCount).getInt(RoomType);
chatRoomDto.unreadCount = roomListJsonArray.getJSONObject(listCount).getInt(UnreadCount);
chatRoomDto.userCount = roomListJsonArray.getJSONObject(listCount).getJSONArray(AttendUsers).length();
//最後メッセージ情報がある場合の処理
JSONObject lastMessageInfoJSON = roomListJsonArray.getJSONObject(listCount).getJSONObject(LastMessageInfo);
if (lastMessageInfoJSON != null) {
chatMessageDto.chatRoomId = chatRoomDto.chatRoomId;
chatMessageDto.message = lastMessageInfoJSON.getString(Message);
chatMessageDto.messageType = lastMessageInfoJSON.getInt(MessageType);
chatMessageDto.insertDate = lastMessageInfoJSON.getString(MessageInsertDate);
chatMessageDto.shopMemberId = lastMessageInfoJSON.getInt(ShopMemberId);
chatMessageDto.chatMessageId = lastMessageInfoJSON.getInt(MessageId);
chatRoomDto.lastMessageInfo = chatMessageDto;
}
roomList.add(chatRoomDto);
}
}
}
}
}
......@@ -14,7 +14,7 @@ public class AcmsParameters extends HttpParameterObject {
* @since 1.0.0
*/
private String sid;
private String cmd;
/**
* {@link AcmsParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
......@@ -25,6 +25,17 @@ public class AcmsParameters extends HttpParameterObject {
}
/**
* {@link AcmsParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public AcmsParameters(String sid, String cmd) {
this.sid = sid;
this.cmd = cmd;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
......@@ -32,4 +43,13 @@ public class AcmsParameters extends HttpParameterObject {
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
}
......@@ -170,6 +170,11 @@ public class AcmsApis {
// チャット
public static final String ChatApiUrlFormat = "%s/%s/chatapi/%s/";
public static final String ApiGetChatPushData = "push";
public static final String ApigetChatRooms = "room";
public static final class Cmds {
public static final String getRoomList = "5";
}
// download
/**
......@@ -217,7 +222,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)) { // pushActionはchatapiを指定
} else if (methodName.equals(ApiGetChatPushData) || methodName.equals(ApigetChatRooms)) { // pushActionはchatapiを指定
apiValue = Constant.ApiValue.chatapi;
}
......
......@@ -13,8 +13,7 @@ public class ChatRoomDto extends AbstractDto {
public String message;
public Integer messageType;
public String insertDate;
public ChatMessageDto lastMessageInfo;
@Override
public Object[] getInsertValues() {
......
......@@ -26,6 +26,7 @@ import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.common.util.ContentFileUtil;
import jp.agentec.abook.abv.bl.common.util.JsonUtil;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.ChatMessageDao;
import jp.agentec.abook.abv.bl.data.dao.ChatRoomDao;
import jp.agentec.abook.abv.bl.data.dao.ContentCategoryDao;
import jp.agentec.abook.abv.bl.data.dao.ContentDao;
......@@ -49,6 +50,7 @@ public class CommunicationLogic extends AbstractLogic {
private static final String TAG = "CommunicationLogic";
private ChatRoomDao chatRoomDao = AbstractDao.getDao(ChatRoomDao.class);
private ChatMessageDao chatMessageDao = AbstractDao.getDao(ChatMessageDao.class);
/**
* {@link CommunicationLogic} クラスのインスタンスを初期化します。
......@@ -82,4 +84,11 @@ public class CommunicationLogic extends AbstractLogic {
String testStr1 = resultJsonArray.toString();
return testStr1;
}
public void insertChatRoomList(List<ChatRoomDto> roomList) {
for (ChatRoomDto chatRoomDto : roomList) {
chatRoomDao.insertChatRoom(chatRoomDto);
chatMessageDao.insertChatMessage(chatRoomDto.lastMessageInfo);
}
}
}
......@@ -8,6 +8,9 @@ function connectSocket(isOnline) {
if (isOnline == 'true') {
socket = io(CHAT_SERVER_URL);
setSocketAction();
android.updateRoomList();
CHAT_UI.refreshRoomList();
$('#createChatRoom').show();
} else {
//オフラインの場合、DBからルーム一覧を表示。
if (CHAT_UTIL.isIOS()) {
......@@ -78,7 +81,7 @@ function setSocketAction () {
* ---------------------------------------------------------------------- */
// Update Room List
socket.on('refreshRoomList', function(rooms, activeRoomId = null){
socket.on('refreshRoomList--', function(rooms, activeRoomId = null){
CHAT.globalIsInvite = false;
......
......@@ -38,8 +38,13 @@ 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.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
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;
......@@ -60,6 +65,7 @@ import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.viewer.activity.ParentWebViewActivity;
import jp.agentec.adf.net.http.HttpResponse;
import static org.chromium.net.NetError.ERR_FAILED;
......@@ -681,22 +687,15 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public String getRoomList() {
Map<String, Object> chatRoomList;
//chatRoomList = communicationLogic.getChatRoomList();
String chatRoomListStr = communicationLogic.getChatRoomList();
return chatRoomListStr;
/* mChatWebView.post(new Runnable() {
@Override
public void run() {
List<ChatRoomDto> chatRoomList;
chatRoomList = communicationLogic.getChatRoomList();
JSONArray resulttest = new JSONArray(chatRoomList);
String resultString = resulttest.toString();
mChatWebView.loadUrl(String.format("javascript:CHAT_UI.getRoomList('%s')",resultString));
}
});*/
}
@JavascriptInterface
public void updateRoomList() throws NetworkDisconnectedException, AcmsException {
Map<String, Object> chatRoomList;
RoomListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getRoomList(sid);
communicationLogic.insertChatRoomList(resultJson.roomList);
}
}
......
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