Commit e78bf3ff by NGUYEN HOANG SON

#45827 : show alert when user not allowed create process

parent 0c051855
package jp.agentec.abook.abv.bl.acms.client.json.content;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
public class PhaseInfoJSON extends AbstractJSON {
public static final String PHASE_GROUP_LIST = "phaseGroupList";
public static final String PHASE_GROUP_ID = "phaseGroupId";
public PhaseInfoJSON(String json) {
super(json);
}
/**
* get phase Group ID List by phaseNo
* @param phaseNo
* @return
*/
public List<Integer> getPhaseGroupIds(String phaseNo) {
List<Integer> phaseGroupIds = new ArrayList<Integer>();
try {
JSONArray timeLineListJSONArray = root.getJSONArray(ABookKeys.TIME_LINE_LIST);
for (int listCount = 0; listCount < timeLineListJSONArray.length(); listCount++) {
if (timeLineListJSONArray.getJSONObject(listCount).length() == 0) {
break;
}
JSONObject timeLineJSONObject = timeLineListJSONArray.getJSONObject(listCount);
JSONArray phaseListJSONArray = timeLineJSONObject.getJSONArray(ABookKeys.PHASE_LIST);
for (int phaseListCount = 0; phaseListCount < phaseListJSONArray.length(); phaseListCount++) {
if (phaseListJSONArray.getJSONObject(phaseListCount).length() == 0) {
break;
}
JSONObject phaseListJSONObject = phaseListJSONArray.getJSONObject(phaseListCount);
if (phaseListJSONObject.has(ABookKeys.PHASE_NO)) {
if (phaseListJSONObject.getString(ABookKeys.PHASE_NO).contentEquals(phaseNo)) {
if (phaseListJSONObject.has(PHASE_GROUP_LIST)) {
JSONArray phaseGroupListJSONArray = phaseListJSONObject.getJSONArray(PHASE_GROUP_LIST);
for (int phaseGroupListCount = 0; phaseGroupListCount < phaseGroupListJSONArray.length(); phaseGroupListCount++) {
if (phaseGroupListJSONArray.getJSONObject(phaseGroupListCount).length() == 0) {
break;
}
JSONObject phaseGroupListJSONObject = phaseGroupListJSONArray.getJSONObject(phaseGroupListCount);
if (phaseGroupListJSONObject.has(PHASE_GROUP_ID)) {
phaseGroupIds.add(phaseGroupListJSONObject.getInt(PHASE_GROUP_ID));
}
}
}
}
}
}
}
} catch (Exception e) {}
return phaseGroupIds;
}
}
......@@ -29,6 +29,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ProcessDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.SceneEntryJSON;
import jp.agentec.abook.abv.bl.acms.client.json.WorkerGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.json.content.PhaseInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.DeleteProcessParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetOperationDataParameters;
......@@ -104,6 +105,8 @@ public class OperationLogic extends AbstractLogic {
private TaskWorkerGroupDao mTaskWorkerGroupDao = AbstractDao.getDao(TaskWorkerGroupDao.class);
private TaskReportApprovalDao mTaskReportApprovalDao = AbstractDao.getDao(TaskReportApprovalDao.class);
private GroupLogic mGroupLogic = AbstractLogic.getLogic(GroupLogic.class);
/**
* 作業に関連する情報取得(API通信で取得して、DB保存処理)
*
......@@ -2448,4 +2451,31 @@ public class OperationLogic extends AbstractLogic {
}
return null;
}
/**
* check user has permission to create process
* @param phaseNo
* @param contentPath
* @return
*/
public boolean checkProcessPermission(String phaseNo, String contentPath) {
boolean hasPermission = false;
try {
Integer[] userGroupIds = mGroupLogic.getServerUserGroupIds(cache.getMemberInfo().sid);
if (userGroupIds == null) {
return hasPermission;
}
// check userGroupId in phaseGroupId
String jsonPath = contentPath.replaceAll(ABookKeys.PANO_IMAGE,ABookKeys.PROCESS_LIST).replaceAll(ABookKeys.TASK_PDF, ABookKeys.PROCESS_LIST) + "/" + ABookKeys.PHASE_INFO_JSON;
PhaseInfoJSON phaseInfoJSON = new PhaseInfoJSON(FileUtil.readTextFile(jsonPath));
List<Integer> phaseGroupIds = phaseInfoJSON.getPhaseGroupIds(phaseNo);
for (int i = 0; i < userGroupIds.length; i++) {
if (phaseGroupIds.contains(userGroupIds[i])) {
hasPermission = true;
break;
}
}
} catch (Exception e) {}
return hasPermission;
}
}
\ No newline at end of file
......@@ -1553,4 +1553,6 @@
<string name="failed_to_get_terms_of_service">利用規約の取得に失敗しました。</string>
<string name="logout_by_disagree">ログアウトされ、ログイン画面に遷移します。よろしいでしょうか?</string>
<string name="failed_to_send_agreement">利用規約同意情報をサーバへ送信失敗しました。\nもう一度、同意ボタンをタップしてください。</string>
<string name="msg_error_not_allowed_creating_process">作業登録権限がありません。</string>
</resources>
......@@ -1550,4 +1550,6 @@
<string name="failed_to_get_terms_of_service">이용규약 정보 취득에 실패하였습니다.</string>
<string name="logout_by_disagree">로그 아웃되어 로그인 화면으로 이동합니다. 실행 하시겠습니까?</string>
<string name="failed_to_send_agreement">이용 규약 동의 정보를 서버에 전송 실패하였습니다. 다시 한번 동의 버튼을 눌러주세요.</string>
<string name="msg_error_not_allowed_creating_process">등록권한이 없습니다.</string>
</resources>
\ No newline at end of file
......@@ -1553,4 +1553,6 @@
<string name="failed_to_get_terms_of_service">Failed to get the terms of service information.</string>
<string name="logout_by_disagree">Log out and transition to the login screen. Are you okay?</string>
<string name="failed_to_send_agreement">Failed to send information about agreeing to the Terms of Service to the server. Please tap \"Agree\" again.</string>
<string name="msg_error_not_allowed_creating_process">You do not have the right to register for work.</string>
</resources>
......@@ -5381,6 +5381,18 @@ public class ContentViewActivity extends ABVContentViewActivity {
operationTaskLayout.currentTaskDto = operationTaskDto;
}
public boolean checkPermissionProcess() {
// show alert when user not allowed create process
if (isOperationPdf() && operationDto != null && operationDto.reportType == Constant.ReportType.ReportContinuous) {
boolean hasPermission = mOperationLogic.checkProcessPermission("1", mContentPath);
if (!hasPermission) {
showSimpleAlertDialog(R.string.msg_error_not_allowed_creating_process);
return false;
}
}
return true;
}
public void showOperationTaskLayout(ZoomRelativeLayout layout, OperationTaskDto operationTaskDto, float clickX) {
operationTaskLayout.showTaskForm(layout, mXWalkOpenType, operationTaskDto, isNormalSize(), clickX);
// 拡大・縮小・切替ボタンの非表示
......
......@@ -932,6 +932,9 @@ public class ZoomRelativeLayout extends RelativeLayout {
if(((ContentViewActivity) mContext).getOpenedProjestTask() || !((ContentViewActivity) mContext).isReportEdit() || ((ContentViewActivity) mContext).mMoveTaskFlg) {
return true;
}
if (!((ContentViewActivity) mContext).checkPermissionProcess()) {
return true;
}
final float x = e.getX();
final float y = e.getY();
......
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