1 25 package org.ofbiz.common.status; 26 27 import java.util.Collection ; 28 import java.util.HashMap ; 29 import java.util.Iterator ; 30 import java.util.LinkedList ; 31 import java.util.List ; 32 import java.util.Map ; 33 34 import org.ofbiz.base.util.Debug; 35 import org.ofbiz.base.util.UtilMisc; 36 import org.ofbiz.entity.GenericDelegator; 37 import org.ofbiz.entity.GenericEntityException; 38 import org.ofbiz.service.DispatchContext; 39 import org.ofbiz.service.ServiceUtil; 40 41 48 public class StatusServices { 49 50 public static final String module = StatusServices.class.getName(); 51 52 public static Map getStatusItems(DispatchContext ctx, Map context) { 53 GenericDelegator delegator = (GenericDelegator) ctx.getDelegator(); 54 List statusTypes = (List ) context.get("statusTypeIds"); 55 if (statusTypes == null || statusTypes.size() == 0) { 56 return ServiceUtil.returnError("Parameter statusTypeIds can not be null and must contain at least one element"); 57 } 58 59 Iterator i = statusTypes.iterator(); 60 List statusItems = new LinkedList (); 61 while (i.hasNext()) { 62 String statusTypeId = (String ) i.next(); 63 try { 64 Collection myStatusItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeId), UtilMisc.toList("sequenceId")); 65 statusItems.addAll(myStatusItems); 66 } catch (GenericEntityException e) { 67 Debug.logError(e, module); 68 } 69 } 70 Map ret = new HashMap (); 71 ret.put("statusItems",statusItems); 72 return ret; 73 } 74 75 public static Map getStatusValidChangeToDetails(DispatchContext ctx, Map context) { 76 GenericDelegator delegator = (GenericDelegator) ctx.getDelegator(); 77 List statusValidChangeToDetails = null; 78 String statusId = (String ) context.get("statusId"); 79 try { 80 statusValidChangeToDetails = delegator.findByAndCache("StatusValidChangeToDetail", UtilMisc.toMap("statusId", statusId), UtilMisc.toList("sequenceId")); 81 } catch (GenericEntityException e) { 82 Debug.logError(e, module); 83 } 84 Map ret = ServiceUtil.returnSuccess(); 85 if (statusValidChangeToDetails != null) { 86 ret.put("statusValidChangeToDetails", statusValidChangeToDetails); 87 } 88 return ret; 89 } 90 } 91 | Popular Tags |