Source Code Cross Referenced for FlowResult.java in  » Content-Management-System » dspace » org » dspace » app » xmlui » aspect » administrative » 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 » Content Management System » dspace » org.dspace.app.xmlui.aspect.administrative 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * FlowResult.java
003:         *
004:         * Version: $Revision: 1.3 $
005:         *
006:         * Date: $Date: 2006/07/13 23:20:54 $
007:         *
008:         * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
009:         * Institute of Technology.  All rights reserved.
010:         *
011:         * Redistribution and use in source and binary forms, with or without
012:         * modification, are permitted provided that the following conditions are
013:         * met:
014:         *
015:         * - Redistributions of source code must retain the above copyright
016:         * notice, this list of conditions and the following disclaimer.
017:         *
018:         * - Redistributions in binary form must reproduce the above copyright
019:         * notice, this list of conditions and the following disclaimer in the
020:         * documentation and/or other materials provided with the distribution.
021:         *
022:         * - Neither the name of the Hewlett-Packard Company nor the name of the
023:         * Massachusetts Institute of Technology nor the names of their
024:         * contributors may be used to endorse or promote products derived from
025:         * this software without specific prior written permission.
026:         *
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028:         * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031:         * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033:         * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034:         * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036:         * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037:         * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038:         * DAMAGE.
039:         */
040:
041:        package org.dspace.app.xmlui.aspect.administrative;
042:
043:        import java.util.ArrayList;
044:        import java.util.HashMap;
045:        import java.util.List;
046:        import java.util.Map;
047:
048:        import org.dspace.app.xmlui.wing.Message;
049:
050:        /**
051:         * This class represents the results that may be generated during a flow script
052:         * in this administrative section. Typicaly, some method preforms an operation
053:         * and returns an object of type FlowResult, then the flow script can inspect
054:         * the results object to determine what the next course of action is.
055:         * 
056:         * Basicaly, this results object stores all the errors and contiunation states
057:         * that need to be represented. There are four types of information stored:
058:         * 
059:         * 1) Continuation, this is a simple boolean variable that indicates wheather
060:         * the required operation is complete and the user may continue on to the next step.
061:         * 
062:         * 2) Notice information, this is a simple encoding of a notice message to be displayed
063:         * to the user on their next step. There are four parts: outcome, header, message, and
064:         * characters. See each field for more description on each part. Note: either a message
065:         * or characters are required.
066:         * 
067:         * 3) Errors, this is a list of errors that were encountered during processing. 
068:         * Typical, it just consists of a list of errored fields. However occasionaly there 
069:         * may be other specialized errors listed.
070:         * 
071:         * 4) Parameters, this is a map of attached parameters that may be relevnt to the 
072:         * result. This should be used for things such as generated id's when objects are newly
073:         * created.
074:         * 
075:         * @author Scott Phillips
076:         */
077:        public class FlowResult {
078:
079:            /**
080:             * Determine wheather the operation has been completed enough that the user
081:             * may successufully continue on to the next step.
082:             */
083:            private boolean continuep;
084:
085:            /**
086:             * Notice parameters:
087:             * 
088:             * Outcome: The outcome of the notice, may be either success, failure, or netural.
089:             * 
090:             * Header: The notice's label, an i18n dictionary key.
091:             * 
092:             * message: The main body of the notice, an i18n dictionary key.
093:             * 
094:             * characters: Supplementaiol information for the notice, plain text. This is 
095:             * typicaly used for exepctions.
096:             *
097:             */
098:            private enum Outcome {
099:                SUCCESS, FAILURE, NETURAL
100:            };
101:
102:            private Outcome outcome = Outcome.NETURAL;
103:            private Message header;
104:            private Message message;
105:            private String characters;
106:
107:            /**
108:             * A list of errors encountered while processing this operation.
109:             */
110:            private List<String> errors;
111:
112:            /**
113:             * Any parameters that may be attached to this result.
114:             */
115:            private Map<String, Object> parameters;
116:
117:            /**
118:             * Set the continuation parameter determining if the
119:             * user should progress to the next step in the flow.
120:             */
121:            public void setContinue(boolean continuep) {
122:                this .continuep = continuep;
123:            }
124:
125:            /**
126:             * Determine if the user should progress to the
127:             * next step in the flow.
128:             * 
129:             * @return the continuation parameter
130:             */
131:            public boolean getContinue() {
132:                return this .continuep;
133:            }
134:
135:            /**
136:             * Set the notice outcome to either success or failure. Note, 
137:             * the default outcome is netural, once an outcome is set the
138:             * netural outcome can never be atained again.
139:             * 
140:             * @param success True for success, false for failure.
141:             */
142:            public void setOutcome(boolean success) {
143:                if (success)
144:                    outcome = Outcome.SUCCESS;
145:                else
146:                    outcome = Outcome.FAILURE;
147:            }
148:
149:            /**
150:             * Get the notice outcome in string form, either success 
151:             * or failure. If the outcome is netural then null is returned.
152:             */
153:            public String getOutcome() {
154:                if (outcome == Outcome.SUCCESS) {
155:                    return "success";
156:                } else if (outcome == Outcome.FAILURE) {
157:                    return "failure";
158:                }
159:                return null;
160:            }
161:
162:            /**
163:             * Set the notice header.
164:             * 
165:             * This must be an i18n dictionary key
166:             */
167:            public void setHeader(Message header) {
168:                this .header = header;
169:            }
170:
171:            /**
172:             * Return the notice header
173:             */
174:            public String getHeader() {
175:                if (this .header != null)
176:                    return this .header.getKey();
177:                return null;
178:            }
179:
180:            /**
181:             * Set the notice message
182:             * 
183:             * This must be an i18n dictionary key
184:             */
185:            public void setMessage(Message message) {
186:                this .message = message;
187:            }
188:
189:            /**
190:             * return the notice message
191:             */
192:            public String getMessage() {
193:                if (this .message != null)
194:                    return this .message.getKey();
195:                return null;
196:            }
197:
198:            /**
199:             * Set the notice characters
200:             */
201:            public void setCharacters(String characters) {
202:                this .characters = characters;
203:            }
204:
205:            /**
206:             * Return the notice characters
207:             */
208:            public String getCharacters() {
209:                return this .characters;
210:            }
211:
212:            /**
213:             * Set the results errors, note this will remove any previous errors.
214:             * 
215:             * @param errors New error list.
216:             */
217:            public void setErrors(List<String> errors) {
218:                this .errors = errors;
219:            }
220:
221:            /**
222:             * Add a new single error to the error list.
223:             * 
224:             * @param newError New error.
225:             */
226:            public void addError(String newError) {
227:                if (this .errors == null)
228:                    this .errors = new ArrayList<String>();
229:
230:                this .errors.add(newError);
231:            }
232:
233:            /**
234:             * Return the current list of errors.
235:             */
236:            public List<String> getErrors() {
237:                return this .errors;
238:            }
239:
240:            /**
241:             * Return the list of errors in string form, i.e. a comma seperated list
242:             * of errors. If there are no errors then null is returned.
243:             */
244:            public String getErrorString() {
245:                if (errors == null || errors.size() == 0)
246:                    return null;
247:
248:                String errorString = null;
249:                for (String error : errors) {
250:                    if (errorString == null)
251:                        errorString = error;
252:                    else
253:                        errorString += "," + error;
254:                }
255:                return errorString;
256:            }
257:
258:            /**
259:             * Attatch a new parameter to this result object with the specified
260:             * name & value.
261:             * 
262:             * @param name The parameter's name
263:             * @param value The parameter's value.
264:             */
265:            public void setParameter(String name, Object value) {
266:                if (this .parameters == null)
267:                    this .parameters = new HashMap<String, Object>();
268:
269:                this .parameters.put(name, value);
270:            }
271:
272:            /**
273:             * Find the attached parameter with the given name. If no parameter is 
274:             * found for the specified name then null is returned.
275:             * 
276:             * @param name The parameter's name.
277:             * @return The parameter's value.
278:             */
279:            public Object getParameter(String name) {
280:                if (this.parameters == null)
281:                    return null;
282:
283:                return this.parameters.get(name);
284:            }
285:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.