Source Code Cross Referenced for DefaultProcessDefinition.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » workflow » domain » 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 » Workflow Engines » wfmopen 2.1.1 » de.danet.an.workflow.domain 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * This file is part of the WfMOpen project.
0003:         * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
0004:         * All rights reserved.
0005:         *
0006:         * This program is free software; you can redistribute it and/or modify
0007:         * it under the terms of the GNU General Public License as published by
0008:         * the Free Software Foundation; either version 2 of the License, or
0009:         * (at your option) any later version.
0010:         *
0011:         * This program is distributed in the hope that it will be useful,
0012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014:         * GNU General Public License for more details.
0015:         *
0016:         * You should have received a copy of the GNU General Public License
0017:         * along with this program; if not, write to the Free Software
0018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0019:         *
0020:         * $Id: DefaultProcessDefinition.java,v 1.10 2007/05/03 21:58:16 mlipp Exp $
0021:         *
0022:         * $Log: DefaultProcessDefinition.java,v $
0023:         * Revision 1.10  2007/05/03 21:58:16  mlipp
0024:         * Internal refactoring for making better use of local EJBs.
0025:         *
0026:         * Revision 1.9  2007/02/27 14:34:12  drmlipp
0027:         * Some refactoring to reduce cyclic dependencies.
0028:         *
0029:         * Revision 1.8  2006/09/29 12:32:08  drmlipp
0030:         * Consistently using WfMOpen as projct name now.
0031:         *
0032:         * Revision 1.7  2006/09/28 09:50:12  drmlipp
0033:         * Moved parsing methods to better place.
0034:         *
0035:         * Revision 1.6  2006/03/08 14:46:43  drmlipp
0036:         * Synchronized with 1.3.3p5.
0037:         *
0038:         * Revision 1.5  2005/04/22 15:11:02  drmlipp
0039:         * Merged changes from 1.3 branch up to 1.3p15.
0040:         *
0041:         * Revision 1.4.2.4  2005/04/19 09:32:16  drmlipp
0042:         * Moved warning about non-standard behaviour to proper place and made
0043:         * extended attribute specification more flexible.
0044:         *
0045:         * Revision 1.4.2.3  2005/04/16 21:18:30  drmlipp
0046:         * Made audit event filtering more flexible and added possibility to turn
0047:         * off audit log.
0048:         *
0049:         * Revision 1.4.2.2  2005/04/15 21:07:40  drmlipp
0050:         * Added "storeAuditEvents" flag.
0051:         *
0052:         * Revision 1.4.2.1  2005/04/14 15:10:39  drmlipp
0053:         * Added "filterable" event auditing.
0054:         *
0055:         * Revision 1.4  2005/01/21 09:57:08  drmlipp
0056:         * Validate only if syntactically OK.
0057:         *
0058:         * Revision 1.3  2004/08/20 09:17:34  drmlipp
0059:         * Fixed deserialization bug.
0060:         *
0061:         * Revision 1.2  2004/08/19 09:28:49  drmlipp
0062:         * Added check to import.
0063:         *
0064:         * Revision 1.1.1.3  2004/08/18 15:17:38  drmlipp
0065:         * Update to 1.2
0066:         *
0067:         * Revision 1.73  2004/04/28 14:19:21  lipp
0068:         * Getting started with SAX based process creation.
0069:         *
0070:         * Revision 1.72  2004/02/19 10:42:25  lipp
0071:         * Updated to jdom-b10rc1
0072:         *
0073:         * Revision 1.71  2003/08/21 13:42:37  lipp
0074:         * Implemented fallback for getResources for buggy class loaders.
0075:         *
0076:         * Revision 1.70  2003/06/27 08:51:45  lipp
0077:         * Fixed copyright/license information.
0078:         *
0079:         * Revision 1.69  2003/06/26 15:31:16  lipp
0080:         * Resolver library only used for documentation generation, not in
0081:         * application.
0082:         *
0083:         * Revision 1.68  2003/06/03 16:38:56  lipp
0084:         * Updated to jdom b9.
0085:         *
0086:         * Revision 1.67  2003/05/15 07:46:42  lipp
0087:         * Proper handling of JavaScript default double result.
0088:         *
0089:         * Revision 1.66  2003/05/12 19:01:02  lipp
0090:         * Fixed process definition version().
0091:         *
0092:         * Revision 1.65  2003/05/09 10:39:32  huaiyang
0093:         * read redefinable header in process and package.
0094:         *
0095:         * Revision 1.64  2003/05/07 09:48:33  lipp
0096:         * Completed asynchronous subflow implementation.
0097:         *
0098:         * Revision 1.63  2003/05/06 13:54:41  lipp
0099:         * Fixed null pointer exception.
0100:         *
0101:         * Revision 1.62  2003/05/06 13:21:30  lipp
0102:         * Resolved cyclic dependency.
0103:         *
0104:         * Revision 1.61  2003/05/05 07:04:51  lipp
0105:         * Handling parameters for sub-flow now.
0106:         *
0107:         * Revision 1.60  2003/05/02 08:21:54  lipp
0108:         * Some fixes handling tool properties specified by subtrees.
0109:         *
0110:         * Revision 1.59  2003/04/28 17:17:06  lipp
0111:         * Added formal parameters to context signature and initialize remoove
0112:         * closed from SAX now.
0113:         *
0114:         * Revision 1.58  2003/04/26 18:56:24  lipp
0115:         * Moved extended interfaces to own package.
0116:         *
0117:         * Revision 1.57  2003/04/25 20:05:32  lipp
0118:         * Retrieving participants from SAX now.
0119:         *
0120:         * Revision 1.56  2003/04/25 14:50:59  lipp
0121:         * Fixed javadoc errors and warnings.
0122:         *
0123:         * Revision 1.55  2003/04/24 19:47:50  lipp
0124:         * Removed dependency between general util and workflow api.
0125:         *
0126:         * Revision 1.54  2003/04/24 15:08:14  lipp
0127:         * Reading ApplicationDefinitiosn from SAX now.
0128:         *
0129:         * Revision 1.53  2003/04/23 14:27:35  lipp
0130:         * Improved modelling of header data.
0131:         *
0132:         * Revision 1.52  2003/04/22 16:38:12  lipp
0133:         * Retrieving resultSiganture from SAX.
0134:         *
0135:         * Revision 1.51  2003/04/22 14:56:57  lipp
0136:         * Using new delegate handler type.
0137:         *
0138:         * Revision 1.50  2003/04/22 14:34:56  lipp
0139:         * Retrieving context signature from SAX.
0140:         *
0141:         * Revision 1.49  2003/04/22 11:14:19  lipp
0142:         * Getting started with SAX based initialization.
0143:         *
0144:         * Revision 1.48  2003/04/21 21:27:09  lipp
0145:         * Prepared new intialization.
0146:         *
0147:         * Revision 1.47  2003/04/19 18:33:29  lipp
0148:         * Improved handling of info.
0149:         *
0150:         * Revision 1.46  2003/04/18 20:31:22  lipp
0151:         * Made SAXContentBuffer primary process definition representation.
0152:         *
0153:         * Revision 1.45  2003/04/17 21:05:17  lipp
0154:         * Made text primary representation (DOM trees simply need too much
0155:         * space).
0156:         *
0157:         * Revision 1.44  2003/04/08 11:49:04  lipp
0158:         * ResultSignature implemented.
0159:         *
0160:         * Revision 1.43  2003/04/02 09:30:05  lipp
0161:         * Supporting more data types.
0162:         *
0163:         * Revision 1.42  2003/03/31 16:50:28  huaiyang
0164:         * Logging using common-logging.
0165:         *
0166:         * Revision 1.41  2003/03/28 12:44:08  lipp
0167:         * Moved XPDL related constants to XPDLUtil.
0168:         *
0169:         * Revision 1.40  2003/03/28 11:41:59  lipp
0170:         * More changes for data type support.
0171:         *
0172:         * Revision 1.39  2003/03/27 16:32:20  lipp
0173:         * Started support for addditional data types.
0174:         *
0175:         * Revision 1.38  2003/03/07 14:09:02  huaiyang
0176:         * use non-static ProcDefValidator
0177:         *
0178:         * Revision 1.37  2003/03/07 08:00:43  huaiyang
0179:         * use workflow.util.CollectingErrorHandler to collect errors.
0180:         *
0181:         * Revision 1.36  2003/03/04 13:46:09  lipp
0182:         * Renamed processCOntext to contextSignature for ProcessDefinition.
0183:         *
0184:         * Revision 1.35  2003/03/03 15:31:50  lipp
0185:         * Updated implementation of time estimation.
0186:         *
0187:         * Revision 1.34  2002/12/19 21:37:43  lipp
0188:         * Reorganized interfaces.
0189:         *
0190:         * Revision 1.33  2002/12/03 13:48:59  huaiyang
0191:         * Add the check of otherwise condition.
0192:         *
0193:         * Revision 1.32  2002/12/02 15:55:31  huaiyang
0194:         * Replace ParseException with ImportException.
0195:         *
0196:         * Revision 1.31  2002/11/13 10:38:20  huaiyang
0197:         * SAXBuilder validate inputSource.
0198:         *
0199:         * Revision 1.30  2002/11/06 12:14:14  huaiyang
0200:         * Add the method of RemoveClosedProcess.
0201:         *
0202:         * Revision 1.29  2002/11/05 09:05:39  huaiyang
0203:         * Change the name of processContextData to processContextCache.
0204:         *
0205:         * Revision 1.28  2002/11/04 14:35:07  huaiyang
0206:         * Add the method of processContext.
0207:         *
0208:         * Revision 1.27  2002/10/15 13:22:32  huaiyang
0209:         * Remove system.out.println and printStackTrace.
0210:         *
0211:         * Revision 1.26  2002/09/27 12:44:55  lipp
0212:         * Moved validation to a separate class.
0213:         *
0214:         * Revision 1.25  2002/09/24 12:20:17  huaiyang
0215:         * Check the match of formal and actual parameter and if actual parameter
0216:         * defined.
0217:         *
0218:         * Revision 1.24  2002/09/19 15:20:38  huaiyang
0219:         * parseProcessDefinitions returns now a collection of process
0220:         * definition.
0221:         *
0222:         * Revision 1.23  2002/09/19 08:44:15  huaiyang
0223:         * Moved validate staff from AbstractProcessDefinitionDirectory to
0224:         * DefaultProcessDefinition.
0225:         *
0226:         * Revision 1.22  2002/09/19 08:32:27  lipp
0227:         * Added schema for XPDL extensions.
0228:         *
0229:         * Revision 1.21  2002/09/18 11:42:21  lipp
0230:         * Moved participant data access to process definition.
0231:         *
0232:         * Revision 1.20  2002/09/18 09:53:34  lipp
0233:         * Moved access to application data to process definition.
0234:         *
0235:         * Revision 1.19  2002/09/17 15:24:24  lipp
0236:         * Renamed Tool to Application and copied some functionality to
0237:         * ProcessDefintion.
0238:         *
0239:         * Revision 1.18  2002/09/11 06:33:32  huaiyang
0240:         * Remove the variable of prefix.
0241:         *
0242:         * Revision 1.17  2002/09/09 13:11:46  huaiyang
0243:         * Cleanup the unnecessary code for old style process definition.
0244:         *
0245:         * Revision 1.16  2002/09/09 11:21:04  lipp
0246:         * More deprecated usaged of process type removed.
0247:         *
0248:         * Revision 1.15  2002/09/08 18:49:17  lipp
0249:         * Proper use of packageId and processId.
0250:         *
0251:         * Revision 1.14  2002/09/04 15:14:33  lipp
0252:         * Removed dubious use of id as process definition identifier.
0253:         *
0254:         * Revision 1.13  2002/09/02 10:22:48  lipp
0255:         * Added XPDL name space.
0256:         *
0257:         * Revision 1.12  2002/08/28 09:22:09  huaiyang
0258:         * Compatible with new style of process definition spec.
0259:         *
0260:         * Revision 1.11  2002/08/27 11:36:37  lipp
0261:         * Better use of ProcessDefinition.
0262:         *
0263:         * Revision 1.10  2002/08/26 20:23:13  lipp
0264:         * Lots of method renames.
0265:         *
0266:         * Revision 1.9  2002/08/25 20:55:54  lipp
0267:         * Clearing up use of ProcessDefinition.
0268:         *
0269:         * Revision 1.8  2002/08/20 21:17:21  lipp
0270:         * Replaced JAREntityResolver with resolver library.
0271:         *
0272:         * Revision 1.7  2002/08/20 11:54:32  lipp
0273:         * Cleaned up usage of XPDL and JDOM representation of processes and
0274:         * process definitions.
0275:         *
0276:         * Revision 1.6  2002/08/14 09:38:13  lipp
0277:         * Added missing entity resolver helper.
0278:         *
0279:         * Revision 1.5  2002/08/01 14:19:50  huaiyang
0280:         * Use XPath to select elements of JDOM tree.
0281:         *
0282:         * Revision 1.4  2002/08/01 10:13:17  huaiyang
0283:         * Use JDOM instead of DOM now.
0284:         *
0285:         * Revision 1.3  2002/07/24 08:04:42  huaiyang
0286:         * doccheck.
0287:         *
0288:         * Revision 1.2  2002/01/29 09:08:43  huaiyang
0289:         * Modify the method of write to add docTypeHeader.
0290:         *
0291:         * Revision 1.1  2002/01/17 16:45:06  lipp
0292:         * ProcessDefinition moved to workflow.api.
0293:         *
0294:         */
0295:
0296:        package de.danet.an.workflow.domain;
0297:
0298:        import java.io.IOException;
0299:        import java.io.ObjectInputStream;
0300:        import java.io.Serializable;
0301:        import java.io.StringReader;
0302:        import java.io.StringWriter;
0303:
0304:        import java.util.ArrayList;
0305:        import java.util.Collection;
0306:        import java.util.HashMap;
0307:        import java.util.List;
0308:        import java.util.Map;
0309:
0310:        import javax.xml.parsers.ParserConfigurationException;
0311:        import javax.xml.parsers.SAXParser;
0312:        import javax.xml.parsers.SAXParserFactory;
0313:        import javax.xml.transform.TransformerConfigurationException;
0314:        import javax.xml.transform.TransformerFactory;
0315:        import javax.xml.transform.sax.SAXTransformerFactory;
0316:        import javax.xml.transform.sax.TransformerHandler;
0317:        import javax.xml.transform.stream.StreamResult;
0318:
0319:        import org.jdom.Document;
0320:        import org.jdom.Element;
0321:        import org.jdom.JDOMException;
0322:        import org.jdom.input.SAXHandler;
0323:        import org.jdom.output.SAXOutputter;
0324:        import org.xml.sax.Attributes;
0325:        import org.xml.sax.InputSource;
0326:        import org.xml.sax.SAXException;
0327:        import org.xml.sax.XMLReader;
0328:
0329:        import de.danet.an.util.sax.DelegatingHandler;
0330:        import de.danet.an.util.sax.HandlerStack;
0331:        import de.danet.an.util.sax.StackedHandler;
0332:        import de.danet.an.util.sax.XmlnsUrisPatcher;
0333:
0334:        import de.danet.an.workflow.util.SAXEventBufferImpl;
0335:        import de.danet.an.workflow.util.XPDLUtil;
0336:
0337:        import de.danet.an.workflow.omgcore.ProcessDataInfo;
0338:
0339:        import de.danet.an.workflow.api.Application;
0340:        import de.danet.an.workflow.api.FormalParameter;
0341:        import de.danet.an.workflow.api.ImportException;
0342:        import de.danet.an.workflow.api.InvalidIdException;
0343:        import de.danet.an.workflow.api.Participant;
0344:        import de.danet.an.workflow.api.ProcessDefinition;
0345:        import de.danet.an.workflow.api.SAXEventBuffer;
0346:
0347:        /**
0348:         * This class represents a process definitions with
0349:         * the root tag ProcessDefinition. It converts the input to the 
0350:         * respective objects in the process definition database.
0351:         */
0352:        public class DefaultProcessDefinition implements  ProcessDefinition,
0353:                Serializable {
0354:
0355:            /**
0356:             * logger of this class.
0357:             */
0358:            static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
0359:                    .getLog(DefaultProcessDefinition.class);
0360:
0361:            private final String packagePath = "/{" + XPDLUtil.XPDL_NS
0362:                    + "}Package";
0363:            private final String processPath = packagePath + "/{"
0364:                    + XPDLUtil.XPDL_NS + "}WorkflowProcesses" + "/{"
0365:                    + XPDLUtil.XPDL_NS + "}WorkflowProcess";
0366:            private final String applRelPath = "/{" + XPDLUtil.XPDL_NS
0367:                    + "}Applications" + "/{" + XPDLUtil.XPDL_NS
0368:                    + "}Application";
0369:            private final String extAttrRelPath = "/{" + XPDLUtil.XPDL_NS
0370:                    + "}ExtendedAttributes" + "/{" + XPDLUtil.XPDL_NS
0371:                    + "}ExtendedAttribute";
0372:
0373:            /*
0374:             * Implementation hint: this class is used as return value of a
0375:             * remote method call. Therefore care should be taken to keep the
0376:             * amount of data transfered (i.e. the number of non-transient
0377:             * attributes) small. Any information derived from the process
0378:             * description should be cached in transient attributes.
0379:             */
0380:
0381:            // name of the workflow process
0382:            private String packageId = null;
0383:
0384:            // name of the workflow process
0385:            private String processId = null;
0386:
0387:            // name of the workflow process
0388:            private String packageName = null;
0389:
0390:            // name of the workflow process
0391:            private String processName = null;
0392:
0393:            // the process description as SAX events.
0394:            // this is the primary representation.
0395:            private SAXEventBufferImpl procDef = null;
0396:
0397:            // the representation of process header date and package header data
0398:            private transient ProcessHeaderData processHeader = null;
0399:
0400:            // the context information of the process
0401:            private transient ProcessDataInfo contextSignature = null;
0402:
0403:            /** The result signature cache. */
0404:            private transient ProcessDataInfo resultSignature = null;
0405:
0406:            /** The formal parameters of the process. */
0407:            private transient FormalParameter[] formalParams;
0408:
0409:            /** The defined applications. */
0410:            private transient Map applications = null;
0411:
0412:            /** The defined participants. */
0413:            private transient Map participants = null;
0414:
0415:            /** The remove closed process extended attribute. */
0416:            private transient Integer cleanupMode = null;
0417:
0418:            /** The audit state change events only extended attribute. */
0419:            private transient Integer auditEventSelection = null;
0420:
0421:            /** The audit state change events only extended attribute. */
0422:            private transient Boolean storeAuditEvents = null;
0423:
0424:            /**
0425:             * This class defines the elements of package header.
0426:             */
0427:            public static class DefaultPackageHeader implements 
0428:                    ProcessDefinition.PackageHeaderData, Serializable {
0429:
0430:                private String xpdlVersion = null;
0431:                private String vendor = null;
0432:                private String created = null;
0433:                private String description = null;
0434:                private String documentation = null;
0435:                private String priorityUnit = null;
0436:                private String costUnit = null;
0437:
0438:                /**
0439:                 * Version of the process definition specification.
0440:                 * @return the version.
0441:                 */
0442:                public String xpdlVersion() {
0443:                    return xpdlVersion;
0444:                }
0445:
0446:                /**
0447:                 * Defines the origin of this model definition 
0448:                 * and contains vendor's name, vendor's product name
0449:                 * and product's release number.
0450:                 * @return the vendor.
0451:                 */
0452:                public String vendor() {
0453:                    return vendor;
0454:                }
0455:
0456:                /**
0457:                 * Creation date of package definition.
0458:                 * @return the created time.
0459:                 */
0460:                public String created() {
0461:                    return created;
0462:                }
0463:
0464:                /**
0465:                 * Short description of the package definition.
0466:                 * @return the description.
0467:                 */
0468:                public String description() {
0469:                    return description;
0470:                }
0471:
0472:                /**
0473:                 * Operating system specific path and -filename 
0474:                 * of help file/description file.
0475:                 * @return the documentation.
0476:                 */
0477:                public String documentation() {
0478:                    return documentation;
0479:                }
0480:
0481:                /**
0482:                 * Units used in simulation data.
0483:                 * @return the priority unit.
0484:                 */
0485:                public String priorityUnit() {
0486:                    return priorityUnit;
0487:                }
0488:
0489:                /**
0490:                 * Units used in simulation data.
0491:                 * @return the cost unit.
0492:                 */
0493:                public String costUnit() {
0494:                    return costUnit;
0495:                }
0496:
0497:                /**
0498:                 * A helper class that can be used to initialize this class
0499:                 * from SAX events.
0500:                 */
0501:                public class SAXInitializer extends StackedHandler {
0502:                    /**
0503:                     * Receive notification of the end of an element.
0504:                     *
0505:                     * @param uri the Namespace URI, or the empty string if the
0506:                     * element has no Namespace URI or if Namespace processing is not
0507:                     * being performed.
0508:                     * @param loc the local name (without prefix), or the empty string
0509:                     * if Namespace processing is not being performed.
0510:                     * @param raw the raw XML 1.0 name (with prefix), or the empty
0511:                     * string if raw names are not available.
0512:                     * @throws SAXException not thrown.
0513:                     */
0514:                    public void endElement(String uri, String loc, String raw)
0515:                            throws SAXException {
0516:                        if (loc.equals("XPDLVersion")) {
0517:                            xpdlVersion = text();
0518:                        } else if (loc.equals("Vendor")) {
0519:                            vendor = text();
0520:                        } else if (loc.equals("Created")) {
0521:                            created = text();
0522:                        } else if (loc.equals("Description")) {
0523:                            description = text();
0524:                        } else if (loc.equals("Documentation")) {
0525:                            documentation = text();
0526:                        } else if (loc.equals("PriorityUnit")) {
0527:                            priorityUnit = text();
0528:                        } else if (loc.equals("CostUnit")) {
0529:                            costUnit = text();
0530:                        }
0531:                    }
0532:                }
0533:
0534:                /**
0535:                 * Return a handler that can be used to initialize an object
0536:                 * from SAX events.
0537:                 * @return the handler.
0538:                 */
0539:                StackedHandler saxInitializer() {
0540:                    return new SAXInitializer();
0541:                }
0542:            }
0543:
0544:            /**
0545:             * This class defines the elements of the process header.
0546:             */
0547:            public static class DefaultProcessHeader implements 
0548:                    ProcessHeaderData, Serializable {
0549:
0550:                private String created = null;
0551:                private String description = null;
0552:                private String priority = null;
0553:                private String limit = null;
0554:                private String validFrom = null;
0555:                private String validTo = null;
0556:                private String timeEstimationWaiting = null;
0557:                private String timeEstimationWorking = null;
0558:                private String timeEstimationDuration = null;
0559:                private String author = null;
0560:                private String codepage = null;
0561:                private String countrykey = null;
0562:                private String publicationStatus = null;
0563:                private List responsibles = null;
0564:                private String version = null;
0565:                private PackageHeaderData packageHeader;
0566:
0567:                /**
0568:                 * Default constructor.
0569:                 */
0570:                public DefaultProcessHeader() {
0571:                    packageHeader = new DefaultPackageHeader();
0572:                }
0573:
0574:                /**
0575:                 * Dreation date of the process definition.
0576:                 * @return the created information.
0577:                 */
0578:                public String created() {
0579:                    return created;
0580:                }
0581:
0582:                /**
0583:                 * Short description of the process definition.
0584:                 * @return the description.
0585:                 */
0586:                public String description() {
0587:                    return description;
0588:                }
0589:
0590:                /**
0591:                 * Priority of the process type.
0592:                 * @return the priority.
0593:                 */
0594:                public String priority() {
0595:                    return priority;
0596:                }
0597:
0598:                /**
0599:                 * Expected duration for time management purposes in units
0600:                 * of duration unit (duration unit does not present in this class).
0601:                 * @return the limit.
0602:                 */
0603:                public String limit() {
0604:                    return limit;
0605:                }
0606:
0607:                /**
0608:                 * Date that the workflow process definition is active from.
0609:                 * @return the valid from date.
0610:                 */
0611:                public String validFrom() {
0612:                    return validFrom;
0613:                }
0614:
0615:                /**
0616:                 * Date at witch the process definition becomes valid.
0617:                 * @return the valid to date.
0618:                 */
0619:                public String validTo() {
0620:                    return validTo;
0621:                }
0622:
0623:                /**
0624:                 * Describes the amount of time the performer of the activity
0625:                 * needs to perform the task.
0626:                 * @return the estimated time.
0627:                 */
0628:                public String timeEstimationWaiting() {
0629:                    return timeEstimationWaiting;
0630:                }
0631:
0632:                /**
0633:                 * Describes the amount of time the performer of the activity
0634:                 * needs to perform the task.
0635:                 * @return the estimated time.
0636:                 */
0637:                public String timeEstimationWorking() {
0638:                    return timeEstimationWorking;
0639:                }
0640:
0641:                /**
0642:                 * Describes the amount of time the performer of the activity
0643:                 * needs to perform the task.
0644:                 * @return the estimated time.
0645:                 */
0646:                public String timeEstimationDuration() {
0647:                    return timeEstimationDuration;
0648:                }
0649:
0650:                /**
0651:                 * Name of the author of this workflow process definition.
0652:                 * @return the author.
0653:                 */
0654:                public String author() {
0655:                    return author;
0656:                }
0657:
0658:                /**
0659:                 * Describes the version of this workflow process definition.
0660:                 * @return the version.
0661:                 */
0662:                public String version() {
0663:                    return version;
0664:                }
0665:
0666:                /**
0667:                 * Describes the codepage used for the text parts.
0668:                 * @return the codepage.
0669:                 */
0670:                public String codepage() {
0671:                    return codepage;
0672:                }
0673:
0674:                /**
0675:                 * Describes the country code based on ISO 3166. It could
0676:                 * be either the three digits country code number, or the
0677:                 * two alpha characters country codes.
0678:                 * @return the country code.
0679:                 */
0680:                public String countrykey() {
0681:                    return countrykey;
0682:                }
0683:
0684:                /**
0685:                 * Describes the status of the Workflow Process Definition.
0686:                 * @return the status.
0687:                 */
0688:                public String publicationStatus() {
0689:                    return publicationStatus;
0690:                }
0691:
0692:                /**
0693:                 * Describes the responsible Workflow participant(s). It is assumed
0694:                 * that the responsible is the supervisor during the execution 
0695:                 * of the process.
0696:                 * @return the list of responsible Workflow participant in String.
0697:                 */
0698:                public List responsibles() {
0699:                    return responsibles;
0700:                }
0701:
0702:                /**
0703:                 * The elements of package header.
0704:                 * @return the package header.
0705:                 */
0706:                public PackageHeaderData packageHeader() {
0707:                    return packageHeader;
0708:                }
0709:
0710:                /**
0711:                 * A helper class that can be used to initialize this class
0712:                 * from SAX events.
0713:                 */
0714:                public class SAXInitializer extends StackedHandler {
0715:                    /**
0716:                     * Receive notification of the beginning of an element.
0717:                     *
0718:                     * @param uri the Namespace URI, or the empty string if the
0719:                     * element has no Namespace URI or if Namespace processing is not
0720:                     * being performed.
0721:                     * @param loc the local name (without prefix), or the empty string
0722:                     * if Namespace processing is not being performed.
0723:                     * @param raw the raw XML 1.0 name (with prefix), or the empty
0724:                     * string if raw names are not available.
0725:                     * @param a the attributes attached to the element. If there are
0726:                     * no attributes, it shall be an empty Attributes object.
0727:                     * @throws SAXException not thrown.
0728:                     */
0729:                    public void startElement(String uri, String loc,
0730:                            String raw, Attributes a) throws SAXException {
0731:                        if (loc.equals("RedefinableHeader")) {
0732:                            publicationStatus = a.getValue("PublicationStatus");
0733:                        } else if (loc.equals("Responsibles")) {
0734:                            responsibles = new ArrayList();
0735:                        }
0736:                    }
0737:
0738:                    /**
0739:                     * Receive notification of the end of an element.
0740:                     *
0741:                     * @param uri the Namespace URI, or the empty string if the
0742:                     * element has no Namespace URI or if Namespace processing is not
0743:                     * being performed.
0744:                     * @param loc the local name (without prefix), or the empty string
0745:                     * if Namespace processing is not being performed.
0746:                     * @param raw the raw XML 1.0 name (with prefix), or the empty
0747:                     * string if raw names are not available.
0748:                     * @throws SAXException not thrown.
0749:                     */
0750:                    public void endElement(String uri, String loc, String raw)
0751:                            throws SAXException {
0752:                        if (loc.equals("Created")) {
0753:                            created = text();
0754:                        } else if (loc.equals("Description")) {
0755:                            description = text();
0756:                        } else if (loc.equals("Priority")) {
0757:                            priority = text();
0758:                        } else if (loc.equals("Limit")) {
0759:                            limit = text();
0760:                        } else if (loc.equals("ValidFrom")) {
0761:                            validFrom = text();
0762:                        } else if (loc.equals("ValidTo")) {
0763:                            validTo = text();
0764:                        } else if (loc.equals("WaitingTime")) {
0765:                            timeEstimationWaiting = text();
0766:                        } else if (loc.equals("WorkingTime")) {
0767:                            timeEstimationWorking = text();
0768:                        } else if (loc.equals("Duration")) {
0769:                            timeEstimationDuration = text();
0770:                        } else if (loc.equals("Author")) {
0771:                            author = text();
0772:                        } else if (loc.equals("Version")) {
0773:                            version = text();
0774:                        } else if (loc.equals("Codepage")) {
0775:                            codepage = text();
0776:                        } else if (loc.equals("Countrykey")) {
0777:                            countrykey = text();
0778:                        } else if (loc.equals("Responsible")) {
0779:                            responsibles.add(text());
0780:                        }
0781:                    }
0782:                }
0783:
0784:                /**
0785:                 * Return a handler that can be used to initialize an object
0786:                 * from SAX events.
0787:                 * @return the handler.
0788:                 */
0789:                StackedHandler saxInitializer() {
0790:                    return new SAXInitializer();
0791:                }
0792:            }
0793:
0794:            /**
0795:             * Construct a new <code>DefaultProcessDefinition</code> from a 
0796:             * JDOM document.
0797:             *
0798:             * @param processDefinition parsed process definition
0799:             * as <code>Document</code>.
0800:             * @throws JDOMException If an error occurs. 
0801:             * @throws ImportException if the XPDL is not correct.
0802:             */
0803:            public DefaultProcessDefinition(Document processDefinition)
0804:                    throws JDOMException, ImportException {
0805:                try {
0806:                    SAXOutputter outputter = new SAXOutputter();
0807:                    procDef = new SAXEventBufferImpl();
0808:                    outputter.setContentHandler(procDef);
0809:                    outputter.setLexicalHandler(procDef);
0810:                    outputter.output(processDefinition);
0811:                } catch (JDOMException e) {
0812:                    String s = "Cannot get XPDL from DOM: " + e.getMessage();
0813:                    logger.error(s, e);
0814:                    throw new IllegalArgumentException(s);
0815:                }
0816:                init();
0817:            }
0818:
0819:            /**
0820:             * Construct a new <code>DefaultProcessDefinition</code> from an 
0821:             * XPDL Document.<P>
0822:             *
0823:             * This constructor assumes that XPDL has been verified before, i.e.
0824:             * it parses the process definition with verification turned off.
0825:             *
0826:             * @param xpdl String representation of the process definition
0827:             * @throws IOException If an error occurs. 
0828:             * @throws ImportException if the XPDL is not correct.
0829:             */
0830:            public DefaultProcessDefinition(String xpdl) throws IOException,
0831:                    ImportException {
0832:                try {
0833:                    SAXParserFactory pf = SAXParserFactory.newInstance();
0834:                    pf.setValidating(false);
0835:                    pf.setNamespaceAware(true);
0836:                    pf.setFeature(
0837:                            "http://xml.org/sax/features/namespace-prefixes",
0838:                            true);
0839:                    XMLReader reader = null;
0840:                    try {
0841:                        pf.setFeature("http://xml.org/sax/features/xmlns-uris",
0842:                                true);
0843:                        SAXParser parser = pf.newSAXParser();
0844:                        reader = parser.getXMLReader();
0845:                    } catch (SAXException e) {
0846:                        SAXParser parser = pf.newSAXParser();
0847:                        reader = new XmlnsUrisPatcher(parser.getXMLReader());
0848:                    }
0849:                    procDef = new SAXEventBufferImpl();
0850:                    reader.setContentHandler(procDef);
0851:                    // Parse the file
0852:                    InputSource inSrc = new InputSource(new StringReader(xpdl));
0853:                    reader.parse(inSrc);
0854:                    init();
0855:                } catch (SAXException e) {
0856:                    String s = "Cannot read XPDL: " + e.getMessage();
0857:                    logger.error(s, e);
0858:                    throw new IOException(s);
0859:                } catch (ParserConfigurationException e) {
0860:                    String s = "Cannot read XPDL: " + e.getMessage();
0861:                    logger.fatal(s, e);
0862:                    throw new IllegalStateException(s);
0863:                }
0864:            }
0865:
0866:            private void readObject(ObjectInputStream stream)
0867:                    throws IOException, ClassNotFoundException {
0868:                stream.defaultReadObject();
0869:                init();
0870:            }
0871:
0872:            private class MyDelegatingHandler extends DelegatingHandler {
0873:                private ApplicationDefinition applDef = null;
0874:
0875:                // Add some "on the fly" handling
0876:                public void startElement(String uri, String loc, String raw,
0877:                        Attributes a) throws SAXException {
0878:                    super .startElement(uri, loc, raw, a);
0879:                    String curPath = currentPath();
0880:                    if (curPath.equals(packagePath)) {
0881:                        packageId = a.getValue("Id");
0882:                        packageName = a.getValue("Name");
0883:                    } else if (curPath.equals(processPath)) {
0884:                        processId = a.getValue("Id");
0885:                        processName = a.getValue("Name");
0886:                    } else if (curPath.equals(packagePath + applRelPath)
0887:                            || (curPath.equals(processPath + applRelPath))) {
0888:                        applDef = new ApplicationDefinition();
0889:                        getStack().push(applDef.saxInitializer());
0890:                    }
0891:                }
0892:
0893:                public void endElement(String uri, String loc, String raw)
0894:                        throws SAXException {
0895:                    if (applDef != null) {
0896:                        applications.put(applDef.id(), applDef);
0897:                        applDef = null;
0898:                    } else if (uri.equals(XPDLUtil.XPDL_NS)
0899:                            && loc.equals("Participant")) {
0900:                        Participant p = (Participant) getStack()
0901:                                .removeContextData("Participant");
0902:                        participants.put(p.getId(), p);
0903:                    }
0904:                }
0905:            }
0906:
0907:            /**
0908:             * Initialize this <code>DefaultProcessDefinition</code> from the
0909:             * SAX events.
0910:             */
0911:            private void init() {
0912:                formalParams = new FormalParameter[0];
0913:
0914:                final String dfRelPath = "/{" + XPDLUtil.XPDL_NS
0915:                        + "}DataFields";
0916:                final String partiRelPath = "/{" + XPDLUtil.XPDL_NS
0917:                        + "}Participants" + "/{" + XPDLUtil.XPDL_NS
0918:                        + "}Participant";
0919:                try {
0920:                    DelegatingHandler dh = new MyDelegatingHandler();
0921:                    processHeader = new DefaultProcessHeader();
0922:                    dh.addHandler(packagePath + "/{" + XPDLUtil.XPDL_NS
0923:                            + "}PackageHeader",
0924:                            ((DefaultPackageHeader) processHeader
0925:                                    .packageHeader()).saxInitializer());
0926:                    dh.addHandler(processPath + "/{" + XPDLUtil.XPDL_NS
0927:                            + "}ProcessHeader",
0928:                            ((DefaultProcessHeader) processHeader)
0929:                                    .saxInitializer());
0930:                    dh.addHandler(packagePath + "/{" + XPDLUtil.XPDL_NS
0931:                            + "}RedefinableHeader",
0932:                            ((DefaultProcessHeader) processHeader)
0933:                                    .saxInitializer());
0934:                    dh.addHandler(processPath + "/{" + XPDLUtil.XPDL_NS
0935:                            + "}RedefinableHeader",
0936:                            ((DefaultProcessHeader) processHeader)
0937:                                    .saxInitializer());
0938:                    StackedHandler dfh = new SAXDataFieldHandler();
0939:                    contextSignature = new DefaultProcessDataInfo();
0940:                    dh.addHandler(packagePath + dfRelPath, dfh);
0941:                    dh.addHandler(processPath + dfRelPath, dfh);
0942:                    resultSignature = new DefaultProcessDataInfo();
0943:                    dh.addHandler(processPath + "/{" + XPDLUtil.XPDL_NS
0944:                            + "}FormalParameters",
0945:                            new SAXFormalParameterHandler());
0946:                    participants = new HashMap();
0947:                    dh.addHandler(packagePath + partiRelPath,
0948:                            DefaultParticipant.SAXInitializer.class);
0949:                    dh.addHandler(processPath + partiRelPath,
0950:                            DefaultParticipant.SAXInitializer.class);
0951:                    StackedHandler extAttrHandler = new SAXExtAttrHandler();
0952:                    dh.addHandler(packagePath + extAttrRelPath, extAttrHandler);
0953:                    dh.addHandler(processPath + extAttrRelPath, extAttrHandler);
0954:                    applications = new HashMap();
0955:                    HandlerStack hs = new HandlerStack(dh);
0956:                    procDef.emit(hs.contentHandler(), null);
0957:                } catch (SAXException e) {
0958:                    String s = "Cannot initialize: " + e.getMessage();
0959:                    logger.error(s, e);
0960:                    throw new IllegalStateException(s);
0961:                }
0962:            }
0963:
0964:            /**
0965:             * Helper class for retrieving the context info from the process
0966:             * definition.
0967:             */
0968:            public class SAXDataFieldHandler extends StackedHandler {
0969:
0970:                private String dfId = null;
0971:
0972:                /**
0973:                 * Receive notification of the beginning of an element.
0974:                 *
0975:                 * @param uri the Namespace URI, or the empty string if the
0976:                 * element has no Namespace URI or if Namespace processing is not
0977:                 * being performed.
0978:                 * @param loc the local name (without prefix), or the empty string
0979:                 * if Namespace processing is not being performed.
0980:                 * @param raw the raw XML 1.0 name (with prefix), or the empty
0981:                 * string if raw names are not available.
0982:                 * @param a the attributes attached to the element. If there are
0983:                 * no attributes, it shall be an empty Attributes object.
0984:                 * @throws SAXException not thrown.
0985:                 */
0986:                public void startElement(String uri, String loc, String raw,
0987:                        Attributes a) throws SAXException {
0988:                    if (loc.equals("DataField")) {
0989:                        dfId = a.getValue("Id");
0990:                    } else if (loc.equals("DataType")) {
0991:                        getStack().push(new XPDLUtil.SAXDataTypeHandler());
0992:                    }
0993:                }
0994:
0995:                /**
0996:                 * Receive notification of the end of an element.
0997:                 *
0998:                 * @param uri the Namespace URI, or the empty string if the
0999:                 * element has no Namespace URI or if Namespace processing is not
1000:                 * being performed.
1001:                 * @param loc the local name (without prefix), or the empty string
1002:                 * if Namespace processing is not being performed.
1003:                 * @param raw the raw XML 1.0 name (with prefix), or the empty
1004:                 * string if raw names are not available.
1005:                 * @throws SAXException not thrown.
1006:                 */
1007:                public void endElement(String uri, String loc, String raw)
1008:                        throws SAXException {
1009:                    if (loc.equals("DataField")) {
1010:                        Object dtc = removeContextData("DataType");
1011:                        if (dtc == null) {
1012:                            logger
1013:                                    .error("Unknown data type in data field with id = \""
1014:                                            + dfId + "\".");
1015:                            return;
1016:                        }
1017:                        contextSignature.put(dfId, dtc);
1018:                    }
1019:                }
1020:            }
1021:
1022:            /**
1023:             * Helper class for retrieving the formal parameter info from the process
1024:             * definition.
1025:             */
1026:            public class SAXFormalParameterHandler extends StackedHandler {
1027:
1028:                private String fpId = null;
1029:                private int fpIdx = 0;
1030:                private FormalParameter.Mode fpMode = null;
1031:                private List fps = null;
1032:
1033:                /**
1034:                 * Receive notification of the beginning of an element.
1035:                 *
1036:                 * @param uri the Namespace URI, or the empty string if the
1037:                 * element has no Namespace URI or if Namespace processing is not
1038:                 * being performed.
1039:                 * @param loc the local name (without prefix), or the empty string
1040:                 * if Namespace processing is not being performed.
1041:                 * @param raw the raw XML 1.0 name (with prefix), or the empty
1042:                 * string if raw names are not available.
1043:                 * @param a the attributes attached to the element. If there are
1044:                 * no attributes, it shall be an empty Attributes object.
1045:                 * @throws SAXException not thrown.
1046:                 */
1047:                public void startElement(String uri, String loc, String raw,
1048:                        Attributes a) throws SAXException {
1049:                    if (loc.equals("FormalParameters")) {
1050:                        fps = new ArrayList();
1051:                    } else if (loc.equals("FormalParameter")) {
1052:                        fpId = a.getValue("Id");
1053:                        fpMode = FormalParameter.Mode.fromString(a
1054:                                .getValue("Mode"));
1055:                    } else if (loc.equals("DataType")) {
1056:                        getStack().push(new XPDLUtil.SAXDataTypeHandler());
1057:                    }
1058:                }
1059:
1060:                /**
1061:                 * Receive notification of the end of an element.
1062:                 *
1063:                 * @param uri the Namespace URI, or the empty string if the
1064:                 * element has no Namespace URI or if Namespace processing is not
1065:                 * being performed.
1066:                 * @param loc the local name (without prefix), or the empty string
1067:                 * if Namespace processing is not being performed.
1068:                 * @param raw the raw XML 1.0 name (with prefix), or the empty
1069:                 * string if raw names are not available.
1070:                 * @throws SAXException not thrown.
1071:                 */
1072:                public void endElement(String uri, String loc, String raw)
1073:                        throws SAXException {
1074:                    if (loc.equals("FormalParameter")) {
1075:                        Object dtc = removeContextData("DataType");
1076:                        if (dtc == null) {
1077:                            logger
1078:                                    .error("Unknown data type in formal parameter "
1079:                                            + "with id = \"" + fpId + "\".");
1080:                            return;
1081:                        }
1082:                        if (fpMode != FormalParameter.Mode.IN) {
1083:                            resultSignature.put(fpId, dtc);
1084:                        }
1085:                        contextSignature.put(fpId, dtc);
1086:                        fps.add(new FormalParameter(fpId, Integer
1087:                                .toString(fpIdx++), fpMode, dtc));
1088:                    } else if (loc.equals("FormalParameters")) {
1089:                        formalParams = (FormalParameter[]) fps
1090:                                .toArray(new FormalParameter[fps.size()]);
1091:                    }
1092:                }
1093:            }
1094:
1095:            /**
1096:             * Helper class for retrieving extended attributes from the process
1097:             * definition.
1098:             */
1099:            public class SAXExtAttrHandler extends StackedHandler {
1100:
1101:                private String waitingFor = null;
1102:                private String valueAttr = null;
1103:
1104:                /**
1105:                 * Receive notification of the beginning of an element.
1106:                 *
1107:                 * @param uri the Namespace URI, or the empty string if the
1108:                 * element has no Namespace URI or if Namespace processing is not
1109:                 * being performed.
1110:                 * @param loc the local name (without prefix), or the empty string
1111:                 * if Namespace processing is not being performed.
1112:                 * @param raw the raw XML 1.0 name (with prefix), or the empty
1113:                 * string if raw names are not available.
1114:                 * @param a the attributes attached to the element. If there are
1115:                 * no attributes, it shall be an empty Attributes object.
1116:                 * @throws SAXException not thrown.
1117:                 */
1118:                public void startElement(String uri, String loc, String raw,
1119:                        Attributes a) throws SAXException {
1120:                    waitingFor = a.getValue("Name");
1121:                    if (waitingFor == null) {
1122:                        waitingFor = "(unknown)";
1123:                    }
1124:                    valueAttr = a.getValue("Value");
1125:                }
1126:
1127:                /**
1128:                 * Receive notification of the end of an element.
1129:                 *
1130:                 * @param uri the Namespace URI, or the empty string if the
1131:                 * element has no Namespace URI or if Namespace processing is not
1132:                 * being performed.
1133:                 * @param loc the local name (without prefix), or the empty string
1134:                 * if Namespace processing is not being performed.
1135:                 * @param raw the raw XML 1.0 name (with prefix), or the empty
1136:                 * string if raw names are not available.
1137:                 * @throws SAXException not thrown.
1138:                 */
1139:                public void endElement(String uri, String loc, String raw)
1140:                        throws SAXException {
1141:                    if (waitingFor.equals("RemoveClosedProcess")) {
1142:                        // note that for extended attributes process level values
1143:                        // preceed package level settings.
1144:                        if (cleanupMode != null) {
1145:                            return;
1146:                        }
1147:                        if (valueAttr == null) {
1148:                            valueAttr = getStack().text().trim();
1149:                        }
1150:                        cleanupMode = new Integer(REMOVE_AUTOMATIC);
1151:                        if (valueAttr.equals("MANUAL")) {
1152:                            cleanupMode = new Integer(REMOVE_MANUAL);
1153:                        } else if (valueAttr.equals("COMPLETED")) {
1154:                            cleanupMode = new Integer(REMOVE_COMPLETED);
1155:                        }
1156:                        return;
1157:                    }
1158:                    if (waitingFor.equals("AuditEventSelection")) {
1159:                        // note that for extended attributes process level values
1160:                        // preceed package level settings.
1161:                        if (auditEventSelection != null) {
1162:                            return;
1163:                        }
1164:                        if (valueAttr == null) {
1165:                            valueAttr = getStack().text().trim();
1166:                        }
1167:                        if (valueAttr.equals("AllEvents")) {
1168:                            auditEventSelection = new Integer(
1169:                                    ProcessDefinition.AUDIT_SELECTION_ALL_EVENTS);
1170:                        }
1171:                        if (valueAttr.equals("StateEventsOnly")) {
1172:                            auditEventSelection = new Integer(
1173:                                    ProcessDefinition.AUDIT_SELECTION_STATE_EVENTS_ONLY);
1174:                        }
1175:                        if (valueAttr.equals("ProcessClosedEventsOnly")) {
1176:                            auditEventSelection = new Integer(
1177:                                    ProcessDefinition.AUDIT_SELECTION_PROCESS_CLOSED_EVENTS_ONLY);
1178:                        }
1179:                        if (valueAttr.equals("NoEvents")) {
1180:                            auditEventSelection = new Integer(
1181:                                    ProcessDefinition.AUDIT_SELECTION_NO_EVENTS);
1182:                        }
1183:                        return;
1184:                    }
1185:                    if (waitingFor.equals("StoreAuditEvents")) {
1186:                        // note that for extended attributes process level values
1187:                        // preceed package level settings.
1188:                        if (storeAuditEvents != null) {
1189:                            return;
1190:                        }
1191:                        if (valueAttr == null) {
1192:                            valueAttr = getStack().text().trim();
1193:                        }
1194:                        storeAuditEvents = new Boolean(valueAttr
1195:                                .equalsIgnoreCase("true"));
1196:                        return;
1197:                    }
1198:                }
1199:            }
1200:
1201:            /**
1202:             * Return the id of the package. 
1203:             * @return id of the package in String.
1204:             */
1205:            public String packageId() {
1206:                return packageId;
1207:            }
1208:
1209:            /**
1210:             * Return the id of the process. 
1211:             * @return id of the process in String.
1212:             */
1213:            public String processId() {
1214:                return processId;
1215:            }
1216:
1217:            /**
1218:             * Return the name of the package. 
1219:             * @return name of the package in String.
1220:             */
1221:            public String packageName() {
1222:                return packageName;
1223:            }
1224:
1225:            /**
1226:             * Return the name of the process. 
1227:             * @return name of the process in String.
1228:             */
1229:            public String processName() {
1230:                return processName;
1231:            }
1232:
1233:            /**
1234:             * Return the name of the process manager. 
1235:             * @return name of the process manager as String.
1236:             */
1237:            public String mgrName() {
1238:                return packageId + "/" + processId;
1239:            }
1240:
1241:            /**
1242:             * Return the version of the process manager. 
1243:             * @return version of the process manager as String.
1244:             */
1245:            public String version() {
1246:                return processHeader().version();
1247:            }
1248:
1249:            /**
1250:             * Returns the meta information that describes the context for
1251:             * this kind of process. Equivalent to calling {@link
1252:             * de.danet.an.workflow.localcoreapi.WfProcessMgrLocal#contextSignature
1253:             * <code>contextSignature</code>} on a process manager for this
1254:             * kind of process.
1255:             * @return the process meta information.
1256:             * @see de.danet.an.workflow.localcoreapi.WfProcessMgrLocal#contextSignature
1257:             */
1258:            public ProcessDataInfo contextSignature() {
1259:                return contextSignature;
1260:            }
1261:
1262:            /**
1263:             * Returns the meta information that describes the result for this
1264:             * kind of process. Equivalent to calling {@link
1265:             * de.danet.an.workflow.localcoreapi.WfProcessMgrLocal#resultSignature
1266:             * <code>resultSignature</code>} on a process manager for this
1267:             * kind of process.<P>
1268:             *
1269:             * The implementation returns all formal IN or INOUT parameters.
1270:             * 
1271:             * @return the process meta information.
1272:             * @see de.danet.an.workflow.localcoreapi.WfProcessMgrLocal#resultSignature
1273:             */
1274:            public ProcessDataInfo resultSignature() {
1275:                return resultSignature;
1276:            }
1277:
1278:            /**
1279:             * Returns the meta information that describes the formal parameters
1280:             * for this kind of process.
1281:             * @return the process meta information.
1282:             */
1283:            public FormalParameter[] formalParameters() {
1284:                return formalParams;
1285:            }
1286:
1287:            /**
1288:             * Return the process definition as SAX event buffer.
1289:             * @return the process definition
1290:             */
1291:            public SAXEventBuffer toSAX() {
1292:                return procDef;
1293:            }
1294:
1295:            /**
1296:             * Use XMLOutputter to transfer process definition presented as JDOM Tree 
1297:             * in String. 
1298:             * @return the process definition in String. 
1299:             */
1300:            public String toXPDL() {
1301:                try {
1302:                    TransformerFactory tf = TransformerFactory.newInstance();
1303:                    if (!tf.getFeature(SAXTransformerFactory.FEATURE)) {
1304:                        String s = "JAXP transformer factory does not support"
1305:                                + " a SAX transformer!";
1306:                        logger.fatal(s);
1307:                        throw new IllegalStateException(s);
1308:                    }
1309:                    TransformerHandler th = ((SAXTransformerFactory) tf)
1310:                            .newTransformerHandler();
1311:                    StringWriter out = new StringWriter();
1312:                    th.setResult(new StreamResult(out));
1313:                    procDef.emit(th, th);
1314:                    return out.toString();
1315:                } catch (SAXException e) {
1316:                    String s = "Error generating XPDL as string: "
1317:                            + e.getMessage();
1318:                    logger.error(s, e);
1319:                    throw new IllegalStateException(s);
1320:                } catch (TransformerConfigurationException e) {
1321:                    String s = "Error generating XPDL as string: "
1322:                            + e.getMessage();
1323:                    logger.error(s, e);
1324:                    throw new IllegalStateException(s);
1325:                }
1326:            }
1327:
1328:            /** 
1329:             * Return the process definition presented as JDOM document.
1330:             *
1331:             * @return the process definition presented as JDOM document.
1332:             */
1333:            public Document toJDOM() {
1334:                try {
1335:                    SAXHandler sh = new SAXHandler();
1336:                    procDef.emit(sh, sh);
1337:                    return sh.getDocument();
1338:                } catch (SAXException e) {
1339:                    logger.error(e.getMessage(), e);
1340:                    throw new IllegalStateException(
1341:                            "Error generating XPDL as JDOM: " + e.getMessage());
1342:                }
1343:            }
1344:
1345:            /** Return the process header data of this process definition.
1346:             *
1347:             * @return the process header data of this process definition.
1348:             */
1349:            public ProcessHeaderData processHeader() {
1350:                return processHeader;
1351:            }
1352:
1353:            /**
1354:             * Extracts all the applications definition in the package and
1355:             * in this process and use it to generate a collection of 
1356:             * <code>ApplicationDefinition</code>. 
1357:             * @return a collection of <code>ApplicationDefinition</code>. 
1358:             */
1359:            public Collection applications() {
1360:                return applications.values();
1361:            }
1362:
1363:            /**
1364:             * Find out the dedicated application using the given id. 
1365:             * @param id the given id of the application to be found.
1366:             * @throws InvalidIdException If no such application be found
1367:             * @return the dedicated application. 
1368:             */
1369:            public Application applicationById(String id)
1370:                    throws InvalidIdException {
1371:                Application a = (Application) applications.get(id);
1372:                if (a == null) {
1373:                    throw new InvalidIdException("No application with Id = "
1374:                            + id);
1375:                }
1376:                return a;
1377:            }
1378:
1379:            /** 
1380:             * Gets the participants for this process.
1381:             * @return a collection of {@link Participant
1382:             * <code>Participant</code>s} for this process.
1383:             */
1384:            public Collection participants() {
1385:                return participants.values();
1386:            }
1387:
1388:            /**
1389:             * Return the participant identified by the id.
1390:             * @param id identity of the participant in string 
1391:             * @return a Participant object
1392:             * @throws InvalidIdException if no participant with the given id exists.
1393:             */
1394:            public Participant participantById(String id)
1395:                    throws InvalidIdException {
1396:                Participant p = (Participant) participants.get(id);
1397:                if (p == null) {
1398:                    throw new InvalidIdException("No participant with Id = "
1399:                            + id);
1400:                }
1401:                return p;
1402:            }
1403:
1404:            /**
1405:             * This method checks if the closed process should be removed. Parse the 
1406:             * process definition and find out if the extendAttribute with the name of 
1407:             * RemoveClosedProcess has the value of MANUAL, then return false; if it 
1408:             * has the value of AUTOMATIC, then return true. Default is true.
1409:             * @return true if the closed process should be removed, otherwise false.
1410:             */
1411:            public boolean removeClosedProcess() {
1412:                return cleanupMode() == REMOVE_AUTOMATIC;
1413:            }
1414:
1415:            /**
1416:             * This method checks if a closed process should be removed. Parse the 
1417:             * process definition and find out if the extendAttribute with the name of 
1418:             * RemoveClosedProcess has the value of <code>MANUAL</code>, 
1419:             * <code>AUTOMATIC</code> or <code>COMPLETED</code> and return the 
1420:             * corresponding constant. Default is to remove automatically, i.e. 
1421:             * {@link #REMOVE_AUTOMATIC <code>REMOVE_AUTOMATIC</code>}.
1422:             * @return the cleanup mode.
1423:             */
1424:            public int cleanupMode() {
1425:                return cleanupMode == null ? REMOVE_AUTOMATIC : cleanupMode
1426:                        .intValue();
1427:            }
1428:
1429:            /**
1430:             * This method the audit event filter for instances of this
1431:             * process definition.
1432:             * @return the audit event filter in effect.
1433:             */
1434:            public int auditEventSelection() {
1435:                return (auditEventSelection == null) ? ProcessDefinition.AUDIT_SELECTION_ALL_EVENTS
1436:                        : auditEventSelection.intValue();
1437:            }
1438:
1439:            /**
1440:             * This method reports if audit events are written to the
1441:             * database.
1442:             * @return <code>true</code> if only state change events of the
1443:             * process instance are audited.
1444:             */
1445:            public boolean storeAuditEvents() {
1446:                return (storeAuditEvents == null)
1447:                        || storeAuditEvents.booleanValue();
1448:            }
1449:
1450:            //
1451:            // Additional methods provided by the domain class.
1452:            //
1453:
1454:            //
1455:            // Some private helpers.
1456:            //
1457:
1458:            /** 
1459:             * Retrieves the value for the attribute "Id" of this element.
1460:             * @return the value for the attribute or <code>null</code>, if 
1461:             * the attribute does not exist.
1462:             * @param el element
1463:             */
1464:            private String getAttributeValue(Element el, String at) {
1465:                return el != null ? el.getAttributeValue(at) : null;
1466:            }
1467:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.