Search in sources :

Example 21 with Context

use of org.apache.commons.chain.Context 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)

Example 22 with Context

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

the class IndexAction method loadRecord.

@SuppressWarnings("unchecked")
private void loadRecord() throws ControllerException, ServiceException, Exception {
    String visionOid = this.getFields().get("visionOid");
    if (super.isNoSelectId(visionOid)) {
        return;
    }
    Context context = new ContextBase();
    context.put("visionOid", visionOid);
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("strategyMapItemsForRecChain", context);
    this.setPageMessage(resultObj.getMessage());
    if (resultObj.getValue() instanceof StrategyMapItemsVO) {
        this.divItems = ((StrategyMapItemsVO) resultObj.getValue()).getDiv();
        this.cssItems = ((StrategyMapItemsVO) resultObj.getValue()).getCss();
        this.conItems = ((StrategyMapItemsVO) resultObj.getValue()).getCon();
    }
}
Also used : Context(org.apache.commons.chain.Context) StrategyMapItemsVO(com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 23 with Context

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

the class PerformanceScoreChainUtils method createOrUpdateMonitorItemScoreCurrentDate.

public static void createOrUpdateMonitorItemScoreCurrentDate(String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
    String dateVal = SimpleUtils.getStrYMD("");
    String year = dateVal.substring(0, 4);
    String startDate = "";
    String endDate = "";
    String startYearDate = year;
    String endYearDate = year;
    //String dataFor = "all"; // all, organization, employee
    if (BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency)) {
        Map<String, String> dateMap = BscMeasureDataFrequency.getWeekOrMonthStartEnd(frequency, dateVal, dateVal);
        startDate = dateMap.get("startDate");
        endDate = dateMap.get("endDate");
    }
    if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency)) {
        startDate = dateVal;
        endDate = dateVal;
    }
    Map<String, String> visions = visionService.findForMap(false);
    for (Map.Entry<String, String> visionData : visions.entrySet()) {
        String visionOid = visionData.getKey();
        Context context = getContext(visionOid, startDate, endDate, startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid, measureDataEmployeeOid);
        createOrUpdateMonitorItemScore(dateVal, context);
    }
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) HashMap(java.util.HashMap) Map(java.util.Map)

Example 24 with Context

use of org.apache.commons.chain.Context in project sonar-java by SonarSource.

the class TestWrappingLookupCommand method testWrapContextSubclass.

public void testWrapContextSubclass() throws Exception {
    WrappingLookupCommand command = new WrappingLookupCommand();
    command.setWrapperClassName(ServletActionContext.class.getName());
    Context testContext = new ServletWebContext();
    Context wrapped = command.getContext(testContext);
    assertNotNull(wrapped);
    assertTrue(wrapped instanceof ServletActionContext);
}
Also used : ServletWebContext(org.apache.commons.chain.web.servlet.ServletWebContext) ServletActionContext(org.apache.struts.chain.contexts.ServletActionContext) Context(org.apache.commons.chain.Context) ServletWebContext(org.apache.commons.chain.web.servlet.ServletWebContext) ServletActionContext(org.apache.struts.chain.contexts.ServletActionContext)

Example 25 with Context

use of org.apache.commons.chain.Context in project sonar-java by SonarSource.

the class TestWrappingLookupCommand method testSame.

public void testSame() throws Exception {
    WrappingLookupCommand command = new WrappingLookupCommand();
    Context testContext = new ContextBase();
    Context wrapped = command.getContext(testContext);
    assertNotNull(wrapped);
    assertSame(testContext, wrapped);
}
Also used : ServletWebContext(org.apache.commons.chain.web.servlet.ServletWebContext) ServletActionContext(org.apache.struts.chain.contexts.ServletActionContext) Context(org.apache.commons.chain.Context) 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