Commit 795a5353 by Lee Munkyeong

テーブル作成

parent e74692c5
...@@ -8,16 +8,13 @@ import java.util.ArrayList; ...@@ -8,16 +8,13 @@ import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants; 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.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException; import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto; import jp.agentec.abook.abv.bl.dto.ChatGroupDto;
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.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.DateTimeUtil;
public class GroupListJSON extends AcmsCommonJSON { public class GroupListJSON extends AcmsCommonJSON {
public ArrayList<GroupDto> groupList; public ArrayList<ChatGroupDto> groupList;
public String allGroupLastUpdateDate; public String allGroupLastUpdateDate;
public GroupListJSON(String jsonString) throws AcmsException { public GroupListJSON(String jsonString) throws AcmsException {
...@@ -34,14 +31,14 @@ public class GroupListJSON extends AcmsCommonJSON { ...@@ -34,14 +31,14 @@ public class GroupListJSON extends AcmsCommonJSON {
JSONArray groupListJsonArray = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONArray(ABookCommConstants.KEY.GROUP_INFO_LIST); JSONArray groupListJsonArray = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONArray(ABookCommConstants.KEY.GROUP_INFO_LIST);
if (groupListJsonArray == null) { return; } if (groupListJsonArray == null) { return; }
groupList = new ArrayList<GroupDto>(); groupList = new ArrayList<ChatGroupDto>();
for (int listCount = 0; listCount < groupListJsonArray.length(); listCount++) { for (int listCount = 0; listCount < groupListJsonArray.length(); listCount++) {
if (groupListJsonArray.getJSONObject(listCount).length() == 0) { if (groupListJsonArray.getJSONObject(listCount).length() == 0) {
break; break;
} }
JSONObject groupJSON = groupListJsonArray.getJSONObject(listCount); JSONObject groupJSON = groupListJsonArray.getJSONObject(listCount);
GroupDto groupDto = new GroupDto(); ChatGroupDto groupDto = new ChatGroupDto();
groupDto.groupId = groupJSON.getInt(ABookCommConstants.KEY.GROUP_ID); groupDto.groupId = groupJSON.getInt(ABookCommConstants.KEY.GROUP_ID);
if (groupJSON.has(ABookCommConstants.KEY.PARENT_GROUP_ID)) { if (groupJSON.has(ABookCommConstants.KEY.PARENT_GROUP_ID)) {
......
...@@ -6,6 +6,7 @@ import java.util.List; ...@@ -6,6 +6,7 @@ import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor; import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ChatGroupDto; import jp.agentec.abook.abv.bl.dto.ChatGroupDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.adf.util.CollectionUtil; import jp.agentec.adf.util.CollectionUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
...@@ -44,10 +45,24 @@ public class ChatGroupDao extends AbstractDao { ...@@ -44,10 +45,24 @@ public class ChatGroupDao extends AbstractDao {
sql.append(" ,parent_group_id "); sql.append(" ,parent_group_id ");
sql.append(" ,group_name "); sql.append(" ,group_name ");
sql.append(" ,favorite_register_date "); sql.append(" ,favorite_register_date ");
sql.append(" FROM n_chat_group"); sql.append(" FROM m_chat_group");
return rawQueryGetDtoList(sql.toString(), null, ChatGroupDto.class); return rawQueryGetDtoList(sql.toString(), null, ChatGroupDto.class);
} }
public List<String> getMyGroupPathList() {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" CASE WHEN (grandparentgroup.group_name IS NOT NULL) THEN grandparentgroup.group_name || ' / ' || parentgroup.group_name || ' / ' || mygroup.group_name ");
sql.append(" WHEN (parentgroup.group_name IS NOT NULL) THEN parentgroup.group_name || ' / ' || mygroup.group_name ");
sql.append(" ELSE mygroup.group_name ");
sql.append(" END AS group_path_list ");
sql.append(" FROM m_chat_group mygroup ");
sql.append(" LEFT JOIN m_chat_group parentgroup on mygroup.parent_group_id = parentgroup.group_id ");
sql.append(" LEFT JOIN m_chat_group grandparentgroup on parentgroup.parent_group_id = grandparentgroup.group_id ");
sql.append(" WHERE mygroup.group_id IN (select group_id from m_shop_member sm inner join r_shop_member_group rmg on sm.shop_member_id = rmg.shop_member_id where sm.self_flg = 1)");
return rawQueryGetStringList(sql.toString(), null);
}
public List<ChatGroupDto> getUserGroupPathList(Integer shopMemberId) { public List<ChatGroupDto> getUserGroupPathList(Integer shopMemberId) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append(" SELECT "); sql.append(" SELECT ");
...@@ -114,7 +129,21 @@ public class ChatGroupDao extends AbstractDao { ...@@ -114,7 +129,21 @@ public class ChatGroupDao extends AbstractDao {
} finally { } finally {
} }
} }
public void deleteChatGroup() {
try {
beginTransaction();
delete("r_shop_member_group", null, null);
delete("m_chat_group", null, null);
commit();
} catch (Exception e) {
rollback();
Logger.e("deleteChatMessage failed.", e);
throw new RuntimeException(e);
} finally {
}
}
public ChatGroupDto getGroup(int groupId) { public ChatGroupDto getGroup(int groupId) {
return rawQueryGetDto("select * from m_chat_group where group_id = " + groupId, null, ChatGroupDto.class); return rawQueryGetDto("select * from m_chat_group where group_id = " + groupId, null, ChatGroupDto.class);
} }
...@@ -138,7 +167,7 @@ public class ChatGroupDao extends AbstractDao { ...@@ -138,7 +167,7 @@ public class ChatGroupDao extends AbstractDao {
if (CollectionUtil.isNotEmpty(whereSqlList)) { if (CollectionUtil.isNotEmpty(whereSqlList)) {
sql.append("WHERE " + StringUtil.join(" AND ", whereSqlList)); sql.append("WHERE " + StringUtil.join(" AND ", whereSqlList));
} }
sql.append(" ORDER BY group_id "); sql.append(" ORDER BY group_name ASC ");
return rawQueryGetDtoList(sql.toString(), null, ChatGroupDto.class); return rawQueryGetDtoList(sql.toString(), null, ChatGroupDto.class);
} }
...@@ -147,9 +176,9 @@ public class ChatGroupDao extends AbstractDao { ...@@ -147,9 +176,9 @@ public class ChatGroupDao extends AbstractDao {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append(" WITH group_loop AS "); sql.append(" WITH group_loop AS ");
sql.append(" ( "); sql.append(" ( ");
sql.append(" SELECT 1 rownum,group_id,group_name,parent_group_id from m_chat_group where group_id = ? "); sql.append(" SELECT 1 rownum, group_id, group_name, parent_group_id from m_chat_group where group_id = ? ");
sql.append(" UNION ALL "); sql.append(" UNION ALL ");
sql.append(" SELECT rownum+1 rownum,parent.group_id,parent. group_name,parent.parent_group_id "); sql.append(" SELECT rownum+1 rownum, parent.group_id, parent.group_name, parent.parent_group_id ");
sql.append(" FROM group_loop inner join m_chat_group parent on parent.group_id = group_loop.parent_group_id "); sql.append(" FROM group_loop inner join m_chat_group parent on parent.group_id = group_loop.parent_group_id ");
sql.append(" ) "); sql.append(" ) ");
sql.append(" SELECT * FROM group_loop ORDER BY group_loop.rownum DESC "); sql.append(" SELECT * FROM group_loop ORDER BY group_loop.rownum DESC ");
...@@ -176,18 +205,18 @@ public class ChatGroupDao extends AbstractDao { ...@@ -176,18 +205,18 @@ public class ChatGroupDao extends AbstractDao {
return rawQueryGetInt("select * from m_chat_group where parent_group_id = " + baseId, null) > 0; return rawQueryGetInt("select * from m_chat_group where parent_group_id = " + baseId, null) > 0;
} }
public List<ChatGroupDto> getUserGroups() { public List<ChatGroupDto> getMyGroups() {
return rawQueryGetDtoList("select * from m_chat_group where user_group_flg = 1 ORDER BY group_name", null, ChatGroupDto.class); return rawQueryGetDtoList("select * from m_chat_group where group_id IN (select group_id from m_shop_member sm inner join r_shop_member_group rmg on sm.shop_member_id = rmg.shop_member_id where sm.self_flg = 1) ORDER BY group_name ASC", null, ChatGroupDto.class);
} }
public void insertGroupList(List<ChatGroupDto> groupList) { public void insertGroupList(List<ChatGroupDto> groupList) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append(" INSERT INTO m_chat_group (group_id, parent_group_id, group_name, group_path, group_level, user_group_flg) "); sql.append(" INSERT INTO m_chat_group (group_id, parent_group_id, group_name) ");
sql.append(" VALUES (?,?,?,?,?,?) "); sql.append(" VALUES (?,?,?) ");
try { try {
beginTransaction(); beginTransaction();
for (ChatGroupDto groupDto : groupList) { for (ChatGroupDto groupDto : groupList) {
insert(sql.toString(), new Object[] { groupDto.groupId, groupDto.parentGroupId, groupDto.groupName, ""+ groupDto.groupId, 0, 0 }); insert(sql.toString(), new Object[] { groupDto.groupId, groupDto.parentGroupId, groupDto.groupName});
} }
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -347,7 +347,6 @@ public class ShopMemberDao extends AbstractDao { ...@@ -347,7 +347,6 @@ public class ShopMemberDao extends AbstractDao {
try { try {
beginTransaction(); beginTransaction();
delete("r_collaboration_member", null, null); delete("r_collaboration_member", null, null);
delete("r_shop_member_group", null, null);
delete("m_shop_member", null, null); delete("m_shop_member", null, null);
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -25,7 +25,7 @@ public class MChatGroup extends SQLiteTableScript { ...@@ -25,7 +25,7 @@ public class MChatGroup extends SQLiteTableScript {
// since DatabaseVersions.Ver1_0_0 // since DatabaseVersions.Ver1_0_0
sql.append(" CREATE TABLE m_chat_group ( "); sql.append(" CREATE TABLE m_chat_group ( ");
sql.append(" , group_id INTEGER NOT NULL "); sql.append(" group_id INTEGER NOT NULL ");
sql.append(" , parent_group_id INTEGER NOT NULL "); sql.append(" , parent_group_id INTEGER NOT NULL ");
sql.append(" , group_name VARCHAR(64) NOT NULL "); sql.append(" , group_name VARCHAR(64) NOT NULL ");
sql.append(" , favorite_register_date VARCHAR2(64) "); sql.append(" , favorite_register_date VARCHAR2(64) ");
......
...@@ -10,7 +10,7 @@ import java.util.List; ...@@ -10,7 +10,7 @@ import java.util.List;
*/ */
public class ChatGroupDto extends AbstractDto { public class ChatGroupDto extends AbstractDto {
public int groupId; public int groupId;
public int parentGroupId; public int parentGroupId = 0;
public String groupName; public String groupName;
public int contentCount = 0; public int contentCount = 0;
public String displayCount; public String displayCount;
......
...@@ -54,9 +54,9 @@ import jp.agentec.abook.abv.bl.common.exception.AcmsException; ...@@ -54,9 +54,9 @@ 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.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache; import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.dto.ChatGroupDto;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto; import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto; import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto; import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic; import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.CommunicationLogic; import jp.agentec.abook.abv.bl.logic.CommunicationLogic;
...@@ -1041,7 +1041,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -1041,7 +1041,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid); MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
if (resultJson.shopMemberDto != null) { if (resultJson.shopMemberDto != null) {
communicationLogic.insertMyInfo(resultJson.shopMemberDto); communicationLogic.insertMyInfo(resultJson.shopMemberDto);
communicationLogic.updateMyGroup(resultJson.shopMemberDto.groupIdList);
} }
} }
...@@ -1109,7 +1108,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -1109,7 +1108,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) { if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) {
editor.putString(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString(),resultJson.allGroupLastUpdateDate); editor.putString(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString(),resultJson.allGroupLastUpdateDate);
} else { } else {
for (GroupDto groupDto : resultJson.groupList) { for (ChatGroupDto groupDto : resultJson.groupList) {
editor.putString(Integer.toString(groupDto.groupId),groupDto.updateDate); editor.putString(Integer.toString(groupDto.groupId),groupDto.updateDate);
} }
} }
...@@ -1133,9 +1132,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -1133,9 +1132,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private void updateAllGroupInfo() throws NetworkDisconnectedException, AcmsException { private void updateAllGroupInfo() throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString()); updateGroupInfoFromServer(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString());
List<GroupDto> groupList = communicationLogic.getAllGroup(); List<ChatGroupDto> groupList = communicationLogic.getAllGroup();
for (GroupDto group : groupList) { for (ChatGroupDto group : groupList) {
updateGroupInfoFromServer(Integer.toString(group.groupId)); 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