Source Code Cross Referenced for WFPersistence.java in  » Workflow-Engines » bonita-v3.1 » hero » client » grapheditor » 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 » bonita v3.1 » hero.client.grapheditor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package hero.client.grapheditor;
002:
003:        /*
004:         *
005:         * WFPersistence.java - 
006:         * Copyright (C) 2003 Ecoo Team
007:         * valdes@loria.fr
008:         * 
009:         *
010:         * This program is free software; you can redistribute it and/or
011:         * modify it under the terms of the GNU Lesser General Public License
012:         * as published by the Free Software Foundation; either version 2
013:         * of the License, or (at your option) any later version.
014:         *
015:         * This program is distributed in the hope that it will be useful,
016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
018:         * GNU Lesser General Public License for more details.
019:         *
020:         * You should have received a copy of the GNU Lesser General Public License
021:         * along with this program; if not, write to the Free Software
022:         * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
023:         */
024:
025:        import hero.interfaces.Constants;
026:
027:        import java.util.Iterator;
028:        import java.util.Collection;
029:        import java.util.Date;
030:
031:        import javax.swing.JOptionPane;
032:        import hero.util.BonitaClient;
033:        import hero.util.ProjectNodes;
034:        import hero.net.ProjectSession.StrutsNodeValue;
035:        import javax.swing.ImageIcon;
036:        import java.text.SimpleDateFormat;
037:
038:        public class WFPersistence {
039:
040:            //	private String userAcces = "all";
041:            private String projectName;
042:            public boolean permission = false;
043:            private String endpoint = null;
044:            private String url = null;
045:            private String userPassword = null;
046:            public BonitaClient soapclient;
047:            private ProjectNodes pn = new ProjectNodes();
048:            public final static String imageBase = "images/";
049:            public final static ImageIcon icon = new ImageIcon(Thread
050:                    .currentThread().getContextClassLoader().getResource(
051:                            imageBase + "icon.png"));
052:
053:            public WFPersistence(String managerProject, BonitaClient soapclient)
054:                    throws Exception {
055:                this .soapclient = soapclient;
056:                soapclient.openProject(managerProject);
057:                projectName = managerProject;
058:                permission = isInRole(this .getUser(), Constants.ADMIN);
059:            }
060:
061:            public boolean openProject(String projectName) throws Exception {
062:                soapclient.openProject(projectName);
063:                this .projectName = projectName;
064:                this .setProjectNodes();
065:                return true;
066:            }
067:
068:            public boolean createProject(String projectName) throws Exception {
069:
070:                if (exists(projectName)) {
071:                    return false;
072:                }
073:
074:                soapclient.createProject(projectName);
075:                //		userAcces = "All";
076:                this .projectName = projectName;
077:                return true;
078:
079:            }
080:
081:            public boolean createModel(String modelName) throws Exception {
082:
083:                if (exists(modelName)) {
084:                    return false;
085:                }
086:
087:                soapclient.createModel(modelName);
088:                //		userAcces = "All";
089:                this .projectName = modelName;
090:                return true;
091:
092:            }
093:
094:            public boolean cloneProject(String projectSrc, String projectDest)
095:                    throws Exception {
096:                if (exists(projectDest)) {
097:                    return false;
098:                }
099:                soapclient.cloneProject(projectSrc, projectDest);
100:                //		userAcces = "All";
101:                this .projectName = projectDest;
102:                return true;
103:            }
104:
105:            public boolean cloneSubProject(String projectSrc, String projectDest)
106:                    throws Exception {
107:                soapclient.cloneProject(projectSrc, projectDest);
108:                return true;
109:            }
110:
111:            public String getUser() throws Exception {
112:                return (soapclient.getUser());
113:            }
114:
115:            public boolean hasPermission() {
116:                return permission;
117:            }
118:
119:            private boolean exists(String name) throws Exception {
120:                String prj;
121:                Collection projects = soapclient.getProjects();
122:                Iterator i = projects.iterator();
123:                while (i.hasNext()) {
124:                    prj = (String) i.next();
125:                    if (prj.equalsIgnoreCase(name)) {
126:                        return true;
127:                    }
128:                }
129:                return false;
130:            }
131:
132:            public Object[] getProjects() throws Exception {
133:                Collection projects = soapclient.getProjects();
134:                return (projects.toArray());
135:            }
136:
137:            public boolean containsNode(String value) throws Exception {
138:                Collection nodes = soapclient.getNodes();
139:                Iterator i = nodes.iterator();
140:                while (i.hasNext()) {
141:                    String nodeName = (String) i.next();
142:                    if (value.equalsIgnoreCase(nodeName)) {
143:                        return true;
144:                    }
145:                }
146:                return false;
147:            }
148:
149:            public boolean containsProject(String value) throws Exception {
150:                Collection projects = soapclient.getProjects();
151:                Iterator i = projects.iterator();
152:                while (i.hasNext()) {
153:                    String projectName = (String) i.next();
154:                    if (value.equalsIgnoreCase(projectName)) {
155:                        return true;
156:                    }
157:                }
158:                return false;
159:            }
160:
161:            public Object[] getNodes() throws Exception {
162:                Collection nodes = soapclient.getNodes();
163:                return (nodes.toArray());
164:            }
165:
166:            public Object[] getEdges() throws Exception {
167:                Collection nodes = soapclient.getEdges();
168:                return (nodes.toArray());
169:            }
170:
171:            public void addNode(String name, String type) throws Exception {
172:                soapclient.addNode(name, type);
173:            }
174:
175:            public void addNodeSubProcess(String name, String projectName)
176:                    throws Exception {
177:                soapclient.addNodeSubProcess(name, projectName);
178:            }
179:
180:            public boolean deleteNode(String node) throws Exception {
181:                soapclient.deleteNode(node);
182:                return true;
183:            }
184:
185:            public boolean deleteProject(String project) throws Exception {
186:                soapclient.deleteProject(project);
187:                return true;
188:            }
189:
190:            public void deleteEdges(Object[] edges) throws Exception {
191:                soapclient.deleteEdges(edges);
192:            }
193:
194:            public String addEdge(String src, String dest) throws Exception {
195:                return soapclient.addEdge(src, dest);
196:            }
197:
198:            public String setEdgeCondition(String edgeName, String condition)
199:                    throws Exception {
200:                soapclient.setEdgeCondition(edgeName, condition);
201:                return edgeName;
202:            }
203:
204:            public String getEdgeCondition(String edgeName) throws Exception {
205:                return (soapclient.getEdgeCondition(edgeName));
206:            }
207:
208:            public String getState(String name) throws Exception {
209:                int state = soapclient.getNodeState(name);
210:                switch (state) {
211:                case Constants.Nd.INITIAL:
212:                    return ("Initial");
213:                case Constants.Nd.READY:
214:                    return ("READY");
215:                case Constants.Nd.ANTICIPABLE:
216:                    return ("Anticipable");
217:                case Constants.Nd.ANTICIPATING:
218:                    return ("Anticipating");
219:                case Constants.Nd.EXECUTING:
220:                    return ("Executing");
221:                case Constants.Nd.EXECUTED:
222:                    return ("Executed");
223:                case Constants.Nd.TERMINATED:
224:                    return ("Terminated");
225:                case Constants.Nd.ANT_SUSPENDED:
226:                    return ("Ant_suspended");
227:                case Constants.Nd.EXEC_SUSPENDED:
228:                    return ("Exec_suspended");
229:                }
230:                return ("");
231:            }
232:
233:            public int getNodeState(String name) throws Exception {
234:                /*	Object[] nodes = this.pn.getNodes();
235:                	for (int i=0;i<nodes.length;i++)
236:                	{		
237:                	    StrutsNodeValue node = (StrutsNodeValue) nodes[i];
238:                		if ((node.getName()).equals(name))
239:                			return(new Integer(node.getState()).intValue());
240:                	}			
241:                return(0);*/
242:                return (soapclient.getNodeState(name));
243:            }
244:
245:            public int getNodeType(String name) throws Exception {
246:                /*Object[] nodes = this.pn.getNodes();
247:                for (int i=0;i<nodes.length;i++)
248:                {		
249:                	StrutsNodeValue node = (StrutsNodeValue) nodes[i];
250:                	if ((node.getName()).equals(name))
251:                		return(new Integer(node.getType()).intValue());
252:                }			
253:                return(0);*/
254:                return (soapclient.getNodeType(name));
255:            }
256:
257:            public String getEdgeInNode(String name) throws Exception {
258:                return (soapclient.getEdgeInNode(name));
259:            }
260:
261:            public String getEdgeOutNode(String name) throws Exception {
262:                return (soapclient.getEdgeOutNode(name));
263:            }
264:
265:            public boolean isActive(String name) throws Exception { //Only used by WFmanager.updateStatus
266:                int state = soapclient.getNodeState(name);
267:                switch (state) {
268:                case Constants.Nd.INITIAL:
269:                    return false;
270:                case Constants.Nd.READY:
271:                    return false;
272:                case Constants.Nd.ANTICIPABLE:
273:                    return false;
274:                case Constants.Nd.ANTICIPATING:
275:                    return true;
276:                case Constants.Nd.EXECUTING:
277:                    return true;
278:                case Constants.Nd.EXECUTED:
279:                    return false;
280:                case Constants.Nd.TERMINATED:
281:                    return true;
282:                case Constants.Nd.ANT_SUSPENDED:
283:                    return false;
284:                case Constants.Nd.EXEC_SUSPENDED:
285:                    return false;
286:                }
287:                return false;
288:            }
289:
290:            public String getType(String name) throws Exception {
291:                return (soapclient.getType(name));
292:            }
293:
294:            public String getRole(String name) throws Exception {
295:                return (soapclient.getRole(name));
296:            }
297:
298:            public void setNodeRole(String node, String newRole)
299:                    throws Exception {
300:                soapclient.setNodeRole(node, newRole);
301:                this .setProjectNodeRole(node, newRole);
302:            }
303:
304:            public String getDeadline(String name) throws Exception {
305:                this .setProjectNodes();
306:                return (soapclient.getDeadline(name));
307:            }
308:
309:            public void setDeadline(String name, long dl) throws Exception {
310:                soapclient.setDeadline(name, dl);
311:            }
312:
313:            public String getNodeInterHookValue(String nodeName, String hookName)
314:                    throws Exception {
315:                return (soapclient.getNodeInterHookValue(nodeName, hookName));
316:            }
317:
318:            public String getProjectInterHookValue(String hookName)
319:                    throws Exception {
320:                return (soapclient.getProjectInterHookValue(hookName));
321:            }
322:
323:            public String getNodeDescription(String nodeName) throws Exception {
324:                return (soapclient.getNodeDescription(nodeName));
325:            }
326:
327:            public void setNodeDescription(String nodeName, String description)
328:                    throws Exception {
329:                soapclient.setNodeDescription(nodeName, description);
330:                this .setProjectNodeDescription(nodeName, description);
331:            }
332:
333:            public void setNodeTraditional(String nodeName) throws Exception {
334:                soapclient.setNodeTraditional(nodeName);
335:            }
336:
337:            public void setNodeAnticipable(String nodeName) throws Exception {
338:                soapclient.setNodeAnticipable(nodeName);
339:            }
340:
341:            public boolean getNodeAnticipable(String nodeName) throws Exception {
342:                return (soapclient.getNodeAnticipable(nodeName));
343:            }
344:
345:            public void setNodeInterHookValue(String nodeName, String hookName,
346:                    String value) throws Exception {
347:                soapclient.setNodeInterHookValue(nodeName, hookName, value);
348:            }
349:
350:            public void setProjectInterHookValue(String hookName, String value)
351:                    throws Exception {
352:                soapclient.setProjectInterHookValue(hookName, value);
353:            }
354:
355:            public Object[] getRoles() throws Exception {
356:                Collection roles = soapclient.getRoles();
357:                return (roles.toArray());
358:            }
359:
360:            public Object[] getUsersInProject() throws Exception {
361:                Collection users = soapclient.getUsersInProject();
362:                return (users.toArray());
363:            }
364:
365:            public Object[] getAllUsers() throws Exception {
366:                Collection users = soapclient.getAllUsers();
367:                return (users.toArray());
368:            }
369:
370:            public void addUser(String name) throws Exception {
371:                soapclient.addUser(name);
372:            }
373:
374:            public void addRole(String name, String desc) throws Exception {
375:                soapclient.addRole(name, desc);
376:            }
377:
378:            public void addNodeProperty(String nodeName, String key,
379:                    String value, boolean propagate) throws Exception {
380:                soapclient.addNodeProperty(nodeName, key, value, propagate);
381:            }
382:
383:            public void addProjectProperty(String key, String value)
384:                    throws Exception {
385:                soapclient.addProjectProperty(key, value);
386:            }
387:
388:            public void setUserRole(String name, String role) throws Exception {
389:                soapclient.setUserRole(name, role);
390:            }
391:
392:            public void addRoleMapper(String role, String mapper, String type)
393:                    throws Exception {
394:                soapclient.addRoleMapper(role, mapper, type);
395:            }
396:
397:            public void addPerformerAssigment(String node,
398:                    String performerName, String type, String property)
399:                    throws Exception {
400:                soapclient.addNodePerformerAssigment(node, performerName, type,
401:                        property);
402:            }
403:
404:            public void setEditNode(String node, String role,
405:                    String description, Date deadline) throws Exception {
406:                soapclient.setEditNode(node, role, description, deadline
407:                        .getTime());
408:                this .setProjectNodeRole(node, role);
409:                this .setProjectNodeDescription(node, description);
410:                this .setProjectNodeDeadline(node, deadline.getTime());
411:            }
412:
413:            public void addNodeInterHook(String nodeName, String hookName,
414:                    String event, String value) throws Exception {
415:                soapclient.addNodeInterHook(nodeName, hookName, event, value);
416:            }
417:
418:            public void addProjectInterHook(String hookName, String event,
419:                    String value) throws Exception {
420:                soapclient.addProjectInterHook(hookName, event, value);
421:            }
422:
423:            public void addIteration(String from, String to, String condition)
424:                    throws Exception {
425:                soapclient.addIteration(from, to, condition);
426:            }
427:
428:            public Collection getIterations() throws Exception {
429:                return (soapclient.getIterations());
430:            }
431:
432:            public boolean isInRole(String name, String role) throws Exception {
433:                return (soapclient.isInRole(name, role));
434:            }
435:
436:            public String getProjectName() {
437:                return this .projectName;
438:            }
439:
440:            public String getStateString(int state) throws Exception {
441:                switch (state) {
442:                case Constants.Nd.INITIAL:
443:                    return ("INITIAL");
444:                case Constants.Nd.READY:
445:                    return ("READY");
446:                case Constants.Nd.ANTICIPABLE:
447:                    return ("ANTICIPABLE");
448:                case Constants.Nd.ANTICIPATING:
449:                    return ("ANTICIPATING");
450:                case Constants.Nd.EXECUTING:
451:                    return ("EXECUTING");
452:                case Constants.Nd.EXECUTED:
453:                    return ("EXECUTED");
454:                case Constants.Nd.TERMINATED:
455:                    return ("TERMINATED");
456:                case Constants.Nd.ANT_SUSPENDED:
457:                    return ("ANT_SUSPENDED");
458:                case Constants.Nd.EXEC_SUSPENDED:
459:                    return ("EXEC_SUSPENDED");
460:                }
461:                return ("");
462:            }
463:
464:            public int getStateInt(String state) throws Exception {
465:                if (state.equals("INITIAL"))
466:                    return Constants.Nd.INITIAL;
467:                if (state.equals("READY"))
468:                    return Constants.Nd.READY;
469:                if (state.equals("ANTICIPABLE"))
470:                    return Constants.Nd.ANTICIPABLE;
471:                if (state.equals("ANTICIPATING"))
472:                    return Constants.Nd.ANTICIPATING;
473:                if (state.equals("EXECUTING"))
474:                    return Constants.Nd.EXECUTING;
475:                if (state.equals("TERMINATED"))
476:                    return Constants.Nd.TERMINATED;
477:                return (-1);
478:            }
479:
480:            public String getTypeString(int type) throws Exception {
481:                switch (type) {
482:                case Constants.Nd.AND_JOIN_NODE:
483:                    return ("And Join");
484:                case Constants.Nd.OR_JOIN_NODE:
485:                    return ("Or Join");
486:                case Constants.Nd.AND_JOIN_AUTOMATIC_NODE:
487:                    return ("And Join Automatic");
488:                case Constants.Nd.OR_JOIN_AUTOMATIC_NODE:
489:                    return ("Or Join Automatic");
490:                }
491:                return ("");
492:            }
493:
494:            public void setProjectNodes() throws Exception {
495:                this .pn.setNodes(soapclient.getProjectNodes());
496:            }
497:
498:            public Object[] getProjectNodes() throws Exception {
499:                return (soapclient.getProjectNodes());
500:            }
501:
502:            public Object[] getProjectNodesArray() throws Exception {
503:                return (this .pn.getNodes());
504:            }
505:
506:            public Collection getProperties() throws Exception {
507:                return (soapclient.getProperties());
508:            }
509:
510:            public void windowMessage(String msg) {
511:                JOptionPane.showMessageDialog(null, msg);
512:            }
513:
514:            // Local Model operations
515:
516:            public StrutsNodeValue getProjectNode(String nodeName)
517:                    throws Exception {
518:                /*Collection nodes = this.pn.getNodes();		
519:                Iterator i = nodes.iterator();
520:                while (i.hasNext()) {*/
521:                Object[] nodes = this .pn.getNodes();
522:                for (int i = 0; i < nodes.length; i++) {
523:                    StrutsNodeValue node = (StrutsNodeValue) nodes[i];
524:                    if ((node.getName()).equals(nodeName))
525:                        return node;
526:                }
527:                return null;
528:                //return(soapclient.getStrutsNode(nodeName));	
529:            }
530:
531:            public void setProjectNodeState(String nodeName, int state)
532:                    throws Exception {
533:                Object[] nodes = this .pn.getNodes();
534:                for (int i = 0; i < nodes.length; i++) {
535:                    StrutsNodeValue node = (StrutsNodeValue) nodes[i];
536:                    if ((node.getName()).equals(nodeName))
537:                        node.setState(this .getStateString(state));
538:                }
539:            }
540:
541:            public void setProjectNodeRole(String nodeName, String role)
542:                    throws Exception {
543:                Object[] nodes = this .pn.getNodes();
544:                for (int i = 0; i < nodes.length; i++) {
545:                    StrutsNodeValue node = (StrutsNodeValue) nodes[i];
546:                    if ((node.getName()).equals(nodeName))
547:                        node.setRole(role);
548:                }
549:            }
550:
551:            public void setProjectNodeDescription(String nodeName,
552:                    String description) throws Exception {
553:                Object[] nodes = this .pn.getNodes();
554:                for (int i = 0; i < nodes.length; i++) {
555:                    StrutsNodeValue node = (StrutsNodeValue) nodes[i];
556:                    if ((node.getName()).equals(nodeName))
557:                        node.setDescription(description);
558:                }
559:            }
560:
561:            public void setProjectNodeDeadline(String nodeName, long deadline)
562:                    throws Exception {
563:                Object[] nodes = this .pn.getNodes();
564:                for (int i = 0; i < nodes.length; i++) {
565:                    StrutsNodeValue node = (StrutsNodeValue) nodes[i];
566:                    if ((node.getName()).equals(nodeName)) {
567:                        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
568:                        node.setDeadline(df.format(df.parse(new java.sql.Date(
569:                                deadline).toString())));
570:                    }
571:                }
572:            }
573:
574:        } // WFPersistence
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.