📄 workeffortapplication.java
字号:
/* * $Id: WorkEffortApplication.java 5462 2005-08-05 18:35:48Z jonesde $ * * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */package org.ofbiz.workeffort.workeffort;import java.io.IOException;import java.util.Collection;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import javax.servlet.jsp.PageContext;import org.ofbiz.base.util.BshUtil;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.StringUtil;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.serialize.SerializeException;import org.ofbiz.entity.serialize.XmlSerializer;import org.ofbiz.workflow.WfException;import org.ofbiz.workflow.WfUtil;import bsh.EvalError;/** * WorkEffortWorker - Worker class to reduce code in JSPs & make it more reusable * * @author Manuel Soto * @version $Rev: 5462 $ * @since 2.0 */public final class WorkEffortApplication { public static final String module = WorkEffortApplication.class.getName(); /** * Determine if the workeffort is an activity and has an Application as the implementation * @param pageContext * @param workEffort The work effort to be examined * @return */ public static boolean isApplication(GenericValue workEffort) { if (!workEffort.get("workEffortTypeId").equals("ACTIVITY")) return false; // check for the existence of applications try { if (getApplications(workEffort).isEmpty()) return false; } catch (GenericEntityException ee) { Debug.logWarning(ee, module); return false; } return true; } /** * Determine if the workeffort is an activity and has an Application as the implementation * @param workEffortAttrName The work effort to be examined. Located in the pageContext * @return */ public static void isApplication( PageContext pageContext, String workEffortAttrName, String isApplicationAttrName) { pageContext.setAttribute( isApplicationAttrName, new Boolean(isApplication((GenericValue) pageContext.getAttribute(workEffortAttrName)))); } public static String getApplicationId(PageContext pageContext, String partyAssignsAttrName) { Collection partyAssigns = (Collection) pageContext.getAttribute(partyAssignsAttrName); if (!partyAssigns.isEmpty()) { // look for acepted GenericValue partyAssignAcepted = null; for (Iterator partyAssignIt = partyAssigns.iterator(); partyAssignIt.hasNext();) { GenericValue partyAssign = (GenericValue) partyAssignIt.next(); if (((String) partyAssign.get("statusId")).equals("CAL_ACCEPTED")) { partyAssignAcepted = partyAssign; break; } } if (partyAssignAcepted != null) try { final Collection applicationSandboxs = partyAssignAcepted.getRelated("ApplicationSandbox"); GenericValue applicationSandbox = (GenericValue) applicationSandboxs.toArray()[0]; return (String) applicationSandbox.get("applicationId"); } catch (GenericEntityException ee) { Debug.logWarning(ee, module); } } Debug.logWarning("Can't find applicationId", module); return null; } /** * Retrieve the information of the application in the implementation of the activity ans save in the page context * It asume that an activity has at least one application * * @param pageContext The page context where the information is to be saved * @param workEffortAttrName The attribute name to localte the workeffort in the pageCOntext * @param applicationAttrName The name of the attribute where the application's specification will be savd in the page context * @throws WfException * @see getApplication */ public static void getApplication(PageContext pageContext, String workEffortAttrName, String applicationAttrName) throws WfException { getApplication(pageContext, workEffortAttrName, applicationAttrName, null, null, null); } /** * Retrieve the information of the application in the implementation of the activity ans save in the page context * It asume that an activity has at least one application * * @param pageContext The page context where the information is to be saved * @param workEffortAttrName The attribute name to localte the workeffort in the pageContext * @param applicationAttrName The name of the attribute where the application's specification will be savd in the page context * @param applicationContextSignatureName The name of the attribute where the application's context Signature specification will be savd in the page context * @param applicationResultSignatureName The name of the attribute where the application's result Signature specification will be saved in the page context * @param applicationContextName The name of the attribute where the application's context will be savd in the page context * @throws WfException */ public static void getApplication(PageContext pageContext, String workEffortAttrName, String applicationAttrName, String applicationContextSignatureName, String applicationResultSignatureName, String applicationContextName) throws WfException { GenericValue workEffort = (GenericValue) pageContext.getAttribute(workEffortAttrName); GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator"); try { Collection applications = getApplications(workEffort); if (applications.iterator().hasNext()) { GenericValue workflowActivityTool = (GenericValue) applications.iterator().next(); if (applicationAttrName != null && applicationAttrName.length() != 0) pageContext.setAttribute(applicationAttrName, workflowActivityTool); Map contextSignature = new HashMap(); Map resultSignature = new HashMap(); getApplicationSignatures(delegator, workflowActivityTool, contextSignature, resultSignature); Map context = getApplicationContext( delegator, contextSignature, (String) workflowActivityTool.get("actualParameters"), (String) workflowActivityTool.get("extendedAttributes"),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -