This is an automated email from the ASF dual-hosted git repository.
mbrohl pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/trunk by this push: new 30566a6 Convert Thesaurus services in CommonServices.xml from mini lang to groovy. (OFBIZ-11357) 30566a6 is described below commit 30566a6bde121217f78111830b499ea7cdbe1559 Author: Michael Brohl <[hidden email]> AuthorDate: Sat Feb 22 10:29:35 2020 +0100 Convert Thesaurus services in CommonServices.xml from mini lang to groovy. (OFBIZ-11357) Thanks Wiebke Pätzold for reporting and providing the patch. --- .../common/groovyScripts/CommonServices.groovy | 62 ++++++++++++++++++++++ framework/common/minilang/CommonServices.xml | 32 ----------- framework/common/servicedef/services.xml | 17 +++--- 3 files changed, 71 insertions(+), 40 deletions(-) diff --git a/framework/common/groovyScripts/CommonServices.groovy b/framework/common/groovyScripts/CommonServices.groovy new file mode 100644 index 0000000..64d5fef --- /dev/null +++ b/framework/common/groovyScripts/CommonServices.groovy @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.ofbiz.base.util.UtilProperties +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.entity.GenericValue + + +/** + * Create a KeywordThesaurus + * @return + */ + +def createKeywordThesaurus() { + if(!(security.hasEntityPermission("CATALOG", "_CREATE", parameters.userLogin))) { + return error(UtilProperties.getMessage("CommonUiLabels", "CommonGenericPermissionError", parameters.locale)) + } + + GenericValue newEntity = makeValue("KeywordThesaurus", parameters) + newEntity.enteredKeyword = newEntity.enteredKeyword.toLowerCase() + newEntity.alternateKeyword = newEntity.alternateKeyword.toLowerCase() + newEntity.create() + return success() +} + +/** + * Delete a complete Entry KeywordThesaurus + * @return + */ + +def deleteKeywordThesaurus() { + + if(!(security.hasEntityPermission("CATALOG", "_DELETE", parameters.userLogin))) { + return error(UtilProperties.getMessage("CommonUiLabels", "CommonGenericPermissionError", parameters.locale)) + } + + GenericValue newEntity = makeValue("KeywordThesaurus") + newEntity.enteredKeyword = parameters.enteredKeyword + if (UtilValidate.isNotEmpty(parameters.alternateKeyword)) { + newEntity.alternateKeyword = parameters.alternateKeyword + } + + delegator.removeByAnd("KeywordThesaurus", newEntity) + + return success() +} diff --git a/framework/common/minilang/CommonServices.xml b/framework/common/minilang/CommonServices.xml index 9a11bed..51d465a 100644 --- a/framework/common/minilang/CommonServices.xml +++ b/framework/common/minilang/CommonServices.xml @@ -25,38 +25,6 @@ under the License. <call-simple-method method-name="genericBasePermissionCheck" xml-resource="component://common/minilang/permission/CommonPermissionServices.xml"/> </simple-method> - <simple-method method-name="createKeywordThesaurus" short-description="Create a KeywordThesaurus"> - <check-permission permission="CATALOG" action="_CREATE"> - <fail-property resource="CommonUiLabels" property="CommonGenericPermissionError"/> - </check-permission> - <check-errors/> - <make-value entity-name="KeywordThesaurus" value-field="newEntity"/> - <set-pk-fields map="parameters" value-field="newEntity"/> - <set-nonpk-fields map="parameters" value-field="newEntity"/> - <call-object-method obj-field="newEntity.enteredKeyword" method-name="toLowerCase" ret-field="newEntity.enteredKeyword"/> - <call-object-method obj-field="newEntity.alternateKeyword" method-name="toLowerCase" ret-field="newEntity.alternateKeyword"/> - <create-value value-field="newEntity"/> - </simple-method> - <simple-method method-name="updateKeywordThesaurus" short-description="Update a KeywordThesaurus"> - <check-permission permission="CATALOG" action="_UPDATE"> - <fail-property resource="CommonUiLabels" property="CommonGenericPermissionError"/> - </check-permission> - <check-errors/> - <make-value entity-name="KeywordThesaurus" value-field="newEntity"/> - <set-pk-fields map="parameters" value-field="newEntity"/> - <set-nonpk-fields map="parameters" value-field="newEntity"/> - <store-value value-field="newEntity"/> - </simple-method> - <simple-method method-name="deleteKeywordThesaurus" short-description="Delete a KeywordThesaurus"> - <check-permission permission="CATALOG" action="_DELETE"> - <fail-property resource="CommonUiLabels" property="CommonGenericPermissionError"/> - </check-permission> - <check-errors/> - <make-value entity-name="KeywordThesaurus" value-field="newEntity"/> - <set-pk-fields map="parameters" value-field="newEntity"/> - <remove-by-and entity-name="KeywordThesaurus" map="newEntity"/> - </simple-method> - <!-- Uom Conversion service --> <simple-method method-name="createUomConversionDated" short-description="Create a new dated UOM conversion entity"> <make-value entity-name="UomConversionDated" value-field="newEntity"/> diff --git a/framework/common/servicedef/services.xml b/framework/common/servicedef/services.xml index bbaf7b5..8ce7197 100644 --- a/framework/common/servicedef/services.xml +++ b/framework/common/servicedef/services.xml @@ -280,20 +280,21 @@ under the License. <!-- Keyword Thesaurus services --> - <service name="createKeywordThesaurus" default-entity-name="KeywordThesaurus" engine="simple" - location="component://common/minilang/CommonServices.xml" invoke="createKeywordThesaurus" auth="true"> + <service name="createKeywordThesaurus" default-entity-name="KeywordThesaurus" engine="groovy" + location="component://common/groovyScripts/CommonServices.groovy" invoke="createKeywordThesaurus" auth="true"> <description>Create a Keyword Thesaurus</description> <auto-attributes include="pk" mode="IN" optional="false"/> - <auto-attributes include="nonpk" mode="IN" optional="true"/> + <auto-attributes include="nonpk" mode="IN" optional="false"/> </service> - <service name="updateKeywordThesaurus" default-entity-name="KeywordThesaurus" engine="simple" - location="component://common/minilang/CommonServices.xml" invoke="updateKeywordThesaurus" auth="true"> + <service name="updateKeywordThesaurus" default-entity-name="KeywordThesaurus" engine="entity-auto" + invoke="update" auth="true"> <description>Update a Keyword Thesaurus</description> + <permission-service service-name="commonGenericPermission" main-action="UPDATE"/> <auto-attributes include="pk" mode="IN" optional="false"/> - <auto-attributes include="nonpk" mode="IN" optional="true"/> + <auto-attributes include="nonpk" mode="IN" optional="false"/> </service> - <service name="deleteKeywordThesaurus" default-entity-name="KeywordThesaurus" engine="simple" - location="component://common/minilang/CommonServices.xml" invoke="deleteKeywordThesaurus" auth="true"> + <service name="deleteKeywordThesaurus" default-entity-name="KeywordThesaurus" engine="groovy" + location="component://common/groovyScripts/CommonServices.groovy" invoke="deleteKeywordThesaurus" auth="true"> <description>Delete a Keyword Thesaurus</description> <auto-attributes include="pk" mode="IN" optional="false"/> <override name="alternateKeyword" optional="true"/> |
Free forum by Nabble | Edit this page |