1 25 package org.ofbiz.common.status; 26 27 import java.util.Collection ; 28 import java.util.LinkedList ; 29 import java.util.List ; 30 31 import javax.servlet.jsp.PageContext ; 32 33 import org.ofbiz.base.util.Debug; 34 import org.ofbiz.base.util.UtilMisc; 35 import org.ofbiz.entity.GenericDelegator; 36 import org.ofbiz.entity.GenericEntityException; 37 38 45 public class StatusWorker { 46 47 public static final String module = StatusWorker.class.getName(); 48 49 public static void getStatusItems(PageContext pageContext, String attributeName, String statusTypeId) { 50 GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator"); 51 52 try { 53 Collection statusItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeId), UtilMisc.toList("sequenceId")); 54 55 if (statusItems != null) 56 pageContext.setAttribute(attributeName, statusItems); 57 } catch (GenericEntityException e) { 58 Debug.logError(e, module); 59 } 60 } 61 62 public static void getStatusItems(PageContext pageContext, String attributeName, String statusTypeIdOne, String statusTypeIdTwo) { 63 GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator"); 64 List statusItems = new LinkedList (); 65 66 try { 67 Collection calItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeIdOne), UtilMisc.toList("sequenceId")); 68 69 if (calItems != null) 70 statusItems.addAll(calItems); 71 } catch (GenericEntityException e) { 72 Debug.logError(e, module); 73 } 74 try { 75 Collection taskItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeIdTwo), UtilMisc.toList("sequenceId")); 76 77 if (taskItems != null) 78 statusItems.addAll(taskItems); 79 } catch (GenericEntityException e) { 80 Debug.logError(e, module); 81 } 82 83 if (statusItems.size() > 0) 84 pageContext.setAttribute(attributeName, statusItems); 85 } 86 87 public static void getStatusValidChangeToDetails(PageContext pageContext, String attributeName, String statusId) { 88 GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator"); 89 Collection statusValidChangeToDetails = null; 90 91 try { 92 statusValidChangeToDetails = delegator.findByAndCache("StatusValidChangeToDetail", UtilMisc.toMap("statusId", statusId), UtilMisc.toList("sequenceId")); 93 } catch (GenericEntityException e) { 94 Debug.logError(e, module); 95 } 96 97 if (statusValidChangeToDetails != null) 98 pageContext.setAttribute(attributeName, statusValidChangeToDetails); 99 } 100 } 101 | Popular Tags |