Source Code Cross Referenced for IssueTemplateInfoPeer.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » om » 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 » Issue Tracking » scarab 0.21 » org.tigris.scarab.om 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //  ================================================================
002:        //  Copyright (c) 2000-2005 CollabNet.  All rights reserved.
003:        //  
004:        //  Redistribution and use in source and binary forms, with or without
005:        //  modification, are permitted provided that the following conditions are
006:        //  met:
007:        //  
008:        //  1. Redistributions of source code must retain the above copyright
009:        //  notice, this list of conditions and the following disclaimer.
010:        // 
011:        //  2. Redistributions in binary form must reproduce the above copyright
012:        //  notice, this list of conditions and the following disclaimer in the
013:        //  documentation and/or other materials provided with the distribution.
014:        //  
015:        //  3. The end-user documentation included with the redistribution, if
016:        //  any, must include the following acknowlegement: "This product includes
017:        //  software developed by Collab.Net <http://www.Collab.Net/>."
018:        //  Alternately, this acknowlegement may appear in the software itself, if
019:        //  and wherever such third-party acknowlegements normally appear.
020:        //  
021:        //  4. The hosted project names must not be used to endorse or promote
022:        //  products derived from this software without prior written
023:        //  permission. For written permission, please contact info@collab.net.
024:        //  
025:        //  5. Products derived from this software may not use the "Tigris" or 
026:        //  "Scarab" names nor may "Tigris" or "Scarab" appear in their names without 
027:        //  prior written permission of Collab.Net.
028:        //  
029:        //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
030:        //  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
031:        //  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
032:        //  IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
033:        //  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
034:        //  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
035:        //  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
036:        //  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
037:        //  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
038:        //  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
039:        //  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
040:        // 
041:        //  ====================================================================
042:        //  
043:        //  This software consists of voluntary contributions made by many
044:        //  individuals on behalf of Collab.Net.
045:        package org.tigris.scarab.om;
046:
047:        import java.util.List;
048:        import java.util.Comparator;
049:        import java.util.Collections;
050:        import java.io.Serializable;
051:        import org.apache.torque.TorqueException;
052:        import org.apache.torque.util.Criteria;
053:        import org.tigris.scarab.services.cache.ScarabCache;
054:
055:        // Local classes
056:        import org.tigris.scarab.om.Module;
057:        import org.tigris.scarab.util.ScarabException;
058:
059:        /** 
060:         *  You should add additional methods to this class to meet the
061:         *  application requirements.  This class will only be generated as
062:         *  long as it does not already exist in the output directory.
063:         */
064:        public class IssueTemplateInfoPeer extends BaseIssueTemplateInfoPeer {
065:
066:            private static final String GET_TEMPLATES = "getTemplates";
067:            static final String GET_USER_TEMPLATES = "getUserTemplates";
068:            static final String GET_MODULE_TEMPLATES = "getModuleTemplates";
069:            static final String TEMPLATE_PEER = "IssueTemplateInfoPeer";
070:
071:            // query types
072:            public static final String TYPE_PRIVATE = "private";
073:            public static final String TYPE_GLOBAL = "global";
074:            public static final String TYPE_ALL = "all";
075:
076:            /**
077:             * List of Issue Template objects associated with this module.
078:             * And issue type, either created by current user, or project-scoped.
079:             * i.e., all templates this user has permission to see.
080:             */
081:            public static List getTemplates(Module module, IssueType issueType,
082:                    ScarabUser user, String sortColumn, String sortPolarity,
083:                    String type) throws TorqueException, ScarabException {
084:                List templates = null;
085:                Serializable[] key = { TEMPLATE_PEER, GET_TEMPLATES, module,
086:                        null, issueType, user, sortColumn, sortPolarity, type };
087:                Object obj = ScarabCache.get(key);
088:                if (obj == null) {
089:                    Criteria crit = new Criteria().add(IssuePeer.MODULE_ID,
090:                            module.getModuleId()).add(IssuePeer.DELETED, 0)
091:                            .add(IssuePeer.MOVED, 0).addJoin(
092:                                    ActivitySetPeer.TRANSACTION_ID,
093:                                    ActivityPeer.TRANSACTION_ID).addJoin(
094:                                    IssuePeer.ISSUE_ID, ActivityPeer.ISSUE_ID)
095:                            .add(IssuePeer.TYPE_ID, issueType.getTemplateId())
096:                            .addJoin(IssueTemplateInfoPeer.ISSUE_ID,
097:                                    IssuePeer.ISSUE_ID);
098:                    crit.setDistinct();
099:
100:                    Criteria.Criterion cGlob = crit.getNewCriterion(
101:                            IssueTemplateInfoPeer.SCOPE_ID, Scope.MODULE__PK,
102:                            Criteria.EQUAL);
103:                    cGlob.and(crit.getNewCriterion(
104:                            IssueTemplateInfoPeer.APPROVED, Boolean.TRUE,
105:                            Criteria.EQUAL));
106:                    Criteria.Criterion cPriv = crit.getNewCriterion(
107:                            ActivitySetPeer.CREATED_BY, user.getUserId(),
108:                            Criteria.EQUAL);
109:                    cPriv.and(crit.getNewCriterion(
110:                            IssueTemplateInfoPeer.SCOPE_ID, Scope.PERSONAL__PK,
111:                            Criteria.EQUAL));
112:
113:                    if (TYPE_PRIVATE.equals(type)) {
114:                        crit.add(cPriv);
115:                    } else if (TYPE_GLOBAL.equals(type)) {
116:                        crit.add(cGlob);
117:                    } else {
118:                        // All templates
119:                        cGlob.or(cPriv);
120:                        crit.add(cGlob);
121:                    }
122:
123:                    // Add sort criteria
124:                    if (sortColumn.equals("desc")) {
125:                        addSortOrder(crit, IssueTemplateInfoPeer.DESCRIPTION,
126:                                sortPolarity);
127:                    } else if (sortColumn.equals("avail")) {
128:                        crit.addJoin(IssueTemplateInfoPeer.SCOPE_ID,
129:                                ScopePeer.SCOPE_ID);
130:                        addSortOrder(crit, ScopePeer.SCOPE_NAME, sortPolarity);
131:                    } else if (!sortColumn.equals("user")) {
132:                        // sort by name
133:                        addSortOrder(crit, IssueTemplateInfoPeer.NAME,
134:                                sortPolarity);
135:                    }
136:                    templates = IssueTemplateInfoPeer.doSelect(crit);
137:                    ScarabCache.put(templates, key);
138:                } else {
139:                    templates = (List) obj;
140:                }
141:                if (sortColumn.equals("user")) {
142:                    templates = sortByCreatingUser(templates, sortPolarity);
143:                }
144:                return templates;
145:            }
146:
147:            public static List getUserTemplates(ScarabUser user, Module module,
148:                    IssueType issueType) throws TorqueException,
149:                    ScarabException {
150:                List templates = null;
151:                Object obj = ScarabCache.get(TEMPLATE_PEER, GET_USER_TEMPLATES,
152:                        user);
153:                if (obj == null) {
154:                    Criteria crit = new Criteria().addJoin(
155:                            IssueTemplateInfoPeer.ISSUE_ID, IssuePeer.ISSUE_ID)
156:                            .add(IssuePeer.DELETED, 0).add(IssuePeer.MODULE_ID,
157:                                    module.getModuleId()).addJoin(
158:                                    ActivitySetPeer.TRANSACTION_ID,
159:                                    ActivityPeer.TRANSACTION_ID).addJoin(
160:                                    IssuePeer.ISSUE_ID, ActivityPeer.ISSUE_ID)
161:                            .add(IssuePeer.TYPE_ID, issueType.getTemplateId())
162:                            .add(ActivitySetPeer.CREATED_BY, user.getUserId());
163:                    templates = IssueTemplateInfoPeer.doSelect(crit);
164:                    ScarabCache.put(templates, TEMPLATE_PEER,
165:                            GET_USER_TEMPLATES, user);
166:                } else {
167:                    templates = (List) obj;
168:                }
169:                return templates;
170:            }
171:
172:            public static List getModuleTemplates(Module module)
173:                    throws TorqueException {
174:                List templates = null;
175:                Object obj = ScarabCache.get(TEMPLATE_PEER,
176:                        GET_MODULE_TEMPLATES, module);
177:                if (obj == null) {
178:                    Criteria crit = new Criteria().addJoin(
179:                            IssueTemplateInfoPeer.ISSUE_ID, IssuePeer.ISSUE_ID)
180:                            .add(IssuePeer.DELETED, 0).add(IssuePeer.MODULE_ID,
181:                                    module.getModuleId()).add(
182:                                    IssueTemplateInfoPeer.SCOPE_ID,
183:                                    Scope.MODULE__PK);
184:                    templates = IssueTemplateInfoPeer.doSelect(crit);
185:                    ScarabCache.put(templates, TEMPLATE_PEER,
186:                            GET_USER_TEMPLATES, module);
187:                } else {
188:                    templates = (List) obj;
189:                }
190:                return templates;
191:            }
192:
193:            private static Criteria addSortOrder(Criteria crit,
194:                    String sortColumn, String sortPolarity) {
195:                if (sortPolarity.equals("desc")) {
196:                    crit.addDescendingOrderByColumn(sortColumn);
197:                } else {
198:                    crit.addAscendingOrderByColumn(sortColumn);
199:                }
200:                return crit;
201:            }
202:
203:            private static List sortByCreatingUser(List result,
204:                    String sortPolarity) throws TorqueException {
205:                final int polarity = ("asc".equals(sortPolarity)) ? 1 : -1;
206:                Comparator c = new Comparator() {
207:                    public int compare(Object o1, Object o2) {
208:                        int i = 0;
209:                        try {
210:                            i = polarity
211:                                    * ((Issue) o1).getCreatedBy()
212:                                            .getFirstName().compareTo(
213:                                                    ((Issue) o2).getCreatedBy()
214:                                                            .getFirstName());
215:                        } catch (Exception e) {
216:                            //
217:                        }
218:                        return i;
219:                    }
220:                };
221:                Collections.sort(result, c);
222:                return result;
223:            }
224:
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.