Search in sources :

Example 6 with Context

use of org.apache.commons.chain.Context in project bamboobsc by billchen198318.

the class DepartmentReportContentQueryAction method getChainContext.

@SuppressWarnings("unchecked")
private Context getChainContext() throws Exception {
    Context context = new ContextBase();
    context.put("visionOid", this.getFields().get("visionOid"));
    context.put("frequency", this.getFields().get("frequency"));
    context.put("startYearDate", this.getFields().get("year"));
    context.put("endYearDate", this.getFields().get("year"));
    context.put("dateType", this.getFields().get("dateType"));
    context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ORGANIZATION);
    OrganizationVO organization = new OrganizationVO();
    organization.setOid(this.getFields().get("organizationOid"));
    DefaultResult<OrganizationVO> result = this.organizationService.findObjectByOid(organization);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    organization = result.getValue();
    context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
    context.put("orgId", organization.getOrgId());
    context.put("uploadSignatureOid", this.getFields().get("uploadSignatureOid"));
    return context;
}
Also used : Context(org.apache.commons.chain.Context) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 7 with Context

use of org.apache.commons.chain.Context in project bamboobsc by billchen198318.

the class DepartmentReportContentQueryAction method getExcel.

private void getExcel() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    Context context = this.getChainContext();
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("organizationReportExcelContentChain", context);
    this.message = resultObj.getMessage();
    if (resultObj.getValue() instanceof String) {
        this.uploadOid = (String) resultObj.getValue();
        this.success = IS_YES;
    }
}
Also used : Context(org.apache.commons.chain.Context) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain)

Example 8 with Context

use of org.apache.commons.chain.Context in project bamboobsc by billchen198318.

the class ObjectivesDashboardAction method getContext.

@SuppressWarnings("unchecked")
private Context getContext() throws Exception {
    List<Map<String, Object>> chartDatas = new LinkedList<Map<String, Object>>();
    Enumeration<String> paramNames = this.getHttpServletRequest().getParameterNames();
    while (paramNames.hasMoreElements()) {
        String paramName = paramNames.nextElement();
        String value = this.getHttpServletRequest().getParameter(paramName);
        if (paramName.startsWith("BSC_PROG003D0005Q_meterGaugeChartDatas:")) {
            Map<String, Object> dataMap = (Map<String, Object>) new ObjectMapper().readValue(value, LinkedHashMap.class);
            chartDatas.add(dataMap);
        }
    }
    Context context = new ContextBase();
    context.put("chartDatas", chartDatas);
    context.put("year", this.getHttpServletRequest().getParameter("BSC_PROG003D0005Q_year"));
    context.put("barChartsData", this.getHttpServletRequest().getParameter("BSC_PROG003D0005Q_objectivesBarChartsData"));
    return context;
}
Also used : Context(org.apache.commons.chain.Context) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedList(java.util.LinkedList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 9 with Context

use of org.apache.commons.chain.Context in project bamboobsc by billchen198318.

the class ObjectivesDashboardAction method getExcel.

@SuppressWarnings("unchecked")
private void getExcel() throws ControllerException, AuthorityException, ServiceException, Exception {
    Context context = this.getContext();
    List<Map<String, Object>> chartDatas = (List<Map<String, Object>>) context.get("chartDatas");
    if (chartDatas == null || chartDatas.size() < 1) {
        super.throwMessage(this.getText("MESSAGE.BSC_PROG003D0005Q_msg1"));
    }
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("objectivesDashboardExcelContentChain", context);
    this.message = resultObj.getMessage();
    if (resultObj.getValue() instanceof String) {
        this.uploadOid = (String) resultObj.getValue();
        this.success = IS_YES;
    }
}
Also used : Context(org.apache.commons.chain.Context) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) LinkedList(java.util.LinkedList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 10 with Context

use of org.apache.commons.chain.Context in project bamboobsc by billchen198318.

the class PerspectivesDashboardAction method getContext.

@SuppressWarnings("unchecked")
private Context getContext() throws Exception {
    List<Map<String, Object>> chartDatas = new LinkedList<Map<String, Object>>();
    String pieCanvasToData = "";
    String barCanvasToData = "";
    Enumeration<String> paramNames = this.getHttpServletRequest().getParameterNames();
    while (paramNames.hasMoreElements()) {
        String paramName = paramNames.nextElement();
        String value = this.getHttpServletRequest().getParameter(paramName);
        if (paramName.startsWith("BSC_PROG003D0004Q_meterGaugeChartDatas:")) {
            Map<String, Object> dataMap = (Map<String, Object>) new ObjectMapper().readValue(value, LinkedHashMap.class);
            chartDatas.add(dataMap);
        }
        if (paramName.equals("BSC_PROG003D0004Q_barChartDatas")) {
            barCanvasToData = SimpleUtils.deHex(this.defaultString(value));
        }
        if (paramName.equals("BSC_PROG003D0004Q_pieChartDatas")) {
            pieCanvasToData = SimpleUtils.deHex(this.defaultString(value));
        }
    }
    Context context = new ContextBase();
    context.put("barCanvasToData", barCanvasToData);
    context.put("pieCanvasToData", pieCanvasToData);
    context.put("chartDatas", chartDatas);
    context.put("year", this.getHttpServletRequest().getParameter("BSC_PROG003D0004Q_year"));
    return context;
}
Also used : Context(org.apache.commons.chain.Context) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedList(java.util.LinkedList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap) ContextBase(org.apache.commons.chain.impl.ContextBase)

Aggregations

Context (org.apache.commons.chain.Context)49 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)28 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)27 ContextBase (org.apache.commons.chain.impl.ContextBase)24 Map (java.util.Map)9 LinkedHashMap (java.util.LinkedHashMap)7 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)6 ArrayList (java.util.ArrayList)6 LinkedList (java.util.LinkedList)6 List (java.util.List)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 AppContext (com.netsteadfast.greenstep.base.AppContext)4 HashMap (java.util.HashMap)4 ServletWebContext (org.apache.commons.chain.web.servlet.ServletWebContext)4 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)4 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)3 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)3 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)3 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)3 ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)2