Source Code Cross Referenced for WorkArea.java in  » Groupware » hipergate » com » knowgate » workareas » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.workareas 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:          Copyright (C) 2003  Know Gate S.L. All rights reserved.
0003:                              C/Oña, 107 1º2 28050 Madrid (Spain)
0004:
0005:          Redistribution and use in source and binary forms, with or without
0006:          modification, are permitted provided that the following conditions
0007:          are met:
0008:
0009:          1. Redistributions of source code must retain the above copyright
0010:             notice, this list of conditions and the following disclaimer.
0011:
0012:          2. The end-user documentation included with the redistribution,
0013:             if any, must include the following acknowledgment:
0014:             "This product includes software parts from hipergate
0015:             (http://www.hipergate.org/)."
0016:             Alternately, this acknowledgment may appear in the software itself,
0017:             if and wherever such third-party acknowledgments normally appear.
0018:
0019:          3. The name hipergate must not be used to endorse or promote products
0020:             derived from this software without prior written permission.
0021:             Products derived from this software may not be called hipergate,
0022:             nor may hipergate appear in their name, without prior written
0023:             permission.
0024:
0025:          This library is distributed in the hope that it will be useful,
0026:          but WITHOUT ANY WARRANTY; without even the implied warranty of
0027:          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0028:
0029:          You should have received a copy of hipergate License with this code;
0030:          if not, visit http://www.hipergate.org or mail to info@hipergate.org
0031:         */
0032:
0033:        package com.knowgate.workareas;
0034:
0035:        import java.io.IOException;
0036:
0037:        import java.sql.Connection;
0038:        import java.sql.Date;
0039:        import java.sql.ResultSet;
0040:        import java.sql.Statement;
0041:        import java.sql.PreparedStatement;
0042:        import java.sql.CallableStatement;
0043:        import java.sql.SQLException;
0044:        import java.sql.Types;
0045:
0046:        import com.knowgate.jdc.JDCConnection;
0047:        import com.knowgate.debug.DebugFile;
0048:        import com.knowgate.misc.Gadgets;
0049:        import com.knowgate.dataobjs.*;
0050:
0051:        import com.knowgate.addrbook.Room;
0052:        import com.knowgate.addrbook.Meeting;
0053:        import com.knowgate.addrbook.Fellow;
0054:
0055:        import com.knowgate.crm.Company;
0056:        import com.knowgate.crm.Contact;
0057:        import com.knowgate.crm.DistributionList;
0058:
0059:        import com.knowgate.projtrack.Project;
0060:
0061:        import com.knowgate.hipergate.Image;
0062:
0063:        import com.knowgate.dataxslt.db.*;
0064:
0065:        import com.knowgate.hipergate.QueryByForm;
0066:        import com.knowgate.hipergate.Shop;
0067:
0068:        import com.knowgate.scheduler.Job;
0069:
0070:        /**
0071:         * <p>WorkArea</p>
0072:         * @author Sergio Montoro Ten
0073:         * @version 2.0
0074:         */
0075:        public class WorkArea extends DBPersist {
0076:
0077:            /**
0078:             * Create empty WorkArea.
0079:             */
0080:            public WorkArea() {
0081:                super (DB.k_workareas, "WorkArea");
0082:            }
0083:
0084:            // ----------------------------------------------------------
0085:
0086:            /**
0087:             * Load WorkArea from database
0088:             * @param oConn Database Conenction
0089:             * @param sIdWorkArea GUID of WorkArea to be loaded
0090:             * @throws SQLException
0091:             */
0092:            public WorkArea(JDCConnection oConn, String sIdWorkArea)
0093:                    throws SQLException {
0094:                super (DB.k_workareas, "WorkArea");
0095:
0096:                Object aWrkA[] = { sIdWorkArea };
0097:
0098:                load(oConn, aWrkA);
0099:            }
0100:
0101:            // ----------------------------------------------------------
0102:
0103:            /**
0104:             * <p>Delete a WorkArea and all its associated data.</p>
0105:             * USE THIS METHOD WITH EXTREME CARE. AS IT WILL DELETE DATA FROM EVERY TABLE
0106:             * CONTAINING A gu_workarea COLUMN MATCHING THE DELETED WORKAREA GUID.<br><br>
0107:             * Deletion takes place by delegating it in other objects delete() method.
0108:             * @param oConn Database Connection
0109:             * @throws SQLException
0110:             */
0111:            public boolean delete(JDCConnection oConn) throws SQLException {
0112:                return WorkArea.delete(oConn, getString(DB.gu_workarea));
0113:            }
0114:
0115:            // ----------------------------------------------------------
0116:
0117:            public boolean store(JDCConnection oConn) throws SQLException {
0118:
0119:                // Si no se especificó un identificador para el área de trabajo
0120:                // entonces añadirlo autimaticamente
0121:                if (!AllVals.containsKey(DB.gu_workarea))
0122:                    put(DB.gu_workarea, Gadgets.generateUUID());
0123:
0124:                return super .store(oConn);
0125:            }
0126:
0127:            // ----------------------------------------------------------
0128:
0129:            public int getUserAppMask(JDCConnection oConn, String sUserId)
0130:                    throws SQLException {
0131:                return WorkArea.getUserAppMask(oConn,
0132:                        getString(DB.gu_workarea), sUserId);
0133:            }
0134:
0135:            // ----------------------------------------------------------
0136:
0137:            public DBSubset getUsers(JDCConnection oConn) throws SQLException {
0138:                Object oGroups[] = { get(DB.gu_admins), get(DB.gu_powusers),
0139:                        get(DB.gu_users), get(DB.gu_guests), get(DB.gu_other) };
0140:                DBSubset oUsers = new DBSubset(DB.k_users + " u", "u."
0141:                        + DB.gu_user + ",u." + DB.tx_nickname + ",u."
0142:                        + DB.nm_user + ",u." + DB.tx_surname1 + ",u."
0143:                        + DB.tx_surname2 + ",u." + DB.bo_searchable + ",u."
0144:                        + DB.tx_main_email, "EXISTS (SELECT x." + DB.gu_user
0145:                        + " FROM " + DB.k_x_group_user + " x WHERE "
0146:                        + DB.gu_user + "=u." + DB.gu_user + " AND x."
0147:                        + DB.gu_acl_group + " IN (?,?,?,?,?)) ORDER BY 3,4,5",
0148:                        4);
0149:                oUsers.load(oConn, oGroups);
0150:
0151:                return oUsers;
0152:            }
0153:
0154:            // **********************************************************
0155:            // Static Methods
0156:
0157:            /**
0158:             * <p>Delete a WorkArea and all its associated data.</p>
0159:             * USE THIS METHOD WITH EXTREME CARE. AS IT WILL DELETE DATA FROM EVERY TABLE
0160:             * CONTAINING A gu_workarea COLUMN MATCHING THE DELETED WORKAREA GUID.<br><br>
0161:             * Deletion takes place by delegating it in other objects delete() method.<br><br>
0162:             * In this order:<br>
0163:             * <table border=1 cellpadding=4>
0164:             * <tr><td>DELETE k_x_portlet_user</td></tr>
0165:             * <tr><td>QueryByForm.delete</td></tr>
0166:             * <tr><td>MicrositeDB.delete</td></tr>
0167:             * <tr><td>PageSetDB.delete</td></tr>
0168:             * <tr><td>DELETE k_images</td></tr>
0169:             * <tr><td>DistributionList.delete</td></tr>
0170:             * <tr><td>Meeting.delete</td></tr>
0171:             * <tr><td>Fellow.delete</td></tr>
0172:             * <tr><td>DELETE k_lu_fellow_titles</td></tr>
0173:             * <tr><td>DELETE k_fellows_lookup</td></tr>
0174:             * <tr><td>Room.delete</td></tr><tr>
0175:             * <tr><td>DELETE k_rooms_lookup</td></tr>
0176:             * <tr><td>DELETE k_to_do</td></tr>
0177:             * <tr><td>DELETE k_to_do_lookup</td></tr>
0178:             * <tr><td>DELETE k_phone_calls</td></tr>
0179:             * <tr><td>DELETE k_sales_men</td></tr>
0180:             * <tr><td>DELETE k_sales_men_lookup</td></tr>
0181:             * <tr><td>Company.delete</td></tr>
0182:             * <tr><td>DELETE k_companies_lookup</td></tr>
0183:             * <tr><td>DELETE k_contacts_lookup</td></tr>
0184:             * <tr><td>DELETE k_oportunities_lookup</td></tr>
0185:             * <tr><td>DELETE k_welcome_packs_lookup</td></tr>
0186:             * <tr><td>Project.delete</td></tr>
0187:             * <tr><td>DELETE k_projects_lookup</td></tr>
0188:             * <tr><td>DELETE k_duties_lookup </td></tr>
0189:             * <tr><td>DELETE k_bugs_lookup </td></tr>
0190:             * <tr><td>DELETE k_orders</td></tr>
0191:             * <tr><td>DELETE k_orders_lookup</td></tr>
0192:             * <tr><td>DELETE k_invoices</td></tr>
0193:             * <tr><td>DELETE k_invoices_lookup</td></tr>
0194:             * <tr><td>DELETE k_lu_business_states</td></tr>
0195:             * <tr><td>DELETE k_business_states</td></tr>
0196:             * <tr><td>Shop.delete</td></tr>
0197:             * <tr><td>Job.delete</td></tr>
0198:             * <tr><td>DELETE k_lu_meta_attrs</td></tr>
0199:             * <tr><td>DELETE k_addresses</td></tr>
0200:             * <tr><td>DELETE k_addresses_lookup</td></tr>
0201:             * <tr><td>DELETE k_thesauri_lookup</td></tr>
0202:             * <tr><td>DELETE k_bank_accounts</td></tr>
0203:             * <tr><td>DELETE k_bank_accounts_lookup</td></tr>
0204:             * <tr><td>DELETE k_x_app_workarea</td></tr>
0205:             * <tr><td>DELETE k_workareas</td></tr>
0206:             * </table>
0207:             * @param oConn Database Connection
0208:             * @param sWrkAreaGUID GUID of WorkArea to be deleted.
0209:             * @throws SQLException
0210:             */
0211:            public static boolean delete(JDCConnection oConn,
0212:                    String sWrkAreaGUID) throws SQLException {
0213:                CallableStatement oCall;
0214:                Statement oStmt;
0215:                PreparedStatement oPtmt;
0216:                ResultSet oRSet;
0217:                DBSubset oItems;
0218:                String sSQL;
0219:                int iItems;
0220:
0221:                if (DebugFile.trace) {
0222:                    DebugFile.writeln("Begin WorkArea.delete([Connection], "
0223:                            + sWrkAreaGUID + ")");
0224:                    DebugFile.incIdent();
0225:                }
0226:
0227:                // -----------------------------------------------------------------------------------
0228:                // Verificar que la WorkArea realmente existe antes de empezar a borrar y tambien
0229:                // evitar que una inyección maliciosa de SQL en el parámetro sWrkAreaGUID pudiera
0230:                // borrar más registros de los debidos
0231:
0232:                oPtmt = oConn.prepareStatement("SELECT " + DB.gu_workarea
0233:                        + " FROM " + DB.k_workareas + " WHERE "
0234:                        + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY,
0235:                        ResultSet.CONCUR_READ_ONLY);
0236:                oPtmt.setString(1, sWrkAreaGUID);
0237:                oRSet = oPtmt.executeQuery();
0238:                boolean bExists = oRSet.next();
0239:                oRSet.close();
0240:                oPtmt.close();
0241:
0242:                if (!bExists) {
0243:                    if (DebugFile.trace) {
0244:                        DebugFile.writeln("workarea " + sWrkAreaGUID
0245:                                + " not found");
0246:                        DebugFile.decIdent();
0247:                        DebugFile.writeln("End WorkArea.delete() : false");
0248:                    }
0249:                    return false;
0250:                }
0251:
0252:                // -----------------------------------------------------------------------------------
0253:                // Borrar los e-mails
0254:
0255:                if (DBBind.exists(oConn, DB.k_mime_msgs, "U")) {
0256:                    oStmt = oConn.createStatement();
0257:
0258:                    if (DebugFile.trace)
0259:                        DebugFile
0260:                                .writeln("Statement.executeUpdate(DELETE FROM "
0261:                                        + DB.k_x_cat_objs
0262:                                        + " WHERE "
0263:                                        + DB.gu_object
0264:                                        + " IN (SELECT "
0265:                                        + DB.gu_mimemsg
0266:                                        + " FROM k_mime_msgs WHERE gu_workarea='"
0267:                                        + sWrkAreaGUID + "') AND "
0268:                                        + DB.id_class + "=822)");
0269:
0270:                    oStmt.executeUpdate("DELETE FROM " + DB.k_x_cat_objs
0271:                            + " WHERE " + DB.gu_object + " IN (SELECT "
0272:                            + DB.gu_mimemsg
0273:                            + " FROM k_mime_msgs WHERE gu_workarea='"
0274:                            + sWrkAreaGUID + "') AND " + DB.id_class + "=822");
0275:
0276:                    if (DebugFile.trace)
0277:                        DebugFile
0278:                                .writeln("Statement.executeUpdate(DELETE FROM "
0279:                                        + DB.k_inet_addrs + " WHERE "
0280:                                        + DB.gu_mimemsg + " IN (SELECT "
0281:                                        + DB.gu_mimemsg + " FROM "
0282:                                        + DB.k_mime_msgs + " WHERE "
0283:                                        + DB.gu_workarea + "='" + sWrkAreaGUID
0284:                                        + "'))");
0285:
0286:                    oStmt.executeUpdate("DELETE FROM " + DB.k_inet_addrs
0287:                            + " WHERE " + DB.gu_mimemsg + " IN (SELECT "
0288:                            + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs
0289:                            + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID
0290:                            + "')");
0291:
0292:                    if (DebugFile.trace)
0293:                        DebugFile
0294:                                .writeln("Statement.executeUpdate(DELETE FROM "
0295:                                        + DB.k_mime_parts + " WHERE "
0296:                                        + DB.gu_mimemsg + " IN (SELECT "
0297:                                        + DB.gu_mimemsg + " FROM "
0298:                                        + DB.k_mime_msgs + " WHERE "
0299:                                        + DB.gu_workarea + "='" + sWrkAreaGUID
0300:                                        + "'))");
0301:
0302:                    oStmt.executeUpdate("DELETE FROM " + DB.k_mime_parts
0303:                            + " WHERE " + DB.gu_mimemsg + " IN (SELECT "
0304:                            + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs
0305:                            + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID
0306:                            + "')");
0307:
0308:                    if (DebugFile.trace)
0309:                        DebugFile
0310:                                .writeln("Statement.executeUpdate(DELETE FROM "
0311:                                        + DB.k_mime_msgs + " WHERE "
0312:                                        + DB.gu_workarea + "='" + sWrkAreaGUID
0313:                                        + "')");
0314:
0315:                    oStmt.executeUpdate("DELETE FROM " + DB.k_mime_msgs
0316:                            + " WHERE  " + DB.gu_workarea + "='" + sWrkAreaGUID
0317:                            + "'");
0318:
0319:                    oStmt.close();
0320:                }
0321:
0322:                // -----------------------------------------------------------------------------------
0323:                // Borrar las preferencias de usuario para portlets
0324:
0325:                if (DBBind.exists(oConn, DB.k_x_portlet_user, "U")) {
0326:                    oStmt = oConn.createStatement();
0327:
0328:                    if (DebugFile.trace)
0329:                        DebugFile
0330:                                .writeln("Statement.executeUpdate(DELETE FROM "
0331:                                        + DB.k_x_portlet_user + " WHERE "
0332:                                        + DB.gu_workarea + "='" + sWrkAreaGUID
0333:                                        + "')");
0334:
0335:                    oStmt.executeUpdate("DELETE FROM " + DB.k_x_portlet_user
0336:                            + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID
0337:                            + "'");
0338:
0339:                    oStmt.close();
0340:                }
0341:
0342:                // -----------------------------------------------------------------------------------
0343:                // Borrar las consultas
0344:
0345:                if (DBBind.exists(oConn, DB.k_queries, "U")) {
0346:                    oItems = new DBSubset(DB.k_queries, DB.gu_query,
0347:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0348:                    iItems = oItems.load(oConn);
0349:
0350:                    for (int p = 0; p < iItems; p++)
0351:                        QueryByForm.delete(oConn, oItems.getString(0, p));
0352:                }
0353:                // -----------------------------------------------------------------------------------
0354:
0355:                // Borrar los pagesets
0356:                if (DBBind.exists(oConn, DB.k_pagesets, "U")) {
0357:                    oItems = new DBSubset(DB.k_pagesets, DB.gu_pageset,
0358:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0359:                    iItems = oItems.load(oConn);
0360:                    for (int p = 0; p < iItems; p++)
0361:                        PageSetDB.delete(oConn, oItems.getString(0, p));
0362:                }
0363:
0364:                // -----------------------------------------------------------------------------------
0365:
0366:                // Borrar los microsites
0367:                if (DBBind.exists(oConn, DB.k_microsites, "U")) {
0368:                    oItems = new DBSubset(DB.k_microsites, DB.gu_microsite,
0369:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0370:                    iItems = oItems.load(oConn);
0371:                    for (int p = 0; p < iItems; p++)
0372:                        new MicrositeDB(oConn, oItems.getString(0, p))
0373:                                .delete(oConn);
0374:                }
0375:
0376:                // -----------------------------------------------------------------------------------
0377:                // Nuevo para la v2.1
0378:                // Borrar las imagenes
0379:
0380:                if (DBBind.exists(oConn, DB.k_images, "U")) {
0381:                    oItems = new DBSubset(DB.k_images, DB.gu_image,
0382:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0383:                    iItems = oItems.load(oConn);
0384:                    for (int p = 0; p < iItems; p++)
0385:                        new Image(oConn, oItems.getString(0, p)).delete(oConn);
0386:                }
0387:
0388:                // -----------------------------------------------------------------------------------
0389:                // Borrar las listas
0390:                if (DBBind.exists(oConn, DB.k_lists, "U")) {
0391:                    oItems = new DBSubset(DB.k_lists, DB.gu_list,
0392:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0393:                    iItems = oItems.load(oConn);
0394:                    for (int p = 0; p < iItems; p++)
0395:                        DistributionList.delete(oConn, oItems.getString(0, p));
0396:                }
0397:                // -----------------------------------------------------------------------------------
0398:
0399:                // Borrar actividades, compañeros y salas
0400:
0401:                if (DBBind.exists(oConn, DB.k_meetings, "U")) {
0402:                    oItems = new DBSubset(DB.k_meetings, DB.gu_meeting,
0403:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0404:                    iItems = oItems.load(oConn);
0405:                    for (int c = 0; c < iItems; c++)
0406:                        Meeting.delete(oConn, oItems.getString(0, c));
0407:                }
0408:
0409:                if (DBBind.exists(oConn, DB.k_fellows, "U")) {
0410:                    oItems = new DBSubset(DB.k_fellows, DB.gu_fellow,
0411:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0412:                    iItems = oItems.load(oConn);
0413:                    for (int c = 0; c < iItems; c++)
0414:                        Fellow.delete(oConn, oItems.getString(0, c));
0415:                }
0416:
0417:                if (DBBind.exists(oConn, DB.k_lu_fellow_titles, "U")) {
0418:                    oStmt = oConn.createStatement();
0419:                    sSQL = "DELETE FROM " + DB.k_lu_fellow_titles + " WHERE "
0420:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0421:                    if (DebugFile.trace)
0422:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0423:                    oStmt.execute(sSQL);
0424:                    oStmt.close();
0425:                }
0426:
0427:                if (DBBind.exists(oConn, DB.k_fellows_lookup, "U")) {
0428:                    oStmt = oConn.createStatement();
0429:                    try {
0430:                        oStmt.setQueryTimeout(30);
0431:                    } catch (SQLException sqle) {
0432:                    }
0433:                    sSQL = "DELETE FROM " + DB.k_fellows_lookup + " WHERE "
0434:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0435:                    if (DebugFile.trace)
0436:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0437:                    oStmt.execute(sSQL);
0438:                    oStmt.close();
0439:                }
0440:
0441:                if (DBBind.exists(oConn, DB.k_rooms, "U")) {
0442:                    oItems = new DBSubset(DB.k_rooms, DB.nm_room,
0443:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0444:                    iItems = oItems.load(oConn);
0445:                    for (int c = 0; c < iItems; c++)
0446:                        Room
0447:                                .delete(oConn, oItems.getString(0, c),
0448:                                        sWrkAreaGUID);
0449:                }
0450:
0451:                if (DBBind.exists(oConn, DB.k_rooms_lookup, "U")) {
0452:                    oStmt = oConn.createStatement();
0453:                    try {
0454:                        oStmt.setQueryTimeout(30);
0455:                    } catch (SQLException sqle) {
0456:                    }
0457:                    sSQL = "DELETE FROM " + DB.k_rooms_lookup + " WHERE "
0458:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0459:                    if (DebugFile.trace)
0460:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0461:                    oStmt.execute(sSQL);
0462:                    oStmt.close();
0463:                }
0464:
0465:                // -----------------------------------------------------------------------------------
0466:                // Borrar ToDo Lists
0467:
0468:                if (DBBind.exists(oConn, DB.k_to_do, "U")) {
0469:                    oStmt = oConn.createStatement();
0470:                    try {
0471:                        oStmt.setQueryTimeout(30);
0472:                    } catch (SQLException sqle) {
0473:                    }
0474:                    sSQL = "DELETE FROM " + DB.k_to_do + " WHERE "
0475:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0476:                    if (DebugFile.trace)
0477:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0478:                    oStmt.execute(sSQL);
0479:                    oStmt.close();
0480:                }
0481:
0482:                if (DBBind.exists(oConn, DB.k_to_do_lookup, "U")) {
0483:                    oStmt = oConn.createStatement();
0484:                    try {
0485:                        oStmt.setQueryTimeout(30);
0486:                    } catch (SQLException sqle) {
0487:                    }
0488:                    sSQL = "DELETE FROM " + DB.k_to_do_lookup + " WHERE "
0489:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0490:                    if (DebugFile.trace)
0491:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0492:                    oStmt.execute(sSQL);
0493:                    oStmt.close();
0494:                }
0495:
0496:                // -----------------------------------------------------------------------------------
0497:                // Borrar llamadas de teléfono
0498:
0499:                if (DBBind.exists(oConn, DB.k_phone_calls, "U")) {
0500:                    oStmt = oConn.createStatement();
0501:                    try {
0502:                        oStmt.setQueryTimeout(30);
0503:                    } catch (SQLException sqle) {
0504:                    }
0505:                    sSQL = "DELETE FROM " + DB.k_phone_calls + " WHERE "
0506:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0507:                    if (DebugFile.trace)
0508:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0509:                    oStmt.execute(sSQL);
0510:                    oStmt.close();
0511:                }
0512:
0513:                // -----------------------------------------------------------------------------------
0514:                // Borrar el datawarehouse de direcciones
0515:
0516:                if (DBBind.exists(oConn, DB.k_member_address, "U")) {
0517:
0518:                    oStmt = oConn.createStatement();
0519:                    try {
0520:                        oStmt.setQueryTimeout(30);
0521:                    } catch (SQLException sqle) {
0522:                    }
0523:
0524:                    sSQL = "DELETE FROM " + DB.k_member_address + " WHERE "
0525:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0526:                    if (DebugFile.trace)
0527:                        DebugFile.writeln("Statement.executeUpdate(" + sSQL
0528:                                + ")");
0529:                    oStmt.executeUpdate(sSQL);
0530:
0531:                    oStmt.close();
0532:                }
0533:
0534:                // -----------------------------------------------------------------------------------
0535:
0536:                // Borrar los Vendedores
0537:                if (DBBind.exists(oConn, DB.k_sales_men, "U")) {
0538:                    oItems = new DBSubset(DB.k_sales_men, DB.gu_sales_man,
0539:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0540:                    iItems = oItems.load(oConn);
0541:
0542:                    if (oConn.getDataBaseProduct() == JDCConnection.DBMS_POSTGRESQL) {
0543:                        if (DebugFile.trace)
0544:                            DebugFile
0545:                                    .writeln("Connection.prepareStatement(SELECT k_sp_del_sales_man (?))");
0546:                        oPtmt = oConn
0547:                                .prepareStatement("SELECT k_sp_del_sales_man (?)");
0548:                        for (int c = 0; c < iItems; c++) {
0549:                            oPtmt.setString(1, oItems.getString(0, c));
0550:                            oPtmt.executeQuery();
0551:                        } // next
0552:                        oPtmt.close();
0553:                    } else {
0554:                        if (DebugFile.trace)
0555:                            DebugFile
0556:                                    .writeln("Connection.prepareCall({ call k_sp_del_sales_man (?) })");
0557:                        oCall = oConn
0558:                                .prepareCall("{call k_sp_del_sales_man (?)}");
0559:                        for (int c = 0; c < iItems; c++) {
0560:                            oCall.setString(1, oItems.getString(0, c));
0561:                            oCall.execute();
0562:                        } // next
0563:                        oCall.close();
0564:                    }
0565:                } // fi (DBMS_POSTGRESQL)
0566:
0567:                if (DBBind.exists(oConn, DB.k_sales_men_lookup, "U")) {
0568:                    oStmt = oConn.createStatement();
0569:                    try {
0570:                        oStmt.setQueryTimeout(30);
0571:                    } catch (SQLException sqle) {
0572:                    }
0573:                    sSQL = "DELETE FROM " + DB.k_sales_men_lookup + " WHERE "
0574:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0575:                    if (DebugFile.trace)
0576:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0577:                    oStmt.execute(sSQL);
0578:                    oStmt.close();
0579:                }
0580:
0581:                // -----------------------------------------------------------------------------------
0582:
0583:                // Borrar las compañías, cada compañía borrará en cascada sus individuos asociados
0584:                if (DBBind.exists(oConn, DB.k_companies, "U")) {
0585:                    oItems = new DBSubset(DB.k_companies, DB.gu_company,
0586:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0587:                    iItems = oItems.load(oConn);
0588:                    for (int c = 0; c < iItems; c++)
0589:                        Company.delete(oConn, oItems.getString(0, c));
0590:                }
0591:
0592:                // Borrar los contactos, puede haber contactos individuales no asociados a ninguna compañia
0593:                if (DBBind.exists(oConn, DB.k_contacts, "U")) {
0594:                    oItems = new DBSubset(DB.k_contacts, DB.gu_contact,
0595:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0596:                    iItems = oItems.load(oConn);
0597:                    for (int c = 0; c < iItems; c++)
0598:                        Contact.delete(oConn, oItems.getString(0, c));
0599:                }
0600:
0601:                if (DBBind.exists(oConn, DB.k_companies_lookup, "U")) {
0602:                    oStmt = oConn.createStatement();
0603:                    try {
0604:                        oStmt.setQueryTimeout(30);
0605:                    } catch (SQLException sqle) {
0606:                    }
0607:                    sSQL = "DELETE FROM " + DB.k_companies_lookup + " WHERE "
0608:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0609:                    if (DebugFile.trace)
0610:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0611:                    oStmt.execute(sSQL);
0612:                    oStmt.close();
0613:                }
0614:
0615:                if (DBBind.exists(oConn, DB.k_contacts_lookup, "U")) {
0616:                    oStmt = oConn.createStatement();
0617:                    try {
0618:                        oStmt.setQueryTimeout(30);
0619:                    } catch (SQLException sqle) {
0620:                    }
0621:                    sSQL = "DELETE FROM " + DB.k_contacts_lookup + " WHERE "
0622:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0623:                    if (DebugFile.trace)
0624:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0625:                    oStmt.execute(sSQL);
0626:                    oStmt.close();
0627:                }
0628:
0629:                if (DBBind.exists(oConn, DB.k_oportunities_lookup, "U")) {
0630:                    oStmt = oConn.createStatement();
0631:                    try {
0632:                        oStmt.setQueryTimeout(30);
0633:                    } catch (SQLException sqle) {
0634:                    }
0635:                    sSQL = "DELETE FROM " + DB.k_oportunities_lookup
0636:                            + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID
0637:                            + "'";
0638:                    if (DebugFile.trace)
0639:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0640:                    oStmt.execute(sSQL);
0641:                    oStmt.close();
0642:                }
0643:
0644:                if (DBBind.exists(oConn, DB.k_welcome_packs_lookup, "U")) {
0645:                    oStmt = oConn.createStatement();
0646:                    try {
0647:                        oStmt.setQueryTimeout(30);
0648:                    } catch (SQLException sqle) {
0649:                    }
0650:                    sSQL = "DELETE FROM " + DB.k_welcome_packs_lookup
0651:                            + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID
0652:                            + "'";
0653:                    if (DebugFile.trace)
0654:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0655:                    oStmt.execute(sSQL);
0656:                    oStmt.close();
0657:                }
0658:
0659:                // -----------------------------------------------------------------------------------
0660:
0661:                // Borrar los proyectos, cada proyecto borrará en cascada sus incidencias y tareas
0662:                if (DBBind.exists(oConn, DB.k_projects, "U")) {
0663:                    oItems = new DBSubset(DB.k_projects, DB.gu_project,
0664:                            DB.gu_owner + "='" + sWrkAreaGUID + "'", 100);
0665:                    iItems = oItems.load(oConn);
0666:                    for (int p = 0; p < iItems; p++)
0667:                        Project.delete(oConn, oItems.getString(0, p));
0668:                }
0669:
0670:                if (DBBind.exists(oConn, DB.k_projects_lookup, "U")) {
0671:                    oStmt = oConn.createStatement();
0672:                    try {
0673:                        oStmt.setQueryTimeout(30);
0674:                    } catch (SQLException sqle) {
0675:                    }
0676:                    sSQL = "DELETE FROM " + DB.k_projects_lookup + " WHERE "
0677:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0678:                    if (DebugFile.trace)
0679:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0680:                    oStmt.execute(sSQL);
0681:                    oStmt.close();
0682:                }
0683:
0684:                if (DBBind.exists(oConn, DB.k_duties_lookup, "U")) {
0685:                    oStmt = oConn.createStatement();
0686:                    try {
0687:                        oStmt.setQueryTimeout(30);
0688:                    } catch (SQLException sqle) {
0689:                    }
0690:                    sSQL = "DELETE FROM " + DB.k_duties_lookup + " WHERE "
0691:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0692:                    if (DebugFile.trace)
0693:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0694:                    oStmt.execute(sSQL);
0695:                    oStmt.close();
0696:                }
0697:
0698:                if (DBBind.exists(oConn, DB.k_bugs_lookup, "U")) {
0699:                    oStmt = oConn.createStatement();
0700:                    try {
0701:                        oStmt.setQueryTimeout(30);
0702:                    } catch (SQLException sqle) {
0703:                    }
0704:                    sSQL = "DELETE FROM " + DB.k_bugs_lookup + " WHERE "
0705:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0706:                    if (DebugFile.trace)
0707:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0708:                    oStmt.execute(sSQL);
0709:                    oStmt.close();
0710:                }
0711:
0712:                // -----------------------------------------------------------------------------------
0713:                // Borrar las tiendas, cada tienda borrará en cascada sus categorías y productos
0714:
0715:                if (DBBind.exists(oConn, DB.k_invoices, "U")) {
0716:                    oStmt = oConn.createStatement();
0717:                    try {
0718:                        oStmt.setQueryTimeout(30);
0719:                    } catch (SQLException sqle) {
0720:                    }
0721:
0722:                    sSQL = "DELETE FROM " + DB.k_x_orders_invoices + " WHERE "
0723:                            + DB.gu_order + " IN (SELECT " + DB.gu_order
0724:                            + " FROM " + DB.k_orders + " WHERE "
0725:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
0726:                    if (DebugFile.trace)
0727:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0728:                    oStmt.execute(sSQL);
0729:
0730:                    sSQL = "DELETE FROM " + DB.k_invoice_lines + " WHERE "
0731:                            + DB.gu_invoice + " IN (SELECT " + DB.gu_invoice
0732:                            + " FROM " + DB.k_invoices + " WHERE "
0733:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
0734:                    if (DebugFile.trace)
0735:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0736:                    oStmt.execute(sSQL);
0737:
0738:                    sSQL = "DELETE FROM " + DB.k_invoice_schedules + " WHERE "
0739:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0740:                    if (DebugFile.trace)
0741:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0742:                    oStmt.execute(sSQL);
0743:
0744:                    sSQL = "DELETE FROM " + DB.k_invoices + " WHERE "
0745:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0746:                    if (DebugFile.trace)
0747:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0748:                    oStmt.execute(sSQL);
0749:
0750:                    sSQL = "DELETE FROM " + DB.k_invoices_lookup + " WHERE "
0751:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0752:                    if (DebugFile.trace)
0753:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0754:                    oStmt.execute(sSQL);
0755:
0756:                    oStmt.close();
0757:                }
0758:
0759:                if (DBBind.exists(oConn, DB.k_invoices_next, "U")) {
0760:                    oStmt = oConn.createStatement();
0761:                    try {
0762:                        oStmt.setQueryTimeout(30);
0763:                    } catch (SQLException sqle) {
0764:                    }
0765:                    sSQL = "DELETE FROM " + DB.k_invoices_next + " WHERE "
0766:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0767:                    if (DebugFile.trace)
0768:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0769:                    oStmt.execute(sSQL);
0770:                    oStmt.close();
0771:                }
0772:
0773:                if (DBBind.exists(oConn, DB.k_orders, "U")) {
0774:                    oStmt = oConn.createStatement();
0775:                    try {
0776:                        oStmt.setQueryTimeout(30);
0777:                    } catch (SQLException sqle) {
0778:                    }
0779:
0780:                    sSQL = "DELETE FROM " + DB.k_order_lines + " WHERE "
0781:                            + DB.gu_order + " IN (SELECT " + DB.gu_order
0782:                            + " FROM " + DB.k_orders + " WHERE "
0783:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
0784:                    if (DebugFile.trace)
0785:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0786:                    oStmt.execute(sSQL);
0787:
0788:                    sSQL = "DELETE FROM " + DB.k_orders + " WHERE "
0789:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0790:                    if (DebugFile.trace)
0791:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0792:                    oStmt.execute(sSQL);
0793:
0794:                    sSQL = "DELETE FROM " + DB.k_orders_lookup + " WHERE "
0795:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0796:                    if (DebugFile.trace)
0797:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0798:                    oStmt.execute(sSQL);
0799:                    oStmt.close();
0800:                }
0801:
0802:                if (DBBind.exists(oConn, DB.k_business_states, "U")) {
0803:                    oStmt = oConn.createStatement();
0804:                    try {
0805:                        oStmt.setQueryTimeout(30);
0806:                    } catch (SQLException sqle) {
0807:                    }
0808:
0809:                    sSQL = "DELETE FROM " + DB.k_business_states + " WHERE "
0810:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0811:                    if (DebugFile.trace)
0812:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0813:                    oStmt.execute(sSQL);
0814:
0815:                    sSQL = "DELETE FROM " + DB.k_lu_business_states + " WHERE "
0816:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0817:                    if (DebugFile.trace)
0818:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0819:                    oStmt.execute(sSQL);
0820:
0821:                    oStmt.close();
0822:                }
0823:
0824:                if (DBBind.exists(oConn, DB.k_shops, "U")) {
0825:                    oItems = new DBSubset(DB.k_shops, DB.gu_shop,
0826:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
0827:                    iItems = oItems.load(oConn);
0828:                    for (int s = 0; s < iItems; s++)
0829:                        new Shop(oConn, oItems.getString(0, s)).delete(oConn);
0830:                }
0831:
0832:                // -----------------------------------------------------------------------------------
0833:                // Borrar los jobs
0834:
0835:                if (DBBind.exists(oConn, DB.k_jobs, "U")) {
0836:                    oItems = new DBSubset(DB.k_jobs, DB.gu_job, DB.gu_workarea
0837:                            + "='" + sWrkAreaGUID + "'", 100);
0838:                    iItems = oItems.load(oConn);
0839:                    for (int s = 0; s < iItems; s++)
0840:                        Job.delete(oConn, oItems.getString(0, s));
0841:                }
0842:
0843:                // -----------------------------------------------------------------------------------
0844:
0845:                // Borrar campos definidos por los usuarios
0846:                if (DBBind.exists(oConn, DB.k_lu_meta_attrs, "U")) {
0847:                    oStmt = oConn.createStatement();
0848:                    try {
0849:                        oStmt.setQueryTimeout(30);
0850:                    } catch (SQLException sqle) {
0851:                    }
0852:                    sSQL = "DELETE FROM " + DB.k_lu_meta_attrs + " WHERE "
0853:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0854:                    if (DebugFile.trace)
0855:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0856:                    oStmt.execute(sSQL);
0857:                    oStmt.close();
0858:                }
0859:
0860:                // -----------------------------------------------------------------------------------
0861:                // Borrar las direcciones
0862:
0863:                oStmt = oConn.createStatement();
0864:                try {
0865:                    oStmt.setQueryTimeout(30);
0866:                } catch (SQLException sqle) {
0867:                }
0868:
0869:                sSQL = "UPDATE " + DB.k_orders + " SET " + DB.gu_ship_addr
0870:                        + "=NULL WHERE " + DB.gu_ship_addr + " IN (SELECT "
0871:                        + DB.gu_address + " FROM " + DB.k_addresses + " WHERE "
0872:                        + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
0873:                if (DebugFile.trace)
0874:                    DebugFile.writeln("Statement.execute(" + sSQL + ")");
0875:                oStmt.execute(sSQL);
0876:
0877:                sSQL = "UPDATE " + DB.k_orders + " SET " + DB.gu_bill_addr
0878:                        + "=NULL WHERE " + DB.gu_bill_addr + " IN (SELECT "
0879:                        + DB.gu_address + " FROM " + DB.k_addresses + " WHERE "
0880:                        + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
0881:                if (DebugFile.trace)
0882:                    DebugFile.writeln("Statement.execute(" + sSQL + ")");
0883:                oStmt.execute(sSQL);
0884:
0885:                sSQL = "DELETE FROM " + DB.k_x_contact_addr + " WHERE "
0886:                        + DB.gu_address + " IN (SELECT " + DB.gu_address
0887:                        + " FROM " + DB.k_addresses + " WHERE "
0888:                        + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
0889:                if (DebugFile.trace)
0890:                    DebugFile.writeln("Statement.execute(" + sSQL + ")");
0891:                oStmt.execute(sSQL);
0892:
0893:                sSQL = "DELETE FROM " + DB.k_x_company_addr + " WHERE "
0894:                        + DB.gu_address + " IN (SELECT " + DB.gu_address
0895:                        + " FROM " + DB.k_addresses + " WHERE "
0896:                        + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
0897:                if (DebugFile.trace)
0898:                    DebugFile.writeln("Statement.execute(" + sSQL + ")");
0899:                oStmt.execute(sSQL);
0900:
0901:                sSQL = "DELETE FROM " + DB.k_addresses + " WHERE "
0902:                        + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0903:                if (DebugFile.trace)
0904:                    DebugFile.writeln("Statement.execute(" + sSQL + ")");
0905:                oStmt.execute(sSQL);
0906:
0907:                sSQL = "DELETE FROM " + DB.k_addresses_lookup + " WHERE "
0908:                        + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0909:                if (DebugFile.trace)
0910:                    DebugFile.writeln("Statement.execute(" + sSQL + ")");
0911:                oStmt.execute(sSQL);
0912:
0913:                oStmt.close();
0914:
0915:                // -----------------------------------------------------------------------------------
0916:
0917:                // Borrar las entradas del tesauro
0918:                if (DBBind.exists(oConn, DB.k_thesauri, "U")) {
0919:                    oStmt = oConn.createStatement();
0920:                    try {
0921:                        oStmt.setQueryTimeout(30);
0922:                    } catch (SQLException sqle) {
0923:                    }
0924:
0925:                    // Primero los sinonimos
0926:                    sSQL = "DELETE FROM " + DB.k_thesauri + " WHERE "
0927:                            + DB.bo_mainterm + "=0 AND " + DB.gu_rootterm
0928:                            + " IN (SELECT " + DB.gu_rootterm + " FROM "
0929:                            + DB.k_thesauri_root + " WHERE " + DB.gu_workarea
0930:                            + "='" + sWrkAreaGUID + "')";
0931:
0932:                    if (DebugFile.trace)
0933:                        DebugFile.writeln("Statement.executeUpdate(" + sSQL
0934:                                + ")");
0935:                    oStmt.executeUpdate(sSQL);
0936:
0937:                    // Luego los términos principales
0938:                    sSQL = "DELETE FROM " + DB.k_thesauri + " WHERE "
0939:                            + DB.gu_rootterm + " IN (SELECT " + DB.gu_rootterm
0940:                            + " FROM " + DB.k_thesauri_root + " WHERE "
0941:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
0942:
0943:                    if (DebugFile.trace)
0944:                        DebugFile.writeln("Statement.executeUpdate(" + sSQL
0945:                                + ")");
0946:                    oStmt.executeUpdate(sSQL);
0947:
0948:                    // Finalmente los terminos raiz
0949:                    sSQL = "DELETE FROM " + DB.k_thesauri_root + " WHERE "
0950:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0951:
0952:                    if (DebugFile.trace)
0953:                        DebugFile.writeln("Statement.executeUpdate(" + sSQL
0954:                                + ")");
0955:                    oStmt.executeUpdate(sSQL);
0956:
0957:                    oStmt.close();
0958:                }
0959:
0960:                // Borrar los lookups del tesauro
0961:                if (DBBind.exists(oConn, DB.k_thesauri_lookup, "U")) {
0962:                    oStmt = oConn.createStatement();
0963:                    try {
0964:                        oStmt.setQueryTimeout(30);
0965:                    } catch (SQLException sqle) {
0966:                    }
0967:                    sSQL = "DELETE FROM " + DB.k_thesauri_lookup + " WHERE "
0968:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
0969:                    if (DebugFile.trace)
0970:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0971:                    oStmt.execute(sSQL);
0972:                    oStmt.close();
0973:                }
0974:
0975:                // -----------------------------------------------------------------------------------
0976:                // Borrar las cuentas bancarias
0977:
0978:                if (DBBind.exists(oConn, DB.k_bank_accounts, "U")) {
0979:                    oStmt = oConn.createStatement();
0980:                    try {
0981:                        oStmt.setQueryTimeout(30);
0982:                    } catch (SQLException sqle) {
0983:                    }
0984:                    sSQL = "DELETE FROM " + DB.k_bank_accounts + " WHERE "
0985:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
0986:                    if (DebugFile.trace)
0987:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
0988:                    oStmt.execute(sSQL);
0989:                    oStmt.close();
0990:                }
0991:
0992:                if (DBBind.exists(oConn, DB.k_bank_accounts_lookup, "U")) {
0993:                    oStmt = oConn.createStatement();
0994:                    try {
0995:                        oStmt.setQueryTimeout(30);
0996:                    } catch (SQLException sqle) {
0997:                    }
0998:                    sSQL = "DELETE FROM " + DB.k_bank_accounts_lookup
0999:                            + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID
1000:                            + "'";
1001:                    if (DebugFile.trace)
1002:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
1003:                    oStmt.execute(sSQL);
1004:                    oStmt.close();
1005:                }
1006:
1007:                // -----------------------------------------------------------------------------------
1008:                // Borrar los cursos
1009:                // nuevo v2.2
1010:
1011:                if (DBBind.exists(oConn, DB.k_absentisms_lookup, "U")) {
1012:                    oStmt = oConn.createStatement();
1013:                    try {
1014:                        oStmt.setQueryTimeout(30);
1015:                    } catch (SQLException sqle) {
1016:                    }
1017:                    sSQL = "DELETE FROM " + DB.k_absentisms_lookup + " WHERE "
1018:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
1019:                    if (DebugFile.trace)
1020:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
1021:                    oStmt.execute(sSQL);
1022:                    oStmt.close();
1023:                }
1024:
1025:                if (DBBind.exists(oConn, DB.k_subjects, "U")) {
1026:                    oStmt = oConn.createStatement();
1027:                    try {
1028:                        oStmt.setQueryTimeout(30);
1029:                    } catch (SQLException sqle) {
1030:                    }
1031:                    sSQL = "DELETE FROM " + DB.k_subjects_lookup + " WHERE "
1032:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
1033:                    if (DebugFile.trace)
1034:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
1035:                    oStmt.execute(sSQL);
1036:                    sSQL = "DELETE FROM " + DB.k_subjects + " WHERE "
1037:                            + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
1038:                    if (DebugFile.trace)
1039:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
1040:                    oStmt.execute(sSQL);
1041:                    oStmt.close();
1042:                }
1043:
1044:                if (DBBind.exists(oConn, DB.k_courses, "U")) {
1045:                    oStmt = oConn.createStatement();
1046:                    try {
1047:                        oStmt.setQueryTimeout(30);
1048:                    } catch (SQLException sqle) {
1049:                    }
1050:                    sSQL = "DELETE FROM " + DB.k_courses_lookup + " WHERE "
1051:                            + DB.gu_owner + "='" + sWrkAreaGUID + "'";
1052:                    if (DebugFile.trace)
1053:                        DebugFile.writeln("Statement.execute(" + sSQL + ")");
1054:                    oStmt.execute(sSQL);
1055:                    oStmt.close();
1056:
1057:                    oItems = new DBSubset(DB.k_courses, DB.gu_course,
1058:                            DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
1059:                    iItems = oItems.load(oConn);
1060:                    if (oConn.getDataBaseProduct() == JDCConnection.DBMS_POSTGRESQL) {
1061:                        oPtmt = oConn
1062:                                .prepareStatement("SELECT k_sp_del_course(?)");
1063:                        for (int c = 0; c < iItems; c++) {
1064:                            oPtmt.setString(1, oItems.getString(0, c));
1065:                            oPtmt.executeQuery();
1066:                        }
1067:                        oPtmt.close();
1068:                    } else {
1069:                        oCall = oConn.prepareCall("{call k_sp_del_course (?)}");
1070:                        for (int c = 0; c < iItems; c++) {
1071:                            oCall.setString(1, oItems.getString(0, c));
1072:                            oCall.execute();
1073:                        }
1074:                        oCall.close();
1075:                    } // fi (DBMS_POSTGRESQL)
1076:                } // fi (exists(DB.k_courses))
1077:
1078:                // -----------------------------------------------------------------------------------
1079:                // Borrar la workarea en si misma
1080:                oStmt = oConn.createStatement();
1081:                try {
1082:                    oStmt.setQueryTimeout(30);
1083:                } catch (SQLException sqle) {
1084:                }
1085:
1086:                sSQL = "DELETE FROM " + DB.k_x_app_workarea + " WHERE "
1087:                        + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
1088:                if (DebugFile.trace)
1089:                    DebugFile.writeln("Statement.execute(" + sSQL + ")");
1090:                oStmt.execute(sSQL);
1091:
1092:                sSQL = "DELETE FROM " + DB.k_workareas + " WHERE "
1093:                        + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
1094:                if (DebugFile.trace)
1095:                    DebugFile.writeln("Statement.execute(" + sSQL + ")");
1096:                oStmt.execute(sSQL);
1097:                oStmt.close();
1098:
1099:                if (DebugFile.trace) {
1100:                    DebugFile.decIdent();
1101:                    DebugFile.writeln("End WorkArea.delete() : true");
1102:                }
1103:
1104:                return true;
1105:            } // delete()
1106:
1107:            // ----------------------------------------------------------
1108:
1109:            /**
1110:             * <p>Delete a WorkArea, its associated data and working directories.</p>
1111:             * USE THIS METHOD WITH EXTREME CARE. AS IT WILL DELETE DATA FROM EVERY TABLE
1112:             * CONTAINING A gu_workarea COLUMN MATCHING THE DELETED WORKAREA GUID.<br><br>
1113:             * @param oConn Database Connection
1114:             * @param sWrkAreaGUID GUID of WorkArea to be deleted
1115:             * @param oProps Properties Colection containing "storage" and "workareasput" properties.<br>
1116:             * /storage/domains/<i>nnnn</i>/workareas/<i>sWrkAreaGUID</i> and
1117:             * /workareasput/<i>sWrkAreaGUID</i> will be taken as base directories for deleting
1118:             * WorkArea files.<br>
1119:             * javamode property will determine whether directories shall be deleted witha tomic operating
1120:             * systems calls or by Pure Java functions.
1121:             * @return <b>true</b> if specified WorkArea GUID was found and deleted at k_workareas,
1122:             * <b>false</b> if specified WorkArea GUID was not found.
1123:             * @throws IOException
1124:             * @throws SQLException
1125:             * @see com.knowgate.dfs.FileSystem.delete(String)
1126:             */
1127:            public static boolean delete(JDCConnection oConn,
1128:                    String sWrkAreaGUID, java.util.Properties oProps)
1129:                    throws Exception, IOException, SQLException {
1130:
1131:                final String s = System.getProperty("file.separator");
1132:
1133:                if (DebugFile.trace) {
1134:                    DebugFile.writeln("Begin WorkArea.delete([Connection], "
1135:                            + sWrkAreaGUID + ", " + "[Properties])");
1136:                    DebugFile.incIdent();
1137:                }
1138:
1139:                int iDomainId = 0;
1140:
1141:                if (DebugFile.trace)
1142:                    DebugFile.writeln("Connection.prepareStatement(SELECT "
1143:                            + DB.id_domain + " FROM " + DB.k_workareas
1144:                            + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID
1145:                            + "'");
1146:
1147:                PreparedStatement oStmt = oConn.prepareStatement("SELECT "
1148:                        + DB.id_domain + " FROM " + DB.k_workareas + " WHERE "
1149:                        + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY,
1150:                        ResultSet.CONCUR_READ_ONLY);
1151:                oStmt.setString(1, sWrkAreaGUID);
1152:                ResultSet oRSet = oStmt.executeQuery();
1153:                if (oRSet.next())
1154:                    iDomainId = oRSet.getInt(1);
1155:                oRSet.close();
1156:                oStmt.close();
1157:
1158:                boolean bRetVal = false;
1159:
1160:                if (0 != iDomainId) {
1161:                    FileSystemWorkArea oFS = new FileSystemWorkArea(oProps);
1162:
1163:                    bRetVal = delete(oConn, sWrkAreaGUID);
1164:
1165:                    if (bRetVal) {
1166:                        if (null != oProps.getProperty("workareasput"))
1167:                            oFS.rmworkpath(sWrkAreaGUID);
1168:
1169:                        if (null != oProps.getProperty("storage"))
1170:                            oFS.rmstorpath(iDomainId, sWrkAreaGUID);
1171:
1172:                    } // fi (bRetVal)
1173:                } // fi(0!=iDomainId)
1174:
1175:                if (DebugFile.trace) {
1176:                    DebugFile.decIdent();
1177:                    DebugFile.writeln("End WorkArea.delete() : "
1178:                            + String.valueOf(bRetVal));
1179:                }
1180:
1181:                return bRetVal;
1182:            } // delete
1183:
1184:            // ----------------------------------------------------------
1185:
1186:            /**
1187:             * Get path_logo field from k_workareas table
1188:             * @param oConn JDCConnection
1189:             * @param sWrkAId String GUID of WorkArea
1190:             * @return String Value of field path_logo
1191:             * @throws SQLException
1192:             */
1193:            public static String getPath(JDCConnection oConn, String sWrkAId)
1194:                    throws SQLException {
1195:                String sWrkAPath;
1196:
1197:                if (DebugFile.trace) {
1198:                    DebugFile.writeln("Begin WorkArea.getPath([Connection], "
1199:                            + sWrkAId + ")");
1200:                    DebugFile.incIdent();
1201:                }
1202:
1203:                PreparedStatement oStmt = oConn.prepareStatement("SELECT "
1204:                        + DB.path_logo + " FROM " + DB.k_workareas + " WHERE "
1205:                        + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY,
1206:                        ResultSet.CONCUR_READ_ONLY);
1207:                oStmt.setString(1, sWrkAId);
1208:                ResultSet oRSet = oStmt.executeQuery();
1209:                if (oRSet.next())
1210:                    sWrkAPath = oRSet.getString(1);
1211:                else
1212:                    sWrkAPath = null;
1213:                oRSet.close();
1214:                oRSet = null;
1215:                oStmt.close();
1216:
1217:                if (DebugFile.trace) {
1218:                    DebugFile.decIdent();
1219:                    DebugFile.writeln("End WorkArea.getPath() : "
1220:                            + (sWrkAPath != null ? sWrkAPath : "null"));
1221:                }
1222:
1223:                return sWrkAPath;
1224:            } // getPath
1225:
1226:            // ----------------------------------------------------------
1227:
1228:            public static boolean isAdmin(JDCConnection oConn,
1229:                    String guWorkArea, String sUserId) throws SQLException {
1230:                int iIsAdmin;
1231:                CallableStatement oCall;
1232:                PreparedStatement oStmt;
1233:                ResultSet oRSet;
1234:
1235:                if (DebugFile.trace) {
1236:                    DebugFile.writeln("Begin WorkArea.isAdmin([Connection], "
1237:                            + guWorkArea + "," + sUserId + ")");
1238:                    DebugFile.incIdent();
1239:                }
1240:
1241:                switch (oConn.getDataBaseProduct()) {
1242:
1243:                case JDCConnection.DBMS_MSSQL:
1244:                case JDCConnection.DBMS_ORACLE:
1245:
1246:                    if (DebugFile.trace)
1247:                        DebugFile
1248:                                .writeln("Connection.prepareCall({ call k_is_workarea_admin ('"
1249:                                        + guWorkArea
1250:                                        + "','"
1251:                                        + sUserId
1252:                                        + "',?)})");
1253:
1254:                    oCall = oConn
1255:                            .prepareCall("{ call k_is_workarea_admin (?,?,?)}");
1256:
1257:                    oCall.setString(1, guWorkArea);
1258:                    oCall.setString(2, sUserId);
1259:                    oCall.registerOutParameter(3, Types.INTEGER);
1260:                    oCall.execute();
1261:                    iIsAdmin = oCall.getInt(3);
1262:                    oCall.close();
1263:                    break;
1264:
1265:                default:
1266:
1267:                    if (DebugFile.trace)
1268:                        DebugFile
1269:                                .writeln("Connection.prepareStatement(SELECT x."
1270:                                        + DB.gu_acl_group
1271:                                        + " FROM "
1272:                                        + DB.k_x_group_user
1273:                                        + " x, "
1274:                                        + DB.k_x_app_workarea
1275:                                        + " w WHERE x."
1276:                                        + DB.gu_acl_group
1277:                                        + "=w."
1278:                                        + DB.gu_admins
1279:                                        + " AND x."
1280:                                        + DB.gu_user
1281:                                        + "='"
1282:                                        + sUserId
1283:                                        + "' AND w."
1284:                                        + DB.gu_workarea
1285:                                        + "='"
1286:                                        + guWorkArea
1287:                                        + "')");
1288:
1289:                    oStmt = oConn.prepareStatement("SELECT x."
1290:                            + DB.gu_acl_group + " FROM " + DB.k_x_group_user
1291:                            + " x, " + DB.k_x_app_workarea + " w WHERE x."
1292:                            + DB.gu_acl_group + "=w." + DB.gu_admins
1293:                            + " AND x." + DB.gu_user + "=? AND w."
1294:                            + DB.gu_workarea + "=?",
1295:                            ResultSet.TYPE_FORWARD_ONLY,
1296:                            ResultSet.CONCUR_READ_ONLY);
1297:                    oStmt.setString(1, sUserId);
1298:                    oStmt.setString(2, guWorkArea);
1299:                    oRSet = oStmt.executeQuery();
1300:                    if (oRSet.next())
1301:                        iIsAdmin = 1;
1302:                    else
1303:                        iIsAdmin = 0;
1304:                    oRSet.close();
1305:                    oStmt.close();
1306:                    break;
1307:                } // end switch
1308:
1309:                if (DebugFile.trace) {
1310:                    DebugFile.decIdent();
1311:                    DebugFile.writeln("End WorkArea.isAdmin() : "
1312:                            + String.valueOf(0 != iIsAdmin));
1313:                }
1314:
1315:                return (0 != iIsAdmin);
1316:            } // isAdmin()
1317:
1318:            // ----------------------------------------------------------
1319:
1320:            public static boolean isPowerUser(JDCConnection oConn,
1321:                    String guWorkArea, String sUserId) throws SQLException {
1322:                int iIsPowerUser;
1323:                CallableStatement oCall;
1324:                PreparedStatement oStmt;
1325:                ResultSet oRSet;
1326:
1327:                if (DebugFile.trace) {
1328:                    DebugFile
1329:                            .writeln("Begin WorkArea.isPowerUser([Connection], "
1330:                                    + guWorkArea + "," + sUserId + ")");
1331:                    DebugFile.incIdent();
1332:                }
1333:
1334:                switch (oConn.getDataBaseProduct()) {
1335:
1336:                case JDCConnection.DBMS_MSSQL:
1337:                case JDCConnection.DBMS_ORACLE:
1338:
1339:                    if (DebugFile.trace)
1340:                        DebugFile
1341:                                .writeln("Connection.prepareCall({ call k_is_workarea_poweruser ('"
1342:                                        + guWorkArea
1343:                                        + "','"
1344:                                        + sUserId
1345:                                        + "',?)})");
1346:
1347:                    oCall = oConn
1348:                            .prepareCall("{ call k_is_workarea_poweruser (?,?,?)}");
1349:
1350:                    oCall.setString(1, guWorkArea);
1351:                    oCall.setString(2, sUserId);
1352:                    oCall.registerOutParameter(3, Types.INTEGER);
1353:                    oCall.execute();
1354:                    iIsPowerUser = oCall.getInt(3);
1355:                    oCall.close();
1356:                    break;
1357:
1358:                default:
1359:
1360:                    if (DebugFile.trace)
1361:                        DebugFile
1362:                                .writeln("Connection.prepareStatement(SELECT x."
1363:                                        + DB.gu_acl_group
1364:                                        + " FROM "
1365:                                        + DB.k_x_group_user
1366:                                        + " x, "
1367:                                        + DB.k_x_app_workarea
1368:                                        + " w WHERE x."
1369:                                        + DB.gu_acl_group
1370:                                        + "=w."
1371:                                        + DB.gu_powusers
1372:                                        + " AND x."
1373:                                        + DB.gu_user
1374:                                        + "='"
1375:                                        + sUserId
1376:                                        + "' AND w."
1377:                                        + DB.gu_workarea
1378:                                        + "='"
1379:                                        + guWorkArea + "')");
1380:
1381:                    oStmt = oConn.prepareStatement("SELECT x."
1382:                            + DB.gu_acl_group + " FROM " + DB.k_x_group_user
1383:                            + " x, " + DB.k_x_app_workarea + " w WHERE x."
1384:                            + DB.gu_acl_group + "=w." + DB.gu_powusers
1385:                            + " AND x." + DB.gu_user + "=? AND w."
1386:                            + DB.gu_workarea + "=?",
1387:                            ResultSet.TYPE_FORWARD_ONLY,
1388:                            ResultSet.CONCUR_READ_ONLY);
1389:                    oStmt.setString(1, sUserId);
1390:                    oStmt.setString(2, guWorkArea);
1391:                    oRSet = oStmt.executeQuery();
1392:                    if (oRSet.next())
1393:                        iIsPowerUser = 1;
1394:                    else
1395:                        iIsPowerUser = 0;
1396:                    oRSet.close();
1397:                    oStmt.close();
1398:                    break;
1399:                } // end switch
1400:
1401:                if (DebugFile.trace) {
1402:                    DebugFile.decIdent();
1403:                    DebugFile.writeln("End WorkArea.isPowerUser() : "
1404:                            + String.valueOf(0 != iIsPowerUser));
1405:                }
1406:
1407:                return (0 != iIsPowerUser);
1408:
1409:            } // isPowerUser()
1410:
1411:            // ----------------------------------------------------------
1412:
1413:            public static boolean isUser(JDCConnection oConn,
1414:                    String guWorkArea, String sUserId) throws SQLException {
1415:                int iIsUser;
1416:                CallableStatement oCall;
1417:                PreparedStatement oStmt;
1418:                ResultSet oRSet;
1419:
1420:                if (DebugFile.trace) {
1421:                    DebugFile.writeln("Begin WorkArea.isUser([Connection], "
1422:                            + guWorkArea + "," + sUserId + ")");
1423:                    DebugFile.incIdent();
1424:                }
1425:
1426:                switch (oConn.getDataBaseProduct()) {
1427:
1428:                case JDCConnection.DBMS_MSSQL:
1429:                case JDCConnection.DBMS_ORACLE:
1430:
1431:                    oCall = oConn
1432:                            .prepareCall("{ call k_is_workarea_user (?,?,?)}");
1433:
1434:                    oCall.setString(1, guWorkArea);
1435:                    oCall.setString(2, sUserId);
1436:                    oCall.registerOutParameter(3, Types.INTEGER);
1437:                    oCall.execute();
1438:                    iIsUser = oCall.getInt(3);
1439:                    oCall.close();
1440:                    break;
1441:                default:
1442:                    oStmt = oConn.prepareStatement("SELECT x."
1443:                            + DB.gu_acl_group + " FROM " + DB.k_x_group_user
1444:                            + " x, " + DB.k_x_app_workarea + " w WHERE x."
1445:                            + DB.gu_acl_group + "=w." + DB.gu_users + " AND x."
1446:                            + DB.gu_user + "=? AND w." + DB.gu_workarea + "=?",
1447:                            ResultSet.TYPE_FORWARD_ONLY,
1448:                            ResultSet.CONCUR_READ_ONLY);
1449:                    oStmt.setString(1, sUserId);
1450:                    oStmt.setString(2, guWorkArea);
1451:                    oRSet = oStmt.executeQuery();
1452:                    if (oRSet.next())
1453:                        iIsUser = 1;
1454:                    else
1455:                        iIsUser = 0;
1456:                    oRSet.close();
1457:                    oStmt.close();
1458:                    break;
1459:                } // end switch
1460:
1461:                if (DebugFile.trace) {
1462:                    DebugFile.decIdent();
1463:                    DebugFile.writeln("End WorkArea.isUser() : "
1464:                            + String.valueOf(0 != iIsUser));
1465:                }
1466:
1467:                return (0 != iIsUser);
1468:            } // iIsUser()
1469:
1470:            // ----------------------------------------------------------
1471:
1472:            public static boolean isGuest(JDCConnection oConn,
1473:                    String guWorkArea, String sUserId) throws SQLException {
1474:                int iIsGuest;
1475:                CallableStatement oCall;
1476:                PreparedStatement oStmt;
1477:                ResultSet oRSet;
1478:
1479:                if (DebugFile.trace) {
1480:                    DebugFile.writeln("Begin WorkArea.isGuest([Connection], "
1481:                            + guWorkArea + "," + sUserId + ")");
1482:                    DebugFile.incIdent();
1483:                }
1484:
1485:                switch (oConn.getDataBaseProduct()) {
1486:
1487:                case JDCConnection.DBMS_ORACLE:
1488:
1489:                    if (DebugFile.trace)
1490:                        DebugFile
1491:                                .writeln("Connection.prepareCall({ call k_is_workarea_guest ('"
1492:                                        + guWorkArea
1493:                                        + "','"
1494:                                        + sUserId
1495:                                        + "',?)})");
1496:
1497:                    oCall = oConn
1498:                            .prepareCall("{ call k_is_workarea_guest (?,?,?)}");
1499:
1500:                    oCall.setString(1, guWorkArea);
1501:                    oCall.setString(2, sUserId);
1502:                    oCall.registerOutParameter(3, Types.DECIMAL);
1503:                    oCall.execute();
1504:                    iIsGuest = oCall.getBigDecimal(3).intValue();
1505:                    oCall.close();
1506:                    break;
1507:
1508:                case JDCConnection.DBMS_MSSQL:
1509:
1510:                    if (DebugFile.trace)
1511:                        DebugFile
1512:                                .writeln("Connection.prepareCall({ call k_is_workarea_guest ('"
1513:                                        + guWorkArea
1514:                                        + "','"
1515:                                        + sUserId
1516:                                        + "',?)})");
1517:
1518:                    oCall = oConn
1519:                            .prepareCall("{ call k_is_workarea_guest (?,?,?)}");
1520:
1521:                    oCall.setString(1, guWorkArea);
1522:                    oCall.setString(2, sUserId);
1523:                    oCall.registerOutParameter(3, Types.INTEGER);
1524:                    oCall.execute();
1525:                    iIsGuest = oCall.getInt(3);
1526:                    oCall.close();
1527:                    break;
1528:
1529:                default:
1530:
1531:                    if (DebugFile.trace)
1532:                        DebugFile
1533:                                .writeln("Connection.prepareStatement(SELECT x."
1534:                                        + DB.gu_acl_group
1535:                                        + " FROM "
1536:                                        + DB.k_x_group_user
1537:                                        + " x, "
1538:                                        + DB.k_x_app_workarea
1539:                                        + " w WHERE x."
1540:                                        + DB.gu_acl_group
1541:                                        + "=w."
1542:                                        + DB.gu_guests
1543:                                        + " AND x."
1544:                                        + DB.gu_user
1545:                                        + "='"
1546:                                        + sUserId
1547:                                        + "' AND w."
1548:                                        + DB.gu_workarea
1549:                                        + "='"
1550:                                        + guWorkArea
1551:                                        + "')");
1552:
1553:                    oStmt = oConn.prepareStatement("SELECT x."
1554:                            + DB.gu_acl_group + " FROM " + DB.k_x_group_user
1555:                            + " x, " + DB.k_x_app_workarea + " w WHERE x."
1556:                            + DB.gu_acl_group + "=w." + DB.gu_guests
1557:                            + " AND x." + DB.gu_user + "=? AND w."
1558:                            + DB.gu_workarea + "=?",
1559:                            ResultSet.TYPE_FORWARD_ONLY,
1560:                            ResultSet.CONCUR_READ_ONLY);
1561:                    oStmt.setString(1, sUserId);
1562:                    oStmt.setString(2, guWorkArea);
1563:                    oRSet = oStmt.executeQuery();
1564:                    if (oRSet.next())
1565:                        iIsGuest = 1;
1566:                    else
1567:                        iIsGuest = 0;
1568:                    oRSet.close();
1569:                    oStmt.close();
1570:                    break;
1571:                } // end switch
1572:
1573:                if (DebugFile.trace) {
1574:                    DebugFile.decIdent();
1575:                    DebugFile.writeln("End WorkArea.isGuest() : "
1576:                            + String.valueOf(0 != iIsGuest));
1577:                }
1578:
1579:                return (0 != iIsGuest);
1580:            } // iIsGuest()
1581:
1582:            // ----------------------------------------------------------
1583:
1584:            public static int getUserAppMask(JDCConnection oConn,
1585:                    String guWorkArea, String sUserId) throws SQLException {
1586:
1587:                if (DebugFile.trace) {
1588:                    DebugFile
1589:                            .writeln("Begin WorkArea.getUserAppMask([Connection], "
1590:                                    + guWorkArea + "," + sUserId + ")");
1591:                    DebugFile.incIdent();
1592:                }
1593:
1594:                DBSubset oApps = new DBSubset(DB.k_x_app_workarea, DB.id_app
1595:                        + "," + DB.gu_admins + "," + DB.gu_powusers + ","
1596:                        + DB.gu_users + "," + DB.gu_guests + "," + DB.gu_other,
1597:                        DB.gu_workarea + "=?", 30);
1598:                int iApps = oApps.load(oConn, new Object[] { guWorkArea });
1599:                int iAppMask = 0;
1600:                String sGrp;
1601:
1602:                if (DebugFile.trace)
1603:                    DebugFile.writeln("Connection.prepareStatement(SELECT "
1604:                            + DB.gu_acl_group + " FROM " + DB.k_x_group_user
1605:                            + " WHERE " + DB.gu_user + "='" + sUserId + "')");
1606:
1607:                PreparedStatement oStmt = oConn
1608:                        .prepareStatement("SELECT " + DB.gu_acl_group
1609:                                + " FROM " + DB.k_x_group_user + " WHERE "
1610:                                + DB.gu_user + "=?",
1611:                                ResultSet.TYPE_FORWARD_ONLY,
1612:                                ResultSet.CONCUR_READ_ONLY);
1613:
1614:                try {
1615:                    oStmt.setQueryTimeout(10);
1616:                } catch (SQLException sqle) {
1617:                }
1618:
1619:                oStmt.setString(1, sUserId);
1620:
1621:                ResultSet oRSet = oStmt.executeQuery();
1622:
1623:                while (oRSet.next()) {
1624:                    sGrp = oRSet.getString(1);
1625:                    for (int a = 0; a < iApps; a++)
1626:                        if (sGrp.equals(oApps.get(1, a))
1627:                                || sGrp.equals(oApps.get(2, a))
1628:                                || sGrp.equals(oApps.get(3, a))
1629:                                || sGrp.equals(oApps.get(4, a))
1630:                                || sGrp.equals(oApps.get(5, a)))
1631:                            iAppMask |= (1 << oApps.getInt(0, a));
1632:                } // wend
1633:                oRSet.close();
1634:                oStmt.close();
1635:
1636:                if (DebugFile.trace) {
1637:                    DebugFile.decIdent();
1638:                    DebugFile.writeln("End WorkArea.getUserAppMask() : "
1639:                            + String.valueOf(iAppMask));
1640:                }
1641:
1642:                return iAppMask;
1643:            } // getUserAppMask()
1644:
1645:            // ----------------------------------------------------------
1646:
1647:            public static String getIdFromName(JDCConnection oConn,
1648:                    int iDomainId, String sWorkAreaNm) throws SQLException {
1649:                PreparedStatement oStmt;
1650:                ResultSet oRSet;
1651:                String sRetVal;
1652:
1653:                if (DebugFile.trace) {
1654:                    DebugFile
1655:                            .writeln("Begin WorkArea.getIdFromName([Connection], "
1656:                                    + String.valueOf(iDomainId)
1657:                                    + ","
1658:                                    + sWorkAreaNm + ")");
1659:                    DebugFile.incIdent();
1660:                }
1661:
1662:                switch (oConn.getDataBaseProduct()) {
1663:
1664:                case JDCConnection.DBMS_MSSQL:
1665:                case JDCConnection.DBMS_ORACLE:
1666:                    sRetVal = getUIdFromName(oConn, new Integer(iDomainId),
1667:                            sWorkAreaNm, "k_get_workarea_id");
1668:                    break;
1669:
1670:                default:
1671:                    if (DebugFile.trace)
1672:                        DebugFile.writeln("Connection.prepareStatement(SELECT "
1673:                                + DB.gu_workarea + " FROM " + DB.k_workareas
1674:                                + " WHERE " + DB.nm_workarea + "='"
1675:                                + sWorkAreaNm + "' AND " + DB.id_domain + "="
1676:                                + String.valueOf(iDomainId) + " AND "
1677:                                + DB.bo_active + "<>0)");
1678:
1679:                    oStmt = oConn.prepareStatement("SELECT " + DB.gu_workarea
1680:                            + " FROM " + DB.k_workareas + " WHERE "
1681:                            + DB.nm_workarea + "=? AND " + DB.id_domain
1682:                            + "=? AND " + DB.bo_active + "<>0",
1683:                            ResultSet.TYPE_FORWARD_ONLY,
1684:                            ResultSet.CONCUR_READ_ONLY);
1685:                    oStmt.setString(1, sWorkAreaNm);
1686:                    oStmt.setInt(2, iDomainId);
1687:                    oRSet = oStmt.executeQuery();
1688:                    if (oRSet.next())
1689:                        sRetVal = oRSet.getString(1);
1690:                    else
1691:                        sRetVal = null;
1692:                    oRSet.close();
1693:                    oStmt.close();
1694:                    break;
1695:                }
1696:
1697:                if (DebugFile.trace) {
1698:                    DebugFile.decIdent();
1699:                    DebugFile.writeln("End WorkArea.getIdFromName() : "
1700:                            + sRetVal);
1701:                }
1702:
1703:                return sRetVal;
1704:            } // getIdFromName
1705:
1706:            // ----------------------------------------------------------
1707:
1708:            public static final short ClassId = 5;
1709:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.