List of usage examples for org.apache.commons.chain Context get
V get(Object key);
From source file:com.netsteadfast.greenstep.bsc.command.LoadMeasureDataCommand.java
@SuppressWarnings("unchecked") @Override/* w w w . ja va2 s. c o m*/ public boolean execute(Context context) throws Exception { measureDataService = (IMeasureDataService<MeasureDataVO, BbMeasureData, String>) AppContext .getBean("bsc.service.MeasureDataService"); String frequency = (String) context.get("frequency"); String startYearDate = StringUtils.defaultString((String) context.get("startYearDate")).trim(); String endYearDate = StringUtils.defaultString((String) context.get("endYearDate")).trim(); String startDate = StringUtils.defaultString((String) context.get("startDate")).trim(); String endDate = StringUtils.defaultString((String) context.get("endDate")).trim(); startDate = startDate.replaceAll("/", "").replaceAll("-", ""); endDate = endDate.replaceAll("/", "").replaceAll("-", ""); String date1 = startDate; String date2 = endDate; if (BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency)) { date1 = startYearDate + "0101"; date2 = endYearDate + "12" + SimpleUtils.getMaxDayOfMonth(Integer.parseInt(endYearDate), 12); } String measureDataOrgaId = (String) context.get("orgId"); String measureDataEmplId = (String) context.get("empId"); if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) { return false; } BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO vision : treeObj.getVisions()) { for (PerspectiveVO perspective : vision.getPerspectives()) { for (ObjectiveVO objective : perspective.getObjectives()) { for (KpiVO kpi : objective.getKpis()) { this.fillMeasureData(kpi, frequency, date1, date2, measureDataOrgaId, measureDataEmplId); } } } } return false; }
From source file:com.netsteadfast.greenstep.bsc.command.ProcessBscTreeItemsCommand.java
@Override public boolean execute(Context context) throws Exception { if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) { return false; }//from w ww . j ava2 s .c o m String host = StringUtils.defaultString((String) context.get("http")) + ApplicationSiteUtils.getHost(Constants.getMainSystem()) + "/" + ApplicationSiteUtils.getContextPathFromMap(Constants.getMainSystem()) + "/"; String iconImg = IconUtils.getMenuIcon(host, "STAR"); BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); List<Map<String, Object>> items = new LinkedList<Map<String, Object>>(); for (VisionVO vision : treeObj.getVisions()) { Map<String, Object> visionDataMap = new HashMap<String, Object>(); visionDataMap.put("type", "parent"); visionDataMap.put("name", vision.getTitle()); visionDataMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + vision.getOid()); items.add(visionDataMap); List<Map<String, Object>> perspectiveItems = new LinkedList<Map<String, Object>>(); for (PerspectiveVO perspective : vision.getPerspectives()) { Map<String, Object> perspectiveDataMap = new HashMap<String, Object>(); perspectiveDataMap.put("type", "parent"); perspectiveDataMap.put("name", perspective.getName()); perspectiveDataMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + perspective.getOid()); perspectiveItems.add(perspectiveDataMap); visionDataMap.put("children", perspectiveItems); List<Map<String, Object>> objectivesStrategyList = new LinkedList<Map<String, Object>>(); for (ObjectiveVO objective : perspective.getObjectives()) { Map<String, Object> objectiveMap = new HashMap<String, Object>(); objectiveMap.put("type", "parent"); objectiveMap.put("name", objective.getName()); objectiveMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + objective.getOid()); objectivesStrategyList.add(objectiveMap); perspectiveDataMap.put("children", objectivesStrategyList); List<Map<String, Object>> kpiList = new LinkedList<Map<String, Object>>(); for (KpiVO kpi : objective.getKpis()) { Map<String, Object> kpiMap = new HashMap<String, Object>(); kpiMap.put("type", "Leaf"); kpiMap.put("name", iconImg + kpi.getName()); kpiMap.put("id", kpi.getOid()); kpiList.add(kpiMap); objectiveMap.put("children", kpiList); } } } } this.setResult(context, items); if (null == items || items.size() < 1) { this.setMessage(context, SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)); } return false; }
From source file:com.netsteadfast.greenstep.bsc.command.LoadStrategyMapItemsForNewCommand.java
@Override public boolean execute(Context context) throws Exception { if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) { return false; }/* w ww . ja va 2s.c o m*/ BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); String visionOid = (String) context.get("visionOid"); VisionVO vision = null; for (VisionVO obj : treeObj.getVisions()) { if (obj.getOid().equals(visionOid)) { vision = obj; } } StrategyMapItemsVO mapItems = this.fillStrategyMapItems(vision); this.setResult(context, mapItems); return false; }
From source file:com.netsteadfast.greenstep.bsc.command.WeightBodyCommand.java
@Override public boolean execute(Context context) throws Exception { if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) { return false; }/* w ww .j a v a 2s .c o m*/ BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); if (YesNo.YES.equals(context.get("autoAllocation"))) { this.autoAllocation(treeObj); } Map<String, Object> parameter = new HashMap<String, Object>(); parameter.put("treeObj", treeObj); parameter.put("weightName", String.valueOf(context.get("weightName"))); /* StringTemplateLoader templateLoader = new StringTemplateLoader(); templateLoader.putTemplate("resourceTemplate", TemplateUtils.getResourceSrc(WeightBodyCommand.class.getClassLoader(), templateResource) ); Configuration cfg = new Configuration(); cfg.setTemplateLoader(templateLoader); Template template = cfg.getTemplate("resourceTemplate", "utf-8"); Writer out = new StringWriter(); template.process(parameter, out); this.setResult(context, out.toString() ); */ String content = TemplateUtils.processTemplate("resourceTemplate", WeightBodyCommand.class.getClassLoader(), templateResource, parameter); this.setResult(context, content); return false; }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportBodyCommand.java
private void fillHeadContent(Context context, Map<String, Object> parameter) throws ServiceException, Exception { String headContent = ""; String orgId = (String) context.get("orgId"); String empId = (String) context.get("empId"); String account = (String) context.get("account"); if (!BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(orgId) && !StringUtils.isBlank(orgId)) { OrganizationVO organization = new OrganizationVO(); organization.setOrgId(orgId);//from w w w . ja va 2 s . com DefaultResult<OrganizationVO> result = this.organizationService.findByUK(organization); if (result.getValue() != null) { organization = result.getValue(); headContent += Constants.HTML_BR + "Measure data for: " + organization.getOrgId() + " - " + organization.getName(); } } if (!BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(empId) && !StringUtils.isBlank(empId) && !StringUtils.isBlank(account)) { EmployeeVO employee = new EmployeeVO(); employee.setEmpId(empId); employee.setAccount(account); DefaultResult<EmployeeVO> result = this.employeeService.findByUK(employee); if (result.getValue() != null) { employee = result.getValue(); headContent += Constants.HTML_BR + "Measure data for: " + employee.getEmpId() + " - " + employee.getFullName(); if (!StringUtils.isBlank(employee.getJobTitle())) { headContent += " ( " + employee.getJobTitle() + " ) "; } } } parameter.put("headContent", headContent); }
From source file:com.netsteadfast.greenstep.bsc.command.LoadStrategyMapItemsForRecCommand.java
@Override public boolean execute(Context context) throws ServiceException, Exception { if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) { return false; }/* w w w.ja v a 2 s . c om*/ BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); String visionOid = (String) context.get("visionOid"); VisionVO vision = null; for (VisionVO obj : treeObj.getVisions()) { if (obj.getOid().equals(visionOid)) { vision = obj; } } StrategyMapItemsVO mapItems = this.fillStrategyMapItems(vision, context); this.setResult(context, mapItems); return false; }
From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportExcelCommand.java
private String createExcel(Context context) throws Exception { String visionOid = (String) context.get("visionOid"); VisionVO vision = null;//w w w . j a v a2 s . com BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO visionObj : treeObj.getVisions()) { if (visionObj.getOid().equals(visionOid)) { vision = visionObj; } } BscReportPropertyUtils.loadData(); String fileName = SimpleUtils.getUUIDStr() + ".xlsx"; String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName; int row = 0; XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sh = wb.createSheet(); row += this.createHead(wb, sh, row, vision, context); row = this.createMainBody(wb, sh, row, vision); this.putSignature(wb, sh, row + 1, context); FileOutputStream out = new FileOutputStream(fileFullPath); wb.write(out); out.close(); wb = null; File file = new File(fileFullPath); String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "department-report.xlsx"); file = null; return oid; }
From source file:com.netsteadfast.greenstep.bsc.command.PersonalAndOrganizationReportDateRangeScoreCommand.java
@SuppressWarnings("unchecked") @Override/* w ww . ja va 2 s. c o m*/ public boolean execute(Context context) throws Exception { if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) { return false; } float total = 0.0f; BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); String year = StringUtils.defaultString((String) context.get("startYearDate")).trim(); String dateType = StringUtils.defaultString((String) context.get("dateType")).trim(); for (VisionVO vision : treeObj.getVisions()) { for (PerspectiveVO perspective : vision.getPerspectives()) { for (ObjectiveVO objective : perspective.getObjectives()) { for (KpiVO kpi : objective.getKpis()) { this.setDateRangeScore(kpi, dateType, year); total = total + kpi.getDateRangeScores().get(0).getScore(); // ? } } } } context.put("total", total); return false; }
From source file:com.netsteadfast.greenstep.bsc.action.KpisDashboardAction.java
@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) { throw new ServiceException("Please first query!"); }/* ww w.j ava 2 s . c o m*/ SimpleChain chain = new SimpleChain(); ChainResultObj resultObj = chain.getResultFromResource("kpisDashboardExcelContentChain", context); this.message = resultObj.getMessage(); if (resultObj.getValue() instanceof String) { this.uploadOid = (String) resultObj.getValue(); this.success = IS_YES; } }
From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java
private String createPdf(Context context) throws Exception { BscReportPropertyUtils.loadData();// w w w . j a v a2 s. com String visionOid = (String) context.get("visionOid"); VisionVO vision = null; BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO visionObj : treeObj.getVisions()) { if (visionObj.getOid().equals(visionOid)) { vision = visionObj; } } FontFactory.register(BscConstants.PDF_ITEXT_FONT); String fileName = UUID.randomUUID().toString() + ".pdf"; String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName; OutputStream os = new FileOutputStream(fileFullPath); Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); document.left(100f); document.top(150f); PdfWriter writer = PdfWriter.getInstance(document, os); document.open(); PdfPTable table = new PdfPTable(MAX_COLSPAN); table.setWidthPercentage(100f); PdfPTable signTable = new PdfPTable(1); signTable.setWidthPercentage(100f); this.createHead(table, vision, context); this.createBody(table, vision); this.putSignature(signTable, context); document.add(table); document.add(signTable); document.close(); writer.close(); os.flush(); os.close(); os = null; File file = new File(fileFullPath); String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "department-report.pdf"); file = null; return oid; }