Search in sources :

Example 1 with TbSysBeanHelpExprMap

use of com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap in project bamboobsc by billchen198318.

the class ServiceScriptExpressionUtils method getParameters.

private static Map<String, Object> getParameters(TbSysBeanHelpExpr beanHelpExpr, List<TbSysBeanHelpExprMap> beanHelpExprMaps, Object resultObj, ProceedingJoinPoint pjp) {
    Object[] args = pjp.getArgs();
    Map<String, Object> dataMap = new HashMap<String, Object>();
    for (TbSysBeanHelpExprMap map : beanHelpExprMaps) {
        Object value = null;
        if (YesNo.YES.equals(map.getMethodResultFlag())) {
            value = resultObj;
        } else {
            for (int i = 0; args != null && i < args.length; i++) {
                if (args[i] != null && args[i].getClass() != null && args[i].getClass().getName().equals(map.getMethodParamClass()) && map.getMethodParamIndex() == i) {
                    value = args[i];
                }
            }
        }
        dataMap.put(map.getVarName(), value);
    }
    return dataMap;
}
Also used : HashMap(java.util.HashMap) TbSysBeanHelpExprMap(com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Example 2 with TbSysBeanHelpExprMap

use of com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap in project bamboobsc by billchen198318.

the class ServiceScriptExpressionUtils method process.

private static void process(String runType, String beanId, Method method, String system, Object resultObj, ProceedingJoinPoint pjp) throws ServiceException, Exception {
    SysBeanHelpVO beanHelp = loadSysBeanHelperData(beanId, method.getName(), system);
    if (!YesNo.YES.equals(beanHelp.getEnableFlag())) {
        return;
    }
    List<TbSysBeanHelpExpr> beanHelpExprs = loadSysBeanHelpExprsData(beanHelp);
    if (beanHelpExprs == null || beanHelpExprs.size() < 1) {
        return;
    }
    for (TbSysBeanHelpExpr helpExpr : beanHelpExprs) {
        SysExpressionVO expression = new SysExpressionVO();
        expression.setExprId(helpExpr.getExprId());
        DefaultResult<SysExpressionVO> eResult = sysExpressionService.findByUK(expression);
        if (eResult.getValue() == null) {
            continue;
        }
        expression = eResult.getValue();
        List<TbSysBeanHelpExprMap> exprMaps = loadSysBeanHelpExprMapsData(helpExpr);
        /* 2015-04-14 rem
			try {
				ScriptExpressionUtils.execute(
						expression.getType(), 
						expression.getContent(), 
						null, 
						getParameters(helpExpr, exprMaps, resultObj, pjp));						
			} catch (Exception e) {
				e.printStackTrace();
			}	
			*/
        // 不要 try catch 包起來, 讓外面也能接到 Exception 
        ScriptExpressionUtils.execute(expression.getType(), expression.getContent(), null, getParameters(helpExpr, exprMaps, resultObj, pjp));
    }
}
Also used : TbSysBeanHelpExprMap(com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap) SysBeanHelpVO(com.netsteadfast.greenstep.vo.SysBeanHelpVO) TbSysBeanHelpExpr(com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExpr) SysExpressionVO(com.netsteadfast.greenstep.vo.SysExpressionVO)

Example 3 with TbSysBeanHelpExprMap

use of com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap in project bamboobsc by billchen198318.

the class SystemBeanHelpLogicServiceImpl method delete.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(SysBeanHelpVO beanHelp) throws ServiceException, Exception {
    if (beanHelp == null || super.isBlank(beanHelp.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    // delete TB_SYS_BEAN_HELP_EXPR
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("helpOid", beanHelp.getOid());
    List<TbSysBeanHelpExpr> exprList = this.sysBeanHelpExprService.findListByParams(params);
    for (int i = 0; exprList != null && i < exprList.size(); i++) {
        // delete TB_SYS_BEAN_HELP_EXPR_MAP
        TbSysBeanHelpExpr helpExpr = exprList.get(i);
        params.clear();
        params.put("helpExprOid", helpExpr.getOid());
        List<TbSysBeanHelpExprMap> exprMapList = this.sysBeanHelpExprMapService.findListByParams(params);
        for (int j = 0; exprMapList != null && j < exprMapList.size(); j++) {
            TbSysBeanHelpExprMap helpExprMap = exprMapList.get(j);
            this.sysBeanHelpExprMapService.delete(helpExprMap);
        }
        this.sysBeanHelpExprService.delete(helpExpr);
    }
    return sysBeanHelpService.deleteObject(beanHelp);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) TbSysBeanHelpExprMap(com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap) TbSysBeanHelpExpr(com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExpr) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TbSysBeanHelpExprMap (com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap)3 TbSysBeanHelpExpr (com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExpr)2 HashMap (java.util.HashMap)2 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 SysBeanHelpVO (com.netsteadfast.greenstep.vo.SysBeanHelpVO)1 SysExpressionVO (com.netsteadfast.greenstep.vo.SysExpressionVO)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 Transactional (org.springframework.transaction.annotation.Transactional)1