Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy Sat Aug 23 22:36:54 2008 @@ -30,17 +30,17 @@ import org.ofbiz.entity.transaction.*; import org.ofbiz.entity.condition.*; -String outpath = request.getParameter("outpath"); -String filename = request.getParameter("filename"); -String maxRecStr = request.getParameter("maxrecords"); -String entitySyncId = request.getParameter("entitySyncId"); -String[] entityName = request.getParameterValues("entityName"); -String entityFrom = request.getParameter("entityFrom"); -String entityThru = request.getParameter("entityThru"); +outpath = parameters.outpath; +filename = parameters.filename; +maxRecStr = parameters.maxrecords; +entitySyncId = parameters.entitySyncId; +passedEntityNames = parameters.entityName instanceof Collection ? parameters.entityName as TreeSet : [parameters.entityName] as TreeSet; +entityFrom = parameters.entityFrom; +entityThru = parameters.entityThru; // get the max records per file setting and convert to a int -int maxRecordsPerFile = 0; -if (UtilValidate.isNotEmpty(maxRecStr)) { +maxRecordsPerFile = 0; +if (maxRecStr) { try { maxRecordsPerFile = Integer.parseInt(maxRecStr); } @@ -48,14 +48,7 @@ } } -Set passedEntityNames = new TreeSet(); -if (entityName != null && entityName.length > 0) { - for(int inc=0; inc<entityName.length; inc++) { - passedEntityNames.add(entityName[inc]); - } -} - -String preConfiguredSetName = request.getParameter("preConfiguredSetName"); +preConfiguredSetName = parameters.preConfiguredSetName; if ("Product1".equals(preConfiguredSetName)) { passedEntityNames = new LinkedHashSet(); passedEntityNames.add("DataResource"); @@ -160,193 +153,180 @@ //passedEntityNames.add("ProductKeyword"); } -if (UtilValidate.isNotEmpty(entitySyncId)) { +if (entitySyncId) { passedEntityNames = org.ofbiz.entityext.synchronization.EntitySyncContext.getEntitySyncModelNamesToUse(dispatcher, entitySyncId); } -boolean checkAll = "true".equals(request.getParameter("checkAll")); -boolean tobrowser = request.getParameter("tobrowser")!=null?true:false; -context.put("tobrowser", tobrowser); +checkAll = "true".equals(parameters.checkAll); +tobrowser = parameters.tobrowser != null; +context.tobrowser = tobrowser; -EntityExpr entityFromCond = null; -EntityExpr entityThruCond = null; -EntityExpr entityDateCond = null; -if (UtilValidate.isNotEmpty(entityFrom)) { +entityFromCond = null; +entityThruCond = null; +entityDateCond = null; +if (entityFrom) { entityFromCond = EntityCondition.makeCondition("lastUpdatedTxStamp", EntityComparisonOperator.GREATER_THAN, entityFrom); } -if (UtilValidate.isNotEmpty(entityThru)) { +if (entityThru) { entityThruCond = EntityCondition.makeCondition("lastUpdatedTxStamp", EntityComparisonOperator.LESS_THAN, entityThru); } -if ((entityFromCond!=null) && (entityThruCond!=null)) { +if (entityFromCond && entityThruCond) { entityDateCond = EntityCondition.makeCondition(entityFromCond, EntityJoinOperator.AND, entityThruCond); -} else if(entityFromCond!=null) { +} else if (entityFromCond) { entityDateCond = entityFromCond; -} else if(entityThruCond!=null) { +} else if (entityThruCond) { entityDateCond = entityThruCond; } -ModelReader reader = delegator.getModelReader(); -Collection ec = reader.getEntityNames(); -TreeSet entityNames = new TreeSet(ec); -context.put("entityNames", entityNames); +reader = delegator.getModelReader(); +entityNames = reader.getEntityNames() as TreeSet; +context.entityNames = entityNames; if (tobrowser) { - session.setAttribute("xmlrawdump_entitylist", entityName); + session.setAttribute("xmlrawdump_entitylist", passedEntityNames); session.setAttribute("entityDateCond", entityDateCond); } else { - EntityFindOptions efo = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); - ModelReader reader = delegator.getModelReader(); - Collection ec = reader.getEntityNames(); - TreeSet entityNames = new TreeSet(ec); - context.put("entityNames", entityNames); - int numberOfEntities = passedEntityNames.size(); - context.put("numberOfEntities", Integer.toString(numberOfEntities)); - long numberWritten = 0; - - // single file - if(filename != null && filename.length() > 0 && numberOfEntities > 0) { - PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF-8"))); - writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); - writer.println("<entity-engine-xml>"); - - Iterator i = passedEntityNames.iterator(); - while(i.hasNext()) { - String curEntityName = (String) i.next(); - if (UtilValidate.isNotEmpty(entityFrom)) { - curModelEntity = reader.getModelEntity(curEntityName); - if (curModelEntity instanceof ModelViewEntity) { - continue; - } - } - - boolean beganTransaction = TransactionUtil.begin(3600); - try { - ModelEntity me = reader.getModelEntity(curEntityName); - EntityListIterator values = null; - if (me.getNoAutoStamp() == true) { - values = delegator.find(curEntityName, null, null, null, me.getPkFieldNames(), efo); - } else { - values = delegator.find(curEntityName, entityDateCond, null, null, UtilMisc.toList("-createdTxStamp"), efo); - } - - GenericValue value = null; - long curNumberWritten = 0; - while ((value = (GenericValue) values.next()) != null) { - value.writeXmlText(writer, ""); - numberWritten++; - curNumberWritten++; - if (curNumberWritten % 500 == 0 || curNumberWritten == 1) { - Debug.log("Records written [" + curEntityName + "]: " + curNumberWritten + " Total: " + numberWritten); + efo = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); + numberOfEntities = passedEntityNames?.size() ?: 0; + context.numberOfEntities = numberOfEntities; + numberWritten = 0; + + // single file + if(filename && numberOfEntities) { + writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF-8"))); + writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); + writer.println("<entity-engine-xml>"); + + passedEntityNames.each { curEntityName -> + if (entityFrom) { + curModelEntity = reader.getModelEntity(curEntityName); + if (curModelEntity instanceof ModelViewEntity) { + return; } } - values.close(); - Debug.log("Wrote [" + curNumberWritten + "] from entity : " + curEntityName); - TransactionUtil.commit(beganTransaction); - } catch (Exception e) { - String errMsg = "Error reading data for XML export:"; - Debug.logError(e, errMsg, "JSP"); - TransactionUtil.rollback(beganTransaction, errMsg, e); - } - } - writer.println("</entity-engine-xml>"); - writer.close(); - Debug.log("Total records written from all entities: " + numberWritten); - context.put("numberWritten", Long.toString(numberWritten)); -} -// multiple files in a directory -Collection results = new ArrayList(); -int fileNumber = 1; -context.put("results", results); -if (outpath != null){ - File outdir = new File(outpath); - if(!outdir.exists()){ - outdir.mkdir(); - } - if(outdir.isDirectory() && outdir.canWrite()) { - Iterator i= passedEntityNames.iterator(); - - while(i.hasNext()) { - numberWritten = 0; - String curEntityName = (String)i.next(); - String fileName = preConfiguredSetName != null ? UtilFormatOut.formatPaddedNumber((long) fileNumber, 3) + "_" : ""; - fileName = fileName + curEntityName; - - EntityListIterator values = null; - boolean beganTransaction = false; - try{ - beganTransaction = TransactionUtil.begin(3600); - - ModelEntity me = delegator.getModelEntity(curEntityName); - if (me instanceof ModelViewEntity) { - results.add("["+fileNumber +"] [vvv] " + curEntityName + " skipping view entity"); - continue; - } - if (me.getNoAutoStamp() == true) { + beganTransaction = TransactionUtil.begin(3600); + try { + me = reader.getModelEntity(curEntityName); + if (me.getNoAutoStamp()) { values = delegator.find(curEntityName, null, null, null, me.getPkFieldNames(), efo); } else { - values = delegator.find(curEntityName, entityDateCond, null, null, me.getPkFieldNames(), efo); + values = delegator.find(curEntityName, entityDateCond, null, null, UtilMisc.toList("-createdTxStamp"), efo); } - boolean isFirst = true; - PrintWriter writer = null; - int fileSplitNumber = 1; - GenericValue value = null; - while ((value = (GenericValue) values.next()) != null) { - //Don't bother writing the file if there's nothing - //to put into it - if (isFirst) { - writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, fileName +".xml")), "UTF-8"))); - writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); - writer.println("<entity-engine-xml>"); - isFirst = false; - } + + curNumberWritten = 0; + values.each { value -> value.writeXmlText(writer, ""); numberWritten++; + curNumberWritten++; + if (curNumberWritten % 500 == 0 || curNumberWritten == 1) { + Debug.log("Records written [$curEntityName]: $curNumberWritten Total: $numberWritten"); + } + } + values.close(); + Debug.log("Wrote [$curNumberWritten] from entity : $curEntityName"); + TransactionUtil.commit(beganTransaction); + } catch (Exception e) { + errMsg = "Error reading data for XML export:"; + Debug.logError(e, errMsg, "JSP"); + TransactionUtil.rollback(beganTransaction, errMsg, e); + } + } + writer.println("</entity-engine-xml>"); + writer.close(); + Debug.log("Total records written from all entities: $numberWritten"); + context.numberWritten = numberWritten; + } + + // multiple files in a directory + results = []; + fileNumber = 1; + context.results = results; + if (outpath) { + outdir = new File(outpath); + if(!outdir.exists()){ + outdir.mkdir(); + } + if (outdir.isDirectory() && outdir.canWrite()) { + passedEntityNames.each { curEntityName -> + numberWritten = 0; + fileName = preConfiguredSetName ? UtilFormatOut.formatPaddedNumber((long) fileNumber, 3) + "_" : ""; + fileName = fileName + curEntityName; + + values = null; + beganTransaction = false; + try { + beganTransaction = TransactionUtil.begin(3600); + + me = delegator.getModelEntity(curEntityName); + if (me instanceof ModelViewEntity) { + results.add("[$fileNumber] [vvv] $curEntityName skipping view entity"); + return; + } + if (me.getNoAutoStamp()) { + values = delegator.find(curEntityName, null, null, null, me.getPkFieldNames(), efo); + } else { + values = delegator.find(curEntityName, entityDateCond, null, null, me.getPkFieldNames(), efo); + } + isFirst = true; + writer = null; + fileSplitNumber = 1; + values.each { value -> + //Don't bother writing the file if there's nothing + //to put into it + if (isFirst) { + writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, fileName +".xml")), "UTF-8"))); + writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); + writer.println("<entity-engine-xml>"); + isFirst = false; + } + value.writeXmlText(writer, ""); + numberWritten++; + + // split into small files + if (maxRecordsPerFile > 0 && (numberWritten % maxRecordsPerFile == 0)) { + fileSplitNumber++; + // close the file + writer.println("</entity-engine-xml>"); + writer.close(); + + // create a new file + splitNumStr = UtilFormatOut.formatPaddedNumber((long) fileSplitNumber, 3); + writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, fileName + "_" + splitNumStr +".xml")), "UTF-8"))); + writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); + writer.println("<entity-engine-xml>"); + } + + if (numberWritten % 500 == 0 || numberWritten == 1) { + Debug.log("Records written [$curEntityName]: $numberWritten"); + } - // split into small files - if ((maxRecordsPerFile > 0) && (numberWritten % maxRecordsPerFile == 0)) { - fileSplitNumber++; - // close the file + } + if (writer) { writer.println("</entity-engine-xml>"); writer.close(); - - // create a new file - String splitNumStr = UtilFormatOut.formatPaddedNumber((long) fileSplitNumber, 3); - writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, fileName + "_" + splitNumStr +".xml")), "UTF-8"))); - writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); - writer.println("<entity-engine-xml>"); + String thisResult = "[$fileNumber] [$numberWritten] $curEntityName wrote $numberWritten records"; + Debug.log(thisResult); + results.add(thisResult); + } else { + thisResult = "[$fileNumber] [---] $curEntityName has no records, not writing file"; + Debug.log(thisResult); + results.add(thisResult); } - - if (numberWritten % 500 == 0 || numberWritten == 1) { - Debug.log("Records written [" + curEntityName + "]: " + numberWritten); + values.close(); + } catch (Exception ex) { + if (values != null) { + values.close(); } - - } - if (writer != null) { - writer.println("</entity-engine-xml>"); - writer.close(); - String thisResult = "["+fileNumber +"] [" + numberWritten + "] " + curEntityName + " wrote " + numberWritten + " records"; - Debug.log(thisResult); - results.add(thisResult); - } else { - String thisResult = "["+fileNumber +"] [---] " + curEntityName + " has no records, not writing file"; + thisResult = "[$fileNumber] [xxx] Error when writing $curEntityName: $ex"; Debug.log(thisResult); results.add(thisResult); + TransactionUtil.rollback(beganTransaction, thisResult, ex); + } finally { + // only commit the transaction if we started one... this will throw an exception if it fails + TransactionUtil.commit(beganTransaction); } - values.close(); - } catch (Exception ex) { - if (values != null) { - values.close(); - } - String thisResult = "["+fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + ex; - Debug.log(thisResult); - results.add(thisResult); - TransactionUtil.rollback(beganTransaction, thisResult, ex); - } finally { - // only commit the transaction if we started one... this will throw an exception if it fails - TransactionUtil.commit(beganTransaction); + fileNumber++; } - fileNumber++; } } } -} Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.groovy Sat Aug 23 22:36:54 2008 @@ -30,37 +30,29 @@ import org.ofbiz.entity.util.EntityUtil; -Logger rootLogger = Logger.getRootLogger(); -LoggerRepository loggerRepository = rootLogger.getLoggerRepository(); +rootLogger = Logger.getRootLogger(); +loggerRepository = rootLogger.getLoggerRepository(); -List loggerList = UtilMisc.toListArray(new Object[0]); -for (Enumeration enumeration = loggerRepository.getCurrentLoggers(); enumeration.hasMoreElements() ;) { - Logger logger = (Logger) enumeration.nextElement(); +loggerList = []; +for (Enumeration enumeration = loggerRepository.getCurrentLoggers(); enumeration.hasMoreElements();) { + logger = enumeration.nextElement(); if (logger.getLevel() != null) { - Map loggerMap = UtilMisc.toMap("name", logger.getName(), "level", logger.getLevel(), "additivity", logger.getAdditivity() ? "Y" : "N", "logger", logger); + loggerMap = [name : logger.getName(), level : logger.getLevel(), additivity : logger.getAdditivity() ? "Y" : "N", logger : logger]; loggerList.add(loggerMap); } } -Collections.sort(loggerList, new Comparator() { - int compare(Object l1, Object l2) { - Map loggerMap1 = (Map) l1; - Map loggerMap2 = (Map) l2; - String name1 = (String)l1.get("name"); - String name2 = (String)l2.get("name"); - return name1.compareTo(name2); - } -}); +Collections.sort(loggerList, [compare: {l1, l2 -> l1.name.compareTo(l2.name)}] as Comparator); -loggerList.add(0, UtilMisc.toMap("name", rootLogger.getName(), "level", rootLogger.getLevel(), "additivity", rootLogger.getAdditivity() ? "Y" : "N", "logger", rootLogger)); -context.put("loggerList", loggerList); +loggerList.add(0, [name : rootLogger.getName(), level : rootLogger.getLevel(), additivity : rootLogger.getAdditivity() ? "Y" : "N", logger : rootLogger]); +context.loggerList = loggerList; -context.put("defaultLogger", UtilMisc.toMap("name", "org.ofbiz.", "level", "INFO", "additivity", "Y")); -context.put("activeDebugLevel", UtilMisc.toMap(new String[] {"fatal", Debug.fatalOn() ? "Y" : "N", - "error", Debug.errorOn() ? "Y" : "N", - "warning", Debug.warningOn() ? "Y" : "N", - "important", Debug.importantOn() ? "Y" : "N", - "info", Debug.infoOn() ? "Y" : "N", - "timing", Debug.timingOn() ? "Y" : "N", - "verbose", Debug.verboseOn() ? "Y" : "N"})); +context.defaultLogger = [name : "org.ofbiz.", level : "INFO", additivity : "Y"]; +context.activeDebugLevel = [fatal : Debug.fatalOn() ? "Y" : "N", + error : Debug.errorOn() ? "Y" : "N", + warning : Debug.warningOn() ? "Y" : "N", + important : Debug.importantOn() ? "Y" : "N", + info : Debug.infoOn() ? "Y" : "N", + timing : Debug.timingOn() ? "Y" : "N", + verbose : Debug.verboseOn() ? "Y" : "N"]; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.groovy Sat Aug 23 22:36:54 2008 @@ -19,10 +19,10 @@ import org.ofbiz.base.util.FileUtil; -StringBuffer sb = null; +sb = null; try { sb = FileUtil.readTextFile(logFileName, true); } catch(Exception exc) {} -if (sb != null) { - context.put("logFileContent", sb.toString()); +if (sb) { + context.logFileContent = sb.toString(); } Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.groovy Sat Aug 23 22:36:54 2008 @@ -23,62 +23,55 @@ import org.ofbiz.entity.*; import org.ofbiz.base.util.*; -String findOrganizationPartyId = request.getParameter("findOrganizationPartyId"); -if (UtilValidate.isNotEmpty(findOrganizationPartyId)) { - context.put("findOrganizationPartyId", findOrganizationPartyId); +findOrganizationPartyId = parameters.findOrganizationPartyId; +if (findOrganizationPartyId) { + context.findOrganizationPartyId = findOrganizationPartyId; } -String currentCustomTimePeriodId = request.getParameter("currentCustomTimePeriodId"); -if (UtilValidate.isNotEmpty(currentCustomTimePeriodId)) { - context.put("currentCustomTimePeriodId", currentCustomTimePeriodId); +currentCustomTimePeriodId = parameters.currentCustomTimePeriodId; +if (currentCustomTimePeriodId) { + context.currentCustomTimePeriodId = currentCustomTimePeriodId; } -GenericValue currentCustomTimePeriod = currentCustomTimePeriodId == null ? null : delegator.findByPrimaryKey("CustomTimePeriod", UtilMisc.toMap("customTimePeriodId", currentCustomTimePeriodId)); -if (currentCustomTimePeriod != null) { - context.put("currentCustomTimePeriod", currentCustomTimePeriod); +currentCustomTimePeriod = currentCustomTimePeriodId ? delegator.findByPrimaryKey("CustomTimePeriod", [customTimePeriodId : currentCustomTimePeriodId]) : null; +if (currentCustomTimePeriod) { + context.currentCustomTimePeriod = currentCustomTimePeriod; } -GenericValue currentPeriodType = currentCustomTimePeriod == null ? null : currentCustomTimePeriod.getRelatedOneCache("PeriodType"); -if (currentPeriodType != null) { - context.put("currentPeriodType", currentPeriodType); +currentPeriodType = currentCustomTimePeriod ? currentCustomTimePeriod.getRelatedOneCache("PeriodType") : null; +if (currentPeriodType) { + context.currentPeriodType = currentPeriodType; } -Map findMap = UtilMisc.toMap("organizationPartyId", findOrganizationPartyId); -if (UtilValidate.isNotEmpty(currentCustomTimePeriodId)) { - findMap.put("parentPeriodId", currentCustomTimePeriodId); +findMap = [organizationPartyId : findOrganizationPartyId]; +if (currentCustomTimePeriodId) { + findMap.parentPeriodId = currentCustomTimePeriodId; } -List customTimePeriods = delegator.findByAnd("CustomTimePeriod", findMap, - UtilMisc.toList("periodTypeId", "periodNum", "fromDate")); -if (customTimePeriods != null) { - context.put("customTimePeriods", customTimePeriods); -} +customTimePeriods = delegator.findByAnd("CustomTimePeriod", findMap, ["periodTypeId", "periodNum", "fromDate"]); +context.customTimePeriods = customTimePeriods; -List allCustomTimePeriods = delegator.findList("CustomTimePeriod", null, null, UtilMisc.toList("organizationPartyId", "parentPeriodId", "periodTypeId", "periodNum", "fromDate"), null, false); -if (allCustomTimePeriods != null) { - context.put("allCustomTimePeriods", allCustomTimePeriods); -} +allCustomTimePeriods = delegator.findList("CustomTimePeriod", null, null, ["organizationPartyId", "parentPeriodId", "periodTypeId", "periodNum", "fromDate"], null, false); +context.allCustomTimePeriods = allCustomTimePeriods; -List periodTypes = delegator.findList("PeriodType", null, null, UtilMisc.toList("description"), null, true); -if (periodTypes != null) { - context.put("periodTypes", periodTypes); -} +periodTypes = delegator.findList("PeriodType", null, null, ["description"], null, true); +context.periodTypes = periodTypes; -String newPeriodTypeId = "FISCAL_YEAR"; -if (currentCustomTimePeriod != null && "FISCAL_YEAR".equals(currentCustomTimePeriod.getString("periodTypeId"))) { +newPeriodTypeId = "FISCAL_YEAR"; +if ("FISCAL_YEAR".equals(currentCustomTimePeriod?.periodTypeId)) { newPeriodTypeId = "FISCAL_QUARTER"; } -if (currentCustomTimePeriod != null && "FISCAL_QUARTER".equals(currentCustomTimePeriod.getString("periodTypeId"))) { +if ("FISCAL_QUARTER".equals(currentCustomTimePeriod?.periodTypeId)) { newPeriodTypeId = "FISCAL_MONTH"; } -if (currentCustomTimePeriod != null && "FISCAL_MONTH".equals(currentCustomTimePeriod.getString("periodTypeId"))) { +if ("FISCAL_MONTH".equals(currentCustomTimePeriod?.periodTypeId)) { newPeriodTypeId = "FISCAL_WEEK"; } -if (currentCustomTimePeriod != null && "FISCAL_BIWEEK".equals(currentCustomTimePeriod.getString("periodTypeId"))) { +if ("FISCAL_BIWEEK".equals(currentCustomTimePeriod?.periodTypeId)) { newPeriodTypeId = "FISCAL_WEEK"; } -if (currentCustomTimePeriod != null && "FISCAL_WEEK".equals(currentCustomTimePeriod.getString("periodTypeId"))) { +if ("FISCAL_WEEK".equals(currentCustomTimePeriod?.periodTypeId)) { newPeriodTypeId = ""; } -context.put("newPeriodTypeId", newPeriodTypeId); +context.newPeriodTypeId = newPeriodTypeId; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/AvailableServices.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/availableservices.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/AvailableServices.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/AvailableServices.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/availableservices.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/availableservices.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/AvailableServices.groovy Sat Aug 23 22:36:54 2008 @@ -28,25 +28,19 @@ import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilProperties; -getEcaListForService(String selectedService){ +List getEcaListForService(String selectedService){ ecaMap = org.ofbiz.service.eca.ServiceEcaUtil.getServiceEventMap(selectedService); - if(ecaMap == null) return null; + if (!ecaMap) return null; //ecaMap is a HashMap so get keyset & iterate - ecaMapList = new java.util.ArrayList(); + ecaMapList = []; - ecaMapIter = ecaMap.keySet().iterator(); - while(ecaMapIter.hasNext()){ - curRuleKey = ecaMapIter.next(); //get key in ecaMap + ecaMap.each { ecaKey, ecaValue -> + ecaValue.each { curRule -> + curRuleMap = [:]; - curRuleListIter = ecaMap.get(curRuleKey).iterator(); // get rule object from ecaMap using above key - - while(curRuleListIter.hasNext()){ - curRule = curRuleListIter.next(); - curRuleMap = new java.util.HashMap(); - - curRuleMap.put("ruleKey", curRuleKey); + curRuleMap.ruleKey = ecaKey; curRuleClass = curRule.getClass(); @@ -54,8 +48,8 @@ eventName = curRuleClass.getDeclaredField("eventName"); eventName.setAccessible(true); eventNameVal = eventName.get(curRule); - if(eventNameVal != null){ - curRuleMap.put("eventName", eventNameVal+""); + if (eventNameVal) { + curRuleMap.eventName = eventNameVal as String; } eventName.setAccessible(false); @@ -63,8 +57,8 @@ runOnError = curRuleClass.getDeclaredField("runOnError"); runOnError.setAccessible(true); runOnErrorVal = runOnError.get(curRule); - if(runOnErrorVal != null){ - curRuleMap.put("runOnError", runOnErrorVal+""); + if (runOnErrorVal) { + curRuleMap.runOnError = runOnErrorVal as String; } runOnError.setAccessible(false); @@ -72,8 +66,8 @@ runOnFailure = curRuleClass.getDeclaredField("runOnFailure"); runOnFailure.setAccessible(true); runOnFailureVal = runOnFailure.get(curRule); - if(runOnFailureVal != null){ - curRuleMap.put("runOnFailure", runOnFailureVal+""); + if (runOnFailureVal) { + curRuleMap.runOnFailure = runOnFailureVal as String; } runOnFailure.setAccessible(false); @@ -81,20 +75,18 @@ actions = curRuleClass.getDeclaredField("actionsAndSets"); actions.setAccessible(true); actionsVal = actions.get(curRule); - if(actionsVal != null){ + if (actionsVal) { actionsList = new ArrayList(actionsVal.size()); - actionsIter = actionsVal.iterator(); - while(actionsVal != null && actionsIter.hasNext()){ - curAction = actionsIter.next(); - actionMap = new HashMap(); + actionsVal.each { curAction -> + actionMap = [:]; actionClass = curAction.getClass(); //eventName eventName = actionClass.getDeclaredField("eventName"); eventName.setAccessible(true); eventNameVal = eventName.get(curAction); - if(eventNameVal != null){ - actionMap.put("eventName", eventNameVal+""); + if (eventNameVal) { + actionMap.eventName = eventNameVal as String; } eventName.setAccessible(false); @@ -102,8 +94,8 @@ ignoreError = actionClass.getDeclaredField("ignoreError"); ignoreError.setAccessible(true); ignoreErrorVal = ignoreError.get(curAction); - if(ignoreErrorVal != null){ - actionMap.put("ignoreError", ignoreErrorVal+""); + if (ignoreErrorVal) { + actionMap.ignoreError = ignoreErrorVal as String; } ignoreError.setAccessible(false); @@ -111,8 +103,8 @@ ignoreFailure = actionClass.getDeclaredField("ignoreFailure"); ignoreFailure.setAccessible(true); ignoreFailureVal = ignoreFailure.get(curAction); - if(ignoreFailureVal != null){ - actionMap.put("ignoreFailure", ignoreFailureVal+""); + if (ignoreFailureVal) { + actionMap.ignoreFailure = ignoreFailureVal as String; } ignoreFailure.setAccessible(false); @@ -120,8 +112,8 @@ persist = actionClass.getDeclaredField("persist"); persist.setAccessible(true); persistVal = persist.get(curAction); - if(persistVal != null){ - actionMap.put("persist", persistVal+""); + if (persistVal) { + actionMap.persist = persistVal as String; } persist.setAccessible(false); @@ -129,8 +121,8 @@ resultMapName = actionClass.getDeclaredField("resultMapName"); resultMapName.setAccessible(true); resultMapNameVal = resultMapName.get(curAction); - if(resultMapNameVal != null && resultMapNameVal.length() > 0){ - actionMap.put("resultMapName", resultMapNameVal+""); + if (resultMapNameVal) { + actionMap.resultMapName = resultMapNameVal as String; } resultMapName.setAccessible(false); @@ -138,8 +130,8 @@ resultToContext = actionClass.getDeclaredField("resultToContext"); resultToContext.setAccessible(true); resultToContextVal = resultToContext.get(curAction); - if(resultToContextVal != null){ - actionMap.put("resultToContext", resultToContextVal+""); + if (resultToContextVal) { + actionMap.resultToContext = resultToContextVal as String; } resultToContext.setAccessible(false); @@ -147,8 +139,8 @@ resultToResult = actionClass.getDeclaredField("resultToResult"); resultToResult.setAccessible(true); resultToResultVal = resultToResult.get(curAction); - if(resultToResultVal != null){ - actionMap.put("resultToResult", resultToResultVal+""); + if (resultToResultVal) { + actionMap.resultToResult = resultToResultVal as String; } resultToResult.setAccessible(false); @@ -156,8 +148,8 @@ serviceMode = actionClass.getDeclaredField("serviceMode"); serviceMode.setAccessible(true); serviceModeVal = serviceMode.get(curAction); - if(serviceModeVal != null){ - actionMap.put("serviceMode", serviceModeVal+""); + if (serviceModeVal) { + actionMap.serviceMode = serviceModeVal as String; } serviceMode.setAccessible(false); @@ -165,15 +157,15 @@ serviceName = actionClass.getDeclaredField("serviceName"); serviceName.setAccessible(true); serviceNameVal = serviceName.get(curAction); - if(serviceNameVal != null){ - actionMap.put("serviceName", serviceNameVal+""); + if (serviceNameVal) { + actionMap.serviceName = serviceNameVal as String; } serviceName.setAccessible(false); actionsList.add(actionMap); } - curRuleMap.put("actions", actionsList); + curRuleMap.actions = actionsList; } actions.setAccessible(true); @@ -181,21 +173,19 @@ conditions = curRuleClass.getDeclaredField("conditions"); conditions.setAccessible(true); conditionsVal = conditions.get(curRule); - if(conditionsVal != null){ - curRuleMap.put("conditions", runOnFailureVal+""); - condIter = conditionsVal.iterator(); + if (conditionsVal) { + curRuleMap.conditions = runOnFailureVal as String; condList = new ArrayList(conditionsVal.size()); - while(condIter.hasNext()){ - condVal = condIter.next(); + conditionsVal.each { condVal -> condValClass = condVal.getClass(); - condMap = new HashMap(); + condMap = [:]; //compareType compareType = condValClass.getDeclaredField("compareType"); compareType.setAccessible(true); compareTypeVal = compareType.get(condVal); - if(compareTypeVal != null && compareTypeVal.length() > 0){ - condMap.put("compareType", compareTypeVal+""); + if (compareTypeVal) { + condMap.compareType = compareTypeVal as String; } compareType.setAccessible(false); @@ -203,8 +193,8 @@ conditionService = condValClass.getDeclaredField("conditionService"); conditionService.setAccessible(true); conditionServiceVal = conditionService.get(condVal); - if(conditionServiceVal != null && conditionServiceVal.length() > 0){ - condMap.put("conditionService", conditionServiceVal+""); + if (conditionServiceVal) { + condMap.conditionService = conditionServiceVal as String; } conditionService.setAccessible(false); @@ -212,8 +202,8 @@ format = condValClass.getDeclaredField("format"); format.setAccessible(true); formatVal = format.get(condVal); - if(formatVal != null && formatVal.length() > 0){ - condMap.put("format", formatVal+""); + if (formatVal) { + condMap.format = formatVal as String; } format.setAccessible(false); @@ -221,8 +211,8 @@ isConstant = condValClass.getDeclaredField("isConstant"); isConstant.setAccessible(true); isConstantVal = isConstant.get(condVal); - if(isConstantVal != null){ - condMap.put("isConstant", isConstantVal+""); + if (isConstantVal) { + condMap.isConstant = isConstantVal as String; } isConstant.setAccessible(false); @@ -230,8 +220,8 @@ isService = condValClass.getDeclaredField("isService"); isService.setAccessible(true); isServiceVal = isService.get(condVal); - if(isServiceVal != null){ - condMap.put("isService", isServiceVal+""); + if (isServiceVal) { + condMap.isService = isServiceVal as String; } isService.setAccessible(false); @@ -239,8 +229,8 @@ lhsMapName = condValClass.getDeclaredField("lhsMapName"); lhsMapName.setAccessible(true); lhsMapNameVal = lhsMapName.get(condVal); - if(lhsMapNameVal != null && lhsMapNameVal.length() > 0){ - condMap.put("lhsMapName", lhsMapNameVal+""); + if (lhsMapNameVal) { + condMap.lhsMapName = lhsMapNameVal as String; } lhsMapName.setAccessible(false); @@ -248,8 +238,8 @@ lhsValueName = condValClass.getDeclaredField("lhsValueName"); lhsValueName.setAccessible(true); lhsValueNameVal = lhsValueName.get(condVal); - if(lhsValueNameVal != null && lhsValueNameVal.length() > 0){ - condMap.put("lhsValueName", lhsValueNameVal+""); + if (lhsValueNameVal){ + condMap.lhsValueName = lhsValueNameVal as String; } lhsValueName.setAccessible(false); @@ -257,8 +247,8 @@ operator = condValClass.getDeclaredField("operator"); operator.setAccessible(true); operatorVal = operator.get(condVal); - if(operatorVal != null && operatorVal.length() > 0 ){ - condMap.put("operator", operatorVal+""); + if (operatorVal) { + condMap.operator = operatorVal as String; } operator.setAccessible(false); @@ -266,8 +256,8 @@ rhsMapName = condValClass.getDeclaredField("rhsMapName"); rhsMapName.setAccessible(true); rhsMapNameVal = rhsMapName.get(condVal); - if(rhsMapNameVal != null && rhsMapNameVal.length() > 0){ - condMap.put("rhsMapName", rhsMapNameVal+""); + if (rhsMapNameVal){ + condMap.rhsMapName = rhsMapNameVal as String; } rhsMapName.setAccessible(false); @@ -275,18 +265,18 @@ rhsValueName = condValClass.getDeclaredField("rhsValueName"); rhsValueName.setAccessible(true); rhsValueNameVal = rhsValueName.get(condVal); - if(rhsValueNameVal != null && rhsValueNameVal.length() > 0){ - condMap.put("rhsValueName", rhsValueNameVal+""); + if (rhsValueNameVal){ + condMap.rhsValueName = rhsValueNameVal as String; } rhsValueName.setAccessible(false); condList.add(condMap); } - curRuleMap.put("conditions", condList); + curRuleMap.conditions = condList; } conditions.setAccessible(false); - - ecaMapList.add(curRuleMap); + + ecaMapList.add(curRuleMap); } } return ecaMapList; @@ -297,301 +287,254 @@ accounting, content, ecommerce, manufacturing, marketing, ordermgr, partymgr, catalog, facility, workeffort, example, WFDispatcher, webtools, order, wholesale, salesrep, hotelbackend, community */ //Ashish: Don't know how to get list of available dispatchers, so hardcoded. Add to this list if I missed some. -dispArrList = new ArrayList(); -dispArrList.add("accounting"); -dispArrList.add("content"); -dispArrList.add("ecommerce"); -dispArrList.add("manufacturing"); -dispArrList.add("marketing"); -dispArrList.add("order"); -dispArrList.add("partymgr"); -dispArrList.add("catalog"); -dispArrList.add("facility"); -dispArrList.add("workeffort"); -dispArrList.add("example"); -dispArrList.add("WFDispatcher"); -dispArrList.add("webtools"); -dispArrList.add("wholesale"); -dispArrList.add("salesrep"); -dispArrList.add("hotelbackend"); -dispArrList.add("community"); +dispArrList = ["accounting", + "content", + "ecommerce", + "manufacturing", + "marketing", + "order", + "partymgr", + "catalog", + "facility", + "workeffort", + "example", + "WFDispatcher", + "webtools", + "wholesale", + "salesrep", + "hotelbackend", + "community"]; Collections.sort(dispArrList); -context.put("dispArrList", dispArrList); +context.dispArrList = dispArrList; -locale = UtilHttp.getLocale(request); -request.setAttribute("locale",locale); uiLabelMap = UtilProperties.getResourceBundleMap("WebtoolsUiLabels", locale); uiLabelMap.addBottomResourceBundle("CommonUiLabels"); -selDisp = request.getParameter("selDisp"); -selDisp = selDisp == null || selDisp.length() == 0 ? request.getAttribute("selDisp") : selDisp; -//default disptacher is partymgr -selDisp = selDisp == null || selDisp.length() == 0 ? "partymgr" : selDisp; +selDisp = parameters.selDisp ?: "partymgr"; -curDispatcher = request.getAttribute("dispatcher"); -curLocalDispatcher = curDispatcher.getLocalDispatcher(selDisp, request.getAttribute("delegator")); +curLocalDispatcher = dispatcher.getLocalDispatcher(selDisp, delegator); curDispatchContext = curLocalDispatcher.getDispatchContext(); -context.put("dispatcherName", curLocalDispatcher.getName()); +context.dispatcherName = curLocalDispatcher.getName(); -selectedService = request.getParameter("sel_service_name"); -if(selectedService == null || selectedService.length() == 0){ - selectedService = request.getAttribute("sel_service_name"); -} +selectedService = parameters.sel_service_name; -if(selectedService != null && selectedService.length() > 0){ - HashMap curServiceMap = new HashMap(); +if (selectedService) { + curServiceMap = [:]; - curServiceMap.put("serviceName", selectedService); + curServiceMap.serviceName = selectedService; curServiceModel = curDispatchContext.getModelService(selectedService); - curServiceMap.put("description", curServiceModel.description); + curServiceMap.description = curServiceModel.description; - if(curServiceModel != null){ + if (curServiceModel) { - engineName = curServiceModel.engineName; - defaultEntityName = curServiceModel.defaultEntityName; - export = curServiceModel.export ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse"); - permissionGroups = curServiceModel.permissionGroups; - implServices = curServiceModel.implServices; + engineName = curServiceModel.engineName ?: "NA"; + defaultEntityName = curServiceModel.defaultEntityName ?: "NA"; + export = curServiceModel.export ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; + permissionGroups = curServiceModel.permissionGroups ?: "NA"; + implServices = curServiceModel.implServices ?: "NA"; overrideParameters = curServiceModel.overrideParameters; - useTrans = curServiceModel.useTransaction ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse"); + useTrans = curServiceModel.useTransaction ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; maxRetry = curServiceModel.maxRetry; //Test for ECA's ecaMapList = getEcaListForService(selectedService); - if(ecaMapList != null){ - context.put("ecaMapList", ecaMapList); + if (ecaMapList) { + context.ecaMapList = ecaMapList; } //End Test for ECA's - invoke = curServiceModel.invoke; - location = curServiceModel.location; - requireNewTransaction = curServiceModel.requireNewTransaction ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse"); - engineName = engineName != null && engineName.length() > 0 ? engineName : "NA"; - defaultEntityName = defaultEntityName != null && defaultEntityName.length() > 0 ? defaultEntityName : "NA"; - invoke = invoke != null && invoke.length() > 0 ? invoke : "NA"; - location = location != null && location.length() > 0 ? location : "NA"; - permissionGroups = permissionGroups != null && permissionGroups.size() > 0 ? permissionGroups : "NA"; - implServices = implServices != null && implServices.size() > 0 ? implServices : "NA"; - - curServiceMap.put("engineName", engineName); - curServiceMap.put("defaultEntityName", defaultEntityName); - curServiceMap.put("invoke", invoke); - curServiceMap.put("location", location); - curServiceMap.put("requireNewTransaction", requireNewTransaction); - curServiceMap.put("export", export); + invoke = curServiceModel.invoke ?: "NA"; + location = curServiceModel.location ?: "NA"; + requireNewTransaction = curServiceModel.requireNewTransaction ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; + + curServiceMap.engineName = engineName; + curServiceMap.defaultEntityName = defaultEntityName; + curServiceMap.invoke = invoke; + curServiceMap.location = location; + curServiceMap.requireNewTransaction = requireNewTransaction; + curServiceMap.export = export; - if(permissionGroups != null && !permissionGroups.equals("NA") && permissionGroups.size() > 0){ - permIter = permissionGroups.iterator(); + if(permissionGroups && !permissionGroups.equals("NA")){ permList = new ArrayList(permissionGroups.size()); - while(permIter.hasNext()){ - curPerm = (ModelPermGroup)permIter.next();//This is a ModelPermGroup - curIter = curPerm.permissions.size() > 0 ? curPerm.permissions.iterator() : null; - while(curIter != null && curIter.hasNext()){ - curPermObj = curIter.next(); - permObj = new HashMap(); - permObj.put("action" , curPermObj.action); + permissionGroups.each { curPerm -> //This is a ModelPermGroup + curPerm.permissions.each { curPermObj -> + permObj = [:]; + permObj.action = curPermObj.action; permType = curPermObj.permissionType; - if(permType == 1){ + if (permType == 1) { permType = "Simple Permission"; - }else if(permType == 2){ + } else if (permType == 2) { permType = "Entity Permission"; - }else if(permType == 3){ + } else if (permType == 3) { permType = "Role Member"; } - permObj.put("permType" , permType); - permObj.put("nameOrRole" , curPermObj.nameOrRole); + permObj.permType = permType; + permObj.nameOrRole = curPermObj.nameOrRole; permList.add(permObj); } } - curServiceMap.put("permissionGroups", permList); - }else{ - curServiceMap.put("permissionGroups", permissionGroups); + curServiceMap.permissionGroups = permList; + } else { + curServiceMap.permissionGroups = permissionGroups; } - curServiceMap.put("implServices", implServices); - curServiceMap.put("useTrans", useTrans); - curServiceMap.put("maxRetry", maxRetry); + curServiceMap.implServices = implServices; + curServiceMap.useTrans = useTrans; + curServiceMap.maxRetry = maxRetry; allParamsList = new ArrayList(3); inParams = curServiceModel.getInParamNames(); - if(inParams != null){ - inParamsList = new ArrayList(inParams.size()); - inParamsIter = inParams.iterator(); - while(inParamsIter.hasNext()){ - curParam = curServiceModel.getParam(inParamsIter.next()); - curInParam = new HashMap(); - curInParam.put("entityName", curParam.entityName); - curInParam.put("fieldName", curParam.fieldName); - curInParam.put("internal", curParam.internal ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse")); - curInParam.put("mode", curParam.mode); - curInParam.put("name", curParam.name); - curInParam.put("optional", curParam.optional ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse")); - curInParam.put("type", curParam.type); - inParamsList.add(curInParam); - } - inParamMap = new HashMap(); - inParamMap.put("title", uiLabelMap.get("WebtoolsInParameters")); - inParamMap.put("paramList", inParamsList); - allParamsList.add(inParamMap); + inParamsList = new ArrayList(inParams.size()); + imParams.each { paramName -> + curParam = curServiceModel.getParam(paramName); + curInParam = [:]; + curInParam.entityName = curParam.entityName; + curInParam.fieldName = curParam.fieldName; + curInParam.internal = curParam.internal ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; + curInParam.mode = curParam.mode; + curInParam.name = curParam.name; + curInParam.optional = curParam.optional ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; + curInParam.type = curParam.type; + inParamsList.add(curInParam); } + inParamMap = [:]; + inParamMap.title = uiLabelMap.WebtoolsInParameters; + inParamMap.paramList = inParamsList; + allParamsList.add(inParamMap); outParams = curServiceModel.getOutParamNames(); - if(outParams != null){ - outParamsList = new ArrayList(outParams.size()); - outParamsIter = outParams.iterator(); - while(outParamsIter.hasNext()){ - curParam = curServiceModel.getParam(outParamsIter.next()); - curOutParam = new HashMap(); - curOutParam.put("entityName", curParam.entityName); - curOutParam.put("fieldName", curParam.fieldName); - curOutParam.put("internal", curParam.internal ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse")); - curOutParam.put("mode", curParam.mode); - curOutParam.put("name", curParam.name); - curOutParam.put("optional", curParam.optional ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse")); - curOutParam.put("type", curParam.type); - outParamsList.add(curOutParam); - } - outParamMap = new HashMap(); - outParamMap.put("title", uiLabelMap.get("WebtoolsOutParameters")); - outParamMap.put("paramList", outParamsList); - allParamsList.add(outParamMap); + outParamsList = new ArrayList(outParams.size()); + outParams.each { paramName -> + curParam = curServiceModel.getParam(paramName); + curOutParam = [:]; + curOutParam.entityName = curParam.entityName; + curOutParam.fieldName = curParam.fieldName; + curOutParam.internal = curParam.internal ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; + curOutParam.mode = curParam.mode; + curOutParam.name = curParam.name; + curOutParam.optional = curParam.optional ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; + curOutParam.type = curParam.type; + outParamsList.add(curOutParam); } + outParamMap = [:]; + outParamMap.title = uiLabelMap.get("WebtoolsOutParameters"); + outParamMap.paramList = outParamsList; + allParamsList.add(outParamMap); - if(overrideParameters != null && overrideParameters.size() > 0){ + if (overrideParameters) { ovrPrmList = new ArrayList(overrideParameters.size()); - ovrPrmIter = overrideParameters.iterator(); - while(ovrPrmIter.hasNext()){ - curParam = ovrPrmIter.next(); - curOvrPrm = new HashMap(); - curOvrPrm.put("entityName", curParam.entityName); - curOvrPrm.put("fieldName", curParam.fieldName); - curOvrPrm.put("internal", curParam.internal ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse")); - curOvrPrm.put("mode", curParam.mode); - curOvrPrm.put("name", curParam.name); - curOvrPrm.put("optional", curParam.optional ? uiLabelMap.get("CommonTrue") : uiLabelMap.get("CommonFalse")); - curOvrPrm.put("type", curParam.type); + overrideParameters.each { curParam -> + curOvrPrm = [:]; + curOvrPrm.entityName = curParam.entityName; + curOvrPrm.fieldName = curParam.fieldName; + curOvrPrm.internal = curParam.internal ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; + curOvrPrm.mode = curParam.mode; + curOvrPrm.name = curParam.name; + curOvrPrm.optional = curParam.optional ? uiLabelMap.CommonTrue : uiLabelMap.CommonFalse; + curOvrPrm.type = curParam.type; ovrPrmList.add(curOvrPrm); } - ovrParamMap = new HashMap(); - ovrParamMap.put("title", "Override parameters"); - ovrParamMap.put("paramList", ovrPrmList); + ovrParamMap = [:]; + ovrParamMap.title = "Override parameters"; + ovrParamMap.paramList = ovrPrmList; allParamsList.add(ovrParamMap); } - curServiceMap.put("allParamsList", allParamsList); - } - - showWsdl = request.getParameter("show_wsdl"); - if(showWsdl == null || showWsdl.length() == 0){ - showWsdl = request.getAttribute("show_wsdl"); + curServiceMap.allParamsList = allParamsList; } + + showWsdl = parameters.show_wsdl; - if(showWsdl != null && showWsdl.equals("true")) { + if(showWsdl?.equals("true")) { try { - wsdl = curServiceModel.toWSDL("http://" + request.getServerName() + ":" + UtilProperties.getPropertyValue("url.properties", "port.http", "80") + (String) request.getAttribute("_CONTROL_PATH_") + "/SOAPService"); - curServiceMap.put("wsdl", UtilXml.writeXmlDocument(wsdl)); + wsdl = curServiceModel.toWSDL("http://${request.getServerName()}:${UtilProperties.getPropertyValue("url.properties", "port.http", "80")}${parameters._CONTROL_PATH_}/SOAPService"); + curServiceMap.wsdl = UtilXml.writeXmlDocument(wsdl); } catch (WSDLException ex) { - curServiceMap.put("wsdl", ex.getLocalizedMessage()); + curServiceMap.wsdl = ex.getLocalizedMessage(); } - context.put("showWsdl", Boolean.TRUE); + context.showWsdl = true; } - context.put("selectedServiceMap", curServiceMap); + context.selectedServiceMap = curServiceMap; } -if(selectedService == null || selectedService.length() == 0){ +if (!selectedService) { //get constraints if any - constraint = request.getParameter("constraint"); - if(constraint == null || constraint.length() == 0){ - constraint = request.getAttribute("constraint"); - } - + constraint = parameters.constraint; serviceNames = curDispatchContext.getAllServiceNames(); serviceNamesAlphaList = new ArrayList(26); - servicesIter = serviceNames.iterator(); servicesList = new ArrayList(serviceNames.size()); servicesFoundCount = 0; - while(servicesIter.hasNext()){ - serviceName = servicesIter.next(); - + serviceNames.each { serviceName -> //add first char of service name to list - if(serviceName.length() > 0){ - serviceCharAt1 = serviceName.charAt(0); - if(!serviceNamesAlphaList.contains(serviceCharAt1)){ + if(serviceName){ + serviceCharAt1 = serviceName[0]; + if (!serviceNamesAlphaList.contains(serviceCharAt1)) { serviceNamesAlphaList.add(serviceCharAt1); } } //create basic service def - HashMap curServiceMap = new HashMap(); - curServiceMap.put("serviceName", serviceName); + curServiceMap = [:]; + curServiceMap.serviceName = serviceName; curServiceModel = curDispatchContext.getModelService(serviceName); canIncludeService = true; - if(constraint != null && constraint.length() > 0 && curServiceModel != null){ + if (constraint && curServiceModel) { consArr = constraint.split("@"); constraintName = consArr[0]; constraintVal = consArr[1]; - - if(canIncludeService && constraintName.equals("engine_name")){ + + if (constraintName.equals("engine_name")) { canIncludeService = curServiceModel.engineName.equals(constraintVal); - if(constraintVal.equals("NA")){ - canIncludeService = - curServiceModel.engineName == null ||curServiceModel.engineName.equals(""); + if (constraintVal.equals("NA")) { + canIncludeService = curServiceModel.engineName ? false : true; } } - if(canIncludeService && constraintName.equals("default_entity_name")){ + if (canIncludeService && constraintName.equals("default_entity_name")) { canIncludeService = curServiceModel.defaultEntityName.equals(constraintVal); if(constraintVal.equals("NA")){ - canIncludeService = - curServiceModel.defaultEntityName == null ||curServiceModel.defaultEntityName.equals(""); + canIncludeService = curServiceModel.defaultEntityName ? false : true; } } - if(canIncludeService && constraintName.equals("location")){ + if (canIncludeService && constraintName.equals("location")) { canIncludeService = curServiceModel.location.equals(constraintVal); - if(constraintVal.equals("NA")){ - canIncludeService = - curServiceModel.location == null ||curServiceModel.location.equals(""); + if (constraintVal.equals("NA")) { + canIncludeService = curServiceModel.location ? false : true; } } - if(canIncludeService && constraintName.equals("alpha")){ + if (canIncludeService && constraintName.equals("alpha")) { canIncludeService = (serviceName.charAt(0)+"").equals(constraintVal); - if(constraintVal.equals("NA")){ + if (constraintVal.equals("NA")) { canIncludeService = true; } } } - - if(curServiceModel != null && canIncludeService){ - engineName = curServiceModel.engineName; - defaultEntityName = curServiceModel.defaultEntityName; - invoke = curServiceModel.invoke; - location = curServiceModel.location; + if (curServiceModel != null && canIncludeService) { + engineName = curServiceModel.engineName ?: "NA"; + defaultEntityName = curServiceModel.defaultEntityName ?: "NA"; + invoke = curServiceModel.invoke ?: "NA"; + location = curServiceModel.location ?: "NA"; requireNewTransaction = curServiceModel.requireNewTransaction; - engineName = engineName != null && engineName.length() > 0 ? engineName : "NA"; - defaultEntityName = defaultEntityName != null && defaultEntityName.length() > 0 ? defaultEntityName : "NA"; - invoke = invoke != null && invoke.length() > 0 ? invoke : "NA"; - location = location != null && location.length() > 0 ? location : "NA"; - - curServiceMap.put("engineName", engineName); - curServiceMap.put("defaultEntityName", defaultEntityName); - curServiceMap.put("invoke", invoke); - curServiceMap.put("location", location); - curServiceMap.put("requireNewTransaction", requireNewTransaction); + curServiceMap.engineName = engineName; + curServiceMap.defaultEntityName = defaultEntityName; + curServiceMap.invoke = invoke; + curServiceMap.location = location; + curServiceMap.requireNewTransaction = requireNewTransaction; servicesList.add(curServiceMap); servicesFoundCount++; } } - context.put("servicesList", servicesList); - context.put("serviceNamesAlphaList", serviceNamesAlphaList); - context.put("servicesFoundCount", servicesFoundCount); + context.servicesList = servicesList; + context.serviceNamesAlphaList = serviceNamesAlphaList; + context.servicesFoundCount = servicesFoundCount; } Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/scheduleJob.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/scheduleJob.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/scheduleJob.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy Sat Aug 23 22:36:54 2008 @@ -35,48 +35,47 @@ import org.ofbiz.service.engine.GenericEngine; import org.ofbiz.service.config.ServiceConfigUtil; -Map savedSyncResult = null; -if( null!=session.getAttribute("_SAVED_SYNC_RESULT_") ){ - savedSyncResult = (Map)session.getAttribute("_SAVED_SYNC_RESULT_"); +savedSyncResult = null; +if (session.getAttribute("_SAVED_SYNC_RESULT_") != null) { + savedSyncResult = session.getAttribute("_SAVED_SYNC_RESULT_"); } -String serviceName = request.getParameter("SERVICE_NAME"); -context.put("POOL_NAME", ServiceConfigUtil.getSendPool()); +serviceName = parameters.SERVICE_NAME; +context.POOL_NAME = ServiceConfigUtil.getSendPool(); -List scheduleOptions = new ArrayList(); -List serviceParameters = new ArrayList(); -Enumeration e = request.getParameterNames(); +scheduleOptions = []; +serviceParameters = []; +e = request.getParameterNames(); while (e.hasMoreElements()) { - String paramName = (String) e.nextElement(); - String paramValue = request.getParameter(paramName); - scheduleOptions.add(UtilMisc.toMap("name", paramName, "value", paramValue)); + paramName = e.nextElement(); + paramValue = parameters[paramName]; + scheduleOptions.add([name : paramName, value : paramValue]); } -context.put("scheduleOptions", scheduleOptions); +context.scheduleOptions = scheduleOptions; -if (UtilValidate.isNotEmpty(serviceName)) { - DispatchContext dctx = dispatcher.getDispatchContext(); - ModelService model = null; +if (serviceName) { + dctx = dispatcher.getDispatchContext(); + model = null; try { model = dctx.getModelService(serviceName); } catch(Exception exc) { - context.put("errorMessageList", UtilMisc.toList(exc.getMessage())); + context.errorMessageList = [exc.getMessage()]; } if (model != null) { - Iterator params = model.getInParamNames().iterator(); - while (params.hasNext()) { - ModelParam par = model.getParam((String) params.next()); + model.getInParamNames().each { paramName -> + par = model.getParam(paramName); if (par.internal) { - continue; + return; } - Map serviceParam = null; - if(null != savedSyncResult && null != savedSyncResult.get(par.name)){ - serviceParam = UtilMisc.toMap("name", par.name, "type", par.type, "optional", (par.optional? "Y": "N"), "defaultValue", par.defaultValue, "value", savedSyncResult.get(par.name).toString()); - }else{ - serviceParam = UtilMisc.toMap("name", par.name, "type", par.type, "optional", (par.optional? "Y": "N"), "defaultValue", par.defaultValue); + serviceParam = null; + if (savedSyncResult?.get(par.name)) { + serviceParam = [name : par.name, type : par.type, optional : par.optional ? "Y" : "N", defaultValue : par.defaultValue, value : savedSyncResult.get(par.name)]; + } else { + serviceParam = [name : par.name, type : par.type, optional : par.optional ? "Y" : "N", defaultValue : par.defaultValue]; } serviceParameters.add(serviceParam); } } } -context.put("serviceParameters", serviceParameters); +context.serviceParameters = serviceParameters; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ServiceResult.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/serviceResult.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ServiceResult.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ServiceResult.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/serviceResult.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/serviceResult.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ServiceResult.groovy Sat Aug 23 22:36:54 2008 @@ -32,34 +32,30 @@ import javolution.util.FastList; import javolution.util.FastMap; -if(null!=session.getAttribute("_RUN_SYNC_RESULT_")){ - List serviceResultList = FastList.newInstance(); - Map serviceResult = (Map)session.getAttribute("_RUN_SYNC_RESULT_"); +if (session.getAttribute("_RUN_SYNC_RESULT_")) { + serviceResultList = FastList.newInstance(); + serviceResult = session.getAttribute("_RUN_SYNC_RESULT_"); - if(request.getParameter("servicePath")!=null && !request.getParameter("servicePath").equals("")){ - String servicePath = request.getParameter("servicePath"); + if (parameters.servicePath) { + servicePath = parameters.servicePath; newServiceResult = CoreEvents.getObjectFromServicePath(servicePath, serviceResult); - if(null!=newServiceResult && newServiceResult instanceof Map) + if (newServiceResult && newServiceResult instanceof Map) { serviceResult = newServiceResult; - context.put("servicePath", servicePath); + } + context.servicePath = servicePath; } - - Set serviceResultSet = serviceResult.keySet(); - Iterator serviceResultItr = serviceResultSet.iterator(); - while(serviceResultItr.hasNext()){ - String key = serviceResultItr.next(); - Map valueMap = UtilMisc.toMap("key", key, "value", (null==serviceResult.get(key))?"null":serviceResult.get(key).toString()); - if(serviceResult.get(key) instanceof GenericEntity || - serviceResult.get(key) instanceof HashMap || - serviceResult.get(key) instanceof Collection){ - valueMap.put("hasChild", "Y"); - }else{ - valueMap.put("hasChild", "N"); + + serviceResult.each { key, value -> + valueMap = [key : key, value : value.toString()]; + if (value instanceof Map || value instanceof Collection) { + valueMap.hasChild = "Y"; + } else { + valueMap.hasChild = "N"; } serviceResultList.add(valueMap); } - context.put("serviceResultList", serviceResultList); + context.serviceResultList = serviceResultList; } Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Services.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/services.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Services.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Services.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/services.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/services.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Services.groovy Sat Aug 23 22:36:54 2008 @@ -30,26 +30,19 @@ import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilProperties; -locale = UtilHttp.getLocale(request); -request.setAttribute("locale",locale); uiLabelMap = UtilProperties.getResourceBundleMap("WebtoolsUiLabels", locale); uiLabelMap.addBottomResourceBundle("CommonUiLabels"); -Map log = ServiceDispatcher.getServiceLogMap(); -List serviceList = new ArrayList(); -if (log != null) { - Iterator i = log.keySet().iterator(); - while (i.hasNext()) { - Map service = new HashMap(); - RunningService rs = (RunningService) i.next(); +log = ServiceDispatcher.getServiceLogMap(); +serviceList = []; +log.each { rs, value -> + service = [:]; + service.serviceName = rs.getModelService().name; + service.localName = rs.getLocalName(); + service.startTime = rs.getStartStamp(); + service.endTime = rs.getEndStamp(); + service.modeStr = rs.getMode() == GenericEngine.SYNC_MODE ? uiLabelMap.WebtoolsSync : uiLabelMap.WebtoolsAsync; - service.put("serviceName", rs.getModelService().name); - service.put("localName", rs.getLocalName()); - service.put("startTime", rs.getStartStamp()); - service.put("endTime", rs.getEndStamp()); - service.put("modeStr", (rs.getMode() == GenericEngine.SYNC_MODE? uiLabelMap.get("WebtoolsSync") : uiLabelMap.get("WebtoolsAsync"))); - - serviceList.add(service); - } + serviceList.add(service); } -context.put("services", serviceList); +context.services = serviceList; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Threads.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Threads.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Threads.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Threads.groovy Sat Aug 23 22:36:54 2008 @@ -31,36 +31,29 @@ import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilProperties; -locale = UtilHttp.getLocale(request); -request.setAttribute("locale",locale); uiLabelMap = UtilProperties.getResourceBundleMap("WebtoolsUiLabels", locale); uiLabelMap.addBottomResourceBundle("CommonUiLabels"); -List threads = new ArrayList(); -List jobs = dispatcher.getJobManager().processList(); -if (jobs != null) { - Iterator i = jobs.iterator(); - while (i.hasNext()) { - Map job = (Map) i.next(); - String status = uiLabelMap.get("WebtoolsStatusInvalid"); - int state = ((Integer) job.get("status")).intValue(); - switch (state) { - case 0 : status = uiLabelMap.get("WebtoolsStatusSleeping"); break; - case 1 : status = uiLabelMap.get("WebtoolsStatusRunning"); break; - case -1: status = uiLabelMap.get("WebtoolsStatusShuttingDown"); break; - default: status = uiLabelMap.get("WebtoolsStatusInvalid"); break; - } - job.put("status", status); - threads.add(job); +threads = []; +jobs = dispatcher.getJobManager().processList(); +jobs.each { job -> + state = job.status; + switch (state) { + case 0 : status = uiLabelMap.WebtoolsStatusSleeping; break; + case 1 : status = uiLabelMap.WebtoolsStatusRunning; break; + case -1: status = uiLabelMap.WebtoolsStatusShuttingDown; break; + default: status = uiLabelMap.WebtoolsStatusInvalid; break; } + job.status = status; + threads.add(job); } -context.put("threads", threads); +context.threads = threads; // Some stuff for general threads on the server currentThread = Thread.currentThread(); currentThreadGroup = currentThread.getThreadGroup(); topThreadGroup = currentThreadGroup; -while (topThreadGroup.getParent() != null) { +while (topThreadGroup.getParent()) { topThreadGroup = topThreadGroup.getParent(); } @@ -68,4 +61,4 @@ topThreadGroup.enumerate(allThreadArray); allThreadList = Arrays.asList(allThreadArray); -context.put("allThreadList", allThreadList); +context.allThreadList = allThreadList; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.groovy Sat Aug 23 22:36:54 2008 @@ -17,51 +17,43 @@ * under the License. */ -import org.ofbiz.base.util.UtilFormatOut; -import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.*; import org.ofbiz.security.Security; import org.ofbiz.webapp.stats.*; -String id = request.getParameter("statsId"); -String typeStr = request.getParameter("type"); -int type = -1; +id = parameters.statsId; +typeStr = parameters.type; +type = -1; try { - type = Integer.parseInt(typeStr); -} catch (NumberFormatException e) { - type = -1; -} + type = Integer.valueOf(typeStr); +} catch (NumberFormatException e) {} -LinkedList binList = null; +binList = null; if (type == ServerHitBin.REQUEST) { - binList = (LinkedList) ServerHitBin.requestHistory.get(id); + binList = ServerHitBin.requestHistory.get(id); } else if (type == ServerHitBin.EVENT) { - binList = (LinkedList) ServerHitBin.eventHistory.get(id); + binList = ServerHitBin.eventHistory.get(id); } else if (type == ServerHitBin.VIEW) { - binList = (LinkedList) ServerHitBin.viewHistory.get(id); + binList = ServerHitBin.viewHistory.get(id); } -if (binList != null) { - Iterator iterator = binList.iterator(); - if(iterator!=null && iterator.hasNext()){ - List requestList = new ArrayList(); - while(iterator.hasNext()){ - Map requestIdMap = new HashMap(); - ServerHitBin bin = (ServerHitBin) iterator.next(); - if (bin != null) { - requestIdMap.put("requestId", bin.getId()); - requestIdMap.put("requestType", bin.getType()); - requestIdMap.put("startTime", bin.getStartTimeString()); - requestIdMap.put("endTime", bin.getEndTimeString()); - requestIdMap.put("lengthMins", UtilFormatOut.formatQuantity(bin.getBinLengthMinutes())); - requestIdMap.put("numberHits", UtilFormatOut.formatQuantity(bin.getNumberHits())); - requestIdMap.put("minTime", UtilFormatOut.formatQuantity(bin.getMinTimeSeconds())); - requestIdMap.put("avgTime", UtilFormatOut.formatQuantity(bin.getAvgTimeSeconds())); - requestIdMap.put("maxTime", UtilFormatOut.formatQuantity(bin.getMaxTimeSeconds())); - requestIdMap.put("hitsPerMin", UtilFormatOut.formatQuantity(bin.getHitsPerMinute())); - requestList.add(requestIdMap); - } +if (binList) { + requestList = []; + binList.each { bin -> + requestIdMap = [:]; + if (bin != null) { + requestIdMap.requestId = bin.getId(); + requestIdMap.requestType = bin.getType(); + requestIdMap.startTime = bin.getStartTimeString(); + requestIdMap.endTime = bin.getEndTimeString(); + requestIdMap.lengthMins = UtilFormatOut.formatQuantity(bin.getBinLengthMinutes()); + requestIdMap.numberHits = UtilFormatOut.formatQuantity(bin.getNumberHits()); + requestIdMap.minTime = UtilFormatOut.formatQuantity(bin.getMinTimeSeconds()); + requestIdMap.avgTime = UtilFormatOut.formatQuantity(bin.getAvgTimeSeconds()); + requestIdMap.maxTime = UtilFormatOut.formatQuantity(bin.getMaxTimeSeconds()); + requestIdMap.hitsPerMin = UtilFormatOut.formatQuantity(bin.getHitsPerMinute()); + requestList.add(requestIdMap); } - context.put("requestList", requestList); } + context.requestList = requestList; } |
Free forum by Nabble | Edit this page |