Commit 2a46bae2 by Lee Munkyeong

連絡先DB追加

parent 26ede701
......@@ -22,8 +22,10 @@ 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;
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.MyInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.NewAppStoreLoginJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationGroupMasterJSON;
......@@ -35,6 +37,7 @@ 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;
......@@ -541,6 +544,34 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* ログインしたユーザの情報を取得する。
*
* @param sid
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public MyInfoJSON getMyInfo(String sid) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new AcmsParameters(sid,AcmsApis.Cmds.getMyInfo));
MyInfoJSON json = new MyInfoJSON(response.httpResponseBody);
return json;
}
/**
* 全てのグループ更新。
*
* @param sid
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public GroupListJSON getGroupInfo(String sid) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new AcmsParameters(sid,AcmsApis.Cmds.getGroupInfo));
GroupListJSON json = new GroupListJSON(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;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.adf.util.DateTimeUtil;
public class GroupListJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String GROUP_INFO_LIST = "groupInfoList";
private static final String GROUP_ID = "groupId";
private static final String GROUP_NAME = "groupName";
private static final String PARENT_GROUP_ID = "parentGroupId";
private static final String DEL_FLG = "delFlg";
public ArrayList<GroupDto> groupList;
public GroupListJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (!json.has(Body)) { return; }
JSONArray GroupListJsonArray = json.getJSONObject(Body).getJSONArray(GROUP_INFO_LIST);
if (GroupListJsonArray == null) { return; }
groupList = new ArrayList<GroupDto>();
for (int listCount = 0; listCount < GroupListJsonArray.length(); listCount++) {
if (GroupListJsonArray.getJSONObject(listCount).length() == 0) {
break;
}
GroupDto groupDto = new GroupDto();
groupDto.groupId = GroupListJsonArray.getJSONObject(listCount).getInt(GROUP_ID);
groupDto.parentGroupId = GroupListJsonArray.getJSONObject(listCount).getInt(PARENT_GROUP_ID);
groupDto.groupName = GroupListJsonArray.getJSONObject(listCount).getString(GROUP_NAME);
groupDto.delFlg = GroupListJsonArray.getJSONObject(listCount).getInt(DEL_FLG);
groupList.add(groupDto);
}
}
}
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.ShopMemberDto;
public class MyInfoJSON extends AcmsCommonJSON {
private static final String BODY = "body";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MEMBER_NAME = "memberName";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
private static final String GROUP_ID_LIST = "groupIdList";
private static final Integer SELF_FLG_ON = 1;
public ShopMemberDto shopMemberDto;
public MyInfoJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
if (!json.has(BODY)) { return; }
JSONObject MyInfoJson = json.getJSONObject(BODY);
if (MyInfoJson == null) { return; }
shopMemberDto = new ShopMemberDto();
ArrayList<Integer> groupIdList = new ArrayList<Integer>();
JSONArray groupIdJsonArray = (JSONArray) MyInfoJson.get(GROUP_ID_LIST);
for (int i = 0; i < groupIdJsonArray.length(); i++) {
groupIdList.add(groupIdJsonArray.getInt(i));
}
shopMemberDto.groupIdList = groupIdList;
shopMemberDto.selfFlg = SELF_FLG_ON;
shopMemberDto.favoriteRegisterDate = null;
shopMemberDto.profileUrl = MyInfoJson.getString(PROFILE_IMAGE_PATH);
shopMemberDto.shopMemberId = MyInfoJson.getInt(SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = MyInfoJson.getString(MEMBER_NAME);
}
}
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;
import jp.agentec.adf.util.DateTimeUtil;
public class ShopMemberListJSON extends AcmsCommonJSON {
private static final String Body = "body";
private static final String ChatRoomInfoList = "chatRoomInfoList";
private static final String InsertDate = "insertDate";
private static final String Time = "time";
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 ShopMemberListJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (!json.has(Body)) { return; }
JSONArray roomListJsonArray = json.getJSONObject(Body).getJSONArray(ChatRoomInfoList);
if (roomListJsonArray == null) { return; }
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).has(UnreadCount) ? roomListJsonArray.getJSONObject(listCount).getInt(UnreadCount) : 0;
chatRoomDto.userCount = roomListJsonArray.getJSONObject(listCount).getJSONArray(AttendUsers).length();
//最後メッセージ情報がある場合の処理
JSONObject lastMessageInfoJSON = roomListJsonArray.getJSONObject(listCount).has(LastMessageInfo) ? roomListJsonArray.getJSONObject(listCount).getJSONObject(LastMessageInfo) : null;
if (lastMessageInfoJSON != null && lastMessageInfoJSON.has(MessageId)) {
chatMessageDto.chatRoomId = chatRoomDto.chatRoomId;
chatMessageDto.message = lastMessageInfoJSON.getString(Message);
chatMessageDto.messageType = lastMessageInfoJSON.getInt(MessageType);
if (lastMessageInfoJSON.has(InsertDate)) {
chatMessageDto.insertDate = DateTimeUtil.millToDateString(lastMessageInfoJSON.getJSONObject(InsertDate).getLong(Time));
}
chatMessageDto.shopMemberId = lastMessageInfoJSON.getInt(ShopMemberId);
chatMessageDto.chatMessageId = lastMessageInfoJSON.getInt(MessageId);
chatRoomDto.lastMessageInfo = chatMessageDto;
}
roomList.add(chatRoomDto);
}
}
}
......@@ -171,9 +171,12 @@ 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 String ApigetUser = "user";
public static final class Cmds {
public static final String getRoomList = "5";
public static final String getMyInfo = "9";
public static final String getGroupInfo = "10";
}
// download
......@@ -222,7 +225,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)) { // pushActionはchatapiを指定
} else if (methodName.equals(ApiGetChatPushData) || methodName.equals(ApigetChatRooms) || methodName.equals(ApigetUser)) { // pushActionはchatapiを指定
apiValue = Constant.ApiValue.chatapi;
}
......
......@@ -512,4 +512,59 @@ public class GroupDao extends AbstractDao {
return userGroupList.get(0).groupId;
}
public void insertGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" INSERT OR IGNORE INTO m_group (group_id, parent_group_id, group_name, group_path, group_level, user_group_flg) ");
sql.append(" VALUES (?,?,?,?,?,?) ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
insert(sql.toString(), new Object[] { groupDto.groupId, groupDto.parentGroupId, groupDto.groupName, "", 0, 0 });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("insertGroupList failed.", e);
throw new RuntimeException(e);
}
}
public void updateGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE m_group ");
sql.append(" SET group_name = ? ");
sql.append(" , parent_group_id = ? ");
sql.append(" WHERE group_id = ? ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
update(sql.toString(), new Object[] { groupDto.groupName, groupDto.parentGroupId, groupDto.groupId });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("updateGroupList failed.", e);
throw new RuntimeException(e);
}
}
public void deleteGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" delete from m_group ");
sql.append(" WHERE group_id = ? ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
update(sql.toString(), new Object[] { groupDto.groupId });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("deleteGroupList failed.", e);
throw new RuntimeException(e);
}
}
}
......@@ -57,8 +57,21 @@ public class ShopMemberDao extends AbstractDao {
public ShopMemberDto getShopMember(int shopMemberId) {
return rawQueryGetDto("select * from m_shop_member where shop_member_id=?", new String[]{""+ shopMemberId}, ShopMemberDto.class);
}
public void insertShopMember(ShopMemberDto dto) {
insert("insert into m_shop_member (shop_member_id, shop_member_name, profile_url, favorite_register_date, self_flg) values (?,?,?,?,?)", dto.getInsertValues());
try {
beginTransaction();
insert("insert 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());
}
commit();
} catch (Exception e) {
rollback();
Logger.e("insertShopMember failed.", e);
throw new RuntimeException(e);
} finally {
}
}
public ShopMemberDto getMyInfo() {
......
......@@ -20,7 +20,7 @@ public class MShopMember extends SQLiteTableScript {
sql.append(" , shop_member_name VARCHAR(64) ");
sql.append(" , profile_url VARCHAR(64) ");
sql.append(" , favorite_register_date VARCHAR2(64) ");
sql.append(" self_flg INTEGER NOT NULL ");
sql.append(" , self_flg INTEGER NOT NULL ");
sql.append(" , PRIMARY KEY (shop_member_id) ");
sql.append(" ) ");
......
package jp.agentec.abook.abv.bl.data.tables;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
public class RChatRoomShopMember extends SQLiteTableScript {
public RChatRoomShopMember() {
super();
}
@Override
public List<String> getCreateScript(int version) {
List<String> ddl = new ArrayList<String>();
StringBuffer sql = new StringBuffer();
sql.append(" create table r_chat_room_shop_member ( ");
sql.append(" chat_room_id INTEGER NOT NULL ");
sql.append(" , shop_member_id INTEGER NOT NULL ");
sql.append(" , PRIMARY KEY (chat_room_id, shop_member_id) ");
sql.append(" ) ");
ddl.add(sql.toString());
return ddl;
}
@Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) {
return null;
}
@Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object... params) {
return null;
}
}
......@@ -16,7 +16,8 @@ public class GroupDto extends AbstractDto {
public String displayCount;
public String groupPath;
public boolean userGroupFlg;
public int delFlg;
public GroupDto() {
}
......
package jp.agentec.abook.abv.bl.dto;
import java.util.ArrayList;
import java.util.Date;
public class ShopMemberDto extends AbstractDto {
......@@ -8,6 +9,7 @@ public class ShopMemberDto extends AbstractDto {
public String profileUrl;
public String favoriteRegisterDate;
public Integer selfFlg;
public ArrayList<Integer> groupIdList;
@Override
public Object[] getInsertValues() {
......@@ -24,4 +26,8 @@ public class ShopMemberDto extends AbstractDto {
return new String[]{ "" + shopMemberId };
}
public Object[] getGroupIds() {
return groupIdList.toArray();
}
}
......@@ -35,11 +35,15 @@ import jp.agentec.abook.abv.bl.data.dao.ContentMarkingDao;
import jp.agentec.abook.abv.bl.data.dao.ContentPageDao;
import jp.agentec.abook.abv.bl.data.dao.ContentResourceDao;
import jp.agentec.abook.abv.bl.data.dao.ContentTagDao;
import jp.agentec.abook.abv.bl.data.dao.GroupDao;
import jp.agentec.abook.abv.bl.data.dao.ShopMemberDao;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.ContentPageDto;
import jp.agentec.abook.abv.bl.dto.ContentTagDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.abook.abv.bl.dto.comparator.ContentPageDtoComparator;
import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil;
......@@ -52,6 +56,8 @@ public class CommunicationLogic extends AbstractLogic {
private ChatRoomDao chatRoomDao = AbstractDao.getDao(ChatRoomDao.class);
private ChatMessageDao chatMessageDao = AbstractDao.getDao(ChatMessageDao.class);
private ShopMemberDao shopMemberDao = AbstractDao.getDao(ShopMemberDao.class);
private GroupDao groupDao = AbstractDao.getDao(GroupDao.class);
/**
* {@link CommunicationLogic} クラスのインスタンスを初期化します。
......@@ -97,8 +103,37 @@ public class CommunicationLogic extends AbstractLogic {
chatMessageDao.insertChatMessage(insertMessageList);
}
public void insertShopMember(ShopMemberDto shopMemberDto) {
shopMemberDao.insertShopMember(shopMemberDto);
}
public void updateGroup(List<GroupDto> GroupList) {
List<GroupDto> existGroupList = groupDao.getAllGroups();
ArrayList<GroupDto> insertGroupList = new ArrayList<GroupDto>();
ArrayList<GroupDto> deleteGroupList = new ArrayList<GroupDto>();
ArrayList<GroupDto> updateGroupList = new ArrayList<GroupDto>();
for (GroupDto groupDto : GroupList) {
if (groupDto.delFlg == 1) {
deleteGroupList.add(groupDto);
continue;
}
if ( groupDao.getGroup(groupDto.groupId) == null ) {
insertGroupList.add(groupDto);
} else {
updateGroupList.add(groupDto);
}
}
groupDao.insertGroupList(insertGroupList);
groupDao.updateGroupList(updateGroupList);
groupDao.deleteGroupList(deleteGroupList);
}
public void deleteChatRoomList() {
chatRoomDao.deleteChatRoom();
}
}
......@@ -39,7 +39,10 @@ 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.GroupListJSON;
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;
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;
......@@ -698,6 +701,20 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
communicationLogic.deleteChatRoomList();
communicationLogic.insertChatRoomList(resultJson.roomList);
}
@JavascriptInterface
public void updateMyInfo() throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
communicationLogic.insertShopMember(resultJson.shopMemberDto);
}
@JavascriptInterface
public void updateGroupInfo() throws NetworkDisconnectedException, AcmsException {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid);
communicationLogic.updateGroup(resultJson.groupList);
}
}
/**
......
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