Commit e7e39533 by Lee Munkyeong

アーカイブ実装

parent 4146f156
......@@ -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.ArchiveListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AuthLevelJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CategoriesJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ChangeRoomNameJSON;
......@@ -58,6 +59,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.GetArchivesParameters;
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;
......@@ -749,6 +751,21 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* アーカイブ取得
*
* @param sid
* @param updateDate
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public ArchiveListJSON getArchives(String sid, String updateDate) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetArchive, new GetArchivesParameters(sid, AcmsApis.ArchiveCmds.getArchive, updateDate));
ArchiveListJSON json = new ArchiveListJSON(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.abook.abv.bl.dto.ChatGroupDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.DateTimeUtil;
public class ArchiveListJSON extends AcmsCommonJSON {
public ArrayList<ArchiveDto> archiveList;
public String archiveLastUpdateDate;
public ArchiveListJSON(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_LIST)) { return; }
JSONArray archiveListJsonArray = json.getJSONObject(ABookCommConstants.KEY.BODY).getJSONArray(ABookCommConstants.KEY.ARCHIVE_INFO_LIST);
if (archiveListJsonArray == null) { return; }
archiveList = new ArrayList<ArchiveDto>();
for (int listCount = 0; listCount < archiveListJsonArray.length(); listCount++) {
if (archiveListJsonArray.getJSONObject(listCount).length() == 0) {
break;
}
JSONObject archiveJSON = archiveListJsonArray.getJSONObject(listCount);
ArchiveDto archiveDto = new ArchiveDto();
archiveDto.archiveId = archiveJSON.getInt(ABookCommConstants.KEY.ARCHIVE_ID);
archiveDto.archiveName = archiveJSON.getString(ABookCommConstants.KEY.ARCHIVE_NAME);
archiveDto.archiveType = archiveJSON.getInt(ABookCommConstants.KEY.ARCHIVE_TYPE);
archiveDto.archiveDate = DateTimeUtil.millToDateString(archiveJSON.getJSONObject(ABookCommConstants.KEY.TIME)
.getLong(ABookCommConstants.KEY.TIME));
archiveDto.delFlg = archiveJSON.getInt(ABookCommConstants.KEY.ARCHIVE_ID);
archiveList.add(archiveDto);
}
if (json.getJSONObject(ABookCommConstants.KEY.BODY).has(ABookCommConstants.KEY.ARCHIVE_INFO_LAST_UPDATE_DATE)) {
archiveLastUpdateDate = json.getJSONObject(ABookCommConstants.KEY.BODY).getString(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 GetArchivesParameters#sid} を持っているため、ログイン用のパラメータ {@link MobileLoginParameters} は、このクラスを継承する必要はありません。
* @author Taejin Hong
* @version 1.0.0
*/
public class GetArchivesParameters extends HttpParameterObject {
/**
* セッションID
* @since 1.0.0
*/
private String sid;
private String cmd;
private String updatedDate;
/**
* {@link GetArchivesParameters} のインスタンスを初期化します。
* @param sid ログインした時のセッションIDです。
* @param cmd Apiリクエストに必要なコマンド(ABOOK COMM専用)。
* @since 1.0.0
*/
public GetArchivesParameters(String sid, String cmd, String updatedDate) {
this.sid = sid;
this.cmd = cmd;
this.updatedDate = updatedDate;
}
/**
* セッションIDを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getSid() {
return sid;
}
/**
* コマンドを返します。
* @return ログインした時のセッションIDです。
* @since 1.0.0
*/
public String getCmd() {
return cmd;
}
public String getUpdatedDate() {
return updatedDate;
}
}
......@@ -174,6 +174,7 @@ public class AcmsApis {
public static final String ApigetUser = "user";
public static final String ApigetMessage = "message";
public static final String ApigetFavorite = "favorite";
public static final String ApigetArchive = "archive";
public static final class UserCmds {
public static final String inviteUsers = "3";
......@@ -201,6 +202,11 @@ public class AcmsApis {
public static final String removeFavoriteGroup = "8";
}
public static final class ArchiveCmds {
public static final String getArchive = "1";
public static final String getArchiveDetail = "2";
}
// download
/**
* コンテンツのZIPファイルを取得<br>
......@@ -247,7 +253,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) || methodName.equals(ApigetFavorite)) { // pushActionはchatapiを指定
} else if (methodName.equals(ApiGetChatPushData) || methodName.equals(ApigetChatRooms) || methodName.equals(ApigetUser) || methodName.equals(ApigetMessage) || methodName.equals(ApigetFavorite) || methodName.equals(ApigetArchive)) { // pushActionはchatapiを指定
apiValue = Constant.ApiValue.chatapi;
}
......
......@@ -57,6 +57,14 @@ public interface ABookCommConstants {
String FAVORITE_GROUP_IDS = "favoriteGroupIds";
String GROUP_INFO_LAST_UPDATE_DATE = "groupInfoLastUpdateDate";
String ARCHIVE_INFO_LIST = "archiveInfoList";
String ARCHIVE_ID = "archiveId";
String ARCHIVE_NAME = "archiveName";
String ARCHIVE_DATE = "archiveDate";
String ARCHIVE_TYPE = "archiveType";
String SAVE_USER_ID = "saveUserId";
String ATTEND_USER_IDS = "attendUserIds";
String ARCHIVE_INFO_LAST_UPDATE_DATE = "archiveInfoLastUpdateDate";
String ROOT_GROUP_ID = "rootGroupId";
String HTTP_STATUS = "httpStatus";
......
......@@ -31,27 +31,26 @@ public class ArchiveDao extends AbstractDao {
if (column != -1) {
dto.archiveName = cursor.getString(column);
}
column = cursor.getColumnIndex("archive_type");
column = cursor.getColumnIndex("archive_date");
if (column != -1) {
dto.archiveType = cursor.getInt(column);
dto.archiveDate = cursor.getString(column);
}
column = cursor.getColumnIndex("archive_url");
column = cursor.getColumnIndex("archive_type");
if (column != -1) {
dto.archiveUrl = cursor.getString(column);
dto.archiveType = cursor.getInt(column);
}
column = cursor.getColumnIndex("collaboration_id");
column = cursor.getColumnIndex("room_id");
if (column != -1) {
dto.collaborationId = cursor.getInt(column);
dto.roomId = cursor.getInt(column);
}
column = cursor.getColumnIndex("shop_member_id");
column = cursor.getColumnIndex("save_user_id");
if (column != -1) {
dto.shopMemberId = cursor.getInt(column);
dto.saveuserId = cursor.getInt(column);
}
column = cursor.getColumnIndex("archive_save_path");
column = cursor.getColumnIndex("attend_user_ids");
if (column != -1) {
dto.archiveSavePath = cursor.getString(column);
dto.attendUserIds = cursor.getString(column);
}
return dto;
}
......@@ -61,11 +60,11 @@ public class ArchiveDao extends AbstractDao {
}
public void insertArchive(ArchiveDto dto) {
insert("insert into t_archive (archive_id, archive_name, archive_type, archive_url, collaboration_id, shop_member_id, archive_save_path) values (?,?)", dto.getInsertValues());
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());
}
public boolean updateArchive(ArchiveDto dto) {
long count = update("update t_archive set archive_name=?, archive_type=?, archive_url=?, collaboration_id=?, shop_member_id=?, archive_save_path=? where archive_id=?", dto.getUpdateValues());
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());
return count > 0;
}
......
......@@ -17,12 +17,12 @@ public class TArchive extends SQLiteTableScript {
sql.append(" create table t_archive ( ");
sql.append(" archive_id INTEGER NOT NULL ");
sql.append(" , archive_name VARCHAR2(64) ");
sql.append(" , archive_name VARCHAR2 ");
sql.append(" , archive_type INTEGER NOT NULL ");
sql.append(" , archive_url VARCHAR2 ");
sql.append(" , collaboration_id INTEGER NOT NULL ");
sql.append(" , shop_member_id INTEGER NOT NULL ");
sql.append(" , archive_save_path VARCHAR2 ");
sql.append(" , archive_date VARCHAR2(64) ");
sql.append(" , attend_user_ids VARCHAR2 ");
sql.append(" , room_id INTEGER ");
sql.append(" , save_user_id INTEGER NOT NULL ");
sql.append(" , PRIMARY KEY (archive_id)");
sql.append(" ) ");
......
......@@ -4,21 +4,22 @@ public class ArchiveDto extends AbstractDto {
public Integer archiveId;
public String archiveName;
public String archiveDate;
public Integer archiveType;
public String archiveUrl;
public Integer collaborationId;
public Integer shopMemberId;
public String archiveSavePath;
public Integer roomId;
public Integer saveuserId;
public String attendUserIds;
public Integer delFlg;
@Override
public Object[] getInsertValues() {
return new Object[]{archiveId, archiveName, archiveType, archiveUrl, collaborationId, shopMemberId, archiveSavePath};
return new Object[]{archiveId, archiveName, archiveDate, archiveType, roomId, saveuserId, attendUserIds};
}
@Override
public Object[] getUpdateValues() {
return new Object[]{archiveName, archiveType, archiveUrl, collaborationId, shopMemberId,archiveSavePath, archiveId};
return new Object[]{archiveName, archiveDate, archiveType, roomId, saveuserId, attendUserIds, archiveId};
}
@Override
......
......@@ -12,10 +12,12 @@ import java.util.stream.Collectors;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
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;
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.ShopMemberDao;
import jp.agentec.abook.abv.bl.dto.ArchiveDto;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.ChatGroupDto;
......@@ -35,6 +37,7 @@ public class CommunicationLogic extends AbstractLogic {
private ChatMessageDao chatMessageDao = AbstractDao.getDao(ChatMessageDao.class);
private ShopMemberDao shopMemberDao = AbstractDao.getDao(ShopMemberDao.class);
private ChatGroupDao chatGroupDao = AbstractDao.getDao(ChatGroupDao.class);
private ArchiveDao archiveDao = AbstractDao.getDao(ArchiveDao.class);
/**
* {@link CommunicationLogic} クラスのインスタンスを初期化します。
......@@ -654,6 +657,21 @@ public class CommunicationLogic extends AbstractLogic {
//shopMemberDao.deleteShopMemberByList(deleteList);
}
public void updateArchives(List<ArchiveDto> archiveDtoList) {
List<ArchiveDto> insertList = new ArrayList<ArchiveDto>();
List<ArchiveDto> deleteList = new ArrayList<ArchiveDto>();
for (ArchiveDto archiveDto : archiveDtoList) {
if (archiveDto.delFlg == 0) {
insertList.add(archiveDto);
} else {
deleteList.add(archiveDto);
}
}
archiveDao.insertArchiveList();
archiveDao.deleteArchiveList();
}
public void updateGroup(List<ChatGroupDto> GroupList) {
List<ChatGroupDto> existGroupList = chatGroupDao.getAllGroups();
......
......@@ -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.ArchiveListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ChangeRoomNameJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GetFavoriteGroupJSON;
......@@ -1023,6 +1024,20 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
public void updateFavorite() throws NetworkDisconnectedException, AcmsException {
updateFavoriteInfo();
}
@JavascriptInterface
public void updateArchiveList() throws NetworkDisconnectedException, AcmsException {
SharedPreferences pref = getSharedPreferences(ABookCommConstants.TAG,MODE_PRIVATE);
String updateDate = pref.getString(ABookCommConstants.KEY.ARCHIVE_INFO_LAST_UPDATE_DATE, DEFAULT_CHECKSUM);
ArchiveListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getArchives(sid, updateDate);
communicationLogic.updateArchives(resultJson.archiveList);
if (StringUtil.isNullOrEmpty(resultJson.archiveLastUpdateDate)) { return; }
SharedPreferences.Editor editor = pref.edit();
editor.putString(ABookCommConstants.KEY.ARCHIVE_INFO_LAST_UPDATE_DATE, resultJson.archiveLastUpdateDate);
editor.commit();
}
}
/**
......
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