⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workeffortapplication.java

📁 国外的一套开源CRM
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        getContext(workEffort),
                        (String) workEffort.get("workEffortId"));

                if (applicationContextSignatureName != null
                    && applicationContextSignatureName.length() != 0
                    && contextSignature != null)
                    pageContext.setAttribute(applicationContextSignatureName, contextSignature);

                if (applicationResultSignatureName != null
                    && applicationResultSignatureName.length() != 0
                    && resultSignature != null)
                    pageContext.setAttribute(applicationResultSignatureName, resultSignature);

                if (applicationContextName != null && applicationContextName.length() != 0)
                    pageContext.setAttribute(applicationContextName, context);
            }

        } catch (GenericEntityException gex) {
            throw new WfException(
                "Can't find Applications in Workeffort [" + workEffort.get("workEffortId") + "]",
                gex);
        }

    }

    private static Collection getApplications(GenericValue workEffort) throws GenericEntityException {

        final String packageId = (String) workEffort.get("workflowPackageId");
        final String packageVersion = (String) workEffort.get("workflowPackageVersion");
        final String processId = (String) workEffort.get("workflowProcessId");
        final String processVersion = (String) workEffort.get("workflowProcessVersion");
        final String activityId = (String) workEffort.get("workflowActivityId");
        final GenericDelegator delegator = workEffort.getDelegator();

        Map expresions = new HashMap();
        expresions.putAll(UtilMisc.toMap("packageId", packageId));
        expresions.putAll(UtilMisc.toMap("packageVersion", packageVersion));
        expresions.putAll(UtilMisc.toMap("processId", processId));
        expresions.putAll(UtilMisc.toMap("processVersion", processVersion));
        expresions.putAll(UtilMisc.toMap("activityId", activityId));
        expresions.putAll(UtilMisc.toMap("toolTypeEnumId", "WTT_APPLICATION"));

        return delegator.findByAnd("WorkflowActivityTool", expresions);

    }

    private static void getApplicationSignatures(
            GenericDelegator delegator,
            GenericValue application,
            Map contextSignature,
            Map resultSignature)
            throws GenericEntityException {
        final String packageId = (String) application.get("packageId");
        final String packageVersion = (String) application.get("packageVersion");
        final String processId = (String) application.get("processId");
        final String processVersion = (String) application.get("processVersion");
        final String applicationId = (String) application.get("toolId");

        Map expresions = new HashMap();
        expresions.putAll(UtilMisc.toMap("packageId", packageId));
        expresions.putAll(UtilMisc.toMap("packageVersion", packageVersion));
        expresions.putAll(UtilMisc.toMap("processId", processId));
        expresions.putAll(UtilMisc.toMap("processVersion", processVersion));
        expresions.putAll(UtilMisc.toMap("applicationId", applicationId));

        final Collection params = delegator.findByAnd("WorkflowFormalParam", expresions);

        Iterator i = params.iterator();
        while (i.hasNext()) {
            GenericValue param = (GenericValue) i.next();
            String name = param.getString("formalParamId");
            String mode = param.getString("modeEnumId");
            String type = param.getString("dataTypeEnumId");
            if (mode.equals("WPM_IN") || mode.equals("WPM_INOUT"))
                contextSignature.put(name, WfUtil.getJavaType(type));
            else if (mode.equals("WPM_OUT") || mode.equals("WPM_INOUT"))
                resultSignature.put(name, WfUtil.getJavaType(type));
        }
    }

    private static Map getApplicationContext(
            GenericDelegator delegator,
            Map contextSignature,
            String actualParameters,
            String extendedAttr,
            Map context,
            String workEffortId)
            throws WfException {
        List params = StringUtil.split(actualParameters, ",");
        Map actualContext = new HashMap();

        Map extendedAttributes = StringUtil.strToMap(extendedAttr);
        if (extendedAttributes != null && extendedAttributes.size() > 0)
            actualContext.putAll(extendedAttributes);

        // setup some internal buffer parameters
        // maintain synchronized w/ wfActivityImpl
        GenericValue userLogin = null;
        if (context.containsKey("runAsUser")) {
            userLogin = getUserLogin(delegator, (String) context.get("runAsUser"));
            actualContext.put("userLogin", userLogin);
        } else if (context.containsKey("workflowOwnerId")) {
            userLogin = getUserLogin(delegator, (String) context.get("workflowOwnerId"));
        }

        context.put("userLogin", userLogin);
        context.put("workEffortId", workEffortId);
        // /setup some internal bufer parameters

        Iterator i = params.iterator();
        while (i.hasNext()) {

            Object keyExpr = i.next();
            String keyExprStr = (String) keyExpr;
            if (keyExprStr != null && keyExprStr.trim().toLowerCase().startsWith("expr:"))
                try {
                    BshUtil.eval(keyExprStr.trim().substring(5).trim(), context);
                } catch (EvalError e) {
                    throw new WfException("Error evaluating actual parameter: " + keyExprStr, e);
                } else if (keyExprStr != null && keyExprStr.trim().toLowerCase().startsWith("name:")) {
                List couple = StringUtil.split(keyExprStr.trim().substring(5).trim(), "=");
                if (contextSignature.containsKey(((String) couple.get(0)).trim()))
                    actualContext.put(((String) couple.get(0)).trim(), context.get(couple.get(1)));
            } else if (context.containsKey(keyExprStr)) {
                if (contextSignature.containsKey(keyExprStr))
                    actualContext.put(keyExprStr, context.get(keyExprStr));
            } else if (!actualContext.containsKey(keyExprStr))
                throw new WfException("Context does not contain the key: '" + keyExprStr + "'");
        }

        return actualContext;

    }

    private static Map getContext(GenericValue dataObject) throws WfException {
        String contextXML = null;
        Map context = null;
        if (dataObject.get("runtimeDataId") == null)
            return context;
        try {
            GenericValue runtimeData = dataObject.getRelatedOne("RuntimeData");
            contextXML = runtimeData.getString("runtimeInfo");
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e);
        }
        // De-serialize the context
        if (contextXML != null) {
            try {
                context = (Map) XmlSerializer.deserialize(contextXML, dataObject.getDelegator());
            } catch (SerializeException e) {
                throw new WfException(e.getMessage(), e);
            } catch (IOException e) {
                throw new WfException(e.getMessage(), e);
            } catch (Exception e) {
                throw new WfException(e.getMessage(), e);
            }
        }
        return context;
    }
    // Gets a UserLogin object for service invocation
    // This allows a workflow to invoke a service as a specific user
    private static GenericValue getUserLogin(GenericDelegator delegator, String userId) throws WfException {
        GenericValue userLogin = null;
        try {
            userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userId));
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e);
        }
        return userLogin;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -