Source Code Cross Referenced for ModelModifier.java in  » Workflow-Engines » osbl-1_0 » model » 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 » osbl 1_0 » model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package model;
004:
005:        import java.util.Iterator;
006:        import java.util.List;
007:        import java.util.Map;
008:
009:        import newprocess.Element;
010:        import newprocess.EnvEntry;
011:
012:        import org.eclipse.emf.common.util.BasicEList;
013:        import org.eclipse.emf.common.util.EList;
014:        import org.openarchitectureware.workflow.WorkflowContext;
015:
016:        /**
017:         * @author sh
018:         *
019:         */
020:        public class ModelModifier {
021:
022:            /**
023:             * Does the model Element name and implementation modification.
024:             * 
025:             * @param oldImplementation the implementation property to change
026:             * @param newImplementation the new implementation property string to set
027:             * @param newName the new Name to set
028:             * @param new
029:             */
030:            public void doNameModification(String oldImplementation,
031:                    String newImplementation, String newName) {
032:                // load the Object Trees of the Process Model Files
033:                List<Map<WorkflowContext, String>> model = ModelEditor.INSTANCE
034:                        .loadModels();
035:
036:                // iterate over all models and start the refactoring
037:                for (Iterator<Map<WorkflowContext, String>> iterator = model
038:                        .iterator(); iterator.hasNext();) {
039:                    Map<WorkflowContext, String> binding = iterator.next();
040:
041:                    for (Iterator<WorkflowContext> contextIter = binding
042:                            .keySet().iterator(); contextIter.hasNext();) {
043:                        WorkflowContext ctx = (WorkflowContext) contextIter
044:                                .next();
045:                        newprocess.Process processModel = (newprocess.Process) ctx
046:                                .get("default");
047:
048:                        // fetch all model Elements
049:                        EList<Element> elements = new BasicEList<Element>();
050:                        elements.addAll(processModel.getHasActors());
051:                        elements.addAll(processModel.getHasSyncActivities());
052:                        elements.addAll(processModel.getHasAsyncActivities());
053:                        elements.addAll(processModel.getHasListeners());
054:                        elements.addAll(processModel.getHasEvents());
055:                        elements.addAll(processModel.getHasGlobals()
056:                                .getHasCondition());
057:                        elements.add(processModel.getHasGlobals()
058:                                .getHasLoader());
059:                        elements.add(processModel);
060:
061:                        // do the update
062:                        for (Iterator<Element> elementObj = elements.iterator(); elementObj
063:                                .hasNext();) {
064:                            Element obj = (Element) elementObj.next();
065:                            if (obj.getImplementation() == null)
066:                                continue;
067:                            if (obj.getImplementation().equals(
068:                                    oldImplementation)) {
069:                                obj.setName(newName);
070:                                obj.setImplementation(newImplementation);
071:                            }
072:                        }
073:                    }
074:                }
075:
076:                // write the changes to the model
077:                ModelEditor.INSTANCE.writeModel(model);
078:            }
079:
080:            /**
081:             * Does the model Element implementation modification.
082:             * 
083:             * @param oldImplementationName the old implementation property name
084:             * @param newImplementationName the new implementation property name
085:             */
086:            public void doImplementationModification(
087:                    String oldImplementationName, String newImplementationName) {
088:                // load the Object Trees of the Process Model Files
089:                List<Map<WorkflowContext, String>> model = ModelEditor.INSTANCE
090:                        .loadModels();
091:
092:                // iterate over all models and start the refactoring
093:                for (Iterator<Map<WorkflowContext, String>> iterator = model
094:                        .iterator(); iterator.hasNext();) {
095:                    Map<WorkflowContext, String> binding = iterator.next();
096:
097:                    for (Iterator<WorkflowContext> contextIter = binding
098:                            .keySet().iterator(); contextIter.hasNext();) {
099:                        WorkflowContext ctx = (WorkflowContext) contextIter
100:                                .next();
101:                        newprocess.Process processModel = (newprocess.Process) ctx
102:                                .get("default");
103:
104:                        // fetch all model Elements
105:                        EList<Element> elements = new BasicEList<Element>();
106:                        elements.addAll(processModel.getHasActors());
107:                        elements.addAll(processModel.getHasSyncActivities());
108:                        elements.addAll(processModel.getHasAsyncActivities());
109:                        elements.addAll(processModel.getHasListeners());
110:                        elements.addAll(processModel.getHasEvents());
111:                        elements.addAll(processModel.getHasGlobals()
112:                                .getHasCondition());
113:                        elements.add(processModel.getHasGlobals()
114:                                .getHasLoader());
115:                        elements.add(processModel);
116:
117:                        // do the update
118:                        for (Iterator<Element> elementObj = elements.iterator(); elementObj
119:                                .hasNext();) {
120:                            Element obj = (Element) elementObj.next();
121:                            if (obj.getImplementation() == null)
122:                                continue;
123:                            /*
124:                            if(obj.getImplementation().equals(oldImplementationName + "." + obj.getName()))
125:                               obj.setImplementation(newImplementationName + "." + obj.getName());
126:                             */
127:                            if (obj.getImplementation().equals(
128:                                    oldImplementationName))
129:                                obj.setImplementation(newImplementationName);
130:                        }
131:                    }
132:                }
133:
134:                // write the changes to the model
135:                ModelEditor.INSTANCE.writeModel(model);
136:            }
137:
138:            /**
139:             * Does the model Element package modification.
140:             * 
141:             * @param oldPackageName the old package value of the implementation property
142:             * @param newPackageName the new package value of the implementation property
143:             */
144:            public void doPackageModification(String oldImplementationName,
145:                    String newImplementationName) {
146:                // load the Object Trees of the Process Model Files
147:                List<Map<WorkflowContext, String>> model = ModelEditor.INSTANCE
148:                        .loadModels();
149:
150:                // iterate over all models and start the refactoring
151:                for (Iterator<Map<WorkflowContext, String>> iterator = model
152:                        .iterator(); iterator.hasNext();) {
153:                    Map<WorkflowContext, String> binding = iterator.next();
154:
155:                    for (Iterator<WorkflowContext> contextIter = binding
156:                            .keySet().iterator(); contextIter.hasNext();) {
157:                        WorkflowContext ctx = (WorkflowContext) contextIter
158:                                .next();
159:                        newprocess.Process processModel = (newprocess.Process) ctx
160:                                .get("default");
161:
162:                        // fetch all model Elements
163:                        EList<Element> elements = new BasicEList<Element>();
164:                        elements.addAll(processModel.getHasActors());
165:                        elements.addAll(processModel.getHasSyncActivities());
166:                        elements.addAll(processModel.getHasAsyncActivities());
167:                        elements.addAll(processModel.getHasListeners());
168:                        elements.addAll(processModel.getHasEvents());
169:                        elements.addAll(processModel.getHasGlobals()
170:                                .getHasCondition());
171:                        elements.add(processModel.getHasGlobals()
172:                                .getHasLoader());
173:                        elements.add(processModel);
174:
175:                        // do the update
176:                        for (Iterator<Element> elementObj = elements.iterator(); elementObj
177:                                .hasNext();) {
178:                            Element obj = (Element) elementObj.next();
179:                            if (obj.getImplementation() == null)
180:                                continue;
181:                            if (obj.getImplementation().contains(
182:                                    oldImplementationName)) {
183:                                String impl = obj.getImplementation().replace(
184:                                        oldImplementationName,
185:                                        newImplementationName);
186:                                obj.setImplementation(impl);
187:                            }
188:                        }
189:                    }
190:                }
191:
192:                // write the changes to the model
193:                ModelEditor.INSTANCE.writeModel(model);
194:            }
195:
196:            /**
197:             * Does the model environment entry name modification.
198:             * 
199:             * @param oldEntryName the old environment entry name
200:             * @param newEntryName the new environment entry name
201:             */
202:            public void doEnvEntryNameModification(String implementation,
203:                    String oldEntryName, String newEntryName) {
204:
205:                // load the Object Trees of the Process Model Files
206:                List<Map<WorkflowContext, String>> model = ModelEditor.INSTANCE
207:                        .loadModels();
208:
209:                // iterate over all models and start the refactoring
210:                for (Iterator<Map<WorkflowContext, String>> iterator = model
211:                        .iterator(); iterator.hasNext();) {
212:                    Map<WorkflowContext, String> binding = iterator.next();
213:
214:                    for (Iterator<WorkflowContext> contextIter = binding
215:                            .keySet().iterator(); contextIter.hasNext();) {
216:                        WorkflowContext ctx = (WorkflowContext) contextIter
217:                                .next();
218:                        newprocess.Process processModel = (newprocess.Process) ctx
219:                                .get("default");
220:
221:                        // fetch all model Elements
222:                        EList<Element> elements = new BasicEList<Element>();
223:                        elements.addAll(processModel.getHasActors());
224:                        elements.addAll(processModel.getHasSyncActivities());
225:                        elements.addAll(processModel.getHasAsyncActivities());
226:                        elements.addAll(processModel.getHasListeners());
227:                        elements.addAll(processModel.getHasEvents());
228:                        elements.addAll(processModel.getHasGlobals()
229:                                .getHasCondition());
230:                        elements.add(processModel.getHasGlobals()
231:                                .getHasLoader());
232:                        elements.add(processModel);
233:
234:                        // do the update
235:                        for (Iterator<Element> elementObj = elements.iterator(); elementObj
236:                                .hasNext();) {
237:                            Element obj = (Element) elementObj.next();
238:                            if (obj.getImplementation() == null)
239:                                continue;
240:                            if (obj.getImplementation().equals(implementation)) {
241:                                EList<EnvEntry> entries = obj
242:                                        .getHasEnvEntries();
243:                                if (entries == null || entries.isEmpty())
244:                                    continue;
245:                                for (Iterator<EnvEntry> iterator2 = entries
246:                                        .iterator(); iterator2.hasNext();) {
247:                                    EnvEntry entry = (EnvEntry) iterator2
248:                                            .next();
249:                                    if (entry.getName().equals(oldEntryName)) {
250:                                        entry.setName(newEntryName);
251:                                    }
252:                                }
253:                            }
254:                        }
255:                    }
256:                }
257:
258:                // write the changes to the model
259:                ModelEditor.INSTANCE.writeModel(model);
260:            }
261:
262:            /**
263:             * Does the environment entry type modification.
264:             * 
265:             * @param implementation the implementation of the element, containing
266:             * 				the environment entry
267:             * @param oldTypeName the old environment entry type to change
268:             * @param newTypeName the new environment entry type to set
269:             * @param entryName the entry name which type should be changed
270:             */
271:            public void doEnvEntryTypeModification(String implementation,
272:                    String oldTypeName, String newTypeName, String entryName) {
273:
274:                // load the Object Trees of the Process Model Files
275:                List<Map<WorkflowContext, String>> model = ModelEditor.INSTANCE
276:                        .loadModels();
277:
278:                // iterate over all models and start the refactoring
279:                for (Iterator<Map<WorkflowContext, String>> iterator = model
280:                        .iterator(); iterator.hasNext();) {
281:                    Map<WorkflowContext, String> binding = iterator.next();
282:
283:                    for (Iterator<WorkflowContext> contextIter = binding
284:                            .keySet().iterator(); contextIter.hasNext();) {
285:                        WorkflowContext ctx = (WorkflowContext) contextIter
286:                                .next();
287:                        newprocess.Process processModel = (newprocess.Process) ctx
288:                                .get("default");
289:
290:                        // fetch all model Elements
291:                        EList<Element> elements = new BasicEList<Element>();
292:                        elements.addAll(processModel.getHasActors());
293:                        elements.addAll(processModel.getHasSyncActivities());
294:                        elements.addAll(processModel.getHasAsyncActivities());
295:                        elements.addAll(processModel.getHasListeners());
296:                        elements.addAll(processModel.getHasEvents());
297:                        elements.addAll(processModel.getHasGlobals()
298:                                .getHasCondition());
299:                        elements.add(processModel.getHasGlobals()
300:                                .getHasLoader());
301:                        elements.add(processModel);
302:
303:                        // do the update
304:                        for (Iterator<Element> elementObj = elements.iterator(); elementObj
305:                                .hasNext();) {
306:                            Element obj = (Element) elementObj.next();
307:                            if (obj.getImplementation() == null)
308:                                continue;
309:                            if (obj.getImplementation().equals(implementation)) {
310:                                EList<EnvEntry> entries = obj
311:                                        .getHasEnvEntries();
312:                                if (entries == null || entries.isEmpty())
313:                                    continue;
314:                                for (Iterator<EnvEntry> iterator2 = entries
315:                                        .iterator(); iterator2.hasNext();) {
316:                                    EnvEntry entry = (EnvEntry) iterator2
317:                                            .next();
318:                                    if (entry.getName().equals(entryName)
319:                                            && entry.getType().equals(
320:                                                    oldTypeName)) {
321:                                        entry.setType(newTypeName);
322:                                    }
323:                                }
324:                            }
325:                        }
326:                    }
327:                }
328:
329:                // write the changes to the model
330:                ModelEditor.INSTANCE.writeModel(model);
331:            }
332:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.