Source Code Cross Referenced for PreferencesServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » preferences » 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 » ERP CRM Financial » Kuali Financial System » edu.iu.uis.eden.preferences 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         *
004:         *
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         * http://www.opensource.org/licenses/ecl1.php
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.preferences;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:
022:        import edu.iu.uis.eden.EdenConstants;
023:        import edu.iu.uis.eden.KEWServiceLocator;
024:        import edu.iu.uis.eden.WorkflowServiceErrorException;
025:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
026:        import edu.iu.uis.eden.user.WorkflowUser;
027:        import edu.iu.uis.eden.useroptions.UserOptions;
028:        import edu.iu.uis.eden.useroptions.UserOptionsService;
029:
030:        /**
031:         * An implementation of the {@link PreferencesService}.
032:         *
033:         * @author rkirkend
034:         * @author bmcgough
035:         * @author temay
036:         * @author ewestfal
037:         */
038:        public class PreferencesServiceImpl implements  PreferencesService {
039:
040:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
041:                    .getLogger(PreferencesServiceImpl.class);
042:
043:            private static final String DISAPPROVED_DOC_COLOR = "DOCUMENT_STATUS_COLOR_D";
044:            // what the hell is this status?
045:            private static final String DISSAPPROVED_CANCELLED_DOC_COLOR = "DOCUMENT_STATUS_COLOR_C";
046:            private static final String APPROVED_DOC_COLOR = "DOCUMENT_STATUS_COLOR_A";
047:            private static final String CANCELLED_DOC_COLOR = "DOCUMENT_STATUS_COLOR_X";
048:            private static final String SAVED_DOC_COLOR = "DOCUMENT_STATUS_COLOR_S";
049:            private static final String ENROUTE_DOC_COLOR = "DOCUMENT_STATUS_COLOR_R";
050:            private static final String PROCESSED_DOC_COLOR = "DOCUMENT_STATUS_COLOR_P";
051:            private static final String INITIATED_DOC_COLOR = "DOCUMENT_STATUS_COLOR_I";
052:            private static final String FINAL_DOC_COLOR = "DOCUMENT_STATUS_COLOR_F";
053:            private static final String EXCEPTION_DOC_COLOR = "DOCUMENT_STATUS_COLOR_E";
054:            private static final String REFRESH_RATE_KEY = "REFRESH_RATE";
055:            private static final String OPEN_NEW_WINDOW_KEY = "OPEN_ITEMS_NEW_WINDOW";
056:            private static final String COLUMN_DOC_TYPE_KEY = "DOC_TYPE_COL_SHOW_NEW";
057:            private static final String COLUMN_TITLE_KEY = "TITLE_COL_SHOW_NEW";
058:            private static final String COLUMN_ACTION_REQ_KEY = "ACTION_REQUESTED_COL_SHOW_NEW";
059:            private static final String COLUMN_INITIATOR_KEY = "INITIATOR_COL_SHOW_NEW";
060:            private static final String COLUMN_DELEGATOR_KEY = "DELEGATOR_COL_SHOW_NEW";
061:            private static final String COLUMN_DATE_CREATE_KEY = "DATE_CREATED_COL_SHOW_NEW";
062:            private static final String COLUMN_DOCUMENT_STATUS_KEY = "DOCUMENT_STATUS_COL_SHOW_NEW";
063:            private static final String COLUMN_WORKGROUP_REQUEST_KEY = "WORKGROUP_REQUEST_COL_SHOW_NEW";
064:            private static final String COLUMN_CLEAR_FYI_KEY = "CLEAR_FYI_COL_SHOW_NEW";
065:            private static final String ACTION_LIST_SIZE_KEY = "ACTION_LIST_SIZE_NEW";
066:            private static final String EMAIL_REMINDER_KEY = EdenConstants.EMAIL_RMNDR_KEY;
067:            private static final String EMAIL_NOTIFY_PRIMARY_KEY = "EMAIL_NOTIFY_PRIMARY";
068:            private static final String EMAIL_NOTIFY_SECONDARY_KEY = "EMAIL_NOTIFY_SECONDARY";
069:            private static final String DEFAULT_COLOR = "white";
070:            private static final String DEFAULT_ACTION_LIST_SIZE = "10";
071:            private static final String DEFAULT_REFRESH_RATE = "15";
072:            private static final String ERR_KEY_REFRESH_RATE_WHOLE_NUM = "preferences.preferencesservice.refreshRate.wholenum";
073:            private static final String ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM = "preferences.preferencesservice.pagesize.wholenum";
074:            private static final String DELEGATOR_FILTER_KEY = "DELEGATOR_FILTER";
075:
076:            public Preferences getPreferences(WorkflowUser user) {
077:                LOG.debug("start preferences fetch user " + user);
078:                Preferences preferences = new Preferences();
079:                preferences.setColorApproved(getOption(APPROVED_DOC_COLOR,
080:                        DEFAULT_COLOR, user).getOptionVal());
081:                preferences.setColorCanceled(getOption(CANCELLED_DOC_COLOR,
082:                        DEFAULT_COLOR, user).getOptionVal());
083:                preferences.setColorDissapproveCancel(getOption(
084:                        DISSAPPROVED_CANCELLED_DOC_COLOR, DEFAULT_COLOR, user)
085:                        .getOptionVal());
086:                preferences.setColorDissaproved(getOption(
087:                        DISAPPROVED_DOC_COLOR, DEFAULT_COLOR, user)
088:                        .getOptionVal());
089:                preferences.setColorEnroute(getOption(ENROUTE_DOC_COLOR,
090:                        DEFAULT_COLOR, user).getOptionVal());
091:                preferences.setColorException(getOption(EXCEPTION_DOC_COLOR,
092:                        DEFAULT_COLOR, user).getOptionVal());
093:                preferences.setColorFinal(getOption(FINAL_DOC_COLOR,
094:                        DEFAULT_COLOR, user).getOptionVal());
095:                preferences.setColorInitiated(getOption(INITIATED_DOC_COLOR,
096:                        DEFAULT_COLOR, user).getOptionVal());
097:                preferences.setColorProccessed(getOption(PROCESSED_DOC_COLOR,
098:                        DEFAULT_COLOR, user).getOptionVal());
099:                preferences.setColorSaved(getOption(SAVED_DOC_COLOR,
100:                        DEFAULT_COLOR, user).getOptionVal());
101:                preferences.setEmailNotification(getOption(EMAIL_REMINDER_KEY,
102:                        EdenConstants.EMAIL_RMNDR_IMMEDIATE, user)
103:                        .getOptionVal());
104:                preferences
105:                        .setNotifyPrimaryDelegation(getOption(
106:                                EMAIL_NOTIFY_PRIMARY_KEY,
107:                                EdenConstants.PREFERENCES_YES_VAL, user)
108:                                .getOptionVal());
109:                preferences.setNotifySecondaryDelegation(getOption(
110:                        EMAIL_NOTIFY_SECONDARY_KEY,
111:                        EdenConstants.PREFERENCES_NO_VAL, user).getOptionVal());
112:                preferences
113:                        .setOpenNewWindow(getOption(OPEN_NEW_WINDOW_KEY,
114:                                EdenConstants.PREFERENCES_YES_VAL, user)
115:                                .getOptionVal());
116:                preferences.setPageSize(getOption(ACTION_LIST_SIZE_KEY,
117:                        DEFAULT_ACTION_LIST_SIZE, user).getOptionVal());
118:                preferences.setRefreshRate(getOption(REFRESH_RATE_KEY,
119:                        DEFAULT_REFRESH_RATE, user).getOptionVal());
120:                preferences
121:                        .setShowActionRequested(getOption(
122:                                COLUMN_ACTION_REQ_KEY,
123:                                EdenConstants.PREFERENCES_YES_VAL, user)
124:                                .getOptionVal());
125:                preferences
126:                        .setShowDateCreated(getOption(COLUMN_DATE_CREATE_KEY,
127:                                EdenConstants.PREFERENCES_YES_VAL, user)
128:                                .getOptionVal());
129:                preferences
130:                        .setShowDocType(getOption(COLUMN_DOC_TYPE_KEY,
131:                                EdenConstants.PREFERENCES_YES_VAL, user)
132:                                .getOptionVal());
133:                preferences
134:                        .setShowDocumentStatus(getOption(
135:                                COLUMN_DOCUMENT_STATUS_KEY,
136:                                EdenConstants.PREFERENCES_YES_VAL, user)
137:                                .getOptionVal());
138:                preferences
139:                        .setShowInitiator(getOption(COLUMN_INITIATOR_KEY,
140:                                EdenConstants.PREFERENCES_YES_VAL, user)
141:                                .getOptionVal());
142:                preferences
143:                        .setShowDelegator(getOption(COLUMN_DELEGATOR_KEY,
144:                                EdenConstants.PREFERENCES_YES_VAL, user)
145:                                .getOptionVal());
146:                preferences
147:                        .setShowDocTitle(getOption(COLUMN_TITLE_KEY,
148:                                EdenConstants.PREFERENCES_YES_VAL, user)
149:                                .getOptionVal());
150:                preferences
151:                        .setShowWorkgroupRequest(getOption(
152:                                COLUMN_WORKGROUP_REQUEST_KEY,
153:                                EdenConstants.PREFERENCES_YES_VAL, user)
154:                                .getOptionVal());
155:                preferences
156:                        .setShowClearFyi(getOption(COLUMN_CLEAR_FYI_KEY,
157:                                EdenConstants.PREFERENCES_YES_VAL, user)
158:                                .getOptionVal());
159:                //        preferences.setActionListContentType(getOption(ACTION_LIST_CONTENT_KEY, EdenConstants.ACTION_LIST_ALL_REQUESTS, user).getOptionVal());
160:                preferences.setDelegatorFilter(getOption(DELEGATOR_FILTER_KEY,
161:                        EdenConstants.DELEGATORS_ON_ACTION_LIST_PAGE, user)
162:                        .getOptionVal());
163:                LOG.debug("end preferences fetch user " + user);
164:                return preferences;
165:            }
166:
167:            private UserOptions getOption(String optionKey,
168:                    String defaultValue, WorkflowUser user) {
169:                LOG.debug("start fetch option " + optionKey + " user "
170:                        + user.getWorkflowUserId().getWorkflowId());
171:                UserOptionsService optionSrv = getUserOptionService();
172:                UserOptions option = optionSrv.findByOptionId(optionKey, user);
173:                if (option == null) {
174:                    option = new UserOptions();
175:                    option.setWorkflowId(user.getWorkflowUserId()
176:                            .getWorkflowId());
177:                    option.setOptionId(optionKey);
178:                    option.setOptionVal(defaultValue);
179:                    optionSrv.save(option);
180:                }
181:                LOG.debug("end fetch option " + optionKey + " user "
182:                        + user.getWorkflowUserId().getWorkflowId());
183:                return option;
184:            }
185:
186:            public void savePreferences(WorkflowUser user,
187:                    Preferences preferences) {
188:                LOG.debug("saving prerferences user "
189:                        + user.getAuthenticationUserId());
190:                validate(preferences);
191:                UserOptionsService optionSrv = getUserOptionService();
192:                optionSrv.save(user, DISAPPROVED_DOC_COLOR, preferences
193:                        .getColorDissaproved());
194:                optionSrv.save(user, DISSAPPROVED_CANCELLED_DOC_COLOR,
195:                        preferences.getColorDissapproveCancel());
196:                optionSrv.save(user, APPROVED_DOC_COLOR, preferences
197:                        .getColorApproved());
198:                optionSrv.save(user, CANCELLED_DOC_COLOR, preferences
199:                        .getColorCanceled());
200:                optionSrv.save(user, SAVED_DOC_COLOR, preferences
201:                        .getColorSaved());
202:                optionSrv.save(user, ENROUTE_DOC_COLOR, preferences
203:                        .getColorEnroute());
204:                optionSrv.save(user, PROCESSED_DOC_COLOR, preferences
205:                        .getColorProccessed());
206:                optionSrv.save(user, INITIATED_DOC_COLOR, preferences
207:                        .getColorInitiated());
208:                optionSrv.save(user, FINAL_DOC_COLOR, preferences
209:                        .getColorFinal());
210:                optionSrv.save(user, EXCEPTION_DOC_COLOR, preferences
211:                        .getColorException());
212:                optionSrv.save(user, REFRESH_RATE_KEY, preferences
213:                        .getRefreshRate().trim());
214:                optionSrv.save(user, OPEN_NEW_WINDOW_KEY, preferences
215:                        .getOpenNewWindow());
216:                optionSrv.save(user, COLUMN_DOC_TYPE_KEY, preferences
217:                        .getShowDocType());
218:                optionSrv.save(user, COLUMN_TITLE_KEY, preferences
219:                        .getShowDocTitle());
220:                optionSrv.save(user, COLUMN_ACTION_REQ_KEY, preferences
221:                        .getShowActionRequested());
222:                optionSrv.save(user, COLUMN_INITIATOR_KEY, preferences
223:                        .getShowInitiator());
224:                optionSrv.save(user, COLUMN_DELEGATOR_KEY, preferences
225:                        .getShowDelegator());
226:                optionSrv.save(user, COLUMN_DATE_CREATE_KEY, preferences
227:                        .getShowDateCreated());
228:                optionSrv.save(user, COLUMN_DOCUMENT_STATUS_KEY, preferences
229:                        .getShowDocumentStatus());
230:                optionSrv.save(user, COLUMN_WORKGROUP_REQUEST_KEY, preferences
231:                        .getShowWorkgroupRequest());
232:                optionSrv.save(user, COLUMN_CLEAR_FYI_KEY, preferences
233:                        .getShowClearFyi());
234:                optionSrv.save(user, ACTION_LIST_SIZE_KEY, preferences
235:                        .getPageSize().trim());
236:                optionSrv.save(user, EMAIL_REMINDER_KEY, preferences
237:                        .getEmailNotification());
238:                optionSrv.save(user, EMAIL_NOTIFY_PRIMARY_KEY, preferences
239:                        .getNotifyPrimaryDelegation());
240:                optionSrv.save(user, EMAIL_NOTIFY_SECONDARY_KEY, preferences
241:                        .getNotifySecondaryDelegation());
242:                //        optionSrv.save(user, ACTION_LIST_CONTENT_KEY, preferences.getActionListContentType());
243:                optionSrv.save(user, DELEGATOR_FILTER_KEY, preferences
244:                        .getDelegatorFilter());
245:                LOG.debug("saved preferences user "
246:                        + user.getAuthenticationUserId());
247:            }
248:
249:            private void validate(Preferences preferences) {
250:                LOG.debug("validating preferences");
251:                Collection errors = new ArrayList();
252:                try {
253:                    new Integer(preferences.getRefreshRate().trim());
254:                } catch (NumberFormatException e) {
255:                    errors
256:                            .add(new WorkflowServiceErrorImpl(
257:                                    "ActionList Refresh Rate must be in whole "
258:                                            + "minutes",
259:                                    ERR_KEY_REFRESH_RATE_WHOLE_NUM));
260:                } catch (NullPointerException e1) {
261:                    errors
262:                            .add(new WorkflowServiceErrorImpl(
263:                                    "ActionList Refresh Rate must be in whole "
264:                                            + "minutes",
265:                                    ERR_KEY_REFRESH_RATE_WHOLE_NUM));
266:                }
267:
268:                try {
269:                    new Integer(preferences.getPageSize().trim());
270:                } catch (NumberFormatException e) {
271:                    errors.add(new WorkflowServiceErrorImpl(
272:                            "ActionList Refresh Rate must be in whole "
273:                                    + "minutes",
274:                            ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM));
275:                } catch (NullPointerException e1) {
276:                    errors.add(new WorkflowServiceErrorImpl(
277:                            "ActionList Refresh Rate must be in whole "
278:                                    + "minutes",
279:                            ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM));
280:                }
281:                LOG.debug("end validating preferences");
282:                if (!errors.isEmpty()) {
283:                    throw new WorkflowServiceErrorException(
284:                            "Preference Validation Error", errors);
285:                }
286:            }
287:
288:            public UserOptionsService getUserOptionService() {
289:                return (UserOptionsService) KEWServiceLocator
290:                        .getService(KEWServiceLocator.USER_OPTIONS_SRV);
291:            }
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.