Java Code Examples for org.apache.commons.chain.Context#get()

The following examples show how to use org.apache.commons.chain.Context#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PerspectivesDashboardAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
private Context getContext() throws ControllerException, AuthorityException, ServiceException, Exception {
	this.checkFields();
	this.setDateValue();
	this.checkDateRange();
	Context context = this.getChainContext();
	SimpleChain chain = new SimpleChain();
	ChainResultObj resultObj = chain.getResultFromResource("performanceScoreChain", context);
	this.message = resultObj.getMessage();	
	if (context.get("treeObj")==null) {
		return context;
	}
	BscStructTreeObj treeObj = (BscStructTreeObj)context.get("treeObj");
	if (null != treeObj) {
		this.success = IS_YES;
	}
	this.vision = treeObj.getVisions().get(0);
	return context;
}
 
Example 2
Source File: DashboardNewAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
private Context getContext() throws ControllerException, AuthorityException, ServiceException, Exception {
	this.checkFields();
	this.setDateValue();
	this.checkDateRange();
	Context context = this.getChainContext();
	SimpleChain chain = new SimpleChain();
	ChainResultObj resultObj = chain.getResultFromResource("performanceScoreChain", context);
	this.message = resultObj.getMessage();	
	if (context.get("treeObj")==null) {
		return context;
	}
	BscStructTreeObj treeObj = (BscStructTreeObj)context.get("treeObj");
	if (null != treeObj) {
		this.success = IS_YES;
	}
	this.vision = treeObj.getVisions().get(0);
	return context;
}
 
Example 3
Source File: StrategyMapManagementAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
private void loadNew() throws ControllerException, ServiceException, Exception {
	if ( StringUtils.isBlank(this.visionOid) || super.isNoSelectId(this.visionOid) ) {
		throw new ControllerException( this.getText("MESSAGE.BSC_PROG002D0007Q_vision") );
	}
	Context context = this.getChainContext();
	SimpleChain chain = new SimpleChain();
	ChainResultObj resultObj = chain.getResultFromResource("strategyMapItemsForNewChain", context);
	this.backgroundOid = (String) context.get("backgroundOid");
	this.mapHeight = (String) context.get("mapHeight");
	this.setPageMessage( resultObj.getMessage() );
	if ( resultObj.getValue() instanceof StrategyMapItemsVO ) {
		this.divItems = ( (StrategyMapItemsVO)resultObj.getValue() ).getDiv();
		this.cssItems = ( (StrategyMapItemsVO)resultObj.getValue() ).getCss();
	}
	
}
 
Example 4
Source File: IndexAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@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);
	String backgroundOid = (String) context.get("backgroundOid");
	this.backgroundImgBase64 = StrategyMapUtils.getBackgroundImageBase64FromUpload(backgroundOid);
	this.mapHeight = (String) context.get("mapHeight");
	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();
	}		
}
 
Example 5
Source File: LoadStrategyMapItemsForRecCommand.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean execute(Context context) throws ServiceException, Exception {
	if ( this.getResult(context)==null || !(this.getResult(context) instanceof BscStructTreeObj) ) {
		return false;
	}
	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);
	int mapHeight = StrategyMapUtils.getMIN_HEIGHT();
	if (vision.getPerspectives().size() > 4) {
		mapHeight = StrategyMapUtils.getONE_HEIGHT() * vision.getPerspectives().size();
	}		
	context.put("backgroundOid", StrategyMapUtils.createUpload(vision, 800, mapHeight));
	context.put("mapHeight", String.valueOf(mapHeight));
	this.setResult(context, mapItems);		
	return false;
}
 
Example 6
Source File: StrategyMapManagementAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
private void loadRecord() throws ControllerException, ServiceException, Exception {
	if ( StringUtils.isBlank(this.visionOid) || super.isNoSelectId(this.visionOid) ) {
		throw new ControllerException( this.getText("MESSAGE.BSC_PROG002D0007Q_vision") );
	}
	Context context = this.getChainContext();
	SimpleChain chain = new SimpleChain();
	ChainResultObj resultObj = chain.getResultFromResource("strategyMapItemsForRecChain", context);
	this.backgroundOid = (String) context.get("backgroundOid");
	this.mapHeight = (String) context.get("mapHeight");
	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();
	}		
}
 
Example 7
Source File: OrganizationReportExcelCommand.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
private String createExcel(Context context) throws Exception {
	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;
		}
	}
	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;		
}
 
Example 8
Source File: LoadBscMixDataCommand.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean execute(Context context) throws Exception {
	kpiService = (IKpiService<KpiVO, BbKpi, String>)AppContext.getBean("bsc.service.KpiService");		
	String orgId = (String)context.get("orgId");
	String empId = (String)context.get("empId");
	List<String> kpiIds = (List<String>)context.get("kpiIds");
	if (BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(orgId)) {
		orgId = "";
	}
	if (BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(empId)) {
		empId = "";
	}
	DefaultResult<List<BscMixDataVO>> result = kpiService.findForMixData( 
			(String)context.get("visionOid"), 
			orgId, 
			empId,
			StringUtils.defaultString( (String)context.get("nextType") ),
			StringUtils.defaultString( (String)context.get("nextId")),
			kpiIds);
	if (result.getValue()!=null) {
		this.setResult(context, result.getValue());
	} else {
		this.setMessage(context, result.getSystemMessage().getValue());
	}
	return false;
}
 
Example 9
Source File: PerspectivesDashboardAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@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 ) {
		super.throwMessage( this.getText("MESSAGE.BSC_PROG003D0004Q_msg1") );
	}
	SimpleChain chain = new SimpleChain();
	ChainResultObj resultObj = chain.getResultFromResource("perspectivesDashboardExcelContentChain", context);
	this.message = resultObj.getMessage();
	if ( resultObj.getValue() instanceof String ) {
		this.uploadOid = (String)resultObj.getValue();
		this.success = IS_YES;
	}			
}
 
Example 10
Source File: KpisDashboardAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@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!");
	}
	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;
	}			
}
 
Example 11
Source File: PersonalReportExcelCommand.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
private void putSignature(XSSFWorkbook wb, XSSFSheet sh, int row, Context context) throws Exception {
	String uploadOid = (String)context.get("uploadSignatureOid");
	if ( StringUtils.isBlank(uploadOid) ) {
		return;
	}
	byte[] imageBytes = UploadSupportUtils.getDataBytes( uploadOid );
	if ( null == imageBytes ) {
		return;
	}
	SimpleUtils.setCellPicture(wb, sh, imageBytes, row, 0);
}
 
Example 12
Source File: PdcaReportContentQueryAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void getContent() throws ControllerException, AuthorityException, ServiceException, Exception {
	this.checkFields();
	
	Context pdcaContext = new ContextBase();
	pdcaContext.put("pdcaOid", this.getFields().get("pdcaOid"));
	SimpleChain chain = new SimpleChain();
	ChainResultObj pdcaReportObj = chain.getResultFromResource("pdcaReportHtmlContentChain", pdcaContext);		
	
	List<ChainResultObj> bscReportResults = null;
	if ("true".equals(this.getFields().get("showBscReport"))) {
		bscReportResults = this.getBscReportContent( "kpiReportHtmlContentChain" );
	}
	if ( pdcaReportObj.getValue() instanceof String ) {
		this.body = String.valueOf(pdcaReportObj.getValue());
		this.pdca = (PdcaVO) pdcaContext.get("pdca");
	}
	this.message = super.defaultString(pdcaReportObj.getMessage()).trim();
	for (int i=0; bscReportResults!=null && i<bscReportResults.size(); i++) {
		ChainResultObj bscReportObj = bscReportResults.get(i);
		if ( bscReportObj.getValue() instanceof String ) {
			this.body += String.valueOf(bscReportObj.getValue());
		}
		if (!this.message.equals(bscReportObj.getMessage())) {
			if (!"".equals(this.message)) {
				this.message += super.getHtmlBr();
			}
			this.message += bscReportObj.getMessage();
		}			
	}
	if (!StringUtils.isBlank(this.body)) {
		this.success = IS_YES;
	}
}
 
Example 13
Source File: PersonalReportExcelCommand.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
private String createExcel(Context context) throws Exception {
	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;
		}
	}
	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, context);
	this.createFoot(wb, sh, row, vision, context);
	
	this.putSignature(wb, sh, row+2, 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, "personal-report.xlsx");
	file = null;
	return oid;
}
 
Example 14
Source File: SwotDataProvideCommand.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@Override
public boolean execute(Context context) throws Exception {
	String visionOid = (String)context.get("visionOid");
	String organizationOid = (String)context.get("organizationOid");
	VisionVO vision = this.findVision(visionOid);
	OrganizationVO organization = this.findOrganization(organizationOid);
	if ( StringUtils.isBlank(vision.getVisId()) || StringUtils.isBlank(organization.getOrgId()) ) {
		this.setMessage(context, SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
		return false;
	}		
	Map<String, Object> params = new HashMap<String, Object>();
	Map<String, String> orderParams = new HashMap<String, String>();
	params.put("visId", vision.getVisId());
	orderParams.put("perId", "asc");
	List<BbPerspective> perspectives = this.perspectiveService.findListByParams(params, null, orderParams);
	if (perspectives==null || perspectives.size()<1) {
		this.setMessage(context, SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
		return false;
	}		
	params.put("orgId", organization.getOrgId());		
	List<BbSwot> swots = this.swotService.findListByParams(params, null, orderParams);
	SwotDataVO swotData = new SwotDataVO();
	swotData.setVision(vision);
	swotData.setOrganization(organization);
	swotData.setContents(swots);
	swotData.setPerspectives(perspectives);
	this.initIssues(swotData, vision.getVisId(), organization.getOrgId());
	this.setResult(context, swotData);
	return false;
}
 
Example 15
Source File: KpiPeriodTrendsExcelCommand.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void putTables(XSSFWorkbook wb, XSSFSheet sh, Context context) throws Exception {
	
	XSSFCellStyle cellHeadStyle = wb.createCellStyle();
	cellHeadStyle.setFillForegroundColor( new XSSFColor( SimpleUtils.getColorRGB4POIColor( "#f5f5f5" ), null ) );
	cellHeadStyle.setFillPattern( FillPatternType.SOLID_FOREGROUND );	
	cellHeadStyle.setBorderBottom( BorderStyle.THIN );
	cellHeadStyle.setBorderTop( BorderStyle.THIN );
	cellHeadStyle.setBorderRight( BorderStyle.THIN );
	cellHeadStyle.setBorderLeft( BorderStyle.THIN );		
	XSSFFont cellHeadFont = wb.createFont();
	cellHeadFont.setBold(true);		
	cellHeadStyle.setFont( cellHeadFont );
	
	sh.setColumnWidth(0, 12000);
	
	int row = 0;
	
	Row nowRow = sh.createRow(row);
	Cell cell1 = nowRow.createCell(0);
	cell1.setCellStyle(cellHeadStyle);
	cell1.setCellValue( "KPI" );				
	Cell cell2 = nowRow.createCell(1);
	cell2.setCellStyle(cellHeadStyle);
	cell2.setCellValue( "Maximum" );									
	Cell cell3 = nowRow.createCell(2);
	cell3.setCellStyle(cellHeadStyle);
	cell3.setCellValue( "Target" );	
	Cell cell4 = nowRow.createCell(3);
	cell4.setCellStyle(cellHeadStyle);
	cell4.setCellValue( "Minimum" );								
	Cell cell5 = nowRow.createCell(4);
	cell5.setCellStyle(cellHeadStyle);
	cell5.setCellValue( "Current score" );			
	Cell cell6 = nowRow.createCell(5);
	cell6.setCellStyle(cellHeadStyle);
	cell6.setCellValue( "Previous score" );	
	Cell cell7 = nowRow.createCell(6);
	cell7.setCellStyle(cellHeadStyle);
	cell7.setCellValue( "Change(%)" );	
	
	row++;
	
	List<PeriodTrendsData<KpiVO>> periodDatas = (List<PeriodTrendsData<KpiVO>>)context.get("periodDatas");
	for (PeriodTrendsData<KpiVO> periodData : periodDatas) {
		nowRow = sh.createRow(row);

		cell1 = nowRow.createCell(0);
		cell1.setCellValue( periodData.getCurrent().getName() );				
		cell2 = nowRow.createCell(1);
		cell2.setCellValue( periodData.getCurrent().getMax() );									
		cell3 = nowRow.createCell(2);
		cell3.setCellValue( periodData.getCurrent().getTarget() );	
		cell4 = nowRow.createCell(3);
		cell4.setCellValue( periodData.getCurrent().getMin() );								
		cell5 = nowRow.createCell(4);
		cell5.setCellValue( BscReportSupportUtils.parse2( periodData.getCurrent().getScore() ) );			
		cell6 = nowRow.createCell(5);
		cell6.setCellValue( BscReportSupportUtils.parse2( periodData.getPrevious().getScore() ) );	
		cell7 = nowRow.createCell(6);
		cell7.setCellValue( BscReportSupportUtils.parse2( periodData.getChange() ) );			
		
		row++;
	}
	
	nowRow = sh.createRow(row);
	
	cell1 = nowRow.createCell(0);
	cell1.setCellValue( "Current period: " + (String)context.get("currentPeriodDateRange") + " , Previous period: " + (String)context.get("previousPeriodDateRange") );				
	
}
 
Example 16
Source File: PersonalReportPdfCommand.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
private String createPdf(Context context) throws Exception {
	BscReportPropertyUtils.loadData();
	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 = SimpleUtils.getUUIDStr() + ".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.createFoot(table, context);
	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, "personal-report.pdf");
	file = null;
	return oid;
}
 
Example 17
Source File: KpiDateRangeScoreCommand.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
@Override
public boolean execute(Context context) throws Exception {
	if (this.getResult(context)==null || !(this.getResult(context) instanceof BscStructTreeObj) ) {
		return false;
	}
	BscStructTreeObj treeObj = (BscStructTreeObj)this.getResult(context);
	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();
	//BscReportSupportUtils.loadExpression(); 2015-04-11 rem
	//long beg = System.currentTimeMillis();
	for (VisionVO vision : treeObj.getVisions()) {
		for (PerspectiveVO perspective : vision.getPerspectives()) {
			for (ObjectiveVO objective : perspective.getObjectives()) {
				// 2015-04-11 add
				ExecutorService kpiCalculationPool = 
						Executors.newFixedThreadPool( SimpleUtils.getAvailableProcessors(objective.getKpis().size()) );					
				for (KpiVO kpi : objective.getKpis()) {
					/* 2015-04-11 rem
					if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency) 
							|| BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency) 
							|| BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency) ) {
						this.fillDateRangeMonth(kpi, frequency, startDate, endDate);
					} else {
						this.fillDateRangeYear(kpi, frequency, startYearDate, endYearDate);
					}
					*/
					
					// 2015-04-11 add
					ScoreCalculationCallableData data = new ScoreCalculationCallableData();
					data.setDefaultMode(false);
					data.setKpi(kpi);
					data.setFrequency(frequency);
					data.setDate1(startYearDate);
					data.setDate2(endYearDate);
					if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency) 
							|| BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency) 
							|| BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency) ) {
						data.setDate1(startDate);
						data.setDate2(endDate);							
					}
					data = kpiCalculationPool.submit( new ScoreCalculationCallable(data) ).get();						
					
				}
				kpiCalculationPool.shutdown();
			}
		}
	}
	//long end = System.currentTimeMillis();
	//System.out.println( this.getClass().getName() + " use time(MS) = " + (end-beg) );
	return false;
}
 
Example 18
Source File: PerformanceScoreChainUtils.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
public static void createOrUpdateMonitorItemScore(String dateVal, Context context) throws ServiceException, Exception {
	ChainResultObj result = getResult(context);
	if (result.getValue() == null || ( (BscStructTreeObj)result.getValue() ).getVisions() == null || ( (BscStructTreeObj)result.getValue() ).getVisions().size() == 0) {
		logger.warn( "No data!" );
		return;
	}
	//String dateVal = SimpleUtils.getStrYMD("");
	String frequency = (String)context.get("frequency");
	String orgId = (String)context.get("orgId");
	String empId = (String)context.get("empId");
	List<VisionVO> visions = ( (BscStructTreeObj)result.getValue() ).getVisions();
	for (VisionVO vision : visions) {
		List<PerspectiveVO> perspectives = vision.getPerspectives();
		MonitorItemScoreVO visionMonitorItemScore = getMonitorItemScore(
				dateVal, frequency, orgId, empId, MonitorItemType.VISION, vision.getVisId());
		//visionMonitorItemScore.setScore( BscReportSupportUtils.parse2(vision.getScore()) );
		setScore(visionMonitorItemScore, vision.getScore());
		saveOrUpdateMonitorItemScore(visionMonitorItemScore);
		for (PerspectiveVO perspective : perspectives) {
			List<ObjectiveVO> objectives = perspective.getObjectives();
			MonitorItemScoreVO perspectiveMonitorItemScore = getMonitorItemScore(
					dateVal, frequency, orgId, empId, MonitorItemType.PERSPECTIVES, perspective.getPerId());
			//perspectiveMonitorItemScore.setScore( BscReportSupportUtils.parse2(perspective.getScore()) );
			setScore(perspectiveMonitorItemScore, perspective.getScore());
			saveOrUpdateMonitorItemScore(perspectiveMonitorItemScore);
			for (ObjectiveVO objective : objectives) {
				List<KpiVO> kpis = objective.getKpis();
				MonitorItemScoreVO objectiveMonitorItemScore = getMonitorItemScore(
						dateVal, frequency, orgId, empId, MonitorItemType.STRATEGY_OF_OBJECTIVES, objective.getObjId());
				//objectiveMonitorItemScore.setScore( BscReportSupportUtils.parse2(objective.getScore()) );
				setScore(objectiveMonitorItemScore, objective.getScore());
				saveOrUpdateMonitorItemScore(objectiveMonitorItemScore);
				for (KpiVO kpi : kpis) {
					MonitorItemScoreVO kpiMonitorItemScore = getMonitorItemScore(
							dateVal, frequency, orgId, empId, MonitorItemType.KPI, kpi.getId());
					//kpiMonitorItemScore.setScore( BscReportSupportUtils.parse2(kpi.getScore()) );
					setScore(kpiMonitorItemScore, kpi.getScore());
					saveOrUpdateMonitorItemScore(kpiMonitorItemScore);		
				}
			}
		}
	}
	
}
 
Example 19
Source File: KpiReportContentQueryAction.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
private void getContent() throws ControllerException, AuthorityException, ServiceException, Exception {
	this.checkFields();
	this.setDateValue();
	this.checkDateRange();
	Context context = this.getChainContext();
	SimpleChain chain = new SimpleChain();
	ChainResultObj resultObj = chain.getResultFromResource("kpiReportHtmlContentChain", context);
	this.body = String.valueOf( resultObj.getValue() );
	this.message = resultObj.getMessage();
	if ( !StringUtils.isBlank(this.body) && this.body.startsWith("<!-- BSC_PROG003D0001Q -->") ) {
		this.success = IS_YES;
	}		
	if (context.get("treeObj")==null) {
		return;
	}
	BscStructTreeObj treeObj = (BscStructTreeObj)context.get("treeObj");
	this.fillPerspectivesPieChartData(treeObj);
	this.fillPerspectivesBarChartData(treeObj);
	this.fillLineChartData(treeObj);
	if (YesNo.YES.equals(this.getFields().get("nobody"))) { // 不要有 HTML版本的輸出, 通常是給 dashboard 用的
		this.body = "";
	}
	
	// ------------------------------------------------------------------
	// 2016-11-01
	// 把輸出 ChainResultObj 與 BscStructTreeObj 轉成 Json 放入 MAP 存檔至 TB_SYS_UPLOAD , 主要給 workspace 用的
	// ------------------------------------------------------------------
	if (YesNo.YES.equals(this.getFields().get("saveResultJson")) && treeObj.getVisions()!=null && treeObj.getVisions().size()==1) {
		ObjectMapper objectMapper = new ObjectMapper();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("treeObjJsonStr", SimpleUtils.toB64(objectMapper.writeValueAsString(treeObj)));
		dataMap.put("resultObjJsonStr", SimpleUtils.toB64(objectMapper.writeValueAsString(resultObj)));			
		String jsonData = objectMapper.writeValueAsString(dataMap);
		this.uploadOid = UploadSupportUtils.create(
				Constants.getSystem(), 
				UploadTypes.IS_TEMP, 
				false, 
				jsonData.getBytes(), 
				SimpleUtils.getUUIDStr() + ".json");
	}
	// ------------------------------------------------------------------
	
}
 
Example 20
Source File: KpiReportPdfCommand.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
private String createPdf(Context context) throws Exception {
	BscReportPropertyUtils.loadData();
	BscReportSupportUtils.loadExpression(); // 2015-04-18 add
	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 = SimpleUtils.getUUIDStr() + ".pdf";
	String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
	OutputStream os = new FileOutputStream(fileFullPath);
	//Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
	Document document = new Document(PageSize.A4, 10, 10, 10, 10);		
	document.left(100f);
	document.top(150f);
	PdfWriter writer = PdfWriter.getInstance(document, os);
	document.open();  
	
	int dateRangeRows = 4 + vision.getPerspectives().get(0).getObjectives().get(0).getKpis().get(0).getDateRangeScores().size();
	PdfPTable table = new PdfPTable(MAX_COLSPAN);
	PdfPTable dateRangeTable = new PdfPTable( dateRangeRows );
	PdfPTable chartsTable = new PdfPTable( 2 );
	PdfPTable signTable = new PdfPTable( 1 );
	table.setWidthPercentage(100f);	
	dateRangeTable.setWidthPercentage(100f);
	chartsTable.setWidthPercentage(100f);
	signTable.setWidthPercentage(100f);
	
	this.createHead(table, vision);
	this.createBody(table, vision);
	this.createDateRange(dateRangeTable, vision, context, dateRangeRows);		
	this.putCharts(chartsTable, context);
	this.putSignature(signTable, context);
	
	document.add(chartsTable);
	document.add(table);  
	document.add(dateRangeTable);  
	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, "kpi-report.pdf");
	file = null;
	return oid;
}