svn commit: r697423 - in /ofbiz/trunk/specialpurpose/assetmaint: webapp/assetmaint/WEB-INF/actions/assetmaint/ webapp/assetmaint/WEB-INF/actions/workeffort/ widget/

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

svn commit: r697423 - in /ofbiz/trunk/specialpurpose/assetmaint: webapp/assetmaint/WEB-INF/actions/assetmaint/ webapp/assetmaint/WEB-INF/actions/workeffort/ widget/

mrisaliti
Author: mrisaliti
Date: Sat Sep 20 14:26:16 2008
New Revision: 697423

URL: http://svn.apache.org/viewvc?rev=697423&view=rev
Log:
Convert a bsh script to groovy.

Added:
    ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/EditMaint.groovy   (contents, props changed)
      - copied, changed from r697415, ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/editMaint.bsh
    ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy   (contents, props changed)
      - copied, changed from r697415, ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/printFixedAssetMaint.bsh
    ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy   (contents, props changed)
      - copied, changed from r697415, ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.bsh
Removed:
    ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/editMaint.bsh
    ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/printFixedAssetMaint.bsh
    ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.bsh
Modified:
    ofbiz/trunk/specialpurpose/assetmaint/widget/AssetmaintScreens.xml

Copied: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/EditMaint.groovy (from r697415, ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/editMaint.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/EditMaint.groovy?p2=ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/EditMaint.groovy&p1=ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/editMaint.bsh&r1=697415&r2=697423&rev=697423&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/editMaint.bsh (original)
+++ ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/EditMaint.groovy Sat Sep 20 14:26:16 2008
@@ -17,22 +17,21 @@
  * under the License.
  */
 
-import org.ofbiz.base.util.*;
 import org.ofbiz.entity.*;
+import org.ofbiz.entity.condition.*;
 import org.ofbiz.entity.util.*;
 
 // This is a small script to set things up when the EditFixedAssetMaint
 // screen is called from one of the WorkEffort calendar screens.
 // The URL coming from WorkEffort does not contain the maintHistSeqId parameter,
 // so this script will look it up using the workEffortId parameter.
+maintHistSeqId = parameters.maintHistSeqId;
+workEffortId = parameters.workEffortId;
 
-String maintHistSeqId = parameters.get("maintHistSeqId");
-String workEffortId = parameters.get("workEffortId");
-
-if (UtilValidate.isEmpty(maintHistSeqId) && UtilValidate.isNotEmpty(workEffortId)) {
-    GenericValue fixedAssetMaint = EntityUtil.getFirst(delegator.findByAnd("FixedAssetMaint", UtilMisc.toMap("scheduleWorkEffortId", workEffortId)));
-    if (fixedAssetMaint != null) {
-        parameters.put("fixedAssetId", fixedAssetMaint.get("fixedAssetId"));
-        parameters.put("maintHistSeqId", fixedAssetMaint.get("maintHistSeqId"));
+if (!maintHistSeqId && workEffortId) {
+    fixedAssetMaint = EntityUtil.getFirst(delegator.findList("FixedAssetMaint", EntityCondition.makeCondition([scheduleWorkEffortId : workEffortId]), null, null, null, false));
+    if (fixedAssetMaint) {
+        parameters.fixedAssetId = fixedAssetMaint.fixedAssetId;
+        parameters.maintHistSeqId = fixedAssetMaint.maintHistSeqId;
     }
-}
+}
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/EditMaint.groovy
------------------------------------------------------------------------------
    svn:mergeinfo =

Copied: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy (from r697415, ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/printFixedAssetMaint.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy?p2=ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy&p1=ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/printFixedAssetMaint.bsh&r1=697415&r2=697423&rev=697423&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/printFixedAssetMaint.bsh (original)
+++ ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy Sat Sep 20 14:26:16 2008
@@ -17,57 +17,55 @@
 under the License.
 **/
 
-import org.ofbiz.base.util.UtilMisc;
-
+import org.ofbiz.entity.*;
+import org.ofbiz.entity.condition.*;
 
 facility = fixedAsset.getRelatedOne("LocatedAtFacility");
-context.put("locatedAtFacility", facility);
+context.locatedAtFacility = facility;
 
-List fixedAssetIdents = delegator.findByAnd("FixedAssetIdent", UtilMisc.toMap("fixedAssetId",fixedAssetId));
+fixedAssetIdents = delegator.findList("FixedAssetIdent", EntityCondition.makeCondition([fixedAssetId : fixedAssetId]), null, null, null, false);
 fixedAssetIdentValue = "";
-if (fixedAssetIdents !=null) {
- iter = fixedAssetIdents.iterator();
- while (iter.hasNext()) {
- ident = iter.next();
- fixedAssetIdentValue = fixedAssetIdentValue + " " + ident.get("idValue");
- }
+if (fixedAssetIdents) {
+    fixedAssetIdents.each { ident ->
+        fixedAssetIdentValue = fixedAssetIdentValue + " " + ident.idValue;
+    }
 }
-context.put("fixedAssetIdentValue",fixedAssetIdentValue);
+context.fixedAssetIdentValue = fixedAssetIdentValue;
 
 status = fixedAssetMaint.getRelatedOne("StatusItem");
-if (status !=null) {
-    context.put("statusItemDesc",status.getString("description"));
+if (status) {
+    context.statusItemDesc = status.description;
 }
 //context.put("fixedAssetMaint",fixedAssetMaint);
 
 intervalUom = fixedAssetMaint.getRelatedOne("IntervalUom");
-if (intervalUom!=null) {
-    context.put("intervalUomDesc",intervalUom.getString("description"));
+if (intervalUom) {
+    context.intervalUomDesc = intervalUom.description;
 }
 
-instanceOfProductId = fixedAsset.get("instanceOfProductId");
-productMaintSeqId = fixedAssetMaint.get("productMaintSeqId");
-if (productMaintSeqId != null && !productMaintSeqId.equals("")) {
-    productMaint = delegator.findByPrimaryKey("ProductMaint", UtilMisc.toMap("productId", instanceOfProductId,"productMaintSeqId",productMaintSeqId));
-    context.put("productMaintName",productMaint.get("maintName"));
-}
-
-productMaintTypeId = fixedAssetMaint.get("productMaintTypeId");
-if (productMaintTypeId!= null && !productMaintTypeId.equals("")) {
-    productMaintType = delegator.findByPrimaryKey("ProductMaintType", UtilMisc.toMap("productMaintTypeId", productMaintTypeId));
-    if (productMaintType != null) {
-        productMaintTypeDesc = productMaintType.get("description");
-        context.put("productMaintTypeDesc",productMaintTypeDesc);
+instanceOfProductId = fixedAsset.instanceOfProductId;
+productMaintSeqId = fixedAssetMaint.productMaintSeqId;
+if (productMaintSeqId) {
+    productMaint = delegator.findOne("ProductMaint", [productId : instanceOfProductId, productMaintSeqId : productMaintSeqId], false);
+    context.productMaintName = productMaint.maintName;
+}
+
+productMaintTypeId = fixedAssetMaint.productMaintTypeId;
+if (productMaintTypeId) {
+    productMaintType = delegator.findOne("ProductMaintType", [productMaintTypeId : productMaintTypeId], false);
+    if (productMaintType) {
+        productMaintTypeDesc = productMaintType.description;
+        context.productMaintTypeDesc = productMaintTypeDesc;
     }
 }
 
-intervalMeterTypeId = fixedAssetMaint.get("intervalMeterTypeId");
+intervalMeterTypeId = fixedAssetMaint.intervalMeterTypeId;
 productMeterTypeDesc = "";
-if (intervalMeterTypeId!= null && !intervalMeterTypeId.equals("")) {
-    productMeterType = delegator.findByPrimaryKey("ProductMeterType", UtilMisc.toMap("productMeterTypeId", intervalMeterTypeId));
-    productMeterTypeDesc  = productMeterType.get("description");
+if (intervalMeterTypeId) {
+    productMeterType = delegator.findOne("ProductMeterType", [productMeterTypeId : intervalMeterTypeId], false);
+    productMeterTypeDesc  = productMeterType.description;
 }
-context.put("productMeterTypeDesc",productMeterTypeDesc);
+context.productMeterTypeDesc = productMeterTypeDesc;
 
 scheduleWorkEffort = fixedAssetMaint.getRelatedOne("ScheduleWorkEffort");
-context.put("scheduleWorkEffort",scheduleWorkEffort);
+context.scheduleWorkEffort = scheduleWorkEffort;
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy
------------------------------------------------------------------------------
    svn:mergeinfo =

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy (from r697415, ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy?p2=ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy&p1=ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.bsh&r1=697415&r2=697423&rev=697423&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.bsh (original)
+++ ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy Sat Sep 20 14:26:16 2008
@@ -24,18 +24,18 @@
 import org.ofbiz.entity.condition.*;
 import org.ofbiz.entity.util.*;
 
-maintHistSeqId = context.get("maintHistSeqId");
-fixedAssetId = context.get("fixedAssetId");
-workEffortId = context.get("workEffortId");
+maintHistSeqId = context.maintHistSeqId;
+fixedAssetId = context.fixedAssetId;
+workEffortId = context.workEffortId;
 
-if (maintHistSeqId == null) {
-    maintHistSeqId = parameters.get("maintHistSeqId");
+if (!maintHistSeqId) {
+    maintHistSeqId = parameters.maintHistSeqId;
 }
-if (fixedAssetId == null) {
-    fixedAssetId = parameters.get("fixedAssetId");
+if (!fixedAssetId) {
+    fixedAssetId = parameters.fixedAssetId;
 }
-if (workEffortId == null) {
-    workEffortId = parameters.get("workEffortId");
+if (!workEffortId) {
+    workEffortId = parameters.workEffortId;
 }
 
 fixedAssetMaint = null;
@@ -43,42 +43,42 @@
 fixedAsset = null;
 rootWorkEffortId = null;
 
-if (workEffortId != null) {
-    workEffort = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", workEffortId));
-    if (workEffort != null) {
-        if (fixedAssetId == null) {
-            fixedAssetId = workEffort.get("fixedAssetId");
+if (workEffortId) {
+    workEffort = delegator.findOne("WorkEffort", [workEffortId : workEffortId], false);
+    if (workEffort) {
+        if (!fixedAssetId) {
+            fixedAssetId = workEffort.fixedAssetId;
         }
         // If this is a child workeffort, locate the "root" workeffort
-        parentWorkEffort = EntityUtil.getFirst(delegator.findByAnd("WorkEffortAssoc", UtilMisc.toMap("workEffortIdTo", workEffortId)));
-        while (parentWorkEffort != null) {
-            rootWorkEffortId = parentWorkEffort.get("workEffortIdFrom");
-            parentWorkEffort = EntityUtil.getFirst(delegator.findByAnd("WorkEffortAssoc", UtilMisc.toMap("workEffortIdTo", rootWorkEffortId)));
+        parentWorkEffort = EntityUtil.getFirst(delegator.findList("WorkEffortAssoc", EntityCondition.makeCondition([workEffortIdTo : workEffortId]), null, null, null, false));
+        while (parentWorkEffort) {
+            rootWorkEffortId = parentWorkEffort.workEffortIdFrom;
+            parentWorkEffort = EntityUtil.getFirst(delegator.findList("WorkEffortAssoc", EntityCondition.makeCondition([workEffortIdTo : rootWorkEffortId]), null, null, null, false));
         }
     }
 }
 
-if (rootWorkEffortId == null) {
+if (!rootWorkEffortId) {
     rootWorkEffortId = workEffortId;
 }
 
-if (rootWorkEffortId != null) {
-    fixedAssetMaint = EntityUtil.getFirst(delegator.findByAnd("FixedAssetMaint", UtilMisc.toMap("scheduleWorkEffortId", rootWorkEffortId)));
-    if (fixedAssetMaint != null) {
-        maintHistSeqId = fixedAssetMaint.get("maintHistSeqId");
-        if (fixedAssetId == null) {
-            fixedAssetId = fixedAssetMaint.get("fixedAssetId");
+if (rootWorkEffortId) {
+    fixedAssetMaint = EntityUtil.getFirst(delegator.findList("FixedAssetMaint", EntityCondition.makeCondition([scheduleWorkEffortId : rootWorkEffortId]), null, null, null, false));
+    if (fixedAssetMaint) {
+        maintHistSeqId = fixedAssetMaint.maintHistSeqId;
+        if (!fixedAssetId) {
+            fixedAssetId = fixedAssetMaint.fixedAssetId;
         }
     }
 }
 
-if (fixedAssetId != null) {
-    fixedAsset = delegator.findByPrimaryKey("FixedAsset", UtilMisc.toMap("fixedAssetId", fixedAssetId));
+if (fixedAssetId) {
+    fixedAsset = delegator.findOne("FixedAsset", [fixedAssetId : fixedAssetId], false);
 }
 
-context.put("fixedAssetMaint", fixedAssetMaint);      
-context.put("workEffort", workEffort);      
-context.put("fixedAsset", fixedAsset);  
-context.put("maintHistSeqId", maintHistSeqId);      
-context.put("fixedAssetId", fixedAssetId);      
-context.put("workEffortId", workEffortId);
+context.fixedAssetMaint = fixedAssetMaint;
+context.workEffort = workEffort;
+context.fixedAsset = fixedAsset;
+context.maintHistSeqId = maintHistSeqId;
+context.fixedAssetId = fixedAssetId;
+context.workEffortId = workEffortId;
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy
------------------------------------------------------------------------------
    svn:mergeinfo =

Propchange: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/specialpurpose/assetmaint/widget/AssetmaintScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/assetmaint/widget/AssetmaintScreens.xml?rev=697423&r1=697422&r2=697423&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/assetmaint/widget/AssetmaintScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/assetmaint/widget/AssetmaintScreens.xml Sat Sep 20 14:26:16 2008
@@ -92,7 +92,7 @@
         <section>
             <actions>
                 <set field="titleProperty" value="PageTitleEditFixedAssetMaintenance"/>
-                <script location="component://assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/editMaint.bsh"/>
+                <script location="component://assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/EditMaint.groovy"/>
                 <set field="fixedAssetId" from-field="parameters.fixedAssetId"/>
                 <set field="maintHistSeqId" from-field="parameters.maintHistSeqId"/>
                 <entity-one entity-name="FixedAsset" value-name="fixedAsset"/>
@@ -138,7 +138,7 @@
             <actions>
                 <set field="titleProperty" value="PageTitleEditWorkEffort"/>
                 <set field="tabButtonItemFixedAssetMaint" value="EditWorkEfforts"/>
-                <script location="component://assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.bsh"/>
+                <script location="component://assetmaint/webapp/assetmaint/WEB-INF/actions/workeffort/EditWorkEfforts.groovy"/>
                 <set field="fixedAssetId" from-field="parameters.fixedAssetId"/>
             </actions>
             <widgets>
@@ -307,7 +307,7 @@
                     <condition-expr field-name="workEffortId" env-name="workEffortId"/>
                     <order-by field-name="noteId"/>
                 </entity-condition>
-                <script location="component://assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/printFixedAssetMaint.bsh"/>
+                <script location="component://assetmaint/webapp/assetmaint/WEB-INF/actions/assetmaint/PrintFixedAssetMaint.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="GlobalFoDecorator" location="component://common/widget/CommonScreens.xml">