1 32 33 package com.knowgate.workareas; 34 35 import java.io.IOException ; 36 37 import java.sql.Connection ; 38 import java.sql.Date ; 39 import java.sql.ResultSet ; 40 import java.sql.Statement ; 41 import java.sql.PreparedStatement ; 42 import java.sql.CallableStatement ; 43 import java.sql.SQLException ; 44 import java.sql.Types ; 45 46 import com.knowgate.jdc.JDCConnection; 47 import com.knowgate.debug.DebugFile; 48 import com.knowgate.misc.Gadgets; 49 import com.knowgate.dataobjs.*; 50 51 import com.knowgate.addrbook.Room; 52 import com.knowgate.addrbook.Meeting; 53 import com.knowgate.addrbook.Fellow; 54 55 import com.knowgate.crm.Company; 56 import com.knowgate.crm.Contact; 57 import com.knowgate.crm.DistributionList; 58 59 import com.knowgate.projtrack.Project; 60 61 import com.knowgate.hipergate.Image; 62 63 import com.knowgate.dataxslt.db.*; 64 65 import com.knowgate.hipergate.QueryByForm; 66 import com.knowgate.hipergate.Shop; 67 68 import com.knowgate.scheduler.Job; 69 70 75 public class WorkArea extends DBPersist { 76 77 80 public WorkArea() { 81 super(DB.k_workareas, "WorkArea"); 82 } 83 84 86 92 public WorkArea(JDCConnection oConn, String sIdWorkArea) throws SQLException { 93 super(DB.k_workareas, "WorkArea"); 94 95 Object aWrkA[] = { sIdWorkArea }; 96 97 load (oConn,aWrkA); 98 } 99 100 102 110 public boolean delete(JDCConnection oConn) throws SQLException { 111 return WorkArea.delete(oConn, getString(DB.gu_workarea)); 112 } 113 114 116 public boolean store(JDCConnection oConn) throws SQLException { 117 118 if (!AllVals.containsKey(DB.gu_workarea)) 121 put(DB.gu_workarea, Gadgets.generateUUID()); 122 123 return super.store(oConn); 124 } 125 126 128 public int getUserAppMask(JDCConnection oConn, String sUserId) throws SQLException { 129 return WorkArea.getUserAppMask(oConn, getString(DB.gu_workarea), sUserId); 130 } 131 132 134 public DBSubset getUsers(JDCConnection oConn) throws SQLException { 135 Object oGroups[] = { get(DB.gu_admins), get(DB.gu_powusers), get(DB.gu_users), get(DB.gu_guests), get(DB.gu_other) }; 136 DBSubset oUsers = new DBSubset(DB.k_users + " u", 137 "u." + DB.gu_user +",u." + DB.tx_nickname + ",u." + DB.nm_user + ",u." + DB.tx_surname1 + ",u." + DB.tx_surname2 + ",u." + DB.bo_searchable + ",u." + DB.tx_main_email, 138 "EXISTS (SELECT x." + DB.gu_user + " FROM " + DB.k_x_group_user + " x WHERE " + DB.gu_user + "=u." + DB.gu_user + " AND x." + DB.gu_acl_group + " IN (?,?,?,?,?)) ORDER BY 3,4,5", 4); 139 oUsers.load(oConn, oGroups); 140 141 return oUsers; 142 } 143 144 147 201 public static boolean delete(JDCConnection oConn, String sWrkAreaGUID) throws SQLException { 202 CallableStatement oCall; 203 Statement oStmt; 204 PreparedStatement oPtmt; 205 ResultSet oRSet; 206 DBSubset oItems; 207 String sSQL; 208 int iItems; 209 210 if (DebugFile.trace) { 211 DebugFile.writeln("Begin WorkArea.delete([Connection], " + sWrkAreaGUID + ")"); 212 DebugFile.incIdent(); 213 } 214 215 220 oPtmt = oConn.prepareStatement("SELECT "+DB.gu_workarea+" FROM "+DB.k_workareas+" WHERE "+DB.gu_workarea+"=?", 221 ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 222 oPtmt.setString(1, sWrkAreaGUID); 223 oRSet = oPtmt.executeQuery(); 224 boolean bExists = oRSet.next(); 225 oRSet.close(); 226 oPtmt.close(); 227 228 if (!bExists) { 229 if (DebugFile.trace) { 230 DebugFile.writeln("workarea " + sWrkAreaGUID + " not found"); 231 DebugFile.decIdent(); 232 DebugFile.writeln("End WorkArea.delete() : false"); 233 } 234 return false; 235 } 236 237 240 if (DBBind.exists(oConn, DB.k_mime_msgs, "U")) { 241 oStmt = oConn.createStatement(); 242 243 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_cat_objs + " WHERE " + DB.gu_object + " IN (SELECT " + DB.gu_mimemsg + " FROM k_mime_msgs WHERE gu_workarea='" + sWrkAreaGUID + "') AND " + DB.id_class + "=822)"); 244 245 oStmt.executeUpdate("DELETE FROM " + DB.k_x_cat_objs + " WHERE " + DB.gu_object + " IN (SELECT " + DB.gu_mimemsg + " FROM k_mime_msgs WHERE gu_workarea='" + sWrkAreaGUID + "') AND " + DB.id_class + "=822"); 246 247 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_inet_addrs + " WHERE " + DB.gu_mimemsg + " IN (SELECT " + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'))"); 248 249 oStmt.executeUpdate("DELETE FROM " + DB.k_inet_addrs + " WHERE " + DB.gu_mimemsg + " IN (SELECT " + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"); 250 251 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_mime_parts + " WHERE " + DB.gu_mimemsg + " IN (SELECT " + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'))"); 252 253 oStmt.executeUpdate("DELETE FROM " + DB.k_mime_parts + " WHERE " + DB.gu_mimemsg + " IN (SELECT " + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"); 254 255 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"); 256 257 oStmt.executeUpdate("DELETE FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"); 258 259 oStmt.close(); 260 } 261 262 265 if (DBBind.exists(oConn, DB.k_x_portlet_user, "U")) { 266 oStmt = oConn.createStatement(); 267 268 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_portlet_user + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"); 269 270 oStmt.executeUpdate("DELETE FROM " + DB.k_x_portlet_user + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"); 271 272 oStmt.close(); 273 } 274 275 278 if (DBBind.exists(oConn, DB.k_queries, "U")) { 279 oItems = new DBSubset (DB.k_queries, DB.gu_query, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 280 iItems = oItems.load(oConn); 281 282 for (int p=0;p<iItems; p++) 283 QueryByForm.delete(oConn, oItems.getString(0, p)); 284 } 285 287 if (DBBind.exists(oConn, DB.k_pagesets, "U")) { 289 oItems = new DBSubset (DB.k_pagesets, DB.gu_pageset, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 290 iItems = oItems.load(oConn); 291 for (int p=0;p<iItems; p++) 292 PageSetDB.delete(oConn, oItems.getString(0,p)); 293 } 294 295 297 if (DBBind.exists(oConn, DB.k_microsites, "U")) { 299 oItems = new DBSubset (DB.k_microsites, DB.gu_microsite, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 300 iItems = oItems.load(oConn); 301 for (int p=0;p<iItems; p++) 302 new MicrositeDB(oConn, oItems.getString(0,p)).delete(oConn); 303 } 304 305 309 if (DBBind.exists(oConn, DB.k_images, "U")) { 310 oItems = new DBSubset (DB.k_images, DB.gu_image, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 311 iItems = oItems.load(oConn); 312 for (int p=0;p<iItems; p++) 313 new Image(oConn, oItems.getString(0,p)).delete(oConn); 314 } 315 316 if (DBBind.exists(oConn, DB.k_lists, "U")) { 319 oItems = new DBSubset (DB.k_lists, DB.gu_list, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 320 iItems = oItems.load(oConn); 321 for (int p=0;p<iItems; p++) 322 DistributionList.delete(oConn, oItems.getString(0,p)); 323 } 324 326 328 if (DBBind.exists(oConn, DB.k_meetings, "U")) { 329 oItems = new DBSubset (DB.k_meetings, DB.gu_meeting, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 330 iItems = oItems.load(oConn); 331 for (int c=0;c<iItems; c++) 332 Meeting.delete(oConn, oItems.getString(0,c)); 333 } 334 335 if (DBBind.exists(oConn, DB.k_fellows, "U")) { 336 oItems = new DBSubset (DB.k_fellows, DB.gu_fellow, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 337 iItems = oItems.load(oConn); 338 for (int c=0;c<iItems; c++) 339 Fellow.delete(oConn, oItems.getString(0,c)); 340 } 341 342 if (DBBind.exists(oConn, DB.k_lu_fellow_titles, "U")) { 343 oStmt = oConn.createStatement(); 344 sSQL = "DELETE FROM " + DB.k_lu_fellow_titles + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 345 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 346 oStmt.execute(sSQL); 347 oStmt.close(); 348 } 349 350 if (DBBind.exists(oConn, DB.k_fellows_lookup, "U")) { 351 oStmt = oConn.createStatement(); 352 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 353 sSQL = "DELETE FROM " + DB.k_fellows_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 354 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 355 oStmt.execute(sSQL); 356 oStmt.close(); 357 } 358 359 if (DBBind.exists(oConn, DB.k_rooms, "U")) { 360 oItems = new DBSubset (DB.k_rooms, DB.nm_room, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 361 iItems = oItems.load(oConn); 362 for (int c=0;c<iItems; c++) 363 Room.delete(oConn, oItems.getString(0,c), sWrkAreaGUID); 364 } 365 366 if (DBBind.exists(oConn, DB.k_rooms_lookup, "U")) { 367 oStmt = oConn.createStatement(); 368 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 369 sSQL = "DELETE FROM " + DB.k_rooms_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 370 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 371 oStmt.execute(sSQL); 372 oStmt.close(); 373 } 374 375 378 if (DBBind.exists(oConn, DB.k_to_do, "U")) { 379 oStmt = oConn.createStatement(); 380 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 381 sSQL = "DELETE FROM " + DB.k_to_do + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 382 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 383 oStmt.execute(sSQL); 384 oStmt.close(); 385 } 386 387 if (DBBind.exists(oConn, DB.k_to_do_lookup, "U")) { 388 oStmt = oConn.createStatement(); 389 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 390 sSQL = "DELETE FROM " + DB.k_to_do_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 391 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 392 oStmt.execute(sSQL); 393 oStmt.close(); 394 } 395 396 399 if (DBBind.exists(oConn, DB.k_phone_calls, "U")) { 400 oStmt = oConn.createStatement(); 401 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 402 sSQL = "DELETE FROM " + DB.k_phone_calls + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 403 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 404 oStmt.execute(sSQL); 405 oStmt.close(); 406 } 407 408 411 if (DBBind.exists(oConn, DB.k_member_address, "U")) { 412 413 oStmt = oConn.createStatement(); 414 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 415 416 sSQL = "DELETE FROM " + DB.k_member_address + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 417 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")"); 418 oStmt.executeUpdate(sSQL); 419 420 oStmt.close(); 421 } 422 423 425 if (DBBind.exists(oConn, DB.k_sales_men, "U")) { 427 oItems = new DBSubset (DB.k_sales_men, DB.gu_sales_man, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 428 iItems = oItems.load(oConn); 429 430 if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) { 431 if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(SELECT k_sp_del_sales_man (?))"); 432 oPtmt = oConn.prepareStatement("SELECT k_sp_del_sales_man (?)"); 433 for (int c=0;c<iItems; c++) { 434 oPtmt.setString(1, oItems.getString(0,c)); 435 oPtmt.executeQuery(); 436 } oPtmt.close(); 438 } 439 else { 440 if (DebugFile.trace) DebugFile.writeln("Connection.prepareCall({ call k_sp_del_sales_man (?) })"); 441 oCall = oConn.prepareCall("{call k_sp_del_sales_man (?)}"); 442 for (int c=0;c<iItems; c++) { 443 oCall.setString(1, oItems.getString(0,c)); 444 oCall.execute(); 445 } oCall.close(); 447 } 448 } 450 if (DBBind.exists(oConn, DB.k_sales_men_lookup, "U")) { 451 oStmt = oConn.createStatement(); 452 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 453 sSQL = "DELETE FROM " + DB.k_sales_men_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 454 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 455 oStmt.execute(sSQL); 456 oStmt.close(); 457 } 458 459 461 if (DBBind.exists(oConn, DB.k_companies, "U")) { 463 oItems = new DBSubset (DB.k_companies, DB.gu_company, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 464 iItems = oItems.load(oConn); 465 for (int c=0;c<iItems; c++) 466 Company.delete(oConn, oItems.getString(0,c)); 467 } 468 469 if (DBBind.exists(oConn, DB.k_contacts, "U")) { 471 oItems = new DBSubset (DB.k_contacts, DB.gu_contact, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 472 iItems = oItems.load(oConn); 473 for (int c=0;c<iItems; c++) 474 Contact.delete(oConn, oItems.getString(0,c)); 475 } 476 477 if (DBBind.exists(oConn, DB.k_companies_lookup, "U")) { 478 oStmt = oConn.createStatement(); 479 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 480 sSQL = "DELETE FROM " + DB.k_companies_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 481 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 482 oStmt.execute(sSQL); 483 oStmt.close(); 484 } 485 486 if (DBBind.exists(oConn, DB.k_contacts_lookup, "U")) { 487 oStmt = oConn.createStatement(); 488 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 489 sSQL = "DELETE FROM " + DB.k_contacts_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 490 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 491 oStmt.execute(sSQL); 492 oStmt.close(); 493 } 494 495 if (DBBind.exists(oConn, DB.k_oportunities_lookup, "U")) { 496 oStmt = oConn.createStatement(); 497 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 498 sSQL = "DELETE FROM " + DB.k_oportunities_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 499 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 500 oStmt.execute(sSQL); 501 oStmt.close(); 502 } 503 504 if (DBBind.exists(oConn, DB.k_welcome_packs_lookup, "U")) { 505 oStmt = oConn.createStatement(); 506 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 507 sSQL = "DELETE FROM " + DB.k_welcome_packs_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 508 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 509 oStmt.execute(sSQL); 510 oStmt.close(); 511 } 512 513 515 if (DBBind.exists(oConn, DB.k_projects, "U")) { 517 oItems = new DBSubset (DB.k_projects, DB.gu_project, DB.gu_owner + "='" + sWrkAreaGUID + "'", 100); 518 iItems = oItems.load(oConn); 519 for (int p=0;p<iItems; p++) 520 Project.delete(oConn, oItems.getString(0,p)); 521 } 522 523 if (DBBind.exists(oConn, DB.k_projects_lookup, "U")) { 524 oStmt = oConn.createStatement(); 525 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 526 sSQL = "DELETE FROM " + DB.k_projects_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 527 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 528 oStmt.execute(sSQL); 529 oStmt.close(); 530 } 531 532 if (DBBind.exists(oConn, DB.k_duties_lookup, "U")) { 533 oStmt = oConn.createStatement(); 534 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 535 sSQL = "DELETE FROM " + DB.k_duties_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 536 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 537 oStmt.execute(sSQL); 538 oStmt.close(); 539 } 540 541 if (DBBind.exists(oConn, DB.k_bugs_lookup, "U")) { 542 oStmt = oConn.createStatement(); 543 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 544 sSQL = "DELETE FROM " + DB.k_bugs_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 545 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 546 oStmt.execute(sSQL); 547 oStmt.close(); 548 } 549 550 553 if (DBBind.exists(oConn, DB.k_invoices, "U")) { 554 oStmt = oConn.createStatement(); 555 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 556 557 sSQL = "DELETE FROM " + DB.k_x_orders_invoices + " WHERE " + DB.gu_order + " IN (SELECT "+DB.gu_order+" FROM "+DB.k_orders+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')"; 558 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 559 oStmt.execute(sSQL); 560 561 sSQL = "DELETE FROM " + DB.k_invoice_lines + " WHERE " + DB.gu_invoice + " IN (SELECT "+DB.gu_invoice+" FROM "+DB.k_invoices+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')"; 562 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 563 oStmt.execute(sSQL); 564 565 sSQL = "DELETE FROM " + DB.k_invoice_schedules + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 566 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 567 oStmt.execute(sSQL); 568 569 sSQL = "DELETE FROM " + DB.k_invoices + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 570 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 571 oStmt.execute(sSQL); 572 573 sSQL = "DELETE FROM " + DB.k_invoices_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 574 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 575 oStmt.execute(sSQL); 576 577 oStmt.close(); 578 } 579 580 if (DBBind.exists(oConn, DB.k_invoices_next, "U")) { 581 oStmt = oConn.createStatement(); 582 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 583 sSQL = "DELETE FROM " + DB.k_invoices_next + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 584 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 585 oStmt.execute(sSQL); 586 oStmt.close(); 587 } 588 589 if (DBBind.exists(oConn, DB.k_orders, "U")) { 590 oStmt = oConn.createStatement(); 591 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 592 593 sSQL = "DELETE FROM " + DB.k_order_lines + " WHERE " + DB.gu_order + " IN (SELECT "+DB.gu_order+" FROM "+DB.k_orders+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')"; 594 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 595 oStmt.execute(sSQL); 596 597 sSQL = "DELETE FROM " + DB.k_orders + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 598 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 599 oStmt.execute(sSQL); 600 601 sSQL = "DELETE FROM " + DB.k_orders_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 602 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 603 oStmt.execute(sSQL); 604 oStmt.close(); 605 } 606 607 if (DBBind.exists(oConn, DB.k_business_states, "U")) { 608 oStmt = oConn.createStatement(); 609 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 610 611 sSQL = "DELETE FROM " + DB.k_business_states + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 612 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 613 oStmt.execute(sSQL); 614 615 sSQL = "DELETE FROM " + DB.k_lu_business_states + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 616 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 617 oStmt.execute(sSQL); 618 619 oStmt.close(); 620 } 621 622 if (DBBind.exists(oConn, DB.k_shops, "U")) { 623 oItems = new DBSubset (DB.k_shops, DB.gu_shop, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 624 iItems = oItems.load(oConn); 625 for (int s=0;s<iItems; s++) 626 new Shop(oConn, oItems.getString(0,s)).delete(oConn); 627 } 628 629 632 if (DBBind.exists(oConn, DB.k_jobs, "U")) { 633 oItems = new DBSubset (DB.k_jobs, DB.gu_job, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 634 iItems = oItems.load(oConn); 635 for (int s=0;s<iItems; s++) 636 Job.delete(oConn, oItems.getString(0,s)); 637 } 638 639 641 if (DBBind.exists(oConn, DB.k_lu_meta_attrs, "U")) { 643 oStmt = oConn.createStatement(); 644 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 645 sSQL = "DELETE FROM " + DB.k_lu_meta_attrs + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 646 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 647 oStmt.execute(sSQL); 648 oStmt.close(); 649 } 650 651 654 oStmt = oConn.createStatement(); 655 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 656 657 sSQL = "UPDATE " + DB.k_orders + " SET " + DB.gu_ship_addr + "=NULL WHERE " + DB.gu_ship_addr + " IN (SELECT " + DB.gu_address + " FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"; 658 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 659 oStmt.execute(sSQL); 660 661 sSQL = "UPDATE " + DB.k_orders + " SET " + DB.gu_bill_addr + "=NULL WHERE " + DB.gu_bill_addr + " IN (SELECT " + DB.gu_address + " FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"; 662 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 663 oStmt.execute(sSQL); 664 665 sSQL = "DELETE FROM " + DB.k_x_contact_addr + " WHERE " + DB.gu_address + " IN (SELECT " + DB.gu_address + " FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"; 666 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 667 oStmt.execute(sSQL); 668 669 sSQL = "DELETE FROM " + DB.k_x_company_addr + " WHERE " + DB.gu_address + " IN (SELECT " + DB.gu_address + " FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"; 670 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 671 oStmt.execute(sSQL); 672 673 sSQL = "DELETE FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 674 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 675 oStmt.execute(sSQL); 676 677 sSQL = "DELETE FROM " + DB.k_addresses_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 678 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 679 oStmt.execute(sSQL); 680 681 oStmt.close(); 682 683 685 if (DBBind.exists(oConn, DB.k_thesauri, "U")) { 687 oStmt = oConn.createStatement(); 688 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 689 690 sSQL = "DELETE FROM " + DB.k_thesauri + " WHERE " + DB.bo_mainterm + "=0 AND " + DB.gu_rootterm + " IN (SELECT " + DB.gu_rootterm + " FROM " + DB.k_thesauri_root + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"; 692 693 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")"); 694 oStmt.executeUpdate(sSQL); 695 696 sSQL = "DELETE FROM " + DB.k_thesauri + " WHERE " + DB.gu_rootterm + " IN (SELECT " + DB.gu_rootterm + " FROM " + DB.k_thesauri_root + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')"; 698 699 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")"); 700 oStmt.executeUpdate(sSQL); 701 702 sSQL = "DELETE FROM " + DB.k_thesauri_root + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 704 705 if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")"); 706 oStmt.executeUpdate(sSQL); 707 708 oStmt.close(); 709 } 710 711 if (DBBind.exists(oConn, DB.k_thesauri_lookup, "U")) { 713 oStmt = oConn.createStatement(); 714 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 715 sSQL = "DELETE FROM " + DB.k_thesauri_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 716 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 717 oStmt.execute(sSQL); 718 oStmt.close(); 719 } 720 721 724 if (DBBind.exists(oConn, DB.k_bank_accounts, "U")) { 725 oStmt = oConn.createStatement(); 726 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 727 sSQL = "DELETE FROM " + DB.k_bank_accounts + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 728 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 729 oStmt.execute(sSQL); 730 oStmt.close(); 731 } 732 733 if (DBBind.exists(oConn, DB.k_bank_accounts_lookup, "U")) { 734 oStmt = oConn.createStatement(); 735 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 736 sSQL = "DELETE FROM " + DB.k_bank_accounts_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 737 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 738 oStmt.execute(sSQL); 739 oStmt.close(); 740 } 741 742 746 if (DBBind.exists(oConn, DB.k_absentisms_lookup, "U")) { 747 oStmt = oConn.createStatement(); 748 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 749 sSQL = "DELETE FROM " + DB.k_absentisms_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 750 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 751 oStmt.execute(sSQL); 752 oStmt.close(); 753 } 754 755 if (DBBind.exists(oConn, DB.k_subjects, "U")) { 756 oStmt = oConn.createStatement(); 757 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 758 sSQL = "DELETE FROM " + DB.k_subjects_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 759 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 760 oStmt.execute(sSQL); 761 sSQL = "DELETE FROM " + DB.k_subjects + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 762 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 763 oStmt.execute(sSQL); 764 oStmt.close(); 765 } 766 767 if (DBBind.exists(oConn, DB.k_courses, "U")) { 768 oStmt = oConn.createStatement(); 769 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 770 sSQL = "DELETE FROM " + DB.k_courses_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'"; 771 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 772 oStmt.execute(sSQL); 773 oStmt.close(); 774 775 oItems = new DBSubset (DB.k_courses, DB.gu_course, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100); 776 iItems = oItems.load(oConn); 777 if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) { 778 oPtmt = oConn.prepareStatement("SELECT k_sp_del_course(?)"); 779 for (int c=0; c<iItems; c++) { 780 oPtmt.setString(1, oItems.getString(0,c)); 781 oPtmt.executeQuery(); 782 } 783 oPtmt.close(); 784 } 785 else { 786 oCall = oConn.prepareCall("{call k_sp_del_course (?)}"); 787 for (int c=0;c<iItems; c++) { 788 oCall.setString(1, oItems.getString(0,c)); 789 oCall.execute(); 790 } 791 oCall.close(); 792 } } 795 796 oStmt = oConn.createStatement(); 799 try { oStmt.setQueryTimeout(30); } catch (SQLException sqle) {} 800 801 sSQL = "DELETE FROM " + DB.k_x_app_workarea + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 802 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 803 oStmt.execute(sSQL); 804 805 sSQL = "DELETE FROM " + DB.k_workareas + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"; 806 if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")"); 807 oStmt.execute(sSQL); 808 oStmt.close(); 809 810 if (DebugFile.trace) { 811 DebugFile.decIdent(); 812 DebugFile.writeln("End WorkArea.delete() : true"); 813 } 814 815 return true; 816 } 818 820 838 public static boolean delete (JDCConnection oConn, 839 String sWrkAreaGUID, 840 java.util.Properties oProps) throws Exception , IOException , SQLException { 841 842 final String s = System.getProperty("file.separator"); 843 844 if (DebugFile.trace) { 845 DebugFile.writeln("Begin WorkArea.delete([Connection], " + sWrkAreaGUID + ", " + "[Properties])"); 846 DebugFile.incIdent(); 847 } 848 849 int iDomainId = 0; 850 851 if (DebugFile.trace) 852 DebugFile.writeln("Connection.prepareStatement(SELECT " + DB.id_domain + " FROM " + DB.k_workareas + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'"); 853 854 PreparedStatement oStmt = oConn.prepareStatement("SELECT " + DB.id_domain + " FROM " + DB.k_workareas + " WHERE " + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 855 oStmt.setString(1, sWrkAreaGUID); 856 ResultSet oRSet = oStmt.executeQuery(); 857 if (oRSet.next()) 858 iDomainId = oRSet.getInt(1); 859 oRSet.close(); 860 oStmt.close(); 861 862 boolean bRetVal = false; 863 864 if (0!=iDomainId) { 865 FileSystemWorkArea oFS = new FileSystemWorkArea(oProps); 866 867 bRetVal = delete(oConn, sWrkAreaGUID); 868 869 if (bRetVal) { 870 if (null != oProps.getProperty("workareasput")) 871 oFS.rmworkpath(sWrkAreaGUID); 872 873 if (null != oProps.getProperty("storage")) 874 oFS.rmstorpath(iDomainId, sWrkAreaGUID); 875 876 } } 879 if (DebugFile.trace) { 880 DebugFile.decIdent(); 881 DebugFile.writeln("End WorkArea.delete() : " + String.valueOf(bRetVal)); 882 } 883 884 return bRetVal; 885 } 887 889 896 public static String getPath (JDCConnection oConn, String sWrkAId) throws SQLException { 897 String sWrkAPath; 898 899 if (DebugFile.trace) { 900 DebugFile.writeln("Begin WorkArea.getPath([Connection], " + sWrkAId + ")"); 901 DebugFile.incIdent(); 902 } 903 904 PreparedStatement oStmt = oConn.prepareStatement("SELECT " + DB.path_logo + " FROM " + DB.k_workareas + " WHERE " + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 905 oStmt.setString(1, sWrkAId); 906 ResultSet oRSet = oStmt.executeQuery(); 907 if (oRSet.next()) 908 sWrkAPath = oRSet.getString(1); 909 else 910 sWrkAPath = null; 911 oRSet.close(); 912 oRSet = null; 913 oStmt.close(); 914 915 if (DebugFile.trace) { 916 DebugFile.decIdent(); 917 DebugFile.writeln("End WorkArea.getPath() : " + (sWrkAPath!=null ? sWrkAPath : "null")); 918 } 919 920 return sWrkAPath; 921 } 923 925 public static boolean isAdmin(JDCConnection oConn, String guWorkArea, String sUserId) throws SQLException { 926 int iIsAdmin; 927 CallableStatement oCall; 928 PreparedStatement oStmt; 929 ResultSet oRSet; 930 931 if (DebugFile.trace) { 932 DebugFile.writeln("Begin WorkArea.isAdmin([Connection], " + guWorkArea + "," + sUserId + ")"); 933 DebugFile.incIdent(); 934 } 935 936 switch (oConn.getDataBaseProduct()) { 937 938 case JDCConnection.DBMS_MSSQL: 939 case JDCConnection.DBMS_ORACLE: 940 941 if (DebugFile.trace) 942 DebugFile.writeln("Connection.prepareCall({ call k_is_workarea_admin ('" + guWorkArea + "','" + sUserId + "',?)})"); 943 944 oCall = oConn.prepareCall("{ call k_is_workarea_admin (?,?,?)}"); 945 946 oCall.setString(1, guWorkArea); 947 oCall.setString(2, sUserId); 948 oCall.registerOutParameter(3, Types.INTEGER); 949 oCall.execute(); 950 iIsAdmin = oCall.getInt(3); 951 oCall.close(); 952 break; 953 954 default: 955 956 if (DebugFile.trace) 957 DebugFile.writeln("Connection.prepareStatement(SELECT x." + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " x, " + DB.k_x_app_workarea + " w WHERE x." + DB.gu_acl_group + "=w." + DB.gu_admins + " AND x." + DB.gu_user + "='" + sUserId + "' AND w." + DB.gu_workarea + "='" + guWorkArea + "')"); 958 959 oStmt = oConn.prepareStatement("SELECT x." + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " x, " + DB.k_x_app_workarea + " w WHERE x." + DB.gu_acl_group + "=w." + DB.gu_admins + " AND x." + DB.gu_user + "=? AND w." + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 960 oStmt.setString(1, sUserId); 961 oStmt.setString(2, guWorkArea); 962 oRSet = oStmt.executeQuery(); 963 if (oRSet.next()) 964 iIsAdmin = 1; 965 else 966 iIsAdmin = 0; 967 oRSet.close(); 968 oStmt.close(); 969 break; 970 } 972 if (DebugFile.trace) { 973 DebugFile.decIdent(); 974 DebugFile.writeln("End WorkArea.isAdmin() : " + String.valueOf(0!=iIsAdmin)); 975 } 976 977 return (0!=iIsAdmin); 978 } 980 982 public static boolean isPowerUser(JDCConnection oConn, String guWorkArea, String sUserId) throws SQLException { 983 int iIsPowerUser; 984 CallableStatement oCall; 985 PreparedStatement oStmt; 986 ResultSet oRSet; 987 988 if (DebugFile.trace) { 989 DebugFile.writeln("Begin WorkArea.isPowerUser([Connection], " + guWorkArea + "," + sUserId + ")"); 990 DebugFile.incIdent(); 991 } 992 993 switch (oConn.getDataBaseProduct()) { 994 995 case JDCConnection.DBMS_MSSQL: 996 case JDCConnection.DBMS_ORACLE: 997 998 if (DebugFile.trace) 999 DebugFile.writeln("Connection.prepareCall({ call k_is_workarea_poweruser ('" + guWorkArea + "','" + sUserId + "',?)})"); 1000 1001 oCall = oConn.prepareCall("{ call k_is_workarea_poweruser (?,?,?)}"); 1002 1003 oCall.setString(1, guWorkArea); 1004 oCall.setString(2, sUserId); 1005 oCall.registerOutParameter(3, Types.INTEGER); 1006 oCall.execute(); 1007 iIsPowerUser = oCall.getInt(3); 1008 oCall.close(); 1009 break; 1010 1011 default: 1012 1013 if (DebugFile.trace) 1014 DebugFile.writeln("Connection.prepareStatement(SELECT x." + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " x, " + DB.k_x_app_workarea + " w WHERE x." + DB.gu_acl_group + "=w." + DB.gu_powusers + " AND x." + DB.gu_user + "='" + sUserId + "' AND w." + DB.gu_workarea + "='" + guWorkArea + "')"); 1015 1016 oStmt = oConn.prepareStatement("SELECT x." + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " x, " + DB.k_x_app_workarea + " w WHERE x." + DB.gu_acl_group + "=w." + DB.gu_powusers + " AND x." + DB.gu_user + "=? AND w." + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 1017 oStmt.setString(1, sUserId); 1018 oStmt.setString(2, guWorkArea); 1019 oRSet = oStmt.executeQuery(); 1020 if (oRSet.next()) 1021 iIsPowerUser = 1; 1022 else 1023 iIsPowerUser = 0; 1024 oRSet.close(); 1025 oStmt.close(); 1026 break; 1027 } 1029 if (DebugFile.trace) { 1030 DebugFile.decIdent(); 1031 DebugFile.writeln("End WorkArea.isPowerUser() : " + String.valueOf(0!=iIsPowerUser)); 1032 } 1033 1034 return (0!=iIsPowerUser); 1035 1036 } 1038 1040 public static boolean isUser(JDCConnection oConn, String guWorkArea, String sUserId) throws SQLException { 1041 int iIsUser; 1042 CallableStatement oCall; 1043 PreparedStatement oStmt; 1044 ResultSet oRSet; 1045 1046 if (DebugFile.trace) { 1047 DebugFile.writeln("Begin WorkArea.isUser([Connection], " + guWorkArea + "," + sUserId + ")"); 1048 DebugFile.incIdent(); 1049 } 1050 1051 switch (oConn.getDataBaseProduct()) { 1052 1053 case JDCConnection.DBMS_MSSQL: 1054 case JDCConnection.DBMS_ORACLE: 1055 1056 oCall = oConn.prepareCall("{ call k_is_workarea_user (?,?,?)}"); 1057 1058 oCall.setString(1, guWorkArea); 1059 oCall.setString(2, sUserId); 1060 oCall.registerOutParameter(3, Types.INTEGER); 1061 oCall.execute(); 1062 iIsUser = oCall.getInt(3); 1063 oCall.close(); 1064 break; 1065 default: 1066 oStmt = oConn.prepareStatement("SELECT x." + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " x, " + DB.k_x_app_workarea + " w WHERE x." + DB.gu_acl_group + "=w." + DB.gu_users + " AND x." + DB.gu_user + "=? AND w." + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 1067 oStmt.setString(1, sUserId); 1068 oStmt.setString(2, guWorkArea); 1069 oRSet = oStmt.executeQuery(); 1070 if (oRSet.next()) 1071 iIsUser = 1; 1072 else 1073 iIsUser = 0; 1074 oRSet.close(); 1075 oStmt.close(); 1076 break; 1077 } 1079 if (DebugFile.trace) { 1080 DebugFile.decIdent(); 1081 DebugFile.writeln("End WorkArea.isUser() : " + String.valueOf(0!=iIsUser)); 1082 } 1083 1084 return (0!=iIsUser); 1085 } 1087 1089 public static boolean isGuest(JDCConnection oConn, String guWorkArea, String sUserId) throws SQLException { 1090 int iIsGuest; 1091 CallableStatement oCall; 1092 PreparedStatement oStmt; 1093 ResultSet oRSet; 1094 1095 if (DebugFile.trace) { 1096 DebugFile.writeln("Begin WorkArea.isGuest([Connection], " + guWorkArea + "," + sUserId + ")"); 1097 DebugFile.incIdent(); 1098 } 1099 1100 switch (oConn.getDataBaseProduct()) { 1101 1102 case JDCConnection.DBMS_ORACLE: 1103 1104 if (DebugFile.trace) 1105 DebugFile.writeln("Connection.prepareCall({ call k_is_workarea_guest ('" + guWorkArea + "','" + sUserId + "',?)})"); 1106 1107 oCall = oConn.prepareCall("{ call k_is_workarea_guest (?,?,?)}"); 1108 1109 oCall.setString(1, guWorkArea); 1110 oCall.setString(2, sUserId); 1111 oCall.registerOutParameter(3, Types.DECIMAL); 1112 oCall.execute(); 1113 iIsGuest = oCall.getBigDecimal(3).intValue(); 1114 oCall.close(); 1115 break; 1116 1117 case JDCConnection.DBMS_MSSQL: 1118 1119 if (DebugFile.trace) 1120 DebugFile.writeln("Connection.prepareCall({ call k_is_workarea_guest ('" + guWorkArea + "','" + sUserId + "',?)})"); 1121 1122 oCall = oConn.prepareCall("{ call k_is_workarea_guest (?,?,?)}"); 1123 1124 oCall.setString(1, guWorkArea); 1125 oCall.setString(2, sUserId); 1126 oCall.registerOutParameter(3, Types.INTEGER); 1127 oCall.execute(); 1128 iIsGuest = oCall.getInt(3); 1129 oCall.close(); 1130 break; 1131 1132 default: 1133 1134 if (DebugFile.trace) 1135 DebugFile.writeln("Connection.prepareStatement(SELECT x." + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " x, " + DB.k_x_app_workarea + " w WHERE x." + DB.gu_acl_group + "=w." + DB.gu_guests + " AND x." + DB.gu_user + "='" + sUserId + "' AND w." + DB.gu_workarea + "='" + guWorkArea + "')"); 1136 1137 oStmt = oConn.prepareStatement("SELECT x." + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " x, " + DB.k_x_app_workarea + " w WHERE x." + DB.gu_acl_group + "=w." + DB.gu_guests + " AND x." + DB.gu_user + "=? AND w." + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 1138 oStmt.setString(1, sUserId); 1139 oStmt.setString(2, guWorkArea); 1140 oRSet = oStmt.executeQuery(); 1141 if (oRSet.next()) 1142 iIsGuest = 1; 1143 else 1144 iIsGuest = 0; 1145 oRSet.close(); 1146 oStmt.close(); 1147 break; 1148 } 1150 if (DebugFile.trace) { 1151 DebugFile.decIdent(); 1152 DebugFile.writeln("End WorkArea.isGuest() : " + String.valueOf(0!=iIsGuest)); 1153 } 1154 1155 return (0!=iIsGuest); 1156 } 1158 1160 public static int getUserAppMask(JDCConnection oConn, String guWorkArea, String sUserId) throws SQLException { 1161 1162 if (DebugFile.trace) { 1163 DebugFile.writeln("Begin WorkArea.getUserAppMask([Connection], " + guWorkArea + "," + sUserId + ")"); 1164 DebugFile.incIdent(); 1165 } 1166 1167 DBSubset oApps = new DBSubset(DB.k_x_app_workarea, 1168 DB.id_app + "," + DB.gu_admins + "," + DB.gu_powusers + "," + DB.gu_users + "," + DB.gu_guests + "," + DB.gu_other, 1169 DB.gu_workarea + "=?", 30); 1170 int iApps = oApps.load(oConn, new Object [] { guWorkArea }); 1171 int iAppMask = 0; 1172 String sGrp; 1173 1174 if (DebugFile.trace) 1175 DebugFile.writeln("Connection.prepareStatement(SELECT " + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " WHERE " + DB.gu_user + "='" + sUserId + "')"); 1176 1177 PreparedStatement oStmt = oConn.prepareStatement("SELECT " + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " WHERE " + DB.gu_user + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 1178 1179 try { oStmt.setQueryTimeout(10); } catch (SQLException sqle) {} 1180 1181 oStmt.setString(1, sUserId); 1182 1183 ResultSet oRSet = oStmt.executeQuery(); 1184 1185 while (oRSet.next()) { 1186 sGrp = oRSet.getString(1); 1187 for (int a=0; a<iApps; a++) 1188 if (sGrp.equals(oApps.get(1,a)) || sGrp.equals(oApps.get(2,a)) || sGrp.equals(oApps.get(3,a)) || sGrp.equals(oApps.get(4,a)) || sGrp.equals(oApps.get(5,a))) 1189 iAppMask |= (1<<oApps.getInt(0,a)); 1190 } oRSet.close(); 1192 oStmt.close(); 1193 1194 if (DebugFile.trace) { 1195 DebugFile.decIdent(); 1196 DebugFile.writeln("End WorkArea.getUserAppMask() : " + String.valueOf(iAppMask)); 1197 } 1198 1199 return iAppMask; 1200 } 1202 1204 public static String getIdFromName(JDCConnection oConn, int iDomainId, String sWorkAreaNm) throws SQLException { 1205 PreparedStatement oStmt; 1206 ResultSet oRSet; 1207 String sRetVal; 1208 1209 if (DebugFile.trace) { 1210 DebugFile.writeln("Begin WorkArea.getIdFromName([Connection], " + String.valueOf(iDomainId) + "," + sWorkAreaNm + ")"); 1211 DebugFile.incIdent(); 1212 } 1213 1214 switch (oConn.getDataBaseProduct()) { 1215 1216 case JDCConnection.DBMS_MSSQL: 1217 case JDCConnection.DBMS_ORACLE: 1218 sRetVal = getUIdFromName(oConn, new Integer (iDomainId), sWorkAreaNm, "k_get_workarea_id"); 1219 break; 1220 1221 default: 1222 if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(SELECT " + DB.gu_workarea+ " FROM " + DB.k_workareas + " WHERE " + DB.nm_workarea + "='" + sWorkAreaNm + "' AND " + DB.id_domain + "=" + String.valueOf(iDomainId) +" AND " + DB.bo_active + "<>0)"); 1223 1224 oStmt = oConn.prepareStatement("SELECT " + DB.gu_workarea+ " FROM " + DB.k_workareas + " WHERE " + DB.nm_workarea + "=? AND " + DB.id_domain + "=? AND " + DB.bo_active + "<>0", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 1225 oStmt.setString(1, sWorkAreaNm); 1226 oStmt.setInt(2, iDomainId); 1227 oRSet = oStmt.executeQuery(); 1228 if (oRSet.next()) 1229 sRetVal = oRSet.getString(1); 1230 else 1231 sRetVal = null; 1232 oRSet.close(); 1233 oStmt.close(); 1234 break; 1235 } 1236 1237 if (DebugFile.trace) { 1238 DebugFile.decIdent(); 1239 DebugFile.writeln("End WorkArea.getIdFromName() : " + sRetVal); 1240 } 1241 1242 return sRetVal; 1243 } 1245 1247 public static final short ClassId = 5; 1248} 1249 | Popular Tags |