Source Code Cross Referenced for MilestoneController.java in  » Project-Management » EmForce » org » emforge » projectmanager » web » bean » 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 » EmForce » org.emforge.projectmanager.web.bean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.emforge.projectmanager.web.bean;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.GregorianCalendar;
006:        import java.util.LinkedList;
007:        import java.util.List;
008:        import java.util.TimeZone;
009:
010:        import org.apache.commons.lang.StringUtils;
011:        import org.apache.commons.logging.Log;
012:        import org.apache.commons.logging.LogFactory;
013:        import org.emforge.BpmService;
014:        import org.emforge.CommentService;
015:        import org.emforge.EmForgeException;
016:        import org.emforge.projectmanager.ProjectService;
017:        import org.emforge.projectmanager.base.MilestoneDO;
018:        import org.emforge.projectmanager.base.ProjectDO;
019:        import org.emforge.xfer.CommentTO;
020:        import org.emforge.xfer.TaskStatus;
021:        import org.emforge.xfer.TaskTO;
022:        import org.emforge.projectmanager.web.bean.MilestoneController;
023:        import org.emforge.projectmanager.web.bean.ProjectController;
024:
025:        import ru.emdev.EmForge.web.bean.BaseControllerImpl;
026:        import ru.emdev.EmForge.web.bean.EditTextController;
027:        import ru.emdev.EmForge.web.bean.MainMenuController.MainMenuItem;
028:        import ru.emdev.EmForge.wiki.web.bean.Crumb;
029:
030:        import com.ecyrd.jspwiki.WikiContext;
031:        import com.ecyrd.jspwiki.WikiPage;
032:        import com.ecyrd.jspwiki.attachment.Attachment;
033:        import com.ecyrd.jspwiki.parser.MarkupParser;
034:        import com.ecyrd.jspwiki.providers.ProviderException;
035:
036:        public class MilestoneController extends BaseControllerImpl {
037:            public static final String MILESTONE_PAGE_NAME = "milestone";
038:            public static final String MILESTONE_ID_ATTR = "id";
039:            public static final String MILESTONE_PROJECT_ATTR = "project";
040:            public static final String MILESTONE_PAGE_ATTR = "page";
041:
042:            protected final Log logger = LogFactory.getLog(getClass());
043:
044:            ProjectService m_projectService;
045:
046:            MilestoneDO m_milestone;
047:
048:            boolean m_isNewMilestone = false;
049:
050:            Integer m_openedTasksCount;
051:            List<TaskTO> m_openedTasks;
052:            Integer m_closedTasksCount;
053:            List<TaskTO> m_closedTasks;
054:
055:            boolean m_isShowSubprocesses = false;
056:
057:            BpmService m_bpmService;
058:
059:            CommentService m_commentService;
060:            EditTextController m_editTextController;
061:
062:            public void setProjectService(ProjectService i_projectService) {
063:                m_projectService = i_projectService;
064:            }
065:
066:            public void setBpmService(BpmService i_bpmService) {
067:                m_bpmService = i_bpmService;
068:            }
069:
070:            public void setCommentService(CommentService i_commentService) {
071:                m_commentService = i_commentService;
072:            }
073:
074:            public void setEditTextController(
075:                    EditTextController i_editTextController) {
076:                m_editTextController = i_editTextController;
077:            }
078:
079:            @Override
080:            public MainMenuItem getSelectionItemOnMainMenu() {
081:                return MainMenuItem.PROJECTS;
082:            }
083:
084:            public String getTitleImpl() {
085:                if (m_isNewMilestone) {
086:                    return "Create New Milestone";
087:                } else {
088:                    return "Milestone: " + m_milestone.getDisplayName();
089:                }
090:            }
091:
092:            public String getDialogTitle() {
093:                if (m_isNewMilestone) {
094:                    return "New Milestone Settings";
095:                } else {
096:                    return "Milestone " + m_milestone.getDisplayName()
097:                            + " settings";
098:                }
099:            }
100:
101:            @Override
102:            public Crumb getTrailCrumbInfo() {
103:                if (m_milestone == null) {
104:                    return null;
105:                }
106:
107:                String displayName = m_milestone.getName();
108:                String url = getUrl();
109:
110:                return new Crumb(displayName, url);
111:            }
112:
113:            @Override
114:            protected void init() {
115:
116:                if (m_appContext != null && m_projectService != null) {
117:                    //get milestone by id
118:                    // moved initialization here - so, hibernate session is available
119:                    // get id
120:                    String idStr = getParam(MILESTONE_ID_ATTR);
121:                    String wikiName = null;
122:
123:                    if (StringUtils.isNotEmpty(idStr)) {
124:                        try {
125:                            long id = Long.valueOf(idStr).longValue();
126:
127:                            m_milestone = m_projectService.getMilestone(id);
128:                        } catch (Exception ex) {
129:                            // just ignore it here
130:                        }
131:                    }
132:
133:                    if (m_milestone != null) {
134:                        wikiName = m_milestone.getName();
135:                    } else if (StringUtils
136:                            .isNotEmpty(getParam(MILESTONE_PAGE_ATTR))) {
137:                        wikiName = getParam(MILESTONE_PAGE_ATTR);
138:                        m_milestone = m_projectService.getMilestone(wikiName);
139:
140:                    } else {
141:                        String projectName = getParam(MILESTONE_PROJECT_ATTR);
142:                        if (StringUtils.isNotEmpty(projectName)) {
143:                            m_milestone = new MilestoneDO();
144:                            m_isNewMilestone = true;
145:
146:                            ProjectDO project = m_projectService
147:                                    .getProject(projectName);
148:
149:                            m_milestone.setProject(project);
150:                        }
151:                    }
152:                }
153:            }
154:
155:            /** This action is used for new milestone dialog
156:             * to automatically generate unique milestoneName from milestone Display Name
157:             * 
158:             * @return
159:             */
160:            public String changeMilestoneName() {
161:                if (isNewMilestone()) {
162:                    // this is used only for new milestones
163:                    String displayName = getMilestone().getDisplayName();
164:                    String name = MarkupParser.cleanLink(displayName);
165:                    String milestoneName = name;
166:                    int i = 0;
167:                    // now, check - name should be unique
168:                    while (m_projectService.getMilestone(milestoneName) != null) {
169:                        i++;
170:                        milestoneName = name + i;
171:                    }
172:
173:                    getMilestone().setName(milestoneName);
174:                }
175:
176:                return null;
177:            }
178:
179:            /** Gets processed milestone
180:             * 
181:             * @return
182:             */
183:            public MilestoneDO getMilestone() {
184:                return m_milestone;
185:            }
186:
187:            /**
188:             * 
189:             * @deprecated I do not know why it is here!
190:             * @return
191:             */
192:            public TimeZone getTimeZone() {
193:                return new GregorianCalendar().getTimeZone();
194:            }
195:
196:            /** Save new milestone data
197:             * 
198:             * @return
199:             */
200:            public String save() {
201:                assert m_milestone != null;
202:
203:                Boolean wasNew = isNewMilestone();
204:
205:                m_projectService.saveMilestone(m_milestone);
206:
207:                if (wasNew) {
208:                    addInfoMessage("New Milestone Created", null);
209:                } else {
210:                    addInfoMessage("Milestone Changes Saved", null);
211:                }
212:
213:                m_isNewMilestone = false;
214:
215:                // navigate to edit window - if it was new project
216:                if (wasNew) {
217:                    redirect("edit/" + m_milestone.getName());
218:                } else {
219:                    // returns to the project page
220:                    redirect(getUrl());
221:                }
222:
223:                return null;
224:            }
225:
226:            public List<TaskTO> getOpenedTasks() throws EmForgeException {
227:                if (m_openedTasks == null) {
228:                    m_openedTasks = m_bpmService
229:                            .findTasks(m_milestone.getName(),
230:                                    TaskStatus.OPENED, m_isShowSubprocesses);
231:                }
232:
233:                return m_openedTasks;
234:
235:            }
236:
237:            public List<TaskTO> getClosedTasks() throws EmForgeException {
238:                if (m_closedTasks == null) {
239:                    m_closedTasks = m_bpmService
240:                            .findTasks(m_milestone.getName(),
241:                                    TaskStatus.CLOSED, m_isShowSubprocesses);
242:                }
243:
244:                return m_closedTasks;
245:            }
246:
247:            public boolean isNewMilestone() {
248:                return m_isNewMilestone;
249:            }
250:
251:            public boolean isCanSaveMilestone() {
252:                return m_projectService.canChangeMilestone(m_milestone);
253:            }
254:
255:            public String getUrl() {
256:                return ProjectController.PROJECT_PAGE_NAME + "/"
257:                        + m_milestone.getProject().getName() + "/"
258:                        + MilestoneController.MILESTONE_PAGE_NAME + "/"
259:                        + m_milestone.getName();
260:            }
261:
262:            public int getOpenedProcessesCount() throws EmForgeException {
263:                if (m_openedTasksCount == null) {
264:                    m_openedTasksCount = getOpenedTasks().size();
265:                }
266:                return m_openedTasksCount;
267:            }
268:
269:            public int getClosedProcessesCount() throws EmForgeException {
270:                if (m_closedTasksCount == null) {
271:                    m_closedTasksCount = getClosedTasks().size();
272:                }
273:                return m_closedTasksCount;
274:            }
275:
276:            public int getOpenedProcessesPercentage() throws EmForgeException {
277:                return 100
278:                        * getOpenedProcessesCount()
279:                        / (getOpenedProcessesCount() + getClosedProcessesCount());
280:            }
281:
282:            public int getClosedProcessesPercentage() throws EmForgeException {
283:                return 100 - getOpenedProcessesPercentage();
284:            }
285:
286:            public boolean getShowSubprocesses() {
287:                return m_isShowSubprocesses;
288:            }
289:
290:            public void setShowSubprocesses(boolean i_isShowSubprocesses) {
291:                m_isShowSubprocesses = i_isShowSubprocesses;
292:            }
293:
294:            /** Returns Attachments for Project
295:             * 
296:             * @return
297:             */
298:            @SuppressWarnings("unchecked")
299:            public Collection<Attachment> getAttachments() {
300:                if (isNewMilestone()) {
301:                    // return empty list
302:                    return new LinkedList<Attachment>();
303:                }
304:
305:                // attachments for project are stored in wiki-engine
306:                Collection<Attachment> result = new ArrayList<Attachment>();
307:
308:                WikiContext wikiContext = getWikiContext();
309:                if (wikiContext != null) {
310:                    try {
311:                        WikiPage page = wikiContext.getPage();
312:                        if (page != null) {
313:                            result = wikiContext.getEngine()
314:                                    .getAttachmentManager().listAttachments(
315:                                            page);
316:                        }
317:                    } catch (ProviderException e) {
318:                        logger.error("Cannot get attachment list: ", e);
319:                        return result;
320:                    }
321:                }
322:                return result;
323:
324:            }
325:
326:            private WikiContext getWikiContext() {
327:                if (StringUtils.isEmpty(getMilestone().getName())) {
328:                    return null;
329:                }
330:
331:                WikiPage page = m_wikiEngine.getPage(getMilestone().getName(),
332:                        -1);
333:                if (page != null) {
334:                    return new WikiContext(m_wikiEngine, page);
335:                }
336:
337:                return null;
338:            }
339:
340:            public CommentTO[] getComments() throws EmForgeException {
341:                return m_commentService.getComments(getMilestone().getName());
342:            }
343:
344:            /** Logged-In user can add comments for project
345:             * 
346:             */
347:            public boolean isCanAddComment() {
348:                return !m_appContext.getUserService().getCurrentUser()
349:                        .isAnonymous()
350:                        && !isNewMilestone();
351:            }
352:
353:            public String addComment() {
354:                String comment = m_editTextController.getWikiText();
355:
356:                if (StringUtils.isNotEmpty(comment)) {
357:                    try {
358:                        m_commentService.addComment(getMilestone().getName(),
359:                                comment);
360:                    } catch (EmForgeException ex) {
361:                        logger.error("Cannot add comment for milestone: "
362:                                + getMilestone().getName(), ex);
363:                        addErrorMessage("Cannot add comment: "
364:                                + ex.getMessage(), "Cannot add comment: "
365:                                + ex.getMessage());
366:                    }
367:
368:                }
369:
370:                return null;
371:            }
372:
373:            public String cancel() {
374:                if (m_trail.getCurrentUrl() != null) {
375:                    redirect(m_trail.getCurrentUrl());
376:                }
377:
378:                return null;
379:            }
380:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.