Source Code Cross Referenced for RoleDescriptorService.java in  » Workflow-Engines » wilos » wilos » business » services » spem2 » role » 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 » wilos » wilos.business.services.spem2.role 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
003:         * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
004:         * Copyright (C) 2007 Mathieu BENOIT <mathieu-benoit@hotmail.fr>
005:         * Copyright (C) 2007 Sebastien BALARD <sbalard@wilos-project.org>
006:         *
007:         * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
008:         * General Public License as published by the Free Software Foundation; either version 2 of the License,
009:         * or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
012:         * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013:         * GNU General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU General Public License along with this program; if not,
016:         * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
017:         */
018:
019:        package wilos.business.services.spem2.role;
020:
021:        import java.util.HashMap;
022:        import java.util.HashSet;
023:        import java.util.List;
024:        import java.util.Set;
025:
026:        import org.springframework.transaction.annotation.Propagation;
027:        import org.springframework.transaction.annotation.Transactional;
028:
029:        import wilos.business.services.misc.concreteactivity.ConcreteActivityService;
030:        import wilos.business.services.misc.concretebreakdownelement.ConcreteBreakdownElementService;
031:        import wilos.business.services.misc.project.ProjectService;
032:        import wilos.business.services.spem2.activity.ActivityService;
033:        import wilos.business.services.spem2.breakdownelement.BreakdownElementService;
034:        import wilos.business.services.spem2.process.ProcessService;
035:        import wilos.hibernate.misc.concreterole.ConcreteRoleDescriptorDao;
036:        import wilos.hibernate.spem2.role.RoleDescriptorDao;
037:        import wilos.model.misc.concreteactivity.ConcreteActivity;
038:        import wilos.model.misc.concretebreakdownelement.ConcreteBreakdownElement;
039:        import wilos.model.misc.concreterole.ConcreteRoleDescriptor;
040:        import wilos.model.misc.project.Project;
041:        import wilos.model.spem2.activity.Activity;
042:        import wilos.model.spem2.process.Process;
043:        import wilos.model.spem2.role.RoleDescriptor;
044:        import wilos.model.spem2.task.TaskDescriptor;
045:        import wilos.utils.Constantes.State;
046:
047:        @Transactional(readOnly=false,propagation=Propagation.REQUIRED)
048:        public class RoleDescriptorService {
049:
050:            /* Attributes */
051:
052:            private ConcreteRoleDescriptorDao concreteRoleDescriptorDao;
053:
054:            private RoleDescriptorDao roleDescriptorDao;
055:
056:            private ConcreteActivityService concreteActivityService;
057:
058:            private ProcessService processService;
059:
060:            private ActivityService activityService;
061:
062:            private BreakdownElementService breakdownElementService;
063:
064:            private ConcreteBreakdownElementService concreteBreakdownElementService;
065:
066:            private ProjectService projectService;
067:
068:            /* Public Methods */
069:
070:            public RoleDescriptor getRoleDescriptor(String _id) {
071:                return this .roleDescriptorDao.getRoleDescriptor(_id);
072:            }
073:
074:            public String saveRoleDescriptor(RoleDescriptor _roleDescriptor) {
075:                return this .roleDescriptorDao
076:                        .saveOrUpdateRoleDescriptor(_roleDescriptor);
077:            }
078:
079:            /**
080:             * 
081:             * @param _project
082:             * @param _rd
083:             * @param _cact
084:             * @param _occ
085:             */
086:            public void roleDescriptorInstanciation(Project _project,
087:                    RoleDescriptor _rd, ConcreteActivity _cact, int _occ) {
088:
089:                if (_occ > 0) {
090:                    int nbCrd = 0;
091:                    for (ConcreteBreakdownElement tmp : this .concreteActivityService
092:                            .getConcreteBreakdownElements(_cact)) {
093:                        if (tmp instanceof  ConcreteRoleDescriptor) {
094:                            if (((ConcreteRoleDescriptor) tmp)
095:                                    .getRoleDescriptor().getId().equals(
096:                                            _rd.getId())) {
097:                                nbCrd++;
098:                            }
099:                        }
100:                    }
101:                    for (int i = nbCrd + 1; i <= nbCrd + _occ; i++) {
102:
103:                        ConcreteRoleDescriptor crd = new ConcreteRoleDescriptor();
104:
105:                        if (_rd.getPresentationName().equals(""))
106:                            crd.setConcreteName(_rd.getName() + "#" + i);
107:                        else
108:                            crd.setConcreteName(_rd.getPresentationName() + "#"
109:                                    + i);
110:
111:                        crd.addRoleDescriptor(_rd);
112:                        crd.setBreakdownElement(_rd);
113:                        crd.setProject(_project);
114:                        crd.setInstanciationOrder(i);
115:                        crd.addSuperConcreteActivity(_cact);
116:
117:                        this .concreteRoleDescriptorDao
118:                                .saveOrUpdateConcreteRoleDescriptor(crd);
119:                        System.out
120:                                .println("### ConcreteRoleDescriptor sauve : "
121:                                        + crd.getConcreteName());
122:
123:                        this .concreteActivityService
124:                                .saveConcreteActivity(_cact);
125:
126:                        if (_project != _cact) {
127:                            System.out
128:                                    .println("### ConcreteActivity updated : "
129:                                            + _cact.getProject()
130:                                                    .getConcreteName());
131:                        }
132:                    }
133:                }
134:            }
135:
136:            /* Public Methods to resolve the lazy loading problem */
137:
138:            public Set<TaskDescriptor> getAdditionalTasks(RoleDescriptor _rd) {
139:                Set<TaskDescriptor> tmp = new HashSet<TaskDescriptor>();
140:                this .roleDescriptorDao.getSessionFactory().getCurrentSession()
141:                        .saveOrUpdate(_rd);
142:                for (TaskDescriptor td : _rd.getAdditionalTasks()) {
143:                    tmp.add(td);
144:                }
145:                return tmp;
146:            }
147:
148:            /**
149:             * 
150:             * @param _rd
151:             * @return
152:             */
153:            public Set<TaskDescriptor> getPrimaryTasks(RoleDescriptor _rd) {
154:                Set<TaskDescriptor> tmp = new HashSet<TaskDescriptor>();
155:                this .roleDescriptorDao.getSessionFactory().getCurrentSession()
156:                        .saveOrUpdate(_rd);
157:                for (TaskDescriptor td : _rd.getPrimaryTasks()) {
158:                    tmp.add(td);
159:                }
160:                return tmp;
161:            }
162:
163:            /**
164:             * 
165:             * @param _rd
166:             * @return
167:             */
168:            public Set<ConcreteRoleDescriptor> getConcreteRoleDescriptors(
169:                    RoleDescriptor _rd) {
170:                Set<ConcreteRoleDescriptor> tmp = new HashSet<ConcreteRoleDescriptor>();
171:                this .roleDescriptorDao.getSessionFactory().getCurrentSession()
172:                        .saveOrUpdate(_rd);
173:                for (ConcreteRoleDescriptor td : _rd
174:                        .getConcreteRoleDescriptors()) {
175:                    tmp.add(td);
176:                }
177:                return tmp;
178:            }
179:
180:            /**
181:             * 
182:             * @param _project
183:             * @param _process
184:             * @param _list
185:             */
186:            public void rolesInstanciation(Project _project, Process _process,
187:                    List<HashMap<String, Object>> _list) {
188:
189:                this .concreteActivityService.getConcreteActivityDao()
190:                        .getSessionFactory().getCurrentSession().saveOrUpdate(
191:                                _project);
192:                this .activityService.getActivityDao().getSessionFactory()
193:                        .getCurrentSession().saveOrUpdate(_process);
194:
195:                for (HashMap<String, Object> hm : _list) {
196:                    if (hm.get("isDisabled") != null) {
197:                        // general role instanciation
198:                        if ((Boolean) hm.get("isDisabled") == false) {
199:                            for (HashMap<String, Object> tmp : this .projectService
200:                                    .getDifferentPathsOfRoleDescriptorInProcess(
201:                                            _process, (String) hm.get("name"))) {
202:                                RoleDescriptor rd = this .roleDescriptorDao
203:                                        .getRoleDescriptor((String) tmp
204:                                                .get("id"));
205:                                for (Activity act : this .breakdownElementService
206:                                        .getSuperActivitiesUnderList(rd)) {
207:
208:                                    if (!_process.getGuid().equals(
209:                                            "_0uyGoMlgEdmt3adZL5Dmdw")) {
210:                                        this .generalParsing(_project, hm, rd,
211:                                                act);
212:                                    } else {
213:                                        this .openUPParsing(_project, hm, tmp,
214:                                                rd, act);
215:                                    }
216:                                }
217:                            }
218:                        }
219:                    } else {
220:                        // instanciation for each occurence of a role
221:                        RoleDescriptor rd = this .roleDescriptorDao
222:                                .getRoleDescriptor((String) hm.get("id"));
223:                        for (Activity act : this .breakdownElementService
224:                                .getSuperActivitiesUnderList(rd)) {
225:                            if (!_process.getGuid().equals(
226:                                    "_0uyGoMlgEdmt3adZL5Dmdw")) {
227:                                generalParsing(_project, hm, rd, act);
228:                            } else {
229:                                openUPParsing(_project, hm, hm, rd, act);
230:                            }
231:                        }
232:                    }
233:                }
234:
235:            }
236:
237:            /**
238:             * 
239:             * @param _project
240:             * @param hm
241:             * @param tmp
242:             * @param rd
243:             * @param act
244:             */
245:            private void openUPParsing(Project _project,
246:                    HashMap<String, Object> hm, HashMap<String, Object> tmp,
247:                    RoleDescriptor rd, Activity act) {
248:                // open up process
249:                String path = (String) tmp.get("name");
250:                path = path.substring(0, path.lastIndexOf('/') - 1);
251:                path = path.substring(0, path.lastIndexOf('/') - 1);
252:                String cAncestorName = path.substring(
253:                        path.lastIndexOf('/') + 2, path.length());
254:                Activity super Act = null;
255:                for (Activity super ActTmp : act.getSuperActivities()) {
256:                    if (super ActTmp.getPresentationName().equals(cAncestorName)) {
257:                        super Act = super ActTmp;
258:                        break;
259:                    }
260:                }
261:                // first level role in hierarchy
262:                if (act instanceof  Process) {
263:                    this .roleDescriptorInstanciation(_project, rd, _project,
264:                            (Integer) hm.get("nbOccurences"));
265:                } else {
266:                    // others levels
267:                    for (ConcreteActivity ca : this .activityService
268:                            .getConcreteActivitiesFromActivityAndForAProject(
269:                                    act, _project)) {
270:                        if (!ca.getState().equals(State.FINISHED)) {
271:                            List<ConcreteActivity> listSuperCA = this .concreteBreakdownElementService
272:                                    .getSuperConcreteActivitiesUnderList(ca);
273:                            if (listSuperCA.get(0).getActivity().equals(
274:                                    super Act))
275:                                this .roleDescriptorInstanciation(_project, rd,
276:                                        ca, (Integer) hm.get("nbOccurences"));
277:                        }
278:                    }
279:                }
280:            }
281:
282:            /**
283:             * 
284:             * @param _project
285:             * @param hm
286:             * @param rd
287:             * @param act
288:             */
289:            private void generalParsing(Project _project,
290:                    HashMap<String, Object> hm, RoleDescriptor rd, Activity act) {
291:                // scrum process
292:                if (act instanceof  Process) {
293:                    this .roleDescriptorInstanciation(_project, rd, _project,
294:                            (Integer) hm.get("nbOccurences"));
295:                } else {
296:                    for (ConcreteActivity ca : this .activityService
297:                            .getConcreteActivitiesFromActivityAndForAProject(
298:                                    act, _project)) {
299:                        if (!ca.getState().equals(State.FINISHED)) {
300:                            this .roleDescriptorInstanciation(_project, rd, ca,
301:                                    (Integer) hm.get("nbOccurences"));
302:                        }
303:                    }
304:                }
305:            }
306:
307:            /* Getters & Setters */
308:
309:            public RoleDescriptorDao getRoleDescriptorDao() {
310:                return roleDescriptorDao;
311:            }
312:
313:            public void setRoleDescriptorDao(RoleDescriptorDao roleDescriptorDao) {
314:                this .roleDescriptorDao = roleDescriptorDao;
315:            }
316:
317:            public ConcreteRoleDescriptorDao getConcreteRoleDescriptorDao() {
318:                return concreteRoleDescriptorDao;
319:            }
320:
321:            public void setConcreteRoleDescriptorDao(
322:                    ConcreteRoleDescriptorDao concreteRoleDescriptorDao) {
323:                this .concreteRoleDescriptorDao = concreteRoleDescriptorDao;
324:            }
325:
326:            public ConcreteActivityService getConcreteActivityService() {
327:                return concreteActivityService;
328:            }
329:
330:            public void setConcreteActivityService(
331:                    ConcreteActivityService concreteActivityService) {
332:                this .concreteActivityService = concreteActivityService;
333:            }
334:
335:            /**
336:             * @param _roleDescriptor
337:             */
338:            public void deleteRoleDescriptor(RoleDescriptor _roleDescriptor) {
339:                this .roleDescriptorDao.deleteRoleDescriptor(_roleDescriptor);
340:            }
341:
342:            /**
343:             * @return
344:             */
345:            public List<RoleDescriptor> getAllRoleDescriptors() {
346:                return this .roleDescriptorDao.getAllRoleDescriptors();
347:            }
348:
349:            /**
350:             * @return the processService
351:             */
352:            public ProcessService getProcessService() {
353:                return this .processService;
354:            }
355:
356:            /**
357:             * @param _processService
358:             *                the processService to set
359:             */
360:            public void setProcessService(ProcessService _processService) {
361:                this .processService = _processService;
362:            }
363:
364:            /**
365:             * @return the activityService
366:             */
367:            public ActivityService getActivityService() {
368:                return this .activityService;
369:            }
370:
371:            /**
372:             * @param _activityService
373:             *                the activityService to set
374:             */
375:            public void setActivityService(ActivityService _activityService) {
376:                this .activityService = _activityService;
377:            }
378:
379:            /**
380:             * @return the breakdownElementService
381:             */
382:            public BreakdownElementService getBreakdownElementService() {
383:                return this .breakdownElementService;
384:            }
385:
386:            /**
387:             * @param _breakdownElementService
388:             *                the breakdownElementService to set
389:             */
390:            public void setBreakdownElementService(
391:                    BreakdownElementService _breakdownElementService) {
392:                this .breakdownElementService = _breakdownElementService;
393:            }
394:
395:            public ProjectService getProjectService() {
396:                return projectService;
397:            }
398:
399:            public void setProjectService(ProjectService projectService) {
400:                this .projectService = projectService;
401:            }
402:
403:            public ConcreteBreakdownElementService getConcreteBreakdownElementService() {
404:                return concreteBreakdownElementService;
405:            }
406:
407:            public void setConcreteBreakdownElementService(
408:                    ConcreteBreakdownElementService concreteBreakdownElementService) {
409:                this .concreteBreakdownElementService = concreteBreakdownElementService;
410:            }
411:
412:            public String getPresentationName(RoleDescriptor _rd) {
413:                this.roleDescriptorDao.saveOrUpdateRoleDescriptor(_rd);
414:                return _rd.getPresentationName();
415:            }
416:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.