1 32 33 package com.knowgate.crm; 34 35 import java.sql.CallableStatement ; 36 import java.sql.SQLException ; 37 import java.sql.PreparedStatement ; 38 import java.sql.ResultSet ; 39 import java.sql.ResultSetMetaData ; 40 41 import com.knowgate.debug.DebugFile; 42 import com.knowgate.jdc.JDCConnection; 43 import com.knowgate.dataobjs.DB; 44 import com.knowgate.dataobjs.DBBind; 45 import com.knowgate.dataobjs.DBPersist; 46 import com.knowgate.misc.Gadgets; 47 48 74 75 public class ListMember { 76 77 private DBPersist oMember; 78 79 81 private short getListType (JDCConnection oConn, String sListGUID) throws SQLException { 82 83 PreparedStatement oList; 84 ResultSet oRSet; 85 short iTpList; 86 87 if (DebugFile.trace) { 88 DebugFile.writeln("Begin ListMember.getListType([Connection], " + (null!=sListGUID ? sListGUID : "null") + ")"); 89 DebugFile.incIdent(); 90 } 91 92 if (null==sListGUID) 93 iTpList = 0; 94 95 else { 96 97 if (!oMember.getItemMap().containsKey(DB.tp_list)) { 98 99 if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(SELECT " + DB.tp_list + " FROM " + DB.k_lists + " WHERE " + DB.gu_list + "='" + (null!=sListGUID ? sListGUID : "null") + "'"); 100 101 oList = oConn.prepareStatement("SELECT " + DB.tp_list + " FROM " + DB.k_lists + " WHERE " + DB.gu_list + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 102 oList.setString(1, sListGUID); 103 104 try { oList.setQueryTimeout(20); } catch (SQLException sqle) { } 105 106 if (DebugFile.trace) DebugFile.writeln("PreparedStatement.executeQuery()"); 107 108 oRSet = oList.executeQuery(); 109 110 if (oRSet.next()) { 111 iTpList = oRSet.getShort(1); 112 oMember.put(DB.tp_list, iTpList); 113 } 114 else 115 iTpList = 0; 116 117 oRSet.close(); 118 oList.close(); 119 120 } 121 else 122 123 iTpList = oMember.getShort(DB.tp_list); 124 } 126 if (DebugFile.trace) { 127 DebugFile.decIdent(); 128 DebugFile.writeln("End ListMember.getListType() : " + String.valueOf(iTpList)); 129 } 130 131 return iTpList; 132 } 134 136 public ListMember() { 137 oMember = new DBPersist(DB.k_list_members, "ListMember"); 138 } 139 140 148 public ListMember(JDCConnection oConn, String sMemberId, String sListGUID) throws SQLException { 149 150 PreparedStatement oStmt; 151 ResultSet oRSet; 152 ResultSetMetaData oMDat; 153 Object oFld; 154 int iCols; 155 156 oMember = new DBPersist(DB.k_list_members, "ListMember"); 157 158 if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(SELECT * FROM " + DB.k_x_list_members + " WHERE " + DB.gu_list + "='" + sListGUID + "' AND (" + DB.gu_contact + "='" + sMemberId + "' OR " + DB.gu_company + "='" + sMemberId + "' OR " + DB.tx_email + "='" + sMemberId + "'))"); 159 160 oStmt = oConn.prepareStatement("SELECT * FROM " + DB.k_x_list_members + " WHERE " + DB.gu_list + "=? AND (" + DB.gu_contact + "=? OR " + DB.gu_company + "=? OR " + DB.tx_email + "=?)", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 161 162 try { oStmt.setQueryTimeout(20); } catch (SQLException sqle) { } 163 164 oStmt.setString(1, sListGUID); 165 oStmt.setString(2, sMemberId); 166 oStmt.setString(3, sMemberId); 167 oStmt.setString(4, sMemberId); 168 169 if (DebugFile.trace) DebugFile.writeln("PreparedStatement.executeQuery()"); 170 171 oRSet = oStmt.executeQuery(); 172 173 oMDat = oRSet.getMetaData(); 174 iCols = oMDat.getColumnCount(); 175 176 if (oRSet.next()) { 177 for (int c=1; c<=iCols; c++) { 178 if (!oMDat.getColumnName(c).equalsIgnoreCase(DB.dt_created)) { 179 oFld = oRSet.getObject(c); 180 if (!oRSet.wasNull()) 181 oMember.put(oMDat.getColumnName(c).toLowerCase(), oFld); 182 } } } else { 186 if (DebugFile.trace) DebugFile.writeln("member " + sMemberId + " not found at list " + sListGUID); 187 } 188 189 oRSet.close(); 190 oStmt.close(); 191 } 192 193 195 198 public DBPersist member() { 199 return oMember; 200 } 201 202 204 public java.util.Date getDate(String sKey) { 205 return oMember.getDate(sKey); 206 } 207 208 210 public String getDateFormated(String sKey, String sFormat) { 211 return oMember.getDateFormated(sKey, sFormat); 212 } 213 214 216 public short getShort(String sKey) throws java.lang.NullPointerException { 217 return oMember.getShort(sKey); 218 } 219 220 222 public String getString(String sKey) throws java.lang.NullPointerException { 223 return oMember.getString(sKey); 224 } 225 226 228 public String getStringNull(String sKey, String sDefault) { 229 return oMember.getStringNull(sKey, sDefault); 230 } 231 232 234 public boolean isNull(String sColumnName) { 235 return oMember.isNull(sColumnName); 236 } 237 238 240 public void put(String sKey, String sVal) { 241 oMember.put(sKey, sVal); 242 } 243 244 246 public void put(String sKey, short iVal) { 247 oMember.put(sKey, iVal); 248 } 249 250 252 public void put(String sKey, java.util.Date dtVal) { 253 oMember.put(sKey, dtVal); 254 } 255 256 258 public void put(String sKey, Object oObj) { 259 oMember.put(sKey, oObj); 260 } 261 262 264 public void replace(String sKey, Object oObj) { 265 oMember.replace(sKey,oObj); 266 } 267 268 270 public void replace(String sKey, short iVal) { 271 oMember.replace(sKey,iVal); 272 } 273 274 276 public void remove(String sKey) { 277 oMember.remove(sKey); 278 } 279 280 281 283 298 public boolean isBlocked (JDCConnection oConn) throws SQLException { 299 boolean bBlocked; 300 CallableStatement oCall; 301 PreparedStatement oStmt; 302 ResultSet oRSet; 303 String sList; 304 String sProc; 305 String sParm; 306 307 if (DebugFile.trace) { 308 DebugFile.writeln("Begin ListMember.isBlocked([Connection])"); 309 DebugFile.incIdent(); 310 } 311 312 sList = oMember.getString(DB.gu_list); 313 314 switch (oMember.getShort(DB.tp_member)) { 315 case Company.ClassId: 316 sProc = "k_sp_company_blocked"; 317 sParm = oMember.getString(DB.gu_company); 318 if (DebugFile.trace) DebugFile.writeln("gu_company=" + sParm); 319 break; 320 case Contact.ClassId: 321 sProc = "k_sp_contact_blocked"; 322 sParm = oMember.getString(DB.gu_contact); 323 if (DebugFile.trace) DebugFile.writeln("gu_contact=" + sParm); 324 break; 325 default: 326 sProc = "k_sp_email_blocked"; 327 sParm = oMember.getString(DB.tx_email); 328 if (DebugFile.trace) DebugFile.writeln("tx_email=" + sParm); 329 } 330 331 switch (oConn.getDataBaseProduct()) { 332 333 case JDCConnection.DBMS_POSTGRESQL: 334 if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(SELECT " + sProc + "(?,?))"); 335 336 oStmt = oConn.prepareStatement("SELECT " + sProc + "(?,?)", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 337 oStmt.setString(1, sList); 338 oStmt.setString(2, sParm); 339 oRSet = oStmt.executeQuery(); 340 oRSet.next(); 341 bBlocked = (oRSet.getShort(1)!=(short)0); 342 oRSet.close(); 343 oStmt.close(); 344 break; 345 346 case JDCConnection.DBMS_ORACLE: 347 if (DebugFile.trace) DebugFile.writeln("Connection.prepareCall({ call " + sProc + "(?,?,?)})"); 348 349 oCall = oConn.prepareCall("{ call " + sProc + "(?,?,?)}"); 350 oCall.setString(1, sList); 351 oCall.setString(2, sParm); 352 oCall.registerOutParameter(3, java.sql.Types.DECIMAL); 353 oCall.execute(); 354 bBlocked = (oCall.getBigDecimal(3).intValue()!=0); 355 oCall.close(); 356 break; 357 358 default: 359 if (DebugFile.trace) DebugFile.writeln("Connection.prepareCall({ call " + sProc + "(?,?,?)})"); 360 361 oCall = oConn.prepareCall("{ call " + sProc + "(?,?,?)}"); 362 oCall.setString(1, sList); 363 oCall.setString(2, sParm); 364 oCall.registerOutParameter(3, java.sql.Types.SMALLINT); 365 oCall.execute(); 366 bBlocked = (oCall.getShort(3)!=(short)0); 367 oCall.close(); 368 } 369 370 if (DebugFile.trace) { 371 DebugFile.decIdent(); 372 DebugFile.writeln("End ListMember.isBlocked() : " + String.valueOf(bBlocked)); 373 } 374 375 return bBlocked; 376 } 377 378 380 387 public boolean delete(JDCConnection oConn, String sListId) throws SQLException { 388 PreparedStatement oDlte; 389 PreparedStatement oStmt; 390 ResultSet oRSet; 391 boolean bRetVal; 392 String sBlackList; 393 394 if (DebugFile.trace) { 395 DebugFile.writeln("Begin ListMember.delete([Connection], " + sListId + ")"); 396 DebugFile.incIdent(); 397 } 398 399 401 if (DebugFile.trace) 402 DebugFile.writeln("Connection.prepareStatement(SELECT " + DB.gu_list + " FROM " + DB.k_lists + " WHERE " + DB.gu_query + "='" + sListId + "' AND " + DB.tp_list + "=" + String.valueOf(DistributionList.TYPE_BLACK) + ")"); 403 404 oStmt = oConn.prepareStatement("SELECT " + DB.gu_list + " FROM " + DB.k_lists + " WHERE " + DB.gu_query + "=? AND " + DB.tp_list + "=" + String.valueOf(DistributionList.TYPE_BLACK), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 405 oStmt.setString(1, sListId); 406 oRSet = oStmt.executeQuery(); 407 if (oRSet.next()) 408 sBlackList = oRSet.getString(1); 409 else 410 sBlackList = null; 411 oRSet.close(); 412 oStmt.close(); 413 414 416 if (null!=sBlackList) { 417 if (DebugFile.trace) 418 DebugFile.writeln("Connection.prepareStatement(DELETE FROM " + DB.k_x_list_members + " WHERE " + DB.gu_list + "='" + sBlackList + "' AND (" + DB.gu_contact + "='" + oMember.getStringNull(DB.gu_member,"null") + "' OR " + DB.gu_company + "='" + oMember.getStringNull(DB.gu_member,"null") + "' OR " + DB.tx_email + "='" + oMember.getStringNull(DB.tx_email,"null") + "'))"); 419 420 oDlte = oConn.prepareStatement("DELETE FROM " + DB.k_x_list_members + " WHERE " + DB.gu_list + "=? AND (" + DB.gu_contact + "=? OR " + DB.gu_company + "=? OR " + DB.tx_email + "=?)"); 421 422 oDlte.setString(1, sBlackList); 423 oDlte.setString(2, oMember.getString(DB.gu_member)); 424 oDlte.setString(3, oMember.getString(DB.gu_member)); 425 oDlte.setString(4, oMember.getString(DB.tx_email)); 426 427 if (DebugFile.trace) DebugFile.writeln("PreparedStatement.executeUpdate()"); 428 429 bRetVal = oDlte.executeUpdate()>0; 430 oDlte.close(); 431 } 432 433 435 if (DebugFile.trace) 436 DebugFile.writeln("Connection.prepareStatement(DELETE FROM " + DB.k_x_list_members + " WHERE " + DB.gu_list + "='" + sListId + "' AND (" + DB.gu_contact + "='" + oMember.getStringNull(DB.gu_member,"null") + "' OR " + DB.gu_company + "='" + oMember.getStringNull(DB.gu_member,"null") + "' OR " + DB.tx_email + "='" + oMember.getStringNull(DB.tx_email,"null") + "'))"); 437 438 oDlte = oConn.prepareStatement("DELETE FROM " + DB.k_x_list_members + " WHERE " + DB.gu_list + "=? AND (" + DB.gu_contact + "=? OR " + DB.gu_company + "=? OR " + DB.tx_email + "=?)"); 439 440 oDlte.setString(1, sListId); 441 oDlte.setString(2, oMember.getString(DB.gu_member)); 442 oDlte.setString(3, oMember.getString(DB.gu_member)); 443 oDlte.setString(4, oMember.getString(DB.tx_email)); 444 445 if (DebugFile.trace) DebugFile.writeln("PreparedStatement.executeUpdate()"); 446 447 bRetVal = oDlte.executeUpdate()>0; 448 oDlte.close(); 449 450 int iTpList = getListType(oConn, sListId); 451 452 if (DistributionList.TYPE_DIRECT==iTpList || DistributionList.TYPE_BLACK==iTpList) 453 bRetVal = oMember.delete(oConn); 454 455 if (DebugFile.trace) { 456 DebugFile.decIdent(); 457 DebugFile.writeln("End ListMember.delete() : " + String.valueOf(bRetVal)); 458 } 459 460 return bRetVal; 461 } 463 465 470 public boolean delete(JDCConnection oConn) throws SQLException { 471 PreparedStatement oDlte; 472 boolean bRetVal; 473 474 if (DebugFile.trace) { 475 DebugFile.writeln("Begin ListMember.delete([Connection])"); 476 DebugFile.incIdent(); 477 } 478 479 oDlte = oConn.prepareStatement("DELETE FROM " + DB.k_x_list_members + " WHERE " + DB.gu_contact + "=? OR " + DB.gu_company + "=?"); 480 oDlte.setString(1, oMember.getString(DB.gu_member)); 481 oDlte.setString(2, oMember.getString(DB.gu_member)); 482 oDlte.execute(); 483 oDlte.close(); 484 485 bRetVal = oMember.delete(oConn); 486 487 if (DebugFile.trace) { 488 DebugFile.decIdent(); 489 DebugFile.writeln("End ListMember.delete() : " + String.valueOf(bRetVal)); 490 } 491 492 return bRetVal; 493 } 495 497 506 507 public boolean store(JDCConnection oConn, String sListGUID) 508 throws ClassCastException ,NoSuchFieldException ,SQLException { 509 boolean bRetVal; 510 String sSQL; 511 java.sql.Timestamp dtNow = new java.sql.Timestamp (DBBind.getTime()); 512 PreparedStatement oStmt; 513 int iAffected; 514 515 if (DebugFile.trace) { 516 DebugFile.writeln("Begin ListMember.store([Connection])"); 517 DebugFile.incIdent(); 518 } 519 520 int iTpList = getListType(oConn, sListGUID); 521 522 if (iTpList==DistributionList.TYPE_DYNAMIC) 523 throw new ClassCastException ("Dynamic Distribution Lists cannot have additional Members directly added"); 524 525 if (!oMember.getItemMap().containsKey(DB.gu_member)) { 526 if (iTpList==DistributionList.TYPE_STATIC) 527 throw new NoSuchFieldException ("gu_member field must be set before storing a Member from a Static Distribution List"); 528 529 oMember.put(DB.gu_member, Gadgets.generateUUID()); 530 } 531 532 oMember.replace(DB.dt_modified, dtNow); 534 535 if (DistributionList.TYPE_DIRECT==iTpList || DistributionList.TYPE_BLACK==iTpList) 536 bRetVal = oMember.store(oConn); 537 538 if (DebugFile.trace) { 539 String sActive; 540 if (oMember.getItemMap().containsKey(DB.bo_active)) 541 sActive = String.valueOf(oMember.getShort(DB.bo_active)); 542 else 543 sActive = "null"; 544 545 sSQL = "UPDATE " + DB.k_x_list_members + " SET " + DB.tx_email + "='" + oMember.getStringNull(DB.tx_email,"null") + "'," + DB.tx_name + "=?," + DB.tx_surname + "=?," + DB.tx_salutation + "=?,"+ DB.bo_active + "=" + sActive + "," + DB.id_format + "='" + oMember.getStringNull(DB.id_format, "TXT") + "'," + DB.dt_modified + "=" + DBBind.escape(new java.util.Date (), "ts") + " WHERE " + DB.gu_list + "='" + sListGUID + "' AND (" + DB.gu_contact + "='" + oMember.getStringNull(DB.gu_member,"null") + "' OR " + DB.gu_company + "=? OR " + DB.tx_email + "='" + oMember.getStringNull(DB.tx_email,"null") + "')"; 546 547 DebugFile.writeln("Connection.prepareStatement(" + sSQL + ")"); 548 } 549 550 sSQL = "UPDATE " + DB.k_x_list_members + " SET " + DB.tx_email + "=?," + DB.tx_name + "=?," + DB.tx_surname + "=?," + DB.tx_salutation + "=?,"+ DB.bo_active + "=?," + DB.id_format + "=?," + DB.dt_modified + "=" + DBBind.escape(new java.util.Date (), "ts") + " WHERE " + DB.gu_list + "=? AND (" + DB.gu_contact + "=? OR " + DB.gu_company + "=? OR " + DB.tx_email + "=?)"; 551 552 oStmt = oConn.prepareStatement(sSQL); 553 554 oStmt.setString(1, oMember.getString(DB.tx_email)); 555 oStmt.setString(2, oMember.getStringNull(DB.tx_name, null)); 556 oStmt.setString(3, oMember.getStringNull(DB.tx_surname, null)); 557 oStmt.setString(4, oMember.getStringNull(DB.tx_salutation, null)); 558 559 if (oMember.getItemMap().containsKey(DB.bo_active)) 560 oStmt.setShort (5, oMember.getShort(DB.bo_active)); 561 else 562 oStmt.setShort (5, (short)1); 563 564 oStmt.setString(6, oMember.getStringNull(DB.id_format, "TXT")); 565 566 oStmt.setString(7, sListGUID); 567 568 if (oMember.getItemMap().containsKey(DB.tp_member)) { 569 570 if (DebugFile.trace) DebugFile.writeln("tp_member=" + String.valueOf(oMember.getShort(DB.tp_member))); 571 572 if (oMember.getShort(DB.tp_member)==Company.ClassId) { 573 574 if (DebugFile.trace) 575 DebugFile.writeln("gu_contact=" + oMember.getStringNull(DB.gu_member,"null") + " , gu_company=null"); 576 577 oStmt.setString(8, oMember.getString(DB.gu_member)); 578 oStmt.setString(9, null); 579 } 580 else { 581 if (DebugFile.trace) 582 DebugFile.writeln("gu_contact=null, gu_company=" + oMember.getStringNull(DB.gu_member,"null")); 583 584 oStmt.setString(8, null); 585 oStmt.setString(9, oMember.getString(DB.gu_member)); 586 } 587 } 588 else { 589 if (DebugFile.trace) DebugFile.writeln("tp_member not set"); 590 591 if (DebugFile.trace) 592 DebugFile.writeln("gu_contact=null, gu_company=" + oMember.getStringNull(DB.gu_member,"null")); 593 594 oStmt.setString(8, null); 595 oStmt.setString(9, oMember.getString(DB.gu_member)); 596 } 597 598 oStmt.setString(10, oMember.getString(DB.tx_email)); 599 600 if (DebugFile.trace) DebugFile.writeln("PreparedStatement.executeUpdate()"); 601 602 iAffected = oStmt.executeUpdate(); 603 604 if (DebugFile.trace) DebugFile.writeln("affected rows = " + String.valueOf(iAffected)); 605 606 oStmt.close(); 607 608 if (0==iAffected) { 609 610 if (DebugFile.trace) { 611 sSQL = "INSERT INTO " + DB.k_x_list_members + " (" + DB.gu_list + "," + DB.tx_email + "," + DB.tx_name + "," + DB.tx_surname + "," + DB.tx_salutation + "," + DB.bo_active + "," + DB.tp_member + "," + DB.gu_company + "," + DB.gu_contact + "," + DB.id_format + ") VALUES ('" + sListGUID + "','" + oMember.getStringNull(DB.tx_email,"null") + "',?,?,?,?,?,?,'" + oMember.getStringNull(DB.gu_member,"null") + "','" + oMember.getStringNull(DB.id_format,"TXT") + "')"; 612 613 DebugFile.writeln("Connection.prepareStatement(" + sSQL + ")"); 614 } 615 616 sSQL = "INSERT INTO " + DB.k_x_list_members + " (" + DB.gu_list + "," + DB.tx_email + "," + DB.tx_name + "," + DB.tx_surname + "," + DB.tx_salutation + "," + DB.bo_active + "," + DB.tp_member + "," + DB.gu_company + "," + DB.gu_contact + "," + DB.id_format + ") VALUES (?,?,?,?,?,?,?,?,?,?)"; 617 618 oStmt = oConn.prepareStatement(sSQL); 619 oStmt.setString(1, sListGUID); 620 oStmt.setString(2, oMember.getString(DB.tx_email)); 621 oStmt.setString(3, oMember.getStringNull(DB.tx_name,null)); 622 oStmt.setString(4, oMember.getStringNull(DB.tx_surname,null)); 623 oStmt.setString(5, oMember.getStringNull(DB.tx_salutation,null)); 624 625 if (oMember.getItemMap().containsKey(DB.bo_active)) 626 oStmt.setShort (6, oMember.getShort(DB.bo_active)); 627 else 628 oStmt.setShort (6, (short)1); 629 630 if (oMember.getItemMap().containsKey(DB.tp_member)) { 631 if (DebugFile.trace) DebugFile.writeln ("member type is " + String.valueOf(oMember.getShort(DB.tp_member))); 632 633 oStmt.setShort(7, oMember.getShort(DB.tp_member)); 634 635 if (oMember.getShort(DB.tp_member)==Company.ClassId) { 636 oStmt.setString(8, oMember.getString(DB.gu_member)); 637 oStmt.setString(9, null); 638 } 639 else { 640 oStmt.setString(8, null); 641 oStmt.setString(9, oMember.getString(DB.gu_member)); 642 } 643 } 644 else { 645 646 if (new Contact(getString(DB.gu_member)).exists(oConn)) { 647 if (DebugFile.trace) DebugFile.writeln("member type automatically set to " + String.valueOf(Contact.ClassId)); 648 649 oStmt.setShort (7, Contact.ClassId); 650 oStmt.setString(8, null); 651 oStmt.setString(9, oMember.getString(DB.gu_member)); 652 } 653 else if (new Company(getString(DB.gu_member)).exists(oConn)) { 654 if (DebugFile.trace) DebugFile.writeln("member type automatically set to " + String.valueOf(Company.ClassId)); 655 656 oStmt.setShort (7, Company.ClassId); 657 oStmt.setString(8, oMember.getString(DB.gu_member)); 658 oStmt.setString(9, null); 659 } 660 else { 661 if (DebugFile.trace) DebugFile.writeln("member type automatically set to " + String.valueOf(ListMember.ClassId)); 662 663 oStmt.setShort (7, ListMember.ClassId); 664 oStmt.setString(8, null); 665 oStmt.setString(9, oMember.getString(DB.gu_member)); 666 } 667 } 668 669 oStmt.setString(10, oMember.getStringNull(DB.id_format,"TXT")); 670 671 if (DebugFile.trace) DebugFile.writeln("PreparedStatement.execute()"); 672 673 bRetVal = oStmt.execute(); 674 675 oStmt.close(); 676 } 677 else 678 bRetVal = true; 679 680 if (DebugFile.trace) { 681 DebugFile.decIdent(); 682 DebugFile.writeln("End ListMember.store() : " + String.valueOf(bRetVal)); 683 } 684 685 return bRetVal; 686 } 688 696 697 public void block (JDCConnection oConn, String sListGUID) 698 throws SQLException , NoSuchFieldException { 699 700 if (DebugFile.trace) { 701 DebugFile.writeln("Begin ListMember.block([Connection], " + sListGUID + ")"); 702 DebugFile.incIdent(); 703 } 704 705 DistributionList oList = new DistributionList(oConn, sListGUID); 706 707 String sBlack = oList.blackList (oConn); 708 709 if (null==sBlack) { 710 sBlack = Gadgets.generateUUID(); 711 712 if (DebugFile.trace) 713 DebugFile.writeln("Connection.prepareStatement(INSERT INTO " + DB.k_lists + "(" + DB.gu_list + "," + DB.gu_workarea + "," + DB.tp_list + "," + DB.gu_query + "," + DB.de_list + ") VALUES('" + sBlack + "','" + getStringNull(DB.gu_workarea,"null") + "',4,'" + getStringNull(DB.gu_list,"null") + "','" + getStringNull(DB.de_list,"null") + "'))"); 714 715 PreparedStatement oStmt = oConn.prepareStatement("INSERT INTO " + DB.k_lists + "(" + DB.gu_list + "," + DB.gu_workarea + "," + DB.tp_list + "," + DB.gu_query + "," + DB.de_list + ") VALUES(?,?,?,?,?)"); 716 oStmt.setString(1, sBlack); 717 oStmt.setString(2, oList.getString(DB.gu_workarea)); 718 oStmt.setShort (3, DistributionList.TYPE_BLACK); 719 oStmt.setString(4, sListGUID); 720 oStmt.setString(5, oList.getString(DB.de_list)); 721 oStmt.executeUpdate(); 722 oStmt.close(); 723 } 724 725 store (oConn, sBlack); 726 727 if (DebugFile.trace) { 728 DebugFile.decIdent(); 729 DebugFile.writeln("End ListMember.block()"); 730 } 731 } 732 733 740 741 public void unblock (JDCConnection oConn, String sListGUID) 742 throws SQLException { 743 744 if (DebugFile.trace) { 745 DebugFile.writeln("Begin ListMember.unblock([Connection], " + sListGUID + ")"); 746 DebugFile.incIdent(); 747 } 748 749 DistributionList oList = new DistributionList(oConn, sListGUID); 750 751 String sBlack = oList.blackList (oConn); 752 753 if (null!=sBlack) { 754 if (DebugFile.trace) 755 DebugFile.writeln("Connection.prepareStatement(DELETE FROM " + DB.k_x_list_members + " WHERE " + DB.gu_list + "='" + sBlack + "' AND " + DB.tx_email + "='" + getStringNull(DB.tx_email,"null")+ "')"); 756 757 PreparedStatement oDlte = oConn.prepareStatement("DELETE FROM " + DB.k_x_list_members + " WHERE " + DB.gu_list + "=? AND " + DB.tx_email + "=?"); 758 oDlte.setString (1, sBlack); 759 oDlte.setString (2, getString(DB.tx_email)); 760 oDlte.executeUpdate(); 761 oDlte.close(); 762 } 763 764 if (DebugFile.trace) { 765 DebugFile.decIdent(); 766 DebugFile.writeln("End ListMember.unblock()"); 767 } 768 } 770 771 774 public static final short ClassId = 95; 775 776 } | Popular Tags |