Commit f701f370 by Lee Munkyeong

アーカイブ一覧、詳細実装

parent 68b7cad4
......@@ -16,6 +16,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ApertureMasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AppLatestVersionJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ArchiveDetailJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ArchiveListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AuthLevelJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CategoriesJSON;
......@@ -59,6 +60,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.EnterpriseNewLoginParamete
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.GetArchivesDetailParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetArchivesParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetContentParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetEnqueteReplyParameters;
......@@ -766,6 +768,21 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* アーカイブ詳細取得
*
* @param sid
* @param archiveId
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public ArchiveDetailJSON getArchiveDetail(String sid, Integer archiveId, Integer collaborationDetailId) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetArchive, new GetArchivesDetailParameters(sid, AcmsApis.ArchiveCmds.getArchiveDetail, archiveId, collaborationDetailId));
ArchiveDetailJSON json = new ArchiveDetailJSON(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 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.ArchiveDto;
import jp.agentec.adf.util.DateTimeUtil;
public class ArchiveDetailJSON extends AcmsCommonJSON {
public ArchiveDto archiveDto;
public ArchiveDetailJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
// ルーム一覧情報を取得
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
if (!json.getJSONObject(ABookCommConstants.KEY.BODY).has(ABookCommConstants.KEY.ARCHIVE_INFO)) { return; }
JSONObject archiveInfo = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONObject(ABookCommConstants.KEY.ARCHIVE_INFO);
archiveDto = new ArchiveDto();
archiveDto.archiveId = archiveInfo.getInt(ABookCommConstants.KEY.ARCHIVE_ID);
archiveDto.archiveName = archiveInfo.getString(ABookCommConstants.KEY.ARCHIVE_NAME);
archiveDto.archiveType = archiveInfo.getInt(ABookCommConstants.KEY.ARCHIVE_TYPE);
archiveDto.archiveDate = DateTimeUtil.millToDateString(archiveInfo.getJSONObject(ABookCommConstants.KEY.ARCHIVE_DATE)
.getLong(ABookCommConstants.KEY.TIME), "yyyy/MM/dd HH:mm");
archiveDto.roomId = archiveInfo.getInt(ABookCommConstants.KEY.ROOM_ID);
archiveDto.saveuserId = archiveInfo.getInt(ABookCommConstants.KEY.SAVE_USER_ID);
archiveDto.filePath = archiveInfo.getString(ABookCommConstants.KEY.FILE_PATH);
if (archiveInfo.has(ABookCommConstants.KEY.ATTEND_USER_IDS)) {
archiveDto.attendUserIds = archiveInfo.getJSONArray(ABookCommConstants.KEY.ATTEND_USER_IDS).toString();
}
}
}
......@@ -46,8 +46,7 @@ public class ArchiveListJSON extends AcmsCommonJSON {
archiveDto.archiveDate = DateTimeUtil.millToDateString(archiveJSON.getJSONObject(ABookCommConstants.KEY.ARCHIVE_DATE)
.getLong(ABookCommConstants.KEY.TIME), "yyyy/MM/dd HH:mm");
archiveDto.delFlg = archiveJSON.getInt(ABookCommConstants.KEY.DEL_FLG);
archiveDto.collaborationDetailId = archiveJSON.getInt(ABookCommConstants.KEY.COLLABORATION_DEATAIL_ID);
archiveList.add(archiveDto);
}
if (json.getJSONObject(ABookCommConstants.KEY.BODY).has(ABookCommConstants.KEY.ARCHIVE_INFO_LAST_UPDATE_DATE)) {
......
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* ACMSのAPIに渡す共通的なパラメータを格納します。ACMSのAPIのパラメータ用クラスを作成するときはこのクラスを継承してください。<br>
* ただし、このクラスはログイン状態の確認用として使われる {@link GetArchivesDetailParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author lee-mk
* @version 1.0.0
*/
public class GetArchivesDetailParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private Integer archiveId;
private Integer collaborationDetailId;
/**
* {@link GetArchivesDetailParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public GetArchivesDetailParameters(String sid, String cmd, Integer archiveId, Integer collaborationDetailId) {
this.sid = sid;
this.cmd = cmd;
this.archiveId = archiveId;
this.collaborationDetailId = collaborationDetailId;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
/**
* archiveIdを返します。
* @return 詳細取得対象のIDです。
* @since 1.0.0
*/
public Integer getArchiveId() {
return archiveId;
}
/**
* collaborationDetailIdを返します。
* @return collaborationDetailId
* @since 1.0.0
*/
public Integer getCollaborationDetailId() {
return collaborationDetailId;
}
}
......@@ -58,14 +58,18 @@ public interface ABookCommConstants {
String GROUP_INFO_LAST_UPDATE_DATE = "groupInfoLastUpdateDate";
String ARCHIVE_INFO_LIST = "archiveInfoList";
String ARCHIVE_INFO = "archiveInfo";
String ARCHIVE_ID = "archiveId";
String ARCHIVE_NAME = "archiveName";
String ARCHIVE_DATE = "archiveDate";
String ARCHIVE_TYPE = "archiveType";
String SAVE_USER_ID = "saveUserId";
String FILE_PATH = "filePath";
String ATTEND_USER_IDS = "attendUserIds";
String ARCHIVE_INFO_LAST_UPDATE_DATE = "archiveInfoLastUpdateDate";
String COLLABORATION_DEATAIL_ID = "collaborationDetailId";
String ROOT_GROUP_ID = "rootGroupId";
String HTTP_STATUS = "httpStatus";
interface API_KIND {
......
package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
......@@ -7,6 +8,8 @@ import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ArchiveDto;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.CollaborationDto;
import jp.agentec.adf.util.CollectionUtil;
import jp.agentec.adf.util.StringUtil;
public class ArchiveDao extends AbstractDao {
......@@ -51,11 +54,19 @@ public class ArchiveDao extends AbstractDao {
if (column != -1) {
dto.attendUserIds = cursor.getString(column);
}
column = cursor.getColumnIndex("collaboration_detail_id");
if (column != -1) {
dto.collaborationDetailId = cursor.getInt(column);
}
column = cursor.getColumnIndex("file_path");
if (column != -1) {
dto.filePath = cursor.getString(column);
}
return dto;
}
public List<ArchiveDto> getArchive(int archiveId) {
List<ArchiveDto> list = rawQueryGetDtoList("select * from t_archive where archive_id = ?", new String[]{""+ archiveId}, ArchiveDto.class);
public ArchiveDto getArchive(int archiveId) {
ArchiveDto list = rawQueryGetDto("select * from t_archive where archive_id = ?", new String[]{""+ archiveId}, ArchiveDto.class);
return list;
}
......@@ -64,8 +75,38 @@ public class ArchiveDao extends AbstractDao {
return list;
}
public List<Integer> getExistArchiveIds() {
List<Integer> list = rawQueryGetIntegerList("select archive_id from t_archive ", null);
return list;
}
public List<ArchiveDto> getArchiveListByName(String[] keywords) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT archive_id");
sql.append(" ,archive_name");
sql.append(" ,archive_date");
sql.append(" ,archive_type");
sql.append(" ,room_id");
sql.append(" ,save_user_id");
sql.append(" ,attend_user_ids");
sql.append(" FROM t_archive ");
ArrayList<String> whereSqlList = new ArrayList<String>();
for (String keyword : keywords) {
if(StringUtil.isNullOrEmpty(keyword)){
continue;
}
String whereSql = "archive_name LIKE '%"+keyword+"%'";
whereSqlList.add(whereSql);
}
if (CollectionUtil.isNotEmpty(whereSqlList)) {
sql.append("WHERE " + StringUtil.join(" AND ", whereSqlList));
}
List<ArchiveDto> list = rawQueryGetDtoList(sql.toString(), null, ArchiveDto.class);
return list;
}
public void insertArchive(ArchiveDto dto) {
insert("insert or replace into t_archive (archive_id, archive_name, archive_date, archive_type, room_id, save_user_id, attend_user_ids) values (?,?,?,?,?,?,?)", dto.getInsertValues());
insert("insert or ignore into t_archive (archive_id, archive_name, archive_date, archive_type, room_id, save_user_id, attend_user_ids, collaboration_detail_id, file_path) values (?,?,?,?,?,?,?,?,?)", dto.getInsertValues());
}
public void insertArchiveList(List<ArchiveDto> archiveDtoList) {
......@@ -97,7 +138,26 @@ public class ArchiveDao extends AbstractDao {
}
public boolean updateArchive(ArchiveDto dto) {
long count = update("update t_archive set archive_name=?, archive_type=?, room_id=?, collaboration_id=?, shop_member_id=?, archive_save_path=? where archive_id=?", dto.getUpdateValues());
long count = update("update t_archive set archive_name=?, archive_type=?, archive_date=?, collaboration_detail_id=? where archive_id=?", dto.getUpdateValues());
return count > 0;
}
public void updateArchiveInfoList(List<ArchiveDto> archiveDtoList) {
try {
beginTransaction();
for (ArchiveDto archiveDto : archiveDtoList) {
updateArchive(archiveDto);
}
commit();
} catch (Exception e) {
rollback();
Logger.e("deleteArchive failed.", e);
throw new RuntimeException(e);
}
}
public boolean updateArchiveDetailInfo(ArchiveDto dto) {
long count = update("update t_archive set archive_name=?, archive_type=?, archive_date=?, room_id=?, attend_user_ids=?, file_path=?, save_user_id=? where archive_id=?", dto.getUpdateDetailValues());
return count > 0;
}
......
......@@ -21,8 +21,10 @@ public class TArchive extends SQLiteTableScript {
sql.append(" , archive_type INTEGER NOT NULL ");
sql.append(" , archive_date VARCHAR2(64) ");
sql.append(" , attend_user_ids VARCHAR2 ");
sql.append(" , file_path VARCHAR2 ");
sql.append(" , room_id INTEGER ");
sql.append(" , save_user_id INTEGER ");
sql.append(" , collaboration_detail_id INTEGER ");
sql.append(" , PRIMARY KEY (archive_id)");
sql.append(" ) ");
......
......@@ -9,17 +9,23 @@ public class ArchiveDto extends AbstractDto {
public Integer roomId;
public Integer saveuserId;
public String attendUserIds;
public Integer delFlg;
public String filePath;
public Integer collaborationDetailId;
public Integer delFlg = 0;
@Override
public Object[] getInsertValues() {
return new Object[]{archiveId, archiveName, archiveDate, archiveType, roomId, saveuserId, attendUserIds};
return new Object[]{archiveId, archiveName, archiveDate, archiveType, roomId, saveuserId, attendUserIds, collaborationDetailId, filePath};
}
@Override
public Object[] getUpdateValues() {
return new Object[]{archiveName, archiveDate, archiveType, roomId, saveuserId, attendUserIds, archiveId};
return new Object[]{archiveName, archiveType, archiveDate, collaborationDetailId, archiveId};
}
public Object[] getUpdateDetailValues() {
return new Object[]{archiveName, archiveType, archiveDate, roomId, attendUserIds, filePath, saveuserId, archiveId};
}
@Override
......
......@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
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.ArchiveDao;
import jp.agentec.abook.abv.bl.data.dao.ChatGroupDao;
......@@ -660,18 +661,29 @@ public class CommunicationLogic extends AbstractLogic {
public void updateArchives(List<ArchiveDto> archiveDtoList) {
List<ArchiveDto> insertList = new ArrayList<ArchiveDto>();
List<ArchiveDto> deleteList = new ArrayList<ArchiveDto>();
List<ArchiveDto> updateList = new ArrayList<ArchiveDto>();
List<Integer> existIdList = archiveDao.getExistArchiveIds();
for (ArchiveDto archiveDto : archiveDtoList) {
if (archiveDto.delFlg == 0) {
insertList.add(archiveDto);
} else {
if (archiveDto.delFlg == 1) {
deleteList.add(archiveDto);
} else {
if (existIdList.contains(archiveDto.archiveId)) {
updateList.add(archiveDto);
} else {
insertList.add(archiveDto);
}
}
}
archiveDao.insertArchiveList(insertList);
archiveDao.updateArchiveInfoList(updateList);
archiveDao.deleteArchiveList(deleteList);
}
public void updateArchiveDetial(ArchiveDto archiveDto) {
archiveDao.updateArchiveDetailInfo(archiveDto);
}
public void updateGroup(List<ChatGroupDto> GroupList) {
List<ChatGroupDto> existGroupList = chatGroupDao.getAllGroups();
......@@ -791,4 +803,50 @@ public class CommunicationLogic extends AbstractLogic {
}
return archiveArray.toString();
}
public String getArchiveListByName(String keywods) {
String[] replacedKeyword = keywods.replaceAll(" ", " ").split(" ");
List<ArchiveDto> archiveList = archiveDao.getArchiveListByName(replacedKeyword);
JSONArray archiveArray = new JSONArray();
for (ArchiveDto archive : archiveList) {
Map<String, Object> archiveMap = new HashMap<String, Object>();
archiveMap.put(ABookCommConstants.KEY.ARCHIVE_ID, archive.archiveId);
archiveMap.put(ABookCommConstants.KEY.ARCHIVE_NAME, archive.archiveName);
archiveMap.put(ABookCommConstants.KEY.ARCHIVE_DATE, archive.archiveDate);
archiveMap.put(ABookCommConstants.KEY.ARCHIVE_TYPE, archive.archiveType);
JSONObject jsonObject = new JSONObject(archiveMap);
archiveArray.put(jsonObject);
}
return archiveArray.toString();
}
public String getArchiveDetail(Integer archiveId) {
ArchiveDto archiveDto = archiveDao.getArchive(archiveId);
Map<String, Object> archiveMap = new HashMap<String, Object>();
archiveMap.put(ABookCommConstants.KEY.ARCHIVE_ID, archiveDto.archiveId);
archiveMap.put(ABookCommConstants.KEY.ARCHIVE_NAME, archiveDto.archiveName);
archiveMap.put(ABookCommConstants.KEY.ARCHIVE_DATE, archiveDto.archiveDate);
archiveMap.put(ABookCommConstants.KEY.ARCHIVE_TYPE, archiveDto.archiveType);
archiveMap.put(ABookCommConstants.KEY.ROOM_ID, archiveDto.roomId);
archiveMap.put(ABookCommConstants.KEY.ROOM_NAME, chatRoomDao.getChatRoom(archiveDto.roomId).chatRoomName);
archiveMap.put(ABookCommConstants.KEY.SAVE_USER_ID, archiveDto.saveuserId);
archiveMap.put(ABookCommConstants.KEY.ATTEND_USER_IDS, archiveDto.attendUserIds);
archiveMap.put(ABookCommConstants.KEY.FILE_PATH, archiveDto.filePath);
JSONObject jsonObject = new JSONObject(archiveMap);
return jsonObject.toString();
}
public ArchiveDto getArchive(Integer archiveId) {
return archiveDao.getArchive(archiveId);
}
public String getUserInfo(Integer shopMemberId) {
ShopMemberDto shopMemberDto = shopMemberDao.getShopMember(shopMemberId);
Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMemberDto.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMemberDto.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMemberDto.profileUrl);
JSONObject jsonObject = new JSONObject(userMap);
return jsonObject.toString();
}
}
......@@ -39,6 +39,7 @@ 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.ArchiveDetailJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ArchiveListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ChangeRoomNameJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON;
......@@ -55,6 +56,7 @@ 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.data.ABVDataCache;
import jp.agentec.abook.abv.bl.dto.ArchiveDto;
import jp.agentec.abook.abv.bl.dto.ChatGroupDto;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
......@@ -1044,7 +1046,34 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
return archiveListStr;
}
@JavascriptInterface
public String getArchiveListByName(String keyword) {
String archiveListStr = communicationLogic.getArchiveListByName(keyword);
return archiveListStr;
}
@JavascriptInterface
public String getUserInfo(String shopMemberId) {
String archiveListStr = communicationLogic.getUserInfo(Integer.parseInt(shopMemberId));
return archiveListStr;
}
@JavascriptInterface
public String getArchiveDetail(String archiveId) {
String archiveListStr = communicationLogic.getArchiveDetail(Integer.parseInt(archiveId));
return archiveListStr;
}
@JavascriptInterface
public void updateArchiveDetail(String archiveId) throws NetworkDisconnectedException, AcmsException {
ArchiveDto archiveDto = communicationLogic.getArchive(Integer.parseInt(archiveId));
ArchiveDetailJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getArchiveDetail(sid, Integer.parseInt(archiveId), archiveDto.collaborationDetailId);
if (resultJson.archiveDto == null) {
return;
}
communicationLogic.updateArchiveDetial(resultJson.archiveDto);
}
}
/**
......
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