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


0001:        /*
0002:         * Copyright 2005-2006 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.documentoperation.web;
0018:
0019:        import java.io.IOException;
0020:        import java.sql.Timestamp;
0021:        import java.text.ParseException;
0022:        import java.util.ArrayList;
0023:        import java.util.HashMap;
0024:        import java.util.HashSet;
0025:        import java.util.Iterator;
0026:        import java.util.List;
0027:        import java.util.Map;
0028:        import java.util.Set;
0029:        import java.util.StringTokenizer;
0030:
0031:        import javax.servlet.ServletException;
0032:        import javax.servlet.http.HttpServletRequest;
0033:        import javax.servlet.http.HttpServletResponse;
0034:
0035:        import org.apache.commons.lang.StringUtils;
0036:        import org.apache.struts.action.ActionForm;
0037:        import org.apache.struts.action.ActionForward;
0038:        import org.apache.struts.action.ActionMapping;
0039:        import org.apache.struts.action.ActionMessage;
0040:        import org.apache.struts.action.ActionMessages;
0041:        import org.kuali.rice.resourceloader.GlobalResourceLoader;
0042:
0043:        import edu.iu.uis.eden.EdenConstants;
0044:        import edu.iu.uis.eden.KEWServiceLocator;
0045:        import edu.iu.uis.eden.WorkflowServiceErrorException;
0046:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
0047:        import edu.iu.uis.eden.actionitem.ActionItem;
0048:        import edu.iu.uis.eden.actionlist.ActionListService;
0049:        import edu.iu.uis.eden.actionrequests.ActionRequestService;
0050:        import edu.iu.uis.eden.actionrequests.ActionRequestValue;
0051:        import edu.iu.uis.eden.actionrequests.DocumentRequeuerService;
0052:        import edu.iu.uis.eden.actions.asyncservices.ActionInvocation;
0053:        import edu.iu.uis.eden.actions.asyncservices.ActionInvocationService;
0054:        import edu.iu.uis.eden.actions.asyncservices.BlanketApproveProcessorService;
0055:        import edu.iu.uis.eden.actions.asyncservices.MoveDocumentService;
0056:        import edu.iu.uis.eden.actiontaken.ActionTakenService;
0057:        import edu.iu.uis.eden.actiontaken.ActionTakenValue;
0058:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
0059:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
0060:        import edu.iu.uis.eden.docsearch.SearchableAttributeProcessingService;
0061:        import edu.iu.uis.eden.doctype.DocumentType;
0062:        import edu.iu.uis.eden.doctype.DocumentTypeService;
0063:        import edu.iu.uis.eden.engine.node.Branch;
0064:        import edu.iu.uis.eden.engine.node.BranchService;
0065:        import edu.iu.uis.eden.engine.node.BranchState;
0066:        import edu.iu.uis.eden.engine.node.NodeState;
0067:        import edu.iu.uis.eden.engine.node.RouteNodeInstance;
0068:        import edu.iu.uis.eden.engine.node.RouteNodeService;
0069:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
0070:        import edu.iu.uis.eden.exception.WorkflowRuntimeException;
0071:        import edu.iu.uis.eden.messaging.KEWXMLService;
0072:        import edu.iu.uis.eden.messaging.MessageServiceNames;
0073:        import edu.iu.uis.eden.plugin.attributes.WorkflowLookupable;
0074:        import edu.iu.uis.eden.routeheader.DocumentRouteHeaderValue;
0075:        import edu.iu.uis.eden.routeheader.RouteHeaderService;
0076:        import edu.iu.uis.eden.routetemplate.RuleTemplate;
0077:        import edu.iu.uis.eden.user.AuthenticationUserId;
0078:        import edu.iu.uis.eden.user.UserService;
0079:        import edu.iu.uis.eden.user.WorkflowUser;
0080:        import edu.iu.uis.eden.web.WorkflowAction;
0081:
0082:        /**
0083:         * Struts Action for doing editing of workflow documents.
0084:         *
0085:         * @author shenl
0086:         */
0087:        public class DocumentOperationAction extends WorkflowAction {
0088:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
0089:                    .getLogger(DocumentOperationAction.class);
0090:            private static final String DEFAULT_LOG_MSG = "Admin change via document operation";
0091:
0092:            public ActionForward start(ActionMapping mapping, ActionForm form,
0093:                    HttpServletRequest request, HttpServletResponse response)
0094:                    throws IOException, ServletException {
0095:                return mapping.findForward("basic");
0096:            }
0097:
0098:            public ActionForward getDocument(ActionMapping mapping,
0099:                    ActionForm form, HttpServletRequest request,
0100:                    HttpServletResponse response) throws IOException,
0101:                    ServletException {
0102:                DocumentOperationForm docForm = (DocumentOperationForm) form;
0103:                Long docId = new Long(docForm.getRouteHeaderId().trim());
0104:                //to clear Document Field first;
0105:                docForm.resetOps();
0106:                DocumentRouteHeaderValue routeHeader = getRouteHeaderService()
0107:                        .getRouteHeader(docId);
0108:                List routeNodeInstances = getRouteNodeService()
0109:                        .findRouteNodeInstances(docId);
0110:                Map branches1 = new HashMap();
0111:                List branches = new ArrayList();
0112:
0113:                if (routeHeader == null) {
0114:                    throw new WorkflowServiceErrorException(
0115:                            "Document Not Found", new WorkflowServiceErrorImpl(
0116:                                    "Document Not Found",
0117:                                    "docoperation.routeheaderid.invalid"));
0118:                } else {
0119:                    materializeDocument(routeHeader);
0120:                    docForm.setRouteHeader(routeHeader);
0121:                    setRouteHeaderTimestampsToString(docForm);
0122:                    docForm.setRouteHeaderOp(EdenConstants.NOOP);
0123:                    docForm.setRouteHeaderId(docForm.getRouteHeaderId().trim());
0124:                    String initials = "";
0125:                    for (Iterator lInitials = routeHeader
0126:                            .getInitialRouteNodeInstances().iterator(); lInitials
0127:                            .hasNext();) {
0128:                        Long initial = ((RouteNodeInstance) lInitials.next())
0129:                                .getRouteNodeInstanceId();
0130:                        LOG.debug(initial);
0131:                        initials = initials + initial + ", ";
0132:                    }
0133:                    if (initials.trim().length() > 1) {
0134:                        initials = initials.substring(0, initials
0135:                                .lastIndexOf(","));
0136:                    }
0137:                    docForm.setInitialNodeInstances(initials);
0138:                    request.getSession().setAttribute("routeNodeInstances",
0139:                            routeNodeInstances);
0140:                    docForm.setRouteNodeInstances(routeNodeInstances);
0141:                    if (routeNodeInstances != null) {
0142:                        Iterator routeNodeInstanceIter = routeNodeInstances
0143:                                .iterator();
0144:                        while (routeNodeInstanceIter.hasNext()) {
0145:                            RouteNodeInstance routeNodeInstance = (RouteNodeInstance) routeNodeInstanceIter
0146:                                    .next();
0147:                            Branch branch = routeNodeInstance.getBranch();
0148:                            if (!branches1.containsKey(branch.getName())) {
0149:                                branches1.put(branch.getName(), branch);
0150:                                branches.add(branch);
0151:                                LOG.debug(branch.getName() + "; "
0152:                                        + branch.getBranchState());
0153:                            }
0154:                        }
0155:                        if (branches.size() < 1) {
0156:                            branches = null;
0157:                        }
0158:                    }
0159:                    branches1.clear();
0160:                    request.getSession().setAttribute("branches", branches);
0161:                    docForm.setBranches(branches);
0162:
0163:                }
0164:                return mapping.findForward("basic");
0165:            }
0166:
0167:            /**
0168:             * Sets up various objects on the document which are required for use inside of the Struts and JSP framework.
0169:             *
0170:             * Specifically, if a document has action requests with null RouteNodeInstances, it will create empty node instance
0171:             * objects.
0172:             */
0173:            private void materializeDocument(DocumentRouteHeaderValue document) {
0174:                for (Iterator iterator = document.getActionRequests()
0175:                        .iterator(); iterator.hasNext();) {
0176:                    ActionRequestValue request = (ActionRequestValue) iterator
0177:                            .next();
0178:                    if (request.getNodeInstance() == null) {
0179:                        request.setNodeInstance(new RouteNodeInstance());
0180:                    }
0181:                }
0182:            }
0183:
0184:            public ActionForward clear(ActionMapping mapping, ActionForm form,
0185:                    HttpServletRequest request, HttpServletResponse response)
0186:                    throws IOException, ServletException {
0187:                DocumentOperationForm docForm = (DocumentOperationForm) form;
0188:                docForm.setRouteHeader(new DocumentRouteHeaderValue());
0189:                docForm.setRouteHeaderId(null);
0190:                return mapping.findForward("basic");
0191:            }
0192:
0193:            public ActionMessages establishRequiredState(
0194:                    HttpServletRequest request, ActionForm form)
0195:                    throws Exception {
0196:                return null;
0197:            }
0198:
0199:            public ActionForward save(ActionMapping mapping, ActionForm form,
0200:                    HttpServletRequest request, HttpServletResponse response)
0201:                    throws Exception {
0202:                DocumentOperationForm docForm = (DocumentOperationForm) form;
0203:                boolean change = false;
0204:
0205:                String routeHeaderOp = docForm.getRouteHeaderOp();
0206:                if (!EdenConstants.UPDATE.equals(routeHeaderOp)
0207:                        && !EdenConstants.NOOP.equals(routeHeaderOp)) {
0208:                    throw new WorkflowServiceErrorException(
0209:                            "Document operation not defined",
0210:                            new WorkflowServiceErrorImpl(
0211:                                    "Document operation not defined",
0212:                                    "docoperation.operation.invalid"));
0213:                }
0214:                if (EdenConstants.UPDATE.equals(routeHeaderOp)) {
0215:                    setRouteHeaderTimestamps(docForm);
0216:                    DocumentRouteHeaderValue dHeader = docForm.getRouteHeader();
0217:                    String initials = docForm.getInitialNodeInstances();
0218:                    List lInitials = new ArrayList();
0219:                    StringTokenizer tokenInitials = new StringTokenizer(
0220:                            initials, ",");
0221:                    while (tokenInitials.hasMoreTokens()) {
0222:                        Long instanceId = Long.valueOf(tokenInitials
0223:                                .nextToken().trim());
0224:                        LOG.debug(instanceId);
0225:                        RouteNodeInstance instance = getRouteNodeService()
0226:                                .findRouteNodeInstanceById(instanceId);
0227:                        lInitials.add(instance);
0228:                    }
0229:                    dHeader.setInitialRouteNodeInstances(lInitials);
0230:                    getRouteHeaderService().validateRouteHeader(
0231:                            docForm.getRouteHeader());
0232:                    getRouteHeaderService().saveRouteHeader(
0233:                            docForm.getRouteHeader());
0234:                    change = true;
0235:                }
0236:
0237:                for (Iterator actionRequestIter = docForm.getActionRequestOps()
0238:                        .iterator(); actionRequestIter.hasNext();) {
0239:                    DocOperationIndexedParameter actionRequestOp = (DocOperationIndexedParameter) actionRequestIter
0240:                            .next();
0241:                    int index = actionRequestOp.getIndex().intValue();
0242:                    String opValue = actionRequestOp.getValue();
0243:                    ActionRequestValue actionRequest = docForm.getRouteHeader()
0244:                            .getDocActionRequest(index);
0245:                    String createDateParamName = "actionRequestCreateDate"
0246:                            + index;
0247:
0248:                    if (!EdenConstants.UPDATE.equals(opValue)
0249:                            && !EdenConstants.DELETE.equals(opValue)
0250:                            && !EdenConstants.NOOP.equals(opValue)) {
0251:                        throw new WorkflowServiceErrorException(
0252:                                "Action request operation not defined",
0253:                                new WorkflowServiceErrorImpl(
0254:                                        "Action request operation not defined",
0255:                                        "docoperation.actionrequest.operation.invalid"));
0256:                    }
0257:                    if (EdenConstants.UPDATE.equals(opValue)) {
0258:                        try {
0259:                            actionRequest
0260:                                    .setCreateDate(new Timestamp(
0261:                                            EdenConstants
0262:                                                    .getDefaultDateFormat()
0263:                                                    .parse(
0264:                                                            request
0265:                                                                    .getParameter(createDateParamName))
0266:                                                    .getTime()));
0267:                            actionRequest.setCreateDateString(EdenConstants
0268:                                    .getDefaultDateFormat().format(
0269:                                            actionRequest.getCreateDate()));
0270:                            actionRequest.setRouteHeader(docForm
0271:                                    .getRouteHeader());
0272:                            actionRequest
0273:                                    .setParentActionRequest(getActionRequestService()
0274:                                            .findByActionRequestId(
0275:                                                    actionRequest
0276:                                                            .getParentActionRequestId()));
0277:                            actionRequest
0278:                                    .setActionTaken(getActionTakenService()
0279:                                            .findByActionTakenId(
0280:                                                    actionRequest
0281:                                                            .getActionTakenId()));
0282:                            if (actionRequest.getNodeInstance() != null
0283:                                    && actionRequest.getNodeInstance()
0284:                                            .getRouteNodeInstanceId() == null) {
0285:                                actionRequest.setNodeInstance(null);
0286:                            } else if (actionRequest.getNodeInstance() != null
0287:                                    && actionRequest.getNodeInstance()
0288:                                            .getRouteNodeInstanceId() != null) {
0289:                                actionRequest
0290:                                        .setNodeInstance(KEWServiceLocator
0291:                                                .getRouteNodeService()
0292:                                                .findRouteNodeInstanceById(
0293:                                                        actionRequest
0294:                                                                .getNodeInstance()
0295:                                                                .getRouteNodeInstanceId()));
0296:                            }
0297:                            // getActionRequestService().validateActionRequest(actionRequest);
0298:                            getActionRequestService().saveActionRequest(
0299:                                    actionRequest);
0300:                            change = true;
0301:                        } catch (ParseException pe) {
0302:                            throw new WorkflowServiceErrorException(
0303:                                    "Action request create date parsing error",
0304:                                    new WorkflowServiceErrorImpl(
0305:                                            "Action request create date parsing error",
0306:                                            "docoperation.actionrequests.dateparsing.error",
0307:                                            actionRequest.getActionRequestId()
0308:                                                    .toString()));
0309:                        }
0310:
0311:                    }
0312:                    if (EdenConstants.DELETE.equals(opValue)) {
0313:                        for (Iterator childIter = actionRequest
0314:                                .getChildrenRequests().iterator(); childIter
0315:                                .hasNext();) {
0316:                            getActionRequestService().deleteByActionRequestId(
0317:                                    ((ActionRequestValue) childIter.next())
0318:                                            .getActionRequestId());
0319:                        }
0320:                        getActionListService().deleteActionItems(
0321:                                actionRequest.getActionRequestId());
0322:                        if (actionRequest.getActionTakenId() != null) {
0323:                            ActionTakenValue actionTaken = getActionTakenService()
0324:                                    .findByActionTakenId(
0325:                                            actionRequest.getActionTakenId());
0326:                            getActionTakenService().delete(actionTaken);
0327:                        }
0328:
0329:                        getActionRequestService().deleteByActionRequestId(
0330:                                actionRequest.getActionRequestId());
0331:                        change = true;
0332:                    }
0333:                }
0334:
0335:                for (Iterator actionTakenIter = docForm.getActionTakenOps()
0336:                        .iterator(); actionTakenIter.hasNext();) {
0337:                    DocOperationIndexedParameter actionTakenOp = (DocOperationIndexedParameter) actionTakenIter
0338:                            .next();
0339:                    int index = actionTakenOp.getIndex().intValue();
0340:                    String opValue = actionTakenOp.getValue();
0341:
0342:                    String actionDateParamName = "actionTakenActionDate"
0343:                            + index;
0344:                    ActionTakenValue actionTaken = docForm.getRouteHeader()
0345:                            .getDocActionTaken(index);
0346:                    if (!EdenConstants.UPDATE.equals(opValue)
0347:                            && !EdenConstants.DELETE.equals(opValue)
0348:                            && !EdenConstants.NOOP.equals(opValue)) {
0349:                        throw new WorkflowServiceErrorException(
0350:                                "Action taken operation not defined",
0351:                                new WorkflowServiceErrorImpl(
0352:                                        "Action taken operation not defined",
0353:                                        "docoperation.actiontaken.operation.invalid"));
0354:                    }
0355:                    if (EdenConstants.UPDATE.equals(opValue)) {
0356:                        try {
0357:                            actionTaken
0358:                                    .setActionDate(new Timestamp(
0359:                                            EdenConstants
0360:                                                    .getDefaultDateFormat()
0361:                                                    .parse(
0362:                                                            request
0363:                                                                    .getParameter(actionDateParamName))
0364:                                                    .getTime()));
0365:                            actionTaken.setActionDateString(EdenConstants
0366:                                    .getDefaultDateFormat().format(
0367:                                            actionTaken.getActionDate()));
0368:                            // getActionTakenService().validateActionTaken(actionTaken);
0369:                            getActionTakenService()
0370:                                    .saveActionTaken(actionTaken);
0371:                            change = true;
0372:                        } catch (ParseException pe) {
0373:                            throw new WorkflowServiceErrorException(
0374:                                    "Action taken action date parsing error",
0375:                                    new WorkflowServiceErrorImpl(
0376:                                            "Action taken action date parse error",
0377:                                            "docoperation.actionstaken.dateparsing.error",
0378:                                            actionTaken.getActionTakenId()
0379:                                                    .toString()));
0380:                        }
0381:                    }
0382:                    if (EdenConstants.DELETE.equals(opValue)) {
0383:                        getActionTakenService().delete(actionTaken);
0384:                        change = true;
0385:                    }
0386:                }
0387:
0388:                for (Iterator actionItemIter = docForm.getActionItemOps()
0389:                        .iterator(); actionItemIter.hasNext();) {
0390:                    DocOperationIndexedParameter actionItemOp = (DocOperationIndexedParameter) actionItemIter
0391:                            .next();
0392:                    int index = actionItemOp.getIndex().intValue();
0393:                    String opValue = actionItemOp.getValue();
0394:
0395:                    String dateAssignedParamName = "actionItemDateAssigned"
0396:                            + index;
0397:                    ActionItem actionItem = docForm.getRouteHeader()
0398:                            .getDocActionItem(index);
0399:                    if (!EdenConstants.UPDATE.equals(opValue)
0400:                            && !EdenConstants.DELETE.equals(opValue)
0401:                            && !EdenConstants.NOOP.equals(opValue)) {
0402:                        throw new WorkflowServiceErrorException(
0403:                                "Action Item operation not defined",
0404:                                new WorkflowServiceErrorImpl(
0405:                                        "Action Item operation not defined",
0406:                                        "docoperation.operation.invalid"));
0407:                    }
0408:                    if (EdenConstants.UPDATE.equals(opValue)) {
0409:                        try {
0410:                            actionItem
0411:                                    .setDateAssigned(new Timestamp(
0412:                                            EdenConstants
0413:                                                    .getDefaultDateFormat()
0414:                                                    .parse(
0415:                                                            request
0416:                                                                    .getParameter(dateAssignedParamName))
0417:                                                    .getTime()));
0418:                            actionItem.setDateAssignedString(EdenConstants
0419:                                    .getDefaultDateFormat().format(
0420:                                            actionItem.getDateAssigned()));
0421:                            actionItem.setRouteHeader(docForm.getRouteHeader());
0422:                            // getActionItemService().validateActionItem(actionItem);
0423:                            getActionListService().saveActionItem(actionItem);
0424:                            change = true;
0425:                        } catch (ParseException pe) {
0426:                            throw new WorkflowServiceErrorException(
0427:                                    "Action item date assigned parsing error",
0428:                                    new WorkflowServiceErrorImpl(
0429:                                            "Action item date assigned parse error",
0430:                                            "docoperation.actionitem.dateassignedparsing.error",
0431:                                            actionItem.getActionItemId()
0432:                                                    .toString()));
0433:                        }
0434:                    }
0435:                    if (EdenConstants.DELETE.equals(opValue)) {
0436:                        getActionListService().deleteActionItem(actionItem);
0437:                        change = true;
0438:                    }
0439:                }
0440:
0441:                List routeNodeInstances = (List) (request.getSession()
0442:                        .getAttribute("routeNodeInstances"));
0443:                String ids = docForm.getNodeStatesDelete().trim();
0444:                List statesToBeDeleted = new ArrayList();
0445:                if (ids != null || !ids.equals("")) {
0446:                    StringTokenizer idSets = new StringTokenizer(ids);
0447:                    while (idSets.hasMoreTokens()) {
0448:                        String id = idSets.nextToken().trim();
0449:                        statesToBeDeleted.add(Long.valueOf(id));
0450:                    }
0451:                }
0452:
0453:                for (Iterator routeNodeInstanceIter = docForm
0454:                        .getRouteNodeInstanceOps().iterator(); routeNodeInstanceIter
0455:                        .hasNext();) {
0456:                    DocOperationIndexedParameter routeNodeInstanceOp = (DocOperationIndexedParameter) routeNodeInstanceIter
0457:                            .next();
0458:                    int index = routeNodeInstanceOp.getIndex().intValue();
0459:                    String opValue = routeNodeInstanceOp.getValue();
0460:                    LOG.debug(opValue);
0461:                    RouteNodeInstance routeNodeInstance = (RouteNodeInstance) (routeNodeInstances
0462:                            .get(index));
0463:                    RouteNodeInstance routeNodeInstanceNew = (RouteNodeInstance) (docForm
0464:                            .getRouteNodeInstance(index));
0465:                    if (!EdenConstants.UPDATE.equals(opValue)
0466:                            && !EdenConstants.DELETE.equals(opValue)
0467:                            && !EdenConstants.NOOP.equals(opValue)) {
0468:                        throw new WorkflowServiceErrorException(
0469:                                "Route Node Instance Operation not defined",
0470:                                new WorkflowServiceErrorImpl(
0471:                                        "Route Node Instance Operation not defined",
0472:                                        "docoperation.routenodeinstance.operation.invalid"));
0473:                    }
0474:                    if (EdenConstants.UPDATE.equals(opValue)) {
0475:                        //LOG.debug("saving routeNodeInstance:"+routeNodeInstance.getRouteNodeInstanceId());
0476:                        //getRouteNodeService().save(routeNodeInstance);
0477:                        routeNodeInstance.setActive(routeNodeInstanceNew
0478:                                .isActive());
0479:                        LOG.debug(Boolean.toString(routeNodeInstanceNew
0480:                                .isActive()));
0481:                        routeNodeInstance.setComplete(routeNodeInstanceNew
0482:                                .isComplete());
0483:                        routeNodeInstance.setInitial(routeNodeInstanceNew
0484:                                .isInitial());
0485:                        List nodeStates = routeNodeInstance.getState();
0486:                        List nodeStatesNew = routeNodeInstanceNew.getState();
0487:
0488:                        if (nodeStates != null) {
0489:                            for (int i = 0; i < nodeStates.size(); i++) {
0490:                                NodeState nodeState = (NodeState) nodeStates
0491:                                        .get(i);
0492:                                NodeState nodeStateNew = (NodeState) nodeStatesNew
0493:                                        .get(i);
0494:                                if (nodeStateNew.getKey() != null
0495:                                        && !nodeStateNew.getKey().trim()
0496:                                                .equals("")) {
0497:                                    nodeState.setKey(nodeStateNew.getKey());
0498:                                    LOG.debug(nodeState.getKey());
0499:                                    nodeState.setValue(nodeStateNew.getValue());
0500:                                    LOG.debug(nodeState.getValue());
0501:                                }
0502:                            }
0503:                        }
0504:                        getRouteNodeService().save(routeNodeInstance);
0505:                        LOG.debug("saved");
0506:                        change = true;
0507:                    }
0508:
0509:                    if (EdenConstants.DELETE.equals(opValue)) {
0510:                        List nodeStates = routeNodeInstance.getState();
0511:                        List nodeStatesNew = routeNodeInstanceNew.getState();
0512:
0513:                        if (nodeStates != null) {
0514:                            for (int i = 0; i < nodeStates.size(); i++) {
0515:                                NodeState nodeState = (NodeState) nodeStates
0516:                                        .get(i);
0517:                                NodeState nodeStateNew = (NodeState) nodeStatesNew
0518:                                        .get(i);
0519:                                if (nodeStateNew.getKey() == null
0520:                                        || nodeStateNew.getKey().trim().equals(
0521:                                                "")) {
0522:                                    statesToBeDeleted.remove(nodeState
0523:                                            .getNodeStateId());
0524:                                }
0525:                            }
0526:                        }
0527:                        getRouteNodeService().deleteByRouteNodeInstance(
0528:                                routeNodeInstance);
0529:                        LOG.debug(routeNodeInstance.getRouteNodeInstanceId()
0530:                                + " is deleted");
0531:                        change = true;
0532:                        break;
0533:                    }
0534:
0535:                    if (EdenConstants.NOOP.equals(opValue)) {
0536:                        routeNodeInstanceNew.setActive(routeNodeInstance
0537:                                .isActive());
0538:                        routeNodeInstanceNew.setComplete(routeNodeInstance
0539:                                .isComplete());
0540:                        routeNodeInstanceNew.setInitial(routeNodeInstance
0541:                                .isInitial());
0542:                        List nodeStates = routeNodeInstance.getState();
0543:                        List nodeStatesNew = routeNodeInstanceNew.getState();
0544:                        if (nodeStates != null) {
0545:                            for (int i = 0; i < nodeStates.size(); i++) {
0546:                                NodeState nodeState = (NodeState) nodeStates
0547:                                        .get(i);
0548:                                NodeState nodeStateNew = (NodeState) nodeStatesNew
0549:                                        .get(i);
0550:                                if (nodeStateNew.getKey() == null
0551:                                        || nodeStateNew.getKey().trim().equals(
0552:                                                "")) {
0553:                                    statesToBeDeleted.remove(nodeState
0554:                                            .getNodeStateId());
0555:                                }
0556:                                nodeStateNew.setKey(nodeState.getKey());
0557:                                nodeStateNew.setValue(nodeState.getValue());
0558:                            }
0559:                        }
0560:                    }
0561:
0562:                    //((DocOperationIndexedParameter)(docForm.getRouteNodeInstanceOps().get(index))).setValue(EdenConstants.NOOP);
0563:                }
0564:
0565:                if (statesToBeDeleted != null && statesToBeDeleted.size() > 0) {
0566:                    getRouteNodeService().deleteNodeStates(statesToBeDeleted);
0567:                }
0568:
0569:                List branches = (List) (request.getSession()
0570:                        .getAttribute("branches"));
0571:                String branchStateIds = docForm.getBranchStatesDelete().trim();
0572:                List branchStatesToBeDeleted = new ArrayList();
0573:                if (branchStateIds != null || !branchStateIds.equals("")) {
0574:                    StringTokenizer idSets = new StringTokenizer(branchStateIds);
0575:                    while (idSets.hasMoreTokens()) {
0576:                        String id = idSets.nextToken().trim();
0577:                        branchStatesToBeDeleted.add(Long.valueOf(id));
0578:                    }
0579:                }
0580:
0581:                for (Iterator branchesOpIter = docForm.getBranchOps()
0582:                        .iterator(); branchesOpIter.hasNext();) {
0583:                    DocOperationIndexedParameter branchesOp = (DocOperationIndexedParameter) branchesOpIter
0584:                            .next();
0585:                    int index = branchesOp.getIndex().intValue();
0586:                    String opValue = branchesOp.getValue();
0587:                    LOG.debug(opValue);
0588:                    Branch branch = (Branch) (branches.get(index));
0589:                    Branch branchNew = (Branch) (docForm.getBranche(index));
0590:                    if (!EdenConstants.UPDATE.equals(opValue)
0591:                            && !EdenConstants.NOOP.equals(opValue)) {
0592:                        throw new WorkflowServiceErrorException(
0593:                                "Route Node Instance Operation not defined",
0594:                                new WorkflowServiceErrorImpl(
0595:                                        "Route Node Instance Operation not defined",
0596:                                        "docoperation.routenodeinstance.operation.invalid"));
0597:                    }
0598:                    if (EdenConstants.UPDATE.equals(opValue)) {
0599:                        //LOG.debug("saving routeNodeInstance:"+routeNodeInstance.getRouteNodeInstanceId());
0600:                        //getRouteNodeService().save(routeNodeInstance);
0601:                        branch.setName(branchNew.getName());
0602:                        List branchStates = branch.getBranchState();
0603:                        List branchStatesNew = branchNew.getBranchState();
0604:                        if (branchStates != null) {
0605:                            for (int i = 0; i < branchStates.size(); i++) {
0606:                                BranchState branchState = (BranchState) branchStates
0607:                                        .get(i);
0608:                                BranchState branchStateNew = (BranchState) branchStatesNew
0609:                                        .get(i);
0610:                                if (branchStateNew.getKey() != null
0611:                                        && !branchStateNew.getKey().trim()
0612:                                                .equals("")) {
0613:                                    branchState.setKey(branchStateNew.getKey());
0614:                                    LOG.debug(branchState.getKey());
0615:                                    branchState.setValue(branchStateNew
0616:                                            .getValue());
0617:                                    LOG.debug(branchState.getValue());
0618:                                }
0619:                            }
0620:                        }
0621:                        getBranchService().save(branch);
0622:                        LOG.debug("branch saved");
0623:                        change = true;
0624:
0625:                    }
0626:
0627:                    if (EdenConstants.NOOP.equals(opValue)) {
0628:                        branchNew.setName(branch.getName());
0629:                        List branchStates = branch.getBranchState();
0630:                        List branchStatesNew = branchNew.getBranchState();
0631:                        if (branchStates != null) {
0632:                            for (int i = 0; i < branchStates.size(); i++) {
0633:                                BranchState branchState = (BranchState) branchStates
0634:                                        .get(i);
0635:                                BranchState branchStateNew = (BranchState) branchStatesNew
0636:                                        .get(i);
0637:                                if (branchStateNew.getKey() == null
0638:                                        || branchStateNew.getKey().trim()
0639:                                                .equals("")) {
0640:                                    branchStatesToBeDeleted.remove(branchState
0641:                                            .getBranchStateId());
0642:                                }
0643:                                branchStateNew.setKey(branchState.getKey());
0644:                                LOG.debug(branchState.getKey());
0645:                                branchStateNew.setValue(branchState.getValue());
0646:                                LOG.debug(branchState.getValue());
0647:                            }
0648:                        }
0649:                    }
0650:                    //((DocOperationIndexedParameter)(docForm.getBranchOps().get(index))).setValue(EdenConstants.NOOP);
0651:                }
0652:
0653:                if (branchStatesToBeDeleted != null
0654:                        && branchStatesToBeDeleted.size() > 0) {
0655:                    getBranchService().deleteBranchStates(
0656:                            branchStatesToBeDeleted);
0657:                }
0658:
0659:                WorkflowDocument flexDoc = new WorkflowDocument(
0660:                        new NetworkIdVO(getUserSession(request)
0661:                                .getWorkflowUser().getAuthenticationUserId()
0662:                                .getAuthenticationId()), new Long(docForm
0663:                                .getRouteHeaderId()));
0664:                String annotation = docForm.getAnnotation();
0665:                if (StringUtils.isEmpty(annotation)) {
0666:                    annotation = DEFAULT_LOG_MSG;
0667:                }
0668:                flexDoc.logDocumentAction(annotation);
0669:
0670:                ActionMessages messages = new ActionMessages();
0671:                String forward = null;
0672:                if (change) {
0673:                    messages.add(ActionMessages.GLOBAL_MESSAGE,
0674:                            new ActionMessage("docoperation.operation.saved"));
0675:                    docForm
0676:                            .setRouteHeader(getRouteHeaderService()
0677:                                    .getRouteHeader(
0678:                                            docForm.getRouteHeader()
0679:                                                    .getRouteHeaderId()));
0680:                    forward = "summary";
0681:                } else {
0682:                    messages.add(ActionMessages.GLOBAL_MESSAGE,
0683:                            new ActionMessage("docoperation.operation.noop"));
0684:                    forward = "basic";
0685:                }
0686:                saveMessages(request, messages);
0687:                return mapping.findForward(forward);
0688:
0689:            }
0690:
0691:            private RouteHeaderService getRouteHeaderService() {
0692:                return (RouteHeaderService) KEWServiceLocator
0693:                        .getService(KEWServiceLocator.DOC_ROUTE_HEADER_SRV);
0694:            }
0695:
0696:            private RouteNodeService getRouteNodeService() {
0697:                return (RouteNodeService) KEWServiceLocator
0698:                        .getService(KEWServiceLocator.ROUTE_NODE_SERVICE);
0699:            }
0700:
0701:            private ActionRequestService getActionRequestService() {
0702:                return (ActionRequestService) KEWServiceLocator
0703:                        .getService(KEWServiceLocator.ACTION_REQUEST_SRV);
0704:            }
0705:
0706:            private ActionTakenService getActionTakenService() {
0707:                return (ActionTakenService) KEWServiceLocator
0708:                        .getService(KEWServiceLocator.ACTION_TAKEN_SRV);
0709:            }
0710:
0711:            private ActionListService getActionListService() {
0712:                return (ActionListService) KEWServiceLocator
0713:                        .getActionListService();
0714:            }
0715:
0716:            private void setRouteHeaderTimestamps(DocumentOperationForm docForm) {
0717:                if (docForm.getCreateDate() == null
0718:                        || docForm.getCreateDate().trim().equals("")) {
0719:                    throw new WorkflowServiceErrorException(
0720:                            "Document create date empty",
0721:                            new WorkflowServiceErrorImpl(
0722:                                    "Document create date empty",
0723:                                    "docoperation.routeheader.createdate.empty"));
0724:                } else {
0725:                    try {
0726:                        docForm.getRouteHeader().setCreateDate(
0727:                                new Timestamp(EdenConstants
0728:                                        .getDefaultDateFormat().parse(
0729:                                                docForm.getCreateDate())
0730:                                        .getTime()));
0731:                    } catch (ParseException pe) {
0732:                        throw new WorkflowServiceErrorException(
0733:                                "RouteHeader create date parsing error",
0734:                                new WorkflowServiceErrorImpl(
0735:                                        "Date parsing error",
0736:                                        "docoperation.routeheader.createdate.invalid"));
0737:                    }
0738:                }
0739:
0740:                if (docForm.getStatusModDate() == null
0741:                        || docForm.getStatusModDate().trim().equals("")) {
0742:                    throw new WorkflowServiceErrorException(
0743:                            "Document doc status mod date empty",
0744:                            new WorkflowServiceErrorImpl(
0745:                                    "Document doc status mod date empty",
0746:                                    "docoperation.routeheader.statusmoddate.empty"));
0747:                } else {
0748:                    try {
0749:                        docForm.getRouteHeader().setStatusModDate(
0750:                                new Timestamp(EdenConstants
0751:                                        .getDefaultDateFormat().parse(
0752:                                                docForm.getStatusModDate())
0753:                                        .getTime()));
0754:                    } catch (ParseException pe) {
0755:                        throw new WorkflowServiceErrorException(
0756:                                "Document doc status date parsing error",
0757:                                new WorkflowServiceErrorImpl(
0758:                                        "Document doc status mod date parsing error",
0759:                                        "docoperation.routeheader.statusmoddate.invalid"));
0760:                    }
0761:                }
0762:
0763:                if (docForm.getApprovedDate() != null
0764:                        && !docForm.getApprovedDate().trim().equals("")) {
0765:                    try {
0766:                        docForm.getRouteHeader().setApprovedDate(
0767:                                new Timestamp(EdenConstants
0768:                                        .getDefaultDateFormat().parse(
0769:                                                docForm.getApprovedDate())
0770:                                        .getTime()));
0771:                    } catch (ParseException pe) {
0772:                        throw new WorkflowServiceErrorException(
0773:                                "Document approved date parsing error",
0774:                                new WorkflowServiceErrorImpl(
0775:                                        "Document approved date parsing error",
0776:                                        "docoperation.routeheader.approveddate.invalid"));
0777:                    }
0778:
0779:                }
0780:
0781:                if (docForm.getFinalizedDate() != null
0782:                        && !docForm.getFinalizedDate().trim().equals("")) {
0783:                    try {
0784:                        docForm.getRouteHeader().setFinalizedDate(
0785:                                new Timestamp(EdenConstants
0786:                                        .getDefaultDateFormat().parse(
0787:                                                docForm.getFinalizedDate())
0788:                                        .getTime()));
0789:                    } catch (ParseException pe) {
0790:                        throw new WorkflowServiceErrorException(
0791:                                "Document finalized date parsing error",
0792:                                new WorkflowServiceErrorImpl(
0793:                                        "Document finalized date parsing error",
0794:                                        "docoperation.routeheader.finalizeddate.invalid"));
0795:                    }
0796:                }
0797:
0798:                if (docForm.getRouteStatusDate() != null
0799:                        && !docForm.getRouteStatusDate().trim().equals("")) {
0800:                    try {
0801:                        docForm.getRouteHeader().setRouteStatusDate(
0802:                                new Timestamp(EdenConstants
0803:                                        .getDefaultDateFormat().parse(
0804:                                                docForm.getRouteStatusDate())
0805:                                        .getTime()));
0806:                    } catch (ParseException pe) {
0807:                        throw new WorkflowServiceErrorException(
0808:                                "Document route status date parsing error",
0809:                                new WorkflowServiceErrorImpl(
0810:                                        "Document route status date parsing error",
0811:                                        "docoperation.routeheader.routestatusdate.invalid"));
0812:                    }
0813:
0814:                }
0815:
0816:                if (docForm.getRouteLevelDate() != null
0817:                        && !docForm.getRouteLevelDate().trim().equals("")) {
0818:                    try {
0819:                        docForm.getRouteHeader().setRouteLevelDate(
0820:                                new Timestamp(EdenConstants
0821:                                        .getDefaultDateFormat().parse(
0822:                                                docForm.getRouteLevelDate())
0823:                                        .getTime()));
0824:                    } catch (ParseException pe) {
0825:                        throw new WorkflowServiceErrorException(
0826:                                "Document route level date parsing error",
0827:                                new WorkflowServiceErrorImpl(
0828:                                        "Document route level date parsing error",
0829:                                        "docoperation.routeheader.routeleveldate.invalid"));
0830:                    }
0831:                }
0832:            }
0833:
0834:            private void setRouteHeaderTimestampsToString(
0835:                    DocumentOperationForm docForm) {
0836:                try {
0837:                    docForm.setCreateDate(EdenConstants.getDefaultDateFormat()
0838:                            .format(docForm.getRouteHeader().getCreateDate()));
0839:                    docForm
0840:                            .setStatusModDate(EdenConstants
0841:                                    .getDefaultDateFormat().format(
0842:                                            docForm.getRouteHeader()
0843:                                                    .getStatusModDate()));
0844:                    docForm
0845:                            .setApprovedDate(EdenConstants
0846:                                    .getDefaultDateFormat().format(
0847:                                            docForm.getRouteHeader()
0848:                                                    .getApprovedDate()));
0849:                    docForm
0850:                            .setFinalizedDate(EdenConstants
0851:                                    .getDefaultDateFormat().format(
0852:                                            docForm.getRouteHeader()
0853:                                                    .getFinalizedDate()));
0854:                    docForm.setRouteStatusDate(EdenConstants
0855:                            .getDefaultDateFormat().format(
0856:                                    docForm.getRouteHeader()
0857:                                            .getRouteStatusDate()));
0858:                    docForm.setRouteLevelDate(EdenConstants
0859:                            .getDefaultDateFormat().format(
0860:                                    docForm.getRouteHeader()
0861:                                            .getRouteLevelDate()));
0862:
0863:                } catch (Exception e) {
0864:                    LOG
0865:                            .info("One or more of the dates in routeHeader may be null");
0866:                }
0867:            }
0868:
0869:            public ActionForward performLookup(ActionMapping mapping,
0870:                    ActionForm form, HttpServletRequest request,
0871:                    HttpServletResponse response) throws Exception {
0872:                DocumentOperationForm docForm = (DocumentOperationForm) form;
0873:                String basePath = request.getScheme() + "://"
0874:                        + request.getServerName() + ":"
0875:                        + request.getServerPort() + request.getContextPath()
0876:                        + mapping.getModuleConfig().getPrefix();
0877:                ;
0878:                StringBuffer lookupUrl = new StringBuffer(basePath);
0879:
0880:                String lookupType = docForm.getLookupType();
0881:                docForm.setLookupType(null);
0882:
0883:                lookupUrl.append("/Lookup.do?methodToCall=start&docFormKey=")
0884:                        .append(getUserSession(request).addObject(docForm))
0885:                        .append("&lookupableImplServiceName=");
0886:                lookupUrl.append(request
0887:                        .getParameter("lookupableImplServiceName"));
0888:
0889:                if (lookupType != null && !lookupType.equals("")) {
0890:                    lookupUrl.append("&conversionFields=");
0891:                    WorkflowLookupable workflowLookupable = (WorkflowLookupable) GlobalResourceLoader
0892:                            .getService(request
0893:                                    .getParameter("lookupableImplServiceName"));//SpringServiceLocator.getExtensionService().getLookupable(request.getParameter("lookupableImplServiceName"));
0894:                    for (Iterator iterator = workflowLookupable
0895:                            .getDefaultReturnType().iterator(); iterator
0896:                            .hasNext();) {
0897:                        String returnType = (String) iterator.next();
0898:                        lookupUrl.append(returnType).append(":").append(
0899:                                lookupType);
0900:                    }
0901:                }
0902:
0903:                lookupUrl.append("&returnLocation=").append(basePath).append(
0904:                        mapping.getPath()).append(".do");
0905:                return new ActionForward(lookupUrl.toString(), true);
0906:            }
0907:
0908:            public ActionForward refresh(ActionMapping mapping,
0909:                    ActionForm form, HttpServletRequest request,
0910:                    HttpServletResponse response) throws IOException,
0911:                    ServletException {
0912:                DocumentOperationForm docForm = (DocumentOperationForm) form;
0913:                String lookupInvocationModule = docForm
0914:                        .getLookupInvocationModule();
0915:                docForm.getRouteHeader().setRouteHeaderId(
0916:                        new Long(docForm.getRouteHeaderId()));
0917:
0918:                if (lookupInvocationModule != null
0919:                        && !lookupInvocationModule.trim().equals("")) {
0920:                    String lookupField = docForm.getLookupInvocationField();
0921:                    int lookupIndex = new Integer(docForm
0922:                            .getLookupInvocationIndex()).intValue();
0923:                    String networkId = request.getParameter("networkId");
0924:
0925:                    if (lookupInvocationModule.equals("RouteHeader")) {
0926:                        DocumentRouteHeaderValue routeHeader = docForm
0927:                                .getRouteHeader();
0928:                        if ("initiatorWorkflowId".equals(lookupField)) {
0929:                            try {
0930:                                routeHeader
0931:                                        .setInitiatorWorkflowId(getUserService()
0932:                                                .getWorkflowUser(
0933:                                                        new AuthenticationUserId(
0934:                                                                networkId))
0935:                                                .getWorkflowUserId()
0936:                                                .getWorkflowId());
0937:                            } catch (EdenUserNotFoundException e) {
0938:                                LOG.info("route header initiator not found");
0939:                                routeHeader.setInitiatorWorkflowId(null);
0940:                            }
0941:                        }
0942:                        if ("documentTypeId".equals(lookupField)) {
0943:                            DocumentType docType = getDocumentTypeService()
0944:                                    .findByName(
0945:                                            request
0946:                                                    .getParameter("docTypeFullName"));
0947:                            routeHeader.setDocumentTypeId(docType
0948:                                    .getDocumentTypeId());
0949:                        }
0950:                    }
0951:
0952:                    if (lookupInvocationModule.equals("ActionRequest")) {
0953:                        ActionRequestValue actionRequest = docForm
0954:                                .getRouteHeader().getDocActionRequest(
0955:                                        lookupIndex);
0956:                        if ("routeMethodName".equals(lookupField)) {
0957:                            //					actionRequest.setRouteMethodName(null);
0958:                            String id = request
0959:                                    .getParameter("ruleTemplate.ruleTemplateId");
0960:                            if (id != null && !"".equals(id.trim())) {
0961:                                RuleTemplate ruleTemplate = KEWServiceLocator
0962:                                        .getRuleTemplateService()
0963:                                        .findByRuleTemplateId(new Long(id));
0964:                                if (ruleTemplate != null) {
0965:                                    //							actionRequest.setRouteMethodName(ruleTemplate.getName());
0966:                                }
0967:                            }
0968:                        }
0969:                        if ("workflowId".equals(lookupField)) {
0970:                            try {
0971:                                actionRequest.setWorkflowId(getUserService()
0972:                                        .getWorkflowUser(
0973:                                                new AuthenticationUserId(
0974:                                                        networkId))
0975:                                        .getWorkflowUserId().getWorkflowId());
0976:                            } catch (EdenUserNotFoundException e) {
0977:                                LOG.info("action request user not found");
0978:                                actionRequest.setWorkflowId(null);
0979:                            }
0980:                        }
0981:                        if ("workgroupId".equals(lookupField)) {
0982:                            if (request.getParameter("workgroupId") != null
0983:                                    && !"".equals(request.getParameter(
0984:                                            "workgroupId").trim())) {
0985:                                actionRequest.setWorkgroupId(new Long(request
0986:                                        .getParameter("workgroupId")));
0987:                            } else {
0988:                                actionRequest.setWorkgroupId(null);
0989:                            }
0990:                        }
0991:                        if ("roleName".equals(lookupField)) {
0992:                            actionRequest.setRoleName(request
0993:                                    .getParameter("roleName"));
0994:                        }
0995:                    }
0996:                    if (lookupInvocationModule.equals("ActionTaken")) {
0997:                        ActionTakenValue actionTaken = docForm.getRouteHeader()
0998:                                .getDocActionTaken(lookupIndex);
0999:                        if ("workflowId".equals(lookupField)) {
1000:                            try {
1001:                                actionTaken.setWorkflowId(getUserService()
1002:                                        .getWorkflowUser(
1003:                                                new AuthenticationUserId(
1004:                                                        networkId))
1005:                                        .getWorkflowUserId().getWorkflowId());
1006:                            } catch (EdenUserNotFoundException e) {
1007:                                LOG.info("action taken user not found");
1008:                                actionTaken.setWorkflowId(null);
1009:                            }
1010:                        }
1011:                        if ("delegatorWorkflowId".equals(lookupField)) {
1012:                            try {
1013:                                actionTaken
1014:                                        .setDelegatorWorkflowId(getUserService()
1015:                                                .getWorkflowUser(
1016:                                                        new AuthenticationUserId(
1017:                                                                networkId))
1018:                                                .getWorkflowUserId()
1019:                                                .getWorkflowId());
1020:                            } catch (EdenUserNotFoundException e) {
1021:                                LOG
1022:                                        .info("action taken delegator user not found");
1023:                                actionTaken.setDelegatorWorkflowId(null);
1024:                            }
1025:                        }
1026:                        if ("delegatorWorkgroupId".equals(lookupField)) {
1027:                            if (request.getParameter("workgroupId") != null
1028:                                    && !"".equals(request.getParameter(
1029:                                            "workgroupId").trim())) {
1030:                                actionTaken.setDelegatorWorkgroupId(new Long(
1031:                                        request.getParameter("workgroupId")));
1032:                            } else {
1033:                                actionTaken.setDelegatorWorkgroupId(null);
1034:                            }
1035:                        }
1036:                    }
1037:
1038:                    if (lookupInvocationModule.equals("ActionItem")) {
1039:                        ActionItem actionItem = docForm.getRouteHeader()
1040:                                .getDocActionItem(lookupIndex);
1041:                        if ("workflowId".equals(lookupField)) {
1042:                            try {
1043:                                actionItem.setWorkflowId(getUserService()
1044:                                        .getWorkflowUser(
1045:                                                new AuthenticationUserId(
1046:                                                        networkId))
1047:                                        .getWorkflowUserId().getWorkflowId());
1048:                            } catch (EdenUserNotFoundException e) {
1049:                                LOG.info("action item user not found");
1050:                                actionItem.setWorkflowId(null);
1051:                            }
1052:                        }
1053:
1054:                        if ("workgroupId".equals(lookupField)) {
1055:                            if (request.getParameter("workgroupId") != null
1056:                                    && !"".equals(request.getParameter(
1057:                                            "workgroupId").trim())) {
1058:                                actionItem.setWorkgroupId(new Long(request
1059:                                        .getParameter("workgroupId")));
1060:                            } else {
1061:                                actionItem.setWorkgroupId(null);
1062:                            }
1063:                        }
1064:                        if ("roleName".equals(lookupField)) {
1065:                            actionItem.setRoleName(request
1066:                                    .getParameter("roleName"));
1067:                        }
1068:                        if ("delegatorWorkflowId".equals(lookupField)) {
1069:                            try {
1070:                                actionItem
1071:                                        .setDelegatorWorkflowId(getUserService()
1072:                                                .getWorkflowUser(
1073:                                                        new AuthenticationUserId(
1074:                                                                networkId))
1075:                                                .getWorkflowUserId()
1076:                                                .getWorkflowId());
1077:                            } catch (EdenUserNotFoundException e) {
1078:                                LOG
1079:                                        .info("action item delegator user not found");
1080:                                actionItem.setDelegatorWorkflowId(null);
1081:                            }
1082:                        }
1083:                        if ("delegatorWorkgroupId".equals(lookupField)) {
1084:                            if (request.getParameter("workgroupId") != null
1085:                                    && !"".equals(request.getParameter(
1086:                                            "workgroupId").trim())) {
1087:                                actionItem.setDelegatorWorkgroupId(new Long(
1088:                                        request.getParameter("workgroupId")));
1089:                            } else {
1090:                                actionItem.setDelegatorWorkgroupId(null);
1091:                            }
1092:                        }
1093:                        if ("docName".equals(lookupField)) {
1094:                            DocumentType docType = getDocumentTypeService()
1095:                                    .findByName(
1096:                                            request
1097:                                                    .getParameter("docTypeFullName"));
1098:                            actionItem.setDocName(docType.getName());
1099:                            actionItem.setDocLabel(docType.getLabel());
1100:                            actionItem.setDocHandlerURL(docType
1101:                                    .getDocHandlerUrl());
1102:                        }
1103:                    }
1104:                }
1105:
1106:                return mapping.findForward("basic");
1107:            }
1108:
1109:            public ActionForward queueDocument(ActionMapping mapping,
1110:                    ActionForm form, HttpServletRequest request,
1111:                    HttpServletResponse response) throws IOException,
1112:                    ServletException {
1113:                try {
1114:                    DocumentOperationForm docForm = (DocumentOperationForm) form;
1115:                    KEWXMLService routeDoc = MessageServiceNames
1116:                            .getRouteDocumentMessageService(docForm
1117:                                    .getRouteHeader());
1118:                    routeDoc.invoke(docForm.getRouteHeaderId());
1119:                    ActionMessages messages = new ActionMessages();
1120:                    messages.add(ActionMessages.GLOBAL_MESSAGE,
1121:                            new ActionMessage("general.message",
1122:                                    "Document was successfully queued"));
1123:                    saveMessages(request, messages);
1124:                    return mapping.findForward("basic");
1125:                } catch (Exception e) {
1126:                    throw new WorkflowRuntimeException(e);
1127:                }
1128:            }
1129:
1130:            public ActionForward indexSearchableAttributes(
1131:                    ActionMapping mapping, ActionForm form,
1132:                    HttpServletRequest request, HttpServletResponse response)
1133:                    throws IOException, ServletException {
1134:                DocumentOperationForm docForm = (DocumentOperationForm) form;
1135:                SearchableAttributeProcessingService searchableAttributeService = MessageServiceNames
1136:                        .getSearchableAttributeService(docForm.getRouteHeader());
1137:                searchableAttributeService.indexDocument(docForm
1138:                        .getRouteHeader().getRouteHeaderId());
1139:                ActionMessages messages = new ActionMessages();
1140:                messages
1141:                        .add(
1142:                                ActionMessages.GLOBAL_MESSAGE,
1143:                                new ActionMessage("general.message",
1144:                                        "Searchable Attribute Indexing was successfully scheduled"));
1145:                saveMessages(request, messages);
1146:                return mapping.findForward("basic");
1147:            }
1148:
1149:            public ActionForward queueDocumentRequeuer(ActionMapping mapping,
1150:                    ActionForm form, HttpServletRequest request,
1151:                    HttpServletResponse response) throws IOException,
1152:                    ServletException {
1153:                DocumentOperationForm docForm = (DocumentOperationForm) form;
1154:                DocumentRequeuerService docRequeue = MessageServiceNames
1155:                        .getDocumentRequeuerService(docForm.getRouteHeader()
1156:                                .getDocumentType().getMessageEntity(), docForm
1157:                                .getRouteHeader().getRouteHeaderId(), 0);
1158:                docRequeue.requeueDocument(docForm.getRouteHeader()
1159:                        .getRouteHeaderId());
1160:                ActionMessages messages = new ActionMessages();
1161:                messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
1162:                        "general.message",
1163:                        "Document Requeuer was successfully scheduled"));
1164:                saveMessages(request, messages);
1165:                return mapping.findForward("basic");
1166:            }
1167:
1168:            public ActionForward blanketApproveDocument(ActionMapping mapping,
1169:                    ActionForm form, HttpServletRequest request,
1170:                    HttpServletResponse response) throws IOException,
1171:                    ServletException {
1172:                try {
1173:                    DocumentOperationForm docForm = (DocumentOperationForm) form;
1174:                    WorkflowUser user = KEWServiceLocator.getUserService()
1175:                            .getWorkflowUser(
1176:                                    new AuthenticationUserId(docForm
1177:                                            .getBlanketApproveUser()));
1178:                    Set<String> nodeNames = new HashSet<String>();
1179:                    if (!StringUtils.isBlank(docForm.getBlanketApproveNodes())) {
1180:                        String[] nodeNameArray = docForm
1181:                                .getBlanketApproveNodes().split(",");
1182:                        for (String nodeName : nodeNameArray) {
1183:                            nodeNames.add(nodeName.trim());
1184:                        }
1185:                    }
1186:                    BlanketApproveProcessorService blanketApprove = MessageServiceNames
1187:                            .getBlanketApproveProcessorService(docForm
1188:                                    .getRouteHeader());
1189:                    blanketApprove.doBlanketApproveWork(docForm
1190:                            .getRouteHeader().getRouteHeaderId(), user,
1191:                            new Long(docForm.getBlanketApproveActionTakenId()),
1192:                            nodeNames);
1193:                    ActionMessages messages = new ActionMessages();
1194:                    messages
1195:                            .add(
1196:                                    ActionMessages.GLOBAL_MESSAGE,
1197:                                    new ActionMessage("general.message",
1198:                                            "Blanket Approve Processor was successfully scheduled"));
1199:                    saveMessages(request, messages);
1200:                    return mapping.findForward("basic");
1201:                } catch (Exception e) {
1202:                    throw new WorkflowRuntimeException(e);
1203:                }
1204:            }
1205:
1206:            public ActionForward moveDocument(ActionMapping mapping,
1207:                    ActionForm form, HttpServletRequest request,
1208:                    HttpServletResponse response) throws IOException,
1209:                    ServletException {
1210:                try {
1211:                    DocumentOperationForm docForm = (DocumentOperationForm) form;
1212:                    WorkflowUser user = KEWServiceLocator.getUserService()
1213:                            .getWorkflowUser(
1214:                                    new AuthenticationUserId(docForm
1215:                                            .getBlanketApproveUser()));
1216:                    Set<String> nodeNames = new HashSet<String>();
1217:                    if (!StringUtils.isBlank(docForm.getBlanketApproveNodes())) {
1218:                        String[] nodeNameArray = docForm
1219:                                .getBlanketApproveNodes().split(",");
1220:                        for (String nodeName : nodeNameArray) {
1221:                            nodeNames.add(nodeName.trim());
1222:                        }
1223:                    }
1224:                    ActionTakenValue actionTaken = KEWServiceLocator
1225:                            .getActionTakenService().findByActionTakenId(
1226:                                    new Long(docForm
1227:                                            .getBlanketApproveActionTakenId()));
1228:                    MoveDocumentService moveService = MessageServiceNames
1229:                            .getMoveDocumentProcessorService(docForm
1230:                                    .getRouteHeader());
1231:                    moveService.moveDocument(user, docForm.getRouteHeader(),
1232:                            actionTaken, nodeNames);
1233:                    ActionMessages messages = new ActionMessages();
1234:                    messages
1235:                            .add(
1236:                                    ActionMessages.GLOBAL_MESSAGE,
1237:                                    new ActionMessage("general.message",
1238:                                            "Move Document Processor was successfully scheduled"));
1239:                    saveMessages(request, messages);
1240:                    return mapping.findForward("basic");
1241:                } catch (Exception e) {
1242:                    throw new WorkflowRuntimeException(e);
1243:                }
1244:            }
1245:
1246:            public ActionForward queueActionInvocation(ActionMapping mapping,
1247:                    ActionForm form, HttpServletRequest request,
1248:                    HttpServletResponse response) throws IOException,
1249:                    ServletException {
1250:                try {
1251:                    DocumentOperationForm docForm = (DocumentOperationForm) form;
1252:                    WorkflowUser user = KEWServiceLocator.getUserService()
1253:                            .getWorkflowUser(
1254:                                    new AuthenticationUserId(docForm
1255:                                            .getActionInvocationUser()));
1256:                    ActionInvocation invocation = new ActionInvocation(
1257:                            new Long(docForm.getActionInvocationActionItemId()),
1258:                            docForm.getActionInvocationActionCode());
1259:                    ActionInvocationService actionInvocationService = MessageServiceNames
1260:                            .getActionInvocationProcessorService(docForm
1261:                                    .getRouteHeader());
1262:                    actionInvocationService.invokeAction(user, docForm
1263:                            .getRouteHeader().getRouteHeaderId(), invocation);
1264:                    ActionMessages messages = new ActionMessages();
1265:                    messages
1266:                            .add(
1267:                                    ActionMessages.GLOBAL_MESSAGE,
1268:                                    new ActionMessage("general.message",
1269:                                            "Action Invocation Processor was successfully scheduled"));
1270:                    saveMessages(request, messages);
1271:                    return mapping.findForward("basic");
1272:                } catch (Exception e) {
1273:                    throw new WorkflowRuntimeException(e);
1274:                }
1275:            }
1276:
1277:            private UserService getUserService() {
1278:                return (UserService) KEWServiceLocator
1279:                        .getService(KEWServiceLocator.USER_SERVICE);
1280:            }
1281:
1282:            private DocumentTypeService getDocumentTypeService() {
1283:                return (DocumentTypeService) KEWServiceLocator
1284:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE);
1285:            }
1286:
1287:            private BranchService getBranchService() {
1288:                return (BranchService) KEWServiceLocator
1289:                        .getService(KEWServiceLocator.BRANCH_SERVICE);
1290:            }
1291:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.