Source Code Cross Referenced for TKContentValueTableData.java in  » Content-Management-System » webman » com » teamkonzept » field » 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 » Content Management System » webman » com.teamkonzept.field.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.teamkonzept.field.db;
002:
003:        import com.teamkonzept.db.*;
004:        import de.webman.util.legacy.Legacy;
005:
006:        import java.sql.*;
007:
008:        /**
009:         * Reads/writes content from/to the database (table CONTENT_VALUE).
010:         * Note, that it is distinguished between oracle/sybase (clob behavior) and
011:         * webman 1.2/greater than 1.2 (empty string behavior), respectively, at certain points.
012:         *
013:         * @author $Author: ralf $
014:         * @version $Revision: 1.12 $
015:         */
016:        public class TKContentValueTableData extends TKDBTableData {
017:
018:            /**
019:             * content_id
020:             */
021:            public int content_id;
022:
023:            /**
024:             * content_node_id
025:             */
026:            public int content_node_id;
027:            public int idx;
028:            public String value;
029:            public Integer mediaID;
030:
031:            public TKContentValueTableData() {
032:            }
033:
034:            public TKContentValueTableData(int content_id, int content_node_id,
035:                    int idx, String value) {
036:                this (content_id, content_node_id, idx, value, null);
037:            }
038:
039:            public TKContentValueTableData(int content_id, int content_node_id,
040:                    int idx, String value, Integer mediaID) {
041:                this .content_id = content_id;
042:                this .content_node_id = content_node_id;
043:                this .idx = idx;
044:                this .value = value;
045:                this .mediaID = mediaID;
046:            }
047:
048:            public TKContentValueTableData(ResultSet r) throws SQLException {
049:                this .content_id = r.getInt("CONTENT_ID");
050:                this .content_node_id = r.getInt("CONTENT_NODE_ID");
051:                this .idx = r.getInt("IDX");
052:
053:                // NOTE: the current jdbc driver for sybase does not implement the
054:                //       jdbc 2.0 specification. we distinguish between oracle and
055:                //       other database vendors at the point.
056:                // TO BE FIXED SOON
057:                if (TKDBManager.getDBVendor() == QueryConstants.ORACLE) {
058:                    Clob clob = r.getClob("VALUE"); // see comments below!
059:                    if (clob != null) {
060:                        this .value = clob.getSubString(1, (int) clob.length());
061:                    }
062:                } else {
063:                    this .value = r.getString("VALUE");
064:                }
065:                //if( this.value.equals(" ") ) this.value = "";
066:                // BUGFIX: leere Strings in TEXT-Spalten werden als String mit einem Leerzeichen abgelegt!
067:                // ...yes and Oracle does not allow to insert empty strings if the column is restricted to
068:                // "not null" values (this applies to VARCHAR as well as CLOB (Sybase: TEXT)). -ralf
069:                // There is another problem with "value": column VALUE is definded as CLOB and, at least,
070:                // Oracle's JDBC driver returns null if ResultSet.getString("VALUE") is called. Solution:
071:                // call ResultSet.getClob("VALUE") and convert it to a string object.
072:                // It looks like as if this works with Sybase as well. -ralf
073:                if (Legacy.getInstance().isEmptyStringEnabled()) {
074:                    if (this .value == null || this .value.equals(" ")) {
075:                        this .value = ""; // see comments above!
076:                    }
077:                } else {
078:                    if (this .value == null
079:                            || this .value
080:                                    .equals(QueryConstants.EMPTY_STRING_VALUE)) {
081:                        this .value = ""; // see comments above!
082:                    }
083:                }
084:
085:                int id = r.getInt(MEDIA_ID);
086:                if (!r.wasNull()) {
087:                    this .mediaID = new Integer(id);
088:                }
089:
090:            }
091:
092:            public void updatePrimary(TKDBVectorData dbData) {
093:
094:                TKContentDBData cdata = (TKContentDBData) dbData;
095:                content_id = cdata.content_id;
096:            }
097:
098:            public void insertIntoQuery(TKQuery query) throws SQLException {
099:                query.setQueryParams("CONTENT_ID", new Integer(content_id));
100:                query.setQueryParams("CONTENT_NODE_ID", new Integer(
101:                        content_node_id));
102:                query.setQueryParams("IDX", new Integer(idx));
103:                //    if (value != null) {  // -ralf
104:                //	  query.setQueryParams("VALUE", value);
105:                // NOTE: value "can't" be null (that is, value is obviously *expected* to differ
106:                // from null), otherwise the database would report a contraint violation because
107:                // column "VALUE" is restricted to "not null"-values (see table CONTENT_VALUE).
108:                // Also note, that Oracle supports neither null-values (as expected), nor string
109:                // objects of length 0 (empty string) to be inserted into a "not null" restricted
110:                // column of type clob (sybase: text) and varchar, respectively!
111:                // The solution to this problem is - at this moment - to insert a string
112:                // consisting of exactly one blank or changing the definition of the particular
113:                // table.
114:                if (Legacy.getInstance().isEmptyStringEnabled()) {
115:                    query.setQueryParams("VALUE", (value.length() == 0 ? " "
116:                            : value)); // -ralf
117:                } else {
118:                    query
119:                            .setQueryParams(
120:                                    "VALUE",
121:                                    (value.length() == 0 ? QueryConstants.EMPTY_STRING_VALUE
122:                                            : value)); // -ralf
123:                }
124:                //    }
125:                query.setQueryParams(MEDIA_ID, mediaID);
126:            }
127:
128:            public TKDBTableData newFromResultSet(ResultSet r)
129:                    throws SQLException {
130:                return new TKContentValueTableData(r);
131:            }
132:
133:            public String toString() {
134:                return "( CONTENT_ID=" + String.valueOf(content_id)
135:                        + ", CONTENT_NODE_ID="
136:                        + String.valueOf(content_node_id) + ", IDX="
137:                        + String.valueOf(idx) + ", VALUE=" + value
138:                        + ", MEDIA_ID=" + mediaID + ")<BR>";
139:            }
140:
141:            //{{DECLARE_CONTROLS
142:            //}}
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.