Author: doogie
Date: Sun Jun 29 13:33:19 2008 New Revision: 672672 URL: http://svn.apache.org/viewvc?rev=672672&view=rev Log: More generics work. Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java ofbiz/trunk/framework/common/src/org/ofbiz/common/geo/GeoWorker.java ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LdapAuthenticationServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusWorker.java Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java Sun Jun 29 13:33:19 2008 @@ -49,7 +49,7 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map cdyneReturnCityState(DispatchContext dctx, Map context) { + public static Map<String, Object> cdyneReturnCityState(DispatchContext dctx, Map<String, ?> context) { String zipcode = (String) context.get("zipcode"); String serviceUrl = "http://ws.cdyne.com/psaddress/addresslookup.asmx/ReturnCityState?zipcode=" + zipcode + "&LicenseKey=" + licenseKey; @@ -59,7 +59,7 @@ Document addressDocument = UtilXml.readXmlDocument(httpResponse); Element addressRootElement = addressDocument.getDocumentElement(); - Map response = ServiceUtil.returnSuccess(); + Map<String, Object> response = ServiceUtil.returnSuccess(); populateCdyneAddress(addressRootElement, response); if ("true".equals(response.get("ServiceError"))) { @@ -89,7 +89,7 @@ } } - public static void populateCdyneAddress(Element addressRootElement, Map targetContext) { + public static void populateCdyneAddress(Element addressRootElement, Map<String, Object> targetContext) { targetContext.put("ServiceError", UtilXml.childElementValue(addressRootElement, "ServiceError")); targetContext.put("AddressError", UtilXml.childElementValue(addressRootElement, "AddressError")); targetContext.put("AddressFoundBeMoreSpecific", UtilXml.childElementValue(addressRootElement, "AddressFoundBeMoreSpecific")); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java Sun Jun 29 13:33:19 2008 @@ -28,6 +28,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilHttp; @@ -46,7 +48,7 @@ public static final String module = CommonEvents.class.getName(); - public static UtilCache appletSessions = new UtilCache("AppletSessions", 0, 600000, true); + public static UtilCache<String, Map<String, String>> appletSessions = new UtilCache<String, Map<String, String>>("AppletSessions", 0, 600000, true); public static String checkAppletRequest(HttpServletRequest request, HttpServletResponse response) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); @@ -65,9 +67,9 @@ } if (visit != null && visit.getString("sessionId").equals(sessionId) && appletSessions.containsKey(sessionId)) { - Map sessionMap = (Map) appletSessions.get(sessionId); + Map<String, String> sessionMap = appletSessions.get(sessionId); if (sessionMap != null && sessionMap.containsKey("followPage")) - responseString = (String) sessionMap.remove("followPage"); + responseString = sessionMap.remove("followPage"); } try { @@ -101,13 +103,11 @@ if (visit.getString("sessionId").equals(sessionId)) { String currentPage = request.getParameter("currentPage"); if (appletSessions.containsKey(sessionId)) { - Map sessionMap = (Map) appletSessions.get(sessionId); - String followers = (String) sessionMap.get("followers"); - List folList = StringUtil.split(followers, ","); - Iterator i = folList.iterator(); - while (i.hasNext()) { - String follower = (String) i.next(); - Map folSesMap = UtilMisc.toMap("followPage", currentPage); + Map<String, String> sessionMap = appletSessions.get(sessionId); + String followers = sessionMap.get("followers"); + List<String> folList = StringUtil.split(followers, ","); + for (String follower: folList) { + Map<String, String> folSesMap = UtilMisc.toMap("followPage", currentPage); appletSessions.put(follower, folSesMap); } } @@ -134,8 +134,8 @@ if (security.hasPermission("SEND_CONTROL_APPLET", userLogin)) { String followerSessionId = request.getParameter("followerSid"); String followSessionId = request.getParameter("followSid"); - Map follow = (Map) appletSessions.get(followSessionId); - if (follow == null) follow = new HashMap(); + Map<String, String> follow = appletSessions.get(followSessionId); + if (follow == null) follow = FastMap.newInstance(); String followerListStr = (String) follow.get("followers"); if (followerListStr == null) { followerListStr = followerSessionId; @@ -156,8 +156,8 @@ if (security.hasPermission("SEND_CONTROL_APPLET", userLogin)) { String followerSessionId = request.getParameter("followerSid"); String pageUrl = request.getParameter("pageUrl"); - Map follow = (Map) appletSessions.get(followerSessionId); - if (follow == null) follow = new HashMap(); + Map<String, String> follow = appletSessions.get(followerSessionId); + if (follow == null) follow = FastMap.newInstance(); follow.put("followPage", pageUrl); appletSessions.put(followerSessionId, follow); } Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java Sun Jun 29 13:33:19 2008 @@ -26,10 +26,14 @@ import javax.mail.internet.MimeMessage; import javax.transaction.xa.XAException; +import javolution.util.FastMap; + import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; +import static org.ofbiz.base.util.UtilGenerics.checkList; +import static org.ofbiz.base.util.UtilGenerics.checkMap; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; @@ -57,15 +61,13 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map testService(DispatchContext dctx, Map context) { - Map response = ServiceUtil.returnSuccess(); + public static Map<String, Object> testService(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> response = ServiceUtil.returnSuccess(); if (context.size() > 0) { - Iterator i = context.keySet().iterator(); - - while (i.hasNext()) { - Object cKey = i.next(); - Object value = context.get(cKey); + for (Map.Entry<String, ?> entry: context.entrySet()) { + Object cKey = entry.getKey(); + Object value = entry.getValue(); System.out.println("---- SVC-CONTEXT: " + cKey + " => " + value); } @@ -81,7 +83,7 @@ return response; } - public static Map blockingTestService(DispatchContext dctx, Map context) { + public static Map<String, Object> blockingTestService(DispatchContext dctx, Map<String, ?> context) { System.out.println("-----SERVICE BLOCKING----- : 30 seconds"); try { Thread.sleep(30000); @@ -90,13 +92,13 @@ return CommonServices.testService(dctx, context); } - public static Map testWorkflowCondition(DispatchContext dctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> testWorkflowCondition(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> result = FastMap.newInstance(); result.put("evaluationResult", Boolean.TRUE); return result; } - public static Map testRollbackListener(DispatchContext dctx, Map context) { + public static Map<String, Object> testRollbackListener(DispatchContext dctx, Map<String, ?> context) { ServiceXaWrapper xar = new ServiceXaWrapper(dctx); xar.setRollbackService("testScv", context); try { @@ -107,7 +109,7 @@ return ServiceUtil.returnError("Rolling back!"); } - public static Map testCommitListener(DispatchContext dctx, Map context) { + public static Map<String, Object> testCommitListener(DispatchContext dctx, Map<String, ?> context) { ServiceXaWrapper xar = new ServiceXaWrapper(dctx); xar.setCommitService("testScv", context); try { @@ -124,7 +126,7 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map createNote(DispatchContext ctx, Map context) { + public static Map<String, Object> createNote(DispatchContext ctx, Map<String, ?> context) { GenericDelegator delegator = ctx.getDelegator(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Timestamp noteDate = (Timestamp) context.get("noteDate"); @@ -143,7 +145,7 @@ partyId = userLogin.getString("partyId"); } - Map fields = UtilMisc.toMap("noteId", noteId, "noteName", noteName, "noteInfo", note, + Map<String, String> fields = UtilMisc.toMap("noteId", noteId, "noteName", noteName, "noteInfo", note, "noteParty", partyId, "noteDateTime", noteDate); try { @@ -153,7 +155,7 @@ } catch (GenericEntityException e) { return ServiceUtil.returnError("Could update note data (write failure): " + e.getMessage()); } - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("noteId", noteId); return result; @@ -165,7 +167,7 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map adjustDebugLevels(DispatchContext dctc, Map context) { + public static Map<String, Object> adjustDebugLevels(DispatchContext dctc, Map<String, ?> context) { Debug.set(Debug.FATAL, "Y".equalsIgnoreCase((String) context.get("fatal"))); Debug.set(Debug.ERROR, "Y".equalsIgnoreCase((String) context.get("error"))); Debug.set(Debug.WARNING, "Y".equalsIgnoreCase((String) context.get("warning"))); @@ -177,7 +179,7 @@ return ServiceUtil.returnSuccess(); } - public static Map addOrUpdateLogger(DispatchContext dctc, Map context) { + public static Map<String, Object> addOrUpdateLogger(DispatchContext dctc, Map<String, ?> context) { String name = (String) context.get("name"); String level = (String) context.get("level"); boolean additivity = "Y".equalsIgnoreCase((String) context.get("additivity")); @@ -194,7 +196,7 @@ return ServiceUtil.returnSuccess(); } - public static Map forceGc(DispatchContext dctx, Map context) { + public static Map<String, Object> forceGc(DispatchContext dctx, Map<String, ?> context) { System.gc(); return ServiceUtil.returnSuccess(); } @@ -203,23 +205,25 @@ * Echo service; returns exactly what was sent. * This service does not have required parameters and does not validate */ - public static Map echoService(DispatchContext dctx, Map context) { - context.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); - return context; + public static Map<String, Object> echoService(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> result = FastMap.newInstance(); + result.putAll(context); + result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); + return result; } /** * Return Error Service; Used for testing error handling */ - public static Map returnErrorService(DispatchContext dctx, Map context) { + public static Map<String, Object> returnErrorService(DispatchContext dctx, Map<String, ?> context) { return ServiceUtil.returnError("Return Error Service : Returning Error"); } /** * Return TRUE Service; ECA Condition Service */ - public static Map conditionTrueService(DispatchContext dctx, Map context) { - Map result = ServiceUtil.returnSuccess(); + public static Map<String, Object> conditionTrueService(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("conditionReply", Boolean.TRUE); return result; } @@ -227,14 +231,14 @@ /** * Return FALSE Service; ECA Condition Service */ - public static Map conditionFalseService(DispatchContext dctx, Map context) { - Map result = ServiceUtil.returnSuccess(); + public static Map<String, Object> conditionFalseService(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("conditionReply", Boolean.FALSE); return result; } /** Cause a Referential Integrity Error */ - public static Map entityFailTest(DispatchContext dctx, Map context) { + public static Map<String, Object> entityFailTest(DispatchContext dctx, Map<String, ?> context) { GenericDelegator delegator = dctx.getDelegator(); // attempt to create a DataSource entity w/ an invalid dataSourceTypeId @@ -261,9 +265,9 @@ } /** Test entity sorting */ - public static Map entitySortTest(DispatchContext dctx, Map context) { + public static Map<String, Object> entitySortTest(DispatchContext dctx, Map<String, ?> context) { GenericDelegator delegator = dctx.getDelegator(); - Set set = new TreeSet(); + Set<ModelEntity> set = new TreeSet<ModelEntity>(); set.add(delegator.getModelEntity("Person")); set.add(delegator.getModelEntity("PartyRole")); @@ -277,14 +281,13 @@ set.add(delegator.getModelEntity("Product")); set.add(delegator.getModelEntity("RoleType")); - Iterator i = set.iterator(); - while (i.hasNext()) { - Debug.log(((ModelEntity)i.next()).getEntityName(), module); + for (ModelEntity modelEntity: set) { + Debug.log(modelEntity.getEntityName(), module); } return ServiceUtil.returnSuccess(); } - public static Map makeALotOfVisits(DispatchContext dctx, Map context) { + public static Map<String, Object> makeALotOfVisits(DispatchContext dctx, Map<String, ?> context) { GenericDelegator delegator = dctx.getDelegator(); int count = ((Integer) context.get("count")).intValue(); @@ -316,7 +319,7 @@ return ServiceUtil.returnSuccess(); } - public static Map displayXaDebugInfo(DispatchContext dctx, Map context) { + public static Map<String, Object> displayXaDebugInfo(DispatchContext dctx, Map<String, ?> context) { if (TransactionUtil.debugResources) { if (TransactionUtil.debugResMap != null && TransactionUtil.debugResMap.size() > 0) { TransactionUtil.logRunningTx(); @@ -330,7 +333,7 @@ return ServiceUtil.returnSuccess(); } - public static Map byteBufferTest(DispatchContext dctx, Map context) { + public static Map<String, Object> byteBufferTest(DispatchContext dctx, Map<String, ?> context) { ByteBuffer buffer1 = (ByteBuffer) context.get("byteBuffer1"); ByteBuffer buffer2 = (ByteBuffer) context.get("byteBuffer2"); String fileName1 = (String) context.get("saveAsFileName1"); @@ -353,7 +356,7 @@ return ServiceUtil.returnSuccess(); } - public static Map uploadTest(DispatchContext dctx, Map context) { + public static Map<String, Object> uploadTest(DispatchContext dctx, Map<String, ?> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -361,7 +364,7 @@ String fileName = (String) context.get("_uploadFile_fileName"); String contentType = (String) context.get("_uploadFile_contentType"); - Map createCtx = new HashMap(); + Map<String, Object> createCtx = FastMap.newInstance(); createCtx.put("binData", array); createCtx.put("dataResourceTypeId", "OFBIZ_FILE"); createCtx.put("dataResourceName", fileName); @@ -370,7 +373,7 @@ createCtx.put("mimeTypeId", contentType); createCtx.put("userLogin", userLogin); - Map createResp = null; + Map<String, Object> createResp = null; try { createResp = dispatcher.runSync("createFile", createCtx); } catch (GenericServiceException e) { @@ -383,7 +386,7 @@ GenericValue dataResource = (GenericValue) createResp.get("dataResource"); if (dataResource != null) { - Map contentCtx = new HashMap(); + Map<String, Object> contentCtx = FastMap.newInstance(); contentCtx.put("dataResourceId", dataResource.getString("dataResourceId")); contentCtx.put("localeString", ((Locale) context.get("locale")).toString()); contentCtx.put("contentTypeId", "DOCUMENT"); @@ -392,7 +395,7 @@ contentCtx.put("statusId", "CTNT_PUBLISHED"); contentCtx.put("userLogin", userLogin); - Map contentResp = null; + Map<String, Object> contentResp = null; try { contentResp = dispatcher.runSync("createContent", contentCtx); } catch (GenericServiceException e) { @@ -407,13 +410,11 @@ return ServiceUtil.returnSuccess(); } - public static Map simpleMapListTest(DispatchContext dctx, Map context) { - List listOfStrings = (List) context.get("listOfStrings"); - Map mapOfStrings = (Map) context.get("mapOfStrings"); - - Iterator i = listOfStrings.iterator(); - while (i.hasNext()) { - String str = (String) i.next(); + public static Map<String, Object> simpleMapListTest(DispatchContext dctx, Map<String, ?> context) { + List<String> listOfStrings = checkList(context.get("listOfStrings"), String.class); + Map<String, String> mapOfStrings = checkMap(context.get("mapOfStrings"), String.class, String.class); + + for (String str: listOfStrings) { String v = (String) mapOfStrings.get(str); Debug.log("SimpleMapListTest: " + str + " -> " + v, module); } @@ -421,7 +422,7 @@ return ServiceUtil.returnSuccess(); } - public static Map mcaTest(DispatchContext dctx, Map context) { + public static Map<String, Object> mcaTest(DispatchContext dctx, Map<String, ?> context) { MimeMessageWrapper wrapper = (MimeMessageWrapper) context.get("messageWrapper"); MimeMessage message = wrapper.getMessage(); try { @@ -444,7 +445,7 @@ return ServiceUtil.returnSuccess(); } - public static Map streamTest(DispatchContext dctx, Map context) { + public static Map<String, Object> streamTest(DispatchContext dctx, Map<String, ?> context) { InputStream in = (InputStream) context.get("inputStream"); OutputStream out = (OutputStream) context.get("outputStream"); @@ -468,12 +469,12 @@ } } - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("contentType", "text/plain"); return result; } - public static Map ping(DispatchContext dctx, Map context) { + public static Map<String, Object> ping(DispatchContext dctx, Map<String, ?> context) { GenericDelegator delegator = dctx.getDelegator(); String message = (String) context.get("message"); if (message == null) { @@ -489,7 +490,7 @@ } if (count > 0) { - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("message", message); return result; } else { Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Sun Jun 29 13:33:19 2008 @@ -41,8 +41,8 @@ public final static String module = CommonWorkers.class.getName(); - public static List getCountryList(GenericDelegator delegator) { - List geoList = FastList.newInstance(); + public static List<GenericValue> getCountryList(GenericDelegator delegator) { + List<GenericValue> geoList = FastList.newInstance(); String defaultCountry = UtilProperties.getPropertyValue("general.properties", "country.geo.id.default"); GenericValue defaultGeo = null; if (defaultCountry != null && defaultCountry.length() > 0) { @@ -53,7 +53,7 @@ } } try { - List countryGeoList = delegator.findByAndCache("Geo", UtilMisc.toMap("geoTypeId", "COUNTRY"), UtilMisc.toList("geoName")); + List<GenericValue> countryGeoList = delegator.findByAndCache("Geo", UtilMisc.toMap("geoTypeId", "COUNTRY"), UtilMisc.toList("geoName")); if (defaultGeo != null) { geoList.add(defaultGeo); geoList.addAll(countryGeoList); @@ -66,8 +66,8 @@ return geoList; } - public static List getStateList(GenericDelegator delegator) { - List geoList = FastList.newInstance(); + public static List<GenericValue> getStateList(GenericDelegator delegator) { + List<GenericValue> geoList = FastList.newInstance(); EntityCondition condition = EntityCondition.makeCondition(EntityOperator.OR, EntityCondition.makeCondition("geoTypeId", "STATE"), EntityCondition.makeCondition("geoTypeId", "PROVINCE"), EntityCondition.makeCondition("geoTypeId", "TERRITORY")); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java Sun Jun 29 13:33:19 2008 @@ -25,11 +25,15 @@ import java.util.List; import java.util.Map; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilHttp; +import static org.ofbiz.base.util.UtilGenerics.checkList; +import static org.ofbiz.base.util.UtilGenerics.checkMap; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; @@ -59,10 +63,10 @@ public static final String module = FindServices.class.getName(); - public static HashMap entityOperators; + public static HashMap<String, EntityOperator> entityOperators; static { - entityOperators = new HashMap(); + entityOperators = new HashMap<String, EntityOperator>(); entityOperators.put("and", EntityOperator.AND); entityOperators.put("between", EntityOperator.BETWEEN); entityOperators.put("equals", EntityOperator.EQUALS); @@ -87,7 +91,7 @@ * @param inputFields Input parameters run thru UtilHttp.getParameterMap * @return a map with field name and operator */ - public static HashMap prepareField(Map inputFields, Map queryStringMap, Map origValueMap) { + public static HashMap<String, HashMap<String, HashMap<String, Object>>> prepareField(Map<String, ?> inputFields, Map<String, Object> queryStringMap, Map<String, List<Object[]>> origValueMap) { // Strip the "_suffix" off of the parameter name and // build a three-level map of values keyed by fieldRoot name, // fld0 or fld1, and, then, "op" or "value" @@ -102,11 +106,9 @@ // Note that "normalizedFields" will contain values other than those // Contained in the associated entity. // Those extra fields will be ignored in the second half of this method. - HashMap normalizedFields = new HashMap(); - Iterator ifIter = inputFields.keySet().iterator(); + HashMap<String, HashMap<String, HashMap<String, Object>>> normalizedFields = new HashMap<String, HashMap<String, HashMap<String, Object>>>(); //StringBuffer queryStringBuf = new StringBuffer(); - while (ifIter.hasNext()) { - String fieldNameRaw = null; // The name as it appeas in the HTML form + for (String fieldNameRaw: inputFields.keySet()) { // The name as it appeas in the HTML form String fieldNameRoot = null; // The entity field name. Everything to the left of the first "_" if // it exists, or the whole word, if not. String fieldPair = null; // "fld0" or "fld1" - begin/end of range or just fld0 if no range. @@ -114,11 +116,10 @@ // If it is an "op" field, it will be "equals", "greaterThan", etc. int iPos = -1; int iPos2 = -1; - HashMap subMap = null; - HashMap subMap2 = null; + HashMap<String, HashMap<String, Object>> subMap = null; + HashMap<String, Object> subMap2 = null; String fieldMode = null; - fieldNameRaw = (String) ifIter.next(); fieldValue = inputFields.get(fieldNameRaw); if (ObjectType.isEmpty(fieldValue)) { continue; @@ -175,21 +176,21 @@ } } } - subMap = (HashMap) normalizedFields.get(fieldNameRoot); + subMap = normalizedFields.get(fieldNameRoot); if (subMap == null) { - subMap = new HashMap(); + subMap = new HashMap<String, HashMap<String, Object>>(); normalizedFields.put(fieldNameRoot, subMap); } - subMap2 = (HashMap) subMap.get(fieldPair); + subMap2 = subMap.get(fieldPair); if (subMap2 == null) { - subMap2 = new HashMap(); + subMap2 = new HashMap<String, Object>(); subMap.put(fieldPair, subMap2); } subMap2.put(fieldMode, fieldValue); - List origList = (List) origValueMap.get(fieldNameRoot); + List<Object[]> origList = origValueMap.get(fieldNameRoot); if (origList == null) { - origList = new ArrayList(); + origList = new ArrayList<Object[]>(); origValueMap.put(fieldNameRoot, origList); } Object [] origValues = {fieldNameRaw, fieldValue}; @@ -207,27 +208,24 @@ * @param normalizedFields list of field the user have populated * @return a arrayList usable to create an entityCondition */ - public static ArrayList createCondition(List keys, HashMap normalizedFields, Map queryStringMap, Map origValueMap) { - String fieldName = null; - HashMap subMap = null; - HashMap subMap2 = null; + public static ArrayList<EntityCondition> createCondition(List<String> keys, HashMap<String, HashMap<String, HashMap<String, Object>>> normalizedFields, Map<String, Object> queryStringMap, Map<String, List<Object[]>> origValueMap) { + HashMap<String, HashMap<String, Object>> subMap = null; + HashMap<String, Object> subMap2 = null; EntityOperator fieldOp = null; String fieldValue = null; // If it is a "value" field, it will be the value to be used in the query. // If it is an "op" field, it will be "equals", "greaterThan", etc. - Iterator iter = keys.iterator(); EntityExpr cond = null; - ArrayList tmpList = new ArrayList(); + ArrayList<EntityCondition> tmpList = new ArrayList<EntityCondition>(); String opString = null; String ignoreCase = null; int count = 0; - while (iter.hasNext()) { - fieldName = (String) iter.next(); - subMap = (HashMap) normalizedFields.get(fieldName); + for (String fieldName: keys) { + subMap = normalizedFields.get(fieldName); if (subMap == null) { continue; } - subMap2 = (HashMap) subMap.get("fld0"); + subMap2 = subMap.get("fld0"); opString = (String) subMap2.get("op"); ignoreCase = (String) subMap2.get("ic"); @@ -237,7 +235,7 @@ } else if (opString.equals("empty")) { fieldOp = EntityOperator.EQUALS; } else { - fieldOp = (EntityOperator) entityOperators.get(opString); + fieldOp = entityOperators.get(opString); } } else { fieldOp = EntityOperator.EQUALS; @@ -269,16 +267,16 @@ fieldOp = EntityOperator.GREATER_THAN_EQUAL_TO; ignoreCase = null; // Set up so next part finds ending conditions for same day - subMap2 = (HashMap) subMap.get("fld1"); + subMap2 = subMap.get("fld1"); if (subMap2 == null) { - subMap2 = new HashMap(); + subMap2 = new HashMap<String, Object>(); subMap.put("fld1", subMap2); } String endOfDay = dayStart(timeStampString, 1); subMap2.put("value", endOfDay); subMap2.put("op", "lessThan"); } else { - fieldOp = (EntityOperator) entityOperators.get(opString); + fieldOp = entityOperators.get(opString); } } else { fieldOp = EntityOperator.EQUALS; @@ -293,7 +291,7 @@ count++; // Repeat above operations if there is a "range" - second value - subMap2 = (HashMap) subMap.get("fld1"); + subMap2 = subMap.get("fld1"); if (subMap2 == null) { continue; } @@ -305,7 +303,7 @@ } else if (opString.equals("empty")) { fieldOp = EntityOperator.EQUALS; } else { - fieldOp = (EntityOperator) entityOperators.get(opString); + fieldOp = entityOperators.get(opString); } } else { fieldOp = EntityOperator.EQUALS; @@ -334,12 +332,10 @@ tmpList.add(cond); // add to queryStringMap - List origList = (List)origValueMap.get(fieldName); + List<Object[]> origList = origValueMap.get(fieldName); if (origList != null && origList.size() > 0) { - Iterator origIter = origList.iterator(); - while (origIter.hasNext()) { - Object [] arr = (Object [])origIter.next(); - queryStringMap.put(arr[0], arr[1]); + for (Object[] arr: origList) { + queryStringMap.put((String) arr[0], arr[1]); } } } @@ -358,22 +354,22 @@ * @param context * @return Map */ - public static Map performFindList(DispatchContext dctx, Map context) { - Map result = performFind(dctx,context); + public static Map<String, Object> performFindList(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> result = performFind(dctx,context); Integer viewSize = (Integer) context.get("viewSize"); - if (viewSize == null) viewSize = new Integer(20); // default + if (viewSize == null) viewSize = Integer.valueOf(20); // default Integer viewIndex = (Integer) context.get("viewIndex"); - if (viewIndex == null) viewIndex = new Integer(0); // default + if (viewIndex == null) viewIndex = Integer.valueOf(0); // default int start = viewIndex.intValue() * viewSize.intValue(); - List list = null; + List<GenericValue> list = null; Integer listSize = null; try{ EntityListIterator it = (EntityListIterator) result.get("listIt"); list = it.getPartialList(start+1, viewSize.intValue()); // list starts at '1' it.last(); - listSize = new Integer(it.currentIndex()); + listSize = Integer.valueOf(it.currentIndex()); it.close(); } catch (Exception e) { Debug.logInfo("Problem getting partial list" + e,module); @@ -391,10 +387,10 @@ * This is a generic method that expects entity data affixed with special suffixes * to indicate their purpose in formulating an SQL query statement. */ - public static Map performFind(DispatchContext dctx, Map context) { + public static Map<String, Object> performFind(DispatchContext dctx, Map<String, ?> context) { String entityName = (String) context.get("entityName"); String orderBy = (String) context.get("orderBy"); - Map inputFields = (Map) context.get("inputFields"); // Input + Map<String, ?> inputFields = checkMap(context.get("inputFields"), String.class, Object.class); // Input String noConditionFind = (String) context.get("noConditionFind"); GenericValue userLogin = (GenericValue) context.get("userLogin"); if (UtilValidate.isEmpty(noConditionFind)) { @@ -414,16 +410,16 @@ LocalDispatcher dispatcher = dctx.getDispatcher(); - Map prepareResult = null; + Map<String, Object> prepareResult = null; try { prepareResult = dispatcher.runSync("prepareFind", UtilMisc.toMap("entityName", entityName, "orderBy", orderBy, "inputFields", inputFields, "filterByDate", filterByDate,"filterByDateValue", filterByDateValue, "userLogin", userLogin)); } catch (GenericServiceException gse) { return ServiceUtil.returnError("Error preparing conditions: " + gse.getMessage()); } EntityConditionList exprList = (EntityConditionList)prepareResult.get("entityConditionList"); - List orderByList = (List)prepareResult.get("orderByList"); + List<String> orderByList = checkList(prepareResult.get("orderByList"), String.class); - Map executeResult = null; + Map<String, Object> executeResult = null; try { executeResult = dispatcher.runSync("executeFind", UtilMisc.toMap("entityName", entityName, "orderByList", orderByList, "entityConditionList", exprList, "noConditionFind", noConditionFind)); } catch (GenericServiceException gse) { @@ -434,7 +430,7 @@ Debug.logInfo("No list iterator found for query string + [" + prepareResult.get("queryString") + "]", module); } - Map results = ServiceUtil.returnSuccess(); + Map<String, Object> results = ServiceUtil.returnSuccess(); results.put("listIt", executeResult.get("listIt")); results.put("queryString", prepareResult.get("queryString")); results.put("queryStringMap", prepareResult.get("queryStringMap")); @@ -447,10 +443,10 @@ * This is a generic method that expects entity data affixed with special suffixes * to indicate their purpose in formulating an SQL query statement. */ - public static Map prepareFind(DispatchContext dctx, Map context) { + public static Map prepareFind(DispatchContext dctx, Map<String, ?> context) { String entityName = (String) context.get("entityName"); String orderBy = (String) context.get("orderBy"); - Map inputFields = (Map) context.get("inputFields"); // Input + Map<String, ?> inputFields = checkMap(context.get("inputFields"), String.class, Object.class); // Input String noConditionFind = (String) context.get("noConditionFind"); if (UtilValidate.isEmpty(noConditionFind)) { // try finding in inputFields Map @@ -468,19 +464,19 @@ Timestamp filterByDateValue = (Timestamp) context.get("filterByDateValue"); // parameters run thru UtilHttp.getParameterMap - Map queryStringMap = new HashMap(); - Map origValueMap = new HashMap(); - HashMap normalizedFields = prepareField(inputFields, queryStringMap, origValueMap); + Map<String, Object> queryStringMap = FastMap.newInstance(); + Map<String, List<Object[]>> origValueMap = FastMap.newInstance(); + HashMap<String, HashMap<String, HashMap<String, Object>>> normalizedFields = prepareField(inputFields, queryStringMap, origValueMap); // Now use only the values that correspond to entity fields to build // an EntityConditionList GenericDelegator delegator = dctx.getDelegator(); - GenericValue entityValue = delegator.makeValue(entityName, new HashMap()); + GenericValue entityValue = delegator.makeValue(entityName, FastMap.newInstance()); ModelEntity modelEntity = entityValue.getModelEntity(); - List keys = modelEntity.getAllFieldNames(); - ArrayList tmpList = createCondition(keys, normalizedFields, queryStringMap, origValueMap); + List<String> keys = modelEntity.getAllFieldNames(); + ArrayList<EntityCondition> tmpList = createCondition(keys, normalizedFields, queryStringMap, origValueMap); /* the filter by date condition should only be added when there are other conditions or when * the user has specified a noConditionFind. Otherwise, specifying filterByDate will become @@ -503,13 +499,13 @@ exprList = EntityCondition.makeCondition(tmpList); } - List orderByList = null; + List<String> orderByList = null; if (UtilValidate.isNotEmpty(orderBy)) { orderByList = StringUtil.split(orderBy,"|"); } - Map results = ServiceUtil.returnSuccess(); - Map reducedQueryStringMap = buildReducedQueryString(inputFields, entityName, delegator); + Map<String, Object> results = ServiceUtil.returnSuccess(); + Map<String, Object> reducedQueryStringMap = buildReducedQueryString(inputFields, entityName, delegator); reducedQueryStringMap.put("noConditionFind", noConditionFind); reducedQueryStringMap.put("filterByDate", filterByDate); reducedQueryStringMap.put("filterByDateValue", filterByDateValue); @@ -527,10 +523,10 @@ * * This is a generic method that returns an EntityListIterator. */ - public static Map executeFind(DispatchContext dctx, Map context) { + public static Map<String, Object> executeFind(DispatchContext dctx, Map<String, ?> context) { String entityName = (String) context.get("entityName"); EntityConditionList entityConditionList = (EntityConditionList) context.get("entityConditionList"); - List orderByList = (List) context.get("orderByList"); + List<String> orderByList = checkList(context.get("orderByList"), String.class); boolean noConditionFind = "Y".equals((String) context.get("noConditionFind")); GenericDelegator delegator = dctx.getDelegator(); @@ -546,7 +542,7 @@ return ServiceUtil.returnError("Error running Find on the [" + entityName + "] entity: " + e.getMessage()); } - Map results = ServiceUtil.returnSuccess(); + Map<String, Object> results = ServiceUtil.returnSuccess(); results.put("listIt", listIt); return results; } @@ -570,7 +566,7 @@ return retValue; } - public static HashMap buildReducedQueryString(Map inputFields, String entityName, GenericDelegator delegator) { + public static HashMap<String, Object> buildReducedQueryString(Map<String, ?> inputFields, String entityName, GenericDelegator delegator) { // Strip the "_suffix" off of the parameter name and // build a three-level map of values keyed by fieldRoot name, // fld0 or fld1, and, then, "op" or "value" @@ -586,11 +582,9 @@ // Contained in the associated entity. // Those extra fields will be ignored in the second half of this method. ModelEntity modelEntity = delegator.getModelEntity(entityName); - HashMap normalizedFields = new HashMap(); - Iterator ifIter = inputFields.keySet().iterator(); + HashMap<String, Object> normalizedFields = new HashMap<String, Object>(); //StringBuffer queryStringBuf = new StringBuffer(); - while (ifIter.hasNext()) { - String fieldNameRaw = null; // The name as it appeas in the HTML form + for (String fieldNameRaw: inputFields.keySet()) { // The name as it appeas in the HTML form String fieldNameRoot = null; // The entity field name. Everything to the left of the first "_" if // it exists, or the whole word, if not. String fieldPair = null; // "fld0" or "fld1" - begin/end of range or just fld0 if no range. @@ -600,7 +594,6 @@ int iPos2 = -1; String fieldMode = null; - fieldNameRaw = (String) ifIter.next(); fieldValue = inputFields.get(fieldNameRaw); if (ObjectType.isEmpty(fieldValue)) { continue; @@ -644,16 +637,16 @@ * @param context * @return */ - public static Map performFindItem(DispatchContext dctx, Map context) { - Map result = org.ofbiz.common.FindServices.performFind(dctx,context); + public static Map<String, Object> performFindItem(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> result = org.ofbiz.common.FindServices.performFind(dctx,context); - List list = null; + List<GenericValue> list = null; GenericValue item= null; try{ EntityListIterator it = (EntityListIterator) result.get("listIt"); list = it.getPartialList(1, 1); // list starts at '1' if (list != null && list.size() > 0 ) { - item = (GenericValue) list.get(0); + item = list.get(0); } it.close(); } catch (Exception e) { Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java Sun Jun 29 13:33:19 2008 @@ -23,12 +23,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; +import javolution.util.FastList; + import org.ofbiz.base.util.Debug; +import static org.ofbiz.base.util.UtilGenerics.checkList; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.ServiceUtil; @@ -44,7 +45,7 @@ public final static String module = FtpServices.class.getName(); - public static Map putFile(DispatchContext dctx, Map context) { + public static Map<String, Object> putFile(DispatchContext dctx, Map<String, ?> context) { Debug.logInfo("[putFile] starting...", module); InputStream localFile = null; @@ -55,7 +56,7 @@ return ServiceUtil.returnError("ERROR: Could not open local file"); } - List errorList = new ArrayList(); + List<String> errorList = FastList.newInstance(); FTPClient ftp = new FTPClient(); try { @@ -86,11 +87,9 @@ errorList.add("File not sent succesfully: " + ftp.getReplyString()); } else { Debug.logInfo("[putFile] store was successful", module); - List siteCommands = (List) context.get("siteCommands"); + List<String> siteCommands = checkList(context.get("siteCommands"), String.class); if (siteCommands != null) { - Iterator ci = siteCommands.iterator(); - while (ci.hasNext()) { - String command = (String) ci.next(); + for (String command: siteCommands) { Debug.logInfo("[putFile] sending SITE command: " + command, module); if (!ftp.sendSiteCommand(command)) { errorList.add("SITE command (" + command + ") failed: " + ftp.getReplyString()); @@ -130,7 +129,7 @@ return ServiceUtil.returnSuccess(); } - public static Map getFile(DispatchContext dctx, Map context) { + public static Map<String, Object> getFile(DispatchContext dctx, Map<String, ?> context) { String localFilename = (String) context.get("localFilename"); @@ -142,7 +141,7 @@ return ServiceUtil.returnError("ERROR: Could not open local file"); } - List errorList = new ArrayList(); + List<String> errorList = FastList.newInstance(); FTPClient ftp = new FTPClient(); try { Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java Sun Jun 29 13:33:19 2008 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.common; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -27,6 +26,7 @@ import java.util.StringTokenizer; import java.util.TreeSet; +import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; @@ -42,8 +42,8 @@ public static final String module = KeywordSearchUtil.class.getName(); - public static Set thesaurusRelsToInclude = new HashSet(); - public static Set thesaurusRelsForReplace = new HashSet(); + public static Set<String> thesaurusRelsToInclude = new HashSet<String>(); + public static Set<String> thesaurusRelsForReplace = new HashSet<String>(); static { thesaurusRelsToInclude.add("KWTR_UF"); @@ -74,9 +74,9 @@ String removeStemsStr = UtilProperties.getPropertyValue("keywordsearch", "remove.stems"); return "true".equals(removeStemsStr); } - public static Set getStemSet() { + public static Set<String> getStemSet() { String stemBag = UtilProperties.getPropertyValue("keywordsearch", "stem.bag"); - Set stemSet = new TreeSet(); + Set<String> stemSet = new TreeSet<String>(); if (UtilValidate.isNotEmpty(stemBag)) { String curToken; StringTokenizer tokenizer = new StringTokenizer(stemBag, ": "); @@ -88,34 +88,32 @@ return stemSet; } - public static void processForKeywords(String str, Map keywords, boolean forSearch, boolean anyPrefix, boolean anySuffix, boolean isAnd) { + public static void processForKeywords(String str, Map<String, Long> keywords, boolean forSearch, boolean anyPrefix, boolean anySuffix, boolean isAnd) { String separators = getSeparators(); String stopWordBagOr = getStopWordBagOr(); String stopWordBagAnd = getStopWordBagAnd(); boolean removeStems = getRemoveStems(); - Set stemSet = getStemSet(); + Set<String> stemSet = getStemSet(); processForKeywords(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet, forSearch, anyPrefix, anySuffix, isAnd); } - public static void processKeywordsForIndex(String str, Map keywords, String separators, String stopWordBagAnd, String stopWordBagOr, boolean removeStems, Set stemSet) { + public static void processKeywordsForIndex(String str, Map<String, Long> keywords, String separators, String stopWordBagAnd, String stopWordBagOr, boolean removeStems, Set<String> stemSet) { processForKeywords(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet, false, false, false, false); } - public static void processForKeywords(String str, Map keywords, String separators, String stopWordBagAnd, String stopWordBagOr, boolean removeStems, Set stemSet, boolean forSearch, boolean anyPrefix, boolean anySuffix, boolean isAnd) { - Set keywordSet = makeKeywordSet(str, separators, forSearch); + public static void processForKeywords(String str, Map<String, Long> keywords, String separators, String stopWordBagAnd, String stopWordBagOr, boolean removeStems, Set<String> stemSet, boolean forSearch, boolean anyPrefix, boolean anySuffix, boolean isAnd) { + Set<String> keywordSet = makeKeywordSet(str, separators, forSearch); fixupKeywordSet(keywordSet, keywords, stopWordBagAnd, stopWordBagOr, removeStems, stemSet, forSearch, anyPrefix, anySuffix, isAnd); } - public static void fixupKeywordSet(Set keywordSet, Map keywords, String stopWordBagAnd, String stopWordBagOr, boolean removeStems, Set stemSet, boolean forSearch, boolean anyPrefix, boolean anySuffix, boolean isAnd) { + public static void fixupKeywordSet(Set<String> keywordSet, Map<String, Long> keywords, String stopWordBagAnd, String stopWordBagOr, boolean removeStems, Set<String> stemSet, boolean forSearch, boolean anyPrefix, boolean anySuffix, boolean isAnd) { if (keywordSet == null) { return; } - Iterator keywordIter = keywordSet.iterator(); - while (keywordIter.hasNext()) { - String token = (String) keywordIter.next(); + for (String token: keywordSet) { // when cleaning up the tokens the ordering is inportant: check stop words, remove stems, then get rid of 1 character tokens (1 digit okay) @@ -133,9 +131,7 @@ // remove stems if (removeStems) { - Iterator stemIter = stemSet.iterator(); - while (stemIter.hasNext()) { - String stem = (String) stemIter.next(); + for (String stem: stemSet) { if (token.endsWith(stem)) { token = token.substring(0, token.length() - stem.length()); } @@ -170,17 +166,17 @@ // group by word, add up weight Long curWeight = (Long) keywords.get(token); if (curWeight == null) { - keywords.put(token, new Long(1)); + keywords.put(token, Long.valueOf(1)); } else { - keywords.put(token, new Long(curWeight.longValue() + 1)); + keywords.put(token, Long.valueOf(curWeight.longValue() + 1)); } } } - public static Set makeKeywordSet(String str, String separators, boolean forSearch) { + public static Set<String> makeKeywordSet(String str, String separators, boolean forSearch) { if (separators == null) separators = getSeparators(); - Set keywords = new TreeSet(); + Set<String> keywords = new TreeSet<String>(); if (str.length() > 0) { // strip off weird characters str = str.replaceAll("\\\302\\\240|\\\240", " "); @@ -210,22 +206,20 @@ } } return keywords; - } - - public static Set fixKeywordsForSearch(Set keywordSet, boolean anyPrefix, boolean anySuffix, boolean removeStems, boolean isAnd) { - Map keywords = new HashMap(); +} + + public static Set<String> fixKeywordsForSearch(Set<String> keywordSet, boolean anyPrefix, boolean anySuffix, boolean removeStems, boolean isAnd) { + Map<String, Long> keywords = FastMap.newInstance(); fixupKeywordSet(keywordSet, keywords, getStopWordBagAnd(), getStopWordBagOr(), removeStems, getStemSet(), true, anyPrefix, anySuffix, isAnd); return keywords.keySet(); } - public static boolean expandKeywordForSearch(String enteredKeyword, Set addToSet, GenericDelegator delegator) { + public static boolean expandKeywordForSearch(String enteredKeyword, Set<String> addToSet, GenericDelegator delegator) { boolean replaceEnteredKeyword = false; try { - List thesaurusList = delegator.findByAndCache("KeywordThesaurus", UtilMisc.toMap("enteredKeyword", enteredKeyword)); - Iterator thesaurusIter = thesaurusList.iterator(); - while (thesaurusIter.hasNext()) { - GenericValue keywordThesaurus = (GenericValue) thesaurusIter.next(); + List<GenericValue> thesaurusList = delegator.findByAndCache("KeywordThesaurus", UtilMisc.toMap("enteredKeyword", enteredKeyword)); + for (GenericValue keywordThesaurus: thesaurusList) { String relationshipEnumId = (String) keywordThesaurus.get("relationshipEnumId"); if (thesaurusRelsToInclude.contains(relationshipEnumId)) { addToSet.addAll(makeKeywordSet(keywordThesaurus.getString("alternateKeyword"), null, true)); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/geo/GeoWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/geo/GeoWorker.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/geo/GeoWorker.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/geo/GeoWorker.java Sun Jun 29 13:33:19 2008 @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Set; +import javolution.util.FastList; import javolution.util.FastSet; /** @@ -39,7 +40,7 @@ public static final String module = GeoWorker.class.getName(); - public static List expandGeoGroup(String geoId, GenericDelegator delegator) { + public static List<GenericValue> expandGeoGroup(String geoId, GenericDelegator delegator) { GenericValue geo = null; try { geo = delegator.findByPrimaryKeyCache("Geo", UtilMisc.toMap("geoId", geoId)); @@ -49,9 +50,9 @@ return expandGeoGroup(geo); } - public static List expandGeoGroup(GenericValue geo) { + public static List<GenericValue> expandGeoGroup(GenericValue geo) { if (geo == null) { - return new ArrayList(); + return FastList.newInstance(); } if (!"GROUP".equals(geo.getString("geoTypeId"))) { return UtilMisc.toList(geo); @@ -59,17 +60,15 @@ //Debug.log("Expanding geo : " + geo, module); - List geoList = new LinkedList(); - List thisGeoAssoc = null; + List<GenericValue> geoList = FastList.newInstance(); + List<GenericValue> thisGeoAssoc = null; try { thisGeoAssoc = geo.getRelated("AssocGeoAssoc", UtilMisc.toMap("geoAssocTypeId", "GROUP_MEMBER"), null); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get associated Geo GROUP_MEMBER relationship(s)", module); } if (thisGeoAssoc != null && thisGeoAssoc.size() > 0) { - Iterator gi = thisGeoAssoc.iterator(); - while (gi.hasNext()) { - GenericValue nextGeoAssoc = (GenericValue) gi.next(); + for (GenericValue nextGeoAssoc: thisGeoAssoc) { GenericValue nextGeo = null; try { nextGeo = nextGeoAssoc.getRelatedOne("MainGeo"); @@ -87,29 +86,25 @@ return geoList; } - public static Set expandGeoRegionDeep(Set geoIdSet, GenericDelegator delegator) throws GenericEntityException { + public static Set<String> expandGeoRegionDeep(Set<String> geoIdSet, GenericDelegator delegator) throws GenericEntityException { if (geoIdSet == null || geoIdSet.size() == 0) { return geoIdSet; } - Set geoIdSetTemp = FastSet.newInstance(); - Iterator geoIdIter = geoIdSet.iterator(); - while (geoIdIter.hasNext()) { - String curGeoId = (String) geoIdIter.next(); - List geoAssocList = delegator.findByAndCache("GeoAssoc", UtilMisc.toMap("geoIdTo", curGeoId, "geoAssocTypeId", "REGIONS")); - Iterator geoAssocIter = geoAssocList.iterator(); - while (geoAssocIter.hasNext()) { - GenericValue geoAssoc = (GenericValue) geoAssocIter.next(); - geoIdSetTemp.add(geoAssoc.get("geoId")); + Set<String> geoIdSetTemp = FastSet.newInstance(); + for (String curGeoId: geoIdSet) { + List<GenericValue> geoAssocList = delegator.findByAndCache("GeoAssoc", UtilMisc.toMap("geoIdTo", curGeoId, "geoAssocTypeId", "REGIONS")); + for (GenericValue geoAssoc: geoAssocList) { + geoIdSetTemp.add(geoAssoc.getString("geoId")); } } geoIdSetTemp = expandGeoRegionDeep(geoIdSetTemp, delegator); - Set geoIdSetNew = FastSet.newInstance(); + Set<String> geoIdSetNew = FastSet.newInstance(); geoIdSetNew.addAll(geoIdSet); geoIdSetNew.addAll(geoIdSetTemp); return geoIdSetNew; } - public static boolean containsGeo(List geoList, String geoId, GenericDelegator delegator) { + public static boolean containsGeo(List<GenericValue> geoList, String geoId, GenericDelegator delegator) { GenericValue geo = null; try { geo = delegator.findByPrimaryKeyCache("Geo", UtilMisc.toMap("geoId", geoId)); @@ -119,7 +114,7 @@ return containsGeo(geoList, geo); } - public static boolean containsGeo(List geoList, GenericValue geo) { + public static boolean containsGeo(List<GenericValue> geoList, GenericValue geo) { if (geoList == null || geo == null) { return false; } Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LdapAuthenticationServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LdapAuthenticationServices.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LdapAuthenticationServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LdapAuthenticationServices.java Sun Jun 29 13:33:19 2008 @@ -45,7 +45,7 @@ public static final String module = LdapAuthenticationServices.class.getName(); - public static boolean userLogin(DispatchContext ctx, Map<String, Object> context) { + public static boolean userLogin(DispatchContext ctx, Map<String, ?> context) { Debug.logVerbose("Starting LDAP authentication", module); Properties env = UtilProperties.getProperties("jndiLdap"); String username = (String) context.get("login.username"); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java Sun Jun 29 13:33:19 2008 @@ -32,6 +32,7 @@ import org.ofbiz.base.crypto.HashCrypt; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; +import static org.ofbiz.base.util.UtilGenerics.checkMap; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; @@ -63,7 +64,7 @@ /** Login service to authenticate username and password * @return Map of results including (userLogin) GenericValue object */ - public static Map userLogin(DispatchContext ctx, Map context) { + public static Map<String, Object> userLogin(DispatchContext ctx, Map<String, ?> context) { Locale locale = (Locale) context.get("locale"); // Authenticate to LDAP if configured to do so @@ -78,7 +79,7 @@ } } - Map result = FastMap.newInstance(); + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security.properties", "password.encrypt")); @@ -187,7 +188,7 @@ // reset failed login count if necessry Long currentFailedLogins = userLogin.getLong("successiveFailedLogins"); if (currentFailedLogins != null && currentFailedLogins.longValue() > 0) { - userLogin.set("successiveFailedLogins", new Long(0)); + userLogin.set("successiveFailedLogins", Long.valueOf(0)); } else if (!hasLoggedOut) { // successful login & no loggout flag, no need to change anything, so don't do the store doStore = false; @@ -227,9 +228,9 @@ Long currentFailedLogins = userLogin.getLong("successiveFailedLogins"); if (currentFailedLogins == null) { - currentFailedLogins = new Long(1); + currentFailedLogins = Long.valueOf(1); } else { - currentFailedLogins = new Long(currentFailedLogins.longValue() + 1); + currentFailedLogins = Long.valueOf(currentFailedLogins.longValue() + 1); } userLogin.set("successiveFailedLogins", currentFailedLogins); @@ -280,7 +281,7 @@ } if (createHistory) { - Map ulhCreateMap = UtilMisc.toMap("userLoginId", username, "visitId", visitId, + Map<String, Object> ulhCreateMap = UtilMisc.toMap("userLoginId", username, "visitId", visitId, "fromDate", UtilDateTime.nowTimestamp(), "successfulLogin", successfulLogin); ModelEntity modelUserLogin = userLogin.getModelEntity(); @@ -340,17 +341,17 @@ continue; } - Map messageMap = UtilMisc.toMap("username", username); + Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("username", username); errMsg = UtilProperties.getMessage(resource,"loginservices.account_for_user_login_id_disabled",messageMap ,locale); if (disabledDateTime != null) { - messageMap = UtilMisc.toMap("disabledDateTime", disabledDateTime); + messageMap = UtilMisc.<String, Object>toMap("disabledDateTime", disabledDateTime); errMsg += UtilProperties.getMessage(resource,"loginservices.since_datetime",messageMap ,locale); } else { errMsg += "."; } if (loginDisableMinutes > 0 && reEnableTime != null) { - messageMap = UtilMisc.toMap("reEnableTime", reEnableTime); + messageMap = UtilMisc.<String, Object>toMap("reEnableTime", reEnableTime); errMsg += UtilProperties.getMessage(resource,"loginservices.will_be_reenabled",messageMap ,locale); } else { errMsg += UtilProperties.getMessage(resource,"loginservices.not_scheduled_to_be_reenabled",locale); @@ -390,7 +391,7 @@ EntityListIterator eli = delegator.find("UserLoginPasswordHistory", EntityCondition.makeCondition(exprs), null, null, UtilMisc.toList("-fromDate"), efo); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); GenericValue pwdHist; - if((pwdHist = (GenericValue) eli.next()) !=null){ + if((pwdHist = eli.next()) !=null){ // updating password so set end date on previous password in history pwdHist.set("thruDate", nowTimestamp); pwdHist.store(); @@ -399,7 +400,7 @@ int rowIndex = eli.currentIndex(); if(rowIndex==passwordChangeHistoryLimit){ eli.afterLast(); - pwdHist = (GenericValue) eli.previous(); + pwdHist = eli.previous(); pwdHist.remove(); } } @@ -415,12 +416,12 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map createUserLogin(DispatchContext ctx, Map context) { - Map result = FastMap.newInstance(); + public static Map<String, Object> createUserLogin(DispatchContext ctx, Map<String, ?> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue loggedInUserLogin = (GenericValue) context.get("userLogin"); - List errorMessageList = FastList.newInstance(); + List<String> errorMessageList = FastList.newInstance(); Locale locale = (Locale) context.get("locale"); boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security.properties", "password.encrypt")); @@ -474,13 +475,13 @@ try { EntityCondition condition = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.EQUALS, EntityFunction.UPPER(userLoginId)); if (UtilValidate.isNotEmpty(delegator.findList("UserLogin", condition, null, null, null, false))) { - Map messageMap = UtilMisc.toMap("userLoginId", userLoginId); + Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_with_ID_exists", messageMap, locale); errorMessageList.add(errMsg); } } catch (GenericEntityException e) { Debug.logWarning(e, "", module); - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_read_failure", messageMap, locale); errorMessageList.add(errMsg); } @@ -494,7 +495,7 @@ createUserLoginPasswordHistory(delegator,userLoginId, currentPassword); } catch (GenericEntityException e) { Debug.logWarning(e, "", module); - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -508,8 +509,8 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map updatePassword(DispatchContext ctx, Map context) { - Map result = FastMap.newInstance(); + public static Map<String, Object> updatePassword(DispatchContext ctx, Map<String, ?> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue loggedInUserLogin = (GenericValue) context.get("userLogin"); @@ -541,13 +542,13 @@ try { userLoginToUpdate = delegator.findOne("UserLogin", false, "userLoginId", userLoginId); } catch (GenericEntityException e) { - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_read_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } if (userLoginToUpdate == null) { - Map messageMap = UtilMisc.toMap("userLoginId", userLoginId); + Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_userlogin_with_id_not_exist", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -581,7 +582,7 @@ userLoginToUpdate.store(); createUserLoginPasswordHistory(delegator,userLoginId, newPassword); } catch (GenericEntityException e) { - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -597,11 +598,11 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map updateUserLoginId(DispatchContext ctx, Map context) { - Map result = FastMap.newInstance(); + public static Map<String, Object> updateUserLoginId(DispatchContext ctx, Map<String, ?> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); GenericValue loggedInUserLogin = (GenericValue) context.get("userLogin"); - List errorMessageList = FastList.newInstance(); + List<String> errorMessageList = FastList.newInstance(); Locale locale = (Locale) context.get("locale"); //boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security.properties", "password.encrypt")); @@ -647,14 +648,14 @@ newUserLogin = delegator.findOne("UserLogin", false, "userLoginId", userLoginId); } catch (GenericEntityException e) { Debug.logWarning(e, "", module); - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_read_failure", messageMap, locale); errorMessageList.add(errMsg); } if (newUserLogin != null) { if (!newUserLogin.get("partyId").equals(partyId)) { - Map messageMap = UtilMisc.toMap("userLoginId", userLoginId); + Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_with_ID_exists", messageMap, locale); errorMessageList.add(errMsg); } else { @@ -682,7 +683,7 @@ } } catch (GenericEntityException e) { Debug.logWarning(e, "", module); - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -694,7 +695,7 @@ loggedInUserLogin.store(); } catch (GenericEntityException e) { Debug.logWarning(e, "", module); - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_disable_old_login_user_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -709,8 +710,8 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map updateUserLoginSecurity(DispatchContext ctx, Map context) { - Map result = FastMap.newInstance(); + public static Map<String, Object> updateUserLoginSecurity(DispatchContext ctx, Map<String, ?> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue loggedInUserLogin = (GenericValue) context.get("userLogin"); @@ -734,13 +735,13 @@ try { userLoginToUpdate = delegator.findOne("UserLogin", false, "userLoginId", userLoginId); } catch (GenericEntityException e) { - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_read_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } if (userLoginToUpdate == null) { - Map messageMap = UtilMisc.toMap("userLoginId", userLoginId); + Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_userlogin_with_id_not_exist", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -773,7 +774,7 @@ try { userLoginToUpdate.store(); } catch (GenericEntityException e) { - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -782,7 +783,7 @@ return result; } - public static void checkNewPassword(GenericValue userLogin, String currentPassword, String newPassword, String newPasswordVerify, String passwordHint, List errorMessageList, boolean ignoreCurrentPassword, Locale locale) { + public static void checkNewPassword(GenericValue userLogin, String currentPassword, String newPassword, String newPasswordVerify, String passwordHint, List<String> errorMessageList, boolean ignoreCurrentPassword, Locale locale) { boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security.properties", "password.encrypt")); String errMsg = null; @@ -825,17 +826,17 @@ newPasswordHash = HashCrypt.getDigestHash(newPassword, getHashType()); } try { - List pwdHistList = delegator.findByAnd("UserLoginPasswordHistory", UtilMisc.toMap("userLoginId",userLogin.getString("userLoginId"),"currentPassword",newPasswordHash)); + List<GenericValue> pwdHistList = delegator.findByAnd("UserLoginPasswordHistory", UtilMisc.toMap("userLoginId",userLogin.getString("userLoginId"),"currentPassword",newPasswordHash)); Debug.logInfo(" checkNewPassword pwdHistListpwdHistList " + pwdHistList.size(), module); if(pwdHistList.size() >0){ - Map messageMap = UtilMisc.toMap("passwordChangeHistoryLimit", passwordChangeHistoryLimit); + Map<String, Integer> messageMap = UtilMisc.toMap("passwordChangeHistoryLimit", passwordChangeHistoryLimit); errMsg = UtilProperties.getMessage(resource,"loginservices.password_must_be_different_from_last_passwords", messageMap, locale); errorMessageList.add(errMsg); Debug.logInfo(" checkNewPassword errorMessageListerrorMessageList " + pwdHistList.size(), module); } } catch (GenericEntityException e) { Debug.logWarning(e, "", module); - Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"loginevents.error_accessing_password_change_history", messageMap, locale); } @@ -859,7 +860,7 @@ if (newPassword != null) { if (!(newPassword.length() >= minPasswordLength)) { - Map messageMap = UtilMisc.toMap("minPasswordLength", Integer.toString(minPasswordLength)); + Map<String, String> messageMap = UtilMisc.toMap("minPasswordLength", Integer.toString(minPasswordLength)); errMsg = UtilProperties.getMessage(resource,"loginservices.password_must_be_least_characters_long", messageMap, locale); errorMessageList.add(errMsg); } @@ -885,16 +886,16 @@ return hashType; } - public static Map getUserLoginSession(GenericValue userLogin) { + public static Map<String, Object> getUserLoginSession(GenericValue userLogin) { GenericDelegator delegator = userLogin.getDelegator(); GenericValue userLoginSession; - Map userLoginSessionMap = null; + Map<String, Object> userLoginSessionMap = null; try { userLoginSession = userLogin.getRelatedOne("UserLoginSession"); if (userLoginSession != null) { Object deserObj = XmlSerializer.deserialize(userLoginSession.getString("sessionData"), delegator); //don't check, just cast, if it fails it will get caught and reported below; if (deserObj instanceof Map) - userLoginSessionMap = (Map) deserObj; + userLoginSessionMap = checkMap(deserObj, String.class, Object.class); } } catch (GenericEntityException ge) { Debug.logWarning(ge, "Cannot get UserLoginSession for UserLogin ID: " + Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java?rev=672672&r1=672671&r2=672672&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java Sun Jun 29 13:33:19 2008 @@ -40,7 +40,7 @@ /* find the date of the last closed CustomTimePeriod, or, if none available, the earliest date available of any * CustomTimePeriod */ - public static Map findLastClosedDate(DispatchContext dctx, Map context) { + public static Map<String, Object> findLastClosedDate(DispatchContext dctx, Map<String, ?> context) { GenericDelegator delegator = dctx.getDelegator(); String organizationPartyId = (String) context.get("organizationPartyId"); // input parameters String periodTypeId = (String) context.get("periodTypeId"); @@ -53,34 +53,34 @@ Timestamp lastClosedDate = null; // return parameters GenericValue lastClosedTimePeriod = null; - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); try { // try to get the ending date of the most recent accounting time period before findDate which has been closed - List findClosedConditions = UtilMisc.toList(EntityCondition.makeConditionMap("organizationPartyId", organizationPartyId), + List<EntityCondition> findClosedConditions = UtilMisc.toList(EntityCondition.makeConditionMap("organizationPartyId", organizationPartyId), EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN_EQUAL_TO, findDate), EntityCondition.makeConditionMap("isClosed", "Y")); if ((periodTypeId != null) && !(periodTypeId.equals(""))) { // if a periodTypeId was supplied, use it findClosedConditions.add(EntityCondition.makeConditionMap("periodTypeId", periodTypeId)); } - List closedTimePeriods = delegator.findList("CustomTimePeriod", EntityCondition.makeCondition(findClosedConditions), + List<GenericValue> closedTimePeriods = delegator.findList("CustomTimePeriod", EntityCondition.makeCondition(findClosedConditions), UtilMisc.toSet("customTimePeriodId", "periodTypeId", "isClosed", "fromDate", "thruDate"), UtilMisc.toList("thruDate DESC"), null, false); - if ((closedTimePeriods != null) && (closedTimePeriods.size() > 0) && (((GenericValue) closedTimePeriods.get(0)).get("thruDate") != null)) { - lastClosedTimePeriod = (GenericValue) closedTimePeriods.get(0); + if ((closedTimePeriods != null) && (closedTimePeriods.size() > 0) && (closedTimePeriods.get(0).get("thruDate") != null)) { + lastClosedTimePeriod = closedTimePeriods.get(0); lastClosedDate = UtilDateTime.toTimestamp(lastClosedTimePeriod.getDate("thruDate")); } else { // uh oh, no time periods have been closed? in that case, just find the earliest beginning of a time period for this organization // and optionally, for this period type - Map findParams = UtilMisc.toMap("organizationPartyId", organizationPartyId); + Map<String, String> findParams = UtilMisc.toMap("organizationPartyId", organizationPartyId); if ((periodTypeId != null) && !(periodTypeId.equals(""))) { findParams.put("periodTypeId", periodTypeId); } - List timePeriods = delegator.findByAnd("CustomTimePeriod", findParams, UtilMisc.toList("fromDate ASC")); - if ((timePeriods != null) && (timePeriods.size() > 0) && (((GenericValue) timePeriods.get(0)).get("fromDate") != null)) { - lastClosedDate = UtilDateTime.toTimestamp(((GenericValue) timePeriods.get(0)).getDate("fromDate")); + List<GenericValue> timePeriods = delegator.findByAnd("CustomTimePeriod", findParams, UtilMisc.toList("fromDate ASC")); + if ((timePeriods != null) && (timePeriods.size() > 0) && (timePeriods.get(0).get("fromDate") != null)) { + lastClosedDate = UtilDateTime.toTimestamp(timePeriods.get(0).getDate("fromDate")); } else { return ServiceUtil.returnError("Cannot get a starting date for net income"); } |
Free forum by Nabble | Edit this page |