Source Code Cross Referenced for ConcreteWorkOrderService.java in  » Workflow-Engines » wilos » wilos » business » services » misc » concreteworkbreakdownelement » 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.misc.concreteworkbreakdownelement 
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) 2007 Sebastien BALARD <sbalard@wilos-project.org>
004:         * Copyright (C) 2007-2008 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
005:         * 
006:         * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
007:         * General Public License as published by the Free Software Foundation; either version 2 of the License,
008:         * or (at your option) any later version.
009:         *
010:         * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
011:         * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012:         * GNU General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU General Public License along with this program; if not,
015:         * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
016:         */
017:
018:        package wilos.business.services.misc.concreteworkbreakdownelement;
019:
020:        import java.util.HashSet;
021:        import java.util.List;
022:        import java.util.Set;
023:
024:        import org.springframework.transaction.annotation.Propagation;
025:        import org.springframework.transaction.annotation.Transactional;
026:
027:        import wilos.business.services.misc.stateservice.StateService;
028:        import wilos.business.services.spem2.workbreakdownelement.WorkBreakdownElementService;
029:        import wilos.hibernate.misc.concreteactivity.ConcreteActivityDao;
030:        import wilos.hibernate.misc.concretemilestone.ConcreteMilestoneDao;
031:        import wilos.hibernate.misc.concreteworkbreakdownelement.ConcreteWorkBreakdownElementDao;
032:        import wilos.hibernate.misc.concreteworkbreakdownelement.ConcreteWorkOrderDao;
033:        import wilos.hibernate.spem2.workbreakdownelement.WorkOrderDao;
034:        import wilos.model.misc.concreteworkbreakdownelement.ConcreteWorkBreakdownElement;
035:        import wilos.model.misc.concreteworkbreakdownelement.ConcreteWorkOrder;
036:        import wilos.model.misc.concreteworkbreakdownelement.ConcreteWorkOrderId;
037:        import wilos.utils.Constantes.State;
038:        import wilos.utils.Constantes.WorkOrderType;
039:
040:        /**
041:         * @author Sebastien BALARD
042:         * 
043:         */
044:        @Transactional(readOnly=false,propagation=Propagation.REQUIRED)
045:        public class ConcreteWorkOrderService {
046:
047:            private ConcreteWorkOrderDao concreteWorkOrderDao;
048:
049:            private WorkOrderDao workOrderDao;
050:
051:            private ConcreteActivityDao concreteActivityDao;
052:
053:            private StateService stateService;
054:
055:            private ConcreteWorkBreakdownElementDao concreteWorkBreakdownElementDao;
056:
057:            private WorkBreakdownElementService workBreakdownElementService;
058:
059:            private ConcreteMilestoneDao concreteMilestoneDao;
060:
061:            /**
062:             * Allows to save the concreteWorkOrder
063:             * 
064:             * @param _concretePredecessorId
065:             * @param _concreteSuccessorId
066:             * @param _concreteLinkType
067:             * @param _projectId
068:             * @return the concreteWorkOrderId
069:             */
070:            public ConcreteWorkOrderId saveConcreteWorkOrder(
071:                    String _concretePredecessorId, String _concreteSuccessorId,
072:                    String _concreteLinkType, String _projectId) {
073:
074:                ConcreteWorkBreakdownElement concreteWorkBreakdownElement1 = this .concreteWorkBreakdownElementDao
075:                        .getConcreteWorkBreakdownElement(_concretePredecessorId);
076:                ConcreteWorkBreakdownElement concreteWorkBreakdownElement2 = this .concreteWorkBreakdownElementDao
077:                        .getConcreteWorkBreakdownElement(_concreteSuccessorId);
078:
079:                ConcreteWorkOrder concreteWorkOrder = new ConcreteWorkOrder();
080:                concreteWorkOrder.setConcreteLinkType(_concreteLinkType);
081:                concreteWorkOrder.setProjectId(_projectId);
082:
083:                ConcreteWorkOrderId concreteWorkOrderId = new ConcreteWorkOrderId();
084:                concreteWorkOrderId
085:                        .setConcretePredecessorId(_concretePredecessorId);
086:                concreteWorkOrderId
087:                        .setConcreteSuccessorId(_concreteSuccessorId);
088:                concreteWorkOrderId.setConcreteLinkTypeId(_concreteLinkType);
089:                concreteWorkOrder.setConcreteWorkOrderId(concreteWorkOrderId);
090:
091:                concreteWorkBreakdownElement2
092:                        .addConcretePredecessor(concreteWorkOrder);
093:                concreteWorkBreakdownElement1
094:                        .addConcreteSuccessor(concreteWorkOrder);
095:
096:                this .concreteWorkOrderDao
097:                        .saveOrUpdateConcreteWorkOrder(concreteWorkOrder);
098:                this .concreteWorkBreakdownElementDao
099:                        .saveOrUpdateConcreteWorkBreakdownElement(concreteWorkBreakdownElement1);
100:                this .concreteWorkBreakdownElementDao
101:                        .saveOrUpdateConcreteWorkBreakdownElement(concreteWorkBreakdownElement2);
102:
103:                // Check for changes on the state of the successor
104:                this .checkSuccessorStateAfterAddingWorkOrder(concreteWorkOrder);
105:
106:                return concreteWorkOrderId;
107:            }
108:
109:            /**
110:             * Allows to update the workOrder's link type
111:             * 
112:             * @param _concreteWorkOrder
113:             * @param _newLink
114:             * @return the workOrder's link type
115:             */
116:            public ConcreteWorkOrderId updateWorkOrderLinkType(
117:                    ConcreteWorkOrder _concreteWorkOrder, String _newLink) {
118:                // no change to make
119:                if (_concreteWorkOrder.getConcreteLinkType().equals(_newLink)) {
120:                    return _concreteWorkOrder.getConcreteWorkOrderId();
121:                }
122:
123:                ConcreteWorkOrder updatedConcreteWorkOrder = null;
124:                try {
125:                    updatedConcreteWorkOrder = _concreteWorkOrder.clone();
126:                } catch (CloneNotSupportedException e) {
127:                }
128:
129:                this .concreteWorkOrderDao
130:                        .deleteConcreteWorkOrder(_concreteWorkOrder);
131:
132:                // Check for changes on the state of the successor
133:                this .concreteWorkOrderDao.getSessionFactory()
134:                        .getCurrentSession().flush();
135:                this 
136:                        .checkSuccessorStateAfterRemovingWorkOrder(updatedConcreteWorkOrder);
137:
138:                updatedConcreteWorkOrder.setConcreteLinkType(_newLink);
139:                updatedConcreteWorkOrder.getConcreteWorkOrderId()
140:                        .setConcreteLinkTypeId(_newLink);
141:
142:                this .concreteWorkOrderDao
143:                        .saveOrUpdateConcreteWorkOrder(updatedConcreteWorkOrder);
144:
145:                // Check for changes on the state of the successor
146:                this .concreteWorkOrderDao.getSessionFactory()
147:                        .getCurrentSession().flush();
148:                this 
149:                        .checkSuccessorStateAfterAddingWorkOrder(updatedConcreteWorkOrder);
150:
151:                return updatedConcreteWorkOrder.getConcreteWorkOrderId();
152:            }
153:
154:            /**
155:             * Allows to check the successor's state after adding a workOrder
156:             * 
157:             * @param _cwo
158:             */
159:            private void checkSuccessorStateAfterAddingWorkOrder(
160:                    ConcreteWorkOrder _cwo) {
161:                String predecessorId = _cwo.getConcreteWorkOrderId()
162:                        .getConcretePredecessorId();
163:                String successorId = _cwo.getConcreteWorkOrderId()
164:                        .getConcreteSuccessorId();
165:                ConcreteWorkBreakdownElement predecessor = this .concreteWorkBreakdownElementDao
166:                        .getConcreteWorkBreakdownElement(predecessorId);
167:                ConcreteWorkBreakdownElement successor = this .concreteWorkBreakdownElementDao
168:                        .getConcreteWorkBreakdownElement(successorId);
169:
170:                String linkType = _cwo.getConcreteLinkType();
171:
172:                if (successor.getState().equals(State.READY)) {
173:                    boolean predecessorIsAtLeastStarted = predecessor
174:                            .getState().equals(State.STARTED)
175:                            || predecessor.getState().equals(State.SUSPENDED)
176:                            || predecessor.getState().equals(State.FINISHED);
177:                    boolean predecessorIsFinished = predecessor.getState()
178:                            .equals(State.FINISHED);
179:
180:                    if ((linkType.equals(WorkOrderType.START_TO_START) && !predecessorIsAtLeastStarted)
181:                            || (linkType.equals(WorkOrderType.FINISH_TO_START) && !predecessorIsFinished)
182:                            || (this .concreteMilestoneDao
183:                                    .existsConcreteMilestone(successorId) && (linkType
184:                                    .equals(WorkOrderType.START_TO_FINISH)
185:                                    && !predecessorIsAtLeastStarted || linkType
186:                                    .equals(WorkOrderType.FINISH_TO_FINISH)
187:                                    && !predecessorIsFinished))) {
188:
189:                        this .stateService.updateStateTo(successor,
190:                                State.CREATED);
191:                    }
192:                }
193:            }
194:
195:            /**
196:             * Allows to check the successor's state after removing a workOrder
197:             * 
198:             * @param _oldCwo
199:             */
200:            private void checkSuccessorStateAfterRemovingWorkOrder(
201:                    ConcreteWorkOrder _oldCwo) {
202:                String successorId = _oldCwo.getConcreteWorkOrderId()
203:                        .getConcreteSuccessorId();
204:                ConcreteWorkBreakdownElement successor = this .concreteWorkBreakdownElementDao
205:                        .getConcreteWorkBreakdownElement(successorId);
206:
207:                String linkType = _oldCwo.getConcreteLinkType();
208:
209:                if (successor.getState().equals(State.CREATED)) {
210:                    if (linkType.equals(WorkOrderType.START_TO_START)
211:                            || linkType.equals(WorkOrderType.FINISH_TO_START)
212:                            || this .concreteMilestoneDao
213:                                    .existsConcreteMilestone(successorId)) {
214:                        this .stateService.updateStateTo(successor, State.READY);
215:                    }
216:                } else if (successor.getState().equals(State.STARTED)
217:                        && this .concreteActivityDao
218:                                .existsConcreteActivity(successorId)) {
219:                    this .stateService.updateStateTo(successor, State.FINISHED);
220:                }
221:            }
222:
223:            /**
224:             * Allows to get the set of all concreteWorkOrder from the
225:             * concreteBreakdownElement
226:             * 
227:             * @param _concreteWorkBreakdownElement
228:             * @return the set of all concreteWorkOrder
229:             */
230:            public Set<ConcreteWorkOrder> getAllConcreteWorkOrdersFromConcreteWorkBreakdownElement(
231:                    ConcreteWorkBreakdownElement _concreteWorkBreakdownElement) {
232:                Set<ConcreteWorkOrder> tmp = new HashSet<ConcreteWorkOrder>();
233:                this .concreteWorkOrderDao.getSessionFactory()
234:                        .getCurrentSession().saveOrUpdate(
235:                                _concreteWorkBreakdownElement);
236:                for (ConcreteWorkOrder cwo : _concreteWorkBreakdownElement
237:                        .getConcretePredecessors()) {
238:                    tmp.add(cwo);
239:                }
240:                for (ConcreteWorkOrder cwo : _concreteWorkBreakdownElement
241:                        .getConcreteSuccessors()) {
242:                    tmp.add(cwo);
243:                }
244:                return tmp;
245:            }
246:
247:            /**
248:             * Allows to get the list of all concreteWorkOrders
249:             * 
250:             * @return the list of all concreteWorkOrders
251:             */
252:            public List<ConcreteWorkOrder> getAllConcreteWorkOrders() {
253:                return this .concreteWorkOrderDao.getAllConcreteWorkOrders();
254:            }
255:
256:            /**
257:             * Allows to get the list of all concreteWorkOrders with a project id
258:             * 
259:             * @param _string
260:             * @return the list of all concreteWorkOrders
261:             */
262:            public List<ConcreteWorkOrder> getAllConcreteWorkOrdersFromProject(
263:                    String _projectId) {
264:                return this .concreteWorkOrderDao
265:                        .getAllConcreteWorkOrdersFromProject(_projectId);
266:            }
267:
268:            /**
269:             * Allows to get the set of concretePredecessors
270:             * 
271:             * @param _concreteWorkBreakdownElement
272:             * @return the set of concretePredecessors
273:             */
274:            public Set<ConcreteWorkOrder> getConcretePredecessors(
275:                    ConcreteWorkBreakdownElement _concreteWorkBreakdownElement) {
276:                Set<ConcreteWorkOrder> tmp = new HashSet<ConcreteWorkOrder>();
277:                this .concreteWorkOrderDao.getSessionFactory()
278:                        .getCurrentSession().saveOrUpdate(
279:                                _concreteWorkBreakdownElement);
280:                for (ConcreteWorkOrder cwo : _concreteWorkBreakdownElement
281:                        .getConcretePredecessors()) {
282:                    tmp.add(cwo);
283:                }
284:                return tmp;
285:            }
286:
287:            /**
288:             * Allows to get the set of concreteSuccessors
289:             * 
290:             * @param _concreteWorkBreakdownElement
291:             * @return the set of concreteSuccessors
292:             */
293:            public Set<ConcreteWorkOrder> getConcreteSuccessors(
294:                    ConcreteWorkBreakdownElement _concreteWorkBreakdownElement) {
295:                Set<ConcreteWorkOrder> tmp = new HashSet<ConcreteWorkOrder>();
296:                this .concreteWorkOrderDao.getSessionFactory()
297:                        .getCurrentSession().saveOrUpdate(
298:                                _concreteWorkBreakdownElement);
299:                for (ConcreteWorkOrder cwo : _concreteWorkBreakdownElement
300:                        .getConcreteSuccessors()) {
301:                    tmp.add(cwo);
302:                }
303:                return tmp;
304:            }
305:
306:            /**
307:             * Allows to get the concreteWorkOrder
308:             * 
309:             * @param _concreteWorkOrderId
310:             * @return the concreteWorkOrder
311:             */
312:            public ConcreteWorkOrder getConcreteWorkOrder(
313:                    ConcreteWorkOrderId _concreteWorkOrderId) {
314:                return this .concreteWorkOrderDao
315:                        .getConcreteWorkOrder(_concreteWorkOrderId);
316:            }
317:
318:            /**
319:             * Allows to delete the concreteWorkOrder
320:             * 
321:             * @param _concreteWorkOrder
322:             */
323:            public void deleteConcreteWorkOrder(
324:                    ConcreteWorkOrder _concreteWorkOrder) {
325:                this .concreteWorkOrderDao.getSessionFactory()
326:                        .getCurrentSession().saveOrUpdate(_concreteWorkOrder);
327:
328:                ConcreteWorkOrder oldConcreteWorkOrder = null;
329:                try {
330:                    oldConcreteWorkOrder = _concreteWorkOrder.clone();
331:                } catch (CloneNotSupportedException e) {
332:                }
333:
334:                this .concreteWorkOrderDao
335:                        .deleteConcreteWorkOrder(_concreteWorkOrder);
336:
337:                this .concreteWorkOrderDao.getSessionFactory()
338:                        .getCurrentSession().flush();
339:
340:                this 
341:                        .checkSuccessorStateAfterRemovingWorkOrder(oldConcreteWorkOrder);
342:            }
343:
344:            /**
345:             * Allows to check if the concreteWorkOrder exists
346:             * 
347:             * @param _selectedPredecessor
348:             * @param _id
349:             * @return true if the concreteWorkOrder is matched
350:             */
351:            public boolean existsConcreteWorkOrder(
352:                    String _concretePredecessorId, String _concreteSuccessorId,
353:                    String linkType) {
354:
355:                ConcreteWorkOrderId cwoi = new ConcreteWorkOrderId();
356:                cwoi.setConcretePredecessorId(_concretePredecessorId);
357:                cwoi.setConcreteSuccessorId(_concreteSuccessorId);
358:                cwoi.setConcreteLinkTypeId(linkType);
359:
360:                ConcreteWorkOrder cwo = this .concreteWorkOrderDao
361:                        .getConcreteWorkOrder(cwoi);
362:                if (cwo == null)
363:                    return false;
364:                else
365:                    return true;
366:            }
367:
368:            /**
369:             * Allows to get the concreteWorkBreakdownElementDao
370:             * 
371:             * @return the concreteWorkBreakdownElementDao
372:             */
373:            public ConcreteWorkBreakdownElementDao getConcreteWorkBreakdownElementDao() {
374:                return concreteWorkBreakdownElementDao;
375:            }
376:
377:            /**
378:             * Allows to set the concreteWorkBreakdownElementDao
379:             * 
380:             * @param _concreteWorkBreakdownElementDao
381:             * 
382:             */
383:            public void setConcreteWorkBreakdownElementDao(
384:                    ConcreteWorkBreakdownElementDao _concreteWorkBreakdownElementDao) {
385:                concreteWorkBreakdownElementDao = _concreteWorkBreakdownElementDao;
386:            }
387:
388:            /**
389:             * Allows to get the concreteWorkOrderDao
390:             * 
391:             * @return the concreteWorkOrderDao
392:             */
393:            public ConcreteWorkOrderDao getConcreteWorkOrderDao() {
394:                return concreteWorkOrderDao;
395:            }
396:
397:            /**
398:             * Allows to set the concreteWorkOrderDao
399:             * 
400:             * @param _concreteWorkOrderDao
401:             */
402:            public void setConcreteWorkOrderDao(
403:                    ConcreteWorkOrderDao _concreteWorkOrderDao) {
404:                concreteWorkOrderDao = _concreteWorkOrderDao;
405:            }
406:
407:            /**
408:             * Allows to get the workOrderDao
409:             * 
410:             * @return the workOrderDao
411:             */
412:            public WorkOrderDao getWorkOrderDao() {
413:                return this .workOrderDao;
414:            }
415:
416:            /**
417:             * Allows to set the workOrderDao
418:             * 
419:             * @param _workOrderDao
420:             */
421:            public void setWorkOrderDao(WorkOrderDao _workOrderDao) {
422:                this .workOrderDao = _workOrderDao;
423:            }
424:
425:            /**
426:             * Allows to get the workBreakdownElementService
427:             * 
428:             * @return the workBreakdownElementService
429:             */
430:            public WorkBreakdownElementService getWorkBreakdownElementService() {
431:                return this .workBreakdownElementService;
432:            }
433:
434:            /**
435:             * Allows to set the workBreakdownElementService
436:             * 
437:             * @param _workBreakdownElementService
438:             */
439:            public void setWorkBreakdownElementService(
440:                    WorkBreakdownElementService _workBreakdownElementService) {
441:                this .workBreakdownElementService = _workBreakdownElementService;
442:            }
443:
444:            /**
445:             * Allows to get the concreteActivityDao
446:             * 
447:             * @return the concreteActivityDao
448:             */
449:            public ConcreteActivityDao getConcreteActivityDao() {
450:                return this .concreteActivityDao;
451:            }
452:
453:            /**
454:             * Allows to set the concreteActivityDao
455:             * 
456:             * @param _concreteActivityDao
457:             */
458:            public void setConcreteActivityDao(
459:                    ConcreteActivityDao _concreteActivityDao) {
460:                this .concreteActivityDao = _concreteActivityDao;
461:            }
462:
463:            /**
464:             * Allows to get the service state
465:             * 
466:             * @return the stateService
467:             */
468:            public StateService getStateService() {
469:                return this .stateService;
470:            }
471:
472:            /**
473:             * Allows to set the service state
474:             * 
475:             * @param _stateService
476:             */
477:            public void setStateService(StateService _stateService) {
478:                this .stateService = _stateService;
479:            }
480:
481:            /**
482:             * Allows to get the concreteMilestoneDao
483:             * 
484:             * @return the concreteMilestoneDao
485:             */
486:            public ConcreteMilestoneDao getConcreteMilestoneDao() {
487:                return concreteMilestoneDao;
488:            }
489:
490:            /**
491:             * Allows to set the concreteMilestoneDao
492:             * 
493:             * @param _concreteMilestoneDao
494:             */
495:            public void setConcreteMilestoneDao(
496:                    ConcreteMilestoneDao _concreteMilestoneDao) {
497:                concreteMilestoneDao = _concreteMilestoneDao;
498:            }
499:
500:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.