Commit ef288ede by Kim Peace

Merge commit 'd1eb0aa0' into communication/develop

# Conflicts:
#	ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/OperationListActivity.java
parents 731b6188 d1eb0aa0
......@@ -141,6 +141,13 @@ public class Constant {
int ReportContinuous = 3; // 連続作業
}
public interface operationType {
int LIST = 0;
int DRAWING = 1;
int CONTENT360 = 2;
}
// 報告履歴管理
public interface EnableReportHistory {
int Invalid = 0; // 無効
......
package jp.agentec.abook.abv.bl.download;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import jdk.nashorn.internal.codegen.CompilerConstants;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.ContentDownloadLogParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.FetchDateParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
......@@ -123,6 +124,34 @@ public class ContentRefresher {
refreshWorker.start();
}
public void refreshContentList(ContentDownloadListener listener, Callback progressCallback) throws Exception {
if (contentDownloader.getActiveCount() > 0) { // コンテンツのダウンロード中は、自動更新を行わない。
contentDownloader.kickTask(); // waitingで止まらないように実行を促す
throw new ABVException(ABVExceptionCode.C_I_CONTENT_0002);
}
networkAdapter = ABVEnvironment.getInstance().networkAdapter;
if (networkAdapter != null && !networkAdapter.isNetworkConnected()) { // NWのチェック
throw new NetworkDisconnectedException();
}
if (!AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).checkSid(cache.getMemberInfo().sid)) { // SIDのチェックをここで行う
throw new ABVException(ABVExceptionCode.S_E_ACMS_1403);
}
if (isRefreshing()) { // すでに実行中か
throw new ABVException(ABVExceptionCode.C_I_CONTENT_0001);
}
if (listener != null) {
contentDownloadListener = listener;
}
initializingRefreshing = true;
contentDownloader.pauseAll();
refreshWorker = new RefreshContentWorker(progressCallback);
refreshWorker.setPriority(Thread.MIN_PRIORITY);
refreshWorker.start();
}
public void addRefreshingContentId(long contentId) {
refreshingContentMap.put(contentId, false);
}
......@@ -146,50 +175,73 @@ public class ContentRefresher {
private class RefreshContentWorker extends Thread {
private boolean interrupt = false;
private Callback mProgressCallback;
public RefreshContentWorker(Callback progressCallback) {
mProgressCallback = progressCallback;
}
public RefreshContentWorker() {
}
public void stopWorker() {
interrupt = true;
}
@Override
public void run() {
Logger.i(TAG, "refresh main thread start.-----------------------------------------------");
interrupt = false;
try {
boolean isFinishedContentCheck = false;
boolean isFinishedContentCheck = false;
List<ContentDto> localContents = contentDao.getAllContents();
if (networkAdapter.isNetworkConnected()) { // オンライン時の処理
resendLog(); // ログ送信
contractLogic.initializeContractServiceOption(); // サービスオプション関連処理
if (mProgressCallback != null) {
mProgressCallback.callback(10);
}
groupLogic.initializeGroups(); // グループ設定(グループ変更の場合、FetchDateをクリアする)
if (mProgressCallback != null) {
mProgressCallback.callback(5);
}
categoryLogic.initializeCategories(); // カテゴリ設定
// 絞り検索マスタデータの最新更新された時のFetchDateを一時に保存する。
if (mProgressCallback != null) {
mProgressCallback.callback(5);
}
// CMSでメンテナンスされる絞り検索マスタデータをアプリから取得できるようにJSONファイルを生成する。
apertureMasterDataLogic.initializeApertureMasterData();
if (mProgressCallback != null) {
mProgressCallback.callback(5);
}
// 作業種別情報を取得
operationGroupMasterLogic.setOperationGroupMaster();
if (mProgressCallback != null) {
mProgressCallback.callback(5);
}
if (interrupt) { // この時点で停止要求が来た場合先には進まない。(ServiceOption/Group/Categoryの更新は1セットで行う(トランザクションはそれぞれ別))
Logger.d(TAG, "stop refresh worker before content update.");
setFail();
updateRefreshContentListState(-1L, null);
updateRefreshContentListState(-1L, null, mProgressCallback);
return;
}
isFinishedContentCheck = retrieveServerContent(localContents); // ContentVersionAPIを呼出し新規と更新の場合ContentInfoをDLする
isFinishedContentCheck = retrieveServerContent(localContents, mProgressCallback); // ContentVersionAPIを呼出し新規と更新の場合ContentInfoをDLする
}
deleteLocalContent(localContents, isFinishedContentCheck); // コンテンツ削除処理
initializingRefreshing = false;
if (!isRefreshing()) {
updateRefreshContentListState(-1L, null);
updateRefreshContentListState(-1L, null, mProgressCallback);
}
mProgressCallback.callback(100);
} catch (Exception e) {
Logger.e("refreshContent failed.", e);
mProgressCallback.callback(100);
updateRefreshContentListState(-1L, e);
}
contentDownloader.kickTask();
......@@ -267,7 +319,7 @@ public class ContentRefresher {
* @return 変更あり:true、変更なし:false
* @throws Exception
*/
private boolean retrieveServerContent(List<ContentDto> localContents) throws Exception {
private boolean retrieveServerContent(List<ContentDto> localContents, Callback mProgressCallback) throws Exception {
// コンテンツバージョン用lastFetchDateの取得
AcmsDao dao = AbstractDao.getDao(AcmsDao.class);
String lastFetchDate = dao.selectContentVersionLastFetchDate();
......@@ -290,6 +342,12 @@ public class ContentRefresher {
List<ContentDto> serverContents = json.contentVersions;
// DTO Info:contentId, metaVersion, resourceVersion, contentNameKana, readerShareFlg
int progressPercent = 0;
if (CollectionUtil.isNotEmpty(serverContents) && serverContents.size() != 0) {
progressPercent = 50 / serverContents.size() < 1 ? 1 : 50 / serverContents.size();
}
int totalProgress = 0;
for (ContentDto serverContentDto : serverContents) {
while (isBusyRefreshingContent()) {
if (interrupt) {
......@@ -328,11 +386,44 @@ public class ContentRefresher {
}
}
}
if (mProgressCallback != null && totalProgress < 50) {
mProgressCallback.callback(progressPercent);
totalProgress = totalProgress + progressPercent;
}
}
return true;
}
}
public void updateRefreshContentListState(long contentId, Exception e, Callback mCallBack) {
Logger.d(TAG, "[updateRefreshContentListState]: contentId=%s", contentId);
//noinspection VariableNotUsedInsideIf
if (e != null) {
setFail();
}
if (contentDownloadListener != null) {
if (!isRefreshing() && e == null) {
// 新着処理が終わったら以下の処理が実行
try {
// サーバー通信でプロジェクト取得
if(mCallBack != null) {
mCallBack.callback(5);
operationLogic.initializeOperations(mCallBack);
} else {
operationLogic.initializeOperations();
}
} catch (Exception e1) {
Logger.e(TAG, e1);
e = e1;
}
}
contentDownloadListener.onRefreshedContent(e == null, contentId, e);
}
}
public void updateRefreshContentListState(long contentId, Exception e) {
Logger.d(TAG, "[updateRefreshContentListState]: contentId=%s", contentId);
//noinspection VariableNotUsedInsideIf
......@@ -354,7 +445,7 @@ public class ContentRefresher {
contentDownloadListener.onRefreshedContent(e == null, contentId, e);
}
}
public void stopRefresh() {
if (isRefreshing() && refreshWorker != null) {
refreshWorker.stopWorker();
......
......@@ -110,6 +110,14 @@ public class OperationLogic extends AbstractLogic {
retrieveServerOperation();
}
public void initializeOperations(Callback mCallBack) throws AcmsException, NetworkDisconnectedException {
// 作業グループリスト取得
setWorkingGroupList();
mCallBack.callback(5);
// 作業一覧取得し、登録・更新・削除する
retrieveServerOperation(mCallBack);
}
/**
* 作業一覧取得し、登録・更新・削除する
*
......@@ -278,6 +286,159 @@ public class OperationLogic extends AbstractLogic {
}
}
private void retrieveServerOperation(Callback mCallBack) throws AcmsException, NetworkDisconnectedException {
List<OperationDto> localOperations = mOperationDao.getAllOperation();
AcmsParameters param = new AcmsParameters(cache.getMemberInfo().sid);
OperationListJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).getOperationList(param);
List<OperationDto> serverOperations = json.operationList;
for (OperationDto serverOperationDto : serverOperations) {
// 登録フラグ
boolean insertFlg = true;
for (OperationDto localOperationDto : localOperations) {
if (serverOperationDto.operationId.equals(localOperationDto.operationId)) {
//update
serverOperationDto.needSyncFlg = serverOperationDto.equalsLastEdit(localOperationDto) ? localOperationDto.needSyncFlg : true;
List<Long> localOperationContentIds = mOperationContentDao.getContentIds(serverOperationDto.operationId);
for (OperationContentDto operationContentDto : serverOperationDto.operationContentDtoList) {
if (localOperationContentIds == null || localOperationContentIds.size() == 0) {
// insert
mOperationContentDao.insertOperationContent(operationContentDto);
} else {
int localOperationContentIndex = localOperationContentIds.indexOf(operationContentDto.contentId);
if (localOperationContentIndex >= 0) {
// 存在する
localOperationContentIds.remove(localOperationContentIndex);
} else {
// insert
mOperationContentDao.insertOperationContent(operationContentDto);
}
}
}
if (localOperationContentIds != null) {
// 関連資料の削除処理
for (Long deleteContentId : localOperationContentIds) {
mOperationContentDao.deleteOperationContent(localOperationDto.operationId, deleteContentId);
}
}
if (mOperationContentDao.isExistMainOperationContent(serverOperationDto.operationId)) {
serverOperationDto.contentCreatingFlg = false;
}
// ローカルにある作業情報に紐づく全作業IDを取得
List<Integer> localOperationGroupMasterIds = mOperationGroupMasterOperationDao.getOperationGroupMasterIds(serverOperationDto.operationId);
for (OperationGroupMasterRelationDto operationGroupMasterRelationDto : serverOperationDto.operationGroupMasterRelationDtoList) {
if (localOperationGroupMasterIds == null || localOperationGroupMasterIds.size() == 0) {
// 作業IDが存在しなければ、登録する
mOperationGroupMasterOperationDao.insertOperationGroupMasterOperation(operationGroupMasterRelationDto);
} else {
// ローカル(DB)に作業IDが存在するかチェックして更新・登録を判定
int localOperationContentIndex = localOperationGroupMasterIds.indexOf(operationGroupMasterRelationDto.operationGroupMasterId);
if (localOperationContentIndex >= 0) {
// 作業IDが存在するので更新
localOperationGroupMasterIds.remove(localOperationContentIndex);
} else {
// 作業IDが存在しないので登録
mOperationGroupMasterOperationDao.insertOperationGroupMasterOperation(operationGroupMasterRelationDto);
}
}
}
if (localOperationGroupMasterIds != null) {
// ローカルとサーバーの差分は削除と見做し、削除処理を行う。
for (Integer deleteOperationGroupMasterId : localOperationGroupMasterIds) {
mOperationGroupMasterOperationDao.deleteOperationGroupMasterOperation(deleteOperationGroupMasterId, serverOperationDto.operationId);
}
}
mOperationDao.update(serverOperationDto);
// 更新することで登録フラグをfalseにセット
insertFlg = false;
break;
}
mCallBack.callback(1);
}
// 更新されたら以下の処理は行わない
if (insertFlg) {
boolean isNotExistContent = false;
for (OperationContentDto operationContentDto : serverOperationDto.operationContentDtoList) {
if (operationContentDto.operationContentFlg) {
if(mContentDao.getContent(operationContentDto.contentId) == null) {
isNotExistContent = true;
}
}
}
// コンテンツテーブルに存在しない場合、プロジェクトを登録しない
if (isNotExistContent) { continue; }
serverOperationDto.needSyncFlg = true;
serverOperationDto.contentCreatingFlg = false;
mOperationDao.insert(serverOperationDto);
// 関連資料の登録
for (OperationContentDto operationContentDto : serverOperationDto.operationContentDtoList) {
mOperationContentDao.insertOperationContent(operationContentDto);
}
// 作業種別・作業のリレーションテーブルにデータ登録
for (OperationGroupMasterRelationDto operationGroupMasterRelationDto : serverOperationDto.operationGroupMasterRelationDtoList) {
mOperationGroupMasterOperationDao.insertOperationGroupMasterOperation(operationGroupMasterRelationDto);
}
mCallBack.callback(2);
}
// 作業担当グループ登録
mTaskWorkerGroupDao.deleteByOperationId(serverOperationDto.operationId);
for (TaskWorkerGroupDto taskWorkerGroupDto : serverOperationDto.taskWorkerGroupDtoList) {
taskWorkerGroupDto.operationId = serverOperationDto.operationId;
for (Integer groupId : taskWorkerGroupDto.groupList) {
taskWorkerGroupDto.groupId = groupId;
mTaskWorkerGroupDao.insert(taskWorkerGroupDto);
}
}
for (PushMessageDto dto : serverOperationDto.pushMessageList) {
mPushMessageDao.insert(dto);
}
}
List<OperationDto> deleteListDtoArray = new ArrayList<OperationDto>();
for (OperationDto localProjcetDto : localOperations) {
boolean deleteFlg = true;
for (OperationDto serverOperationDto : serverOperations) {
if (localProjcetDto.operationId.equals(serverOperationDto.operationId)) {
deleteFlg = false;
break;
}
}
if (deleteFlg) {
deleteListDtoArray.add(localProjcetDto);
}
}
// サーバーから取得した作業情報がローカルに存在しないので削除する
for (OperationDto deleteOperationDto : deleteListDtoArray) {
List<TaskDto> taskDtoList = mTaskDao.selectAllTaskByOperationId(deleteOperationDto.operationId);
List<Long> contentIds = mOperationContentDao.getContentIds(deleteOperationDto.operationId);
for(TaskDto taskDto : taskDtoList) {
mTaskDao.delete(taskDto);
}
mPushMessageDao.delete(deleteOperationDto.operationId);
mOperationDao.delete(deleteOperationDto);
// 作業削除時、紐づいた資料を削除
for (Long contentId : contentIds) {
if (mOperationContentDao.isDeleteContent(contentId)) {
ContentDto contentDto = mContentDao.getContent(contentId);
mContentLogic.deleteContent(contentDto, true);
}
}
String operationTaskDirPath = ABVEnvironment.getInstance().getOperationDirFile(deleteOperationDto.operationId);
FileUtil.delete(operationTaskDirPath);
}
}
/**
* サーバーから作業者グループ取得し、m_worker_groupテーブルへ登録
*
......
Subproject commit 5d0e71bd7ff6383baab4a0f7f333279b7307a27a
Subproject commit 89f7f804a54cf4890189864d9384f6b3de21ccb4
......@@ -2,6 +2,7 @@ package jp.agentec.abook.abv.ui.common.activity;
import jp.agentec.abook.abv.bl.acms.type.DownloadStatusType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
......@@ -27,6 +28,7 @@ import jp.agentec.abook.abv.ui.common.util.LogUtil;
import jp.agentec.abook.abv.ui.home.activity.ABookSettingActivity;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
......@@ -159,7 +161,7 @@ public abstract class ABVUIActivity extends ABVAuthenticatedActivity {
return super.onKeyUp(keyCode, event);
}
public boolean refreshContent(boolean isAutoRefresh) throws NetworkDisconnectedException {
boolean result = true;
try {
......@@ -167,7 +169,6 @@ public abstract class ABVUIActivity extends ABVAuthenticatedActivity {
Logger.d(TAG, "contentDownloader.isRefreshing() %s", result);
getABVUIDataCache().preIsCatalogEdition = ABVDataCache.getInstance().serviceOption.isCatalogEdition();
if (!result) {
startUpdateAnimation();
// contentDownloadObserverがnullだと更新マークのアニメーションが完了しない TODO 2014/11/12 Jang
......@@ -223,6 +224,33 @@ public abstract class ABVUIActivity extends ABVAuthenticatedActivity {
return result;
}
public boolean refreshContent(boolean isAutoRefresh, Callback progressCallback) throws Exception {
boolean result = true;
try {
result = contentRefresher.isRefreshing();
Logger.d(TAG, "contentDownloader.isRefreshing() %s", result);
getABVUIDataCache().preIsCatalogEdition = ABVDataCache.getInstance().serviceOption.isCatalogEdition();
if (!result) {
startUpdateAnimation();
// contentDownloadObserverがnullだと更新マークのアニメーションが完了しない TODO 2014/11/12 Jang
// onCreateでrefresh処理をcallしたときに起きる
contentRefresher.refreshContentList(this, progressCallback);
// ログ送信可否を確認
LogUtil.checkSendLogFlag();
}
} catch (Exception e) {
stopUpdateAnimation();
if (startRefresh) {
startRefresh = false;
}
throw e;
}
return result;
}
/** 
* グリッド初期化
* onCreateでは呼ばないないこと!!
......@@ -246,6 +274,15 @@ public abstract class ABVUIActivity extends ABVAuthenticatedActivity {
return false;
}
protected boolean dataRefresh(boolean isAutoRefresh, Callback progressCallback) throws Exception {
try {
return refreshContent(isAutoRefresh, progressCallback);
} catch (Exception e) {
Logger.e(TAG, "dataRefresh Fail" + e);
throw e;
}
}
// // @{ABVAuthenticatedActivity.contentLinkCheckDeliverable}と同じ
// //非公開と期間終了のコンテンツがある場合削除
......
......@@ -87,7 +87,7 @@ repeat_default=true
#Setting Info(設定画面のABookについての設定情報)
version_name=1.4.100
release_date=2021/07/29
release_date=2021/09/02
copy_right=2016 AGENTEC Co.,Ltd. All rights reserved.
hope_page=http://www.agentec.jp
contact_email=abook-appsupport@agentec.jp
......
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