svn commit: r1816482 - in /ofbiz/ofbiz-framework/trunk/applications/accounting: groovyScripts/budget/ groovyScripts/budget/BudgetServices.groovy minilang/budget/ servicedef/services_budget.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1816482 - in /ofbiz/ofbiz-framework/trunk/applications/accounting: groovyScripts/budget/ groovyScripts/budget/BudgetServices.groovy minilang/budget/ servicedef/services_budget.xml

nmalin
Author: nmalin
Date: Mon Nov 27 18:04:08 2017
New Revision: 1816482

URL: http://svn.apache.org/viewvc?rev=1816482&view=rev
Log:
Improved: Convert BudgetServices.xml mini lang to groovy (OFBIZ-9985)
Just migrate BudgetServices.xml to groovy file version related to OFBIZ-9350 Deprecate Mini Lang
Thanks to Leila Mekika for resolve this issue

Added:
    ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/
    ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy   (with props)
Removed:
    ofbiz/ofbiz-framework/trunk/applications/accounting/minilang/budget/
Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_budget.xml

Added: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy?rev=1816482&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy Mon Nov 27 18:04:08 2017
@@ -0,0 +1,52 @@
+/*
+ * 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.entity.GenericValue
+    
+
+def createBudget() {
+    //create new entity and create all the fields
+    GenericValue newEntity = makeValue('Budget', parameters)
+
+    //create a non existing ID if not supplied
+    newEntity.budgetId = delegator.getNextSeqId('Budget', 1)
+
+    //finally create the record (should not exist already)
+    newEntity.create()
+
+    Map setStatusMap = ['budgetId': newEntity.budgetId]
+    setStatusMap.statusId = 'BG_CREATED'
+    Map result = run service: 'updateBudgetStatus', with: setStatusMap
+    result.budgetId = newEntity.budgetId
+    return result
+}
+
+def updateBudgetStatus() {
+    Map result = success()
+    List budgetStatuses = from('BudgetStatus').where([budgetId: parameters.budgetId]).orderBy('-statusDate').queryList()
+    GenericValue statusValidChange = null
+    if (budgetStatuses) {
+        budgetStatus = budgetStatuses[0]
+        statusValidChange = from('StatusValidChange').where([statusId: budgetStatus.statusId, statusIdTo: parameters.statusId]).queryOne()
+    }
+    if (! budgetStatuses || budgetStatuses && statusValidChange) {
+        result = run service: 'createBudgetStatus', with: parameters
+    }
+    return result
+}

Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_budget.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_budget.xml?rev=1816482&r1=1816481&r2=1816482&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_budget.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_budget.xml Mon Nov 27 18:04:08 2017
@@ -25,8 +25,8 @@ under the License.
     <version>1.0</version>
 
     <!-- Budget  -->
-    <service name="createBudget" default-entity-name="Budget" engine="simple"
-                location="component://accounting/minilang/budget/BudgetServices.xml" invoke="createBudget" auth="true">
+    <service name="createBudget" default-entity-name="Budget" engine="groovy"
+                location="component://accounting/groovyScripts/budget/BudgetServices.groovy" invoke="createBudget" auth="true">
         <description>Create a Budget</description>
         <auto-attributes include="pk" mode="INOUT" optional="true"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
@@ -42,8 +42,8 @@ under the License.
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
-    <service name="updateBudgetStatus" default-entity-name="BudgetStatus" engine="simple"
-                location="component://accounting/minilang/budget/BudgetServices.xml" invoke="updateBudgetStatus">
+    <service name="updateBudgetStatus" default-entity-name="BudgetStatus" engine="groovy"
+                location="component://accounting/groovyScripts/budget/BudgetServices.groovy" invoke="updateBudgetStatus" auth="true">
         <description>Update a Budget</description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>