ofbiz-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r525850 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java
Date Thu, 05 Apr 2007 15:47:15 GMT
Author: jaz
Date: Thu Apr  5 08:47:14 2007
New Revision: 525850

URL: http://svn.apache.org/viewvc?view=rev&rev=525850
Log:
implemented worker methods to test if a item is available for selling

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java?view=diff&rev=525850&r1=525849&r2=525850
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java Thu
Apr  5 08:47:14 2007
@@ -26,15 +26,13 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.sql.Timestamp;
 import javax.servlet.ServletRequest;
 import javax.servlet.jsp.PageContext;
 
 import org.apache.commons.collections.map.LinkedMap;
 
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.UtilFormatOut;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.*;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
@@ -711,6 +709,31 @@
 
     public static GenericValue findProduct(GenericDelegator delegator, String idToFind) throws
GenericEntityException {
         return findProduct(delegator, idToFind, null);
+    }
+
+    public static boolean isSellable(GenericDelegator delegator, String productId, Timestamp
atTime) throws GenericEntityException {
+        return isSellable(findProduct(delegator, productId), atTime);
+    }
+
+    public static boolean isSellable(GenericDelegator delegator, String productId) throws
GenericEntityException {
+        return isSellable(findProduct(delegator, productId));
+    }
+
+    public static boolean isSellable(GenericValue product) {
+        return isSellable(product, UtilDateTime.nowTimestamp());
+    }
+
+    public static boolean isSellable(GenericValue product, Timestamp atTime) {
+        if (product != null) {
+            Timestamp introDate = product.getTimestamp("introductionDate");
+            Timestamp discDate = product.getTimestamp("salesDiscontinuationDate");
+            if (introDate == null || introDate.before(atTime)) {
+                if (discDate == null || discDate.after(atTime)) {
+                    return true;
+                }
+            }
+        }
+        return false;
     }
 }
 



Mime
View raw message