Commit 2bc13b4a by NGUYEN LONG CHAN

62451: グループコード追加

グループ情報API(abvapi/group)
parent c3bb33c4
...@@ -23,6 +23,7 @@ public class GroupsJSON extends AcmsCommonJSON { ...@@ -23,6 +23,7 @@ public class GroupsJSON extends AcmsCommonJSON {
public static final String GroupLevel = "groupLevel"; public static final String GroupLevel = "groupLevel";
public static final String ParentGroupId = "parentGroupId"; public static final String ParentGroupId = "parentGroupId";
public static final String UserGroupIds = "userGroupIds"; public static final String UserGroupIds = "userGroupIds";
public static final String GroupCode = "groupCode";
public ArrayList<GroupDto> groupList; public ArrayList<GroupDto> groupList;
public Integer[] userGroupIds; public Integer[] userGroupIds;
...@@ -56,6 +57,10 @@ public class GroupsJSON extends AcmsCommonJSON { ...@@ -56,6 +57,10 @@ public class GroupsJSON extends AcmsCommonJSON {
String groupName = getString(group, GroupName); String groupName = getString(group, GroupName);
short groupLevel = (short) getInt(group, GroupLevel); short groupLevel = (short) getInt(group, GroupLevel);
int parentGroupId = getInt(group, ParentGroupId); int parentGroupId = getInt(group, ParentGroupId);
String groupCode = "";
if (group.has(GroupCode)) {
groupCode = getString(group, GroupCode);
}
// ユーザが所属しているグループフラグ // ユーザが所属しているグループフラグ
boolean userGroupFlg = false; boolean userGroupFlg = false;
...@@ -63,7 +68,7 @@ public class GroupsJSON extends AcmsCommonJSON { ...@@ -63,7 +68,7 @@ public class GroupsJSON extends AcmsCommonJSON {
userGroupFlg = Arrays.asList(userGroupIds).contains(groupId); userGroupFlg = Arrays.asList(userGroupIds).contains(groupId);
} }
groupList.add(new GroupDto(groupId, groupName, groupLevel,parentGroupId, userGroupFlg)); groupList.add(new GroupDto(groupId, groupName, groupLevel,parentGroupId, userGroupFlg, groupCode));
} }
} else { } else {
throw new JSONValidationException(json.toString(), GroupList + " property not found."); throw new JSONValidationException(json.toString(), GroupList + " property not found.");
......
...@@ -19,7 +19,7 @@ import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase; ...@@ -19,7 +19,7 @@ import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
public class DBConnector { public class DBConnector {
private static volatile DBConnector dbConnector = null; private static volatile DBConnector dbConnector = null;
public static final String DatabaseName = "ABVJE"; public static final String DatabaseName = "ABVJE";
public static final int DatabaseVersion = DatabaseVersions.Ver1_0_5; public static final int DatabaseVersion = DatabaseVersions.Ver1_0_612;
protected SQLiteDatabase db = null; protected SQLiteDatabase db = null;
......
...@@ -7,4 +7,5 @@ public class DatabaseVersions { ...@@ -7,4 +7,5 @@ public class DatabaseVersions {
public static final int Ver1_0_3 = 21; // @From カテゴリ選択機能追加 public static final int Ver1_0_3 = 21; // @From カテゴリ選択機能追加
public static final int Ver1_0_4 = 31; // @From ロック、ダッシュボード対応 public static final int Ver1_0_4 = 31; // @From ロック、ダッシュボード対応
public static final int Ver1_0_5 = 32; // Ver.1.0.600 プッシュメッセージ仕様変更対応 public static final int Ver1_0_5 = 32; // Ver.1.0.600 プッシュメッセージ仕様変更対応
public static final int Ver1_0_612 = 33;
} }
...@@ -59,6 +59,10 @@ public class GroupDao extends AbstractDao { ...@@ -59,6 +59,10 @@ public class GroupDao extends AbstractDao {
if (column != -1) { if (column != -1) {
dto.userGroupFlg = toBool(cursor.getInt(column)); dto.userGroupFlg = toBool(cursor.getInt(column));
} }
column = cursor.getColumnIndex("group_code");
if (column != -1) {
dto.groupCode = cursor.getString(column);
}
return dto; return dto;
} }
...@@ -88,6 +92,7 @@ public class GroupDao extends AbstractDao { ...@@ -88,6 +92,7 @@ public class GroupDao extends AbstractDao {
sql.append(" , mg.parent_group_id AS parent_group_id "); sql.append(" , mg.parent_group_id AS parent_group_id ");
sql.append(" , mg.group_name AS group_name "); sql.append(" , mg.group_name AS group_name ");
sql.append(" , 0 AS content_count "); // 初期化用であるため、コンテンツ数はいらない。 sql.append(" , 0 AS content_count "); // 初期化用であるため、コンテンツ数はいらない。
sql.append(" , mg.group_code AS group_code ");
sql.append(" FROM m_group AS mg "); sql.append(" FROM m_group AS mg ");
break; break;
case GetRootGroups: case GetRootGroups:
...@@ -125,6 +130,7 @@ public class GroupDao extends AbstractDao { ...@@ -125,6 +130,7 @@ public class GroupDao extends AbstractDao {
sql.append(" , T1.group_level "); sql.append(" , T1.group_level ");
sql.append(" , T1.group_name "); sql.append(" , T1.group_name ");
sql.append(" , T1.group_path "); sql.append(" , T1.group_path ");
sql.append(" , T1.group_code ");
sql.append(" , SUM(T1.content_count) AS content_count "); sql.append(" , SUM(T1.content_count) AS content_count ");
sql.append(" , CASE WHEN SUM(T1.child_content_count) = 0 THEN ' (' || SUM(T1.content_count) || ') ' "); sql.append(" , CASE WHEN SUM(T1.child_content_count) = 0 THEN ' (' || SUM(T1.content_count) || ') ' ");
sql.append(" ELSE ' (' || SUM(T1.content_count) || '/' || (SUM(T1.content_count) + SUM(T1.child_content_count)) || ') ' "); sql.append(" ELSE ' (' || SUM(T1.content_count) || '/' || (SUM(T1.content_count) + SUM(T1.child_content_count)) || ') ' ");
...@@ -136,6 +142,7 @@ public class GroupDao extends AbstractDao { ...@@ -136,6 +142,7 @@ public class GroupDao extends AbstractDao {
sql.append(" , mg2.group_level "); sql.append(" , mg2.group_level ");
sql.append(" , mg2.group_name "); sql.append(" , mg2.group_name ");
sql.append(" , mg2.group_path "); sql.append(" , mg2.group_path ");
sql.append(" , mg2.group_code ");
if (isOnlineSearched) { if (isOnlineSearched) {
sql.append(" , CASE WHEN mg2.group_id = mg1.group_id THEN COUNT(tcss.content_id) "); sql.append(" , CASE WHEN mg2.group_id = mg1.group_id THEN COUNT(tcss.content_id) ");
...@@ -264,14 +271,14 @@ public class GroupDao extends AbstractDao { ...@@ -264,14 +271,14 @@ public class GroupDao extends AbstractDao {
return sql.toString(); return sql.toString();
} }
public void insertGroup(int groupId, int parentGroupId, String groupName, int groupLevel, boolean userGroupFlg) { public void insertGroup(int groupId, int parentGroupId, String groupName, int groupLevel, boolean userGroupFlg, String groupCode) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append(" INSERT OR IGNORE INTO m_group (group_id, parent_group_id, group_name, group_path, group_level, user_group_flg) "); sql.append(" INSERT OR IGNORE INTO m_group (group_id, parent_group_id, group_name, group_path, group_level, user_group_flg, group_code) ");
sql.append(" VALUES (?,?,?,?,?,?) "); sql.append(" VALUES (?,?,?,?,?,?,?) ");
try { try {
beginTransaction(); beginTransaction();
String groupPath = createInsertGroupPath(groupId, parentGroupId, groupLevel); String groupPath = createInsertGroupPath(groupId, parentGroupId, groupLevel);
insert(sql.toString(), new Object[] { groupId, parentGroupId, groupName, groupPath, groupLevel, userGroupFlg }); insert(sql.toString(), new Object[] { groupId, parentGroupId, groupName, groupPath, groupLevel, userGroupFlg, groupCode });
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
rollback(); rollback();
...@@ -305,19 +312,20 @@ public class GroupDao extends AbstractDao { ...@@ -305,19 +312,20 @@ public class GroupDao extends AbstractDao {
return rawQueryGetDto(sql.toString(), new String[] { "" + parentGroupId, "" + groupLevel }, GroupDto.class); return rawQueryGetDto(sql.toString(), new String[] { "" + parentGroupId, "" + groupLevel }, GroupDto.class);
} }
public void updateGroup(int groupId, int parentGroupId, String groupName, int groupLevel, boolean userGroupFlg) { public void updateGroup(int groupId, int parentGroupId, String groupName, int groupLevel, boolean userGroupFlg, String groupCode) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append(" UPDATE m_group "); sql.append(" UPDATE m_group ");
sql.append(" SET group_name = ? "); sql.append(" SET group_name = ? ");
sql.append(" , user_group_flg = ? "); sql.append(" , user_group_flg = ? ");
sql.append(" , group_path = ? "); sql.append(" , group_path = ? ");
sql.append(" , group_code = ? ");
sql.append(" WHERE group_id = ? "); sql.append(" WHERE group_id = ? ");
sql.append(" AND parent_group_id = ? "); sql.append(" AND parent_group_id = ? ");
sql.append(" AND group_level = ? "); sql.append(" AND group_level = ? ");
try { try {
beginTransaction(); beginTransaction();
String groupPath = createUpdateGroupPath(groupId, parentGroupId, groupLevel); String groupPath = createUpdateGroupPath(groupId, parentGroupId, groupLevel);
update(sql.toString(), new Object[] { groupName, userGroupFlg, groupPath, groupId, parentGroupId, groupLevel }); update(sql.toString(), new Object[] { groupName, userGroupFlg, groupPath, groupCode, groupId, parentGroupId, groupLevel });
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
rollback(); rollback();
......
...@@ -34,6 +34,7 @@ public class MGroup extends SQLiteTableScript { ...@@ -34,6 +34,7 @@ public class MGroup extends SQLiteTableScript {
sql.append(" , group_name VARCHAR(64) NOT NULL "); sql.append(" , group_name VARCHAR(64) NOT NULL ");
sql.append(" , group_path TEXT NOT NULL "); // path enumaerationパターンを適用する。since DatabaseVersions.Ver1_5_0 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(" , user_group_flg BOOLEAN NOT NULL DEFAULT 0 "); // since DatabaseVersions.Plus_1_1_0
sql.append(" , group_code VARCHAR(10) DEFAULT '' NOT NULL ");
sql.append(" , PRIMARY KEY (group_relation_id) "); sql.append(" , PRIMARY KEY (group_relation_id) ");
sql.append(" ) "); sql.append(" ) ");
...@@ -66,7 +67,11 @@ public class MGroup extends SQLiteTableScript { ...@@ -66,7 +67,11 @@ public class MGroup extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
return null; List<String> ddl = new ArrayList<String>();
if (oldVersion < DatabaseVersions.Ver1_0_612) {
ddl.add(" ALTER TABLE m_group ADD COLUMN group_code VARCHAR(10) DEFAULT '' NOT NULL ");
}
return ddl;
} }
@Override @Override
......
...@@ -16,16 +16,18 @@ public class GroupDto extends AbstractDto { ...@@ -16,16 +16,18 @@ public class GroupDto extends AbstractDto {
public String displayCount; public String displayCount;
public String groupPath; public String groupPath;
public boolean userGroupFlg; public boolean userGroupFlg;
public String groupCode;
public GroupDto() { public GroupDto() {
} }
public GroupDto(int groupId, String groupName, int groupLevel, int parentGroupId, boolean userGroupFlg) { public GroupDto(int groupId, String groupName, int groupLevel, int parentGroupId, boolean userGroupFlg, String groupCode) {
this.groupId = groupId; this.groupId = groupId;
this.groupName = groupName; this.groupName = groupName;
this.groupLevel = groupLevel; this.groupLevel = groupLevel;
this.parentGroupId = parentGroupId; this.parentGroupId = parentGroupId;
this.userGroupFlg = userGroupFlg; this.userGroupFlg = userGroupFlg;
this.groupCode = groupCode;
} }
@Override @Override
......
...@@ -70,7 +70,7 @@ public class GroupLogic extends AbstractLogic { ...@@ -70,7 +70,7 @@ public class GroupLogic extends AbstractLogic {
if (exist) { if (exist) {
// update // update
groupDao.updateGroup(serverDto.groupId, serverDto.parentGroupId, serverDto.groupName, serverDto.groupLevel, serverDto.userGroupFlg); groupDao.updateGroup(serverDto.groupId, serverDto.parentGroupId, serverDto.groupName, serverDto.groupLevel, serverDto.userGroupFlg, serverDto.groupCode);
// 更新したグループはローカルのリストから外しておく。 // 更新したグループはローカルのリストから外しておく。
localGroups.remove(localDto); localGroups.remove(localDto);
...@@ -83,7 +83,7 @@ public class GroupLogic extends AbstractLogic { ...@@ -83,7 +83,7 @@ public class GroupLogic extends AbstractLogic {
// ユーザの所属グループの情報が変更された // ユーザの所属グループの情報が変更された
isChangedUserGroupInfo = true; isChangedUserGroupInfo = true;
// insert // insert
groupDao.insertGroup(serverDto.groupId, serverDto.parentGroupId, serverDto.groupName, serverDto.groupLevel, serverDto.userGroupFlg); groupDao.insertGroup(serverDto.groupId, serverDto.parentGroupId, serverDto.groupName, serverDto.groupLevel, serverDto.userGroupFlg, serverDto.groupCode);
if (localContents == null) { if (localContents == null) {
localContents = contentDao.getAllContents(); localContents = contentDao.getAllContents();
......
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