You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/04/05 17:47:15 UTC

svn commit: r525850 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java

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;
     }
 }
 



Re: svn commit: r525850 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java

Posted by Jacques Le Roux <ja...@les7arts.com>.
+1 !

Jacques

>
> Andrew,
>
> Which of the incarnations of this method are actually used? I'd say
> get rid of the rest.
>
> There are lots of methods in various classes in OFBiz that are
> redundant like this and should be eliminated, I'd even like to do
> that with the majority of the methods in the GenericDelegator... it's
> a beast! The problem is with so many methods it makes it harder to
> figure out which one to use than it makes it easier to use the
methods.
>
> That's my opinion on it anyway... and others may disagree... if so
> let's get a thread going around.
>
> -David
>
>
> On Apr 5, 2007, at 11:47 AM, jaz@apache.org wrote:
>
> > 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;
> >      }
> >  }
> >
> >
> >
>
>


Re: svn commit: r525850 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java

Posted by "David E. Jones" <jo...@hotwaxmedia.com>.
Andrew,

Which of the incarnations of this method are actually used? I'd say  
get rid of the rest.

There are lots of methods in various classes in OFBiz that are  
redundant like this and should be eliminated, I'd even like to do  
that with the majority of the methods in the GenericDelegator... it's  
a beast! The problem is with so many methods it makes it harder to  
figure out which one to use than it makes it easier to use the methods.

That's my opinion on it anyway... and others may disagree... if so  
let's get a thread going around.

-David


On Apr 5, 2007, at 11:47 AM, jaz@apache.org wrote:

> 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;
>      }
>  }
>
>
>