Source Code Cross Referenced for TriggerEngine.java in  » Workflow-Engines » JFolder » org » jfolder » engines » 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 » JFolder » org.jfolder.engines 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
003:         *
004:         * Distributable under LGPL license.
005:         * See terms of license at gnu.org.
006:         */
007:
008:        package org.jfolder.engines;
009:
010:        //base classes
011:        import java.io.IOException;
012:        import java.math.BigDecimal;
013:        import javax.xml.parsers.ParserConfigurationException;
014:        import org.w3c.dom.Document;
015:        import org.xml.sax.SAXException;
016:
017:        //project specific classes
018:        import org.jfolder.common.UnexpectedSystemException;
019:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
020:        import org.jfolder.common.tagging.ConceptTagPreferences;
021:        import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
022:        import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
023:        import org.jfolder.common.tagging.RootConceptTagHolder;
024:        import org.jfolder.common.tagging.ValueAndClassForConceptTag;
025:        import org.jfolder.common.utils.misc.MiscHelper;
026:        import org.jfolder.common.utils.xml.XMLHelper;
027:        import org.jfolder.security.audit.SecurityAudit;
028:        import org.jfolder.services.workflow.WorkflowServiceCaller;
029:        import org.jfolder.workflow.model.attributes.AttributeSet;
030:        import org.jfolder.workflow.model.attributes.WaitHelper;
031:        import org.jfolder.workflow.model.history.HistoryAudit;
032:        import org.jfolder.workflow.model.history.TraceAudit;
033:        import org.jfolder.workflow.model.template.WorkflowTemplate;
034:        import org.jfolder.workflow.model.template.WorkflowTemplateStart;
035:        import org.jfolder.workflow.model.trigger.WorkflowTrigger;
036:
037:        //other classes
038:
039:        public class TriggerEngine {
040:
041:            public final static void triggerWorkflow(String inHandle,
042:                    WorkflowServiceCaller inWsc) {
043:
044:                throw UnexpectedSystemException.notImplemented();
045:                //TO DO: determine how to use local interfaces with JBoss
046:
047:                //MiscHelper.println("TriggerEngine inHandle = " + inHandle);
048:                //TriggerData td = inWl.retrieveTriggerData(inHandle);
049:                //MiscHelper.println("TriggerEngine content = " + td.getDataAsString());
050:                //MiscHelper.println("TriggerEngine status = " + td.getAuditStatus());
051:                //td.setAuditStatus(TriggerData.PROCESSED);
052:
053:                //if (true) {
054:                //    throw UnexpectedSystemException.notImplemented();
055:                //}
056:
057:                //inWl.updateTriggerDataStatus(inHandle, td);
058:
059:                //td = inWl.retrieveTriggerData(inHandle);
060:                //MiscHelper.println("TriggerEngine status2 = " + td.getAuditStatus());
061:
062:                /*
063:                try {
064:                    
065:                    //core variables
066:                    HistoryAudit history = null;
067:                    TriggerData trigger = inWl.retrieveTriggerData(inHandle);
068:                    WorkflowTemplate processMap = null;
069:                    RootConceptTagHolder rootTagHolder = null;
070:                    AttributeSet attributeSet = null;
071:                    WorkflowTemplateStart start = null;
072:                    //DetermineValueAndClassConceptTagContext rvacfctc = null;
073:                    String appName = null;
074:                    
075:                    //String triggerData = trigger.getDataAsString();
076:                    
077:                    //if (trigger.getWorkflowId() == null) {
078:                    //    trigger = TriggerDataFactory.newTrigger(triggerData, inTc);
079:                    //}
080:                    //else {
081:                    //    WorkflowInstance w =
082:                    //        inWl.retrieveWorkflowInstance(inTc.getWorkflowId());
083:                    //    if (!w.getStateCode().equals(inTc.getWorkflowStateCode())) {
084:                    //        throw new UnexpectedSystemException(
085:                    //            "Trigger for workflow '" + inTc.getWorkflowId()
086:                    //            + "' has already been resubmitted");
087:                    //    }
088:                    //    trigger = TriggerDataFactory.newTrigger(triggerData,
089:                    //        w.getTriggerData(), inTc);
090:                    //}
091:                    
092:                    if (trigger.getWorkflowId() != null) {
093:                        throw new UnexpectedSystemException(
094:                            "Trigger for workflow '" + trigger.getWorkflowId()
095:                                + "' has already been resubmitted");
096:                    }
097:                    
098:                    WorkflowInstancePrecursor wp = null;
099:                    
100:                    if (!trigger.isAuditExceptionPresent()) {
101:                        ProjectScript ws[] = inWl.getDeployedScripts();
102:                        
103:                        selectProcessMapAndStart: for (int i = 0; i < ws.length; i++) {
104:                            
105:                            ProjectScript nextScript = ws[i];
106:                            Document doc = XMLHelper.loadDocument(
107:                                nextScript.getContent());
108:                            
109:                            RootConceptTagHolder rth =
110:                                WorkflowTemplateTagHelper.getRootConceptTagHolder(
111:                                    doc, null, trigger, nextScript.getName());
112:                            ConceptTagPreferences localCtp =
113:                                rth.getConceptTagPreferences();
114:                            DetermineValueAndClassConceptTagContext rvacfctc =
115:                                localCtp.getDetermineValueAndClassConceptTagContext();
116:                            ConceptTagCharacteristic tc =
117:                                rth.getConceptTagCharacteristic();
118:                            Object ccto = tc.getValueAsCoreConceptTag();
119:                            WorkflowTemplateScriptTag pm =
120:                                (WorkflowTemplateScriptTag)ccto;
121:                            //StartsTag starts = (StartsTag)pm.getStarts();
122:                            
123:                            for (int j = 0; j < pm.getStartCount(); j++) {
124:                                StartScriptTag currentStart = pm.getStart(j);
125:                                //TO DO: trigger, attribute set part of rvacc
126:                                //rvacc =
127:                                //ScriptTagHelper.createdetermineValueAndClassContext(
128:                                //        null, trigger, nextScript.getName());
129:                                boolean result =
130:                                    isStartActive(currentStart, rvacfctc, trigger);
131:                                if (trigger.isAuditExceptionPresent()) {
132:                                    break selectProcessMapAndStart;
133:                                }
134:                                else if (result) {
135:                                    processMap = pm;
136:                                    rootTagHolder = rth;
137:                                    start = currentStart;
138:                                    //set application name
139:                                    appName = nextScript.getName();
140:                                    break selectProcessMapAndStart;
141:                                }
142:                            }
143:                        }
144:                        if (trigger.isAuditExceptionPresent() || processMap == null
145:                            || start == null) {
146:                            trigger.setAuditException(
147:                                new UnexpectedSystemException(
148:                                    "Unable to find active 'start'"));
149:                        }
150:                        
151:                        ConceptTagPreferences localCtp =
152:                            rootTagHolder.getConceptTagPreferences();
153:                        DetermineValueAndClassConceptTagContext rvacfctc =
154:                            localCtp.getDetermineValueAndClassConceptTagContext();
155:                        
156:                        attributeSet = AttributeSetFactory.newAttributeSet();
157:                        initializeAttributes(
158:                            processMap, attributeSet, rvacfctc, trigger);
159:                    }
160:                    
161:                    if (!trigger.isAuditExceptionPresent()) {
162:                        
163:                        ConceptTagPreferences localCtp =
164:                            rootTagHolder.getConceptTagPreferences();
165:                        DetermineValueAndClassConceptTagContext rvacfctc =
166:                            localCtp.getDetermineValueAndClassConceptTagContext();
167:                        
168:                        SecurityAudit wa = SecurityAuditFactory.newSecurityAudit(
169:                            trigger.getAuditUser(), SecurityAudit.INITIAL_ID,
170:                            "Trigger Engine Initialized", TraceAudit.STATUS_ACTIVE,
171:                            MiscHelper.currentGMT());
172:                        //initialize history
173:                        history = HistoryAuditFactory.createHistoryAudit(start,
174:                            rvacfctc, wa);
175:                
176:                        //set workflow precursor attributes here
177:                
178:                        //TO DO: try to use below function instead at some point
179:                        //VersionHelper.initializeSystemAttributes(wp);
180:                        
181:                        //initialize all system parameters, except ID
182:                        
183:                        TraceAudit currentTrace =
184:                            history.getOneTraceByStatus(TraceAudit.STATUS_ACTIVE);
185:                        //MiscHelper.println("currentTrace = " + currentTrace);
186:                        //MiscHelper.println("currentTrace,id = "
187:                        //    + currentTrace.getId());
188:                    
189:                        attributeSet.addPublicSysAttr(AttributeSet.STATUS,
190:                            ValueAndClassForConceptTag.newInstance(
191:                                TraceAudit.STATUS_ACTIVE, String.class));
192:                        attributeSet.addPublicSysAttr(AttributeSet.APP,
193:                            ValueAndClassForConceptTag.newInstance(
194:                                appName, String.class));
195:                        //as.addPublicSysAttr(AttributeSet.APP_VERSION,
196:                        //  ValueAndClassFactory.newValueAndClass("",String.class));
197:                        attributeSet.addPublicSysAttr(AttributeSet.WAIT,
198:                            ValueAndClassForConceptTag.newInstance(
199:                                WaitHelper.NO_WAIT, String.class));
200:                        attributeSet.addPublicSysAttr(AttributeSet.CURRENT_TRACE,
201:                            ValueAndClassForConceptTag.newInstance(
202:                                new BigDecimal(currentTrace.getId()),
203:                                    BigDecimal.class));
204:                        attributeSet.addPublicSysAttr(AttributeSet.STEP_COUNT,
205:                            ValueAndClassForConceptTag.newInstance(
206:                                new BigDecimal(history.getTotalRecordCount()),
207:                                    BigDecimal.class));
208:                        
209:                        wp = WorkflowInstancePrecursorFactory.newWorkflowPrecursor(
210:                            trigger, attributeSet, rootTagHolder, history);
211:                    }
212:                    else {
213:                        throw UnexpectedSystemException.notImplemented();
214:                        //wp = WorkflowInstancePrecursorFactory.newWorkflowPrecursor(
215:                        //    inTc, trigger);
216:                    }
217:                    
218:                    
219:                    inWl.startWorkflowInstance(wp);
220:                    trigger.setAuditStatus(TriggerData.PROCESSED);
221:                    inWl.updateTriggerDataStatus(inHandle, trigger);
222:                }
223:                catch (ParserConfigurationException pce) {
224:                    throw new UnexpectedSystemException(pce);
225:                }
226:                catch (SAXException saxe) {
227:                    throw new UnexpectedSystemException(saxe);
228:                }
229:                catch (IOException ioe) {
230:                    throw new UnexpectedSystemException(ioe);
231:                }
232:                 */
233:            }
234:
235:            //private final static boolean isStartActive(StartScriptTag inSt,
236:            //    DetermineValueAndClassConceptTagContext inRvacfctc,
237:            //    TriggerData inTrigger) {
238:            //        
239:            //    boolean outValue = false;
240:            //
241:            //    try {
242:            //        outValue = inSt.isTriggerConditionActive(inRvacfctc);
243:            //    }
244:            //    catch (DetermineValueAndClassConceptTagException rste) {
245:            //        outValue = false;
246:            //        inTrigger.setAuditException(rste);
247:            //    }
248:            //    
249:            //    return outValue;
250:            //}
251:
252:            //private final static void initializeAttributes(
253:            //    WorkflowTemplateScriptTag inPmt, AttributeSet inAs,
254:            //    DetermineValueAndClassConceptTagContext inRvacfctc,
255:            //    TriggerData inTrigger) {
256:            //    
257:            //    try {
258:            //        inPmt.initializeApplicationAttributeSet(inAs, inRvacfctc);
259:            //    }
260:            //    catch (DetermineValueAndClassConceptTagException rste) {
261:            //        inTrigger.setAuditException(rste);
262:            //    }
263:            //}
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.