Commit 1164f170 by Lee Munkyeong

お気に入りAPI移行

parent 16d53379
......@@ -23,6 +23,7 @@ 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.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.FixPushMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GetFavoriteUserJSON;
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;
......@@ -54,11 +55,13 @@ 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.GetFavoriteParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetGroupInfoParameters;
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.InsertFavoriteParameters;
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;
......@@ -625,6 +628,31 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* お気に入り追加。。
*
* @param sid
* @param shopMemberId
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public boolean insertFavoriteUser(String sid, Integer shopMemberId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetFavorite, new InsertFavoriteParameters(sid, AcmsApis.FavoriteCmds.addFavoriteUser, shopMemberId));
return response.httpResponseCode == 200;
}
public boolean deleteFavoriteUser(String sid, Integer shopMemberId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetFavorite, new InsertFavoriteParameters(sid, AcmsApis.FavoriteCmds.removeFavoriteUser, shopMemberId));
return response.httpResponseCode == 200;
}
public GetFavoriteUserJSON getFavoriteUser(String sid) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetFavorite, new GetFavoriteParameters(sid, AcmsApis.FavoriteCmds.getFavoriteUser));
GetFavoriteUserJSON json = new GetFavoriteUserJSON(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 java.util.List;
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 GetFavoriteUserJSON extends AcmsCommonJSON {
public List<Integer> favoriteUserIds;
public GetFavoriteUserJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
JSONObject responseBodyObject = json.getJSONObject(ABookCommConstants.KEY.BODY);
if (responseBodyObject == null) { return; }
JSONArray favoriteIds = responseBodyObject.getJSONArray(ABookCommConstants.KEY.FAVORITE_USER_IDS);
if (favoriteIds == null || favoriteIds.length() == 0) {
return;
}
favoriteUserIds = new ArrayList<Integer>();
for (int count = 0; count < favoriteIds.length(); count++) {
favoriteUserIds.add((Integer)favoriteIds.get(count));
}
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link GetFavoriteParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author Taejin Hong
* @version 1.0.0
*/
public class GetFavoriteParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
/**
* {@link GetFavoriteParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @since 1.0.0
*/
public GetFavoriteParameters(String sid) {
this.sid = sid;
}
/**
* {@link GetFavoriteParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public GetFavoriteParameters(String sid, String cmd) {
this.sid = sid;
this.cmd = cmd;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link InsertFavoriteParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author Taejin Hong
* @version 1.0.0
*/
public class InsertFavoriteParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private Integer targetUserId;
/**
* {@link InsertFavoriteParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public InsertFavoriteParameters(String sid, String cmd, Integer targetUserId) {
this.sid = sid;
this.cmd = cmd;
this.targetUserId = targetUserId;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
public Integer getTargetUserId() {
return targetUserId;
}
}
......@@ -173,6 +173,7 @@ public class AcmsApis {
public static final String ApigetChatRooms = "room";
public static final String ApigetUser = "user";
public static final String ApigetMessage = "message";
public static final String ApigetFavorite = "favorite";
public static final class UserCmds {
public static final String getMyInfo = "9";
......@@ -189,6 +190,15 @@ public class AcmsApis {
public static final String getMessages = "2";
}
public static final class FavoriteCmds {
public static final String addFavoriteUser = "1";
public static final String addFavoriteGroup = "2";
public static final String getFavoriteUser = "4";
public static final String getFavoriteGroup = "5";
public static final String removeFavoriteUser = "7";
public static final String removeFavoriteGroup = "8";
}
// download
/**
* コンテンツのZIPファイルを取得<br>
......@@ -235,7 +245,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) || methodName.equals(ApigetMessage)) { // pushActionはchatapiを指定
} else if (methodName.equals(ApiGetChatPushData) || methodName.equals(ApigetChatRooms) || methodName.equals(ApigetUser) || methodName.equals(ApigetMessage) || methodName.equals(ApigetFavorite)) { // pushActionはchatapiを指定
apiValue = Constant.ApiValue.chatapi;
}
......
......@@ -49,6 +49,7 @@ public interface ABookCommConstants {
String GROUP_MEMBER_LIST = "groupMemberList";
String CHAT_ROOM_INFO_LIST = "chatRoomInfoList";
String LAST_MESSAGE_INFO = "lastMessageInfo";
String FAVORITE_USER_IDS = "favoriteUserIds";
String ROOT_GROUP_ID = "rootGroupId";
......
......@@ -61,7 +61,7 @@ public class ShopMemberDao extends AbstractDao {
public void insertShopMember(ShopMemberDto dto) {
try {
beginTransaction();
insert("insert or replace 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, self_flg, favorite_register_date) values (?,?,?,?,(select favorite_register_date from m_shop_member where shop_member_id = ?))", dto.getInsertValues());
update(" delete from r_shop_member_group WHERE shop_member_id = ? ", new Integer[]{dto.shopMemberId});
for (Integer groupId : dto.groupIdList) {
......@@ -80,7 +80,7 @@ public class ShopMemberDao extends AbstractDao {
try {
beginTransaction();
for (ShopMemberDto dto : dtoList) {
insert("insert or replace 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, self_flg, favorite_register_date) values (?,?,?,?, (select favorite_register_date from m_shop_member where shop_member_id = ?))", dto.getInsertValues());
if (dto.groupIdList == null) { continue; }
for (Integer groupId : dto.groupIdList) {
insert("insert or replace into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", new Integer[]{groupId});
......@@ -109,6 +109,7 @@ public class ShopMemberDao extends AbstractDao {
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 ");
......@@ -137,8 +138,13 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public boolean updateShopMember(MemberInfoDto dto) {
long count = update("update m_shop_member set shop_member_name=?, profile_url=?, favorite_register_date=? where shop_member_id=?", dto.getUpdateValues());
public boolean updateShopMember(ShopMemberDto dto) {
long count = update("update m_shop_member set shop_member_name=?, profile_url=? where shop_member_id=?", dto.getUpdateValues());
return count > 0;
}
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;
}
......
......@@ -13,12 +13,12 @@ public class ShopMemberDto extends AbstractDto {
@Override
public Object[] getInsertValues() {
return new Object[] { shopMemberId, shopMemberName, profileUrl, favoriteRegisterDate, selfFlg };
return new Object[] { shopMemberId, shopMemberName, profileUrl, selfFlg , shopMemberId};
}
@Override
public Object[] getUpdateValues() {
return new Object[] { shopMemberName, profileUrl, favoriteRegisterDate, shopMemberId };
return new Object[] { shopMemberName, profileUrl, shopMemberId };
}
@Override
......
......@@ -4,6 +4,7 @@ import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -18,6 +19,7 @@ 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.DateTimeUtil;
import jp.agentec.adf.util.StringUtil;
/**
......@@ -115,17 +117,30 @@ public class CommunicationLogic extends AbstractLogic {
}
public String getMyGroupUsers() {
List<ShopMemberDto> myGroupUsers = shopMemberDao.getMyGroupUsers();
List<GroupDto> myGroupIds = groupDao.getUserGroups();
JSONArray myGroupUsersJson = new JSONArray();
for (ShopMemberDto myGroupUser : myGroupUsers) {
List<String> groupPathList = groupDao.getUserGroupPathList(myGroupUser.shopMemberId);
Map<String, Object> myGroupUserMap = new HashMap<String, Object>();
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, myGroupUser.shopMemberId);
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, myGroupUser.shopMemberName);
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, myGroupUser.profileUrl);
myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
JSONObject jsonObject = new JSONObject(myGroupUserMap);
myGroupUsersJson.put(jsonObject);
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.getUserListByGroupId(groupDto.groupId);
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.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;
......@@ -159,6 +174,7 @@ public class CommunicationLogic extends AbstractLogic {
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, favoriteUser.shopMemberName);
favoriteUserMap.put(ABookCommConstants.KEY.PROFILE_URL, favoriteUser.profileUrl);
favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
JSONObject jsonObject = new JSONObject(favoriteUserMap);
resultJsonArray.put(jsonObject);
}
......@@ -176,6 +192,7 @@ public class CommunicationLogic extends AbstractLogic {
Map<String, Object> favoriteGroupMap = new HashMap<String, Object>();
favoriteGroupMap.put(ABookCommConstants.KEY.GROUP_NAME, favoriteGroup.groupName);
favoriteGroupMap.put(ABookCommConstants.KEY.GROUP_ID, favoriteGroup.groupId);
favoriteGroupMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
JSONObject jsonObject = new JSONObject(favoriteGroupMap);
resultJsonArray.put(jsonObject);
}
......@@ -333,5 +350,21 @@ public class CommunicationLogic extends AbstractLogic {
shopMemberDao.insertShopMember(shopMemberDto);
}
public void updateFavoriteUser(List<Integer> favoriteUserIds){
for (Integer favoriteUserId : favoriteUserIds) {
ShopMemberDto favoriteUserDto= new ShopMemberDto();
favoriteUserDto.shopMemberId = favoriteUserId;
favoriteUserDto.favoriteRegisterDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(new Date(System.currentTimeMillis()));
shopMemberDao.updateFavoriteUser(favoriteUserDto);
}
}
public void deleteavoriteUser(List<Integer> favoriteUserIds){
for (Integer favoriteUserId : favoriteUserIds) {
ShopMemberDto favoriteUserDto= new ShopMemberDto();
favoriteUserDto.shopMemberId = favoriteUserId;
favoriteUserDto.favoriteRegisterDate = null;
shopMemberDao.updateFavoriteUser(favoriteUserDto);
}
}
}
......@@ -29,12 +29,14 @@ import android.widget.LinearLayout;
import android.widget.Toast;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
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.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GetFavoriteUserJSON;
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;
......@@ -76,9 +78,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private final String TAG = "ChatWebviewActivity";
private final String NETWORK_ERROR_PLACE_HOLDER = "file:///android_asset/chat/public/index.html";
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/index.html";
private final String CHAT_PAGE_URL = "file:///android_asset/chat/public_new/chat.html";
private final String DEFAULT_CHECKSUM = "0000000000";
//AISDevelop
......@@ -128,6 +130,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
chatWebviewUrl = CHAT_PAGE_URL;
updateMyInfoFromServer();
updateAllGroupInfo();
updateFavoriteInfo();
}
} catch (Exception e) {
Logger.d("SID_CHECK_ERROR");
......@@ -799,6 +802,37 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
String favoriteGroupsListStr = communicationLogic.getFavoriteGroups();
return favoriteGroupsListStr;
}
@JavascriptInterface
public void addFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = insertFavoriteUser(shopMemberId);
if (result) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
}
}
@JavascriptInterface
public void removeFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = deleteFavoriteUser(shopMemberId);
if (result) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
}
}
@JavascriptInterface
public void updateFavorite() throws NetworkDisconnectedException, AcmsException {
updateFavoriteInfo();
}
}
/**
......@@ -823,11 +857,31 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
communicationLogic.insertShopMember(resultJson.shopMemberDto);
}
private boolean insertFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).insertFavoriteUser(sid,Integer.parseInt(shopMemberId));
return result;
}
private boolean deleteFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).deleteFavoriteUser(sid,Integer.parseInt(shopMemberId));
if (result) {
List<Integer> deleteFavoriteList = new ArrayList<Integer>();
deleteFavoriteList.add(Integer.parseInt(shopMemberId));
communicationLogic.deleteavoriteUser(deleteFavoriteList);
}
return result;
}
private void updateGroupInfoFromServer(String groupIds) throws NetworkDisconnectedException, AcmsException {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,groupIds,DEFAULT_CHECKSUM);
communicationLogic.updateGroup(resultJson.groupList);
}
private void updateFavoriteUser() throws NetworkDisconnectedException, AcmsException {
GetFavoriteUserJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getFavoriteUser(sid);
communicationLogic.updateFavoriteUser(resultJson.favoriteUserIds);
}
private void updateAllGroupInfo() throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString());
List<GroupDto> groupList = communicationLogic.getAllGroup();
......@@ -835,6 +889,15 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
updateGroupInfoFromServer(Integer.toString(group.groupId));
}
}
private void updateFavoriteInfo() throws NetworkDisconnectedException, AcmsException {
updateFavoriteUser();
/*List<GroupDto> groupList = communicationLogic.getAllGroup();
for (GroupDto group : groupList) {
updateGroupInfoFromServer(Integer.toString(group.groupId));
}*/
}
/** 
* ボタンイベント設定
*/
......
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