KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > server > BizServices


1 package sellwin.server;
2
3 import sellwin.domain.*;
4 import sellwin.db.*;
5 import sellwin.utils.*;
6
7 import java.rmi.*;
8 import java.sql.*;
9 import java.util.*;
10
11 import javax.ejb.*;
12
13 // SellWin http://sourceforge.net/projects/sellwincrm
14
//Contact support@open-app.com for commercial help with SellWin
15
//This software is provided "AS IS", without a warranty of any kind.
16

17 /**
18  * This class is the remote server implementation of
19  * the SellwinSession interface. All client to server
20  * communications goes thru this implementation at the
21  * moment. I've coded this to work in 2-tier form
22  * as well as via EJB or CORBA. Typically, calls to
23  * this class are initiated via the GUI, specifically
24  * the Whiteboard class. The Whiteboard class keeps
25  * the rest of the GUI ignorant of how data is retrieved
26  * from the remote interface, this is good mister fubu.
27  */

28 public class BizServices implements SellwinSession {
29
30     private int DB_TYPE;
31
32     //some security state info for a given user session is
33
//stored in 'login'
34
private Login login;
35
36     //create the low-level database objects
37
//these are declared protected since the EJB interface
38
//will extend this class and needs access to these
39
protected ActivityDB activityDB;
40     protected AddressDB addressDB;
41     protected Admin adminDB;
42     protected AttendeeDB attendeeDB;
43     protected CampaignDB campaignDB;
44     protected CustomerDB customerDB;
45     protected DeleteInfoDB deleteInfoDB;
46     protected StateTaxDB stateTaxDB;
47     protected ContactDB contactDB;
48     protected CustomerInventoryDB custInventoryDB;
49     protected ForecastDB forecastDB;
50     protected LeadDB leadDB;
51     protected OpportunityDB oppDB;
52     protected OrderDB orderDB;
53     protected ProductDB productDB;
54     protected QuoteDB quoteDB;
55     protected QuoteLineDB quoteLineDB;
56     protected RolePermissionDB rolePermissionDB;
57     protected SalesPersonDB salesPersonDB;
58     protected SalesPersonRoleDB salesPersonRoleDB;
59     protected UserGroupDB userGroupDB;
60     protected UserGroupMemberDB ugMemberDB;
61     protected UserRoleDB userRoleDB;
62
63     private Connection con=null;
64
65     /**
66      * construct a BizServices
67      */

68     public BizServices() {
69         Properties props = System.getProperties();
70         String JavaDoc temp = props.getProperty("DBTYPE");
71         if (temp == null) {
72             DB_TYPE = Prefs.ORACLE;
73             System.out.println("ORACLE DB [DEFAULT] TYPE WILL BE USED");
74         }
75         else
76         if (temp.equals("MYSQL")) {
77             System.out.println("MYSQL DB TYPE WILL BE USED");
78             DB_TYPE = Prefs.MYSQL;
79         }
80         else {
81             DB_TYPE = Prefs.ORACLE;
82             System.out.println("unknown DBTYPE specified = [" + temp + "]");
83             System.out.println("ORACLE DB TYPE WILL BE USED AS DEFAULT");
84         }
85         init(DB_TYPE);
86     }
87
88     /***
89      * construct a BizServices specifying a database type
90      * @param dbType the database type , types found in Prefs.java
91      */

92     public BizServices(int dbType) {
93         DB_TYPE = dbType;
94         init(DB_TYPE);
95     }
96
97     /**
98      * construct a 2 tier connection to a database
99      * this will be called only when SellWin is to
100      * be configured to operate in a 2 tier model.
101      * @exception AngError thrown when we can't get
102      * a database connection
103      * @param dbURL the JDBC URL of the database
104      * @param dbID the database ID we are to log in with
105      * @param dbPSW the database password to log in with
106      */

107     public void init2Tier(String JavaDoc dbURL, String JavaDoc dbID, String JavaDoc dbPSW)
108         throws AngError {
109
110         try {
111             if (DB_TYPE == Prefs.ORACLE) {
112                 DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
113                 System.out.println("registered Oracle Driver");
114                 System.out.println("Oracle URL=["+dbURL+"] ID=[" + dbID +"] PSW=["+ dbPSW + "]");
115                 con = DriverManager.getConnection(dbURL, dbID, dbPSW);
116             }
117             else
118             if (DB_TYPE == Prefs.MYSQL) {
119                 DriverManager.registerDriver(new org.gjt.mm.mysql.Driver());
120                 System.out.println("registered MySQL mm Driver");
121                 String JavaDoc mysqlURL = dbURL + "?user=" + dbID + "&password=" + dbPSW;
122                 System.out.println("MYSQL URL=["+mysqlURL+"]");
123                 con = DriverManager.getConnection(mysqlURL);
124             }
125             else {
126                 throw new AngError("Unsupported database: " + DB_TYPE);
127             }
128         
129             con.setAutoCommit(false);
130
131             activityDB.setConnection(con);
132             addressDB.setConnection(con);
133             adminDB.setConnection(con);
134             attendeeDB.setConnection(con);
135             campaignDB.setConnection(con);
136             customerDB.setConnection(con);
137             deleteInfoDB.setConnection(con);
138             stateTaxDB.setConnection(con);
139             contactDB.setConnection(con);
140             custInventoryDB.setConnection(con);
141             forecastDB.setConnection(con);
142             leadDB.setConnection(con);
143             oppDB.setConnection(con);
144             orderDB.setConnection(con);
145             productDB.setConnection(con);
146             quoteDB.setConnection(con);
147             quoteLineDB.setConnection(con);
148             rolePermissionDB.setConnection(con);
149             salesPersonDB.setConnection(con);
150             salesPersonRoleDB.setConnection(con);
151             userGroupDB.setConnection(con);
152             ugMemberDB.setConnection(con);
153             userRoleDB.setConnection(con);
154
155         } catch (Exception JavaDoc e) {
156             System.out.println ("\n Error connecting to Database...\n");
157             e.printStackTrace();
158             throw new AngError(e.getMessage());
159         }
160     }
161
162
163     /**
164      * update a Lead in the database
165      * @param campPK a Campaign primary key that is the
166      * container of this Lead
167      * @param l the Lead we are updating
168      * @exception AngError thrown when an app error occurs
169      */

170     public void updateLead(long campPK, Lead l)
171         throws RemoteException, AngError {
172
173         if (Prefs.DEBUG) System.out.println("BizServices.updateLead");
174         try {
175             l.setCampaignKey(campPK);
176             leadDB.updateRow(l);
177             leadDB.getConnection().commit();
178         } catch (SQLException e) {
179             e.printStackTrace();
180             try { leadDB.getConnection().rollback(); } catch (SQLException x) {}
181             throw new AngError(e.getMessage());
182         }
183     }
184
185     /**
186      * get the Opportunity Index array structure
187      * @param u the SalesPerson we are searching with
188      * @return an ArrayList of OppIndex objects
189      * @exception AngError thrown when an app error occurs
190      */

191     public ArrayList getOpportunityIndex(SalesPerson u)
192         throws RemoteException, AngError {
193     
194         if (Prefs.DEBUG) System.out.println("BizServices.getOpportunityIndex");
195         ArrayList rows=null;
196     
197         try {
198             if (Prefs.DEBUG) System.out.println("getOpportunityIndex ");
199             //u.print();
200
rows = oppDB.selectOppIndexRows(u);
201         } catch (SQLException e) {
202             e.printStackTrace();
203             throw new AngError(e.getMessage());
204         }
205
206         return rows;
207     }
208         
209     /**
210      * get the product matrix ArrayList which is a big
211      * blob of Products that we build quotes with
212      * @return an ArrayList of Product objects
213      * @exception AngError thrown when an app error occurs
214      */

215     public ArrayList getProductMatrix()
216         throws RemoteException, AngError {
217
218         if (Prefs.DEBUG) System.out.println("BizServices.getProductMatrix");
219
220         ArrayList matrix=null;
221
222         try {
223             matrix = productDB.selectMatrixRows();
224         } catch (SQLException e) {
225             e.printStackTrace();
226             throw new AngError(e.getMessage());
227         }
228     
229         return matrix;
230     }
231
232     /**
233      * get the list of Product groups used in the quoting
234      * process
235      * @return an ArrayList of product group objects
236      * @exception AngError thrown when an app error occurs
237      */

238     public ArrayList getProductGroups()
239         throws RemoteException, AngError {
240
241         //currently not used, so not implemented here
242

243         if (Prefs.DEBUG) System.out.println("BizServices.getProductGroups");
244         return new ArrayList();
245     }
246
247     /**
248      * get the ArrayList of Product Line objects used
249      * in the quoting process
250      * @param group a product group to search for
251      * @return the ArrayList of found Product Line objs
252      * @exception AngError thrown when an app error occurs
253      */

254     public ArrayList getProductLines(String JavaDoc group)
255         throws RemoteException, AngError {
256
257         //currently not used, so not implemented here
258

259         if (Prefs.DEBUG) System.out.println("BizServices.getProductLines");
260         return new ArrayList();
261     }
262
263     /**
264      * get all the Products for a given product line
265      * @param group the product group to search in
266      * @param line the product line to search in
267      * @return the ArrayList of foun products
268      * @exception AngError thrown when an app error occurs
269      */

270     public ArrayList getProductsForLine(String JavaDoc group, String JavaDoc line)
271         throws RemoteException, AngError {
272         ArrayList prods = null;
273
274         if (Prefs.DEBUG) System.out.println("BizServices.getProductsForLine");
275         try {
276             prods = productDB.selectByGroupLine(group, line);
277         } catch (SQLException e) {
278             e.printStackTrace();
279             throw new AngError(e.getMessage());
280         }
281     
282         return prods;
283     }
284
285     /**
286      * get a Product object using some criteria
287      * @param group the product group to search
288      * @param line the product line to search
289      * @param name the product name to search
290      * @return the found Product
291      * @exception AngError thrown when an app error occurs
292      */

293     public Product getProduct(String JavaDoc group, String JavaDoc line, String JavaDoc name)
294         throws RemoteException, AngError {
295
296         if (Prefs.DEBUG) System.out.println("BizServices.getProduct");
297         Product product=null;
298
299         try {
300             product = productDB.selectRow(group, line, name);
301         } catch (SQLException e) {
302             e.printStackTrace();
303             throw new AngError(e.getMessage());
304         }
305
306         return product;
307     }
308
309     /**
310      * get a Product object using it's primary key
311      * @param pk the primary key
312      * @return the found Product or null if not found
313      * @exception AngError thrown when an app error occurs
314      */

315     public Product getProduct(long pk)
316         throws RemoteException, AngError {
317
318         if (Prefs.DEBUG) System.out.println("BizServices.getProduct");
319         Product product=null;
320
321         try {
322             product = (Product)productDB.selectRow(new Long JavaDoc(pk));
323         } catch (SQLException e) {
324             e.printStackTrace();
325             throw new AngError(e.getMessage());
326         }
327
328         return product;
329     }
330
331     /**
332      * update a Product
333      * @param product the Product to update
334      * @exception AngError thrown when an app error occurs
335      */

336     public void updateProduct(Product product)
337         throws RemoteException, AngError {
338
339         try {
340             productDB.updateRow(product);
341         } catch (SQLException e) {
342             e.printStackTrace();
343             throw new AngError(e.getMessage());
344         }
345     }
346
347     /**
348      * add a Forecast to the database
349      * @param opportunityPK the Opportunity primary key of the
350      * parent to this Forecast being added
351      * @param a the Forecast we are adding
352      * @return the newly assigned Forecast primary key
353      * @exception AngError thrown when an app error occurs
354      */

355     public long addForecast(long opportunityPK, Forecast a)
356         throws RemoteException, AngError {
357
358         long pk=0L;
359         if (Prefs.DEBUG) System.out.println("BizServices.addForecast");
360
361         try {
362             a.setOppKey(opportunityPK);
363             pk = forecastDB.insertRow(a, false);
364             forecastDB.getConnection().commit();
365         } catch (SQLException e) {
366             e.printStackTrace();
367             try { forecastDB.getConnection().rollback(); } catch (SQLException x) {}
368             throw new AngError(e.getMessage());
369         }
370
371         return pk;
372     }
373
374
375     /**
376      * update the Forecast
377      * @param oppPK the Opportunity primary key of the parent
378      * to this Forecast
379      * @param a the Forecast we are updating
380      * @exception AngError thrown when an app error occurs
381      */

382     public void updateForecast(long oppPK, Forecast a)
383         throws RemoteException, AngError {
384
385         if (Prefs.DEBUG) System.out.println("BizServices.updateForecast");
386         try {
387             a.setOppKey(oppPK);
388             forecastDB.updateRow(a);
389             forecastDB.getConnection().commit();
390         } catch (SQLException e) {
391             e.printStackTrace();
392             try { forecastDB.getConnection().rollback(); } catch (SQLException x) {}
393             throw new AngError(e.getMessage());
394         }
395     }
396
397     /**
398      * delete a Forecast
399      * @param opportunityPK the parent Opportunity's primary key
400      * @param forecastPK the Forecast primary key we delete with
401      * @exception AngError thrown when an app error occurs
402      */

403     public void deleteForecast(long opportunityPK, long forecastPK)
404         throws RemoteException, AngError {
405
406         if (Prefs.DEBUG) System.out.println("BizServices.deleteForecast");
407         try {
408             forecastDB.deleteRow(new Long JavaDoc(forecastPK));
409             forecastDB.getConnection().commit();
410         } catch (SQLException e) {
411             e.printStackTrace();
412             try { forecastDB.getConnection().rollback(); } catch (SQLException x) {}
413             throw new AngError(e.getMessage());
414         }
415     }
416
417     /**
418      * add an Order to the database
419      * @param oppPK the parent Opportunity primary key
420      * @param q the Order we are adding
421      * @return the newly assigned primary key
422      * @exception AngError thrown when an app error occurs
423      */

424     public long addOrder(long oppPK, Order q)
425         throws RemoteException, AngError {
426
427         if (Prefs.DEBUG) System.out.println("BizServices.addOrder");
428         long pk=0L;
429
430         try {
431             q.setOppKey(oppPK);
432             pk = orderDB.insertRow(q, false);
433             orderDB.getConnection().commit();
434         } catch (SQLException e) {
435             e.printStackTrace();
436             try { orderDB.getConnection().rollback(); } catch (SQLException x) {}
437             throw new AngError(e.getMessage());
438         }
439         return pk;
440     }
441
442     /**
443      * update an Order in the database
444      * @param oppPK the parent Opportunity primary key
445      * @param q the Order we are updating
446      * @exception AngError thrown when an app error occurs
447      */

448     public void updateOrder(long oppPK, Order q)
449         throws RemoteException, AngError {
450
451         if (Prefs.DEBUG) System.out.println("BizServices.updateOrder");
452         try {
453             q.setOppKey(oppPK);
454             orderDB.updateRow(q);
455             orderDB.getConnection().commit();
456         } catch (SQLException e) {
457             e.printStackTrace();
458             try { orderDB.getConnection().rollback(); } catch (SQLException x) {}
459             throw new AngError(e.getMessage());
460         }
461     }
462
463     /**
464      * add a Quote to the database
465      * @param oppPK the parent Opportunity primary key
466      * @param q the Quote we are adding
467      * @return the newly assigned Quote primary key
468      * @exception AngError thrown when an app error occurs
469      */

470     public long addQuote(long oppPK, Quote q)
471         throws RemoteException, AngError {
472
473         if (Prefs.DEBUG) System.out.println("BizServices.addQuote");
474         long pk = 0L;
475
476         try {
477             q.setOppPK(oppPK);
478             pk = quoteDB.insertRow(q, false);
479             quoteDB.getConnection().commit();
480         } catch (SQLException e) {
481             e.printStackTrace();
482             try { quoteDB.getConnection().rollback(); } catch (SQLException x) {}
483             throw new AngError(e.getMessage());
484         }
485
486         return pk;
487     }
488
489     /**
490      * update a Quote in the database
491      * @param oppPK the parent Opportunity primary key
492      * @param q the Quote we are updating
493      * @exception AngError thrown when an app error occurs
494      */

495     public void updateQuote(long oppPK, Quote q)
496         throws RemoteException, AngError {
497
498         if (Prefs.DEBUG) System.out.println("BizServices.updateQuote");
499         try {
500             q.setOppPK(oppPK);
501             quoteDB.updateRow(q);
502             quoteDB.getConnection().commit();
503         } catch (SQLException e) {
504             e.printStackTrace();
505             try { quoteDB.getConnection().rollback(); } catch (SQLException x) {}
506             throw new AngError(e.getMessage());
507         }
508     }
509
510     /**
511      * delete a Quote in the database
512      * @param oppPK the parent Opportunity primary key
513      * @param quotePK the Quote primary key we delete with
514      * @exception AngError thrown when an app error occurs
515      */

516     public void deleteQuote(long oppPK, long quotePK)
517         throws RemoteException, AngError {
518         
519         if (Prefs.DEBUG) System.out.println("BizServices.deleteQuote");
520         try {
521             quoteDB.deleteRow(new Long JavaDoc(quotePK));
522             quoteDB.getConnection().commit();
523         } catch (SQLException e) {
524             e.printStackTrace();
525             try { quoteDB.getConnection().rollback(); } catch (SQLException x) {}
526             throw new AngError(e.getMessage());
527         }
528     }
529
530     /**
531      * add a QuoteLine to the database
532      * @param oppPK the parent Opportunity primary key
533      * @param quotePK the parent Quote primary key
534      * @param a the QuoteLine we are adding
535      * @return the newly assigned QuoteLine primary key
536      * @exception AngError thrown when an app error occurs
537      */

538     public long addQuoteLine(long oppPK, long quotePK, QuoteLine a)
539         throws RemoteException, AngError {
540
541         if (Prefs.DEBUG) System.out.println("BizServices.addQuoteLine");
542         long pk = 0L;
543
544         try {
545             a.setQuotePK(quotePK);
546             pk = quoteLineDB.insertRow(a, false);
547             quoteLineDB.getConnection().commit();
548         } catch (SQLException e) {
549             e.printStackTrace();
550             try { quoteLineDB.getConnection().rollback(); } catch (SQLException x) {}
551             throw new AngError(e.getMessage());
552         }
553         return pk;
554     }
555
556     /**
557      * delete a QuoteLine from the database
558      * @param oppPK the primary key of the parent Opportunity
559      * @param quotePK the primary key of the parent Quote
560      * @param linePK the primary key of the QuoteLine we are deleting
561      * @exception AngError thrown when an app error occurs
562      */

563     public void deleteQuoteLine(long oppPK, long quotePK, long linePK)
564         throws RemoteException, AngError {
565         if (Prefs.DEBUG) System.out.println("BizServices.deleteQuoteLine");
566
567         try {
568             quoteLineDB.deleteRow(new Long JavaDoc(linePK));
569             quoteLineDB.getConnection().commit();
570         } catch (SQLException e) {
571             e.printStackTrace();
572             try { quoteLineDB.getConnection().rollback(); } catch (SQLException x) {}
573             throw new AngError(e.getMessage());
574         }
575     }
576
577     /**
578      * get all the Alarms for a given SalesPerson
579      * only for the current day
580      * @param salesPersonPK the primary key of the sales person
581      * we are searching for
582      * @return an ArrayList of all Alarms that pertain
583      * to this sales person
584      * @exception AngError thrown when an app error occurs
585      */

586     public ArrayList getAlarms(long salesPersonPK)
587         throws RemoteException, AngError {
588
589         if (Prefs.DEBUG) System.out.println("BizServices.getAlarms");
590         try {
591             ArrayList acts = activityDB.selectActiveAlarms(salesPersonPK);
592             System.out.println("BizServices.getAlarms acts="+ acts.size());
593             return acts;
594         } catch (SQLException e) {
595             e.printStackTrace();
596             throw new AngError(e.getMessage());
597         }
598     }
599     
600     /**
601      * add an Activity to the database
602      * @param opportunityPK the parent opportunity
603      * @return description
604      * @exception AngError thrown when an app error occurs
605      */

606     public long addActivity(long opportunityPK, Activity a)
607         throws RemoteException, AngError {
608
609         if (Prefs.DEBUG) System.out.println("BizServices.addActivity");
610         long pk = 0L;
611
612         try {
613             a.setOppPK(opportunityPK);
614             pk = activityDB.insertRow(a, false);
615             activityDB.getConnection().commit();
616         } catch (SQLException e) {
617             e.printStackTrace();
618             try { activityDB.getConnection().rollback(); } catch (SQLException x) {}
619             throw new AngError(e.getMessage());
620         }
621         return pk;
622     }
623
624     /**
625      * update an Activity
626      * @param oppPK the containing Opportunity primary key
627      * @param a the Activity we are updating
628      * @exception AngError thrown when an app error occurs
629      */

630     public void updateActivity(long oppPK, Activity a)
631         throws RemoteException, AngError {
632
633         if (Prefs.DEBUG) System.out.println("BizServices.updateActivity");
634         try {
635             a.setOppPK(oppPK);
636             activityDB.updateRow(a);
637             activityDB.getConnection().commit();
638         } catch (SQLException e) {
639             e.printStackTrace();
640             try { activityDB.getConnection().rollback(); } catch (SQLException x) {}
641             throw new AngError(e.getMessage());
642         }
643     }
644
645     /**
646      * delete an Activity
647      * @param opportunityPK the containing opportunity primary key
648      * @param activityPK the primary key of the Activity we are deleting
649      * @exception AngError thrown when an app error occurs
650      */

651     public void deleteActivity(long opportunityPK, long activityPK)
652         throws RemoteException, AngError {
653
654         if (Prefs.DEBUG) System.out.println("BizServices.deleteActivity");
655         try {
656             activityDB.deleteRow(new Long JavaDoc(activityPK));
657             activityDB.getConnection().commit();
658         } catch (SQLException e) {
659             e.printStackTrace();
660             try { activityDB.getConnection().rollback(); } catch (SQLException x) {}
661             throw new AngError(e.getMessage());
662         }
663     }
664
665
666     /**
667      * get all the user roles in the system
668      * @param lastSyncDate a user's last sync date we use in the
669      * query to limit results
670      * @return an ArrayList of all the found data
671      * @exception AngError thrown when an app error occurs
672      */

673     public ArrayList getAllUserRoles(java.util.Date JavaDoc lastSyncDate)
674         throws RemoteException, AngError {
675
676         if (Prefs.DEBUG) System.out.println("BizServices.getAllUserRoles");
677         ArrayList roles=null;
678         try {
679             roles = userRoleDB.selectAllRows(lastSyncDate);
680         } catch (SQLException e) {
681             e.printStackTrace();
682             throw new AngError(e.getMessage());
683         }
684         return roles;
685     }
686
687     /**
688      * load a user role to the system
689      * @param role the user role we are adding
690      * @exception AngError thrown when an app error occurs
691      */

692     public void loadUserRole(UserRole role)
693         throws RemoteException, AngError {
694
695         if (Prefs.DEBUG) System.out.println("BizServices.loadUserRole");
696         long pk=0L;
697
698         try {
699             pk = userRoleDB.insertRow(role, true);
700             userRoleDB.getConnection().commit();
701         } catch (SQLException e) {
702             e.printStackTrace();
703             try { userRoleDB.getConnection().rollback(); } catch (SQLException x) {}
704             throw new AngError(e.getMessage());
705         }
706
707     }
708
709
710     /**
711      * add a user role to the system
712      * @param role the user role we are adding
713      * @exception AngError thrown when an app error occurs
714      */

715     public void addUserRole(UserRole role)
716         throws RemoteException, AngError {
717
718         if (Prefs.DEBUG) System.out.println("BizServices.addUserRole");
719         long pk=0L;
720
721         try {
722             pk = userRoleDB.insertRow(role, false);
723             userRoleDB.getConnection().commit();
724         } catch (SQLException e) {
725             e.printStackTrace();
726             try { userRoleDB.getConnection().rollback(); } catch (SQLException x) {}
727             throw new AngError(e.getMessage());
728         }
729
730     }
731
732     /**
733      * deleta all user roles
734      * @exception AngError thrown when an app error occurs
735      */

736     public void deleteAllUserRole()
737         throws RemoteException, AngError {
738
739         if (Prefs.DEBUG) System.out.println("BizServices.deleteAllUserRole");
740         try {
741             userRoleDB.deleteAllRows();
742             userRoleDB.getConnection().commit();
743         } catch (SQLException e) {
744             e.printStackTrace();
745             try { userRoleDB.getConnection().rollback(); } catch (SQLException x) {}
746             throw new AngError(e.getMessage());
747         }
748     }
749
750     /**
751      * deleta a user role
752      * @param name the name of the user role to delete
753      * @exception AngError thrown when an app error occurs
754      */

755     public void deleteUserRole(long pk)
756         throws RemoteException, AngError {
757
758         if (Prefs.DEBUG) System.out.println("BizServices.deleteUserRole");
759         try {
760             userRoleDB.deleteRow(new Long JavaDoc(pk));
761             userRoleDB.getConnection().commit();
762         } catch (SQLException e) {
763             e.printStackTrace();
764             try { userRoleDB.getConnection().rollback(); } catch (SQLException x) {}
765             throw new AngError(e.getMessage());
766         }
767     }
768
769
770     /**
771      * update a user role
772      * @param role the UserRole we are updating
773      * @exception AngError thrown when an app error occurs
774      */

775     public void updateUserRole(UserRole role)
776         throws RemoteException, AngError {
777
778         if (Prefs.DEBUG) System.out.println("BizServices.updateUserRole");
779         try {
780             userRoleDB.updateRow(role);
781             userRoleDB.getConnection().commit();
782         } catch (SQLException e) {
783             e.printStackTrace();
784             try { userRoleDB.getConnection().rollback(); } catch (SQLException x) {}
785             throw new AngError(e.getMessage());
786         }
787     }
788
789     
790     /**
791      * get a user role
792      * @param name the name of the User Role we are getting
793      * @return the found UserRole
794      * @exception AngError thrown when an app error occurs
795      */

796     public UserRole getUserRole(String JavaDoc name)
797         throws RemoteException, AngError {
798
799         if (Prefs.DEBUG) System.out.println("BizServices.getUserRole");
800         UserRole ur = null;
801         try {
802             ur = userRoleDB.selectRowByName(name);
803         } catch (SQLException e) {
804             e.printStackTrace();
805             throw new AngError(e.getMessage());
806         }
807         return ur;
808     }
809
810
811     /**
812      * logon to the system
813      * @param id the logon id to try
814      * @param psw the logon psw to try
815      * @return a Login credential if successful
816      * @exception AngError thrown when an app error occurs
817      */

818     public Login logon(String JavaDoc id, String JavaDoc psw)
819         throws RemoteException, AngError {
820
821         if (Prefs.DEBUG) System.out.println(id + "/" + psw + " BizServices.logon");
822         try {
823             SalesPerson sp = salesPersonDB.selectRow(id, psw);
824             login = new Login();
825             login.setSalesPerson(sp);
826         } catch (SellwinNotFoundException f) {
827             throw new AngError("Logon failed. Check ID and Password.");
828         } catch (SQLException e) {
829             e.printStackTrace();
830             throw new AngError(e.getMessage());
831         }
832         return login;
833     }
834
835     /**
836      * delete a customer by pk
837      * @param cust the customer to delete
838      * @exception AngError thrown when an app error occurs
839      */

840     public void deleteCustomer(Customer cust)
841         throws RemoteException, AngError {
842
843         if (Prefs.DEBUG) System.out.println("BizServices.deleteCustomer");
844         try {
845             customerDB.deleteRow(cust);
846             customerDB.getConnection().commit();
847         } catch (SQLException e) {
848             e.printStackTrace();
849             try { customerDB.getConnection().rollback(); } catch (SQLException x) {}
850             throw new AngError(e.getMessage());
851         }
852     }
853
854
855     /**
856      * update a customer
857      * @param c the Customer we update
858      * @exception AngError thrown when an app error occurs
859      */

860
861     /**
862      * delete a customer
863      * @param name the customer name to delete with
864      * @exception AngError thrown when an app error occurs
865      */

866     public void deleteCustomer(String JavaDoc name)
867         throws RemoteException, AngError {
868
869         if (Prefs.DEBUG) System.out.println("BizServices.deleteCustomer");
870         try {
871             customerDB.deleteByNameRow(name);
872             customerDB.getConnection().commit();
873         } catch (SQLException e) {
874             e.printStackTrace();
875             try { customerDB.getConnection().rollback(); } catch (SQLException x) {}
876             throw new AngError(e.getMessage());
877         }
878     }
879
880
881     /**
882      * update a customer
883      * @param c the Customer we update
884      * @exception AngError thrown when an app error occurs
885      */

886     public void updateCustomer(Customer c)
887         throws RemoteException, AngError {
888
889         if (Prefs.DEBUG) System.out.println("BizServices.udpateCustomer");
890         try {
891             customerDB.updateRow(c);
892             customerDB.getConnection().commit();
893         } catch (SQLException e) {
894             e.printStackTrace();
895             try { customerDB.getConnection().rollback(); } catch (SQLException x) {}
896             throw new AngError(e.getMessage());
897         }
898     }
899
900     /**
901      * load a customer
902      * @param c the Customer to load
903      * @exception AngError thrown when an app error occurs
904      */

905     public void loadCustomer(Customer c)
906         throws RemoteException, AngError {
907
908         if (Prefs.DEBUG) System.out.println("BizServices.loadCustomer");
909         try {
910             long pk = customerDB.insertRow(c, true);
911             customerDB.getConnection().commit();
912         } catch (SQLException e) {
913             e.printStackTrace();
914             try { customerDB.getConnection().rollback(); } catch (SQLException x) {}
915             throw new AngError(e.getMessage());
916         }
917     }
918
919     /**
920      * add a customer
921      * @param c the Customer to add
922      * @return the primary key of the newly added row
923      * @exception AngError thrown when an app error occurs
924      */

925     public long addCustomer(Customer c)
926         throws RemoteException, AngError {
927
928         if (Prefs.DEBUG) System.out.println("BizServices.addCustomer");
929         long pk=0L;
930         try {
931             pk = customerDB.insertRow(c, false);
932             customerDB.getConnection().commit();
933         } catch (SQLException e) {
934             e.printStackTrace();
935             try { customerDB.getConnection().rollback(); } catch (SQLException x) {}
936             throw new AngError(e.getMessage());
937         }
938         return pk;
939     }
940
941
942     /**
943      * get a customer by name
944      * @param name the customer name to search with
945      * @return the found Customer
946      * @exception AngError thrown when an app error occurs
947      */

948     public Customer getCustomer(String JavaDoc name)
949         throws RemoteException, AngError {
950
951         if (Prefs.DEBUG) System.out.println("BizServices.getCustomer");
952         Customer cust=null;
953         try {
954             cust = customerDB.selectByNameRow(name);
955         } catch (SQLException e) {
956             e.printStackTrace();
957             throw new AngError(e.getMessage());
958         }
959         return cust;
960     }
961
962
963     /**
964      * get all the customer names
965      * @return an array of customer names found
966      * @exception AngError thrown when an app error occurs
967      */

968     public Object JavaDoc[] getAllCustomerNames()
969         throws RemoteException, AngError {
970
971         if (Prefs.DEBUG) System.out.println("BizServices.getAllCustomerNames");
972         TreeMap names = null;
973
974         try {
975             names = customerDB.selectAllNames();
976             return names.values().toArray();
977         } catch (SQLException e) {
978             e.printStackTrace();
979             throw new AngError(e.getMessage());
980         }
981     }
982
983     /**
984      * get a StateTax
985      * @param stateCode the code to key with
986      * @return a StateTax if found null if not found
987      */

988     public StateTax getTax(String JavaDoc code)
989         throws RemoteException, AngError {
990
991         if (Prefs.DEBUG) System.out.println("BizServices.getTax");
992         try {
993             return (StateTax)stateTaxDB.selectRow(code);
994         } catch (SQLException e) {
995             e.printStackTrace();
996             throw new AngError(e.getMessage());
997         }
998     }
999
1000    /**
1001     * update a state tax row
1002     * @param stateTax a StateTax to update
1003     */

1004    public void updateTax(StateTax tax)
1005        throws RemoteException, AngError {
1006
1007        if (Prefs.DEBUG) System.out.println("BizServices.updateTax");
1008
1009        try {
1010            stateTaxDB.updateRow(tax);
1011        } catch (SQLException e) {
1012            e.printStackTrace();
1013            throw new AngError(e.getMessage());
1014        }
1015    }
1016
1017    /**
1018     * delete all StateTax rows
1019     * @exception AngError thrown when an app error occurs
1020     */

1021    public void deleteAllTax()
1022        throws RemoteException, AngError {
1023
1024        if (Prefs.DEBUG) System.out.println("BizServices.deleteAllTax");
1025
1026        try {
1027            stateTaxDB.deleteAllRows();
1028        } catch (SQLException e) {
1029            e.printStackTrace();
1030            throw new AngError(e.getMessage());
1031        }
1032    }
1033
1034
1035    /**
1036     * load a StateTax
1037     * @param row StateTax to load
1038     * @exception AngError thrown when an app error occurs
1039     */

1040    public void loadTax(StateTax row)
1041        throws RemoteException, AngError {
1042
1043        if (Prefs.DEBUG) System.out.println("BizServices.loadTax");
1044
1045        try {
1046            stateTaxDB.insertRow(row, true);
1047        } catch (SQLException e) {
1048            e.printStackTrace();
1049            throw new AngError(e.getMessage());
1050        }
1051    }
1052
1053
1054    /**
1055     * get all the State tax codes
1056     * @param lastSyncDate the user's last sync date which limits
1057     * the query, if null no limit
1058     * @return an ArrayList of StateTax found
1059     * @exception AngError thrown when an app error occurs
1060     */

1061    public ArrayList getStateTax(java.util.Date JavaDoc lastSyncDate)
1062        throws RemoteException, AngError {
1063
1064        if (Prefs.DEBUG) System.out.println("BizServices.getStateTax");
1065        ArrayList tax = null;
1066
1067        try {
1068            tax = stateTaxDB.selectAllRows(lastSyncDate);
1069        } catch (SQLException e) {
1070            e.printStackTrace();
1071            throw new AngError(e.getMessage());
1072        }
1073
1074        return tax;
1075    }
1076
1077
1078    /**
1079     * get all the Customers
1080     * @param lastSyncDate a user's last sync date used to limit the
1081     * query or null if no limit
1082     * @return an ArrayList of Customers found
1083     * @exception AngError thrown when an app error occurs
1084     */

1085    public ArrayList getCustomers(java.util.Date JavaDoc lastSyncDate)
1086        throws RemoteException, AngError {
1087
1088        if (Prefs.DEBUG) System.out.println("BizServices.getCustomers");
1089        ArrayList customers = null;
1090
1091        try {
1092            customers = customerDB.selectAllRows(lastSyncDate);
1093        } catch (SQLException e) {
1094            e.printStackTrace();
1095            throw new AngError(e.getMessage());
1096        }
1097
1098        return customers;
1099    }
1100
1101    /**
1102     * load a Product
1103     * @param p the Product to add
1104     * @exception AngError thrown when an app error occurs
1105     */

1106    public void loadProduct(Product p)
1107        throws RemoteException, AngError {
1108
1109        long pk=0L;
1110        if (Prefs.DEBUG) System.out.println("BizServices.loadProduct");
1111
1112        try {
1113            pk = productDB.insertRow(p, true);
1114            productDB.getConnection().commit();
1115        } catch (SQLException e) {
1116            e.printStackTrace();
1117            try { productDB.getConnection().rollback(); } catch (SQLException x) {}
1118            throw new AngError(e.getMessage());
1119        }
1120
1121    }
1122
1123
1124    /**
1125     * add a Product
1126     * @param p the Product to add
1127     * @exception AngError thrown when an app error occurs
1128     */

1129    public void addProduct(Product p)
1130        throws RemoteException, AngError {
1131
1132        long pk=0L;
1133        if (Prefs.DEBUG) System.out.println("BizServices.addProduct");
1134
1135        try {
1136            pk = productDB.insertRow(p, false);
1137            productDB.getConnection().commit();
1138        } catch (SQLException e) {
1139            e.printStackTrace();
1140            try { productDB.getConnection().rollback(); } catch (SQLException x) {}
1141            throw new AngError(e.getMessage());
1142        }
1143
1144    }
1145
1146    /**
1147     * delete all the Products
1148     * @param prod Product to delete
1149     * @exception AngError thrown when an app error occurs
1150     */

1151    public void deleteProduct(Product prod)
1152        throws RemoteException, AngError {
1153
1154        if (Prefs.DEBUG) System.out.println("BizServices.deleteProduct");
1155        try {
1156            productDB.deleteRow(new Long JavaDoc(prod.getPK()));
1157        } catch (SQLException e) {
1158            e.printStackTrace();
1159            throw new AngError(e.getMessage());
1160        }
1161    }
1162
1163    
1164    /**
1165     * get all the Products
1166     * @param a date criteria to use for the query
1167     * @return an ArrayList of Products
1168     * @exception AngError thrown when an app error occurs
1169     */

1170    public ArrayList getProducts(java.util.Date JavaDoc afterDate)
1171        throws RemoteException, AngError {
1172
1173        if (Prefs.DEBUG) System.out.println("BizServices.getProducts");
1174        ArrayList products = null;;
1175        try {
1176            products = productDB.selectAllRows(afterDate);
1177        } catch (SQLException e) {
1178            e.printStackTrace();
1179            throw new AngError(e.getMessage());
1180        }
1181        
1182        return products;
1183    }
1184
1185
1186    /**
1187     * get all the Opportunity names for a given user
1188     * @param u the SalesPerson to search for
1189     * @return an ArrayList of Opportunity Names (Strings)
1190     * @exception AngError thrown when an app error occurs
1191     */

1192    public ArrayList getOpportunityNames(SalesPerson u)
1193        throws RemoteException, AngError {
1194        
1195        if (Prefs.DEBUG) System.out.println("BizServices.getOpportunityNames");
1196        ArrayList names = null;
1197        try {
1198            names = oppDB.selectNames(u.getPK());
1199            if (Prefs.DEBUG) System.out.println("opp names has "+names.size());
1200        } catch (SQLException e) {
1201            e.printStackTrace();
1202            throw new AngError(e.getMessage());
1203        }
1204        return names;
1205    }
1206
1207
1208    /**
1209     * get all the Opportunities for a given user
1210     * @param u the SalesPerson to search for
1211     * @param lastSyncDate a user's last sync date used to limit
1212     * the query, null if no limit
1213     * @return an ArrayList of Opportunity rows found
1214     * @exception AngError thrown when an app error occurs
1215     */

1216    public ArrayList getOpportunities(SalesPerson u, java.util.Date JavaDoc lastSyncDate)
1217        throws RemoteException, AngError {
1218
1219        if (Prefs.DEBUG) System.out.println("BizServices.getOpportunities");
1220        ArrayList opps = null;
1221        try {
1222            opps = oppDB.selectByUserRows(u.getPK(), lastSyncDate);
1223        } catch (SQLException e) {
1224            e.printStackTrace();
1225            throw new AngError(e.getMessage());
1226        }
1227        return opps;
1228    }
1229
1230
1231    /**
1232     * get an Opportunity
1233     * @param pk search by the Opportunity's primary key
1234     * @return the found Opportunity
1235     * @exception AngError thrown when an app error occurs
1236     */

1237    public Opportunity getOpportunity(long pk)
1238        throws RemoteException, AngError {
1239
1240        if (Prefs.DEBUG) System.out.println("BizServices.getOpportunity");
1241        Opportunity opp=null;
1242
1243        try {
1244            opp = (Opportunity)(oppDB.selectRow(new Long JavaDoc(pk)));
1245        } catch (SQLException e) {
1246            e.printStackTrace();
1247            throw new AngError(e.getMessage());
1248        }
1249        return opp;
1250    }
1251
1252
1253    /**
1254     * delete an Opportunity
1255     * @param pk the primary key of an Opportunity to delete
1256     * @exception AngError thrown when an app error occurs
1257     */

1258    public void deleteOpportunity(long pk)
1259        throws RemoteException, AngError {
1260
1261        if (Prefs.DEBUG) System.out.println("BizServices.deleteOpportunity");
1262        try {
1263            oppDB.deleteRow(new Long JavaDoc(pk));
1264            oppDB.getConnection().commit();
1265        } catch (SQLException e) {
1266            e.printStackTrace();
1267            try { productDB.getConnection().rollback(); } catch (SQLException x) {}
1268            throw new AngError(e.getMessage());
1269        }
1270    }
1271
1272    /**
1273     * load an Opportunity
1274     * @param o the Opportunity we are loading
1275     * @exception AngError thrown when an app error occurs
1276     */

1277    public void loadOpportunity(Opportunity o)
1278        throws RemoteException, AngError {
1279
1280        if (Prefs.DEBUG) System.out.println("BizServices.loadOpportunity");
1281
1282        try {
1283            long pk= oppDB.insertRow(o, true);
1284            oppDB.getConnection().commit();
1285        } catch (SQLException e) {
1286            e.printStackTrace();
1287            try { oppDB.getConnection().rollback(); } catch (SQLException x) {}
1288            throw new AngError(e.getMessage());
1289        }
1290    }
1291
1292    /**
1293     * add an Opportunity
1294     * @param o the Opportunity we are adding
1295     * @return the newly added Opportunity's primary key
1296     * @exception AngError thrown when an app error occurs
1297     */

1298    public long addOpportunity(Opportunity o)
1299        throws RemoteException, AngError {
1300
1301        long pk;
1302        if (Prefs.DEBUG) System.out.println("BizServices.addOpportunity");
1303
1304        try {
1305            pk= oppDB.insertRow(o, false);
1306            oppDB.getConnection().commit();
1307        } catch (SQLException e) {
1308            e.printStackTrace();
1309            try { oppDB.getConnection().rollback(); } catch (SQLException x) {}
1310            throw new AngError(e.getMessage());
1311        }
1312        return pk;
1313    }
1314
1315
1316    /**
1317     * update an Opportunity
1318     * @param o the Opportunity to update
1319     * @exception AngError thrown when an app error occurs
1320     */

1321    public void updateOpportunity(Opportunity o)
1322        throws RemoteException, AngError {
1323
1324        if (Prefs.DEBUG) System.out.println("BizServices.updateOpportunity");
1325        try {
1326            oppDB.updateRow(o);
1327            oppDB.getConnection().commit();
1328        } catch (SQLException e) {
1329            e.printStackTrace();
1330            try { oppDB.getConnection().rollback(); } catch (SQLException x) {}
1331            throw new AngError(e.getMessage());
1332        }
1333    }
1334
1335
1336    /**
1337     * delete a Contact
1338     * @param oppPk the containing Opportunity primary key
1339     * @param contPk the Contact primary key to delete with
1340     * @exception AngError thrown when an app error occurs
1341     */

1342    public void deleteContact(long oppPk, long contPk)
1343        throws RemoteException, AngError {
1344
1345        if (Prefs.DEBUG) System.out.println("BizServices.deleteContact");
1346        try {
1347            contactDB.deleteRow(new Long JavaDoc(contPk));
1348            contactDB.getConnection().commit();
1349        } catch (SQLException e) {
1350            e.printStackTrace();
1351            try { contactDB.getConnection().rollback(); } catch (SQLException x) {}
1352            throw new AngError(e.getMessage());
1353        }
1354    }
1355
1356
1357    /**
1358     * update a Contact
1359     * @param oppPK the containing Opportunity primary key
1360     * @param c the the Contact being added
1361     * @exception AngError thrown when an app error occurs
1362     */

1363    public void updateContact(long oppPK, Contact c)
1364        throws RemoteException, AngError {
1365        if (Prefs.DEBUG) System.out.println("BizServices.udpateContact");
1366        try {
1367            contactDB.updateRow(c);
1368            contactDB.getConnection().commit();
1369        } catch (SQLException e) {
1370            e.printStackTrace();
1371            try { contactDB.getConnection().rollback(); } catch (SQLException x) {}
1372            throw new AngError(e.getMessage());
1373        }
1374    }
1375
1376    /**
1377     * add a new Contact to the database belonging to the
1378     * current opportunity
1379     *
1380     * @param oppPk the primary key of the parent opportunity
1381     * @param c the Address entered for this new contact
1382     * @return the primary key of the Contact object that is created
1383     * @exception AngError general application error
1384     */

1385    public long addContact(long oppPk, Contact contact)
1386        throws RemoteException, AngError {
1387        
1388        if (Prefs.DEBUG) System.out.println("BizServices.addContact");
1389        long pk;
1390        try {
1391            contact.setOppKey(oppPk);
1392            pk = contactDB.insertRow(contact, false);
1393            contactDB.getConnection().commit();
1394        } catch (SQLException e) {
1395            e.printStackTrace();
1396            try { contactDB.getConnection().rollback(); } catch (SQLException x) {}
1397            throw new AngError(e.getMessage());
1398        }
1399        return pk;
1400    }
1401
1402
1403    /**
1404     * get all SalesPersons in the system
1405     * @param lastSyncDate a user's last sync date or null, used to
1406     * limit the query
1407     * @return an array of SalesPerson objects
1408     * @exception AngError thrown when an app error occurs
1409     */

1410    public Object JavaDoc[] getSalesPersons(java.util.Date JavaDoc lastSyncDate)
1411        throws RemoteException, AngError {
1412
1413        if (Prefs.DEBUG) System.out.println("BizServices.getSalesPersons");
1414        TreeMap users = null;
1415
1416        try {
1417            users = salesPersonDB.selectAllRows(lastSyncDate);
1418        } catch (SQLException e) {
1419            e.printStackTrace();
1420            throw new AngError(e.getMessage());
1421        }
1422        return users.values().toArray();
1423    }
1424
1425    /**
1426     * get a SalesPerson using a formatted name
1427     * @param pk primary key to search with
1428     * @return the found SalesPerson
1429     * @exception AngError thrown when an app error occurs
1430     */

1431    public SalesPerson getSalesPerson(long pk)
1432        throws RemoteException, AngError {
1433
1434        if (Prefs.DEBUG) System.out.println("BizServices.getSalesPerson");
1435        SalesPerson sp=null;
1436        try {
1437            sp = (SalesPerson)salesPersonDB.selectRow(new Long JavaDoc(pk));
1438        } catch (SQLException e) {
1439            e.printStackTrace();
1440            throw new AngError(e.getMessage());
1441        }
1442        return sp;
1443    }
1444
1445
1446    /**
1447     * update a SalesPerson
1448     * @param s the SalesPerson to update with
1449     * @exception AngError thrown when an app error occurs
1450     */

1451    public void updateSalesPerson(SalesPerson s)
1452        throws RemoteException, AngError {
1453
1454        if (Prefs.DEBUG) System.out.println("BizServices.updateSalesPerson");
1455        try {
1456            salesPersonDB.updateRow(s);
1457            salesPersonDB.getConnection().commit();
1458        } catch (SQLException e) {
1459            e.printStackTrace();
1460            try { salesPersonDB.getConnection().rollback(); } catch (SQLException x) {}
1461            throw new AngError(e.getMessage());
1462        }
1463    }
1464
1465    /**
1466     * delete a user from the system
1467     * @param pk the SalesPerson primary key to delete with
1468     * @exception AngError thrown when an app error occurs
1469     */

1470    public void deleteSalesPerson(SalesPerson per)
1471        throws RemoteException, AngError {
1472        if (Prefs.DEBUG) System.out.println("BizServices.deleteSalesPerson");
1473
1474        try {
1475            salesPersonDB.deleteRow(per);
1476            salesPersonDB.getConnection().commit();
1477        } catch (SQLException e) {
1478            e.printStackTrace();
1479            try { salesPersonDB.getConnection().rollback(); } catch (SQLException x) {}
1480            throw new AngError(e.getMessage());
1481        }
1482    }
1483
1484    /**
1485     * load a user to the system
1486     * @param s the SalesPerson to add
1487     * @exception AngError thrown when an app error occurs
1488     */

1489    public void loadSalesPerson(SalesPerson s)
1490        throws RemoteException, AngError {
1491
1492        if (Prefs.DEBUG) System.out.println("BizServices.loadSalesPerson");
1493        long pk;
1494        try {
1495            pk= salesPersonDB.insertRow(s, true);
1496            salesPersonDB.getConnection().commit();
1497        } catch (SQLException e) {
1498            e.printStackTrace();
1499            try { salesPersonDB.getConnection().rollback(); } catch (SQLException x) {}
1500            throw new AngError(e.getMessage());
1501        }
1502    }
1503
1504    /**
1505     * add a user to the system
1506     * @param s the SalesPerson to add
1507     * @return the newly added row's primary key
1508     * @exception AngError thrown when an app error occurs
1509     */

1510    public long addSalesPerson(SalesPerson s)
1511        throws RemoteException, AngError {
1512
1513        if (Prefs.DEBUG) System.out.println("BizServices.addSalesPerson");
1514        long pk;
1515        try {
1516            pk = salesPersonDB.insertRow(s, false);
1517            salesPersonDB.getConnection().commit();
1518        } catch (SQLException e) {
1519            e.printStackTrace();
1520            try { salesPersonDB.getConnection().rollback(); } catch (SQLException x) {}
1521            throw new AngError(e.getMessage());
1522        }
1523        return pk;
1524    }
1525
1526
1527    /**
1528     * get all sales person id's
1529     * @return an ArrayList of user IDs
1530     * @exception AngError thrown when an app error occurs
1531     */

1532    public ArrayList getSalesPersonIDs()
1533        throws RemoteException, AngError {
1534
1535        if (Prefs.DEBUG) System.out.println("BizServices.getSalesPersonIDs");
1536        ArrayList idList = null;
1537
1538        try {
1539            idList = salesPersonDB.selectAllIDs();
1540        } catch (SQLException e) {
1541            e.printStackTrace();
1542            throw new AngError(e.getMessage());
1543        }
1544        return idList;
1545
1546    }
1547
1548    /**
1549     * get all the users names in 'formatted' form
1550     * @return an ArrayList of formatted user names
1551     * @exception AngError thrown when an app error occurs
1552     */

1553    public ArrayList getSalesPersonNames()
1554        throws RemoteException, AngError {
1555        
1556        if (Prefs.DEBUG) System.out.println("BizServices.getSalesPersonNames");
1557        ArrayList names=null;
1558        try {
1559            names = salesPersonDB.selectAllNames();
1560        } catch (SQLException e) {
1561            e.printStackTrace();
1562            throw new AngError(e.getMessage());
1563        }
1564        return names;
1565    }
1566
1567
1568    /**
1569     * add a user to a UserGroup
1570     * @param userPK the primary key of the user being added
1571     * @param group the UserGroup begin added to
1572     * @exception AngError thrown when an app error occurs
1573     */

1574    public void addUserToGroup(long userPK, UserGroup group)
1575        throws RemoteException, AngError {
1576
1577        if (Prefs.DEBUG) System.out.println("BizServices.addUserToGroup");
1578        try {
1579            UserGroupMember ugm = new UserGroupMember();
1580            ugm.setUserGroupPK(group.getPK());
1581            ugm.setModifiedBy(group.getModifiedBy());
1582            ugm.setUserPK(userPK);
1583            long pk = ugMemberDB.insertRow(ugm, false);
1584            ugMemberDB.getConnection().commit();
1585        } catch (SQLException e) {
1586            e.printStackTrace();
1587            try { ugMemberDB.getConnection().rollback(); } catch (SQLException x) {}
1588            throw new AngError(e.getMessage());
1589        }
1590    }
1591
1592
1593    /**
1594     * get all the SalesPersons in a UserGroup
1595     * @param groupName the UserGroup we are searching with
1596     * @return an array of SalesPersons found
1597     * @exception AngError thrown when an app error occurs
1598     */

1599    public Object JavaDoc[] getUsersInGroup(String JavaDoc groupName)
1600        throws RemoteException, AngError {
1601
1602        if (Prefs.DEBUG) System.out.println("BizServices.getUsersInGroup");
1603        try {
1604            TreeMap members = userGroupDB.selectUsersInGroup(groupName);
1605            return members.values().toArray();
1606        } catch (SQLException e) {
1607            e.printStackTrace();
1608            throw new AngError(e.getMessage());
1609        }
1610    }
1611
1612    /**
1613     * get a UserGroup in the system by primary key
1614     * @param pk a UserGroup primary key to search with
1615     * @return a UserGroup that was found or null if not found
1616     * @exception AngError thrown when an app error occurs
1617     */

1618    public UserGroup getUserGroup(long pk)
1619        throws RemoteException, AngError {
1620
1621        if (Prefs.DEBUG) System.out.println("BizServices.getUserGroup");
1622        try {
1623            UserGroup ug = (UserGroup)userGroupDB.selectRow(new Long JavaDoc(pk));
1624            return ug;
1625        } catch (SQLException e) {
1626            e.printStackTrace();
1627            throw new AngError(e.getMessage());
1628        }
1629    }
1630
1631    /**
1632     * get all UserGroups in the system
1633     * @param lastSyncDate a user's last sync date which limits the query
1634     * @return an array of UserGroups that were found
1635     * @exception AngError thrown when an app error occurs
1636     */

1637    public Object JavaDoc[] getUserGroups(java.util.Date JavaDoc lastSyncDate)
1638        throws RemoteException, AngError {
1639
1640        if (Prefs.DEBUG) System.out.println("BizServices.getUserGroups");
1641        try {
1642            TreeMap userGroups = userGroupDB.selectAllRows(lastSyncDate);
1643            return userGroups.values().toArray();
1644        } catch (SQLException e) {
1645            e.printStackTrace();
1646            throw new AngError(e.getMessage());
1647        }
1648    }
1649
1650    /**
1651     * load a UserGroup to the system
1652     * @param g a UserGroup we are adding to the system
1653     * @exception AngError thrown when an app error occurs
1654     */

1655    public void loadUserGroup(UserGroup g)
1656        throws RemoteException, AngError {
1657
1658        if (Prefs.DEBUG) System.out.println("BizServices.addUserGroup");
1659        try {
1660            long pk = userGroupDB.insertRow(g, true);
1661            userGroupDB.getConnection().commit();
1662        } catch (SQLException e) {
1663            e.printStackTrace();
1664            try { userGroupDB.getConnection().rollback(); } catch (SQLException x) {}
1665            throw new AngError(e.getMessage());
1666        }
1667    }
1668
1669    /**
1670     * add a UserGroup to the system
1671     * @param g a UserGroup we are adding to the system
1672     * @exception AngError thrown when an app error occurs
1673     */

1674    public void addUserGroup(UserGroup g)
1675        throws RemoteException, AngError {
1676
1677        if (Prefs.DEBUG) System.out.println("BizServices.addUserGroup");
1678        try {
1679            long pk = userGroupDB.insertRow(g, false);
1680            userGroupDB.getConnection().commit();
1681        } catch (SQLException e) {
1682            e.printStackTrace();
1683            try { userGroupDB.getConnection().rollback(); } catch (SQLException x) {}
1684            throw new AngError(e.getMessage());
1685        }
1686    }
1687
1688    /**
1689     * delete all UserGroups
1690     * @exception AngError thrown when an app error occurs
1691     */

1692    public void deleteAllUserGroup()
1693        throws RemoteException, AngError {
1694
1695        if (Prefs.DEBUG) System.out.println("BizServices.deleteAllUserGroup");
1696        try {
1697            userGroupDB.deleteAllRows();
1698            userGroupDB.getConnection().commit();
1699        } catch (SQLException e) {
1700            e.printStackTrace();
1701            try { userGroupDB.getConnection().rollback(); } catch (SQLException x) {}
1702            throw new AngError(e.getMessage());
1703        }
1704    }
1705
1706    /**
1707     * delete a UserGroup
1708     * @param groupName the UserGroup name we delete with
1709     * @exception AngError thrown when an app error occurs
1710     */

1711    public void deleteUserGroup(String JavaDoc groupName)
1712        throws RemoteException, AngError {
1713
1714        if (Prefs.DEBUG) System.out.println("BizServices.deleteUserGroup");
1715        try {
1716            userGroupDB.deleteByNameRow(groupName);
1717            userGroupDB.getConnection().commit();
1718        } catch (SQLException e) {
1719            e.printStackTrace();
1720            try { userGroupDB.getConnection().rollback(); } catch (SQLException x) {}
1721            throw new AngError(e.getMessage());
1722        }
1723    }
1724
1725
1726    /**
1727     * delete a user in a UserGroup
1728     * @param g the containing UserGroup
1729     * @param userPK the user's primary key we are deleting with
1730     * @exception AngError thrown when an app error occurs
1731     */

1732    public void deleteUserInGroup(UserGroup g, long userPK)
1733        throws RemoteException, AngError {
1734
1735        if (Prefs.DEBUG) System.out.println("BizServices.deleteUserInGroup");
1736        try {
1737            ArrayList users = ugMemberDB.selectUsersInGroup(g.getPK());
1738            SalesPerson sp;
1739            for (int i=0;i<users.size();i++) {
1740                sp = (SalesPerson)users.get(i);
1741                if (sp.getPK() == userPK) {
1742                    ugMemberDB.deleteByUserRow(sp.getPK());
1743                    break;
1744                }
1745            }
1746            ugMemberDB.getConnection().commit();
1747        } catch (SQLException e) {
1748            e.printStackTrace();
1749            try { ugMemberDB.getConnection().rollback(); } catch (SQLException x) {}
1750            throw new AngError(e.getMessage());
1751        }
1752    }
1753
1754
1755    /**
1756     * get the UserGroups for a given user
1757     * @param userPK the SalesPerson primary key we are searching for
1758     * @return an ArrayList of UserGroup(s) this user belongs to
1759     * @exception AngError thrown when an app error occurs
1760     */

1761    public ArrayList getGroupsForUser(long userPK)
1762        throws RemoteException, AngError {
1763
1764        if (Prefs.DEBUG) System.out.println("BizServices.getGroupsForUser");
1765        ArrayList userGroups = null;
1766
1767        try {
1768            userGroups = ugMemberDB.selectGroupsForUser(userPK);
1769        } catch (SQLException e) {
1770            e.printStackTrace();
1771            throw new AngError(e.getMessage());
1772        }
1773        return userGroups;
1774    }
1775
1776    /**
1777     * delete the Campaigns
1778     * @exception AngError thrown when an app error occurs
1779     */

1780    public void deleteAllCampaign()
1781        throws RemoteException, AngError {
1782
1783        if (Prefs.DEBUG) System.out.println("BizServices.deleteAllCampaign");
1784
1785        try {
1786            campaignDB.deleteAllRows();
1787            campaignDB.getConnection().commit();
1788        } catch (SQLException e) {
1789            e.printStackTrace();
1790            throw new AngError(e.getMessage());
1791        }
1792    }
1793
1794    /**
1795     * load a campaign into the campaigns table
1796     * @exception AngError thrown when an app error occurs
1797     */

1798    public void loadCampaign(Campaign c)
1799        throws RemoteException, AngError {
1800
1801        if (Prefs.DEBUG) System.out.println("BizServices.loadCampaign");
1802
1803        try {
1804            long pk = campaignDB.insertRow(c, true);
1805        } catch (SQLException e) {
1806            e.printStackTrace();
1807            throw new AngError(e.getMessage());
1808        }
1809    }
1810
1811    /**
1812     * get a Campaign
1813     * @param pk a primary key
1814     * @return a Campaign if found null if not found
1815     * @exception AngError thrown when an app error occurs
1816     */

1817    public Campaign getCampaign(long pk)
1818        throws RemoteException, AngError {
1819
1820        if (Prefs.DEBUG) System.out.println("BizServices.getCampaign");
1821
1822        try {
1823            return (Campaign)campaignDB.selectRow(new Long JavaDoc(pk));
1824        } catch (SQLException e) {
1825            e.printStackTrace();
1826            throw new AngError(e.getMessage());
1827        }
1828    }
1829
1830    /**
1831     * get the Campaigns
1832     * @param lastSyncDate a user's last sync date which limits the
1833     * query or null if no limit
1834     * @return an ArrayList of Campaigns that were found
1835     * @exception AngError thrown when an app error occurs
1836     */

1837    public ArrayList getCampaigns(java.util.Date JavaDoc lastSyncDate)
1838        throws RemoteException, AngError {
1839
1840        if (Prefs.DEBUG) System.out.println("BizServices.getCampaigns");
1841        ArrayList campaigns = null;
1842
1843        try {
1844            campaigns = campaignDB.selectAllRows(lastSyncDate);
1845        } catch (SQLException e) {
1846            e.printStackTrace();
1847            throw new AngError(e.getMessage());
1848        }
1849        return campaigns;
1850    }
1851
1852
1853    /**
1854     * get the Leads for a given Campaign
1855     * @param campaignPK the containing Campaign's primary key
1856     * @return an ArrayList of Leads that were found
1857     * @exception AngError thrown when an app error occurs
1858     */

1859    public ArrayList getCampaignLeads(long campaignPK)
1860        throws RemoteException, AngError {
1861
1862        if (Prefs.DEBUG) System.out.println("BizServices.getCampaignLeads");
1863        ArrayList leads = null;
1864
1865        try {
1866            leads = leadDB.selectByCampaignRows(campaignPK);
1867        } catch (SQLException e) {
1868            e.printStackTrace();
1869            throw new AngError(e.getMessage());
1870        }
1871        return leads;
1872    }
1873
1874    /**
1875     * get all Leads
1876     * @param lastSyncDate a user's last sync date used to limit the
1877     * query or null if no limit
1878     * @return an ArrayList of Leads that were found
1879     * @exception AngError thrown when an app error occurs
1880     */

1881    public ArrayList getCampaignLeads(java.util.Date JavaDoc lastSyncDate)
1882        throws RemoteException, AngError {
1883
1884        if (Prefs.DEBUG) System.out.println("BizServices.getCampaignLeads all");
1885        ArrayList leads = null;
1886
1887        try {
1888            leads = leadDB.selectAllRows(lastSyncDate);
1889        } catch (SQLException e) {
1890            e.printStackTrace();
1891            throw new AngError(e.getMessage());
1892        }
1893        return leads;
1894    }
1895
1896    /**
1897     * get a Lead
1898     * @param pk the Lead primary key
1899     * @return the Lead that was found or null if not found
1900     */

1901    public Lead getLead(long pk)
1902        throws RemoteException, AngError {
1903    
1904        if (Prefs.DEBUG) System.out.println("BizServices.getLead");
1905        try {
1906            return (Lead)leadDB.selectRow(new Long JavaDoc(pk));
1907        } catch (SQLException e) {
1908            e.printStackTrace();
1909            throw new AngError(e.getMessage());
1910        }
1911    }
1912    
1913    /**
1914     * process the items that were deleted by a user when
1915     * operating in a 'disconnected' mode, each object
1916     * in the passed list will be deleted from the database
1917     *
1918     * @param deletes the ArrayList of DeleteInfo objects
1919     * @exception AngError thrown when an app error occurs
1920     */

1921    public void uploadDeletes(ArrayList deletes)
1922        throws RemoteException, AngError {
1923    
1924        if (Prefs.DEBUG) System.out.println("uploadDeletes is working on "+ deletes.size());
1925
1926        DeleteInfo del;
1927        Connection currentConnection=null;
1928
1929        //get the Connection from any one of the database
1930
//routines, they all share the same connection so
1931
//the ActivityDB will do just fine
1932

1933        currentConnection = activityDB.getConnection();
1934
1935        try {
1936            for (int i=0;i<deletes.size();i++) {
1937                del = (DeleteInfo)deletes.get(i);
1938                if (del.className.equals("Activity")) {
1939                    activityDB.deleteRow(new Long JavaDoc(del.pk));
1940                } else
1941                if (del.className.equals("Forecast")) {
1942                    forecastDB.deleteRow(new Long JavaDoc(del.pk));
1943                } else
1944                if (del.className.equals("Quote")) {
1945                    quoteDB.deleteRow(new Long JavaDoc(del.pk));
1946                } else
1947                if (del.className.equals("QuoteLine")) {
1948                    quoteLineDB.deleteRow(new Long JavaDoc(del.pk));
1949                } else
1950                if (del.className.equals("Contact")) {
1951                    contactDB.deleteRow(new Long JavaDoc(del.pk));
1952                } else
1953                if (del.className.equals("Opportunity")) {
1954                    oppDB.deleteRow(new Long JavaDoc(del.pk));
1955                } else
1956                    throw new AngError(del.className + " not implemented yet");
1957
1958                currentConnection.commit();
1959
1960            }
1961        } catch (SQLException e) {
1962            e.printStackTrace();
1963            try { currentConnection.rollback(); } catch (SQLException x) {}
1964            throw new AngError(e.getMessage());
1965        }
1966    }
1967
1968    /**
1969     * add a customer inventory
1970     * @param ci the CustomerInventory to add
1971     * @return the primary key of the newly added row
1972     * @exception AngError thrown when an app error occurs
1973     */

1974    public long addCustomerInventory(CustomerInventory c)
1975        throws RemoteException, AngError {
1976
1977        if (Prefs.DEBUG) System.out.println("BizServices.addCustomerInventory");
1978        long pk=0L;
1979        try {
1980            pk = custInventoryDB.insertRow(c, false);
1981            custInventoryDB.getConnection().commit();
1982        } catch (SQLException e) {
1983            e.printStackTrace();
1984            try { custInventoryDB.getConnection().rollback(); } catch (SQLException x) {}
1985            throw new AngError(e.getMessage());
1986        }
1987        return pk;
1988    }
1989
1990    /**
1991     * delete a customer inventory
1992     * @param ci the customer inventory to delete with
1993     * @exception AngError thrown when an app error occurs
1994     */

1995    public void deleteCustomerInventory(CustomerInventory ci)
1996        throws RemoteException, AngError {
1997
1998        if (Prefs.DEBUG) System.out.println("BizServices.deleteCustomerInventory");
1999        try {
2000            custInventoryDB.deleteRow(new Long JavaDoc(ci.getPK()));
2001            custInventoryDB.getConnection().commit();
2002        } catch (SQLException e) {
2003            e.printStackTrace();
2004            try { custInventoryDB.getConnection().rollback(); } catch (SQLException x) {}
2005            throw new AngError(e.getMessage());
2006        }
2007    }
2008
2009    /**
2010     * get the CustomerInventory for a given customer
2011     * @param cust the Customer we are searching with
2012     * @return an ArrayList of CustomerInventory objects
2013     * @exception AngError thrown when an app error occurs
2014     */

2015    public ArrayList getCustomerInventory(long custPK)
2016        throws RemoteException, AngError {
2017    
2018        if (Prefs.DEBUG) System.out.println("BizServices.getCustomerInventory");
2019        ArrayList rows=null;
2020    
2021        try {
2022            rows = custInventoryDB.selectAllRows(custPK);
2023        } catch (SQLException e) {
2024            e.printStackTrace();
2025            throw new AngError(e.getMessage());
2026        }
2027        return rows;
2028    }
2029
2030    /**
2031     * get the list of deleted rows
2032     * @return the list of deleted data
2033     */

2034    public ArrayList getDeletes()
2035        throws RemoteException, AngError {
2036        if (Prefs.DEBUG) System.out.println("BizServices.getDeletes");
2037    
2038        try {
2039            return deleteInfoDB.selectAllRows();
2040        } catch (SQLException e) {
2041            e.printStackTrace();
2042            throw new AngError(e.getMessage());
2043        }
2044    }
2045
2046    /**
2047     * reset the deletes
2048     */

2049    public void resetDeletes()
2050        throws RemoteException, AngError {
2051        if (Prefs.DEBUG) System.out.println("BizServices.resetDeletes");
2052    
2053        try {
2054            deleteInfoDB.deleteAllRows();
2055        } catch (SQLException e) {
2056            e.printStackTrace();
2057            throw new AngError(e.getMessage());
2058        }
2059    }
2060
2061    /**
2062     * write out some delete info for the sync processing
2063     * @param objType class name of object that got deleted
2064     * @param pk primary key of object that got deleted
2065     * @exception AngError thrown when an app error occurs
2066     */

2067    public final void writeDelete(DeleteInfo deleteInfo)
2068        throws RemoteException, AngError {
2069
2070        if (Prefs.DEBUG) System.out.println("BizServices.writeDelete");
2071    
2072        try {
2073            long pk = deleteInfoDB.insertRow(deleteInfo, false);
2074        } catch (SQLException e) {
2075            e.printStackTrace();
2076            throw new AngError(e.getMessage());
2077        }
2078    }
2079
2080    public void init(int DB_TYPE) {
2081        activityDB = new ActivityDB(DB_TYPE);
2082        addressDB = new AddressDB(DB_TYPE);
2083        adminDB = new Admin(DB_TYPE);
2084        attendeeDB = new AttendeeDB(DB_TYPE);
2085        campaignDB = new CampaignDB(DB_TYPE);
2086        customerDB = new CustomerDB(DB_TYPE);
2087        deleteInfoDB = new DeleteInfoDB(DB_TYPE);
2088        stateTaxDB = new StateTaxDB(DB_TYPE);
2089        contactDB = new ContactDB(DB_TYPE);
2090        custInventoryDB = new CustomerInventoryDB(DB_TYPE);
2091        forecastDB = new ForecastDB(DB_TYPE);
2092        leadDB = new LeadDB(DB_TYPE);
2093        oppDB = new OpportunityDB(DB_TYPE);
2094        orderDB = new OrderDB(DB_TYPE);
2095        productDB = new ProductDB(DB_TYPE);
2096        quoteDB = new QuoteDB(DB_TYPE);
2097        quoteLineDB = new QuoteLineDB(DB_TYPE);
2098        rolePermissionDB = new RolePermissionDB(DB_TYPE);
2099        salesPersonDB = new SalesPersonDB(DB_TYPE);
2100        salesPersonRoleDB = new SalesPersonRoleDB(DB_TYPE);
2101        userGroupDB = new UserGroupDB(DB_TYPE);
2102        ugMemberDB = new UserGroupMemberDB(DB_TYPE);
2103        userRoleDB = new UserRoleDB(DB_TYPE);
2104    }
2105
2106    /**
2107     * delete all SalesPersons in the system
2108     * @exception AngError thrown when an app error occurs
2109     */

2110    public void deleteAllSalesPerson()
2111        throws RemoteException, AngError {
2112
2113        if (Prefs.DEBUG) System.out.println("BizServices.deleteAllSalesPerson");
2114
2115        try {
2116            salesPersonDB.deleteAllRows();
2117        } catch (SQLException e) {
2118            e.printStackTrace();
2119            throw new AngError(e.getMessage());
2120        }
2121    }
2122
2123    public void truncateDB()
2124        throws RemoteException, AngError {
2125
2126        try {
2127            //truncate in same order as 'drop' script
2128

2129            deleteInfoDB.truncate();
2130            deleteInfoDB.getConnection().commit();
2131
2132            stateTaxDB.truncate();
2133            stateTaxDB.getConnection().commit();
2134
2135            deleteInfoDB.truncate();
2136            deleteInfoDB.getConnection().commit();
2137
2138            rolePermissionDB.truncate();
2139            rolePermissionDB.getConnection().commit();
2140
2141            userRoleDB.truncate();
2142            userRoleDB.getConnection().commit();
2143
2144            ugMemberDB.truncate();
2145            ugMemberDB.getConnection().commit();
2146
2147            userGroupDB.truncate();
2148            userGroupDB.getConnection().commit();
2149
2150            orderDB.truncate();
2151            orderDB.getConnection().commit();
2152
2153            quoteLineDB.truncate();
2154            quoteLineDB.getConnection().commit();
2155
2156            quoteDB.truncate();
2157            quoteDB.getConnection().commit();
2158
2159            attendeeDB.truncate();
2160            attendeeDB.getConnection().commit();
2161
2162            activityDB.truncate();
2163            activityDB.getConnection().commit();
2164
2165            leadDB.truncate();
2166            leadDB.getConnection().commit();
2167
2168            campaignDB.truncate();
2169            campaignDB.getConnection().commit();
2170
2171            custInventoryDB.truncate();
2172            custInventoryDB.getConnection().commit();
2173
2174            productDB.truncate();
2175            productDB.getConnection().commit();
2176
2177            customerDB.truncate();
2178            customerDB.getConnection().commit();
2179
2180            salesPersonDB.truncate();
2181            salesPersonDB.getConnection().commit();
2182
2183            salesPersonRoleDB.truncate();
2184            salesPersonRoleDB.getConnection().commit();
2185
2186            forecastDB.truncate();
2187            forecastDB.getConnection().commit();
2188
2189            contactDB.truncate();
2190            contactDB.getConnection().commit();
2191
2192            oppDB.truncate();
2193            oppDB.getConnection().commit();
2194
2195            addressDB.truncate();
2196            addressDB.getConnection().commit();
2197        } catch (SQLException e) {
2198            e.printStackTrace();
2199        }
2200    }
2201
2202    /**
2203     * get all the UserGroupMembers
2204     * @param lastSyncDate a user's last sync date or null, used to
2205     * limit the query
2206     * @return an ArrayList of UserGroupMember objects
2207     */

2208    public ArrayList getGroupMembers(java.util.Date JavaDoc lastSyncDate)
2209        throws RemoteException, AngError {
2210        
2211        try {
2212            return ugMemberDB.selectAllRows(lastSyncDate);
2213        } catch (SQLException e) {
2214            e.printStackTrace();
2215            throw new AngError(e.getMessage());
2216        }
2217    }
2218
2219    /**
2220     * select a user group member
2221     * @param pk the UserGroupMember primary key
2222     * @return the UserGroupMember or null if not found
2223     * @exception AngError thrown when an app error occurs
2224     */

2225    public UserGroupMember getGroupMember(long pk)
2226        throws RemoteException, AngError {
2227
2228        if (Prefs.DEBUG) System.out.println("BizServices.getGroupMember");
2229
2230        try {
2231            UserGroupMember ugm = (UserGroupMember)ugMemberDB.selectRow(new Long JavaDoc(pk));
2232            return ugm;
2233        } catch (SQLException e) {
2234            e.printStackTrace();
2235            throw new AngError(e.getMessage());
2236        }
2237    }
2238
2239    /**
2240     * load a user group member to the system
2241     * @param ugm the UserGroupMember we are loading
2242     * @exception AngError thrown when an app error occurs
2243     */

2244    public void loadGroupMember(UserGroupMember ugm)
2245        throws RemoteException, AngError {
2246
2247        if (Prefs.DEBUG) System.out.println("BizServices.loadGroupMember");
2248        long pk=0L;
2249
2250        try {
2251            pk = ugMemberDB.insertRow(ugm, true);
2252            ugMemberDB.getConnection().commit();
2253        } catch (SQLException e) {
2254            e.printStackTrace();
2255            try { userRoleDB.getConnection().rollback(); } catch (SQLException x) {}
2256            throw new AngError(e.getMessage());
2257        }
2258    }
2259
2260    /**
2261     * load a lead
2262     * @param lead the Lead we are loading
2263     * @exception AngError thrown when an app error occurs
2264     */

2265    public void loadLead(Lead lead)
2266        throws RemoteException, AngError {
2267
2268        if (Prefs.DEBUG) System.out.println("BizServices.loadLead");
2269        long pk=0L;
2270
2271        try {
2272            pk = leadDB.insertRow(lead, true);
2273            leadDB.getConnection().commit();
2274        } catch (SQLException e) {
2275            e.printStackTrace();
2276            try { userRoleDB.getConnection().rollback(); } catch (SQLException x) {}
2277            throw new AngError(e.getMessage());
2278        }
2279    }
2280
2281    /**
2282     * test a local table to see if it exists, if not
2283     * then return false, this test is used by the GUI client
2284     * to see if it needs to build the local database
2285     * @return true if the local table exists, false if not
2286     */

2287    public final boolean testTable()
2288        throws RemoteException, AngError {
2289        
2290        return adminDB.testTable();
2291    }
2292
2293    /**
2294     * test a local table to see if data exists in it
2295     * @return the row count is returned
2296     */

2297    public final int testTableData()
2298        throws RemoteException, AngError {
2299        
2300        return adminDB.testTableData();
2301    }
2302
2303    /**
2304     * create local database
2305     * drop the tables first then create them
2306     */

2307    public final void createAllTables()
2308        throws RemoteException, AngError {
2309
2310        try {
2311            adminDB.dropAllTables();
2312            adminDB.createAllTables();
2313        } catch (SQLException e) {
2314            e.printStackTrace();
2315        }
2316    }
2317
2318    /**
2319     * load some test data for trial users
2320     */

2321    public final void loadTestData()
2322        throws RemoteException, AngError {
2323        try {
2324            adminDB.loadTestData();
2325        } catch (SQLException e) {
2326            e.printStackTrace();
2327        }
2328    }
2329
2330    public void remove() {}
2331    public boolean isIdentical(EJBObject x) { return true; }
2332    public Object JavaDoc getPrimaryKey() { return null; }
2333    public EJBHome getEJBHome() { return null; }
2334    public Handle getHandle() { return null; }
2335}
2336
Popular Tags