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

The following examples show how to use org.apache.commons.chain.Context#put() . 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: PersonalAndOrganizationReportDateRangeScoreCommand.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
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;
}
 
Example 2
Source File: KpisDashboardAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void getExcel() throws ControllerException, AuthorityException, ServiceException, Exception {
	String dateRangeChartPngData = this.defaultString( this.getFields().get("dateRangeChartPngData") ).trim();
	String gaugeDatasJsonStr = this.defaultString( this.getFields().get("gaugeDatas") );
	Map<String, Object> gaugeDatas = (Map<String, Object>) new ObjectMapper().readValue(gaugeDatasJsonStr, LinkedHashMap.class);
	Context context = this.getChainContext();
	context.put("dateRangeChartPngData", dateRangeChartPngData);
	context.put("gaugeDatas", gaugeDatas);
	if ( gaugeDatas == null || gaugeDatas.size() < 1 ) {
		super.throwMessage( this.getText("MESSAGE.BSC_PROG003D0006Q_msg1") );
	}
	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 3
Source File: ObjectivesDashboardAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void getExcel() throws ControllerException, AuthorityException, ServiceException, Exception {
	String dateRangeChartPngData = this.defaultString( this.getFields().get("dateRangeChartPngData") ).trim();
	String gaugeDatasJsonStr = this.defaultString( this.getFields().get("gaugeDatas") );
	Map<String, Object> gaugeDatas = (Map<String, Object>) new ObjectMapper().readValue(gaugeDatasJsonStr, LinkedHashMap.class);
	Context context = this.getChainContext();
	context.put("dateRangeChartPngData", dateRangeChartPngData);
	context.put("gaugeDatas", gaugeDatas);
	if ( gaugeDatas == null || gaugeDatas.size() < 1 ) {
		super.throwMessage( this.getText("MESSAGE.BSC_PROG003D0005Q_msg1") );
	}
	SimpleChain chain = new SimpleChain();
	ChainResultObj resultObj = chain.getResultFromResource("objectivesDashboardExcelContentChain", context);
	this.message = resultObj.getMessage();
	if ( resultObj.getValue() instanceof String ) {
		this.uploadOid = (String)resultObj.getValue();
		this.success = IS_YES;
	}			
}
 
Example 4
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 5
Source File: LoadStrategyMapItemsForNewCommand.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@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 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);
	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: DepartmentReportContentQueryAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private Context getChainContext() throws Exception {
	Context context = new ContextBase();
	context.put("visionOid", this.getFields().get("visionOid"));
	context.put("frequency", this.getFields().get("frequency"));
	context.put("startYearDate", this.getFields().get("year"));
	context.put("endYearDate", this.getFields().get("year"));
	context.put("dateType", this.getFields().get("dateType"));
	context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ORGANIZATION);
	OrganizationVO organization = new OrganizationVO();
	organization.setOid( this.getFields().get("organizationOid") );
	DefaultResult<OrganizationVO> result = this.organizationService.findObjectByOid(organization);
	if ( result.getValue() == null ) {
		throw new ServiceException(result.getSystemMessage().getValue());
	}
	organization = result.getValue();
	context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL );
	context.put("orgId", organization.getOrgId() );
	context.put("uploadSignatureOid", this.getFields().get("uploadSignatureOid") );
	return context;
}
 
Example 7
Source File: RegionMapRelationKpisAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private Context getChainContext(String visionOid, String year) throws Exception {
	String dateStr1 = year+"0101";
	String dateStr2 = year+"1230";
	Context context = new ContextBase();
	context.put("visionOid", visionOid);
	context.put("startDate", dateStr1);
	context.put("endDate", dateStr2);		
	context.put("startYearDate",  year);
	context.put("endYearDate",  year);		
	context.put("frequency", BscMeasureDataFrequency.FREQUENCY_YEAR);
	context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ORGANIZATION);
	context.put("orgId", this.getFields().get("orgId"));
	context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
	return context;
}
 
Example 8
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 9
Source File: KpisDashboardAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private Context getContext() throws Exception {
	List< Map<String, Object> > chartDatas = new LinkedList< Map<String, Object> >();
	Enumeration<String> paramNames = this.getHttpServletRequest().getParameterNames();
	while ( paramNames.hasMoreElements() ) {
		String paramName = paramNames.nextElement();
		String value = this.getHttpServletRequest().getParameter(paramName);
		if ( paramName.startsWith("BSC_PROG003D0006Q_meterGaugeChartDatas:") ) {		
			Map<String, Object> dataMap = (Map<String, Object>)
					new ObjectMapper().readValue(value, LinkedHashMap.class);	
			chartDatas.add( dataMap );
		}				
	}		
	Context context = new ContextBase();
	context.put("chartDatas", chartDatas);
	context.put("dateRangeLabel", this.getHttpServletRequest().getParameter("BSC_PROG003D0006Q_dateRangeLabel") );
	context.put("barChartsData", this.getHttpServletRequest().getParameter("BSC_PROG003D0006Q_kpisBarChartsData") );
	return context;
}
 
Example 10
Source File: DashboardNewAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void getExcel() throws ControllerException, AuthorityException, ServiceException, Exception {
	
	// Perspectives
	String perspectiveDateRangeChartPngData = this.defaultString( this.getFields().get("perspectiveDateRangeChartPngData") ).trim();
	String perspectiveGaugeDatasJsonStr = this.defaultString( this.getFields().get("perspectiveGaugeDatas") );
	Map<String, Object> perspectiveGaugeDatas = (Map<String, Object>) new ObjectMapper().readValue(perspectiveGaugeDatasJsonStr, LinkedHashMap.class);
	Context context = this.getChainContext();
	context.put("perspectiveDateRangeChartPngData", perspectiveDateRangeChartPngData);
	context.put("perspectiveGaugeDatas", perspectiveGaugeDatas);
	
	// Objectives
	String objectiveDateRangeChartPngData = this.defaultString( this.getFields().get("objectiveDateRangeChartPngData") ).trim();
	String objectiveGaugeDatasJsonStr = this.defaultString( this.getFields().get("objectiveGaugeDatas") );
	Map<String, Object> objectiveGaugeDatas = (Map<String, Object>) new ObjectMapper().readValue(objectiveGaugeDatasJsonStr, LinkedHashMap.class);
	context.put("objectiveDateRangeChartPngData", objectiveDateRangeChartPngData);
	context.put("objectiveGaugeDatas", objectiveGaugeDatas);
	
	// KPIs
	String kpiDateRangeChartPngData = this.defaultString( this.getFields().get("kpiDateRangeChartPngData") ).trim();
	String kpiGaugeDatasJsonStr = this.defaultString( this.getFields().get("kpiGaugeDatas") );
	Map<String, Object> kpiGaugeDatas = (Map<String, Object>) new ObjectMapper().readValue(kpiGaugeDatasJsonStr, LinkedHashMap.class);
	context.put("kpiDateRangeChartPngData", kpiDateRangeChartPngData);
	context.put("kpiGaugeDatas", kpiGaugeDatas);
	
	if ( perspectiveGaugeDatas == null || perspectiveGaugeDatas.size() < 1 ) {
		super.throwMessage( this.getText("MESSAGE.BSC_PROG003D0009Q_msg1") );
	}
	SimpleChain chain = new SimpleChain();
	ChainResultObj resultObj = chain.getResultFromResource("dashboardNewExcelContentChain", context);
	this.message = resultObj.getMessage();
	if ( resultObj.getValue() instanceof String ) {
		this.uploadOid = (String)resultObj.getValue();
		this.success = IS_YES;
	}			
}
 
Example 11
Source File: PeriodTrendsCalUtils.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
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);		
	if ( !(resultObj.getValue() instanceof String) ) {
		throw new java.lang.IllegalStateException( "kpiPeriodTrendsExcelCommandExcelContentChain error!" );
	}
	return (String)resultObj.getValue();
}
 
Example 12
Source File: KpiReportContentQueryAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void setContextForSingleObject( Context context ) throws Exception {
	String nextType = this.getFields().get("nextType");
	String nextId = this.getFields().get("nextId");
	if ( StringUtils.isBlank(nextType) || StringUtils.isBlank(nextId) ) {
		return;
	}
	if ( ! (BscConstants.HEAD_FOR_PER_ID.equals(nextType) 
			|| BscConstants.HEAD_FOR_OBJ_ID.equals(nextType) || BscConstants.HEAD_FOR_KPI_ID.equals(nextType)) ) {
		return;
	}
	context.put("nextType", nextType );
	context.put("nextId", nextId );
}
 
Example 13
Source File: SwotContentQueryAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Context getChainContext() throws Exception {
	Context context = new ContextBase();
	context.put("visionOid", this.getFields().get("visionOid"));
	context.put("organizationOid", this.getFields().get("organizationOid"));
	context.put("strengthsName", this.getText("TPL.BSC_PROG002D0008Q_s"));
	context.put("weaknessesName", this.getText("TPL.BSC_PROG002D0008Q_w"));
	context.put("opportunitiesName", this.getText("TPL.BSC_PROG002D0008Q_o"));
	context.put("threatsName", this.getText("TPL.BSC_PROG002D0008Q_t"));
	return context;
}
 
Example 14
Source File: LoadPdcaDataCommand.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean execute(Context context) throws Exception {
	pdcaService = (IPdcaService<PdcaVO, BbPdca, String>) AppContext.getBean("bsc.service.PdcaService");
	pdcaDocService = (IPdcaDocService<PdcaDocVO, BbPdcaDoc, String>) AppContext.getBean("bsc.service.PdcaDocService");
	pdcaItemService = (IPdcaItemService<PdcaItemVO, BbPdcaItem, String>) AppContext.getBean("bsc.service.PdcaItemService");
	pdcaItemDocService = (IPdcaItemDocService<PdcaItemDocVO, BbPdcaItemDoc, String>) AppContext.getBean("bsc.service.PdcaItemDocService");
	pdcaAuditService = (IPdcaAuditService<PdcaAuditVO, BbPdcaAudit, String>) AppContext.getBean("bsc.service.PdcaAuditService");
	employeeService = (IEmployeeService<EmployeeVO, BbEmployee, String>) AppContext.getBean("bsc.service.EmployeeService");
	organizationService = (IOrganizationService<OrganizationVO, BbOrganization, String>) AppContext.getBean("bsc.service.OrganizationService");
	kpiService = (IKpiService<KpiVO, BbKpi, String>) AppContext.getBean("bsc.service.KpiService");
	String pdcaOid = (String)context.get("pdcaOid");
	PdcaVO pdca = new PdcaVO();
	pdca.setOid(pdcaOid);
	DefaultResult<PdcaVO> result = pdcaService.findObjectByOid(pdca);
	if (result.getValue() == null) {
		this.setMessage(context, result.getSystemMessage().getValue());
	} else {
		pdca = result.getValue();
		this.loadDetail(pdca);
		this.loadPdcaItems(pdca);
		this.loadAudit(pdca);
		this.setResult(context, pdca);
		context.put("pdca", pdca); // Action 輸出可能會要用到
	}
	return false;
}
 
Example 15
Source File: PerspectivesDashboardAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Context getContext() throws Exception {
	List< Map<String, Object> > chartDatas = new LinkedList< Map<String, Object> >();
	String pieCanvasToData = "";
	String barCanvasToData = "";
	Enumeration<String> paramNames = this.getHttpServletRequest().getParameterNames();
	while ( paramNames.hasMoreElements() ) {
		String paramName = paramNames.nextElement();
		String value = this.getHttpServletRequest().getParameter(paramName);
		if ( paramName.startsWith("BSC_PROG003D0004Q_meterGaugeChartDatas:") ) {		
			Map<String, Object> dataMap = (Map<String, Object>)
					new ObjectMapper().readValue(value, LinkedHashMap.class);	
			chartDatas.add( dataMap );
		}
		if ( paramName.equals("BSC_PROG003D0004Q_barChartDatas") ) {
			barCanvasToData = SimpleUtils.deHex( this.defaultString(value) );
		}
		if ( paramName.equals("BSC_PROG003D0004Q_pieChartDatas") ) {
			pieCanvasToData = SimpleUtils.deHex( this.defaultString(value) );
		}						
	}		
	Context context = new ContextBase();
	context.put("barCanvasToData", barCanvasToData);
	context.put("pieCanvasToData", pieCanvasToData);
	context.put("chartDatas", chartDatas);
	context.put("year", this.getHttpServletRequest().getParameter("BSC_PROG003D0004Q_year") );
	return context;
}
 
Example 16
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 17
Source File: KpiTreeJsonAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void loadTreeItems() throws ServiceException, Exception {
	Context context = new ContextBase();
	context.put("http", this.getHttpServletRequest().getScheme()+"://");
	SimpleChain chain = new SimpleChain();		
	ChainResultObj result = chain.getResultFromResource("kpiTreeItemsChain", context);
	this.message = super.defaultString( result.getMessage() );
	if (result.getValue() != null && result.getValue() instanceof List) {
		this.items = (List<Map<String, Object>>)result.getValue();
	}
}
 
Example 18
Source File: PdcaReportContentQueryAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Context getBscReportChainContext(String pdcaOid, String visionOid, PdcaMeasureFreqVO measureFreq) throws Exception {
	Context context = new ContextBase();
	context.put("visionOid", visionOid);
	context.put("startDate", SimpleUtils.getStrYMD(measureFreq.getStartDate(), "/"));
	context.put("endDate", SimpleUtils.getStrYMD(measureFreq.getEndDate(), "/"));		
	context.put("startYearDate", SimpleUtils.getStrYMD(measureFreq.getStartDate(), "/"));
	context.put("endYearDate", SimpleUtils.getStrYMD(measureFreq.getEndDate(), "/"));		
	context.put("frequency", measureFreq.getFreq());
	context.put("dataFor", measureFreq.getDataType());
	context.put("orgId", measureFreq.getOrgId());
	context.put("empId", measureFreq.getEmpId());
	context.put("account", "");
	context.put("ngVer", YesNo.NO);
	
	List<String> kpiIds = new ArrayList<String>();
	Map<String, Object> paramMap = new HashMap<String, Object>();
	paramMap.put("pdcaOid", pdcaOid);
	List<BbPdcaKpis> pdcaKpisList = this.pdcaKpisService.findListByParams(paramMap);
	for (BbPdcaKpis pdcaKpi : pdcaKpisList) {
		kpiIds.add( pdcaKpi.getKpiId() );
	}
	
	context.put("kpiIds", kpiIds); // 只顯示,要顯示的KPI
	
	return context;
}
 
Example 19
Source File: StrategyMapManagementAction.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private Context getChainContext() throws Exception {
	Context context = new ContextBase();
	context.put("visionOid", this.visionOid);
	return context;
}
 
Example 20
Source File: BaseChainCommandSupport.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public void setMessage(Context context, String message) {
	context.put(ChainConstants.CHAIN_MESSAGE, message);
}