Commit b6590b1f by Lee Munkyeong

Checkのテーブル復元

parent b47d99f6
......@@ -8,7 +8,6 @@ import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.adf.util.CollectionUtil;
import jp.agentec.adf.util.NumericUtil;
import jp.agentec.adf.util.StringUtil;
......@@ -60,10 +59,7 @@ public class GroupDao extends AbstractDao {
if (column != -1) {
dto.userGroupFlg = toBool(cursor.getInt(column));
}
column = cursor.getColumnIndex("favorite_register_date");
if (column != -1) {
dto.favoriteRegisterDate = cursor.getString(column);
}
return dto;
}
......@@ -76,38 +72,6 @@ public class GroupDao extends AbstractDao {
return rawQueryGetDtoList("select * from m_group where group_relation_id in (select group_relation_id from r_content_group where content_id = " + contentId + ") order by group_id", null, GroupDto.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_group mygroup ");
sql.append(" LEFT JOIN m_group parentgroup on mygroup.parent_group_id = parentgroup.group_id ");
sql.append(" LEFT JOIN m_group grandparentgroup on parentgroup.parent_group_id = grandparentgroup.group_id ");
sql.append(" WHERE mygroup.user_group_flg = 1 ");
return rawQueryGetStringList(sql.toString(), null);
}
public List<GroupDto> 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, usergroup.group_id ");
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 rawQueryGetDtoList(sql.toString(), new String[] { "" + shopMemberId}, GroupDto.class);
}
private String generateGetGroupsQuery(QueryType queryType, int[] groupRelationids, int[] parentGroupIds, Boolean downloaded, String searchKeyword, SearchDivisionType searchDivisionType, boolean isOnlineSearched) {
StringBuffer sql = new StringBuffer();
......@@ -515,75 +479,24 @@ public class GroupDao extends AbstractDao {
return rawQueryGetDto("select * from m_group where group_id = " + groupId, null, GroupDto.class);
}
public List<GroupDto> getFavoriteGroup() {
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[] keywords) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT * ");
sql.append(" FROM m_group ");
ArrayList<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
if(StringUtil.isNullOrEmpty(keyword)){
continue;
}
String whereSql = "group_name LIKE '%"+keyword+"%'";
whereSqlList.add(whereSql);
}
if (CollectionUtil.isNotEmpty(whereSqlList)) {
sql.append("WHERE " + StringUtil.join(" AND ", whereSqlList));
}
sql.append(" ORDER BY group_name ASC ");
return rawQueryGetDtoList(sql.toString(), 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);
return list;
}
public List<GroupDto> getGroupTree(Integer groupId) {
List<GroupDto> list;
StringBuffer sql = new StringBuffer();
sql.append(" WITH group_loop AS ");
sql.append(" ( ");
sql.append(" SELECT 1 rownum,group_id,group_name,parent_group_id,user_group_flg from m_group where group_id = ? ");
sql.append(" UNION ALL ");
sql.append(" SELECT rownum+1 rownum,parent.group_id,parent. group_name,parent.parent_group_id,parent.user_group_flg ");
sql.append(" FROM group_loop inner join m_group parent on parent.group_id = group_loop.parent_group_id ");
sql.append(" ) ");
sql.append(" SELECT * FROM group_loop ORDER BY group_loop.rownum DESC ");
list = rawQueryGetDtoList(sql.toString(), new String[]{""+ groupId}, GroupDto.class);
return list;
}
public List<GroupDto> getGroupChildList(int parentId) {
List<GroupDto> list;
list = rawQueryGetDtoList("select * from m_group mg where (mg.parent_group_id = ?) ORDER BY group_name ASC", new String[]{""+ parentId}, GroupDto.class);
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;
}
public List<GroupDto> getUserGroups() {
return rawQueryGetDtoList("select * from m_group where user_group_flg = 1 ORDER BY group_name", null, GroupDto.class);
}
public List<GroupDto> getMyGroups() {
return rawQueryGetDtoList("select * from m_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, GroupDto.class);
return rawQueryGetDtoList("select * from m_group where user_group_flg = 1", null, GroupDto.class);
}
/**
......@@ -599,95 +512,4 @@ public class GroupDao extends AbstractDao {
return userGroupList.get(0).groupId;
}
public void insertGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" INSERT INTO m_group (group_id, parent_group_id, group_name, group_path, group_level, user_group_flg) ");
sql.append(" VALUES (?,?,?,?,?,?) ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
insert(sql.toString(), new Object[] { groupDto.groupId, groupDto.parentGroupId, groupDto.groupName, ""+ groupDto.groupId, 0, 0 });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("insertGroupList failed.", e);
throw new RuntimeException(e);
}
}
public void updateGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE m_group ");
sql.append(" SET group_name = ? ");
sql.append(" , parent_group_id = ? ");
sql.append(" WHERE group_id = ? ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
update(sql.toString(), new Object[] { groupDto.groupName, groupDto.parentGroupId, groupDto.groupId });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("updateGroupList failed.", e);
throw new RuntimeException(e);
}
}
public void updateUserGroupList(List<Integer> groupIds) {
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE m_group ");
sql.append(" SET user_group_flg = 1 ");
sql.append(" WHERE group_id = ? ");
try {
beginTransaction();
for (Integer groupId : groupIds) {
update(sql.toString(), new Object[] { groupId });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("updateGroupList failed.", e);
throw new RuntimeException(e);
}
}
public void updateFavoriteGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE m_group ");
sql.append(" SET favorite_register_date = ? ");
sql.append(" WHERE group_id = ? ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
update(sql.toString(), new Object[] { groupDto.favoriteRegisterDate, groupDto.groupId });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("updateFavoriteGroupList failed.", e);
throw new RuntimeException(e);
}
}
public void deleteGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" delete from m_group ");
sql.append(" WHERE group_id = ? ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
update(sql.toString(), new Object[] { groupDto.groupId });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("deleteGroupList failed.", e);
throw new RuntimeException(e);
}
}
}
......@@ -34,7 +34,6 @@ public class MGroup extends SQLiteTableScript {
sql.append(" , group_name VARCHAR(64) NOT NULL ");
sql.append(" , group_path TEXT NOT NULL "); // path enumaerationパターンを適用する。since DatabaseVersions.Ver1_5_0
sql.append(" , user_group_flg BOOLEAN NOT NULL DEFAULT 0 "); // since DatabaseVersions.Plus_1_1_0
sql.append(" , favorite_register_date VARCHAR2(64) ");
sql.append(" , PRIMARY KEY (group_relation_id) ");
sql.append(" ) ");
......
package jp.agentec.abook.abv.bl.dto;
import java.util.List;
/**
* グループ情報を格納します。m_groupのPKであるgroup_relation_idはこのdtoの扱いません。内部的なキーはgetKyeValuesメソッドで定義してあります。
* @author Taejin Hong
......@@ -17,12 +15,7 @@ public class GroupDto extends AbstractDto {
public int contentCount = 0;
public String displayCount;
public String groupPath;
public String favoriteRegisterDate = "";
public boolean userGroupFlg;
public int delFlg;
public List<ShopMemberDto> groupMembers;
public List<String> groupPathList;
public String updateDate;
public GroupDto() {
}
......
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