Search in sources :

Example 1 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj in project bamboobsc by billchen198318.

the class SimpleChain method getResult.

private ChainResultObj getResult(Context context) throws Exception {
    ChainResultObj resultObj = new ChainResultObj();
    resultObj.setValue(context.get(ChainConstants.CHAIN_RESULT));
    resultObj.setMessage(StringUtils.defaultString((String) context.get(ChainConstants.CHAIN_MESSAGE)));
    return resultObj;
}
Also used : ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj)

Example 2 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj in project bamboobsc by billchen198318.

the class PeriodTrendsCalUtils method generateKpiPeriodTrendsExcel.

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();
}
Also used : Context(org.apache.commons.chain.Context) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 3 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj in project bamboobsc by billchen198318.

the class TimeSeriesAnalysisUtils method getResultForExcel.

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);
    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();
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) TsaVO(com.netsteadfast.greenstep.vo.TsaVO) BbTsaMaCoefficients(com.netsteadfast.greenstep.po.hbm.BbTsaMaCoefficients) TimeSeriesAnalysisResult(com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) ArrayList(java.util.ArrayList) List(java.util.List) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 4 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj in project bamboobsc by billchen198318.

the class KpiReportContentQueryAction method loadContentFromUpload.

//	public static void main(String args[]) throws Exception {
//		//CONTENT.txt
//		String jsonStr = FSUtils.readStr("/tmp/CONTENT.txt");
//		Map<String, Object> dataMap = new ObjectMapper().readValue(jsonStr, Map.class);
//		BscStructTreeObj treeObj = new ObjectMapper().readValue( SimpleUtils.deB64((String)dataMap.get("treeObjJsonStr")), BscStructTreeObj.class);
//		ChainResultObj resultObj = new ObjectMapper().readValue( SimpleUtils.deB64((String)dataMap.get("resultObjJsonStr")), ChainResultObj.class);
//		
//	}
/**
	 * 2016-11-01
	 * 主要給 workspace 圖表元件載入用的 
	 * 
	 * @throws ControllerException
	 * @throws AuthorityException
	 * @throws ServiceException
	 * @throws Exception
	 */
private void loadContentFromUpload() throws ControllerException, AuthorityException, ServiceException, Exception {
    String uploadOid = this.getFields().get("uploadOid");
    byte[] content = UploadSupportUtils.getDataBytes(uploadOid);
    String jsonStr = new String(content, Constants.BASE_ENCODING);
    if (StringUtils.isBlank(jsonStr)) {
        throw new Exception("Report json data error.");
    }
    @SuppressWarnings("unchecked") Map<String, Object> dataMap = new ObjectMapper().readValue(jsonStr, Map.class);
    BscStructTreeObj treeObj = new ObjectMapper().readValue(SimpleUtils.deB64((String) dataMap.get("treeObjJsonStr")), BscStructTreeObj.class);
    ChainResultObj resultObj = new ObjectMapper().readValue(SimpleUtils.deB64((String) dataMap.get("resultObjJsonStr")), ChainResultObj.class);
    this.body = String.valueOf(resultObj.getValue());
    this.message = resultObj.getMessage();
    if (!StringUtils.isBlank(this.body) && this.body.startsWith("<!-- BSC_PROG003D0001Q -->")) {
        this.success = IS_YES;
    }
    this.fillPerspectivesPieChartData(treeObj);
    this.fillPerspectivesBarChartData(treeObj);
    this.fillLineChartData(treeObj);
}
Also used : BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj in project bamboobsc by billchen198318.

the class KpiReportContentQueryAction method getContent.

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 = "";
    }
    // ------------------------------------------------------------------
    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");
    }
// ------------------------------------------------------------------
}
Also used : Context(org.apache.commons.chain.Context) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)34 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)28 Context (org.apache.commons.chain.Context)27 ContextBase (org.apache.commons.chain.impl.ContextBase)8 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)7 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)6 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Map (java.util.Map)5 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)4 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)4 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)4 LinkedHashMap (java.util.LinkedHashMap)4 LinkedList (java.util.LinkedList)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)3 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)3 HashMap (java.util.HashMap)3 AppContext (com.netsteadfast.greenstep.base.AppContext)2