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


0001:        /*
0002:         * Copyright 2005-2007 The Kuali Foundation.
0003:         * 
0004:         * 
0005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
0006:         * you may not use this file except in compliance with the License.
0007:         * You may obtain a copy of the License at
0008:         * 
0009:         * http://www.opensource.org/licenses/ecl1.php
0010:         * 
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:        package edu.iu.uis.eden.server;
0018:
0019:        import java.sql.Timestamp;
0020:        import java.text.DateFormat;
0021:        import java.text.SimpleDateFormat;
0022:        import java.util.ArrayList;
0023:        import java.util.Calendar;
0024:        import java.util.GregorianCalendar;
0025:        import java.util.HashMap;
0026:        import java.util.List;
0027:        import java.util.Map;
0028:
0029:        import org.apache.commons.lang.StringUtils;
0030:
0031:        import edu.iu.uis.eden.EdenConstants;
0032:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
0033:        import edu.iu.uis.eden.clientapp.WorkflowInfo;
0034:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
0035:        import edu.iu.uis.eden.clientapp.vo.NoteVO;
0036:        import edu.iu.uis.eden.clientapp.vo.RouteHeaderVO;
0037:        import edu.iu.uis.eden.clientapp.vo.UserIdVO;
0038:        import edu.iu.uis.eden.clientapp.vo.UserVO;
0039:        import edu.iu.uis.eden.clientapp.vo.WorkflowIdVO;
0040:        import edu.iu.uis.eden.clientapp.vo.WorkgroupIdVO;
0041:        import edu.iu.uis.eden.clientapp.vo.WorkgroupNameIdVO;
0042:        import edu.iu.uis.eden.exception.WorkflowException;
0043:        import edu.iu.uis.eden.util.Utilities;
0044:
0045:        /**
0046:         * Implementation of the SimpleDocumentActionsWebService
0047:         *
0048:         * @author Bryan G. Hutchinson (bh79 at cornell dot edu)
0049:         * @author ewestfal
0050:         * @author Aaron Hamid (arh14 at cornell dot edu)
0051:         */
0052:        public class SimpleDocumentActionsWebServiceImpl implements 
0053:                SimpleDocumentActionsWebService {
0054:
0055:            /*private static final String IS_USER_IN_ROUTE_LOG_LABEL = "isUserInRouteLog";
0056:            private static final String DOC_ID_LABEL = "docId";
0057:            private static final String DOC_CONTENT_LABEL = "docContent";
0058:            private static final String NOTES_LABEL = "notes";
0059:            private static final String ACTION_REQUESTED_LABEL = "actionRequested";
0060:            private static final String ERROR_MESSAGE_LABEL = "errorMessage";
0061:            private static final String INITIATOR_NAME_LABEL = "initiatorName";
0062:            private static final String ROUTED_BY_USER_NAME_LABEL = "routedByUserName";
0063:            private static final String APP_DOC_ID_LABEL = "appDocId";
0064:            private static final String INITIATOR_ID_LABEL = "initiatorId";
0065:            private static final String ROUTED_BY_USER_ID_LABEL = "routedByUserId";
0066:            private static final String CREATE_DATE_LABEL = "createDate";
0067:            private static final String DOC_STATUS_LABEL = "docStatus";
0068:            private static final String TITLE_LABEL = "title";
0069:            private static final String NOTE_AUTHOR_LABEL = "author";
0070:            private static final String NOTE_ID_LABEL = "noteId";
0071:            private static final String NOTE_TIMESTAMP_LABEL = "timestamp";
0072:            private static final String NOTE_TEXT_LABEL = "noteText";*/
0073:
0074:            /**
0075:             * <ol>
0076:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0077:             * <li>Acknowledge the document with the passed in annotation</li>
0078:             * <li>Return the standard set of return values.</li>
0079:             * </ol>
0080:             *
0081:             * @param docId KEW document id of the document to acknowledge
0082:             * @param userId netid of the user who is acknowledging the document
0083:             * @param annotation a comment associated with this request
0084:             * @return Map including the standard set of return values
0085:             *
0086:             * @see edu.cornell.kew.service.CornellKewService#acknowledge(java.lang.String, java.lang.String, java.lang.String)
0087:             */
0088:            public StandardResponse acknowledge(String docId, String userId,
0089:                    String annotation) {
0090:                //Map<String, Object> results;
0091:                StandardResponse results;
0092:
0093:                try {
0094:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0095:                            docId, userId);
0096:
0097:                    workflowDocument.acknowledge(annotation);
0098:                    results = createResults(workflowDocument);
0099:                } catch (WorkflowException e) {
0100:                    results = createErrorResults("Workflow Error: "
0101:                            + e.getLocalizedMessage());
0102:                }
0103:
0104:                return results;
0105:            }
0106:
0107:            /**
0108:             * <ol>
0109:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0110:             * <li>Set the docTitle and docContent if they are passed in</li>
0111:             * <li>Approve the document with the passed in annotation</li>
0112:             * <li>Return the standard set of return values</li>
0113:             * </ol>
0114:             *
0115:             * @param docId KEW document id of the document to approve
0116:             * @param userId netid of the user who is approving the document
0117:             * @param docTitle title for this document
0118:             * @param docContent xml content for this document
0119:             * @param annotation a comment associated with this request
0120:             * @return Map including the standard set of return values
0121:             *
0122:             * @see edu.cornell.kew.service.CornellKewService#approve(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0123:             */
0124:            public StandardResponse approve(String docId, String userId,
0125:                    String docTitle, String docContent, String annotation) {
0126:                //Map<String, Object> results;
0127:                StandardResponse results;
0128:
0129:                try {
0130:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0131:                            docId, userId, docTitle, docContent);
0132:
0133:                    workflowDocument.approve(annotation);
0134:                    results = createResults(workflowDocument);
0135:                } catch (WorkflowException e) {
0136:                    results = createErrorResults("Workflow Error: "
0137:                            + e.getLocalizedMessage());
0138:                }
0139:
0140:                return results;
0141:            }
0142:
0143:            /**
0144:             * <ol>
0145:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0146:             * <li>Set the docTitle and docContent if they are passed in</li>
0147:             * <li>Blanket Approve the document with the passed in annotation</li>
0148:             * <li>Return the standard set of return values</li>
0149:             * </ol>
0150:             *
0151:             * Blanket Approval means all future approval requests will be satisfied
0152:             * Can only be performed by a super user.
0153:             *
0154:             * @param docId KEW document id of the document to blanket approve
0155:             * @param userId netid of the user who is blanket approving the document
0156:             * @param docTitle title for this document
0157:             * @param docContent xml content for this document
0158:             * @param annotation a comment associated with this request
0159:             * @return Map including the standard set of return values
0160:             *
0161:             * @see edu.cornell.kew.service.CornellKewService#blanketApprove(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0162:             */
0163:            public StandardResponse blanketApprove(String docId, String userId,
0164:                    String docTitle, String docContent, String annotation) {
0165:                //Map<String, Object> results;
0166:                StandardResponse results;
0167:
0168:                try {
0169:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0170:                            docId, userId, docTitle, docContent);
0171:
0172:                    workflowDocument.blanketApprove(annotation);
0173:                    results = createResults(workflowDocument);
0174:                } catch (WorkflowException e) {
0175:                    results = createErrorResults("Workflow Error: "
0176:                            + e.getLocalizedMessage());
0177:                }
0178:
0179:                return results;
0180:            }
0181:
0182:            /**
0183:             * <ol>
0184:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0185:             * <li>Cancel the document with the passed in annotation</li>
0186:             * <li>Return the standard set of return values</li>
0187:             * </ol>
0188:             *
0189:             * @param docId KEW document id of the document to cancel
0190:             * @param userId netid of the user who is canceling the document
0191:             * @param annotation a comment associated with this request
0192:             * @return Map including the standard set of return values
0193:             *
0194:             * @see edu.cornell.kew.service.CornellKewService#cancel(java.lang.String, java.lang.String, java.lang.String)
0195:             */
0196:            public StandardResponse cancel(String docId, String userId,
0197:                    String annotation) {
0198:                //Map<String, Object> results;
0199:                StandardResponse results;
0200:                try {
0201:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0202:                            docId, userId);
0203:
0204:                    workflowDocument.cancel(annotation);
0205:                    results = createResults(workflowDocument);
0206:                } catch (WorkflowException e) {
0207:                    results = createErrorResults("Workflow Error: "
0208:                            + e.getLocalizedMessage());
0209:                }
0210:
0211:                return results;
0212:            }
0213:
0214:            /**
0215:             * <ol>
0216:             * <li>Create a WorkflowDocument with the docType and userId passed in</li>
0217:             * <li>Set the document title to be the docTitle that was passed in</li
0218:             * <li>Save the Routing data (Route Header info)</li>
0219:             * <li>Return the standard set of return values and the docId of the newly created document</li>
0220:             * </ol>
0221:             *
0222:             * @param initiatorId netid of the document initiator
0223:             * @param appDocId application specific document id
0224:             * @param docType KEW document type for the document to be created
0225:             * @param docTitle title for this document
0226:             * @return Map including the standard set of return values and the docId of the newly created document
0227:             *
0228:             * @see edu.cornell.kew.service.CornellKewService#create(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0229:             */
0230:            public DocumentResponse create(String initiatorId, String appDocId,
0231:                    String docType, String docTitle) {
0232:
0233:                // Map<String, Object> results;
0234:                StandardResponse results;
0235:
0236:                String docId = "";
0237:
0238:                try {
0239:                    UserIdVO userIdVO = new NetworkIdVO(initiatorId);
0240:                    WorkflowDocument workflowDocument = new WorkflowDocument(
0241:                            userIdVO, docType);
0242:                    workflowDocument.setTitle(docTitle);
0243:                    workflowDocument.setAppDocId(appDocId);
0244:                    workflowDocument.saveRoutingData();
0245:
0246:                    results = createResults(workflowDocument);
0247:                    if (workflowDocument.getRouteHeaderId() != null) {
0248:                        docId = workflowDocument.getRouteHeaderId().toString();
0249:                    }
0250:                } catch (WorkflowException e) {
0251:                    results = createErrorResults("Workflow Error: "
0252:                            + e.getLocalizedMessage());
0253:                }
0254:
0255:                DocumentResponse docResponse = new DocumentResponse(results);
0256:                docResponse.setDocId(docId);
0257:                //results.put(DOC_ID_LABEL, docId);
0258:
0259:                return docResponse;
0260:            }
0261:
0262:            /**
0263:             * <ol>
0264:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0265:             * <li>Disapprove the document with the passed in annotation</li>
0266:             * <li>Return the standard set of return values</li>
0267:             * </ol>
0268:             *
0269:             * @param docId KEW document id of the document to disapprove
0270:             * @param userId netid of the user who is disapproving the document
0271:             * @param annotation a comment associated with this request
0272:             * @return Map including the standard set of return values
0273:             *
0274:             * @see edu.cornell.kew.service.CornellKewService#disapprove(java.lang.String, java.lang.String, java.lang.String)
0275:             */
0276:            public StandardResponse disapprove(String docId, String userId,
0277:                    String annotation) {
0278:                //      Map<String, Object> results;
0279:                StandardResponse results;
0280:
0281:                try {
0282:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0283:                            docId, userId);
0284:
0285:                    workflowDocument.disapprove(annotation);
0286:                    results = createResults(workflowDocument);
0287:                } catch (WorkflowException e) {
0288:                    results = createErrorResults("Workflow Error: "
0289:                            + e.getLocalizedMessage());
0290:                }
0291:
0292:                return results;
0293:            }
0294:
0295:            /**
0296:             * <ol>
0297:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0298:             * <li>Clear the FYI request on the document</li>
0299:             * <li>Return the standard set of return values</li>
0300:             * </ol>
0301:             *
0302:             * @param docId KEW document id of the document to acknowledge
0303:             * @param userId netid of the user who is acknowledging the document
0304:             * @return Map including the standard set of return values
0305:             *
0306:             * @see edu.cornell.kew.service.CornellKewService#fyi(java.lang.String, java.lang.String)
0307:             */
0308:            public StandardResponse fyi(String docId, String userId) {
0309:                //		Map<String, Object> results;
0310:                StandardResponse results;
0311:
0312:                try {
0313:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0314:                            docId, userId);
0315:
0316:                    workflowDocument.fyi();
0317:                    results = createResults(workflowDocument);
0318:                } catch (WorkflowException e) {
0319:                    results = createErrorResults("Workflow Error: "
0320:                            + e.getLocalizedMessage());
0321:                }
0322:
0323:                return results;
0324:            }
0325:
0326:            /**
0327:             * <ol>
0328:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0329:             * <li>Get the document content and the action requested (Approve, Acknowledge, etc) of the user</li>
0330:             * <li>Return the standard set of return values, the docContent, the title,
0331:             * and the actionRequested</li>
0332:             * </ol>
0333:             *
0334:             * @param docId KEW document id of the document to retrieve information about
0335:             * @param userId netid of the user to retrieve the document for
0336:             * @return Map including the standard set of return values, the xml document content,
0337:             * the action requested ( Approve, Aknowledge, Fyi, Complete ) and an array of Maps
0338:             * containing the following for each Note (author, noteId, timestamp, noteText).
0339:             *
0340:             * @see edu.cornell.kew.service.CornellKewService#getDocument(java.lang.String, java.lang.String)
0341:             */
0342:            public DocumentResponse getDocument(String docId, String userId) {
0343:                //		Map<String, Object> results;
0344:                StandardResponse results;
0345:                List<NoteDetail> noteDetails = new ArrayList<NoteDetail>(0);
0346:                String actionRequested = "";
0347:                String docContent = "";
0348:                String title = "";
0349:
0350:                try {
0351:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0352:                            docId, userId);
0353:                    RouteHeaderVO routeHeader = workflowDocument
0354:                            .getRouteHeader();
0355:
0356:                    if (routeHeader == null) {
0357:                        results = createErrorResults("Error: NULL Route Header");
0358:                    } else {
0359:                        results = createStandardResults(routeHeader);
0360:                        docContent = workflowDocument.getApplicationContent();
0361:                        title = workflowDocument.getTitle();
0362:                        List notes = workflowDocument.getNoteList();
0363:                        noteDetails = buildNoteDetails(notes);
0364:
0365:                        if (routeHeader.isApproveRequested()) {
0366:                            actionRequested = EdenConstants.ACTION_REQUEST_APPROVE_REQ_LABEL;
0367:                        } else if (routeHeader.isAckRequested()) {
0368:                            actionRequested = EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL;
0369:                        } else if (routeHeader.isFyiRequested()) {
0370:                            actionRequested = EdenConstants.ACTION_REQUEST_FYI_REQ_LABEL;
0371:                        } else if (routeHeader.isCompleteRequested()) {
0372:                            // TODO: how do we want to handle a "Complete" request?
0373:                            actionRequested = EdenConstants.ACTION_REQUEST_COMPLETE_REQ_LABEL;
0374:                        }
0375:                    }
0376:                } catch (WorkflowException e) {
0377:                    results = createErrorResults("Workflow Error: "
0378:                            + e.getLocalizedMessage());
0379:                }
0380:
0381:                DocumentResponse docResponse = new DocumentResponse(results);
0382:
0383:                //		results.put(DOC_CONTENT_LABEL, docContent);
0384:                //		results.put(TITLE_LABEL, title);
0385:                //		results.put(NOTES_LABEL, noteDetails);
0386:                //		results.put(ACTION_REQUESTED_LABEL, actionRequested);
0387:
0388:                docResponse.setDocId(docId);
0389:                docResponse.setDocContent(docContent);
0390:                docResponse.setTitle(title);
0391:                docResponse.setNotes(noteDetails);
0392:                docResponse.setActionRequested(actionRequested);
0393:
0394:                return docResponse;
0395:            }
0396:
0397:            /**
0398:             * <ol>
0399:             * <li>Create a new WorkflowInfo object</li>
0400:             * <li>Call isUserAuthenticatedByRouteLog on the WorkflowInfo object to see if the user is in the route log</li>
0401:             * <li>Return True/False and an error message if any</li>
0402:             * </ol>
0403:             * Useful for security purposes (if return is False, user shouldn't
0404:             * be able to see the document unless it's public.)
0405:             *
0406:             * Call isUserAuthenticatedByRouteLog with true for the lookFuture parameter so that
0407:             * we will check future workflow requests as well as currently outstanding requests.
0408:             *
0409:             * @param docId KEW document id of the document to check
0410:             * @param userId netid of the user to check
0411:             * @return Map containing True/False for isUserInRouteLog and an error message if
0412:             * a problem occured
0413:             *
0414:             * @see edu.cornell.kew.service.CornellKewService#isUserInRouteLog(java.lang.String, java.lang.String)
0415:             */
0416:            public UserInRouteLogResponse isUserInRouteLog(String docId,
0417:                    String userId) {
0418:                //Map<String, Object> results = new HashMap<String, Object>(6);
0419:
0420:                UserInRouteLogResponse results = new UserInRouteLogResponse();
0421:                String errorMessage = "";
0422:                boolean isUserInRouteLog = false;
0423:                WorkflowInfo info = new WorkflowInfo();
0424:                try {
0425:                    Long id = Long.parseLong(docId);
0426:                    UserIdVO userIdVO = new NetworkIdVO(userId);
0427:
0428:                    isUserInRouteLog = info.isUserAuthenticatedByRouteLog(id,
0429:                            userIdVO, true);
0430:                } catch (NumberFormatException e) {
0431:                    errorMessage = "Invalid (non-numeric) docId";
0432:                } catch (WorkflowException e) {
0433:                    errorMessage = "Workflow Error: " + e.getLocalizedMessage();
0434:                }
0435:
0436:                //		results.put(IS_USER_IN_ROUTE_LOG_LABEL, String.valueOf(isUserInRouteLog));
0437:                //		results.put(ERROR_MESSAGE_LABEL, errorMessage);
0438:
0439:                results.setIsUserInRouteLog(String.valueOf(isUserInRouteLog));
0440:                results.setErrorMessage(errorMessage);
0441:                return results;
0442:            }
0443:
0444:            /**
0445:             * <ol>
0446:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0447:             * <li>Add the adhoc acknowlege request (app specific route) to the passed in group with the passed in annotation</li>
0448:             * <li>Return the standard set of return values</li>
0449:             * </ol>
0450:             *
0451:             * @param docId KEW document id of the document to create the adhoc request for
0452:             * @param userId netid of the user who is making this request
0453:             * @param recipientGroupId workgroupId of the group to create this request for
0454:             * @param annotation a comment associated with this request
0455:             * @return Map including the standard set of return values
0456:             *
0457:             * @see edu.cornell.kew.service.CornellKewService#requestAdHocAckToGroup(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0458:             */
0459:            public StandardResponse requestAdHocAckToGroup(String docId,
0460:                    String userId, String recipientGroupId, String annotation) {
0461:                return requestAdHocToGroup(docId, userId, recipientGroupId,
0462:                        annotation,
0463:                        EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
0464:                        EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
0465:            }
0466:
0467:            /**
0468:             * <ol>
0469:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0470:             * <li>Add the adhoc acknowlege request (app specific route) to the passed in user with the passed in annotation</li>
0471:             * <li>Return the standard set of return values</li>
0472:             * </ol>
0473:             *
0474:             * @param docId KEW document id of the document to create the adhoc request for
0475:             * @param userId netid of the user who is making this request
0476:             * @param recipientUserId netid of the user for whom the request is being created
0477:             * @param annotation a comment associated with this request
0478:             * @return Map including the standard set of return values
0479:             *
0480:             * @see edu.cornell.kew.service.CornellKewService#requestAdHocAckToUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0481:             */
0482:            public StandardResponse requestAdHocAckToUser(String docId,
0483:                    String userId, String recipientUserId, String annotation) {
0484:                return requestAdHocToUser(docId, userId, recipientUserId,
0485:                        annotation,
0486:                        EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
0487:                        EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
0488:            }
0489:
0490:            /**
0491:             * <ol>
0492:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0493:             * <li>Add the adhoc approve request (app specific route) to the passed in group with the passed in annotation</li>
0494:             * <li>Return the standard set of return values</li>
0495:             * </ol>
0496:             *
0497:             * @param docId KEW document id of the document to create the adhoc request for
0498:             * @param userId netid of the user who is making this request
0499:             * @param recipientGroupId workgroupId of the group to create this request for
0500:             * @param annotation a comment associated with this request
0501:             * @return Map including the standard set of return values
0502:             *
0503:             * @see edu.cornell.kew.service.CornellKewService#requestAdHocApproveToGroup(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0504:             */
0505:            public StandardResponse requestAdHocApproveToGroup(String docId,
0506:                    String userId, String recipientGroupId, String annotation) {
0507:                return requestAdHocToGroup(docId, userId, recipientGroupId,
0508:                        annotation, EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0509:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ_LABEL);
0510:            }
0511:
0512:            /**
0513:             * <ol>
0514:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0515:             * <li>Add the adhoc approve request (app specific route) to the passed in user with the passed in annotation</li>
0516:             * <li>Return the standard set of return values</li>
0517:             * </ol>
0518:             *
0519:             * @param docId KEW document id of the document to create the adhoc request for
0520:             * @param userId netid of the user who is making this request
0521:             * @param recipientUserId netid of the user for whom the request is being created
0522:             * @param annotation a comment associated with this request
0523:             * @return Map including the standard set of return values
0524:             *
0525:             * @see edu.cornell.kew.service.CornellKewService#requestAdHocApproveToUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0526:             */
0527:            public StandardResponse requestAdHocApproveToUser(String docId,
0528:                    String userId, String recipientUserId, String annotation) {
0529:
0530:                return requestAdHocToUser(docId, userId, recipientUserId,
0531:                        annotation, EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0532:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ_LABEL);
0533:            }
0534:
0535:            /**
0536:             * <ol>
0537:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0538:             * <li>Add the adhoc fyi request (app specific route) to the passed in group with the passed in annotation</li>
0539:             * <li>Return the standard set of return values</li>
0540:             * </ol>
0541:             *
0542:             * @param docId KEW document id of the document to create the adhoc request for
0543:             * @param userId netid of the user who is making this request
0544:             * @param recipientGroupId workgroupId of the group to create this request for
0545:             * @param annotation a comment associated with this request
0546:             * @return Map including the standard set of return values
0547:             *
0548:             * @see edu.cornell.kew.service.CornellKewService#requestAdHocFyiToGroup(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0549:             */
0550:            public StandardResponse requestAdHocFyiToGroup(String docId,
0551:                    String userId, String recipientGroupId, String annotation) {
0552:                return requestAdHocToGroup(docId, userId, recipientGroupId,
0553:                        annotation, EdenConstants.ACTION_REQUEST_FYI_REQ,
0554:                        EdenConstants.ACTION_REQUEST_FYI_REQ_LABEL);
0555:            }
0556:
0557:            /**
0558:             * <ol>
0559:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0560:             * <li>Add the adhoc fyi request (app specific route) to the passed in user with the passed in annotation</li>
0561:             * <li>Return the standard set of return values</li>
0562:             * </ol>
0563:             *
0564:             * @param docId KEW document id of the document to create the adhoc request for
0565:             * @param userId netid of the user who is making this request
0566:             * @param recipientUserId netid of the user for whom the request is being created
0567:             * @param annotation a comment associated with this request
0568:             * @return Map including the standard set of return values
0569:             *
0570:             * @see edu.cornell.kew.service.CornellKewService#requestAdHocFyiToUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0571:             */
0572:            public StandardResponse requestAdHocFyiToUser(String docId,
0573:                    String userId, String recipientUserId, String annotation) {
0574:                return requestAdHocToUser(docId, userId, recipientUserId,
0575:                        annotation, EdenConstants.ACTION_REQUEST_FYI_REQ,
0576:                        EdenConstants.ACTION_REQUEST_FYI_REQ_LABEL);
0577:            }
0578:
0579:            /**
0580:             * Create the adhoc request for the specified group.
0581:             *
0582:             * @param docId KEW document id of the document to create the adhoc request for
0583:             * @param userId netid of the user who is making this request
0584:             * @param recipientGroupId workflowid of the group for whom the request is being created
0585:             * @param annotation a comment associated with this request
0586:             * @param actionRequested the action for this adhoc request ( A)pprove, aK)nowledge, F)yi )
0587:             * @param responsibilityDesc description of the type of responsibility for this request
0588:             * @return Map including the standard set of return values
0589:             */
0590:            private StandardResponse requestAdHocToGroup(String docId,
0591:                    String userId, String recipientGroupId, String annotation,
0592:                    String actionRequested, String responsibilityDesc) {
0593:                //      Map<String, Object> results;
0594:                StandardResponse results;
0595:
0596:                try {
0597:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0598:                            docId, userId);
0599:
0600:                    WorkgroupIdVO recipientId = new WorkgroupNameIdVO(
0601:                            recipientGroupId);
0602:                    // TODO: what should we put in the responsibility description?
0603:                    workflowDocument.appSpecificRouteDocumentToWorkgroup(
0604:                            actionRequested, annotation, recipientId,
0605:                            responsibilityDesc, true);
0606:                    results = createResults(workflowDocument);
0607:                } catch (WorkflowException e) {
0608:                    results = createErrorResults("Workflow Error: "
0609:                            + e.getLocalizedMessage());
0610:                }
0611:
0612:                return results;
0613:            }
0614:
0615:            /**
0616:             * Create the adhoc request for the specified user.
0617:             *
0618:             * @param docId KEW document id of the document to create the adhoc request for
0619:             * @param userId netid of the user who is making this request
0620:             * @param recipientUserId netid of the user for whom the request is being created
0621:             * @param annotation a comment associated with this request
0622:             * @param actionRequested the action for this adhoc request ( A)pprove, aK)nowledge, F)yi )
0623:             * @param responsibilityDesc description of the type of responsibility for this request
0624:             * @return Map including the standard set of return values
0625:             */
0626:            private StandardResponse requestAdHocToUser(String docId,
0627:                    String userId, String recipientUserId, String annotation,
0628:                    String actionRequested, String responsibilityDesc) {
0629:                //		Map<String, Object> results;
0630:                StandardResponse results;
0631:
0632:                try {
0633:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0634:                            docId, userId);
0635:
0636:                    UserIdVO recipientId = new NetworkIdVO(recipientUserId);
0637:                    // TODO: what should we put in the responsibility description?
0638:                    workflowDocument.appSpecificRouteDocumentToUser(
0639:                            actionRequested, annotation, recipientId,
0640:                            responsibilityDesc, true);
0641:                    results = createResults(workflowDocument);
0642:                } catch (WorkflowException e) {
0643:                    results = createErrorResults("Workflow Error: "
0644:                            + e.getLocalizedMessage());
0645:                }
0646:
0647:                return results;
0648:            }
0649:
0650:            /**
0651:             * <ol>
0652:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0653:             * <li>Set the docTitle and docContent if they are passed in</li>
0654:             * <li>Route the document with the passed in annotation</li>
0655:             * <li>Return the standard set of return values.</li>
0656:             * </ol>
0657:             *
0658:             * @param docId KEW document id of the document to route
0659:             * @param userId netid of the user who is routing the document
0660:             * @param docTitle title for this document
0661:             * @param docContent xml content for this document
0662:             * @param annotation a comment associated with this request
0663:             * @return Map including the standard set of return values
0664:             *
0665:             * @see edu.cornell.kew.service.CornellKewService#route(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0666:             */
0667:            public StandardResponse route(String docId, String userId,
0668:                    String docTitle, String docContent, String annotation) {
0669:
0670:                //Map<String, Object> results;
0671:                StandardResponse results;
0672:
0673:                try {
0674:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0675:                            docId, userId, docTitle, docContent);
0676:
0677:                    workflowDocument.routeDocument(annotation);
0678:                    results = createResults(workflowDocument);
0679:                } catch (WorkflowException e) {
0680:                    results = createErrorResults("Workflow Error: "
0681:                            + e.getLocalizedMessage());
0682:                }
0683:
0684:                return results;
0685:            }
0686:
0687:            /**
0688:             * <ol>
0689:             * <li>Create a WorkflowDocument based on the docId and userId passed in</li>
0690:             * <li>Set the docTitle if it was passed in</li>
0691:             * <li>Save the document with the passed in annotation (keep in user's action list)</li>
0692:             * <li>Return the standard set of return values.</li>
0693:             * </ol>
0694:             *
0695:             * @param docId KEW document id of the document to save
0696:             * @param userId netid of the user who is saving the document
0697:             * @param docTitle title for this document
0698:             * @param annotation a comment associated with this request
0699:             * @return Map including the standard set of return values
0700:             *
0701:             * @see edu.cornell.kew.service.CornellKewService#save(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0702:             */
0703:            public StandardResponse save(String docId, String userId,
0704:                    String docTitle, String annotation) {
0705:                //		Map<String, Object> results;
0706:
0707:                StandardResponse results;
0708:
0709:                try {
0710:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0711:                            docId, userId, docTitle);
0712:                    workflowDocument.saveDocument(annotation);
0713:                    results = createResults(workflowDocument);
0714:                } catch (WorkflowException e) {
0715:                    results = createErrorResults("Workflow Error: "
0716:                            + e.getLocalizedMessage());
0717:                }
0718:
0719:                return results;
0720:            }
0721:
0722:            /**
0723:             * Add a note to this KEW document.
0724:             *
0725:             * @param docId KEW document id of the document to add the note to
0726:             * @param userId netid of the user who is adding the note
0727:             * @param noteText text of the note
0728:             * @return Map containing relevant note information (author, noteId, timestamp, noteText)
0729:             * along with an error message (if any)
0730:             *
0731:             * @see edu.cornell.kew.service.CornellKewService#addNote(java.lang.String, java.lang.String, java.lang.String)
0732:             */
0733:            public NoteResponse addNote(String docId, String userId,
0734:                    String noteText) {
0735:                //		Map<String, Object> results = new HashMap<String, Object>(5);
0736:                NoteResponse results = new NoteResponse();
0737:
0738:                String author = "";
0739:                String noteId = "";
0740:                String timestamp = "";
0741:                String resultsNoteText = "";
0742:                String errorMessage = "";
0743:
0744:                //		results.put(ERROR_MESSAGE_LABEL, "");
0745:
0746:                results.setErrorMessage("");
0747:
0748:                try {
0749:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0750:                            docId, userId);
0751:
0752:                    // setup note
0753:                    NoteVO noteVO = new NoteVO();
0754:                    noteVO.setNoteAuthorWorkflowId(userId);
0755:                    noteVO.setNoteCreateDate(new GregorianCalendar());
0756:                    noteVO.setNoteText(noteText);
0757:                    noteVO
0758:                            .setRouteHeaderId(workflowDocument
0759:                                    .getRouteHeaderId());
0760:                    workflowDocument.updateNote(noteVO);
0761:
0762:                    //TODO: is this necessary?
0763:                    workflowDocument.saveRoutingData();
0764:                    RouteHeaderVO routeHeader = workflowDocument
0765:                            .getRouteHeader();
0766:
0767:                    //TODO: do we need to return the standard result set?
0768:                    //results = createResults(workflowDocument);
0769:
0770:                    noteVO = routeHeader.getNotes()[routeHeader.getNotes().length - 1];
0771:
0772:                    // return note info
0773:                    UserIdVO userIdVO = new NetworkIdVO(noteVO
0774:                            .getNoteAuthorWorkflowId());
0775:                    WorkflowInfo info = new WorkflowInfo();
0776:                    UserVO user = info.getWorkflowUser(userIdVO);
0777:                    author = user.getDisplayName();
0778:                    noteId = noteVO.getNoteId().toString();
0779:                    timestamp = formatCalendar(noteVO.getNoteCreateDate());
0780:                    resultsNoteText = noteVO.getNoteText();
0781:                } catch (WorkflowException e) {
0782:                    errorMessage = "Workflow Error: " + e.getLocalizedMessage();
0783:                }
0784:
0785:                //		results.put(NOTE_AUTHOR_LABEL, author);
0786:                //		results.put(NOTE_ID_LABEL, noteId);
0787:                //		results.put(NOTE_TIMESTAMP_LABEL, timestamp);
0788:                //		results.put(NOTE_TEXT_LABEL, resultsNoteText);
0789:                //		results.put(ERROR_MESSAGE_LABEL, errorMessage);
0790:
0791:                results.setAuthor(author);
0792:                results.setNoteId(noteId);
0793:                results.setTimestamp(timestamp);
0794:                results.setNoteText(resultsNoteText);
0795:                results.setErrorMessage(errorMessage);
0796:
0797:                return results;
0798:            }
0799:
0800:            /**
0801:             * Update an existing note to this KEW document.
0802:             *
0803:             * @param docId KEW document id of the document to update the note for
0804:             * @param noteId the id of the note to update
0805:             * @param userId netid of the user who is updating the note
0806:             * @param noteText text of the note if changed
0807:             * @return Map containing relevant note information (author, noteId, timestamp, noteText)
0808:             * along with an error message (if any)
0809:             *
0810:             * @see edu.cornell.kew.service.CornellKewService#updateNote(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
0811:             */
0812:            public NoteResponse updateNote(String docId, String noteId,
0813:                    String userId, String noteText) {
0814:                //		Map<String, Object> results = new HashMap<String, Object>(5);
0815:                String author = "";
0816:                String resultsNoteId = "";
0817:                String timestamp = "";
0818:                String resultsNoteText = "";
0819:                String errorMessage = "";
0820:
0821:                try {
0822:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0823:                            docId, userId);
0824:                    RouteHeaderVO routeHeader = workflowDocument
0825:                            .getRouteHeader();
0826:
0827:                    // setup note
0828:                    NoteVO noteVO = getNote(routeHeader.getNotes(), noteId);
0829:                    noteVO.setNoteText(noteText);
0830:                    workflowDocument.updateNote(noteVO);
0831:
0832:                    //TODO: is this necessary?
0833:                    workflowDocument.saveRoutingData();
0834:                    routeHeader = workflowDocument.getRouteHeader();
0835:
0836:                    //TODO: do we need to return the standard result set?
0837:                    //results = createResults(workflowDocument);
0838:
0839:                    noteVO = getNote(routeHeader.getNotes(), noteId);
0840:
0841:                    if (noteVO == null) {
0842:                        errorMessage = "Error retrieving note for id ["
0843:                                + noteId + "].";
0844:                    } else {
0845:                        // return note info
0846:                        UserIdVO userIdVO = new NetworkIdVO(noteVO
0847:                                .getNoteAuthorWorkflowId());
0848:                        WorkflowInfo info = new WorkflowInfo();
0849:                        UserVO user = info.getWorkflowUser(userIdVO);
0850:                        author = user.getDisplayName();
0851:                        resultsNoteId = noteVO.getNoteId().toString();
0852:                        timestamp = formatCalendar(noteVO.getNoteCreateDate());
0853:                        resultsNoteText = noteVO.getNoteText();
0854:                    }
0855:                } catch (WorkflowException e) {
0856:                    errorMessage = "Workflow Error: " + e.getLocalizedMessage();
0857:                }
0858:
0859:                NoteResponse results = new NoteResponse();
0860:
0861:                //		results.put(NOTE_AUTHOR_LABEL, author);
0862:                //		results.put(NOTE_ID_LABEL, resultsNoteId);
0863:                //		results.put(NOTE_TIMESTAMP_LABEL, timestamp);
0864:                //		results.put(NOTE_TEXT_LABEL, resultsNoteText);
0865:                //		results.put(ERROR_MESSAGE_LABEL, errorMessage);
0866:
0867:                results.setAuthor(author);
0868:                results.setNoteId(resultsNoteId);
0869:                results.setTimestamp(timestamp);
0870:                results.setNoteText(resultsNoteText);
0871:                results.setErrorMessage(errorMessage);
0872:
0873:                return results;
0874:            }
0875:
0876:            /**
0877:             * Delete an existing note.
0878:             *
0879:             * @param docId KEW document id of the document to delete the note from
0880:             * @param noteId the id of the note to delete
0881:             * @param userId netid of the user who is deleting the note
0882:             * @return Map containing an error message if any
0883:             *
0884:             * @see edu.cornell.kew.service.CornellKewService#deleteNote(java.lang.String, java.lang.String, java.lang.String)
0885:             */
0886:            public ErrorResponse deleteNote(String docId, String noteId,
0887:                    String userId) {
0888:                //Map<String, Object> results = new HashMap<String, Object>(1);
0889:
0890:                ErrorResponse results = new ErrorResponse();
0891:
0892:                String errorMessage = "";
0893:
0894:                try {
0895:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0896:                            docId, userId);
0897:                    RouteHeaderVO routeHeader = workflowDocument
0898:                            .getRouteHeader();
0899:
0900:                    // setup note
0901:                    NoteVO noteVO = getNote(routeHeader.getNotes(), noteId);
0902:                    workflowDocument.deleteNote(noteVO);
0903:
0904:                    //TODO: is this necessary?
0905:                    workflowDocument.saveRoutingData();
0906:
0907:                    ////	      update notes database based on notes and notesToDelete arrays in routeHeaderVO
0908:                    //	        BeanConverter.updateNotes(routeHeader, routeHeader.getRouteHeaderId());
0909:                } catch (WorkflowException e) {
0910:                    errorMessage = "Workflow Error: " + e.getLocalizedMessage();
0911:                }
0912:                //results.put(ERROR_MESSAGE_LABEL, errorMessage);
0913:
0914:                results.setErrorMessage(errorMessage);
0915:
0916:                return results;
0917:            }
0918:
0919:            /**
0920:             * Return a KEW document to a previous route node.  This method should
0921:             * be used with caution.
0922:             *
0923:             * @param annotation a comment associated with this request
0924:             * @param nodeName name of the route node to return to
0925:             * @return Map including the standard set of return values
0926:             *
0927:             * @see edu.cornell.kew.service.CornellKewService#returnToPreviousNode(java.lang.String, java.lang.String)
0928:             */
0929:            public StandardResponse returnToPreviousNode(String docId,
0930:                    String userId, String annotation, String nodeName) {
0931:                //Map<String, Object> results;
0932:
0933:                StandardResponse results;
0934:
0935:                try {
0936:                    WorkflowDocument workflowDocument = setupWorkflowDocument(
0937:                            docId, userId);
0938:
0939:                    workflowDocument.returnToPreviousNode(annotation, nodeName);
0940:                    results = createResults(workflowDocument);
0941:                } catch (WorkflowException e) {
0942:                    results = createErrorResults("Workflow Error: "
0943:                            + e.getLocalizedMessage());
0944:                }
0945:
0946:                return results;
0947:            }
0948:
0949:            private NoteVO getNote(NoteVO[] notes, String noteId) {
0950:                NoteVO note = null;
0951:
0952:                if (notes != null) {
0953:                    for (int i = 0; i < notes.length; i++) {
0954:                        if (notes[i].getNoteId().toString().equals(noteId)) {
0955:                            note = notes[i];
0956:                            break;
0957:                        }
0958:                    }
0959:                }
0960:
0961:                return note;
0962:            }
0963:
0964:            /**
0965:             * Convenience method to setup workflow document without title or content.
0966:             *
0967:             * @param docId KEW document id for the document to setup
0968:             * @param userId KEW netid for the user associated with this document
0969:             * @return populated WorkflowDocument object
0970:             * @throws WorkflowException if something goes wrong
0971:             */
0972:            private WorkflowDocument setupWorkflowDocument(String docId,
0973:                    String userId) throws WorkflowException {
0974:                return setupWorkflowDocument(docId, userId, null, null);
0975:            }
0976:
0977:            /**
0978:             * Convenience method to setup workflow document without content.
0979:             *
0980:             * @param docId KEW document id for the document to setup
0981:             * @param userId KEW netid for the user associated with this document
0982:             * @param docTitle title for this document
0983:             * @return populated WorkflowDocument object
0984:             * @throws WorkflowException if something goes wrong
0985:             */
0986:            private WorkflowDocument setupWorkflowDocument(String docId,
0987:                    String userId, String docTitle) throws WorkflowException {
0988:                return setupWorkflowDocument(docId, userId, docTitle, null);
0989:            }
0990:
0991:            /**
0992:             * Instantiate and setup the WorkflowDocument object.
0993:             *
0994:             * @param docId KEW document id for the document to setup
0995:             * @param userId KEW netid for the user associated with this document
0996:             * @param docTitle title for this document
0997:             * @param docContent xml content for this document
0998:             * @return populated WorkflowDocument object
0999:             * @throws WorkflowException if something goes wrong
1000:             */
1001:            private WorkflowDocument setupWorkflowDocument(String docId,
1002:                    String userId, String docTitle, String docContent)
1003:                    throws WorkflowException {
1004:                UserIdVO userIdVO = new NetworkIdVO(userId);
1005:                WorkflowDocument workflowDocument = new WorkflowDocument(
1006:                        userIdVO, Long.decode(docId));
1007:                if (StringUtils.isNotEmpty(docTitle)) {
1008:                    workflowDocument.setTitle(docTitle);
1009:                }
1010:                if (StringUtils.isNotEmpty(docContent)) {
1011:                    workflowDocument.setApplicationContent(docContent);
1012:                }
1013:                return workflowDocument;
1014:            }
1015:
1016:            /**
1017:             * Create the note details result set.
1018:             *
1019:             * @param notes List of notes to build details Map array for
1020:             * @return Map[] containing note details
1021:             * @throws WorkflowException if an error occurs retrieving user display name
1022:             */
1023:            private List<NoteDetail> buildNoteDetails(List notes)
1024:                    throws WorkflowException {
1025:                List<NoteDetail> noteDetails;
1026:
1027:                if (notes == null) {
1028:                    noteDetails = new ArrayList<NoteDetail>(0);
1029:                } else {
1030:                    noteDetails = new ArrayList<NoteDetail>(notes.size());
1031:                    for (int i = 0; i < notes.size(); i++) {
1032:                        //Map<String, String> noteDetail = new HashMap<String, String>(4);
1033:
1034:                        NoteDetail noteDetail = new NoteDetail();
1035:                        NoteVO note = (NoteVO) notes.get(i);
1036:                        //author, noteId, timestamp, noteText
1037:                        UserIdVO userIdVO = new WorkflowIdVO(note
1038:                                .getNoteAuthorWorkflowId());
1039:                        WorkflowInfo info = new WorkflowInfo();
1040:                        UserVO user = info.getWorkflowUser(userIdVO);
1041:                        //noteDetail.put(NOTE_AUTHOR_LABEL, user.getDisplayName());
1042:                        //noteDetail.put(NOTE_ID_LABEL, note.getNoteId().toString());
1043:                        //noteDetail.put(NOTE_TIMESTAMP_LABEL, formatCalendar(note.getNoteCreateDate()));
1044:                        //noteDetail.put(NOTE_TEXT_LABEL, note.getNoteText());
1045:
1046:                        noteDetail.setAuthor(user.getDisplayName());
1047:                        noteDetail.setId(note.getNoteId().toString());
1048:                        noteDetail.setTimestamp(formatCalendar(note
1049:                                .getNoteCreateDate()));
1050:                        noteDetail.setNoteText(note.getNoteText());
1051:
1052:                        noteDetails.add(noteDetail);
1053:                    }
1054:                }
1055:
1056:                return noteDetails;
1057:            }
1058:
1059:            /**
1060:             * Create the result set, either the standard results or error results
1061:             * if the routeHeader is null.
1062:             *
1063:             * @param workflowDocument WorkflowDocument used to get route header info
1064:             * @return Map containing results of the call (either standard or error version)
1065:             */
1066:            private StandardResponse createResults(
1067:                    WorkflowDocument workflowDocument) {
1068:                //Map<String, Object> results;
1069:
1070:                StandardResponse response;
1071:
1072:                RouteHeaderVO routeHeader = workflowDocument.getRouteHeader();
1073:
1074:                if (routeHeader == null) {
1075:                    response = createErrorResults("Error: NULL Route Header");
1076:                } else {
1077:                    response = createStandardResults(routeHeader);
1078:                }
1079:
1080:                return response;
1081:            }
1082:
1083:            /**
1084:             * Create the standard result set with only the error message populated.
1085:             *
1086:             * @param errorMessage the message describing what error occured in the KEW engine
1087:             * @return Map containing the standard result set with only the error message populated
1088:             */
1089:            private StandardResponse createErrorResults(String errorMessage) {
1090:                //		Map<String, Object> results = new HashMap<String, Object>(6);
1091:                StandardResponse response = new StandardResponse();
1092:                //		results.put(DOC_STATUS_LABEL, "");
1093:                //		results.put(CREATE_DATE_LABEL, "");
1094:                //		results.put(INITIATOR_ID_LABEL, "");
1095:                //        results.put(ROUTED_BY_USER_ID_LABEL, "");
1096:                //		results.put(APP_DOC_ID_LABEL, "");
1097:                //		results.put(INITIATOR_NAME_LABEL, "");
1098:                //        results.put(ROUTED_BY_USER_NAME_LABEL, "");
1099:                //		results.put(ERROR_MESSAGE_LABEL, errorMessage);
1100:
1101:                response.setDocStatus("");
1102:                response.setCreateDate("");
1103:                response.setInitiatorId("");
1104:                response.setRoutedByUserId("");
1105:                response.setAppDocId("");
1106:                response.setInitiatorName("");
1107:                response.setRoutedByUserName("");
1108:                response.setErrorMessage(errorMessage);
1109:
1110:                return response;
1111:            }
1112:
1113:            /**
1114:             * Create the standard result set populated with values contained in the
1115:             * documents route header.
1116:             *
1117:             * @param routeHeader RouteHeaderVO for this document
1118:             * @return Map containing the standard result set populated with values contained in the
1119:             * documents route header.
1120:             */
1121:            private StandardResponse createStandardResults(
1122:                    RouteHeaderVO routeHeader) {
1123:                String docStatus = "";
1124:                String createDate = "";
1125:                String initiatorId = "";
1126:                String routedByUserId = "";
1127:                String appDocId = "";
1128:                String initiatorName = "";
1129:                String routedByUserName = "";
1130:                String errorMessage = "";
1131:
1132:                if (routeHeader == null) {
1133:                    errorMessage = "Error: NULL Route Header";
1134:                } else {
1135:                    if (routeHeader.getDocRouteStatus() == null) {
1136:                        errorMessage = "Error: NULL Route Status; ";
1137:                    } else {
1138:                        docStatus = routeHeader.getDocRouteStatus();
1139:                    }
1140:
1141:                    if (routeHeader.getDateCreated() == null) {
1142:                        errorMessage += "Error: NULL Date Created; ";
1143:                    } else {
1144:                        createDate = formatCalendar(routeHeader
1145:                                .getDateCreated());
1146:                    }
1147:
1148:                    if (routeHeader.getInitiator() == null) {
1149:                        errorMessage += "Error: NULL Initiator; ";
1150:                    } else {
1151:                        initiatorId = routeHeader.getInitiator().getNetworkId();
1152:                        initiatorName = routeHeader.getInitiator()
1153:                                .getDisplayName();
1154:                    }
1155:
1156:                    if (routeHeader.getRoutedByUser() == null) {
1157:                        // of the document has been routed, but there is no routed-by user, that is an error
1158:                        if (EdenConstants.ROUTE_HEADER_ENROUTE_CD
1159:                                .equals(routeHeader.getDocRouteStatus())) {
1160:                            errorMessage += "Error: NULL routedBy user; ";
1161:                        }
1162:                    } else {
1163:                        routedByUserId = routeHeader.getRoutedByUser()
1164:                                .getNetworkId();
1165:                        routedByUserName = routeHeader.getRoutedByUser()
1166:                                .getDisplayName();
1167:                    }
1168:
1169:                    if (routeHeader.getAppDocId() != null) {
1170:                        appDocId = routeHeader.getAppDocId();
1171:                    }
1172:                }
1173:
1174:                //Map<String, Object> results = new HashMap<String, Object>(6);
1175:                StandardResponse response = new StandardResponse();
1176:
1177:                //		results.put(DOC_STATUS_LABEL, docStatus);
1178:                //		results.put(CREATE_DATE_LABEL, createDate);
1179:                //		results.put(INITIATOR_ID_LABEL, initiatorId);
1180:                //        results.put(ROUTED_BY_USER_ID_LABEL, routedByUserId);
1181:                //		results.put(APP_DOC_ID_LABEL, appDocId);
1182:                //		results.put(INITIATOR_NAME_LABEL, initiatorName);
1183:                //        results.put(ROUTED_BY_USER_NAME_LABEL, routedByUserName);
1184:                //		results.put(ERROR_MESSAGE_LABEL, errorMessage);
1185:
1186:                response.setDocStatus(docStatus);
1187:                response.setCreateDate(createDate);
1188:                response.setInitiatorId(initiatorId);
1189:                response.setRoutedByUserId(routedByUserId);
1190:                response.setAppDocId(appDocId);
1191:                response.setInitiatorName(initiatorName);
1192:                response.setRoutedByUserName(routedByUserName);
1193:                response.setErrorMessage(errorMessage);
1194:
1195:                return response;
1196:            }
1197:
1198:            /**
1199:             * Format a String date based on a given Calendar object.
1200:             *
1201:             * @param calendar Calendar date to format
1202:             * @return String formatted date
1203:             */
1204:            private String formatCalendar(Calendar calendar) {
1205:                String formattedDate = "";
1206:
1207:                DateFormat dateFormat = new SimpleDateFormat();
1208:                Timestamp dateCreated = Utilities.convertCalendar(calendar);
1209:                formattedDate = dateFormat.format(dateCreated);
1210:
1211:                return formattedDate;
1212:            }
1213:
1214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.