Search in sources :

Example 26 with Context

use of org.apache.commons.chain.Context in project kernel by exoplatform.

the class CommandServiceTest method testExcecute.

public void testExcecute() throws Exception {
    CommandService cservice = (CommandService) container.getComponentInstanceOfType(CommandService.class);
    Command c1 = cservice.getCatalog().getCommand("Execute2");
    Command c2 = cservice.getCatalog().getCommand("Command1");
    Catalog c = cservice.getCatalog();
    Context ctx = new ContextBase();
    ctx.put("test", Integer.valueOf(0));
    c1.execute(ctx);
    c2.execute(ctx);
    assertEquals(3, ((Integer) ctx.get("test")).intValue());
}
Also used : Context(org.apache.commons.chain.Context) Command(org.apache.commons.chain.Command) CommandService(org.exoplatform.services.command.impl.CommandService) Catalog(org.apache.commons.chain.Catalog) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 27 with Context

use of org.apache.commons.chain.Context in project sonarqube 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 28 with Context

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

Example 29 with Context

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

the class KpiReportContentQueryAction method getCoffeeChartJsonData.

private void getCoffeeChartJsonData() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    this.setDateValue();
    this.checkDateRange();
    Context context = this.getChainContext();
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("kpiReportCoffeeChartJsonDataContentChain", context);
    this.message = resultObj.getMessage();
    if (resultObj.getValue() instanceof String) {
        this.body = String.valueOf(resultObj.getValue());
        this.inputStream = new ByteArrayInputStream(this.body.getBytes(Constants.BASE_ENCODING));
        this.success = IS_YES;
    }
}
Also used : Context(org.apache.commons.chain.Context) ByteArrayInputStream(java.io.ByteArrayInputStream) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain)

Example 30 with Context

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

the class PerformanceScoreChainUtils method getContext.

public static Context getContext(String visionOid, String startDate, String endDate, String startYearDate, String endYearDate, String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
    Context context = new ContextBase();
    context.put("visionOid", visionOid);
    context.put("startDate", startDate);
    context.put("endDate", endDate);
    context.put("startYearDate", startYearDate);
    context.put("endYearDate", endYearDate);
    context.put("frequency", frequency);
    context.put("dataFor", dataFor);
    context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
    context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
    context.put("account", "");
    if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataOrganizationOid) && !StringUtils.isBlank(measureDataOrganizationOid)) {
        OrganizationVO organization = new OrganizationVO();
        organization.setOid(measureDataOrganizationOid);
        DefaultResult<OrganizationVO> result = organizationService.findObjectByOid(organization);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        organization = result.getValue();
        context.put("orgId", organization.getOrgId());
    }
    if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataEmployeeOid) && !StringUtils.isBlank(measureDataEmployeeOid)) {
        EmployeeVO employee = new EmployeeVO();
        employee.setOid(measureDataEmployeeOid);
        DefaultResult<EmployeeVO> result = employeeService.findObjectByOid(employee);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        employee = result.getValue();
        context.put("empId", employee.getEmpId());
        context.put("account", employee.getAccount());
    }
    return context;
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) 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