From 615001dda6fcecbbe25756e280a80c3ed20b7eaa Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Fri, 12 Jan 2018 11:27:34 +0000 Subject: [PATCH] "Applied fix from trunk for revision: 1820966 " ------------------------------------------------------------------------ r1820966 | jleroux | 2018-01-12 12:24:48 +0100 (ven., 12 janv. 2018) | 9 lines Fixed: Correcting findOne() in OfbizDslDescriptorForEclipse.dsld (OFBIZ-10159) The method findOne() which is set in the OfbizDslDescriptorForEclipse.dsld is wrong, since there is no implementation for this method, which only has a String and a List as parameters. I changed it to the correct method, so it can be used within groovy properly, also I put an implementation in the GroovyBaseScriptFile Thanks: Dennis Balkir ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1820967 13f79535-47bb-0310-9956-ffa450edef68 --- .../base/OfbizDslDescriptorForEclipse.dsld | 28 +++++++++---------- .../service/engine/GroovyBaseScript.groovy | 7 +++++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld b/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld index 388849e752..f7aea17799 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld +++ b/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld @@ -23,18 +23,18 @@ contribute(currentType(subType('groovy.lang.Script'))) { property name: 'delegator', type: 'org.apache.ofbiz.entity.Delegator' property name: 'dispatcher', type: 'org.apache.ofbiz.service.LocalDispatcher' - method name: 'runService', type: 'java.util.Map', params: [serviceName: 'String', inputMap: 'java.util.Map'] - method name: 'makeValue', type: 'java.util.Map', params: [entityName: 'String'] - method name: 'findOne', type: 'java.util.Map', params: [entityName: 'String', inputMap: 'java.util.Map'] - method name: 'findList', type: 'java.util.List', params: [entityName: 'String', inputMap: 'java.util.Map'] - method name: 'select', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'java.util.Set'] - method name: 'select', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'String...'] - method name: 'from', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'java.lang.Object'] - method name: 'success', type: 'def', params: [message: 'String'] - method name: 'failure', type: 'java.util.Map', params: [message: 'String'] - method name: 'error', type: 'def', params: [message: 'String'] - method name: 'logInfo', type: 'void', params: [message: 'String'] - method name: 'logWarning', type: 'void', params: [message: 'String'] - method name: 'logError', type: 'void', params: [message: 'String'] - method name: 'logVerbose', type: 'void', params: [message: 'String'] + method name: 'runService', type: 'java.util.Map', params: [serviceName: 'String', inputMap: 'java.util.Map'] + method name: 'makeValue', type: 'java.util.Map', params: [entityName: 'String'] + method name: 'findOne', type: 'java.util.Map', params: [entityName: 'String', fields: 'java.util.Map', useCache: 'boolean'] + method name: 'findList', type: 'java.util.List', params: [entityName: 'String', inputMap: 'java.util.Map'] + method name: 'select', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'java.util.Set'] + method name: 'select', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'String...'] + method name: 'from', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'java.lang.Object'] + method name: 'success', type: 'def', params: [message: 'String'] + method name: 'failure', type: 'java.util.Map', params: [message: 'String'] + method name: 'error', type: 'def', params: [message: 'String'] + method name: 'logInfo', type: 'void', params: [message: 'String'] + method name: 'logWarning', type: 'void', params: [message: 'String'] + method name: 'logError', type: 'void', params: [message: 'String'] + method name: 'logVerbose', type: 'void', params: [message: 'String'] } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy b/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy index 1157c01b4f..daea17f8bc 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy +++ b/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy @@ -18,6 +18,8 @@ *******************************************************************************/ package org.apache.ofbiz.service.engine +import java.util.Map + import org.apache.ofbiz.base.util.Debug import org.apache.ofbiz.entity.util.EntityQuery import org.apache.ofbiz.service.DispatchContext @@ -25,6 +27,7 @@ import org.apache.ofbiz.service.LocalDispatcher import org.apache.ofbiz.service.ModelService import org.apache.ofbiz.service.ServiceUtil import org.apache.ofbiz.service.ExecutionServiceException +import org.apache.ofbiz.entity.GenericValue abstract class GroovyBaseScript extends Script { public static final String module = GroovyBaseScript.class.getName() @@ -73,6 +76,10 @@ abstract class GroovyBaseScript extends Script { return EntityQuery.use(binding.getVariable('delegator')).select(fields) } + GenericValue findOne(String entityName, Map fields, boolean useCache) { + return binding.getVariable('delegator').findOne(entityName, fields, useCache) + } + def success(String message) { // TODO: implement some clever i18n mechanism based on the userLogin and locale in the binding if (this.binding.hasVariable('request')) {