Commit 8d3bc5b8 by Lee Munkyeong

Merge branch 'features/abcomm_sp5_group_search_UI' into 'features/abcomm_sp5'

Features/abcomm sp5 group search ui

See merge request !94
parents c10ae0b2 9816e8e3
......@@ -23,6 +23,8 @@ 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.GetFavoriteGroupJSON;
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;
......@@ -51,9 +53,12 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.DeleteProcessParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.EnqueteReplyParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.EnterpriseLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.EnterpriseNewLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.FavoriteGroupParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.FavoriteUserParameters;
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;
......@@ -603,8 +608,8 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public CreatedRoomJSON createRoom(String sid, String roomType, String inviteMemberIds, String newRoomName) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new CreateRoomParameters(sid, AcmsApis.RoomCmds.createRoom, roomType, inviteMemberIds, newRoomName));
public CreatedRoomJSON createRoom(String sid, String roomType, String inviteMemberIds, String newRoomName, String memberName) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetChatRooms, new CreateRoomParameters(sid, AcmsApis.RoomCmds.createRoom, roomType, inviteMemberIds, newRoomName, memberName));
CreatedRoomJSON json = new CreatedRoomJSON(response.httpResponseBody);
return json;
}
......@@ -625,6 +630,90 @@ 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 FavoriteUserParameters(sid, AcmsApis.FavoriteCmds.addFavoriteUser, shopMemberId));
return response.httpResponseCode == 200;
}
/**
* お気に入りユーザ削除。。
*
* @param sid
* @param shopMemberId
* @return 成功有無
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public boolean deleteFavoriteUser(String sid, Integer shopMemberId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetFavorite, new FavoriteUserParameters(sid, AcmsApis.FavoriteCmds.removeFavoriteUser, shopMemberId));
return response.httpResponseCode == 200;
}
/**
* お気に入りグループ追加。
*
* @param sid
* @param groupId
* @return 成功有無
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public boolean insertFavoriteGroup(String sid, Integer groupId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetFavorite, new FavoriteGroupParameters(sid, AcmsApis.FavoriteCmds.addFavoriteGroup, groupId));
return response.httpResponseCode == 200;
}
/**
* お気に入りグループ削除。
*
* @param sid
* @param groupId
* @return 成功有無
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public boolean deleteFavoriteGroup(String sid, Integer groupId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetFavorite, new FavoriteGroupParameters(sid, AcmsApis.FavoriteCmds.removeFavoriteGroup, groupId));
return response.httpResponseCode == 200;
}
/**
* お気に入りユーザ取得。
*
* @param sid
* @return お気に入りユーザのIDリスト。
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
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
* @return お気に入りグループのIDリスト。
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public GetFavoriteGroupJSON getFavoriteGroup(String sid) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetFavorite, new GetFavoriteParameters(sid, AcmsApis.FavoriteCmds.getFavoriteGroup));
GetFavoriteGroupJSON json = new GetFavoriteGroupJSON(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;
public class GetFavoriteGroupJSON extends AcmsCommonJSON {
public List<Integer> favoriteGroupIds;
public GetFavoriteGroupJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
favoriteGroupIds = new ArrayList<Integer>();
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_GROUP_IDS);
if (favoriteIds == null || favoriteIds.length() == 0) {
return;
}
for (int count = 0; count < favoriteIds.length(); count++) {
favoriteGroupIds.add((Integer)favoriteIds.get(count));
}
}
}
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 {
favoriteUserIds = new ArrayList<Integer>();
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;
}
for (int count = 0; count < favoriteIds.length(); count++) {
favoriteUserIds.add((Integer)favoriteIds.get(count));
}
}
}
......@@ -18,6 +18,7 @@ public class GroupListJSON extends AcmsCommonJSON {
public ArrayList<GroupDto> groupList;
public String allGroupLastUpdateDate;
public GroupListJSON(String jsonString) throws AcmsException {
super(jsonString);
......@@ -28,6 +29,7 @@ public class GroupListJSON extends AcmsCommonJSON {
// ルーム一覧情報を取得
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
if (!json.getJSONObject(ABookCommConstants.KEY.BODY).has(ABookCommConstants.KEY.GROUP_INFO_LIST)) { return; }
JSONArray groupListJsonArray = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONArray(ABookCommConstants.KEY.GROUP_INFO_LIST);
if (groupListJsonArray == null) { return; }
......@@ -47,7 +49,9 @@ public class GroupListJSON extends AcmsCommonJSON {
}
groupDto.groupName = groupJSON.getString(ABookCommConstants.KEY.GROUP_NAME);
groupDto.delFlg = groupJSON.getInt(ABookCommConstants.KEY.DEL_FLG);
if (groupJSON.has(ABookCommConstants.KEY.GROUP_INFO_LAST_UPDATE_DATE)) {
groupDto.updateDate = groupJSON.getString(ABookCommConstants.KEY.GROUP_INFO_LAST_UPDATE_DATE);
}
if (groupJSON.has(ABookCommConstants.KEY.GROUP_MEMBER_LIST)) {
JSONArray groupMemberJsonArray = groupJSON.getJSONArray(ABookCommConstants.KEY.GROUP_MEMBER_LIST);
ArrayList<ShopMemberDto> groupMembers = new ArrayList<ShopMemberDto>();
......@@ -69,6 +73,10 @@ public class GroupListJSON extends AcmsCommonJSON {
}
groupList.add(groupDto);
}
if (json.getJSONObject(ABookCommConstants.KEY.BODY).has(ABookCommConstants.KEY.GROUP_INFO_LAST_UPDATE_DATE)) {
allGroupLastUpdateDate = json.getJSONObject(ABookCommConstants.KEY.BODY).getString(ABookCommConstants.KEY.GROUP_INFO_LAST_UPDATE_DATE);
}
}
}
......@@ -57,6 +57,13 @@ public class RoomListJSON extends AcmsCommonJSON {
chatMessageDto.chatMessageId = lastMessageInfoJSON.getInt(ABookCommConstants.KEY.MESSAGE_ID);
chatRoomDto.lastMessageInfo = chatMessageDto;
}
JSONArray attendUsers = roomListJsonArray.getJSONObject(listCount).getJSONArray(ABookCommConstants.KEY.ATTEND_USERS);
ArrayList<Integer> attendUserList = new ArrayList<Integer>();
for (int attendUserCount = 0; attendUserCount < attendUsers.length(); attendUserCount++) {
attendUserList.add((Integer) attendUsers.get(attendUserCount));
}
chatRoomDto.attendUsers = attendUserList;
roomList.add(chatRoomDto);
}
}
......
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 UserUpdateJSON extends AcmsCommonJSON {
public ShopMemberDto shopMemberDto;
public UserUpdateJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
JSONObject UserInfoJson = json.getJSONObject(ABookCommConstants.KEY.BODY);
if (UserInfoJson == null) { return; }
shopMemberDto = new ShopMemberDto();
ArrayList<Integer> groupIdList = new ArrayList<Integer>();
JSONArray groupIdJsonArray = (JSONArray) UserInfoJson.get(ABookCommConstants.KEY.GROUP_IDS);
for (int i = 0; i < groupIdJsonArray.length(); i++) {
groupIdList.add(groupIdJsonArray.getInt(i));
}
shopMemberDto.groupIdList = groupIdList;
}
}
......@@ -19,6 +19,8 @@ public class CreateRoomParameters extends HttpParameterObject {
private String roomType;
private String inviteMemberIds;
private String newRoomName;
private String memberName;
/**
* {@link CreateRoomParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
......@@ -34,12 +36,13 @@ public class CreateRoomParameters extends HttpParameterObject {
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public CreateRoomParameters(String sid, String cmd, String roomType, String inviteMemberIds, String newRoomName) {
public CreateRoomParameters(String sid, String cmd, String roomType, String inviteMemberIds, String newRoomName, String memberName) {
this.sid = sid;
this.cmd = cmd;
this.roomType = roomType;
this.inviteMemberIds = inviteMemberIds;
this.newRoomName = newRoomName;
this.memberName = memberName;
}
/**
......@@ -71,4 +74,8 @@ public class CreateRoomParameters extends HttpParameterObject {
public String getNewRoomName() {
return newRoomName;
}
public String getMemberName() {
return memberName;
}
}
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 FavoriteGroupParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private Integer targetGroupId;
/**
* {@link FavoriteGroupParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @param targetGroupId お気に入りリクエスト対象になるグループID。
* @since 1.0.0
*/
public FavoriteGroupParameters(String sid, String cmd, Integer targetGroupId) {
this.sid = sid;
this.cmd = cmd;
this.targetGroupId = targetGroupId;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return コマンド。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
/**
* 対象グループIDを返します。
* @return 対象グループID。
* @since 1.0.0
*/
public Integer getTargetGroupId() {
return targetGroupId;
}
}
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 FavoriteUserParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private Integer targetUserId;
/**
* {@link FavoriteUserParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @param targetUserId お気に入りリクエスト対象になるユーザのID。
* @since 1.0.0
*/
public FavoriteUserParameters(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 コマンド。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
/**
* 対象ユーザIDを返します。
* @return 対象ユーザID。
* @since 1.0.0
*/
public Integer getTargetUserId() {
return targetUserId;
}
}
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;
}
}
......@@ -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;
}
......
......@@ -6,6 +6,8 @@ package jp.agentec.abook.abv.bl.common.constant;
public interface ABookCommConstants {
String TAG = "ABookComm";
//AbookComm専用の共通インターフェース
interface KEY {
String CHAT_ROOM_ID = "chatRoomId";
......@@ -25,7 +27,9 @@ public interface ABookCommConstants {
String PROFILE_URL = "profileUrl";
String GROUP_NAME = "groupName";
String GROUP_ID = "groupId";
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";
......@@ -35,7 +39,7 @@ public interface ABookCommConstants {
String ROOM_NAME = "roomName";
String ATTEND_USERS = "attendUsers";
String MEMBER_NAME = "memberName";
String DEL_FLG = "del_flg";
String DEL_FLG = "delFlg";
String ROOM_TYPE = "roomType";
String GROUP_ID_LIST = "groupIdList";
String MESSAGE_INFO_LIST = "messageInfoList";
......@@ -47,6 +51,21 @@ 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 FAVORITE_GROUP_IDS = "favoriteGroupIds";
String GROUP_INFO_LAST_UPDATE_DATE = "groupInfoLastUpdateDate";
String ROOT_GROUP_ID = "rootGroupId";
interface API_KIND {
String USER = "user";
String ROOM = "room";
String GROUP = "group";
String CHAT = "chat";
String FILE = "file";
String COLLABORATION = "collaboration";
}
}
interface FLAG {
......@@ -54,5 +73,7 @@ public interface ABookCommConstants {
Integer OFF = 0;
Integer ON = 1;
}
Integer GROUP_REQUEST_ALL = 0;
}
}
package jp.agentec.abook.abv.bl.common.util;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtil {
public String getNowByFormat(String format) {
SimpleDateFormat format1 = new SimpleDateFormat (format);
Date time = new Date();
return format1.format(time);
}
}
......@@ -81,7 +81,7 @@ public class ChatRoomDao extends AbstractDao {
sql.append(" ON cr.chat_room_id = cm.chat_room_id ");
sql.append(" WHERE cr.type =? ");
sql.append(" GROUP BY cr.chat_room_id ");
sql.append(" ORDER BY unread_count, cm.insert_date DESC ");
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;
}
......@@ -103,6 +103,7 @@ public class ChatRoomDao extends AbstractDao {
beginTransaction();
for (ChatRoomDto chatRoomDto : chatRoomDtoList) {
insertChatRoom(chatRoomDto);
insertChatRoomUsers(chatRoomDto.attendUsers, chatRoomDto.chatRoomId);
}
commit();
} catch (Exception e) {
......@@ -112,6 +113,12 @@ public class ChatRoomDao extends AbstractDao {
}
}
public void insertChatRoomUsers(List<Integer> attendUsers, Integer chatRoomId) {
for (Integer attendUserId : attendUsers) {
insert("insert or replace into r_chat_room_shop_member (chat_room_id, shop_member_id) values (?,?)", new Integer[]{chatRoomId, attendUserId});
}
}
public boolean updateChatRoom(ChatRoomDto dto) {
long count = update("update t_chat_room set chat_room_name=?, type=?, unread_count=?, user_count=?, favorite_register_date=? where chat_room_id=?", dto.getUpdateValues());
return count > 0;
......
......@@ -90,6 +90,23 @@ public class GroupDao extends AbstractDao {
return rawQueryGetStringList(sql.toString(), null);
}
public List<String> 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(" 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 ");
sql.append(" WHERE usergroup.group_id IN ");
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});
}
private String generateGetGroupsQuery(QueryType queryType, int[] groupRelationids, int[] parentGroupIds, Boolean downloaded, String searchKeyword, SearchDivisionType searchDivisionType, boolean isOnlineSearched) {
StringBuffer sql = new StringBuffer();
......@@ -501,6 +518,10 @@ public class GroupDao extends AbstractDao {
return rawQueryGetDtoList("select * from m_group where favorite_register_date IS NOT NULL ORDER BY favorite_register_date ", null, GroupDto.class);
}
public List<GroupDto> getGroupByName(String groupName) {
return rawQueryGetDtoList("select * from m_group where group_name LIKE '%"+groupName+"%'ORDER BY group_id ", null, GroupDto.class);
}
public List<GroupDto> getGroupSpareList(int baseId, int parentId) {
List<GroupDto> list;
list = rawQueryGetDtoList("select * from m_group mg where (mg.group_id = ?) UNION select * from m_group mg where (mg.parent_group_id = ?)", new String[]{""+ baseId, ""+ parentId}, GroupDto.class);
......@@ -528,7 +549,15 @@ public class GroupDao extends AbstractDao {
list = rawQueryGetDtoList("select * from m_group mg where (mg.parent_group_id = ?)", new String[]{""+ parentId}, GroupDto.class);
return list;
}
public GroupDto getRootGroup() {
return rawQueryGetDto("select * from m_group mg where (mg.parent_group_id = 0)",null, GroupDto.class);
}
public GroupDto getParentGroup(Integer childGroupId) {
return rawQueryGetDto("select parent.* from m_group parent inner join m_group child on child.parent_group_id = parent.group_id where child.group_id = ?", new String[]{""+ childGroupId}, GroupDto.class);
}
public boolean isExistParent(int baseId) {
return rawQueryGetInt("select * from m_group where parent_group_id = " + baseId, null) > 0;
}
......@@ -590,8 +619,8 @@ public class GroupDao extends AbstractDao {
public void updateFavoriteGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE m_group ");
sql.append(" , favorite_register_date = ? ");
sql.append(" WHERE group_id = ? ");
sql.append(" SET favorite_register_date = ? ");
sql.append(" WHERE group_id = ? ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
......
......@@ -61,10 +61,11 @@ 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) {
insert("insert or replace into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", new Integer[] {groupId});
insert("insert or replace into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", new Integer[]{groupId});
}
commit();
} catch (Exception e) {
......@@ -79,10 +80,10 @@ 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});
insert("insert or replace into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", new Integer[]{groupId});
}
}
commit();
......@@ -98,6 +99,20 @@ public class ShopMemberDao extends AbstractDao {
return rawQueryGetDto("select * from m_shop_member where self_flg = 1", null, ShopMemberDto.class);
}
public List<ShopMemberDto> getUserInRoom(Integer chatRoomId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT sm.* ");
sql.append(" FROM ");
sql.append(" m_shop_member AS sm ");
sql.append(" INNER JOIN r_chat_room_shop_member AS rrm ");
sql.append(" ON sm.shop_member_id = rrm.shop_member_id ");
sql.append(" WHERE rrm.chat_room_id =?");
sql.append(" AND sm.self_flg != 1");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{""+ chatRoomId}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getfavoriteUserList() {
return rawQueryGetDtoList("select * from m_shop_member where favorite_register_date NOT NULL", null, ShopMemberDto.class);
}
......@@ -108,6 +123,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 ");
......@@ -119,6 +135,43 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getUserInMyGroupByName(String shopMemberName) {
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(" ,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+"%' ");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getUserInAllGroupByName(String shopMemberName) {
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(" ,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(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), new String[]{}, ShopMemberDto.class);
return list;
}
public List<ShopMemberDto> getMyGroupUsers() {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
......@@ -136,8 +189,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;
}
......
package jp.agentec.abook.abv.bl.dto;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -15,6 +16,7 @@ public class ChatRoomDto extends AbstractDto {
public Integer messageType;
public String insertDate;
public ChatMessageDto lastMessageInfo;
public ArrayList<Integer> attendUsers;
@Override
public Object[] getInsertValues() {
......
......@@ -22,6 +22,7 @@ public class GroupDto extends AbstractDto {
public int delFlg;
public List<ShopMemberDto> groupMembers;
public List<String> groupPathList;
public String updateDate;
public GroupDto() {
}
......
......@@ -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
......
......@@ -3,50 +3,23 @@ package jp.agentec.abook.abv.bl.logic;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import jdk.nashorn.internal.parser.JSONParser;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.DownloadedContentInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.content.ContentJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentCheckParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
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.NetworkDisconnectedException;
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;
import jp.agentec.abook.abv.bl.data.dao.ContentGroupDao;
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.DateTimeUtil;
import jp.agentec.adf.util.StringUtil;
/**
......@@ -85,6 +58,20 @@ public class CommunicationLogic extends AbstractLogic {
chatRoomMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatRoomDto.messageType);
chatRoomMap.put(ABookCommConstants.KEY.INSERT_DATE, chatRoomDto.insertDate);
chatRoomMap.put(ABookCommConstants.KEY.USER_COUNT, chatRoomDto.userCount);
//ルームの参加者リスト取得。
List<ShopMemberDto> userList = shopMemberDao.getUserInRoom(chatRoomDto.chatRoomId);
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);
JSONObject jsonObject = new JSONObject(userMap);
attendUsers.put(jsonObject);
}
chatRoomMap.put(ABookCommConstants.KEY.ATTEND_USERS, attendUsers);
JSONObject jsonObject = new JSONObject(chatRoomMap);
resultJsonArray.put(jsonObject);
}
......@@ -101,6 +88,7 @@ public class CommunicationLogic extends AbstractLogic {
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);
......@@ -113,6 +101,19 @@ public class CommunicationLogic extends AbstractLogic {
return messageListStr;
}
public String getNameCardInfo(Integer shopMemberId) {
JSONObject resultJson = new JSONObject();
ShopMemberDto shopMemberDto = shopMemberDao.getShopMember(shopMemberId);
List<String> groupPathList = groupDao.getUserGroupPathList(shopMemberId);
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);
boolean hasRegisteredDate = StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate) == false;
resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, hasRegisteredDate);
return resultJson.toString();
}
public String getMyInfo() {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
......@@ -127,20 +128,106 @@ 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) {
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);
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;
}
public String getMyGroupUserByName(String shopMemberName) {
List<ShopMemberDto> selectedShopMembers = shopMemberDao.getUserInMyGroupByName(shopMemberName);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
List<String> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
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);
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);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto shopMember : selectedShopMembers) {
Map<String, Object> userMap = new HashMap<String, Object>();
List<String> groupPathList = groupDao.getUserGroupPathList(shopMember.shopMemberId);
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);
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 getGroupByName(String groupName) {
List<GroupDto> searchGroups = groupDao.getGroupByName(groupName);
JSONArray resultJsonArray = new JSONArray();
for (GroupDto group : searchGroups) {
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_NAME, group.groupName);
groupMap.put(ABookCommConstants.KEY.GROUP_ID, group.groupId);
if (StringUtil.isNullOrEmpty(group.favoriteRegisterDate)) {
groupMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
groupMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(groupMap);
resultJsonArray.put(jsonObject);
}
String groupsStr = resultJsonArray.toString();
return groupsStr;
}
public String getMyGroupIds() {
List<GroupDto> myGroupList = groupDao.getUserGroups();
String groupIds = "";
......@@ -153,6 +240,10 @@ public class CommunicationLogic extends AbstractLogic {
return groupIds;
}
public List<GroupDto> getAllGroup() {
return groupDao.getAllGroups();
}
public String getFavoriteUsers() {
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserList();
......@@ -160,9 +251,12 @@ 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);
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, favoriteUser.shopMemberId);
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);
}
......@@ -180,6 +274,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);
}
......@@ -195,13 +290,23 @@ public class CommunicationLogic extends AbstractLogic {
//パラメータグループIDが0であれば自分のグループ情報を取得。
GroupDto myGroup = groupDao.getUserGroups().get(0);
GroupDto rootGroup = groupDao.getRootGroup();
Integer targetGroupId;
if (groupId == 0) {
targetGroupId = myGroup.groupId;
targetGroupId = rootGroup.groupId;
} else {
targetGroupId = groupId;
}
GroupDto parentGroup = groupDao.getParentGroup(targetGroupId);
if (parentGroup != null) {
groupSearchData.put(ABookCommConstants.KEY.PARENT_GROUP_ID, parentGroup.groupId);
}
if (rootGroup != null) {
groupSearchData.put(ABookCommConstants.KEY.ROOT_GROUP_ID, rootGroup.groupId);
}
//グループ
List<GroupDto> groupPathList = groupDao.getGroupTree(targetGroupId);
JSONArray groupPathJSONArray = new JSONArray();
......@@ -220,18 +325,30 @@ public class CommunicationLogic extends AbstractLogic {
Map<String, Object> groupTreeMap = new HashMap<String, Object>();
groupTreeMap.put(ABookCommConstants.KEY.GROUP_NAME, group.groupName);
groupTreeMap.put(ABookCommConstants.KEY.GROUP_ID, group.groupId);
if (StringUtil.isNullOrEmpty(group.favoriteRegisterDate)) {
groupTreeMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
groupTreeMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(groupTreeMap);
childGroupJSONArray.put(jsonObject);
}
groupSearchData.put(ABookCommConstants.KEY.CHILD_GROUP_LIST,childGroupJSONArray);
List<ShopMemberDto> shopMemberList = shopMemberDao.getUserListByGroupId(targetGroupId);
JSONArray shopMemberJSONArray = new JSONArray();
for (ShopMemberDto shopMember : shopMemberList) {
Map<String, Object> shopMemberMap = new HashMap<String, Object>();
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.GROUP_PATH_LIST, groupDao.getUserGroupPathList(shopMember.shopMemberId));
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
JSONObject jsonObject = new JSONObject(shopMemberMap);
shopMemberJSONArray.put(jsonObject);
}
......@@ -305,12 +422,18 @@ public class CommunicationLogic extends AbstractLogic {
continue;
}
insertShopMember(groupDto.groupMembers);
}
groupDao.insertGroupList(insertGroupList);
groupDao.updateGroupList(updateGroupList);
groupDao.deleteGroupList(deleteGroupList);
}
public ShopMemberDto getMyShopMemberDto() {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
return myInfo;
}
public void deleteChatRoomList() {
chatRoomDao.deleteChatRoom();
}
......@@ -320,5 +443,42 @@ 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 updateFavoriteGroup(List<Integer> favoriteGroupIds){
List<GroupDto> groupDtos = new ArrayList<GroupDto>();
for (Integer favoriteGroupId : favoriteGroupIds) {
GroupDto groupDto = new GroupDto();
groupDto.groupId = favoriteGroupId;
groupDto.favoriteRegisterDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(new Date(System.currentTimeMillis()));
groupDtos.add(groupDto);
}
groupDao.updateFavoriteGroupList(groupDtos);
}
public void deleteavoriteUser(List<Integer> favoriteUserIds){
for (Integer favoriteUserId : favoriteUserIds) {
ShopMemberDto favoriteUserDto= new ShopMemberDto();
favoriteUserDto.shopMemberId = favoriteUserId;
favoriteUserDto.favoriteRegisterDate = null;
shopMemberDao.updateFavoriteUser(favoriteUserDto);
}
}
public void deleteavoriteGroup(List<Integer> favoriteGroupIds){
List<GroupDto> groupDtos = new ArrayList<GroupDto>();
for (Integer favoriteGroupId : favoriteGroupIds) {
GroupDto groupDto = new GroupDto();
groupDto.favoriteRegisterDate = null;
groupDto.groupId = favoriteGroupId;
groupDtos.add(groupDto);
}
groupDao.updateFavoriteGroupList(groupDtos);
}
}
......@@ -4,6 +4,7 @@ import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.util.Map;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.exception.ABVRuntimeException;
import jp.agentec.adf.core.ADFObject;
import jp.agentec.adf.core.formatter.PropertyNameFormatter;
......@@ -68,12 +69,11 @@ public abstract class HttpParameterObject extends ADFObject {
Object value = method.invoke(this);
if (value != null) {
if (propertyName.equals("groupIds")) {
sb.append(value);
if (propertyName.equals(ABookCommConstants.KEY.GROUP_IDS)) {
sb.append(value.toString());
} else {
sb.append(URLEncoder.encode(value.toString(), encoding).replace("+", "%20"));
}
}
sb.append(DelimiterKeyKey);
......
......@@ -8,6 +8,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
......@@ -29,17 +30,21 @@ 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.GetFavoriteGroupJSON;
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;
import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
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;
......@@ -62,6 +67,8 @@ 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.util.CollectionUtil;
import jp.agentec.adf.util.StringUtil;
import static org.chromium.net.NetError.ERR_FAILED;
......@@ -75,9 +82,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
......@@ -91,6 +98,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private String shopName;
private boolean isOnline;
private Long roomId;
private Integer shopMemberId;
public AlertDialog myAlertDialog;
......@@ -125,6 +133,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
isOnline = true;
chatWebviewUrl = CHAT_PAGE_URL;
updateMyInfoFromServer();
updateAllGroupInfo();
updateFavoriteInfo();
}
} catch (Exception e) {
Logger.d("SID_CHECK_ERROR");
......@@ -133,6 +143,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
Logger.d("DEVICE_NOT_CONNECTED_NETWORK:");
}
shopMemberId = communicationLogic.getMyShopMemberDto().shopMemberId;
mChatWebView = findViewById(R.id.chatWebview2);
mChatWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //オーバースクロールしない。
mChatWebView.setVerticalScrollBarEnabled(false); //スクロールバーを消す。
......@@ -718,7 +731,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public void createChatRoom(String roomType, String userIdList, String encodedRoomName) throws NetworkDisconnectedException, AcmsException {
CreatedRoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).createRoom(sid, roomType, userIdList, encodedRoomName);
CreatedRoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).createRoom(sid, roomType, userIdList, encodedRoomName, loginId);
communicationLogic.insertChatRoom(resultJson.chatRoomDto);
final Integer chatRoomId = resultJson.chatRoomDto.chatRoomId;
final String chatRoomName = resultJson.chatRoomDto.chatRoomName;
......@@ -765,6 +778,25 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
String myGroupUsersStr = communicationLogic.getMyGroupUsers();
return myGroupUsersStr;
}
@JavascriptInterface
public String getMyGroupShopMemberByName(String shopMemberName) {
String searchUserStr = communicationLogic.getMyGroupUserByName(shopMemberName);
return searchUserStr;
}
@JavascriptInterface
public String getAllGroupShopMemberByName(String shopMemberName) {
String searchUserStr = communicationLogic.getAllGroupShopMemberByName(shopMemberName);
return searchUserStr;
}
@JavascriptInterface
public String getGroupByName(String groupName) {
String searchGroupStr = communicationLogic.getGroupByName(groupName);
return searchGroupStr;
}
@JavascriptInterface
public String getFavoriteGroups() {
String favoriteGroupsStr = communicationLogic.getFavoriteGroups();
......@@ -776,11 +808,78 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public String getGroupInfo(String groupId) throws NetworkDisconnectedException, AcmsException {
public String getGroupInfo(String groupId) {
String groupInfoStr = communicationLogic.getGroupSearchData(Integer.parseInt(groupId));
return groupInfoStr;
}
@JavascriptInterface
public String getNameCardData(String shopMemberId) {
String nameCardStr = communicationLogic.getNameCardInfo(Integer.parseInt(shopMemberId));
return nameCardStr;
}
@JavascriptInterface
public String getFavoriteGroupsList() {
String favoriteGroupsListStr = communicationLogic.getFavoriteGroups();
return favoriteGroupsListStr;
}
@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();");
}
});
}
@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 addFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = insertFavoriteGroup(groupId);
if (result) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
}
}
@JavascriptInterface
public void removeFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = deleteFavoriteGroup(groupId);
if (result) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
}
}
@JavascriptInterface
public void updateFavorite() throws NetworkDisconnectedException, AcmsException {
updateFavoriteInfo();
}
}
/**
......@@ -801,14 +900,95 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
private void updateUserInfoFromServer(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getNameCard(sid,shopMemberId);
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getNameCard(sid, shopMemberId);
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 boolean insertFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
.insertFavoriteGroup(sid, Integer.parseInt(groupId));
return result;
}
private boolean deleteFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
.deleteFavoriteGroup(sid, Integer.parseInt(groupId));
if (!result) { return false; }
List<Integer> deleteFavoriteList = new ArrayList<Integer>();
deleteFavoriteList.add(Integer.parseInt(groupId));
communicationLogic.deleteavoriteGroup(deleteFavoriteList);
return true;
}
private void updateGroupInfoFromServer(String groupIds) throws NetworkDisconnectedException, AcmsException {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,groupIds,DEFAULT_CHECKSUM);
communicationLogic.updateGroup(resultJson.groupList);
ArrayList<String> checkSumList = new ArrayList<String>();
SharedPreferences pref = getSharedPreferences(ABookCommConstants.TAG,MODE_PRIVATE);
for (String groupId : groupIds.split(",")) {
checkSumList.add(pref.getString(groupId,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);
}
}
editor.commit();
}
}
private void updateFavoriteUser() throws NetworkDisconnectedException, AcmsException {
GetFavoriteUserJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getFavoriteUser(sid);
communicationLogic.updateFavoriteUser(resultJson.favoriteUserIds);
}
private void updateFavoriteGroup() throws NetworkDisconnectedException, AcmsException {
GetFavoriteGroupJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getFavoriteGroup(sid);
communicationLogic.updateFavoriteGroup(resultJson.favoriteGroupIds);
}
private void updateAllGroupInfo() throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString());
List<GroupDto> groupList = communicationLogic.getAllGroup();
for (GroupDto group : groupList) {
updateGroupInfoFromServer(Integer.toString(group.groupId));
}
}
private void updateFavoriteInfo() throws NetworkDisconnectedException, AcmsException {
updateFavoriteUser();
updateFavoriteGroup();
}
/** 
* ボタンイベント設定
*/
......
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