List of usage examples for org.apache.commons.chain Context put
V put(K key, V value);
From source file:bridge.toolkit.Controller.java
/** * @param args//w ww . j a v a2s . co m */ public static void main(String[] args) { Controller loader = new Controller(); Catalog sampleCatalog = loader.createCatalog(); Command toolkit = sampleCatalog.getCommand("SCORM"); Context ctx = new ContextBase(); ctx.put(Keys.SCPM_FILE, args[0]); ctx.put(Keys.RESOURCE_PACKAGE, args[1]); try { if (args.length > 2) { if (args[2] != null && args[2].equalsIgnoreCase("-scormflash")) { toolkit = sampleCatalog.getCommand("SCORM"); ctx.put(Keys.OUTPUT_TYPE, null); } else if (args[2] != null && args[2].equalsIgnoreCase("-scormhtml")) { toolkit = sampleCatalog.getCommand("SCORM"); ctx.put(Keys.OUTPUT_TYPE, "SCORMHTML"); } else if (args.length > 2 && args[2] != null && (args[2].equalsIgnoreCase("-mobileCourse"))) { toolkit = sampleCatalog.getCommand("Mobile"); ctx.put(Keys.OUTPUT_TYPE, "mobileCourse"); } else if (args.length > 2 && args[2] != null && (args[2].equalsIgnoreCase("-mobilePerformanceSupport"))) { toolkit = sampleCatalog.getCommand("Mobile"); } else if (args[2] != null && args[2].equalsIgnoreCase("-pdfinstructor")) { toolkit = sampleCatalog.getCommand("PDF"); ctx.put(Keys.PDF_OUTPUT_OPTION, "-instructor"); } else if (args[2] != null && args[2].equalsIgnoreCase("-pdfstudent")) { toolkit = sampleCatalog.getCommand("PDF"); ctx.put(Keys.PDF_OUTPUT_OPTION, "-student"); } if (args.length > 3 && args[3] != null) { ctx.put(Keys.OUTPUT_DIRECTORY, args[3]); } } toolkit.execute(ctx); } catch (Exception e) { e.printStackTrace(); System.out.println(e.getCause().toString()); } }
From source file:com.sf.ddao.chain.CtxHelper.java
public static <T> T put(Context ctx, Class<T> clazz, T value) { //noinspection unchecked return (T) ctx.put(clazz.toString(), value); }
From source file:com.sf.ddao.conn.ConnectionHandlerHelper.java
public static Connection setConnection(Context context, Connection conn) { //noinspection unchecked return (Connection) context.put(CONNECTION_KEY, conn); }
From source file:com.azaptree.services.command.util.CommandUtils.java
@SuppressWarnings("unchecked") public static <T> T put(final Context ctx, final TypeReferenceKey<T> key, final T value) { Assert.notNull(ctx, "ctx is required"); Assert.notNull(key, "key is required"); Assert.notNull(value, "value is required"); return (T) ctx.put(key.getName(), value); }
From source file:com.sf.ddao.chain.CtxHelper.java
public static Context context(Object... argv) { Context res = new ContextBase(); String key = null;/*from w w w . j a v a 2 s .c o m*/ for (Object o : argv) { if (key == null) { key = (String) o; } else { //noinspection unchecked res.put(key, o); key = null; } } return res; }
From source file:com.netsteadfast.greenstep.bsc.util.TimeSeriesAnalysisUtils.java
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);//w w w . j av a 2 s.c om 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(); }
From source file:com.netsteadfast.greenstep.bsc.util.PeriodTrendsCalUtils.java
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);/* w w w . ja v a2 s. c o m*/ if (!(resultObj.getValue() instanceof String)) { throw new java.lang.IllegalStateException("kpiPeriodTrendsExcelCommandExcelContentChain error!"); } return (String) resultObj.getValue(); }
From source file:com.netsteadfast.greenstep.bsc.util.BscMobileCardUtils.java
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; }/* w w w . j ava2s.com*/ 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; }
From source file:com.netsteadfast.greenstep.bsc.util.PerformanceScoreChainUtils.java
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()); }//from www. j a v a 2 s . co m 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; }
From source file:com.netsteadfast.greenstep.base.BaseChainCommandSupport.java
@SuppressWarnings("unchecked") public void setResult(Context context, Object result) { context.put(ChainConstants.CHAIN_RESULT, result); }