svn commit: r570297 - in /ofbiz/trunk/framework/entityext: servicedef/services.xml src/org/ofbiz/entityext/EntityWatchServices.java

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

svn commit: r570297 - in /ofbiz/trunk/framework/entityext: servicedef/services.xml src/org/ofbiz/entityext/EntityWatchServices.java

jonesde
Author: jonesde
Date: Mon Aug 27 20:23:23 2007
New Revision: 570297

URL: http://svn.apache.org/viewvc?rev=570297&view=rev
Log:
A few extensions to the watchEntity service

Modified:
    ofbiz/trunk/framework/entityext/servicedef/services.xml
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java

Modified: ofbiz/trunk/framework/entityext/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/servicedef/services.xml?rev=570297&r1=570296&r2=570297&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/entityext/servicedef/services.xml Mon Aug 27 20:23:23 2007
@@ -27,7 +27,7 @@
     <!-- simple generic service to watch and entity through an EECA -->
     <service name="watchEntity" engine="java" location="org.ofbiz.entityext.EntityWatchServices" invoke="watchEntity">
         <attribute name="newValue" type="GenericValue" mode="IN"/>
-        <attribute name="fieldName" type="String" mode="IN"/>
+        <attribute name="fieldName" type="String" mode="IN" optional="true"/>
     </service>
 
     <!-- Entity Engine Extension Services -->

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java?rev=570297&r1=570296&r2=570297&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java Mon Aug 27 20:23:23 2007
@@ -85,15 +85,26 @@
                 }
                 
                 if (changed) {
-                    String errMsg = "Watching entity [" + currentValue.getEntityName() + "] field [" + fieldName + "] value changed from [" + currentFieldValue + "] to [" + newFieldValue + "]";
+                    String errMsg = "Watching entity [" + currentValue.getEntityName() + "] field [" + fieldName + "] value changed from [" + currentFieldValue + "] to [" + newFieldValue + "] for pk [" + newValue.getPrimaryKey() + "]";
                     Debug.log(new Exception(errMsg), errMsg, module);
                 }
             } else {
                 // watch the whole entity
                 if (!currentValue.equals(newValue)) {
-                    String errMsg = "Watching entity [" + currentValue.getEntityName() + "] whole value changed from [" + currentValue + "] to [" + newValue + "]";
+                    String errMsg = "Watching entity [" + currentValue.getEntityName() + "] values changed from [" + currentValue + "] to [" + newValue + "] for pk [" + newValue.getPrimaryKey() + "]";
                     Debug.log(new Exception(errMsg), errMsg, module);
                 }
+            }
+        } else {
+            if (UtilValidate.isNotEmpty(fieldName)) {
+                // just watch the field
+                Object newFieldValue = newValue.get(fieldName);
+                String errMsg = "Watching entity [" + newValue.getEntityName() + "] field [" + fieldName + "] value changed from [null] to [" + newFieldValue + "] for pk [" + newValue.getPrimaryKey() + "]";
+                Debug.log(new Exception(errMsg), errMsg, module);
+            } else {
+                // watch the whole entity
+                String errMsg = "Watching entity [" + newValue.getEntityName() + "] values changed from [null] to [" + newValue + "] for pk [" + newValue.getPrimaryKey() + "]";
+                Debug.log(new Exception(errMsg), errMsg, module);
             }
         }