[ofbiz-framework] branch trunk updated: Improved: Converted all TimeEntry related CRUD services from simple to entity-auto (#99)

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

[ofbiz-framework] branch trunk updated: Improved: Converted all TimeEntry related CRUD services from simple to entity-auto (#99)

surajk
This is an automated email from the ASF dual-hosted git repository.

surajk 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 cb4ca22  Improved: Converted all TimeEntry related CRUD services from simple to entity-auto (#99)
cb4ca22 is described below

commit cb4ca226f0dcac969decc082115286d750cc3415
Author: Suraj Khurana <[hidden email]>
AuthorDate: Mon May 4 10:42:26 2020 +0530

    Improved: Converted all TimeEntry related CRUD services from simple to entity-auto (#99)
   
    (OFBIZ-11624)
    Also, removed unused services named unlinkInvoiceFromTimeEntry, whcih simply clears TimeEntry field, so used updateTimeEntry instead.
---
 .../webapp/accounting/WEB-INF/controller.xml       |  2 +-
 applications/accounting/widget/InvoiceForms.xml    |  3 ++-
 .../workeffort/minilang/test/WorkEffortTests.xml   | 17 --------------
 .../minilang/timesheet/TimesheetServices.xml       | 27 ----------------------
 applications/workeffort/servicedef/secas.xml       |  3 +++
 .../workeffort/servicedef/services_timesheet.xml   | 13 +++--------
 6 files changed, 9 insertions(+), 56 deletions(-)

diff --git a/applications/accounting/webapp/accounting/WEB-INF/controller.xml b/applications/accounting/webapp/accounting/WEB-INF/controller.xml
index 7116519..4080996 100644
--- a/applications/accounting/webapp/accounting/WEB-INF/controller.xml
+++ b/applications/accounting/webapp/accounting/WEB-INF/controller.xml
@@ -209,7 +209,7 @@ under the License.
     </request-map>
     <request-map uri="unlinkInvoiceFromTimeEntry">
         <security https="true" auth="true"/>
-        <event type="service" invoke="unlinkInvoiceFromTimeEntry"/>
+        <event type="service" invoke="updateTimeEntry"/>
         <response name="success" type="view" value="editInvoiceTimeEntries"/>
         <response name="error" type="view" value="editInvoiceTimeEntries"/>
     </request-map>
diff --git a/applications/accounting/widget/InvoiceForms.xml b/applications/accounting/widget/InvoiceForms.xml
index 25691b4..14ac619 100644
--- a/applications/accounting/widget/InvoiceForms.xml
+++ b/applications/accounting/widget/InvoiceForms.xml
@@ -628,7 +628,8 @@ under the License.
         <field name="deleteLink" title=" " widget-style="buttontext">
             <hyperlink description="${uiLabelMap.CommonDelete}" target="unlinkInvoiceFromTimeEntry" also-hidden="false">
                 <parameter param-name="timeEntryId"/>
-                <parameter param-name="invoiceId"/>
+                <parameter param-name="invoiceId" value="null"/>
+                <parameter param-name="invoiceItemSeqId" value="null"/>
                 <parameter param-name="viewIndex"/>
                 <parameter param-name="viewSize"/>
             </hyperlink>
diff --git a/applications/workeffort/minilang/test/WorkEffortTests.xml b/applications/workeffort/minilang/test/WorkEffortTests.xml
index a93e7a7..6df2933 100644
--- a/applications/workeffort/minilang/test/WorkEffortTests.xml
+++ b/applications/workeffort/minilang/test/WorkEffortTests.xml
@@ -560,21 +560,4 @@ under the License.
         </assert>
         <check-errors/>
     </simple-method>
-    <simple-method method-name="testUnlinkInvoiceFromTimeEntry" short-description="Test the service unlinkInvoiceFromTimeEntry" login-required="false">
-        <set field="serviceCtx.invoiceId" value="TestInvoice"/>
-        <set field="serviceCtx.timeEntryId" value="TestTimeEntry-3"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        <set field="serviceCtx.userLogin" from-field="userLogin"/>
-        <call-service service-name="unlinkInvoiceFromTimeEntry" in-map-name="serviceCtx"/>
-        <entity-one entity-name="TimeEntry" value-field="timeEntry">
-            <field-map field-name="timeEntryId" value="TestTimeEntry-3"/>
-        </entity-one>
-        <assert>
-            <not><if-empty field="timeEntry"/></not>
-            <if-empty field="timeEntry.invoiceId"/>
-        </assert>
-        <check-errors/>
-    </simple-method>
 </simple-methods>
\ No newline at end of file
diff --git a/applications/workeffort/minilang/timesheet/TimesheetServices.xml b/applications/workeffort/minilang/timesheet/TimesheetServices.xml
index 0d48d84..ebf546b 100644
--- a/applications/workeffort/minilang/timesheet/TimesheetServices.xml
+++ b/applications/workeffort/minilang/timesheet/TimesheetServices.xml
@@ -296,22 +296,6 @@ under the License.
     </simple-method>
 
     <!-- TimeEntry Services -->
-    <simple-method method-name="createTimeEntry" short-description="Create TimeEntry">
-        <call-simple-method method-name="checkTimesheetStatus"/>
-        <now-timestamp field="nowTimestamp"/>
-
-        <make-value entity-name="TimeEntry" value-field="newEntity"/>
-        <sequenced-id sequence-name="TimeEntry" field="newEntity.timeEntryId"/>
-        <field-to-result field="newEntity.timeEntryId" result-name="timeEntryId"/>
-
-        <set-nonpk-fields map="parameters" value-field="newEntity"/>
-        <if-empty field="newEntity.fromDate">
-            <call-class-method class-name="org.apache.ofbiz.base.util.UtilDateTime" method-name="getDayStart" ret-field="newEntity.fromDate">
-                <field field="nowTimestamp" type="java.sql.Timestamp"/>
-            </call-class-method>
-        </if-empty>
-        <create-value value-field="newEntity"/>
-    </simple-method>
     <simple-method method-name="updateTimeEntry" short-description="Update TimeEntry">
         <entity-one entity-name="TimeEntry" value-field="lookedUpValue"/>
         <call-simple-method method-name="checkTimesheetStatus"/>
@@ -352,17 +336,6 @@ under the License.
         
         <store-value value-field="lookedUpValue"/>
     </simple-method>
-    <simple-method method-name="deleteTimeEntry" short-description="Delete TimeEntry">
-        <entity-one entity-name="TimeEntry" value-field="lookedUpValue"/>
-        <call-simple-method method-name="checkTimesheetStatus"/>
-        <remove-value value-field="lookedUpValue"/>
-    </simple-method>
-    <simple-method method-name="unlinkInvoiceFromTimeEntry" short-description="Delete TimeEntry">
-        <entity-one entity-name="TimeEntry" value-field="lookedUpValue"/>
-        <field-to-result field="lookedUpValue.invoiceId" result-name="invoiceId"/>
-        <clear-field field="lookedUpValue.invoiceId"/>
-        <store-value value-field="lookedUpValue"/>
-    </simple-method>
     <simple-method method-name="getTimeEntryRate" short-description="Get TimeEntry Rate">
         <entity-one entity-name="TimeEntry" value-field="timeEntry"/>
 
diff --git a/applications/workeffort/servicedef/secas.xml b/applications/workeffort/servicedef/secas.xml
index 502c81d..a29dd25 100644
--- a/applications/workeffort/servicedef/secas.xml
+++ b/applications/workeffort/servicedef/secas.xml
@@ -62,6 +62,9 @@ under the License.
         <condition field-name="orderId" operator="is-empty"/>
         <action service="createOrderHeader" mode="sync"/>
     </eca>
+    <eca service="createTimeEntry" event="invoke">
+        <action service="checkTimesheetStatus" mode="sync"/>
+    </eca>
     <eca service="createTimesheetRole" event="invoke">
         <action service="ensurePartyRole" mode="sync"/>
     </eca>
diff --git a/applications/workeffort/servicedef/services_timesheet.xml b/applications/workeffort/servicedef/services_timesheet.xml
index 9e5f545..014faeb 100644
--- a/applications/workeffort/servicedef/services_timesheet.xml
+++ b/applications/workeffort/servicedef/services_timesheet.xml
@@ -119,11 +119,11 @@ under the License.
     </service>
 
     <!-- TimeEntry Services -->
-    <service name="createTimeEntry" default-entity-name="TimeEntry" engine="simple" auth="true"
-        location="component://workeffort/minilang/timesheet/TimesheetServices.xml" invoke="createTimeEntry">
+    <service name="createTimeEntry" default-entity-name="TimeEntry" engine="entity-auto" auth="true" invoke="create">
         <description>Creates TimeEntry</description>
         <auto-attributes include="pk" mode="OUT" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <override name="fromDate" default-value="${date:nowTimestamp()}"/>
     </service>
     <service name="updateTimeEntry" default-entity-name="TimeEntry" engine="simple" auth="true"
         location="component://workeffort/minilang/timesheet/TimesheetServices.xml" invoke="updateTimeEntry">
@@ -131,17 +131,10 @@ under the License.
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
-    <service name="deleteTimeEntry" default-entity-name="TimeEntry" engine="simple" auth="true"
-        location="component://workeffort/minilang/timesheet/TimesheetServices.xml" invoke="deleteTimeEntry">
+    <service name="deleteTimeEntry" default-entity-name="TimeEntry" engine="entity-auto" auth="true" invoke="delete">
         <description>Deletes TimeEntry</description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
-    <service name="unlinkInvoiceFromTimeEntry" default-entity-name="TimeEntry" engine="simple" auth="true"
-        location="component://workeffort/minilang/timesheet/TimesheetServices.xml" invoke="unlinkInvoiceFromTimeEntry">
-        <description>Deletes TimeEntry</description>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
-        <attribute name="invoiceId" type="String" mode="INOUT" optional="false"/>
-    </service>
     <service name="getTimeEntryRate" default-entity-name="TimeEntry" engine="simple" auth="true"
         location="component://workeffort/minilang/timesheet/TimesheetServices.xml" invoke="getTimeEntryRate">
         <description>Creates TimeEntry</description>