Source Code Cross Referenced for CEContentAttributesHandler.java in  » Content-Management-System » webman » de » webman » content » eventhandler » 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 » de.webman.content.eventhandler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.webman.content.eventhandler;
002:
003:        import com.teamkonzept.web.*;
004:        import com.teamkonzept.webman.*;
005:        import com.teamkonzept.webman.db.TKWebmanDBManager;
006:        import com.teamkonzept.webman.mainint.*;
007:        import com.teamkonzept.webman.mainint.db.*;
008:        import com.teamkonzept.webman.mainint.db.queries.*;
009:        import com.teamkonzept.webman.mainint.events.*;
010:        import com.teamkonzept.lib.*;
011:        import com.teamkonzept.field.*;
012:        import com.teamkonzept.field.db.*;
013:        import de.webman.content.db.queries.*;
014:        import com.teamkonzept.db.*;
015:        import com.teamkonzept.publishing.markups.*;
016:        import de.webman.content.workflow.*;
017:
018:        import java.sql.*;
019:        import java.io.*;
020:
021:        /**
022:         * Auflisten aller Attribute eines Contents:
023:         *
024:         * @author  $Author: sebastian $
025:         * @version $Revision: 1.10 $
026:         */
027:        public class CEContentAttributesHandler extends DefaultEventHandler
028:                implements  ParameterTypes, FrameConstants, DatabaseDefaults {
029:            private CEContentAttributesHandler() {
030:            }
031:
032:            private static CEContentAttributesHandler instance = new CEContentAttributesHandler();
033:
034:            public static CEContentAttributesHandler getInstance() {
035:                return instance;
036:            }
037:
038:            private static String getAttributeValue(TKEvent evt, int pos) {
039:                String help = "ATTRIBUTES." + Integer.toString(pos);
040:                if (Integer.parseInt(evt
041:                        .getParameter(PARAMETER, help + ".TYPE")) == 3) {
042:                    String back;
043:
044:                    back = evt.getParameter(PARAMETER, help + ".DAY");
045:                    back = back + '.'
046:                            + evt.getParameter(PARAMETER, help + ".MONTH");
047:                    back = back + '.'
048:                            + evt.getParameter(PARAMETER, help + ".YEAR");
049:                    back = back + ' '
050:                            + evt.getParameter(PARAMETER, help + ".HOUR");
051:                    back = back + ':'
052:                            + evt.getParameter(PARAMETER, help + ".MINUTE");
053:                    back = back + ":00";
054:
055:                    return back;
056:                } else
057:                    return evt.getParameter(PARAMETER, help
058:                            + ".ATTRIBUTE_VALUE");
059:            }
060:
061:            public void handleEvent(TKEvent evt) throws TKException {
062:                try {
063:
064:                    CEUtils.checkEvent(evt);
065:
066:                    TKHTMLTemplate t = evt
067:                            .getPrepHTMLTemplate("ce_conAttrList.tmpl");
068:
069:                    ContentContext ceContext = new ContentContext(evt
070:                            .getParams(), evt.toString());
071:
072:                    if (ceContext.instanceId == null)
073:                        throw new Exception(
074:                                "doCEContentAttributes: No Content Instance");
075:
076:                    String event = evt.getName();
077:                    String action = event == null ? null : evt.getParameter(
078:                            ACTION, event);
079:
080:                    TKContentDBData cdata = new TKContentDBData(
081:                            ceContext.instanceId.intValue(),
082:                            ceContext.versionId.intValue());
083:                    TKContentDBInterface.Get(cdata);
084:
085:                    if (action == null || action.length() == 0
086:                            || action.equalsIgnoreCase("GET")) {
087:                        t.setListIterator(new TKContentIterator(t, cdata, t
088:                                .getListIterator()));
089:                        ceContext.fillIntoTemplate(t);
090:
091:                        evt.finishTemplate(t);
092:                        return;
093:                    }
094:
095:                    if (action.equalsIgnoreCase("SAVE")
096:                            || action.equalsIgnoreCase("NEW_ATTR")
097:                            || action.equalsIgnoreCase("DELETE_ATTRIBUTE")
098:                            || action.equalsIgnoreCase("SAVE_AND_CLOSE")) {
099:                        // packe neue Contentattribute in cdata
100:                        int i = 0;
101:                        while (cdata.content_attribute != null
102:                                && cdata.content_attribute.size() > i) {
103:
104:                            TKContentAttributeTableData table = (TKContentAttributeTableData) cdata.content_attribute
105:                                    .elementAt(i);
106:                            int r;
107:                            for (r = 0; r < cdata.content_attribute.size(); r++) {
108:                                if (Integer.parseInt(evt.getParameter(
109:                                        PARAMETER, "ATTRIBUTES."
110:                                                + Integer.toString(r)
111:                                                + ".VALUE_ID")) == table.value_id)
112:                                    break;
113:                            }
114:
115:                            String value = getAttributeValue(evt, r);
116:
117:                            if (!(table.value.equals(value))) {
118:                                table.value = value;
119:
120:                                TKQuery q = TKDBManager
121:                                        .newQuery(TKDBContentAttributeUpdate.class);
122:                                table.insertIntoQuery(q);
123:                                q.execute();
124:                            }
125:                            i++;
126:                        }
127:                    }
128:
129:                    if (action.equalsIgnoreCase("DELETE_ATTRIBUTE")) {
130:                        TKQuery q = TKDBManager
131:                                .newQuery(TKDBContentAttributeDelete.class);
132:                        q.setQueryParams("VALUE_ID", new Integer(Integer
133:                                .parseInt(evt.getParameter("VALUE_ID", evt
134:                                        .getName()))));
135:                        q.execute();
136:
137:                        for (int i = 0; i < cdata.content_attribute.size(); i++) {
138:                            if (((TKContentAttributeTableData) cdata.content_attribute
139:                                    .elementAt(i)).value_id == Integer
140:                                    .parseInt(evt.getParameter("VALUE_ID", evt
141:                                            .getName()))) {
142:                                cdata.content_attribute.remove(i);
143:                                break;
144:                            }
145:                        }
146:
147:                        t.setListIterator(new TKContentIterator(t, cdata, t
148:                                .getListIterator()));
149:                        ceContext.fillIntoTemplate(t);
150:
151:                        evt.finishTemplate(t);
152:                        return;
153:
154:                    }
155:                    if (action.equalsIgnoreCase("NEW_ATTR")) {
156:                        String new_attr_id = evt.getParameter(PARAMETER,
157:                                "NEW_ATTRIBUTE_ID");
158:                        System.out.println("new_attr_id : " + new_attr_id);
159:                        if (new_attr_id != null && new_attr_id.length() != 0
160:                                && Integer.parseInt(new_attr_id) != -1) {
161:                            // erzeuge neues attributtable
162:                            TKContentAttributeTableData table = new TKContentAttributeTableData(
163:                                    cdata.content_id, Integer
164:                                            .parseInt(new_attr_id), "");
165:
166:                            TKQuery q = TKDBManager
167:                                    .newQuery(TKDBContentAttributePut.class);
168:                            table.insertIntoQuery(q);
169:                            q.execute();
170:                            if (cdata.content_attribute == null)
171:                                cdata.content_attribute = new TKVector();
172:                            ResultSet rs = q.fetchResultSet();
173:                            rs.next();
174:                            cdata.content_attribute
175:                                    .add(new TKContentAttributeTableData(rs));
176:
177:                            t.setListIterator(new TKContentIterator(t, cdata, t
178:                                    .getListIterator()));
179:                            ceContext.fillIntoTemplate(t);
180:
181:                            evt.finishTemplate(t);
182:                            return;
183:
184:                        } else {
185:                            throw new TKUserException(
186:                                    "Please chose an attribute-type first.",
187:                                    UserCodes.CHOSE_CONTENT_ATTRIBUTE,
188:                                    ErrorCodes.USER_SEVERITY, true, null);
189:                        }
190:                    }
191:                    if (action.equalsIgnoreCase("SAVE_AND_CLOSE")
192:                            || action.equalsIgnoreCase("CLOSE")) {
193:                        CEBrowseHandler.getInstance().handleEvent(evt);
194:                        return;
195:                    }
196:
197:                    t.setListIterator(new TKContentIterator(t, cdata, t
198:                            .getListIterator()));
199:                    ceContext.fillIntoTemplate(t);
200:
201:                    evt.finishTemplate(t);
202:                } catch (Throwable e) {
203:                    // TO DO : Analyze Exception !
204:                    throw WebmanExceptionHandler.getException(e);
205:                }
206:            }
207:
208:            public boolean isHandler(TKEvent evt) {
209:                return evt.getName().equalsIgnoreCase("CE_CONTENT_ATTRIBUTES");
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.