Author: lektran
Date: Sat Aug 23 22:36:54 2008 New Revision: 688450 URL: http://svn.apache.org/viewvc?rev=688450&view=rev Log: Converted the remaining framework bsh scripts to groovy Added: ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemaFields.groovy - copied, changed from r688198, ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemas.groovy - copied, changed from r688198, ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemas.bsh ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/RunStarSchemaQuery.groovy - copied, changed from r688198, ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/runStarSchemaQuery.bsh ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy - copied, changed from r688198, ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.groovy - copied, changed from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/EditUtilCache.groovy - copied, changed from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/editUtilCache.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCache.groovy - copied, changed from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCache.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCacheElements.groovy - copied, changed from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCacheElements.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.groovy - copied, changed from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.groovy - copied, changed from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/AvailableServices.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/availableservices.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ScheduleJob.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/scheduleJob.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/ServiceResult.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/serviceResult.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Services.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/services.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/Threads.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatsSinceStart.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatsSinceStart.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/workflow/ReadXpdl.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/workflow/readxpdl.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/workflow/WorkflowMonitor.groovy - copied, changed from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/workflow/workflowMonitor.bsh Removed: ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemas.bsh ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/runStarSchemaQuery.bsh ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/editUtilCache.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCache.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCacheElements.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogConfiguration.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/log/LogView.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/period/EditCustomTimePeriod.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/availableservices.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/scheduleJob.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/serviceResult.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/services.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatBinsHistory.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/stats/StatsSinceStart.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/workflow/readxpdl.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/workflow/workflowMonitor.bsh Modified: ofbiz/trunk/framework/bi/widget/BiForms.xml ofbiz/trunk/framework/bi/widget/BiScreens.xml ofbiz/trunk/framework/common/script/org/ofbiz/common/GroovyServiceTest.groovy ofbiz/trunk/framework/common/widget/CommonScreens.xml ofbiz/trunk/framework/webtools/webapp/webtools/artifactinfo/ArtifactInfo.ftl ofbiz/trunk/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp ofbiz/trunk/framework/webtools/widget/ArtifactInfoScreens.xml ofbiz/trunk/framework/webtools/widget/AvailableServicesScreens.xml ofbiz/trunk/framework/webtools/widget/CacheScreens.xml ofbiz/trunk/framework/webtools/widget/EntityScreens.xml ofbiz/trunk/framework/webtools/widget/LogScreens.xml ofbiz/trunk/framework/webtools/widget/MiscScreens.xml ofbiz/trunk/framework/webtools/widget/ServiceScreens.xml ofbiz/trunk/framework/webtools/widget/StatsScreens.xml Copied: ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemaFields.groovy (from r688198, ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemaFields.groovy?p2=ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemaFields.groovy&p1=ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh (original) +++ ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemaFields.groovy Sat Aug 23 22:36:54 2008 @@ -32,30 +32,30 @@ import javolution.util.FastList; import javolution.util.FastMap; -String starSchemaName = parameters.get("starSchemaName"); +starSchemaName = parameters.starSchemaName; -List starSchemaFields = FastList.newInstance(); -if (UtilValidate.isNotEmpty(starSchemaName)) { - ModelReader reader = delegator.getModelReader(); - ModelEntity starSchema = reader.getModelEntity(starSchemaName); - if (UtilValidate.isNotEmpty(starSchema)) { - Iterator fieldsIt = starSchema.getAliasesIterator(); - while (fieldsIt != null && fieldsIt.hasNext()) { - ModelAlias field = (ModelAlias)fieldsIt.next(); - Map fieldMap = FastMap.newInstance(); - fieldMap.put("name", field.getName()); - String description = field.getDescription(); - if (UtilValidate.isEmpty(description)) { - ModelEntity aliasedEntity = starSchema.getAliasedEntity(field.getEntityAlias(), reader); - if (aliasedEntity != null) { - ModelField aliasedField = starSchema.getAliasedField(aliasedEntity, field.getField(), reader); +starSchemaFields = FastList.newInstance(); +if (starSchemaName) { + reader = delegator.getModelReader(); + starSchema = reader.getModelEntity(starSchemaName); + if (starSchema) { + fieldsIt = starSchema.getAliasesIterator(); + while (fieldsIt.hasNext()) { + field = fieldsIt.next(); + fieldMap = FastMap.newInstance(); + fieldMap.name = field.getName(); + description = field.getDescription(); + if (!description) { + aliasedEntity = starSchema.getAliasedEntity(field.getEntityAlias(), reader); + if (aliasedEntity) { + aliasedField = starSchema.getAliasedField(aliasedEntity, field.getField(), reader); description = aliasedField.getDescription(); } } - fieldMap.put("description", description); + fieldMap.description = description; starSchemaFields.add(fieldMap); } } } -context.put("starSchemaName", starSchemaName); -context.put("starSchemaFields", starSchemaFields); +context.starSchemaName = starSchemaName; +context.starSchemaFields = starSchemaFields; Copied: ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemas.groovy (from r688198, ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemas.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemas.groovy?p2=ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemas.groovy&p1=ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemas.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemas.bsh (original) +++ ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemas.groovy Sat Aug 23 22:36:54 2008 @@ -29,24 +29,24 @@ import javolution.util.FastList; import javolution.util.FastMap; -ModelReader reader = delegator.getModelReader(); -Collection ec = reader.getEntityNames(); -TreeSet entities = new TreeSet(ec); -Iterator entitiesIt = entities.iterator(); +reader = delegator.getModelReader(); +ec = reader.getEntityNames(); +entities = new TreeSet(ec); +entitiesIt = entities.iterator(); List starSchemas = FastList.newInstance(); -while (entitiesIt != null && entitiesIt.hasNext()) { - ModelEntity entity = reader.getModelEntity((String)entitiesIt.next()); - String packageName = entity.getPackageName(); +while (entitiesIt.hasNext()) { + entity = reader.getModelEntity(entitiesIt.next()); + packageName = entity.getPackageName(); if (!packageName.contains("starschema")) { continue; } - Map entityMap = FastMap.newInstance(); - entityMap.put("name", entity.getEntityName()); - entityMap.put("title", entity.getTitle()); + entityMap = FastMap.newInstance(); + entityMap.name = entity.getEntityName(); + entityMap.title = entity.getTitle(); starSchemas.add(entityMap); } -context.put("starSchemas", starSchemas); +context.starSchemas = starSchemas; Copied: ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/RunStarSchemaQuery.groovy (from r688198, ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/runStarSchemaQuery.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/RunStarSchemaQuery.groovy?p2=ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/RunStarSchemaQuery.groovy&p1=ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/runStarSchemaQuery.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/runStarSchemaQuery.bsh (original) +++ ofbiz/trunk/framework/bi/webapp/bi/WEB-INF/actions/reportbuilder/RunStarSchemaQuery.groovy Sat Aug 23 22:36:54 2008 @@ -32,13 +32,12 @@ import javolution.util.FastList; import javolution.util.FastMap; -String starSchemaName = parameters.get("starSchemaName"); -String[] selectedFields = request.getParameterValues("selectedField"); -context.put("columnNames", selectedFields); +starSchemaName = parameters.starSchemaName; +selectedFields = parameters.selectedField as Set; +context.columnNames = selectedFields; List conditionList = null; EntityConditionList condition = null; -selectFields = UtilMisc.toSetArray(selectedFields); List orderByFields = null; EntityFindOptions findOptions = null; @@ -52,6 +51,6 @@ findOptions = new EntityFindOptions(); findOptions.setDistinct(false); -records = delegator.findList(starSchemaName, condition, selectFields, orderByFields, findOptions, false); +records = delegator.findList(starSchemaName, condition, selectedFields, orderByFields, findOptions, false); -context.put("records", records); +context.records = records; Modified: ofbiz/trunk/framework/bi/widget/BiForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/bi/widget/BiForms.xml?rev=688450&r1=688449&r2=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/bi/widget/BiForms.xml (original) +++ ofbiz/trunk/framework/bi/widget/BiForms.xml Sat Aug 23 22:36:54 2008 @@ -24,7 +24,7 @@ <form name="selectStarSchema" title="" type="single" target="ReportBuilderSelectStarSchemaFields" header-row-style="header-row" default-table-style="basic-table"> <actions> - <script location="component://bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemas.bsh"/> + <script location="component://bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemas.groovy"/> </actions> <field name="starSchemaName" title="${uiLabelMap.BusinessIntelligenceReportBuilderSelectTheStarSchemaReport}"> <drop-down allow-empty="false"> Modified: ofbiz/trunk/framework/bi/widget/BiScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/bi/widget/BiScreens.xml?rev=688450&r1=688449&r2=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/bi/widget/BiScreens.xml (original) +++ ofbiz/trunk/framework/bi/widget/BiScreens.xml Sat Aug 23 22:36:54 2008 @@ -71,7 +71,7 @@ <actions> <set field="titleProperty" value="BusinessIntelligenceReportBuilderSelectStarSchemaFields"/> <set field="headerItem" value="reportbuilder"/> - <script location="component://bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh"/> + <script location="component://bi/webapp/bi/WEB-INF/actions/reportbuilder/GetStarSchemaFields.groovy"/> </actions> <widgets> <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> @@ -102,7 +102,7 @@ <actions> <set field="titleProperty" value="BusinessIntelligenceReportBuilderRenderStarSchemaReport"/> <set field="headerItem" value="reportbuilder"/> - <script location="component://bi/webapp/bi/WEB-INF/actions/reportbuilder/runStarSchemaQuery.bsh"/> + <script location="component://bi/webapp/bi/WEB-INF/actions/reportbuilder/RunStarSchemaQuery.groovy"/> </actions> <widgets> <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/GroovyServiceTest.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/GroovyServiceTest.groovy?rev=688450&r1=688449&r2=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/common/script/org/ofbiz/common/GroovyServiceTest.groovy (original) +++ ofbiz/trunk/framework/common/script/org/ofbiz/common/GroovyServiceTest.groovy Sat Aug 23 22:36:54 2008 @@ -20,13 +20,13 @@ import org.ofbiz.service.ServiceUtil; import org.ofbiz.base.util.Debug; -Debug.logInfo("-=-=-=- TEST BSH SERVICE -=-=-=-", ""); +Debug.logInfo("-=-=-=- TEST GROOVY SERVICE -=-=-=-", ""); result = ServiceUtil.returnSuccess(); -if (context.message != null) { +if (context.message) { message = context.message; - result.successMessage = "Got message [" + message + "] and finished fine"; + result.successMessage = "Got message [$message] and finished fine"; result.result = message; - Debug.logInfo("----- Message is: " + message + " -----", ""); + Debug.logInfo("----- Message is: $message -----", ""); } else { result.successMessage = "Got no message but finished fine anyway"; result.result = "[no message received]"; Copied: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy (from r688198, ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy?p2=ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy&p1=ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh (original) +++ ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy Sat Aug 23 22:36:54 2008 @@ -28,14 +28,14 @@ import org.ofbiz.base.util.UtilValidate; andExprs = FastList.newInstance(); -fieldValue = request.getParameter(fieldName); -if (UtilValidate.isNotEmpty(fieldValue)) { +fieldValue = parameters[fieldName]; +if (fieldValue) { andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue(fieldName)), EntityOperator.LIKE, "%" + fieldValue.toUpperCase() + "%")); } -if (andExprs.size() > 0) { +if (andExprs) { entityConditionList = EntityCondition.makeCondition(andExprs, EntityOperator.AND); - List autocompleteOptions = delegator.findList(entityName, entityConditionList, new TreeSet(StringUtil.toList(selectFields)), StringUtil.toList(sortByFields), null, false); - context.put("autocompleteOptions", autocompleteOptions); + autocompleteOptions = delegator.findList(entityName, entityConditionList, StringUtil.toList(selectFields) as Set, StringUtil.toList(sortByFields), null, false); + context.autocompleteOptions = autocompleteOptions; } Modified: ofbiz/trunk/framework/common/widget/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/widget/CommonScreens.xml?rev=688450&r1=688449&r2=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/common/widget/CommonScreens.xml (original) +++ ofbiz/trunk/framework/common/widget/CommonScreens.xml Sat Aug 23 22:36:54 2008 @@ -100,7 +100,7 @@ <set field="fieldName" from-field="parameters.fieldName"/> <set field="selectFields" from-field="parameters.selectFields"/> <set field="sortByFields" from-field="parameters.sortByFields"/> - <script location="component://common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh"/> + <script location="component://common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy"/> --> </actions> <widgets> Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.groovy (from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ArtifactInfo.groovy Sat Aug 23 22:36:54 2008 @@ -22,41 +22,40 @@ import org.ofbiz.base.util.*; import javolution.util.FastList; -name = parameters.get("name"); -location = parameters.get("location"); -type = parameters.get("type"); -uniqueId = parameters.get("uniqueId"); +name = parameters.name; +location = parameters.location; +type = parameters.type; +uniqueId = parameters.uniqueId; aif = ArtifactInfoFactory.getArtifactInfoFactory(delegator.getDelegatorName()); -context.put("aif", aif); - +context.aif = aif; artifactInfo = null; -if ("search".equals(parameters.get("findType"))) { +if ("search".equals(parameters.findType)) { artifactInfoSet = aif.getAllArtifactInfosByNamePartial(name, type); if (artifactInfoSet.size() == 1) { - artifactInfo = artifactInfoSet.iterator().next(); - context.put("artifactInfo", artifactInfo); + artifactInfo = artifactInfoSet[0]; + context.artifactInfo = artifactInfo; } else { - context.put("artifactInfoSet", new TreeSet(artifactInfoSet)); + context.artifactInfoSet = new TreeSet(artifactInfoSet); } } else { - if (UtilValidate.isNotEmpty(name)) { + if (name) { artifactInfo = aif.getArtifactInfoByNameAndType(name, location, type); - context.put("artifactInfo", artifactInfo); - } else if (UtilValidate.isNotEmpty(uniqueId)) { + context.artifactInfo = artifactInfo; + } else if (uniqueId) { artifactInfo = aif.getArtifactInfoByUniqueIdAndType(uniqueId, type); - context.put("artifactInfo", artifactInfo); + context.artifactInfo = artifactInfo; } } -if (artifactInfo != null) { +if (artifactInfo) { // add to the recently viewed list recentArtifactInfoList = session.getAttribute("recentArtifactInfoList"); - if (recentArtifactInfoList == null) { + if (!recentArtifactInfoLis) { recentArtifactInfoList = FastList.newInstance(); session.setAttribute("recentArtifactInfoList", recentArtifactInfoList); } - if (recentArtifactInfoList.size() > 0 && recentArtifactInfoList.get(0).equals(artifactInfo)) { + if (recentArtifactInfoList && recentArtifactInfoList.get(0).equals(artifactInfo)) { // hmmm, I guess do nothing if it's already there } else { recentArtifactInfoList.add(0, artifactInfo); Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/EditUtilCache.groovy (from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/editUtilCache.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/EditUtilCache.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/EditUtilCache.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/editUtilCache.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/editUtilCache.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/EditUtilCache.groovy Sat Aug 23 22:36:54 2008 @@ -21,38 +21,38 @@ import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.security.Security; -String cacheName = request.getParameter("UTIL_CACHE_NAME"); -context.put("cacheName", cacheName); +cacheName = parameters.UTIL_CACHE_NAME; +context.cacheName = cacheName; -if (cacheName != null) { - UtilCache utilCache = UtilCache.findCache(cacheName); - if (utilCache != null) { - Map cache = new HashMap(); +if (cacheName) { + utilCache = UtilCache.findCache(cacheName); + if (utilCache) { + cache = [:]; - cache.put("cacheName", utilCache.getName()); - cache.put("cacheSize", UtilFormatOut.formatQuantity(utilCache.size())); - cache.put("hitCount", UtilFormatOut.formatQuantity(utilCache.getHitCount())); - cache.put("missCountTot", UtilFormatOut.formatQuantity(utilCache.getMissCountTotal())); - cache.put("missCountNotFound", UtilFormatOut.formatQuantity(utilCache.getMissCountNotFound())); - cache.put("missCountExpired", UtilFormatOut.formatQuantity(utilCache.getMissCountExpired())); - cache.put("missCountSoftRef", UtilFormatOut.formatQuantity(utilCache.getMissCountSoftRef())); - cache.put("removeHitCount", UtilFormatOut.formatQuantity(utilCache.getRemoveHitCount())); - cache.put("removeMissCount", UtilFormatOut.formatQuantity(utilCache.getRemoveMissCount())); - cache.put("maxSize", UtilFormatOut.formatQuantity(utilCache.getMaxSize())); - cache.put("expireTime", UtilFormatOut.formatQuantity(utilCache.getExpireTime())); - cache.put("useSoftReference", (new Boolean(utilCache.getUseSoftReference())).toString()); - cache.put("useFileSystemStore", (new Boolean(utilCache.getUseFileSystemStore())).toString()); + cache.cacheName = utilCache.getName(); + cache.cacheSize = UtilFormatOut.formatQuantity(utilCache.size()); + cache.hitCount = UtilFormatOut.formatQuantity(utilCache.getHitCount()); + cache.missCountTot = UtilFormatOut.formatQuantity(utilCache.getMissCountTotal()); + cache.missCountNotFound = UtilFormatOut.formatQuantity(utilCache.getMissCountNotFound()); + cache.missCountExpired = UtilFormatOut.formatQuantity(utilCache.getMissCountExpired()); + cache.missCountSoftRef = UtilFormatOut.formatQuantity(utilCache.getMissCountSoftRef()); + cache.removeHitCount = UtilFormatOut.formatQuantity(utilCache.getRemoveHitCount()); + cache.removeMissCount = UtilFormatOut.formatQuantity(utilCache.getRemoveMissCount()); + cache.maxSize = UtilFormatOut.formatQuantity(utilCache.getMaxSize()); + cache.expireTime = UtilFormatOut.formatQuantity(utilCache.getExpireTime()); + cache.useSoftReference = utilCache.getUseSoftReference().toString(); + cache.useFileSystemStore = utilCache.getUseFileSystemStore().toString(); - long exp = utilCache.getExpireTime(); - long hrs = exp/(60*60*1000); - exp = exp%(60*60*1000); - long mins = exp/(60*1000); - exp = exp%(60*1000); - double secs = (double)exp/(1000.0); - cache.put("hrs", UtilFormatOut.formatQuantity(hrs)); - cache.put("mins", UtilFormatOut.formatQuantity(mins)); - cache.put("secs", UtilFormatOut.formatPrice(secs)); - - context.put("cache", cache); + exp = utilCache.getExpireTime(); + hrs = Math.floor(exp / (60 * 60 * 1000)); + exp = exp % (60 * 60 * 1000); + mins = Math.floor(exp / (60 * 1000)); + exp = exp % (60 * 1000); + secs = exp / 1000; + cache.hrs = hrs; + cache.mins = mins; + cache.secs = UtilFormatOut.formatPrice(secs); + + context.cache = cache; } -} \ No newline at end of file +} Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCache.groovy (from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCache.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCache.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCache.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCache.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCache.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCache.groovy Sat Aug 23 22:36:54 2008 @@ -20,45 +20,34 @@ import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.security.Security; -security = request.getAttribute("security"); +context.hasUtilCacheEdit = security.hasEntityPermission("UTIL_CACHE", "_EDIT", session); -if(security.hasEntityPermission("UTIL_CACHE", "_EDIT", session)) { - context.put("hasUtilCacheEdit", Boolean.TRUE); -} -else { - context.put("hasUtilCacheEdit", Boolean.FALSE); -} +rt = Runtime.getRuntime(); +context.memory = UtilFormatOut.formatQuantity(rt.totalMemory()); +context.freeMemory = UtilFormatOut.formatQuantity(rt.freeMemory()); +context.usedMemory = UtilFormatOut.formatQuantity((rt.totalMemory() - rt.freeMemory())); +context.maxMemory = UtilFormatOut.formatQuantity(rt.maxMemory()); -Runtime rt = Runtime.getRuntime(); -context.put("memory", UtilFormatOut.formatQuantity(rt.totalMemory())); -context.put("freeMemory", UtilFormatOut.formatQuantity(rt.freeMemory())); -context.put("usedMemory", UtilFormatOut.formatQuantity((rt.totalMemory() - rt.freeMemory()))); -context.put("maxMemory", UtilFormatOut.formatQuantity(rt.maxMemory())); +cacheList = []; +names = new TreeSet(UtilCache.utilCacheTable.keySet()); +names.each { cacheName -> + utilCache = UtilCache.findCache(cacheName); + cache = [:]; + + cache.cacheName = utilCache.getName(); + cache.cacheSize = UtilFormatOut.formatQuantity(utilCache.size()); + cache.hitCount = UtilFormatOut.formatQuantity(utilCache.getHitCount()); + cache.missCountTot = UtilFormatOut.formatQuantity(utilCache.getMissCountTotal()); + cache.missCountNotFound = UtilFormatOut.formatQuantity(utilCache.getMissCountNotFound()); + cache.missCountExpired = UtilFormatOut.formatQuantity(utilCache.getMissCountExpired()); + cache.missCountSoftRef = UtilFormatOut.formatQuantity(utilCache.getMissCountSoftRef()); + cache.removeHitCount = UtilFormatOut.formatQuantity(utilCache.getRemoveHitCount()); + cache.removeMissCount = UtilFormatOut.formatQuantity(utilCache.getRemoveMissCount()); + cache.maxSize = UtilFormatOut.formatQuantity(utilCache.getMaxSize()); + cache.expireTime = UtilFormatOut.formatQuantity(utilCache.getExpireTime()); + cache.useSoftReference = utilCache.getUseSoftReference().toString(); + cache.useFileSystemStore = utilCache.getUseFileSystemStore().toString(); -List cacheList = new ArrayList(); -TreeSet names = new TreeSet(UtilCache.utilCacheTable.keySet()); -Iterator nameIter = names.iterator(); -if(nameIter != null && nameIter.hasNext()) { - while(nameIter.hasNext()) { - String cacheName = (String)nameIter.next(); - UtilCache utilCache = UtilCache.findCache(cacheName); - Map cache = new HashMap(); - - cache.put("cacheName", utilCache.getName()); - cache.put("cacheSize", UtilFormatOut.formatQuantity(utilCache.size())); - cache.put("hitCount", UtilFormatOut.formatQuantity(utilCache.getHitCount())); - cache.put("missCountTot", UtilFormatOut.formatQuantity(utilCache.getMissCountTotal())); - cache.put("missCountNotFound", UtilFormatOut.formatQuantity(utilCache.getMissCountNotFound())); - cache.put("missCountExpired", UtilFormatOut.formatQuantity(utilCache.getMissCountExpired())); - cache.put("missCountSoftRef", UtilFormatOut.formatQuantity(utilCache.getMissCountSoftRef())); - cache.put("removeHitCount", UtilFormatOut.formatQuantity(utilCache.getRemoveHitCount())); - cache.put("removeMissCount", UtilFormatOut.formatQuantity(utilCache.getRemoveMissCount())); - cache.put("maxSize", UtilFormatOut.formatQuantity(utilCache.getMaxSize())); - cache.put("expireTime", UtilFormatOut.formatQuantity(utilCache.getExpireTime())); - cache.put("useSoftReference", (new Boolean(utilCache.getUseSoftReference())).toString()); - cache.put("useFileSystemStore", (new Boolean(utilCache.getUseFileSystemStore())).toString()); - cacheList.add(cache); - } } -context.put("cacheList", cacheList); \ No newline at end of file +context.cacheList = cacheList; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCacheElements.groovy (from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCacheElements.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCacheElements.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCacheElements.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCacheElements.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/findUtilCacheElements.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/cache/FindUtilCacheElements.groovy Sat Aug 23 22:36:54 2008 @@ -21,50 +21,39 @@ import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.security.Security; -security = request.getAttribute("security"); +context.hasUtilCacheEdit = security.hasEntityPermission("UTIL_CACHE", "_EDIT", session); -if(security.hasEntityPermission("UTIL_CACHE", "_EDIT", session)) { - context.put("hasUtilCacheEdit", Boolean.TRUE); -} -else { - context.put("hasUtilCacheEdit", Boolean.FALSE); -} - -String cacheName = request.getParameter("UTIL_CACHE_NAME"); -context.put("cacheName", cacheName); -context.put("now", (new Date()).toString()); - -long totalSize = 0; - -List cacheElementsList = new ArrayList(); -if (cacheName != null) { - UtilCache utilCache = UtilCache.findCache(cacheName); - if (utilCache != null) { - Iterator iter = utilCache.cacheLineTable.keySet().iterator(); - if(iter != null && iter.hasNext()) { - int keyNum = 0; - while(iter.hasNext()) { - Map cacheElement = new HashMap(); - Object key = iter.next(); - CacheLine line = (CacheLine) utilCache.cacheLineTable.get(key); - String expireTime = ""; - if(line != null && line.loadTime > 0) { - expireTime = (new Date(line.loadTime + utilCache.getExpireTime())).toString(); - } - long lineSize = line.getSizeInBytes(); - totalSize += lineSize; - - cacheElement.put("elementKey", key); - cacheElement.put("expireTime", expireTime); - cacheElement.put("lineSize", UtilFormatOut.formatQuantity(lineSize)); - cacheElement.put("keyNum", keyNum); - - cacheElementsList.add(cacheElement); - - keyNum++; +cacheName = parameters.UTIL_CACHE_NAME; +context.cacheName = cacheName; +context.now = (new Date()).toString(); + +totalSize = 0; + +cacheElementsList = []; +if (cacheName) { + utilCache = UtilCache.findCache(cacheName); + if (utilCache) { + int keyNum = 0; + utilCache.cacheLineTable.keySet().each { key -> + cacheElement = [:]; + line = utilCache.cacheLineTable.get(key); + expireTime = ""; + if (line?.loadTime > 0) { + expireTime = (new Date(line.loadTime + utilCache.getExpireTime())).toString(); } + lineSize = line.getSizeInBytes(); + totalSize += lineSize; + + cacheElement.elementKey = key; + cacheElement.expireTime = expireTime; + cacheElement.lineSize = UtilFormatOut.formatQuantity(lineSize); + cacheElement.keyNum = keyNum; + + cacheElementsList.add(cacheElement); + + keyNum++; } } } -context.put("totalSize", UtilFormatOut.formatQuantity(totalSize)); -context.put("cacheElementsList", cacheElementsList); \ No newline at end of file +context.totalSize = UtilFormatOut.formatQuantity(totalSize); +context.cacheElementsList = cacheElementsList; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.groovy (from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/CheckDb.groovy Sat Aug 23 22:36:54 2008 @@ -21,124 +21,100 @@ import org.ofbiz.entity.jdbc.DatabaseUtil; import org.ofbiz.entity.model.ModelEntity; -delegator = request.getAttribute("delegator"); -security = request.getAttribute("security"); - -String controlPath = (String)request.getAttribute("_CONTROL_PATH_"); +controlPath = parameters._CONTROL_PATH_; if (security.hasPermission("ENTITY_MAINT", session)) { - boolean addMissing = "true".equals(request.getParameter("addMissing")); - boolean checkFkIdx = "true".equals(request.getParameter("checkFkIdx")); - boolean checkFks = "true".equals(request.getParameter("checkFks")); - boolean checkPks = "true".equals(request.getParameter("checkPks")); - boolean repair = "true".equals(request.getParameter("repair")); - String option = request.getParameter("option"); - String groupName = request.getParameter("groupName"); - String entityName = request.getParameter("entityName"); + addMissing = "true".equals(parameters.addMissing); + checkFkIdx = "true".equals(parameters.checkFkIdx); + checkFks = "true".equals(parameters.checkFks); + checkPks = "true".equals(parameters.checkPks); + repair = "true".equals(parameters.repair); + option = parameters.option; + groupName = parameters.groupName; + entityName = parameters.entityName; - Iterator miter = null; - if (groupName != null && groupName.length() > 0) { - String helperName = delegator.getGroupHelperName(groupName); + if (groupName) { + helperName = delegator.getGroupHelperName(groupName); + + messages = []; + //helper = GenericHelperFactory.getHelper(helperName); + dbUtil = new DatabaseUtil(helperName); + modelEntities = delegator.getModelEntityMapByGroup(groupName); + modelEntityNames = new TreeSet(modelEntities.keySet()); - List messages = new LinkedList(); - //GenericHelper helper = GenericHelperFactory.getHelper(helperName); - DatabaseUtil dbUtil = new DatabaseUtil(helperName); - Map modelEntities = delegator.getModelEntityMapByGroup(groupName); - Set modelEntityNames = new TreeSet(modelEntities.keySet()); - if ("checkupdatetables".equals(option)) { - List fieldsToRepair = null; + fieldsToRepair = null; if (repair) { - fieldsToRepair = new ArrayList(); + fieldsToRepair = []; } dbUtil.checkDb(modelEntities, fieldsToRepair, messages, checkPks, checkFks, checkFkIdx, addMissing); - if (fieldsToRepair != null && fieldsToRepair.size() > 0) { + if (fieldsToRepair) { dbUtil.repairColumnSizeChanges(modelEntities, fieldsToRepair, messages); } } else if ("removetables".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.deleteTable(modelEntity, messages); } } else if ("removetable".equals(option)) { - ModelEntity modelEntity = (ModelEntity) modelEntities.get(entityName); + modelEntity = modelEntities[entityName]; dbUtil.deleteTable(modelEntity, messages); } else if ("removepks".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.deletePrimaryKey(modelEntity, messages); } } else if ("removepk".equals(option)) { - ModelEntity modelEntity = (ModelEntity) modelEntities.get(entityName); + modelEntity = modelEntities[entityName]; dbUtil.deletePrimaryKey(modelEntity, messages); } else if ("createpks".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.createPrimaryKey(modelEntity, messages); } } else if ("createpk".equals(option)) { - ModelEntity modelEntity = (ModelEntity) modelEntities.get(entityName); + modelEntity = modelEntities[entityName]; dbUtil.createPrimaryKey(modelEntity, messages); } else if ("createfkidxs".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.createForeignKeyIndices(modelEntity, messages); } } else if ("removefkidxs".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.deleteForeignKeyIndices(modelEntity, messages); } } else if ("createfks".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.createForeignKeys(modelEntity, modelEntities, messages); } } else if ("removefks".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.deleteForeignKeys(modelEntity, modelEntities, messages); } } else if ("createidx".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.createDeclaredIndices(modelEntity, messages); } } else if ("removeidx".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.deleteDeclaredIndices(modelEntity, messages); } } else if ("updateCharsetCollate".equals(option)) { - Iterator modelEntityNameIter = modelEntityNames.iterator(); - while (modelEntityNameIter.hasNext()) { - String modelEntityName = (String) modelEntityNameIter.next(); - ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName); + modelEntityNames.each { modelEntityName -> + modelEntity = modelEntities[modelEntityName]; dbUtil.updateCharacterSetAndCollation(modelEntity, messages); } } miter = messages.iterator(); - context.put("miters", miter); + context.miters = miter; } - context.put("encodeURLCheckDb", response.encodeURL(controlPath + "/view/checkdb")); - context.put("groupName", (groupName != null) ? groupName : "org.ofbiz"); - context.put("entityName", (entityName != null) ? entityName : ""); + context.encodeURLCheckDb = response.encodeURL(controlPath + "/view/checkdb"); + context.groupName = groupName ?: "org.ofbiz"; + context.entityName = entityName ?: ""; } Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.groovy (from r688198, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh&r1=688198&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.groovy Sat Aug 23 22:36:54 2008 @@ -25,64 +25,55 @@ import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelViewEntity; -delegator = request.getAttribute("delegator"); +mgr = delegator.getModelGroupReader(); +entityGroups = mgr.getGroupNames(delegator.getDelegatorName()).iterator(); -ModelGroupReader mgr = delegator.getModelGroupReader(); -Iterator groupMapIt = mgr.getGroupNames(delegator.getDelegatorName()).iterator(); -List entityGroups = FastList.newInstance(); +filterByGroupName = parameters.filterByGroupName; +context.filterByGroupName = filterByGroupName; -while (groupMapIt.hasNext()) { - entityGroups.add(groupMapIt.next()); -} - -filterByGroupName = parameters.get("filterByGroupName"); -context.put("filterByGroupName", filterByGroupName); - -ModelReader reader = delegator.getModelReader(); -Collection ec = reader.getEntityNames(); -TreeSet entities = new TreeSet(ec); -Iterator classNamesIterator = entities.iterator(); +reader = delegator.getModelReader(); +entities = new TreeSet(reader.getEntityNames()); int colSize = entities.size()/3 + 1; int kIdx = 0; -List entitiesList = new ArrayList(); -while (classNamesIterator != null && classNamesIterator.hasNext()) { - ModelEntity entity = reader.getModelEntity((String)classNamesIterator.next()); +entitiesList = []; +entities.each { entityName -> + entity = reader.getModelEntity(entityName); - if (UtilValidate.isNotEmpty(filterByGroupName) && !filterByGroupName.equals(delegator.getEntityGroupName(entity.getEntityName()))) { - continue; + if (filterByGroupName && !filterByGroupName.equals(delegator.getEntityGroupName(entity.getEntityName()))) { + return; } - String viewEntity = "N"; + viewEntity = "N"; if (entity instanceof ModelViewEntity) { viewEntity = "Y"; } - String entityPermissionView = "N"; + entityPermissionView = "N"; if (security.hasEntityPermission("ENTITY_DATA", "_VIEW", session) || security.hasEntityPermission(entity.getPlainTableName(), "_VIEW", session)) { entityPermissionView = "Y"; } - String entityPermissionCreate = "N"; + entityPermissionCreate = "N"; if (security.hasEntityPermission("ENTITY_DATA", "_CREATE", session) || security.hasEntityPermission(entity.getPlainTableName(), "_CREATE", session)) { entityPermissionCreate = "Y"; } - String changeColumn = "N"; + changeColumn = "N"; kIdx++; if (kIdx >= colSize) { colSize += colSize; changeColumn = "Y"; } - Map entityMap = new HashMap(); - entityMap.put("entityName", entity.getEntityName()); - entityMap.put("entityPermissionView", entityPermissionView); - entityMap.put("entityPermissionCreate", entityPermissionCreate); - entityMap.put("viewEntity", viewEntity); - entityMap.put("changeColumn", changeColumn); + entityMap = [:]; + entityMap.entityName = entity.getEntityName(); + entityMap.entityPermissionView = entityPermissionView; + entityMap.entityPermissionCreate = entityPermissionCreate; + entityMap.viewEntity = viewEntity; + entityMap.changeColumn = changeColumn; entitiesList.add(entityMap); } -context.put("entityGroups", entityGroups); -context.put("entitiesList", entitiesList); +context.entityGroups = entityGroups; +context.entitiesList = entitiesList; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityPerformanceTest.groovy Sat Aug 23 22:36:54 2008 @@ -28,224 +28,222 @@ DecimalFormat decimalFormat = new DecimalFormat("#,##0.#######"); if (security.hasPermission("ENTITY_MAINT", session)) { - double startTime, totalTime, callsPerSecond; - int calls; - List performanceList = new ArrayList(); + performanceList = []; calls = 1000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { - GenericValue dummy = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", "GZ-1000")); - } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); - - Map perfRow = new HashMap(); - perfRow.put("operation", "findByPrimaryKey"); - perfRow.put("entity", "Large:Product"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { + dummy = delegator.findByPrimaryKey("Product", [productId : "GZ-1000"]); + } + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime/1000); + + perfRow = [:]; + perfRow.operation = "findByPrimaryKey"; + perfRow.entity = "Large:Product"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); calls = 10000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { - GenericValue dummy = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", "GZ-1000")); - } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); - - perfRow = new HashMap(); - perfRow.put("operation", "findByPrimaryKeyCache"); - perfRow.put("entity", "Large:Product"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { + dummy = delegator.findByPrimaryKeyCache("Product", [productId : "GZ-1000"]); + } + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); + + perfRow = [:]; + perfRow.operation = "findByPrimaryKeyCache"; + perfRow.entity = "Large:Product"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); calls = 1000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { - GenericValue dummy = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", "_NA_")); - } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); - - perfRow = new HashMap(); - perfRow.put("operation", "findByPrimaryKey"); - perfRow.put("entity", "Small:Party"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { + dummy = delegator.findByPrimaryKey("Party", [partyId : "_NA_"]); + } + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); + + perfRow = [:]; + perfRow.operation = "findByPrimaryKey"; + perfRow.entity = "Small:Party"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); calls = 10000; - startTime = (double) System.currentTimeMillis(); + startTime = System.currentTimeMillis(); for (int i=0; i < calls; i++) { - GenericValue dummy = delegator.findByPrimaryKeyCache("Party", UtilMisc.toMap("partyId", "_NA_")); + dummy = delegator.findByPrimaryKeyCache("Party", [partyId : "_NA_"]); } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); - perfRow = new HashMap(); - perfRow.put("operation", "findByPrimaryKeyCache"); - perfRow.put("entity", "Small:Party"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + perfRow = [:]; + perfRow.operation = "findByPrimaryKeyCache"; + perfRow.entity = "Small:Party"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); - List createTestList = new ArrayList(); + createTestList = []; calls = 1000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { - GenericValue dummy = delegator.makeValue("Product", UtilMisc.toMap("autoCreateKeywords", "N", "description", "Initial Description", "internalName", "Auto-Test Name", "productId", "_~WRITE_TEST~_" + i)); + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { + dummy = delegator.makeValue("Product", [autoCreateKeywords : "N", description : "Initial Description", internalName : "Auto-Test Name", productId : "_~WRITE_TEST~_" + i]); createTestList.add(dummy); delegator.create(dummy); } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); - perfRow = new HashMap(); - perfRow.put("operation", "create"); - perfRow.put("entity", "Large:Product"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + perfRow = [:]; + perfRow.operation = "create"; + perfRow.entity = "Large:Product"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); calls = 1000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { - GenericValue dummy = (GenericValue) createTestList.get(i); - dummy.set("description", "This was a test from the performace BSH"); + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { + dummy = createTestList.get(i); + dummy.description = "This was a test from the performance groovy script"; dummy.store(); } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); - perfRow = new HashMap(); - perfRow.put("operation", "update"); - perfRow.put("entity", "Large:Product"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + perfRow = [:]; + perfRow.operation = "update"; + perfRow.entity = "Large:Product"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); calls = 1000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { - GenericValue dummy = (GenericValue) createTestList.get(i); + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { + dummy = createTestList.get(i); dummy.remove(); } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = (double) calls / (totalTime / 1000); - perfRow = new HashMap(); - perfRow.put("operation", "remove"); - perfRow.put("entity", "Large:Product"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + perfRow = [:]; + perfRow.operation = "remove"; + perfRow.entity = "Large:Product"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); calls = 100000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { - Map ptyMap = new HashMap(); - ptyMap.put("partyId", "_NA_"); - } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); - - perfRow = new HashMap(); - perfRow.put("operation", "new HashMap"); - perfRow.put("entity", "N/A"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { + ptyMap = [:]; + ptyMap.partyId = "_NA_"; + } + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); + + perfRow = [:]; + perfRow.operation = "new HashMap"; + perfRow.entity = "N/A"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); calls = 100000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { - Map ptyMap = UtilMisc.toMap("partyId", "_NA_"); - } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); - - perfRow = new HashMap(); - perfRow.put("operation", "UtilMisc.toMap"); - perfRow.put("entity", "N/A"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { + ptyMap = UtilMisc.toMap("partyId", "_NA_"); + } + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); + + perfRow = [:]; + perfRow.operation = "UtilMisc.toMap"; + perfRow.entity = "N/A"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); - UtilCache utilCache = new UtilCache("test-cache", 0,0, false); + utilCache = new UtilCache("test-cache", 0, 0, false); utilCache.put("testName", "testValue"); calls = 1000000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { utilCache.get("testName"); } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); - perfRow = new HashMap(); - perfRow.put("operation", "UtilCache.get(String) - basic settings"); - perfRow.put("entity", "N/A"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + perfRow = [:]; + perfRow.operation = "UtilCache.get(String) - basic settings"; + perfRow.entity = "N/A"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); - GenericPK testPk = delegator.makePK("Party", UtilMisc.toMap("partyId", "_NA_")); + testPk = delegator.makePK("Party", [partyId : "_NA_"]); utilCache.put(testPk, "testValue"); calls = 1000000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { utilCache.get(testPk); } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime/1000); - perfRow = new HashMap(); - perfRow.put("operation", "UtilCache.get(GenericPK) - basic settings"); - perfRow.put("entity", "N/A"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + perfRow = [:]; + perfRow.operation = "UtilCache.get(GenericPK) - basic settings"; + perfRow.entity = "N/A"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); calls = 1000000; - startTime = (double) System.currentTimeMillis(); - for (int i=0; i < calls; i++) { + startTime = System.currentTimeMillis(); + for (int i = 0; i < calls; i++) { utilCache.put(testPk, "testValue"); } - totalTime = (double) System.currentTimeMillis() - startTime; - callsPerSecond = (double) calls / (totalTime/1000); + totalTime = System.currentTimeMillis() - startTime; + callsPerSecond = calls / (totalTime / 1000); - perfRow = new HashMap(); - perfRow.put("operation", "UtilCache.put(GenericPK) - basic settings"); - perfRow.put("entity", "N/A"); - perfRow.put("calls", decimalFormat.format(calls)); - perfRow.put("seconds", decimalFormat.format(totalTime/1000)); - perfRow.put("secsPerCall", decimalFormat.format(1/callsPerSecond)); - perfRow.put("callsPerSecond", decimalFormat.format(callsPerSecond)); + perfRow = [:]; + perfRow.operation = "UtilCache.put(GenericPK) - basic settings"; + perfRow.entity = "N/A"; + perfRow.calls = decimalFormat.format(calls); + perfRow.seconds = decimalFormat.format(totalTime / 1000); + perfRow.secsPerCall = decimalFormat.format(1 / callsPerSecond); + perfRow.callsPerSecond = decimalFormat.format(callsPerSecond); performanceList.add(perfRow); - context.put("performanceList", performanceList); + context.performanceList = performanceList; } Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRef.groovy Sat Aug 23 22:36:54 2008 @@ -16,18 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -String controlPath = (String)request.getAttribute("_CONTROL_PATH_"); -String list = controlPath + "/view/entityref_list"; -String main = controlPath + "/view/entityref_main"; -String search = (String)request.getParameter("search"); -String forstatic = (String)request.getParameter("forstatic"); +controlPath = parameters._CONTROL_PATH_; +list = "$controlPath/view/entityref_list"; +main = "$controlPath/view/entityref_main"; +search = parameters.search; +forstatic = parameters.forstatic; -if (search != null) { - list = list + "?search=" + search; - main = main + "?search=" + search; -} else if (forstatic != null) { - list = list + "?forstatic=" + forstatic; - main = main + "?forstatic=" + forstatic; +if (search) { + list = "$list?search=$search"; + main = "$main?search=$search"; +} else if (forstatic) { + list = "$list?forstatic=$forstatic"; + main = "$main?forstatic=$forstatic"; } -context.put("encodeUrlList", response.encodeURL(list)); -context.put("encodeUrlMain", response.encodeURL(main)); +context.encodeUrlList = response.encodeURL(list); +context.encodeUrlMain = response.encodeURL(main); Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityRefList.groovy Sat Aug 23 22:36:54 2008 @@ -21,44 +21,35 @@ import org.ofbiz.entity.model.ModelReader; import org.ofbiz.entity.model.ModelEntity; -delegator = request.getAttribute("delegator"); -security = request.getAttribute("security"); - -String controlPath = (String)request.getAttribute("_CONTROL_PATH_"); -context.put("controlPath", controlPath); +controlPath = parameters._CONTROL_PATH_; +context.controlPath = controlPath; if (security.hasPermission("ENTITY_MAINT", session)) { - boolean forstatic = "true".equals(request.getParameter("forstatic")); - context.put("forstatic", forstatic); - - ModelReader reader = delegator.getModelReader(); - Collection ec = reader.getEntityNames(); - TreeSet entities = new TreeSet(ec); - search = (String) request.getParameter("search"); - - TreeSet packageNames = new TreeSet(); - Iterator ecIter = ec.iterator(); - while(ecIter.hasNext()) { - String eName = (String)ecIter.next(); - ModelEntity ent = reader.getModelEntity(eName); + forstatic = "true".equals(parameters.forstatic); + context.forstatic = forstatic; + + reader = delegator.getModelReader(); + ec = reader.getEntityNames(); + entities = new TreeSet(ec); + search = parameters.search; + + packageNames = new TreeSet(); + ec.each { eName -> + ent = reader.getModelEntity(eName); packageNames.add(ent.getPackageName()); } - context.put("packageNames", packageNames); - - List entitiesList = new ArrayList(); - Iterator i = entities.iterator(); - while (i.hasNext()) { - Map entityMap = new HashMap(); - - Object o = i.next(); - String entityName = (String)o; - if (search == null || entityName.toLowerCase().indexOf(search.toLowerCase()) != -1 ) { - String url = (search == null) ? "" : "?search=" + search; - entityMap.put("url", url); + context.packageNames = packageNames; + + entitiesList = []; + entities.each { entityName -> + entityMap = [:]; + if (!search || entityName.toLowerCase().indexOf(search.toLowerCase()) != -1 ) { + url = search ? "?search=$search" : ""; + entityMap.url = url; } - entityMap.put("entityName", entityName); - + entityMap.entityName = entityName; + entitiesList.add(entityMap); } - context.put("entitiesList", entitiesList); + context.entitiesList = entitiesList; } Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntitySQLProcessor.groovy Sat Aug 23 22:36:54 2008 @@ -26,39 +26,34 @@ import org.ofbiz.entity.*; import org.ofbiz.entity.model.ModelGroupReader; -String resultMessage = ""; -ResultSet rs = null; -ArrayList columns = new ArrayList(); -ArrayList records = new ArrayList(); -ArrayList groups = new ArrayList(); -ModelGroupReader mgr = delegator.getModelGroupReader(); -Iterator groupMapIt = mgr.getGroupNames(delegator.getDelegatorName()).iterator(); +resultMessage = ""; +rs = null; +columns = []; +records = []; +mgr = delegator.getModelGroupReader(); +groups = mgr.getGroupNames(delegator.getDelegatorName()); -while (groupMapIt.hasNext()) { - groups.add(groupMapIt.next()); -} - -if (sqlCommand != null && sqlCommand.length() > 0 && selGroup != null && selGroup.length() > 0) { - String helperName = delegator.getGroupHelperName(selGroup); - SQLProcessor du = new SQLProcessor(helperName); +if (sqlCommand && selGroup) { + helperName = delegator.getGroupHelperName(selGroup); + du = new SQLProcessor(helperName); try { if (sqlCommand.toUpperCase().startsWith("SELECT")) { rs = du.executeQuery(sqlCommand); - if (rs != null) { - ResultSetMetaData rsmd = rs.getMetaData(); - int numberOfColumns = rsmd.getColumnCount(); - for (int i = 1; i <= numberOfColumns; i++) { + if (rs) { + rsmd = rs.getMetaData(); + numberOfColumns = rsmd.getColumnCount(); + for (i = 1; i <= numberOfColumns; i++) { columns.add(rsmd.getColumnName(i)); } - boolean rowLimitReached = false; + rowLimitReached = false; while (rs.next()) { if (records.size() >= rowLimit) { - resultMessage = "Returned top " + rowLimit + " rows."; + resultMessage = "Returned top $rowLimit rows."; rowLimitReached = true; break; } - ArrayList record = new ArrayList(); - for (int i = 1; i <= numberOfColumns; i++) { + record = []; + for (i = 1; i <= numberOfColumns; i++) { record.add(rs.getObject(i)); } records.add(record); @@ -68,16 +63,14 @@ } } else { du.prepareStatement(sqlCommand); - int numOfaffectedRows = du.executeUpdate(); - resultMessage = "Affected " + numOfaffectedRows + " rows."; + numOfAffectedRows = du.executeUpdate(); + resultMessage = "Affected $numOfAffectedRows rows."; } } catch(Exception exc) { resultMessage = exc.getMessage(); } } -context.put("groups", groups); -context.put("resultMessage", resultMessage); -context.put("columns", columns); -context.put("records", records); - - +context.groups = groups; +context.resultMessage = resultMessage; +context.columns = columns; +context.records = records; Copied: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.groovy (from r688419, ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.groovy?p2=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.groovy&p1=ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh&r1=688419&r2=688450&rev=688450&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.groovy Sat Aug 23 22:36:54 2008 @@ -23,40 +23,37 @@ import org.ofbiz.entity.model.ModelRelation; import org.ofbiz.entity.model.ModelKeyMap; -delegator = request.getAttribute("delegator"); -security = request.getAttribute("security"); +entityName = parameters.entityName; +context.entityName = entityName; -String entityName = request.getParameter("entityName"); -context.put("entityName", entityName); +reader = delegator.getModelReader(); +modelEntity = reader.getModelEntity(entityName); -ModelReader reader = delegator.getModelReader(); -ModelEntity modelEntity = reader.getModelEntity(entityName); +context.plainTableName = modelEntity.getPlainTableName(); + +hasViewPermission = security.hasEntityPermission("ENTITY_DATA", "_VIEW", session) || security.hasEntityPermission(modelEntity.getPlainTableName(), "_VIEW", session); +context.hasViewPermission = hasViewPermission; + +relations = []; +for (rit = modelEntity.getRelationsIterator(); rit.hasNext();) { + mapRelation = [:]; + + modelRelation = rit.next(); + relFields = []; + for (kit = modelRelation.getKeyMapsIterator(); kit.hasNext();) { + mapFields = [:]; + keyMap = kit.next(); + mapFields.fieldName = keyMap.getFieldName(); + mapFields.relFieldName = keyMap.getRelFieldName(); -context.put("plainTableName", modelEntity.getPlainTableName()); - -boolean hasViewPermission = security.hasEntityPermission("ENTITY_DATA", "_VIEW", session) || security.hasEntityPermission(modelEntity.getPlainTableName(), "_VIEW", session); -context.put("hasViewPermission", hasViewPermission); - -List relations = new ArrayList(); -for (Iterator rit = modelEntity.getRelationsIterator(); rit.hasNext();) { - Map mapRelation = new HashMap(); - - ModelRelation modelRelation = (ModelRelation) rit.next(); - List relFields = new ArrayList(); - for (Iterator kit = modelRelation.getKeyMapsIterator(); kit.hasNext(); ) { - Map mapFields = new HashMap(); - ModelKeyMap keyMap = (ModelKeyMap) kit.next(); - mapFields.put("fieldName", keyMap.getFieldName()); - mapFields.put("relFieldName", keyMap.getRelFieldName()); - relFields.add(mapFields); } - mapRelation.put("relFields", relFields); - mapRelation.put("title", modelRelation.getTitle()); - mapRelation.put("relEntityName", modelRelation.getRelEntityName()); - mapRelation.put("type", modelRelation.getType()); - mapRelation.put("fkName", modelRelation.getFkName()); - + mapRelation.relFields = relFields; + mapRelation.title = modelRelation.getTitle(); + mapRelation.relEntityName = modelRelation.getRelEntityName(); + mapRelation.type = modelRelation.getType(); + mapRelation.fkName = modelRelation.getFkName(); + relations.add(mapRelation); } -context.put("relations", relations); +context.relations = relations; |
Free forum by Nabble | Edit this page |