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


001:        /*
002:         * Created by IntelliJ IDEA.
003:         * User: sg426575
004:         * Date: May 12, 2005
005:         * Time: 11:08:51 PM
006:         */
007:        package com.technoetic.xplanner.actions;
008:
009:        import java.io.IOException;
010:        import javax.servlet.http.Cookie;
011:        import javax.servlet.http.HttpServletRequest;
012:        import javax.servlet.http.HttpServletResponse;
013:
014:        import org.apache.struts.action.*;
015:
016:        import com.technoetic.xplanner.XPlannerProperties;
017:        import com.technoetic.xplanner.domain.Iteration;
018:        import com.technoetic.xplanner.forms.AbstractEditorForm;
019:        import com.technoetic.xplanner.forms.ImportStoriesForm;
020:        import com.technoetic.xplanner.importer.MissingColumnHeaderSpreadsheetImporterException;
021:        import com.technoetic.xplanner.importer.MissingFieldSpreadsheetImporterException;
022:        import com.technoetic.xplanner.importer.SpreadsheetStoryImporter;
023:        import com.technoetic.xplanner.importer.WrongImportFileSpreadsheetImporterException;
024:        import com.technoetic.xplanner.importer.spreadsheet.MissingWorksheetException;
025:        import com.technoetic.xplanner.importer.spreadsheet.SpreadsheetHeaderConfiguration;
026:        import com.technoetic.xplanner.util.CookieSupport;
027:
028:        public class ImportStoriesAction extends EditObjectAction {
029:            SpreadsheetStoryImporter importer;
030:            public static final String WORKSHEET_NAME_PROPERTY_KEY = "import.spreadsheet.worksheet.name";
031:            public static final String STORY_TITLE_PROPERTY_KEY = "import.spreadsheet.story.title.column.header";
032:            public static final String STORY_ESTIMATE_PROPERTY_KEY = "import.spreadsheet.story.estimate.column.header";
033:            public static final String ITERATION_END_DATE_PROPERTY_KEY = "import.spreadsheet.iteration.end.date.column.header";
034:            public static final String STORY_PRIORITY_PROPERTY_KEY = "import.spreadsheet.story.priority.column.header";
035:            public static final String STORY_STATUS_PROPERTY_KEY = "import.spreadsheet.story.status.column.header";
036:            public final static String ONLY_INCOMPLETE_COOKIE_NAME = "import.spreadsheet.onlyIncomplete";
037:            public final static String COMPLETED_STORY_STATUS_KEY = "import.spreadsheet.completedStoryStatus";
038:
039:            public ActionForward execute(ActionMapping mapping,
040:                    ActionForm actionForm, HttpServletRequest request,
041:                    HttpServletResponse response) throws Exception {
042:                ActionErrors errors = new ActionErrors();
043:                try {
044:                    return super 
045:                            .execute(mapping, actionForm, request, response);
046:                } catch (WrongImportFileSpreadsheetImporterException e) {
047:                    errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
048:                            "import.status.corrupted_file"));
049:                } catch (MissingFieldSpreadsheetImporterException e) {
050:                    errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
051:                            "import.status.missing_required_field", e
052:                                    .getField()));
053:                } catch (MissingColumnHeaderSpreadsheetImporterException e) {
054:                    errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
055:                            "import.status.wrong_header", e.getColumnName()));
056:                } catch (MissingWorksheetException e) {
057:                    errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
058:                            "import.status.worksheet_not_found", e
059:                                    .getWorksheetName()));
060:                }
061:                saveErrors(request, errors);
062:                return mapping.getInputForward();
063:            }
064:
065:            protected void populateObject(HttpServletRequest request,
066:                    Object object, ActionForm form) throws IOException {
067:                ImportStoriesForm importStoriesForm = (ImportStoriesForm) form;
068:                SpreadsheetHeaderConfiguration headerConfiguration = new SpreadsheetHeaderConfiguration();
069:                populateHeaderConfiguration(headerConfiguration,
070:                        importStoriesForm);
071:                importStoriesForm.setResults(importer.importStories(
072:                        (Iteration) object, headerConfiguration,
073:                        importStoriesForm.getFormFile().getInputStream(),
074:                        importStoriesForm.isOnlyIncomplete()));
075:            }
076:
077:            private void populateHeaderConfiguration(
078:                    SpreadsheetHeaderConfiguration headerConfiguration,
079:                    ImportStoriesForm form) {
080:                headerConfiguration.setWorksheetName(form.getWorksheetName());
081:                headerConfiguration.setTitleHeader(form.getTitleColumn());
082:                headerConfiguration.setEndDateHeader(form.getEndDateColumn());
083:                headerConfiguration.setEstimateHeader(form.getEstimateColumn());
084:                headerConfiguration.setPriorityHeader(form.getPriorityColumn());
085:                headerConfiguration.setStatusHeader(form.getStatusColumn());
086:            }
087:
088:            protected void setCookies(AbstractEditorForm form,
089:                    ActionMapping mapping, HttpServletRequest request,
090:                    HttpServletResponse response) {
091:                ImportStoriesForm importForm = (ImportStoriesForm) form;
092:                addCookie(WORKSHEET_NAME_PROPERTY_KEY, importForm
093:                        .getWorksheetName(), response);
094:                addCookie(STORY_TITLE_PROPERTY_KEY,
095:                        importForm.getTitleColumn(), response);
096:                addCookie(ITERATION_END_DATE_PROPERTY_KEY, importForm
097:                        .getEndDateColumn(), response);
098:                addCookie(STORY_ESTIMATE_PROPERTY_KEY, importForm
099:                        .getEstimateColumn(), response);
100:                addCookie(STORY_PRIORITY_PROPERTY_KEY, importForm
101:                        .getPriorityColumn(), response);
102:                addCookie(STORY_STATUS_PROPERTY_KEY, importForm
103:                        .getStatusColumn(), response);
104:                addCookie(ONLY_INCOMPLETE_COOKIE_NAME, ""
105:                        + importForm.isOnlyIncomplete(), response);
106:                addCookie(COMPLETED_STORY_STATUS_KEY, importForm
107:                        .getCompletedStatus(), response);
108:            }
109:
110:            private void addCookie(String propertyKey, String value,
111:                    HttpServletResponse response) {
112:                CookieSupport.createCookie(propertyKey, value, response);
113:            }
114:
115:            protected void populateForm(AbstractEditorForm actionForm,
116:                    ActionMapping actionMapping, HttpServletRequest request) {
117:                ImportStoriesForm form = (ImportStoriesForm) actionForm;
118:                form.setWorksheetName(getValueFromCookieOrProperties(
119:                        WORKSHEET_NAME_PROPERTY_KEY, request));
120:                form.setTitleColumn(getValueFromCookieOrProperties(
121:                        STORY_TITLE_PROPERTY_KEY, request));
122:                form.setEndDateColumn(getValueFromCookieOrProperties(
123:                        ITERATION_END_DATE_PROPERTY_KEY, request));
124:                form.setPriorityColumn(getValueFromCookieOrProperties(
125:                        STORY_PRIORITY_PROPERTY_KEY, request));
126:                form.setEstimateColumn(getValueFromCookieOrProperties(
127:                        STORY_ESTIMATE_PROPERTY_KEY, request));
128:                form.setStatusColumn(getValueFromCookieOrProperties(
129:                        STORY_STATUS_PROPERTY_KEY, request));
130:                form.setOnlyIncomplete(Boolean.valueOf(
131:                        getValueFromCookieOrProperties(
132:                                ONLY_INCOMPLETE_COOKIE_NAME, request))
133:                        .booleanValue());
134:                form.setCompletedStatus(getValueFromCookieOrProperties(
135:                        COMPLETED_STORY_STATUS_KEY, request));
136:            }
137:
138:            public SpreadsheetStoryImporter getImporter() {
139:                return importer;
140:            }
141:
142:            public void setImporter(SpreadsheetStoryImporter importer) {
143:                this .importer = importer;
144:            }
145:
146:            public String getValueFromCookieOrProperties(String key,
147:                    HttpServletRequest request) {
148:                Cookie cookie = CookieSupport.getCookie(key, request);
149:                if (cookie != null) {
150:                    return cookie.getValue();
151:                }
152:                XPlannerProperties xplannerProperties = new XPlannerProperties();
153:                return xplannerProperties.getProperty(key);
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.