Commit c67bb94a by nakamura akane

Merge branch 'features/1.2.0_ogawa-y' into 'contract/kagome/1.2.1'

マスタ機能移植および、絞り込み条件周りの処理の修正

See merge request !61
parents bb42b57b 44d498d7
......@@ -21,6 +21,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.ContentCheckDeliverableJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.LogSendFlagJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.NewAppStoreLoginJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationGroupMasterJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ApertureMasterDataJSON;
......@@ -998,4 +999,17 @@ public class AcmsClient implements AcmsClientResponseListener {
}
}
}
/**
* ACMSから、マスタデータ情報を取得します。
* @param param {@link AcmsParameters} オブジェクトです。
* @return コンテンツバージョン情報を格納した {@link ContentDto} のリストを返します。
* 情報の変更がない(HttpStatus 304)場合はnullを返す。
* @since 1.0.0
*/
public MasterDataJSON masterData(AcmsParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiGetMasterData, param);
MasterDataJSON json = new MasterDataJSON(response.httpResponseBody);
return json;
}
}
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONObject;
import java.util.HashMap;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
/**
* {@link AcmsClient#contentVersion} の戻り値です。
* @author Taejin Hong
* @version 1.0.0
*/
public class MasterDataJSON extends AcmsCommonJSON {
public static final String MasterData = "masterData";
public static final String BelongGroup = "belongGroup";
public static final String Staff = "staff";
public static final String Selective = "selective";
public static final String InspectCheck = "inspectCheck";
public static final String InspectNumber = "inspectNumber";
public static final String FetchDate = "fetchDate";
public String fetchDate; // 取得日時(Timestamp yyyy-MM-dd HH:mm:ssGMT)
public Map<String, String> masterDataMap; // JSONマスタ(JSONオブジェクト)
public MasterDataJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
// fechDateの値をデバイスに保持し、次回API呼び出し時のパラメータに設定する。
if (json.has(FetchDate)) {
fetchDate = json.getString(FetchDate);
}
// マスタデータを取得する。
if (json.has(MasterData)) {
masterDataMap = new HashMap<String, String>();
JSONObject masterData = json.getJSONObject(MasterData);
// belongGroupの報告対象マスタ(JSONオブジェクト)
if (masterData.has(BelongGroup)) {
JSONObject belognGroupJson = masterData.getJSONObject(BelongGroup);
masterDataMap.put(BelongGroup, belognGroupJson.toString());
}
// staffの報告者マスタ(JSONオブジェクト)
if (masterData.has(Staff)) {
JSONObject staffJson = masterData.getJSONObject(Staff);
masterDataMap.put(Staff, staffJson.toString());
}
// selectiveの選択型マスタ(JSONオブジェクト)
if (masterData.has(Selective)) {
JSONObject selectiveJson = masterData.getJSONObject(Selective);
masterDataMap.put(Selective, selectiveJson.toString());
}
// inspectCheckの点検チェック型マスタ(JSONオブジェクト)
if (masterData.has(InspectCheck)) {
JSONObject inspectCheckJson = masterData.getJSONObject(InspectCheck);
masterDataMap.put(InspectCheck, inspectCheckJson.toString());
}
// inspectNumberの点検数値型マスタ(JSONオブジェクト)
if (masterData.has(InspectNumber)) {
JSONObject inspectNumberJson = masterData.getJSONObject(InspectNumber);
masterDataMap.put(InspectNumber, inspectNumberJson.toString());
}
} else {
throw new JSONValidationException(json.toString(), MasterData + " property not found.");
}
}
}
......@@ -152,6 +152,9 @@ public class AcmsApis {
public static final String ApiGetPushMessages = "getPushMessage";
// 定期点検データ送信
public static final String ApiSendRoutineTaskData = "routineTaskData";
// マスタデータ取得
public static final String ApiGetMasterData = "getMasterData";
// 作業種別データ取得
public static final String ApiOperationGroupMaster = "operationGroupMaster";
// 絞り検索マスタデータ取得
......@@ -200,7 +203,7 @@ public class AcmsApis {
} else if (methodName.equals(ApiOperationList) || methodName.equals(ApiWorkingGroupList) || methodName.equals(ApiSendTaskData) || methodName.equals(ApiGetOperationData) ||
methodName.equals(ApiGetTaskFile) || methodName.equals(ApiSceneEntry) || methodName.equals(ApiTaskContentEntry) ||
methodName.equals(ApiSendPushMessage) || methodName.equals(ApiGetPushMessages) || methodName.equals(ApiSendRoutineTaskData) ||
methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiGetApertureMasterData)) {
methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiGetApertureMasterData) || methodName.equals(ApiGetMasterData)) {
apiValue = Constant.ApiValue.checkapi;
}
......
......@@ -62,6 +62,9 @@ public class ABVEnvironment {
// Serverから取得したcontentVersion時のリソースパターンを一時的に保存するための変数
public int resourcePatternType;
// Serverから取得したmasterDataのfetchDateを一時的に保存するための変数
public String tempMasterDataFetchDate = "";
public boolean operationGroupMasterClearFlg;
////////////////////////////// 定数 //////////////////////////////////
......@@ -183,6 +186,8 @@ public class ABVEnvironment {
public boolean enableToastMessage = true;
// マスタ参照パス
public static final String OperationMasterDataDirFormat = "%s/ABook/operation/master";
// 絞り検索マスタ参照パス
public static final String ApertureMasterDataDirFormat = "%s/ABook/operation/apertureMaster";
......@@ -798,7 +803,13 @@ public class ABVEnvironment {
// MasterDataに対したJSONファイルの位置
// 経路:root/files/operation/apertureMaster
public String getMasterFilePath() {
public String getApertureMasterFilePath() {
return String.format(ApertureMasterDataDirFormat, rootDirectory);
}
// MasterDataに対したJSONファイルの位置
// 経路:root/files/operation/master
public String getMasterFilePath() {
return String.format(OperationMasterDataDirFormat, rootDirectory);
}
}
package jp.agentec.abook.abv.bl.data;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
......@@ -40,6 +39,9 @@ public class ABVDataCache {
private Date lastPresentTime = DateTimeUtil.getCurrentDate(); // 最後の通信時に取得したサーバの時間
private static final int SEVER_ALERT_INTERVAL = 30; //システム日付チェック前後期間(分)
// Serverから取得したmasterDataのfetchDateを一時的に保存するための変数
public String tempMasterDataFetchDate = null;
// Serverから取得したapertureMasterDataのfetchDateを一時的に保存するための変数
private String tempApertureMasterDataFetchDate = null;
......@@ -237,6 +239,7 @@ public class ABVDataCache {
defaultCategoryId = -1;
defaultGroupId = -1;
urlPath = null;
tempMasterDataFetchDate = null;
// 絞り検索の取得日付を初期化
tempApertureMasterDataFetchDate = null;
}
......
package jp.agentec.abook.abv.bl.download;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -30,6 +29,7 @@ import jp.agentec.abook.abv.bl.logic.ContentReadingLogLogic;
import jp.agentec.abook.abv.bl.logic.ContractLogic;
import jp.agentec.abook.abv.bl.logic.EnqueteLogic;
import jp.agentec.abook.abv.bl.logic.GroupLogic;
import jp.agentec.abook.abv.bl.logic.MasterDataLogic;
import jp.agentec.abook.abv.bl.logic.OperationGroupMasterLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.adf.util.CollectionUtil;
......@@ -67,6 +67,7 @@ public class ContentRefresher {
// masterDataを取得するため登録
private MasterDataLogic masterDataLogic = AbstractLogic.getLogic(MasterDataLogic.class);
private ApertureMasterDataLogic apertureMasterDataLogic = AbstractLogic.getLogic(ApertureMasterDataLogic.class);
private OperationGroupMasterLogic operationGroupMasterLogic = AbstractLogic.getLogic(OperationGroupMasterLogic.class);
......@@ -164,6 +165,16 @@ public class ContentRefresher {
contractLogic.initializeContractServiceOption(); // サービスオプション関連処理
groupLogic.initializeGroups(); // グループ設定(グループ変更の場合、FetchDateをクリアする)
categoryLogic.initializeCategories(); // カテゴリ設定
// マスタデータの最新更新された時のFetchDateを一時に保存する。
Logger.d(TAG, "before fetchDate : " + ABVEnvironment.getInstance().tempMasterDataFetchDate);
// CMSでメンテナンスされるHACCPマスタデータをアプリから取得できるようにJSONファイルを生成する。
String fetchDate = masterDataLogic.initializeMasterData(ABVEnvironment.getInstance().tempMasterDataFetchDate);
Logger.d(TAG, "after fetchDate : " + fetchDate);
// マスタデータの最新更新された時のFetchDateを一時に保存する。
ABVEnvironment.getInstance().tempMasterDataFetchDate = fetchDate;
// 絞り検索マスタデータの最新更新された時のFetchDateを一時に保存する。
// CMSでメンテナンスされる絞り検索マスタデータをアプリから取得できるようにJSONファイルを生成する。
......
package jp.agentec.abook.abv.bl.logic;
import org.json.adf.JSONException;
import org.json.adf.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.Iterator;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.ApertureMasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetApertureMasterDataParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.common.util.JsonUtil;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.FileUtil;
public class ApertureMasterDataLogic extends AbstractLogic {
......@@ -66,7 +56,7 @@ public class ApertureMasterDataLogic extends AbstractLogic {
*/
private void createApertureMasterDataJson(JSONObject masterDataJson) throws IOException {
// マスタデータの保存されるパス
String masterDataJsonPath = ABVEnvironment.getInstance().getMasterFilePath() + File.separator + ABVEnvironment.getInstance().ApertureMasterDataFileName;
String masterDataJsonPath = ABVEnvironment.getInstance().getApertureMasterFilePath() + File.separator + ABVEnvironment.getInstance().ApertureMasterDataFileName;
FileUtil.createFile(masterDataJsonPath, masterDataJson.toString());
}
}
package jp.agentec.abook.abv.bl.logic;
import java.io.IOException;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.MasterDataJSON;
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.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.adf.util.FileUtil;
public class MasterDataLogic extends AbstractLogic {
private static final String TAG = "MasterDataLogic";
/**
* グループ情報をサーバから受信し、ローカルに保存します。既存のデータは上書きされます。また、サーバにないグループがローカルにある場合、そのグループは削除されます。
* マスタデータ情報をサーバから受信し、ローカルにJSONで保存する。で、
* データ単位で項目はあるが要素が0件のデータは削除、
* データ単位で項目が存在しないデータは変更無し
* @throws ABVException キャッシュにユーザ情報がありません。再度ログインする必要があります。
* @throws AcmsException
* @throws Exception その他、例外です。
* @since 1.0.0
*/
public String initializeMasterData(String lastFetchDate) {
String fetchDate = null;
try {
FetchDateParameters param = new FetchDateParameters(cache.getMemberInfo().sid, lastFetchDate);
MasterDataJSON masterDataJson = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).masterData(param);
// get MAP
Map<String, String> masterDataMap = masterDataJson.masterDataMap;
// Map に保存されたデータをJSONに変換する。
for (Map.Entry<String, String> entry : masterDataMap.entrySet()) {
System.out.println(entry.getKey() + ":" + entry.getValue());
try {
createMasterDataJson(entry.getKey(), entry.getValue());
} catch (IOException e) {
Logger.e(TAG, "masterDataJSON error : ", e);
throw e;
}
}
fetchDate = masterDataJson.fetchDate;
} catch (Exception e) {
Logger.e(TAG, "masterDataSend error : ", e);
}
// masterData の fetchDateを渡す。
return fetchDate;
}
/**
* content.jsonファイル作成
*
* @param jsonKeyData
* @param jsonValueData
* @throws IOException
*/
private void createMasterDataJson(String jsonKeyData, String jsonValueData) throws IOException {
// マスタデータの保存されるパース
String masterDataJsonPath = ABVEnvironment.getInstance().getMasterFilePath() + "/" + jsonKeyData + ".json";
if (jsonValueData.contains(",")) {
// マスタデータのJSONのパース設定
FileUtil.createFile(masterDataJsonPath, jsonValueData);
} else {
// データ単位で項目はあるが要素が0件のデータは削除
FileUtil.deleteFileOnly(masterDataJsonPath);
}
}
}
......@@ -839,7 +839,10 @@ public class OperationLogic extends AbstractLogic {
jsonObject.put("attachedMoviePath", ABVEnvironment.getInstance().getAttachedMoviesFilePath(contentId));
// 絞り検索マスタデータのパス
jsonObject.put("masterPath",ABVEnvironment.getInstance().getMasterFilePath() + File.separator + ABVEnvironment.getInstance().ApertureMasterDataFileName);
jsonObject.put("apertureMasterPath",ABVEnvironment.getInstance().getApertureMasterFilePath() + File.separator + ABVEnvironment.getInstance().ApertureMasterDataFileName);
// マスタデータのパースを参照するために「content.json」に保存する。
jsonObject.put("masterPath", ABVEnvironment.getInstance().getMasterFilePath());
FileUtil.createFile(contentPath + "/content.json", jsonObject.toString());
}
......
......@@ -53,6 +53,9 @@ public class ABVApplication extends MultiDexApplication {
//添付ファイル臨時保存場所削除
FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
// masterDataの fetchDateのローカルに保存された値を取得し、新着更新時に利用するため、セットして置く。
ABVDataCache.getInstance().tempMasterDataFetchDate = PreferenceUtil.getUserPref(this, AppDefType.UserPrefKey.MASTER_DATA_FETCH_DATE, null);
// 絞り検索のfetchDateをローカルに保存された値を取得して設定する
ABVDataCache.getInstance().setTempApertureMasterDataFetchDate(PreferenceUtil.getUserPref(this, AppDefType.UserPrefKey.APERTURE_MASTER_DATA_FETCH_DATE, null));
}
......
......@@ -68,6 +68,7 @@ public interface AppDefType {
String OPERATION_SORT_CONDITION = "operation_sort_condition"; // 作業のソート
String APERTURE_MASTER_DATA_FETCH_DATE = "apertureMasterDataFetchDate"; // 絞り検索マスタデータのFetchDate
String MASTER_DATA_FETCH_DATE = "masterDataFetchDate"; // マスタデータのFetchDate
}
interface SubMenuType {
......
......@@ -441,6 +441,8 @@ public class OperationListActivity extends ABVUIActivity {
getABVUIDataCache().saveLastUpdateTime();
// リソースパターンを取得し、ローカルに保存する。
setResourcePattern();
// マスタデータ最新更新する時fetchDateをローカルに保存する。
setMasterDataFetchDate();
// 絞り検索マスタデータ最新更新する時fetchDateをローカルに保存する。
setApertureMasterDataFetchDate();
......@@ -1955,6 +1957,11 @@ public class OperationListActivity extends ABVUIActivity {
}
}
private void setMasterDataFetchDate() {
Logger.d(TAG, "ABVDataCache.getInstance().tempMasterDataFetchDate : " + ABVDataCache.getInstance().tempMasterDataFetchDate);
putUserPref(AppDefType.UserPrefKey.MASTER_DATA_FETCH_DATE, ABVDataCache.getInstance().tempMasterDataFetchDate);
}
/**
* カテゴリ選択した内容で設定・表示する
* @param type 0 : 全て 1: カテゴリ
......
......@@ -38,8 +38,8 @@ app_versioncode=1
# abvEnvironments.xml
#cms server
acms_address=https://kagome-vqms.sato-global.com/acms
download_server_address=https://kagome-vqms.sato-global.com/acms
acms_address=https://abook190.abook.bz/acms
download_server_address=https://abook190.abook.bz/acms
#syncview server
websocket_server_http_url=https://abookplus.agentec.jp/v1
......
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