Search in sources :

Example 1 with ContextBase

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

the class PeriodTrendsCalUtils method generateKpiPeriodTrendsExcel.

public static String generateKpiPeriodTrendsExcel(List<PeriodTrendsData<KpiVO>> periodDatas, String currentPeriodDateRange, String previousPeriodDateRange) throws Exception {
    Context context = new ContextBase();
    context.put("periodDatas", periodDatas);
    context.put("currentPeriodDateRange", currentPeriodDateRange);
    context.put("previousPeriodDateRange", previousPeriodDateRange);
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("kpiPeriodTrendsExcelCommandExcelContentChain", context);
    if (!(resultObj.getValue() instanceof String)) {
        throw new java.lang.IllegalStateException("kpiPeriodTrendsExcelCommandExcelContentChain error!");
    }
    return (String) resultObj.getValue();
}
Also used : Context(org.apache.commons.chain.Context) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 2 with ContextBase

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

the class TimeSeriesAnalysisUtils method getResultForExcel.

public static String getResultForExcel(String tsaOid, String visionOid, String startDate, String endDate, String startYearDate, String endYearDate, String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
    Map<String, Object> dataMap = getResultWithVision(tsaOid, visionOid, startDate, endDate, startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid, measureDataEmployeeOid);
    List<TimeSeriesAnalysisResult> tsaResults = (List<TimeSeriesAnalysisResult>) dataMap.get("result");
    VisionVO vision = (VisionVO) dataMap.get("vision");
    TsaVO tsa = getParam(tsaOid);
    List<BbTsaMaCoefficients> coefficients = getCoefficients(tsa);
    Context context = new ContextBase();
    context.put("tsaResults", tsaResults);
    context.put("tsa", tsa);
    context.put("coefficients", coefficients);
    // for show only.
    context.put("visionName", vision.getTitle());
    if (BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency)) {
        context.put("date1", startYearDate);
        context.put("date2", endYearDate);
    } else {
        context.put("date1", startDate);
        context.put("date2", endDate);
    }
    context.put("frequencyName", BscMeasureDataFrequency.getFrequencyMap(false).get(frequency));
    context.put("dataFor", dataFor);
    context.put("organizationName", "");
    context.put("employeeName", "");
    if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataOrganizationOid) && !StringUtils.isBlank(measureDataOrganizationOid)) {
        context.put("organizationName", BscBaseLogicServiceCommonSupport.findOrganizationData(organizationService, measureDataOrganizationOid).getName());
    }
    if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataEmployeeOid) && !StringUtils.isBlank(measureDataEmployeeOid)) {
        context.put("employeeName", BscBaseLogicServiceCommonSupport.findEmployeeData(employeeService, measureDataEmployeeOid).getFullName());
    }
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("timeSeriesAnalysisExcelCommandContentChain", context);
    if (!(resultObj.getValue() instanceof String)) {
        throw new java.lang.IllegalStateException("timeSeriesAnalysisExcelCommandContentChain error!");
    }
    return (String) resultObj.getValue();
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) TsaVO(com.netsteadfast.greenstep.vo.TsaVO) BbTsaMaCoefficients(com.netsteadfast.greenstep.po.hbm.BbTsaMaCoefficients) TimeSeriesAnalysisResult(com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) ArrayList(java.util.ArrayList) List(java.util.List) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 3 with ContextBase

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

the class KpisDashboardAction 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_PROG003D0006Q_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("dateRangeLabel", this.getHttpServletRequest().getParameter("BSC_PROG003D0006Q_dateRangeLabel"));
    context.put("barChartsData", this.getHttpServletRequest().getParameter("BSC_PROG003D0006Q_kpisBarChartsData"));
    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 4 with ContextBase

use of org.apache.commons.chain.impl.ContextBase 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 5 with ContextBase

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

the class BscMobileCardUtils method getVisionCard.

public static List<VisionVO> getVisionCard(String frequency, String startDate, String endDate) throws ServiceException, Exception {
    List<VisionVO> visionScores = new ArrayList<VisionVO>();
    Map<String, String> visions = visionService.findForMap(false);
    if (null == visions || visions.size() < 1) {
        return visionScores;
    }
    Context context = new ContextBase();
    context.put("startDate", startDate);
    context.put("endDate", endDate);
    context.put("startYearDate", startDate.substring(0, 4));
    context.put("endYearDate", endDate.substring(0, 4));
    context.put("frequency", frequency);
    context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ALL);
    context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
    context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
    for (Map.Entry<String, String> entry : visions.entrySet()) {
        String visionOid = entry.getKey();
        context.put("visionOid", visionOid);
        SimpleChain chain = new SimpleChain();
        ChainResultObj resultObj = chain.getResultFromResource("performanceScoreChain", context);
        BscStructTreeObj treeObj = (BscStructTreeObj) resultObj.getValue();
        for (int i = 0; treeObj.getVisions() != null && i < treeObj.getVisions().size(); i++) {
            VisionVO vision = treeObj.getVisions().get(i);
            vision.setContent(" ".getBytes());
            DefaultResult<VisionVO> vResult = visionService.findObjectByOid(vision);
            if (vResult.getValue() != null) {
                // 計算分數chain 取出的vision資料沒有放 content 欄位, 但這邊要用到, 所以取出content欄位
                vision.setContent(new String(vResult.getValue().getContent(), Constants.BASE_ENCODING).getBytes());
            }
            for (PerspectiveVO perspective : vision.getPerspectives()) {
                for (ObjectiveVO objective : perspective.getObjectives()) {
                    for (KpiVO kpi : objective.getKpis()) {
                        // 產生報表不需要以下欄位
                        kpi.getAggregationMethod().setDescription(" ");
                        kpi.getAggregationMethod().setExpression1(" ");
                        kpi.getAggregationMethod().setExpression2(" ");
                        kpi.getFormula().setExpression(" ");
                    }
                }
            }
            visionScores.add(vision);
        }
    }
    return visionScores;
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) ArrayList(java.util.ArrayList) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) HashMap(java.util.HashMap) Map(java.util.Map) ContextBase(org.apache.commons.chain.impl.ContextBase)

Aggregations

Context (org.apache.commons.chain.Context)22 ContextBase (org.apache.commons.chain.impl.ContextBase)22 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)8 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)8 Map (java.util.Map)5 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)4 ArrayList (java.util.ArrayList)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 AppContext (com.netsteadfast.greenstep.base.AppContext)3 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)3 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)3 LinkedHashMap (java.util.LinkedHashMap)3 LinkedList (java.util.LinkedList)3 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)2 HashMap (java.util.HashMap)2 List (java.util.List)2 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1 TimeSeriesAnalysisResult (com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult)1 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)1 BbPdcaKpis (com.netsteadfast.greenstep.po.hbm.BbPdcaKpis)1