Source Code Cross Referenced for DomainContext.java in  » Project-Management » XPlanner-0.7b7 » com » technoetic » xplanner » tags » 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 » Project Management » XPlanner 0.7b7 » com.technoetic.xplanner.tags 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.technoetic.xplanner.tags;
002:
003:        import com.technoetic.xplanner.db.hibernate.ThreadSession;
004:        import com.technoetic.xplanner.db.IdSearchHelper;
005:        import com.technoetic.xplanner.domain.*;
006:        import net.sf.hibernate.Hibernate;
007:        import net.sf.hibernate.Session;
008:        import net.sf.hibernate.HibernateException;
009:
010:        import javax.servlet.ServletRequest;
011:        import java.util.List;
012:
013:        import org.apache.struts.action.ActionMapping;
014:
015:        // todo - Get rid of this once we have a true object model with relationships
016:
017:        public class DomainContext {
018:            public static final String REQUEST_KEY = "domainContext";
019:
020:            private String projectName;
021:            private int projectId;
022:            private String iterationName;
023:            private int iterationId;
024:            private String storyName;
025:            private int storyId;
026:            private String taskName;
027:            private int taskId;
028:            private String featureName;
029:            private int featureId;
030:            private Object targetObject;
031:            private ActionMapping actionMapping;
032:            public static IdSearchHelper idSearchHelper = new IdSearchHelper();
033:
034:            public ActionMapping getActionMapping() {
035:                return actionMapping;
036:            }
037:
038:            public void setActionMapping(ActionMapping actionMapping) {
039:                this .actionMapping = actionMapping;
040:            }
041:
042:            public String getProjectName() {
043:                return projectName;
044:            }
045:
046:            public void setProjectName(String projectName) {
047:                this .projectName = projectName;
048:            }
049:
050:            public int getProjectId() {
051:                return projectId;
052:            }
053:
054:            public void setProjectId(int projectId) {
055:                this .projectId = projectId;
056:            }
057:
058:            public String getIterationName() {
059:                return iterationName;
060:            }
061:
062:            public void setIterationName(String iterationName) {
063:                this .iterationName = iterationName;
064:            }
065:
066:            public int getIterationId() {
067:                return iterationId;
068:            }
069:
070:            public void setIterationId(int iterationId) {
071:                this .iterationId = iterationId;
072:            }
073:
074:            public String getStoryName() {
075:                return storyName;
076:            }
077:
078:            public void setStoryName(String storyName) {
079:                this .storyName = storyName;
080:            }
081:
082:            public int getStoryId() {
083:                return storyId;
084:            }
085:
086:            public void setStoryId(int storyId) {
087:                this .storyId = storyId;
088:            }
089:
090:            public String getTaskName() {
091:                return taskName;
092:            }
093:
094:            public void setTaskName(String taskName) {
095:                this .taskName = taskName;
096:            }
097:
098:            public int getTaskId() {
099:                return taskId;
100:            }
101:
102:            public String getFeatureName() {
103:                return featureName;
104:            }
105:
106:            public void setFeatureName(String featureName) {
107:                this .featureName = featureName;
108:            }
109:
110:            public int getFeatureId() {
111:                return featureId;
112:            }
113:
114:            public void setFeatureId(int featureId) {
115:                this .featureId = featureId;
116:            }
117:
118:            public void setTaskId(int taskId) {
119:                this .taskId = taskId;
120:            }
121:
122:            public Object getTargetObject() {
123:                return targetObject;
124:            }
125:
126:            public void populate(Object object) throws Exception {
127:                Session session = ThreadSession.get();
128:                targetObject = object;
129:                if (object instanceof  Project) {
130:                    populate((Project) object);
131:                } else if (object instanceof  Iteration) {
132:                    populate(session, (Iteration) object);
133:                } else if (object instanceof  UserStory) {
134:                    populate(session, (UserStory) object);
135:                } else if (object instanceof  Task) {
136:                    populate(session, (Task) object);
137:                } else if (object instanceof  Feature) {
138:                    populate(session, (Feature) object);
139:                } else if (object instanceof  Note) {
140:                    populate((Note) object);
141:                } else if (object instanceof  TimeEntry) {
142:                    populate(session, (TimeEntry) object);
143:                }
144:            }
145:
146:            private void populate(Project project) throws Exception {
147:                setProjectName(project.getName());
148:                setProjectId(project.getId());
149:            }
150:
151:            private void populate(Session session, Iteration iteration)
152:                    throws Exception {
153:                Project project = (Project) session.load(Project.class,
154:                        new Integer(iteration.getProjectId()));
155:                populate(project);
156:                setIterationName(iteration.getName());
157:                setIterationId(iteration.getId());
158:            }
159:
160:            private void populate(Session session, UserStory story)
161:                    throws Exception {
162:                List results = session
163:                        .find(
164:                                "select p.name, p.id, i.name, i.id from "
165:                                        + "from p in class com.technoetic.xplanner.domain.Project, "
166:                                        + "i in class com.technoetic.xplanner.domain.Iteration, "
167:                                        + "s in class com.technoetic.xplanner.domain.UserStory "
168:                                        + "where s.id = ? and  s.iterationId = i.id and i.projectId = p.id",
169:                                new Integer(story.getId()), Hibernate.INTEGER);
170:                if (results.size() > 0) {
171:                    Object[] result = (Object[]) results.iterator().next();
172:                    setProjectName((String) result[0]);
173:                    setProjectId(((Integer) result[1]).intValue());
174:                    setIterationName((String) result[2]);
175:                    setIterationId(((Integer) result[3]).intValue());
176:                }
177:                setStoryName(story.getName());
178:                setStoryId(story.getId());
179:            }
180:
181:            private void populate(Session session, Task task) throws Exception {
182:                List results = session
183:                        .find(
184:                                "select p.name, p.id, i.name, i.id, s.name, s.id "
185:                                        + "from p in class com.technoetic.xplanner.domain.Project, "
186:                                        + "i in class com.technoetic.xplanner.domain.Iteration, "
187:                                        + "s in class com.technoetic.xplanner.domain.UserStory, "
188:                                        + "t in class com.technoetic.xplanner.domain.Task "
189:                                        + "where t.id = ? and t.story.id = s.id and s.iterationId = i.id and i.projectId = p.id",
190:                                new Integer(task.getId()), Hibernate.INTEGER);
191:                if (results.size() > 0) {
192:                    Object[] result = (Object[]) results.iterator().next();
193:                    setProjectName((String) result[0]);
194:                    setProjectId(((Integer) result[1]).intValue());
195:                    setIterationName((String) result[2]);
196:                    setIterationId(((Integer) result[3]).intValue());
197:                    setStoryName((String) result[4]);
198:                    setStoryId(((Integer) result[5]).intValue());
199:                }
200:                setTaskName(task.getName());
201:                setTaskId(task.getId());
202:            }
203:
204:            private void populate(Session session, TimeEntry timeEntry)
205:                    throws Exception {
206:                List results = session
207:                        .find(
208:                                "select p.name, p.id, i.name, i.id, s.name, s.id, t.name "
209:                                        + "from p in class com.technoetic.xplanner.domain.Project, "
210:                                        + "i in class com.technoetic.xplanner.domain.Iteration, "
211:                                        + "s in class com.technoetic.xplanner.domain.UserStory, "
212:                                        + "t in class com.technoetic.xplanner.domain.Task "
213:                                        + "where t.id = ? and t.story.id = s.id and s.iterationId = i.id and i.projectId = p.id",
214:                                new Integer(timeEntry.getTaskId()),
215:                                Hibernate.INTEGER);
216:                if (results.size() > 0) {
217:                    Object[] result = (Object[]) results.iterator().next();
218:                    setProjectName((String) result[0]);
219:                    setProjectId(((Integer) result[1]).intValue());
220:                    setIterationName((String) result[2]);
221:                    setIterationId(((Integer) result[3]).intValue());
222:                    setStoryName((String) result[4]);
223:                    setStoryId(((Integer) result[5]).intValue());
224:                    setTaskName(((String) result[6]));
225:                }
226:                setTaskId(timeEntry.getId());
227:            }
228:
229:            private void populate(Session session, Feature feature)
230:                    throws Exception {
231:                List results = session
232:                        .find(
233:                                "select p.name, p.id, i.name, i.id, s.name, s.id "
234:                                        + "from p in class com.technoetic.xplanner.domain.Project, "
235:                                        + "i in class com.technoetic.xplanner.domain.Iteration, "
236:                                        + "s in class com.technoetic.xplanner.domain.UserStory, "
237:                                        + "f in class com.technoetic.xplanner.domain.Feature "
238:                                        + "where f.id = ? and f.story.id = s.id and s.iterationId = i.id and i.projectId = p.id",
239:                                new Integer(feature.getId()), Hibernate.INTEGER);
240:                if (results.size() > 0) {
241:                    Object[] result = (Object[]) results.iterator().next();
242:                    setProjectName((String) result[0]);
243:                    setProjectId(((Integer) result[1]).intValue());
244:                    setIterationName((String) result[2]);
245:                    setIterationId(((Integer) result[3]).intValue());
246:                    setStoryName((String) result[4]);
247:                    setStoryId(((Integer) result[5]).intValue());
248:                }
249:                setFeatureName(feature.getName());
250:                setFeatureId(feature.getId());
251:            }
252:
253:            private void populate(Note note) throws Exception {
254:                populate(getNoteTarget(note.getAttachedToId()));
255:            }
256:
257:            public static DomainObject getNoteTarget(int attachedToId) {
258:                try {
259:                    return idSearchHelper.search(attachedToId);
260:                } catch (HibernateException e) {
261:                    return null;
262:                }
263:            }
264:
265:            public void save(ServletRequest request) {
266:                request.setAttribute(REQUEST_KEY, this );
267:            }
268:
269:            public static DomainContext get(ServletRequest request) {
270:                return (DomainContext) request.getAttribute(REQUEST_KEY);
271:            }
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.