Source Code Cross Referenced for MicrositeDB.java in  » Groupware » hipergate » com » knowgate » dataxslt » db » 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.dataxslt.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          Copyright (C) 2003  Know Gate S.L. All rights reserved.
003:                              C/Oña, 107 1º2 28050 Madrid (Spain)
004:
005:          Redistribution and use in source and binary forms, with or without
006:          modification, are permitted provided that the following conditions
007:          are met:
008:
009:          1. Redistributions of source code must retain the above copyright
010:             notice, this list of conditions and the following disclaimer.
011:
012:          2. The end-user documentation included with the redistribution,
013:             if any, must include the following acknowledgment:
014:             "This product includes software parts from hipergate
015:             (http://www.hipergate.org/)."
016:             Alternately, this acknowledgment may appear in the software itself,
017:             if and wherever such third-party acknowledgments normally appear.
018:
019:          3. The name hipergate must not be used to endorse or promote products
020:             derived from this software without prior written permission.
021:             Products derived from this software may not be called hipergate,
022:             nor may hipergate appear in their name, without prior written
023:             permission.
024:
025:          This library is distributed in the hope that it will be useful,
026:          but WITHOUT ANY WARRANTY; without even the implied warranty of
027:          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029:          You should have received a copy of hipergate License with this code;
030:          if not, visit http://www.hipergate.org or mail to info@hipergate.org
031:         */
032:
033:        package com.knowgate.dataxslt.db;
034:
035:        import com.knowgate.debug.DebugFile;
036:        import com.knowgate.jdc.JDCConnection;
037:        import com.knowgate.dataobjs.DB;
038:        import com.knowgate.dataobjs.DBBind;
039:        import com.knowgate.dataobjs.DBPersist;
040:        import com.knowgate.misc.Gadgets;
041:
042:        import java.io.File;
043:        import java.io.IOException;
044:
045:        import java.sql.SQLException;
046:        import java.sql.CallableStatement;
047:        import java.sql.PreparedStatement;
048:        import java.sql.ResultSet;
049:        import java.sql.Types;
050:
051:        /**
052:         *
053:         * <p>Microsite database index</p>
054:         * @author Sergio Montoro Ten
055:         * @version 2.0
056:         */
057:        public class MicrositeDB extends DBPersist {
058:
059:            public MicrositeDB() {
060:                super (DB.k_microsites, "MicrositesDB");
061:            }
062:
063:            public MicrositeDB(JDCConnection oConn, String sMicrositeGUID)
064:                    throws SQLException {
065:                super (DB.k_microsites, "MicrositesDB");
066:                Object aPK[] = { sMicrositeGUID };
067:                load(oConn, aPK);
068:            }
069:
070:            // ----------------------------------------------------------
071:
072:            public boolean load(JDCConnection oConn, Object aPK[])
073:                    throws SQLException {
074:                CallableStatement oStmt;
075:                String sNmMicrosite;
076:                boolean bRetVal;
077:
078:                if (DebugFile.trace) {
079:                    DebugFile.writeln("Begin MicrositeDB.load([Connection], {"
080:                            + aPK[0] + "}");
081:                    DebugFile.incIdent();
082:                }
083:
084:                if (oConn.getDataBaseProduct() == JDCConnection.DBMS_ORACLE
085:                        || oConn.getDataBaseProduct() == JDCConnection.DBMS_MSSQL
086:                        || oConn.getDataBaseProduct() == JDCConnection.DBMS_MYSQL) {
087:
088:                    if (DebugFile.trace)
089:                        DebugFile
090:                                .writeln("Connection.prepareCall({ call k_sp_read_microsite ('"
091:                                        + aPK[0] + "',?,?,?,?) }");
092:
093:                    oStmt = oConn
094:                            .prepareCall("{ call k_sp_read_microsite (?,?,?,?,?) }");
095:
096:                    clear();
097:
098:                    oStmt.setObject(1, aPK[0], Types.CHAR); // gu_microsite
099:                    oStmt.registerOutParameter(2, Types.INTEGER); // id_app
100:                    oStmt.registerOutParameter(3, Types.VARCHAR); // nm_microsite
101:                    oStmt.registerOutParameter(4, Types.VARCHAR); // path_metadata
102:                    oStmt.registerOutParameter(5, Types.CHAR); // gu_workarea
103:
104:                    if (DebugFile.trace)
105:                        DebugFile.writeln("CallableStatement.execute()");
106:
107:                    oStmt.execute();
108:
109:                    sNmMicrosite = oStmt.getString(3);
110:
111:                    bRetVal = (null != sNmMicrosite);
112:
113:                    put(DB.gu_microsite, aPK[0]);
114:
115:                    if (bRetVal) {
116:                        put(DB.id_app, oStmt.getInt(2));
117:                        put(DB.nm_microsite, oStmt.getString(3));
118:                        put(DB.path_metadata, oStmt.getString(4));
119:
120:                        if (oStmt.getObject(5) != null)
121:                            put(DB.gu_workarea, oStmt.getString(5).trim());
122:                    }
123:
124:                    oStmt.close();
125:                } else
126:                    bRetVal = super .load(oConn, aPK);
127:
128:                if (DebugFile.trace) {
129:                    DebugFile.decIdent();
130:                    DebugFile.writeln("End MicrositeDB.load() : "
131:                            + String.valueOf(bRetVal));
132:                }
133:
134:                return bRetVal;
135:            } // load
136:
137:            // ----------------------------------------------------------
138:
139:            public boolean store(JDCConnection oConn) throws SQLException {
140:                java.sql.Timestamp dtNow = new java.sql.Timestamp(DBBind
141:                        .getTime());
142:
143:                if (!AllVals.containsKey(DB.gu_microsite))
144:                    put(DB.gu_microsite, Gadgets.generateUUID());
145:
146:                return super .store(oConn);
147:            }
148:
149:            // ----------------------------------------------------------
150:
151:            public boolean existsFile() {
152:                if (!isNull(DB.path_metadata))
153:                    return new File(getString(DB.path_metadata)).exists();
154:                else
155:                    return false;
156:            } // existsFile
157:
158:            // **********************************************************
159:            // Metodos Estáticos
160:
161:            /**
162:             * <p>Get relative path to XML metadata file</p>
163:             * Relative path is readed from field path_metadata of table k_microsites.<br>
164:             * For example: xslt/templates/Basic.xml<br>
165:             * Slashes or backsclashes are used as file separators depending on the value of
166:             * System.getProperty("file.separator") and independently of what separator is
167:             * used at path_metadata field.
168:             * @param oConn Database Connection
169:             * @param sMicrositeGUID GUID of Microsite witch metadata file relative path is to be retrieved
170:             * @return Relative path to XML metadata file or <b>null</b> if no Microsite with such GUID was found at k_microsites table.
171:             * @throws SQLException
172:             */
173:            public static String filePath(JDCConnection oConn,
174:                    String sMicrositeGUID) throws SQLException {
175:
176:                if (DebugFile.trace) {
177:                    DebugFile
178:                            .writeln("Begin MicrositeDB.filePath([Connection], "
179:                                    + sMicrositeGUID + ")");
180:                    DebugFile.incIdent();
181:                }
182:                PreparedStatement oStmt;
183:                ResultSet oRSet;
184:                String sFilePath;
185:
186:                oStmt = oConn.prepareStatement("SELECT " + DB.path_metadata
187:                        + " FROM " + DB.k_microsites + " WHERE "
188:                        + DB.gu_microsite + "=?", ResultSet.TYPE_FORWARD_ONLY,
189:                        ResultSet.CONCUR_READ_ONLY);
190:                oStmt.setString(1, sMicrositeGUID);
191:                oRSet = oStmt.executeQuery();
192:                if (oRSet.next())
193:                    sFilePath = oRSet.getString(1);
194:                else
195:                    sFilePath = null;
196:                oRSet.close();
197:                oStmt.close();
198:
199:                if (System.getProperty("file.separator").equals("\\")
200:                        && (null != sFilePath))
201:                    sFilePath = sFilePath.replace('/', '\\');
202:
203:                if (DebugFile.trace) {
204:                    DebugFile.decIdent();
205:                    DebugFile.writeln("End MicrositeDB.filePath() : "
206:                            + (sFilePath != null ? sFilePath : "null"));
207:                }
208:                return sFilePath;
209:            } // filePath
210:
211:            // **********************************************************
212:            // * Variables estáticas
213:
214:            public static final short ClassId = 70;
215:
216:            public static short TYPE_XSL = 1;
217:            public static short TYPE_HTML = 2;
218:            public static short TYPE_SURVEY = 4;
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.