Source Code Cross Referenced for SetValueComputer.java in  » Web-Framework » makumba » org » makumba » list » engine » valuecomputer » 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 » Web Framework » makumba » org.makumba.list.engine.valuecomputer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.makumba.list.engine.valuecomputer;
002:
003:        import java.util.Vector;
004:
005:        import javax.servlet.jsp.JspException;
006:        import javax.servlet.jsp.PageContext;
007:
008:        import org.makumba.FieldDefinition;
009:        import org.makumba.LogicException;
010:        import org.makumba.analyser.AnalysableTag;
011:        import org.makumba.analyser.PageCache;
012:        import org.makumba.commons.MultipleKey;
013:        import org.makumba.commons.attributes.PageAttributes;
014:        import org.makumba.list.engine.ComposedQuery;
015:        import org.makumba.list.engine.QueryExecution;
016:        import org.makumba.list.tags.QueryTag;
017:        import org.makumba.list.tags.ValueTag;
018:
019:        /**
020:         * The manager of a setValueQuery.
021:         * 
022:         * @author Cristian Bogdan
023:         */
024:        public class SetValueComputer extends QueryValueComputer {
025:            /** If we are in a value tag, the name of the queryProjection that computes the title field, otherwise null */
026:            String name = null;
027:
028:            /** If we are in a value tag, the index of the queryProjection that computes the title field, otherwise null */
029:            int nameIndex;
030:
031:            /**
032:             * Makes a query that has an extra FROM: the set requested. As projections, add the key of the set type and, if we
033:             * are in a value tag, the title field.
034:             * 
035:             * @param analyzed
036:             *            the tag that is analyzed
037:             * @param parentListKey
038:             *            the key of the parent list
039:             * @param set
040:             *            the FieldDefinition of the set we want to compute a value of
041:             * @param setExpr
042:             *            the expression of the set
043:             * @param pageCache
044:             *            the page cache of the current page
045:             */
046:            SetValueComputer(AnalysableTag analyzed, MultipleKey parentListKey,
047:                    FieldDefinition set, String setExpr, PageCache pageCache) {
048:                type = set;
049:                String label = setExpr.replace('.', '_');
050:                String queryProps[] = new String[5];
051:                queryProps[ComposedQuery.FROM] = setExpr + " " + label;
052:
053:                if (analyzed instanceof  ValueTag) {
054:                    name = label + "."
055:                            + set.getForeignTable().getTitleFieldName();
056:                    queryProps[ComposedQuery.ORDERBY] = name;
057:                }
058:
059:                makeQueryAtAnalysis(parentListKey, set.getName(), queryProps,
060:                        label, pageCache);
061:
062:                if (analyzed instanceof  ValueTag)
063:                    QueryTag.getQuery(pageCache, queryKey)
064:                            .checkProjectionInteger(name);
065:            }
066:
067:            /**
068:             * Computes nameIndex
069:             * @param pageCache
070:             *            the page cache of the current page
071:             */
072:            @Override
073:            public void doEndAnalyze(PageCache pageCache) {
074:                super .doEndAnalyze(pageCache);
075:                if (name != null)
076:                    nameIndex = QueryTag.getQuery(pageCache, queryKey)
077:                            .checkProjectionInteger(name).intValue();
078:            }
079:
080:            /**
081:             * Goes through the iterationGroupData and returns a vector with the set values. Used only by InputTag
082:             * 
083:             * @param running
084:             *            the tag that is currently running
085:             * @throws LogicException
086:             */
087:            @Override
088:            public Object getValue(PageContext pageContext)
089:                    throws LogicException {
090:                QueryExecution ex = runQuery(pageContext);
091:                int n = ex.dataSize();
092:                Vector v = new Vector();
093:
094:                for (ex.iteration = 0; ex.iteration < n; ex.iteration++)
095:                    v.addElement(ex.currentListData().data[projectionIndex]);
096:                return v;
097:            }
098:
099:            /**
100:             * Goes through the iterationGroupData and prints the set values, comma-separated; also sets var (Vector with the
101:             * set values) and printVar
102:             * 
103:             * @param running
104:             *            the tag that is currently running
105:             * @param pageCache
106:             *            the pageCache of the current page
107:             * @throws JspException
108:             * @throws LogicException
109:             */
110:            @Override
111:            // FIXME (fred) shouldn't the formatting be in view.html package, instead of here?
112:            public void print(ValueTag running, PageCache pageCache)
113:                    throws JspException, LogicException {
114:                QueryExecution ex = runQuery(running.getPageContext());
115:                int n = ex.dataSize();
116:                Vector v = null;
117:
118:                if (running.getVar() != null)
119:                    v = new Vector();
120:
121:                String sep = "";
122:                StringBuffer print = new StringBuffer();
123:                for (ex.iteration = 0; ex.iteration < n; ex.iteration++) {
124:                    print.append(sep);
125:                    sep = ",";
126:                    if (running.getVar() != null)
127:                        v
128:                                .addElement(ex.currentListData().data[projectionIndex]);
129:                    print.append(ex.currentListData().data[nameIndex]);
130:                }
131:                String s = print.toString();
132:
133:                // replace by 'default' or 'empty' if necessary
134:                if (n == 0 && running.getParams().get("default") != null)
135:                    s = (String) running.getParams().get("default");
136:
137:                if (s.length() == 0 && running.getParams().get("empty") != null)
138:                    s = (String) running.getParams().get("empty");
139:
140:                if (running.getVar() != null)
141:                    PageAttributes.setAttribute(running.getPageContext(),
142:                            running.getVar(), v);
143:                if (running.getPrintVar() != null)
144:                    running.getPageContext().setAttribute(
145:                            running.getPrintVar(), s);
146:                if (running.getPrintVar() == null && running.getVar() == null) {
147:                    try {
148:                        running.getPageContext().getOut().print(s);
149:                    } catch (Exception e) {
150:                        throw new JspException(e.toString());
151:                    }
152:                }
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.