Package org.ofbiz.workflow

Examples of org.ofbiz.workflow.EvaluationException


     */
    public Boolean evaluateCondition(Map<String, Object> context, Map<String, String> attrs, String expression, DispatchContext dctx) throws EvaluationException {
        // get the service to call
        String serviceName = attrs.get("serviceName");
        if (UtilValidate.isEmpty(serviceName))
            throw new EvaluationException("Invalid serviceName; be sure to set the serviceName ExtendedAttribute");

        // get the dispatcher
        LocalDispatcher dispatcher = dctx.getDispatcher();
        if (dispatcher == null)
            throw new EvaluationException("Bad LocalDispatcher found in the DispatchContext");

        // create a map of all context and extended attributes, attributes will overwrite context values
        Map<String, Object> newContext = new HashMap<String, Object>(context);
        newContext.putAll(attrs);

        // build the context for the service
        Map<String, Object> serviceContext = null;
        ModelService model = null;
        try {
            model = dctx.getModelService(serviceName);
            serviceContext = model.makeValid(newContext, ModelService.IN_PARAM);
        } catch (GenericServiceException e) {
            throw new EvaluationException("Cannot get ModelService object for service named: " + serviceName, e);
        }

        // invoke the service
        Map<String, Object> serviceResult = null;
        try {
            serviceResult = dispatcher.runSync(serviceName, serviceContext);
        } catch (GenericServiceException e) {
            throw new EvaluationException("Cannot invoke the service named: " + serviceName, e);
        }

        // get the evaluationResult object from the result
        Boolean evaluationResult = null;
        try {
            evaluationResult = (Boolean) serviceResult.get("evaluationResult");
        } catch (ClassCastException e) {
            throw new EvaluationException("Service did not return a valid evaluationResult object");
        }

        return evaluationResult;
    }
View Full Code Here


     */
    public Boolean evaluateCondition(Map context, Map attrs, String expression, DispatchContext dctx) throws EvaluationException {
        // get the service to call
        String serviceName = (String) attrs.get("serviceName");
        if (serviceName == null || serviceName.length() == 0)
            throw new EvaluationException("Invalid serviceName; be sure to set the serviceName ExtendedAttribute");

        // get the dispatcher
        LocalDispatcher dispatcher = dctx.getDispatcher();
        if (dispatcher == null)
            throw new EvaluationException("Bad LocalDispatcher found in the DispatchContext");

        // create a map of all context and extended attributes, attributes will overwrite context values
        Map newContext = new HashMap(context);
        newContext.putAll(attrs);

        // build the context for the service
        Map serviceContext = null;
        ModelService model = null;
        try {
            model = dctx.getModelService(serviceName);
            serviceContext = model.makeValid(newContext, ModelService.IN_PARAM);
        } catch (GenericServiceException e) {
            throw new EvaluationException("Cannot get ModelService object for service named: " + serviceName, e);
        }

        // invoke the service
        Map serviceResult = null;
        try {
            serviceResult = dispatcher.runSync(serviceName, serviceContext);
        } catch (GenericServiceException e) {
            throw new EvaluationException("Cannot invoke the service named: " + serviceName, e);
        }

        // get the evaluationResult object from the result
        Boolean evaluationResult = null;
        try {
            evaluationResult = (Boolean) serviceResult.get("evaluationResult");
        } catch (ClassCastException e) {
            throw new EvaluationException("Service did not return a valid evaluationResult object");
        }

        return evaluationResult;
    }
View Full Code Here

     */
    public Boolean evaluateCondition(Map<String, Object> context, Map<String, String> attrs, String expression, DispatchContext dctx) throws EvaluationException {
        // get the service to call
        String serviceName = (String) attrs.get("serviceName");
        if (UtilValidate.isEmpty(serviceName))
            throw new EvaluationException("Invalid serviceName; be sure to set the serviceName ExtendedAttribute");

        // get the dispatcher
        LocalDispatcher dispatcher = dctx.getDispatcher();
        if (dispatcher == null)
            throw new EvaluationException("Bad LocalDispatcher found in the DispatchContext");

        // create a map of all context and extended attributes, attributes will overwrite context values
        Map<String, Object> newContext = new HashMap<String, Object>(context);
        newContext.putAll(attrs);

        // build the context for the service
        Map<String, Object> serviceContext = null;
        ModelService model = null;
        try {
            model = dctx.getModelService(serviceName);
            serviceContext = model.makeValid(newContext, ModelService.IN_PARAM);
        } catch (GenericServiceException e) {
            throw new EvaluationException("Cannot get ModelService object for service named: " + serviceName, e);
        }

        // invoke the service
        Map<String, Object> serviceResult = null;
        try {
            serviceResult = dispatcher.runSync(serviceName, serviceContext);
        } catch (GenericServiceException e) {
            throw new EvaluationException("Cannot invoke the service named: " + serviceName, e);
        }

        // get the evaluationResult object from the result
        Boolean evaluationResult = null;
        try {
            evaluationResult = (Boolean) serviceResult.get("evaluationResult");
        } catch (ClassCastException e) {
            throw new EvaluationException("Service did not return a valid evaluationResult object");
        }

        return evaluationResult;
    }
View Full Code Here

     */
    public Boolean evaluateCondition(Map context, Map attrs, String expression, DispatchContext dctx) throws EvaluationException {
        // get the service to call
        String serviceName = (String) attrs.get("serviceName");
        if (serviceName == null || serviceName.length() == 0)
            throw new EvaluationException("Invalid serviceName; be sure to set the serviceName ExtendedAttribute");
         
        // get the dispatcher  
        LocalDispatcher dispatcher = dctx.getDispatcher();
        if (dispatcher == null)
            throw new EvaluationException("Bad LocalDispatcher found in the DispatchContext");
       
        // create a map of all context and extended attributes, attributes will overwrite context values
        Map newContext = new HashMap(context);
        newContext.putAll(attrs);
       
        // build the context for the service
        Map serviceContext = null;
        ModelService model = null;
        try {
            model = dctx.getModelService(serviceName);
            serviceContext = model.makeValid(newContext, ModelService.IN_PARAM);
        } catch (GenericServiceException e) {
            throw new EvaluationException("Cannot get ModelService object for service named: " + serviceName, e);           
        }
       
        // invoke the service
        Map serviceResult = null;
        try {
            serviceResult = dispatcher.runSync(serviceName, serviceContext);
        } catch (GenericServiceException e) {
            throw new EvaluationException("Cannot invoke the service named: " + serviceName, e);
        }
       
        // get the evaluationResult object from the result
        Boolean evaluationResult = null;
        try {
            evaluationResult = (Boolean) serviceResult.get("evaluationResult");
        } catch (ClassCastException e) {
            throw new EvaluationException("Service did not return a valid evaluationResult object");
        }
       
        return evaluationResult;
    }
View Full Code Here

TOP

Related Classes of org.ofbiz.workflow.EvaluationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.