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 17 28 public class BizServices implements SellwinSession { 29 30 private int DB_TYPE; 31 32 private Login login; 35 36 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 68 public BizServices() { 69 Properties props = System.getProperties(); 70 String 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 92 public BizServices(int dbType) { 93 DB_TYPE = dbType; 94 init(DB_TYPE); 95 } 96 97 107 public void init2Tier(String dbURL, String dbID, String 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 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 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 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 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 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 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 238 public ArrayList getProductGroups() 239 throws RemoteException, AngError { 240 241 243 if (Prefs.DEBUG) System.out.println("BizServices.getProductGroups"); 244 return new ArrayList(); 245 } 246 247 254 public ArrayList getProductLines(String group) 255 throws RemoteException, AngError { 256 257 259 if (Prefs.DEBUG) System.out.println("BizServices.getProductLines"); 260 return new ArrayList(); 261 } 262 263 270 public ArrayList getProductsForLine(String group, String 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 293 public Product getProduct(String group, String line, String 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 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 (pk)); 323 } catch (SQLException e) { 324 e.printStackTrace(); 325 throw new AngError(e.getMessage()); 326 } 327 328 return product; 329 } 330 331 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 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 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 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 (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 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 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 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 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 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 (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 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 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 (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 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 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 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 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 (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 673 public ArrayList getAllUserRoles(java.util.Date 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 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 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 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 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 (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 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 796 public UserRole getUserRole(String 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 818 public Login logon(String id, String 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 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 860 861 866 public void deleteCustomer(String 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 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 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 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 948 public Customer getCustomer(String 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 968 public Object [] 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 988 public StateTax getTax(String 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 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 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 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 1061 public ArrayList getStateTax(java.util.Date 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 1085 public ArrayList getCustomers(java.util.Date 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 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 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 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 (prod.getPK())); 1157 } catch (SQLException e) { 1158 e.printStackTrace(); 1159 throw new AngError(e.getMessage()); 1160 } 1161 } 1162 1163 1164 1170 public ArrayList getProducts(java.util.Date 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 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 1216 public ArrayList getOpportunities(SalesPerson u, java.util.Date 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 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 (pk))); 1245 } catch (SQLException e) { 1246 e.printStackTrace(); 1247 throw new AngError(e.getMessage()); 1248 } 1249 return opp; 1250 } 1251 1252 1253 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 (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 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 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 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 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 (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 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 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 1410 public Object [] getSalesPersons(java.util.Date 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 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 (pk)); 1438 } catch (SQLException e) { 1439 e.printStackTrace(); 1440 throw new AngError(e.getMessage()); 1441 } 1442 return sp; 1443 } 1444 1445 1446 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 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 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 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 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 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 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 1599 public Object [] getUsersInGroup(String 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 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 (pk)); 1624 return ug; 1625 } catch (SQLException e) { 1626 e.printStackTrace(); 1627 throw new AngError(e.getMessage()); 1628 } 1629 } 1630 1631 1637 public Object [] getUserGroups(java.util.Date 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 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 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 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 1711 public void deleteUserGroup(String 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 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 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 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 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 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 (pk)); 1824 } catch (SQLException e) { 1825 e.printStackTrace(); 1826 throw new AngError(e.getMessage()); 1827 } 1828 } 1829 1830 1837 public ArrayList getCampaigns(java.util.Date 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 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 1881 public ArrayList getCampaignLeads(java.util.Date 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 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 (pk)); 1907 } catch (SQLException e) { 1908 e.printStackTrace(); 1909 throw new AngError(e.getMessage()); 1910 } 1911 } 1912 1913 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 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 (del.pk)); 1940 } else 1941 if (del.className.equals("Forecast")) { 1942 forecastDB.deleteRow(new Long (del.pk)); 1943 } else 1944 if (del.className.equals("Quote")) { 1945 quoteDB.deleteRow(new Long (del.pk)); 1946 } else 1947 if (del.className.equals("QuoteLine")) { 1948 quoteLineDB.deleteRow(new Long (del.pk)); 1949 } else 1950 if (del.className.equals("Contact")) { 1951 contactDB.deleteRow(new Long (del.pk)); 1952 } else 1953 if (del.className.equals("Opportunity")) { 1954 oppDB.deleteRow(new Long (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 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 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 (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 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 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 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 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 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 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 2208 public ArrayList getGroupMembers(java.util.Date 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 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 (pk)); 2232 return ugm; 2233 } catch (SQLException e) { 2234 e.printStackTrace(); 2235 throw new AngError(e.getMessage()); 2236 } 2237 } 2238 2239 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 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 2287 public final boolean testTable() 2288 throws RemoteException, AngError { 2289 2290 return adminDB.testTable(); 2291 } 2292 2293 2297 public final int testTableData() 2298 throws RemoteException, AngError { 2299 2300 return adminDB.testTableData(); 2301 } 2302 2303 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 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 getPrimaryKey() { return null; } 2333 public EJBHome getEJBHome() { return null; } 2334 public Handle getHandle() { return null; } 2335} 2336 | Popular Tags |