Source Code Cross Referenced for QueryInfo.java in  » ERP-CRM-Financial » SourceTap-CRM » com » sourcetap » sfa » util » 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 » ERP CRM Financial » SourceTap CRM » com.sourcetap.sfa.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * 
003:         * Copyright (c) 2004 SourceTap - www.sourcetap.com
004:         *
005:         *  The contents of this file are subject to the SourceTap Public License 
006:         * ("License"); You may not use this file except in compliance with the 
007:         * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008:         * Software distributed under the License is distributed on an  "AS IS"  basis,
009:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010:         * the specific language governing rights and limitations under the License.
011:         *
012:         * The above copyright notice and this permission notice shall be included
013:         * in all copies or substantial portions of the Software.
014:         *
015:         */
016:
017:        package com.sourcetap.sfa.util;
018:
019:        import java.util.ArrayList;
020:        import java.util.HashMap;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import org.ofbiz.base.util.UtilMisc;
026:        import org.ofbiz.entity.GenericDelegator;
027:        import org.ofbiz.entity.GenericEntityException;
028:        import org.ofbiz.entity.condition.EntityComparisonOperator;
029:        import org.ofbiz.entity.condition.EntityCondition;
030:        import org.ofbiz.entity.condition.EntityConditionList;
031:        import org.ofbiz.entity.condition.EntityExpr;
032:        import org.ofbiz.entity.condition.EntityOperator;
033:        import org.ofbiz.entity.model.DynamicViewEntity;
034:        import org.ofbiz.entity.model.ModelKeyMap;
035:        import org.ofbiz.entity.model.ModelViewEntity.ModelMemberEntity;
036:        import org.ofbiz.entity.util.EntityFindOptions;
037:        import org.ofbiz.entity.util.EntityListIterator;
038:
039:        /**
040:         * @author Steve Fowler
041:         *	
042:         *
043:         *
044:         */
045:        public class QueryInfo {
046:            protected String primaryEntityName;
047:            protected Map secondaryEntityNames = new HashMap();
048:            protected Map secondaryAttributes = new HashMap();
049:            protected DynamicViewEntity dve = null;
050:            protected List entityConditions = new ArrayList();
051:            protected List orderBy = null;
052:            protected GenericDelegator delegator;
053:            protected List selectFields = null;
054:            protected String saveResultListId = "";
055:
056:            public QueryInfo(GenericDelegator delegatorIn, String primaryEntity) {
057:                primaryEntityName = primaryEntity;
058:                delegator = delegatorIn;
059:            }
060:
061:            public void addCondition(EntityCondition newCondition) {
062:                entityConditions.add(newCondition);
063:            }
064:
065:            public void addJoin(String firstEntity, String secondEntity,
066:                    Boolean relOptional, String firstField, String secondField) {
067:                addJoin(firstEntity, firstEntity, secondEntity, secondEntity,
068:                        relOptional, firstField, secondField);
069:            }
070:
071:            public void addJoin(String firstEntity, String secondEntity,
072:                    String secondEntityAlias, Boolean relOptional,
073:                    String firstField, String secondField) {
074:                addJoin(firstEntity, firstEntity, secondEntity,
075:                        secondEntityAlias, relOptional, firstField, secondField);
076:            }
077:
078:            public void addJoin(String firstEntity, String firstEntityAlias,
079:                    String secondEntity, String secondEntityAlias,
080:                    Boolean relOptional, String firstField, String secondField) {
081:                addJoin(firstEntity, firstEntity, secondEntity,
082:                        secondEntityAlias, relOptional, firstField, firstField,
083:                        secondField, secondField);
084:            }
085:
086:            public void addJoin(String firstEntity, String firstEntityAlias,
087:                    String secondEntity, String secondEntityAlias,
088:                    Boolean relOptional, String firstField,
089:                    String firstFieldAlias, String secondField,
090:                    String secondFieldAlias) {
091:                checkEntity(firstEntity, firstEntityAlias);
092:                checkEntity(secondEntity, secondEntityAlias);
093:
094:                if (!firstField.equals(firstFieldAlias))
095:                    addAlias(firstEntityAlias, firstField, firstFieldAlias);
096:
097:                if (!secondField.equals(secondFieldAlias))
098:                    addAlias(secondEntityAlias, secondField, secondFieldAlias);
099:
100:                dve.addViewLink(firstEntityAlias, secondEntityAlias,
101:                        relOptional, UtilMisc.toList(new ModelKeyMap(
102:                                firstFieldAlias, secondFieldAlias)));
103:            }
104:
105:            public void addJoin(String firstEntity, String secondEntity,
106:                    Boolean relOptional, List keyMaps) {
107:                addJoin(firstEntity, firstEntity, secondEntity, secondEntity,
108:                        relOptional, keyMaps);
109:            }
110:
111:            public void addJoin(String firstEntity, String firstEntityAlias,
112:                    String secondEntity, String secondEntityAlias,
113:                    Boolean relOptional, List keyMaps) {
114:                checkEntity(firstEntity, firstEntityAlias);
115:                checkEntity(secondEntity, secondEntityAlias);
116:                dve.addViewLink(firstEntityAlias, secondEntityAlias,
117:                        relOptional, keyMaps);
118:            }
119:
120:            public void checkEntity(String entityName, String entityAlias) {
121:                if (!entityName.equals(primaryEntityName)
122:                        && !secondaryEntityNames.containsKey(entityAlias)) {
123:                    if (dve == null) {
124:                        dve = EntityHelper.createDynamicViewEntity(delegator,
125:                                primaryEntityName);
126:                    }
127:                    dve.addMemberEntity(entityAlias, entityName);
128:                    secondaryEntityNames.put(entityAlias, entityName);
129:                }
130:            }
131:
132:            public void checkAttribute(String entityAlias, String attributeName) {
133:                checkAttribute(entityAlias, attributeName, attributeName);
134:            }
135:
136:            public void checkAttribute(String entityAlias,
137:                    String attributeName, String attributeAlias) {
138:                checkEntity(entityAlias, entityAlias);
139:                if (!entityAlias.equals(primaryEntityName)
140:                        && !secondaryAttributes.containsKey(entityAlias + "."
141:                                + attributeAlias)) {
142:                    dve.addAlias(entityAlias, attributeAlias, attributeName,
143:                            null, null, null, null);
144:
145:                    secondaryAttributes.put(entityAlias + "." + attributeAlias,
146:                            attributeName);
147:                }
148:            }
149:
150:            public void addCondition(String entityAlias, String attributeAlias,
151:                    EntityComparisonOperator operator, Object value) {
152:                addCondition(entityAlias, attributeAlias, attributeAlias,
153:                        operator, value);
154:            }
155:
156:            public void addCondition(String entityAlias, String attributeAlias,
157:                    String attributeName, EntityComparisonOperator operator,
158:                    Object value) {
159:                checkAttribute(entityAlias, attributeName, attributeAlias);
160:                entityConditions.add(new EntityExpr(attributeAlias, operator,
161:                        value));
162:            }
163:
164:            public void addAlias(String entityAlias, String attributeName,
165:                    String aliasName) {
166:                checkEntity(entityAlias, entityAlias);
167:                dve.addAlias(entityAlias, aliasName, attributeName, null, null,
168:                        null, null);
169:                secondaryAttributes.put(entityAlias + "." + aliasName,
170:                        attributeName);
171:            }
172:
173:            public List executeQuery() throws GenericEntityException {
174:                if (isDynamic()) {
175:                    return EntityHelper.findByCondition(delegator, dve,
176:                            new EntityConditionList(entityConditions,
177:                                    EntityOperator.AND), orderBy);
178:                } else {
179:                    return delegator.findByCondition(primaryEntityName,
180:                            new EntityConditionList(entityConditions,
181:                                    EntityOperator.AND), null, orderBy);
182:                }
183:            }
184:
185:            public EntityListIterator getQueryIterator()
186:                    throws GenericEntityException {
187:                if (isDynamic()) {
188:                    return EntityHelper.findIteratorByCondition(delegator, dve,
189:                            new EntityConditionList(entityConditions,
190:                                    EntityOperator.AND), selectFields, orderBy);
191:                } else {
192:                    return delegator.findListIteratorByCondition(
193:                            primaryEntityName, new EntityConditionList(
194:                                    entityConditions, EntityOperator.AND),
195:                            null, selectFields, orderBy, new EntityFindOptions(
196:                                    true,
197:                                    EntityFindOptions.TYPE_SCROLL_INSENSITIVE,
198:                                    EntityFindOptions.CONCUR_READ_ONLY, true));
199:                }
200:            }
201:
202:            public EntityConditionList getEntityConditions() {
203:                return new EntityConditionList(entityConditions,
204:                        EntityOperator.AND);
205:            }
206:
207:            public boolean isDynamic() {
208:                return (dve != null);
209:            }
210:
211:            public DynamicViewEntity getDynamicViewEntity() {
212:                return dve;
213:            }
214:
215:            public String getPrimaryEntity() {
216:                return primaryEntityName;
217:            }
218:
219:            public GenericDelegator getDelegator() {
220:                return delegator;
221:            }
222:
223:            public void setOrderBy(List orderBy_) {
224:                orderBy = orderBy_;
225:            }
226:
227:            public List getOrderBy() {
228:                return orderBy;
229:            }
230:
231:            public List getEntities() {
232:                if (dve == null)
233:                    return UtilMisc.toList(primaryEntityName);
234:
235:                ArrayList entityList = new ArrayList();
236:                Iterator listIter = dve.getModelMemberEntitiesEntryIter();
237:                while (listIter.hasNext()) {
238:                    Map.Entry entry = (Map.Entry) listIter.next();
239:
240:                    ModelMemberEntity modelMemberEntity = (ModelMemberEntity) entry
241:                            .getValue();
242:                    entityList.add(modelMemberEntity.getEntityName());
243:                }
244:
245:                return entityList;
246:            }
247:
248:            public List getSelectFields() {
249:                return selectFields;
250:            }
251:
252:            public void setSelectFields(List fieldsToSelect) {
253:                selectFields = fieldsToSelect;
254:            }
255:
256:            public void addSelectFields(String fieldName) {
257:                if (selectFields == null)
258:                    selectFields = new ArrayList();
259:
260:                selectFields.add(fieldName);
261:            }
262:
263:            /**
264:             * @return Returns the saveResultListId.
265:             */
266:            public String getSaveResultListId() {
267:                return saveResultListId;
268:            }
269:
270:            /**
271:             * @param saveResultListName The saveResultListId to set.
272:             */
273:            public void setSaveResultListId(String saveResultListId) {
274:                this.saveResultListId = saveResultListId;
275:            }
276:
277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.