All pastes #955655 Raw Edit

Mine

public text v1 · immutable
#955655 ·published 2008-03-24 19:50 UTC
rendered paste body
Index: hostedservices/sws/trunk/src/main/java/com/campgroundautomation/sunrise/kioskservices/sws/CustomerService.java
===================================================================
--- hostedservices/sws/trunk/src/main/java/com/campgroundautomation/sunrise/kioskservices/sws/CustomerService.java      (revision 167)
+++ hostedservices/sws/trunk/src/main/java/com/campgroundautomation/sunrise/kioskservices/sws/CustomerService.java      (working copy)
@@ -20,6 +20,8 @@
 import java.util.*;
 
 import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.exp.*;
+import org.apache.cayenne.query.*;
 import org.apache.cayenne.DataObjectUtils;
 import com.campgroundautomation.sunrise.db.*;
 import com.campgroundautomation.sunrise.kioskservices.sws.*;
@@ -75,4 +77,35 @@
                return DataObjectUtils.intPKForObject(cust);
        }
 
+       @WebMethod
+       public List lookupCustomer(Map criteria){
+               Expression expr = null;
+               Expression tmpExpr;
+               List attributes = new ArrayList();
+
+               attributes.add(Customer.ADDRESS1_PROPERTY);
+               attributes.add(Customer.ADDRESS2_PROPERTY);
+               attributes.add(Customer.CITY_PROPERTY);
+               attributes.add(Customer.FIRST_NAME_PROPERTY);
+               attributes.add(Customer.LAST_NAME_PROPERTY);
+               attributes.add(Customer.LOYALTY_ACCOUNT_CODE_PROPERTY);
+               attributes.add(Customer.MIDDLE_INITIAL_PROPERTY);
+               attributes.add(Customer.PHONE_PROPERTY);
+               attributes.add(Customer.POSTAL_CODE_PROPERTY);
+               attributes.add(Customer.STATE_PROVINCE_PROPERTY);
+               attributes.add(Customer.NUMBER_PROPERTY);
+
+
+               ListIterator<String> itr = attributes.listIterator();
+               while(itr.hasNext()){
+                       String attr = itr.next();
+                       if(criteria.containsKey(attr)){
+                               expr = expr.andExp(ExpressionFactory.matchExp(attr, criteria.get(attr)));
+                       }
+               }
+
+               List customers = context.performQuery(new SelectQuery(Customer.class, expr));
+
+               return customers;
+       } 
 }