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


001:        package com.teamkonzept.field.db.queries;
002:
003:        import com.teamkonzept.db.*;
004:        import com.teamkonzept.webman.mainint.db.queries.field.SelectMaxVersionIdFromContentVersion;
005:        import com.teamkonzept.webman.mainint.db.queries.field.SelectMaxContentIdFromContent;
006:        import com.teamkonzept.webman.mainint.db.queries.field.InsertContentIdContent;
007:        import com.teamkonzept.webman.mainint.db.queries.content.InsertContentVersion;
008:        import com.teamkonzept.webman.mainint.db.queries.field.SelectFromContentVersion;
009:
010:        import java.sql.*;
011:
012:        import org.apache.log4j.Category;
013:
014:        /**
015:         *  @author Markus Freitag
016:         *  @version 1.0
017:         */
018:        public class TKDBContentNew extends TKExtendedPrepQuery {
019:
020:            /** Logging Category */
021:            private static Category cat = Category
022:                    .getInstance(TKDBContentNew.class.getName());
023:            public final static boolean IS_PREPARED = true;
024:            public final static String[] PARAM_ORDER = { "INSTANCE_ID",
025:                    "STATUS_ID", "VERS_INFO", "VERS_AUTHOR" };
026:
027:            public final static Object[][] PARAM_TYPES = {
028:                    { "VERS_INFO", new Integer(Types.VARCHAR) },
029:                    { "VERS_AUTHOR", new Integer(Types.VARCHAR) } };
030:
031:            public final static boolean[] SET_RELEVANTS = { true };
032:
033:            protected static Class[] queryClasses = {
034:                    SelectMaxVersionIdFromContentVersion.class, //[0]
035:                    SelectMaxContentIdFromContent.class, //[1]
036:                    InsertContentIdContent.class, //[2]
037:                    InsertContentVersion.class, //[3]
038:                    SelectFromContentVersion.class //[4]
039:            };
040:
041:            public boolean execute() {
042:
043:                try {
044:                    init(queryClasses); // init query objects
045:
046:                    boolean isNotOpen = aTKDBConnection.isAutoCommit();
047:                    if (isNotOpen) {
048:                        TKDBManager.beginTransaction(); // begin transaction
049:                    }
050:
051:                    ResultSet rs = null;
052:
053:                    // get max(version_id) from content_version
054:                    queries[0].execute();
055:                    rs = queries[0].fetchResultSet();
056:                    int next_version_id = 1;
057:                    if (rs.next()) {
058:                        next_version_id = rs.getInt(1) + 1;
059:                    }
060:                    Integer versionId = new Integer(next_version_id);
061:
062:                    // get max(content_id) from content
063:                    queries[1].execute();
064:                    rs = queries[1].fetchResultSet();
065:                    int next_content_id = 1;
066:                    if (rs.next()) {
067:                        next_content_id = rs.getInt(1) + 1;
068:                    }
069:                    Integer contentId = new Integer(next_content_id);
070:
071:                    // insert into content
072:                    queries[2].setQueryParams("CONT_ID", contentId);
073:                    queries[2].execute();
074:
075:                    // insert into content_version
076:                    //"VERSION_ID", "INSTANCE_ID", "CONTENT_ID", "STATUS_ID", "DATE", "VERS_INFO", "VERS_AUTHOR"
077:                    queries[3].setQueryParams("VERSION_ID", versionId);
078:                    queries[3].setQueryParams("INSTANCE_ID", queryParams
079:                            .get("INSTANCE_ID"));
080:                    queries[3].setQueryParams("CONTENT_ID", contentId);
081:                    queries[3].setQueryParams("STATUS_ID", queryParams
082:                            .get("STATUS_ID"));
083:                    queries[3].setQueryParams("DATE", new Timestamp(System
084:                            .currentTimeMillis()));
085:                    queries[3].setQueryParams("VERS_INFO", queryParams
086:                            .get("VERS_INFO"));
087:                    queries[3].setQueryParams("VERS_AUTHOR", queryParams
088:                            .get("VERS_AUTHOR"));
089:                    queries[3].execute();
090:
091:                    // SELECT CV.*, CI.NAME FROM CONTENT_VERSION CV, CONTENT_INSTANCE CI WHERE CV.VERSION_ID = ? AND CI.INSTANCE_ID = ?
092:                    queries[4].setQueryParams("VERS_ID", versionId);
093:                    queries[4].setQueryParams("INST_ID", queryParams
094:                            .get("INSTANCE_ID"));
095:                    queries[4].execute();
096:                    rs = queries[4].fetchResultSet();
097:                    addResult(rs);
098:
099:                    // COMMIT TRANSACTION
100:                    if (isNotOpen) {
101:                        aTKDBConnection.commitTransaction(); // commit all changes
102:                    }
103:
104:                } catch (Throwable t) {
105:                    cat.error("Error while inserting", t);
106:                    TKDBManager.safeRollbackTransaction(t);
107:                }
108:                return hasResults();
109:            }
110:
111:            public void initQuery(Connection con) {
112:                super.initQuery(con, IS_PREPARED, PARAM_ORDER, PARAM_TYPES,
113:                        SET_RELEVANTS, null);
114:            }
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.