Source code: domain/VolatileActivity.java
1 /*
2 * This file is part of the WfMCore/WfMOpen project.
3 * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
4 * All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * $Id: VolatileActivity.java,v 1.31 2003/09/24 15:19:09 lipp Exp $
21 *
22 * $Log: VolatileActivity.java,v $
23 * Revision 1.31 2003/09/24 15:19:09 lipp
24 * Updated to interface changes.
25 *
26 * Revision 1.30 2003/09/21 21:28:14 lipp
27 * Introducing "virtual" block activity.
28 *
29 * Revision 1.29 2003/09/12 14:15:15 lipp
30 * Suspend delay fixed.
31 *
32 * Revision 1.28 2003/09/09 13:42:27 lipp
33 * Updated.
34 *
35 * Revision 1.27 2003/09/08 15:37:18 lipp
36 * Introduced deadline definition and suspend tracking.
37 *
38 * Revision 1.26 2003/06/27 09:44:13 lipp
39 * Fixed copyright/license information.
40 *
41 * Revision 1.25 2003/05/14 13:05:05 lipp
42 * Made creator of subprocess inherited attribute.
43 *
44 * Revision 1.24 2003/05/14 09:01:00 lipp
45 * Some fixes.
46 *
47 * Revision 1.23 2003/05/14 08:48:25 lipp
48 * Added subflow attribute.
49 *
50 * Revision 1.22 2003/05/06 09:43:14 lipp
51 * Moved tool/sub-process invocation.
52 *
53 * Revision 1.21 2003/05/02 14:55:58 lipp
54 * Resolved some more package dependencies.
55 *
56 * Revision 1.20 2003/04/26 18:57:02 lipp
57 * Moved extended interfaces to own package.
58 *
59 * Revision 1.19 2003/02/03 10:09:27 lipp
60 * Adapted to latest changes in src.
61 *
62 * Revision 1.18 2003/01/24 16:47:09 lipp
63 * Implemented thread logging.
64 *
65 * Revision 1.17 2002/12/19 21:37:42 lipp
66 * Reorganized interfaces.
67 *
68 * Revision 1.16 2002/12/05 10:20:39 lipp
69 * Adapted unittests to assignment changes.
70 *
71 * Revision 1.15 2002/12/04 16:05:08 lipp
72 * Reorganized assignment handling.
73 *
74 * Revision 1.14 2002/11/26 11:23:29 lipp
75 * Modified RemoteException comment.
76 *
77 * Revision 1.13 2002/11/25 21:16:23 lipp
78 * Adapted to transition interface changes.
79 *
80 * Revision 1.12 2002/11/20 12:25:38 lipp
81 * Moved ActivityFinderAndKey to super interface.
82 *
83 * Revision 1.11 2002/10/21 19:08:05 lipp
84 * Continuing implementation of new state handling.
85 *
86 * Revision 1.10 2002/10/18 13:46:02 lipp
87 * Getting on with adaptions...
88 *
89 * Revision 1.9 2002/10/09 20:44:54 lipp
90 * New executor implementation for suspend support.
91 *
92 * Revision 1.8 2002/10/09 14:27:33 lipp
93 * Intermediate, compilable state.
94 *
95 * Revision 1.7 2002/10/08 15:32:39 lipp
96 * Providing base implementations for more methods in AbstractActivity.
97 *
98 * Revision 1.6 2002/10/02 21:23:25 lipp
99 * Some adaptations.
100 *
101 * Revision 1.5 2002/09/23 20:31:28 lipp
102 * Implemented async/sync invocation.
103 *
104 * Revision 1.4 2002/08/30 09:06:40 lipp
105 * Renamed internal state to typed state and use polymorphism for type
106 * names where possible.
107 *
108 * Revision 1.3 2002/08/29 18:58:28 lipp
109 * Improved initialization.
110 *
111 * Revision 1.2 2002/08/29 12:37:46 lipp
112 * Added missing method.
113 *
114 * Revision 1.1 2002/08/22 15:19:34 lipp
115 * Redesign of EJB persistence.
116 *
117 */
118 package domain;
119
120 import java.io.Serializable;
121
122 import java.util.ArrayList;
123 import java.util.Collection;
124 import java.util.Date;
125 import java.util.List;
126
127 import java.rmi.RemoteException;
128
129 import org.jdom.Element;
130
131 import de.danet.an.workflow.omgcore.WfAuditEvent;
132 import de.danet.an.workflow.omgcore.WfProcess;
133
134 import de.danet.an.workflow.api.Activity;
135 import de.danet.an.workflow.api.InvalidKeyException;
136 import de.danet.an.workflow.api.Process;
137
138 import de.danet.an.workflow.domain.AbstractActivity;
139
140 import de.danet.an.workflow.apix.ExtProcess;
141 import de.danet.an.workflow.apix.ThreadInfo;
142 import de.danet.an.workflow.spis.ras.ActivityFinder;
143 import de.danet.an.workflow.spis.ras.ResourceAssignmentService;
144
145 /**
146 * This class implements the persistance layer required by
147 * <code>AbstractActivity</code> by, well, providing no
148 * persistence ...
149 *
150 * @author <a href="mailto:lipp@danet.de"></a>
151 * @version $Revision: 1.31 $
152 */
153
154 public class VolatileActivity extends AbstractActivity {
155
156 private Process container;
157
158 //
159 // Provide the persistent attributes
160 //
161
162 /** Persistent attribute <code>key</code>. */
163 private String paKey;
164
165 /** Persistent attribute <code>name</code>. */
166 private String paName;
167
168 /** Persistent attribute <code>description</code>. */
169 private String paDescription;
170
171 /** Persistent attribute <code>priority</code>. */
172 private Priority paPriority = Priority.NORMAL;
173
174 /** Persistent attribute <code>typedState</code>. */
175 private State paTypedState;
176
177 /** Persistent attribute <code>lastStateTime</code>. */
178 private Date paLastStateTime;
179
180 /** Persistent attribute <code>startMode</code>. */
181 private StartFinishMode paStartMode = StartFinishMode.AUTOMATIC;
182
183 /** Persistent attribute <code>finishMode</code>. */
184 private StartFinishMode paFinishMode = StartFinishMode.AUTOMATIC;
185
186 /** Persistent attribute <code>joinMode</code>. */
187 private JoinAndSplitMode paJoinMode = JoinAndSplitMode.AND;
188
189 /** Persistent attribute <code>splitMode</code>. */
190 private JoinAndSplitMode paSplitMode = JoinAndSplitMode.AND;
191
192 /** Persistent attribute <code>performer</code>. */
193 private String paPerformer;
194
195 /** Persistent attribute <code>executor</code>. */
196 private Integer paExecutor = null;
197
198 /** Persistent attribute <code>tools</code>. */
199 private Implementation[] paActImpl = null;
200
201 /** Persistent attribute <code>threadInfo</code>. */
202 private ThreadInfo paThreadInfo;
203
204 /** Persistent attribute <code>Subflow</code>. */
205 private String paSubflow;
206
207 /** Persistent attribute <code>deadlines</code>. */
208 private List paDeadlines = new ArrayList ();
209
210 /** Persistent attribute <code>startTime</code>. */
211 private Date paStartTime;
212
213 /** Persistent attribute <code>suspendStart</code>. */
214 private Date paSuspendStart;
215
216 /** Persistent attribute <code>suspendAccum</code>. */
217 private long paSuspendAccum;
218
219 /** Persistent attribute <code>blockActivity</code>. */
220 private Long paBlockActivity;
221
222 private static int actKeyGen = 1;
223
224 /**
225 * Creates an instance of <code>VolatileActivity</code>
226 * with all attributes initialized to default values.
227 * @param proc a <code>Process</code> value
228 * @param key a <code>String</code> value
229 */
230 public VolatileActivity (Process proc, String key) {
231 super.init (null, null, null, null);
232 container = proc;
233 paKey = key;
234 }
235
236 /**
237 * Creates an instance of <code>VolatileActivity</code>
238 * with all attributes initialized to default values.
239 * @param proc a <code>Process</code> value
240 */
241 public VolatileActivity (Process proc) {
242 this (proc, Integer.toString(actKeyGen++));
243 }
244
245 /**
246 * Describe <code>setStartMode</code> method here.
247 *
248 * @param mode a <code>StartFinishMode</code> value
249 */
250 public void setStartMode (StartFinishMode mode) {
251 setPaStartMode (mode);
252 }
253
254 /**
255 * Describe <code>thisRemote</code> method here.
256 *
257 * @return an <code>Activity</code> value
258 */
259 protected Activity thisRemote () {
260 return this;
261 }
262
263 /**
264 * Returns a <code>WfAuditEvent</code> containing information about the
265 * activity and its container, only.
266 * @return the event containing the required information.
267 * @throws RemoteException if a system-level error occurs.
268 */
269 public WfAuditEvent auditEventBase () throws RemoteException {
270 throw new UnsupportedOperationException ();
271 }
272
273 /**
274 * Describe <code>container</code> method here.
275 *
276 * @return a <code>WfProcess</code> value
277 */
278 public WfProcess container() {
279 return container;
280 }
281
282 /**
283 * Lookup a process by its key. Can only be implemented by the
284 * persistence layer.
285 * @param key the primary key
286 * @return the process
287 * @throws RemoteException if a system-level error occurs
288 * @throws InvalidKeyException if no process with the given key
289 * exists
290 */
291 protected ExtProcess lookupProcess (String key)
292 throws RemoteException, InvalidKeyException {
293 throw new UnsupportedOperationException ();
294 }
295
296
297 /**
298 * Updates the process name (which is cached by the activity EJB)
299 * if the process name changes.
300 * @param newName the new process name.
301 * @throws RemoteException if a system-level error occurs.
302 */
303 public void updateProcessName (String newName) throws RemoteException {
304 }
305
306 /**
307 * Get the resource assignment service.
308 * @return the configured resource assignment service.
309 */
310 protected ResourceAssignmentService resourceAssignmentService() {
311 return null;
312 }
313
314 /**
315 * Returns an {@link de.danet.an.workflow.ras.ActivityFinder
316 * <code>ActivityFinder</code>} that identifies this activity
317 * against a resource assignment service as defined by
318 * {@link de.danet.an.workflow.ras the ras package}.
319 *
320 * @return the activity finder.
321 */
322 public ActivityFinder activityFinder () {
323 return null;
324 }
325
326 /**
327 * Start a timer that will call <code>handleTimeout</code> at the
328 * given date with the given info.
329 * @param due target date
330 * @param info the context
331 */
332 public void startTimer (Date due, Serializable info) {
333 }
334
335 /**
336 * Stop all timers that this object has created.
337 */
338 public void stopTimers () {
339 }
340
341 //
342 // Implement abstract methods as unsupported
343 //
344
345 /**
346 * Describe <code>nextActivities</code> method here.
347 *
348 * @return a <code>List</code> value
349 */
350 public List nextActivities () {
351 throw new UnsupportedOperationException();
352 }
353
354 /**
355 * Returns an <code>WfAuditEvent</code> containing container-related
356 * information.
357 * @return the audit event
358 */
359 protected WfAuditEvent containerAuditEventBase () {
360 return ((VolatileProcess)container()).auditEventBase ();
361 }
362
363 /**
364 * Describe <code>history</code> method here.
365 *
366 * @return a <code>Collection</code> value
367 * @exception RemoteException if an error occurs
368 */
369 public Collection history() throws RemoteException {
370 throw new UnsupportedOperationException();
371 }
372
373 //
374 // Implement accessor methods for the persistent attributes
375 //
376
377 /**
378 * The getter method implementation for the persistent
379 * attribute <code>key</code>.
380 *
381 * @return the value of key.
382 */
383 protected String getPaKey() {
384 return paKey;
385 }
386
387 /**
388 * The getter method implementation for the persistent
389 * attribute <code>name</code>.
390 *
391 * @return the value of name.
392 * @see #setPaName
393 */
394 protected String getPaName() {
395 return paName;
396 }
397
398 /**
399 * The setter method implementation for the persistent
400 * attribute <code>name</code>.
401 *
402 * @param newName the new value of name.
403 * @see #getPaName
404 */
405 protected void setPaName(String newName) {
406 paName = newName;
407 }
408
409 /**
410 * The getter method implementation for the persistent
411 * attribute <code>description</code>.
412 *
413 * @return the value of description.
414 * @see #setPaDescription
415 */
416 protected String getPaDescription() {
417 return paDescription;
418 }
419
420 /**
421 * The setter method implementation for the persistent
422 * attribute <code>description</code>.
423 *
424 * @param newDescription the new value of description.
425 * @see #getPaDescription
426 */
427 protected void setPaDescription(String newDescription) {
428 paDescription = newDescription;
429 }
430
431 /**
432 * The getter method implementation for the persistent
433 * attribute <code>priority</code>.
434 *
435 * @return the value of priority.
436 * @see #setPaPriority
437 */
438 protected Priority getPaPriority() {
439 return paPriority;
440 }
441
442 /**
443 * The setter method implementation for the persistent
444 * attribute <code>priority</code>.
445 *
446 * @param newPriority the new value of priority.
447 * @see #getPaPriority
448 */
449 protected void setPaPriority(Priority newPriority) {
450 paPriority = newPriority;
451 }
452
453 /**
454 * The getter method implementation for the persistent
455 * attribute <code>typedState</code>.
456 *
457 * @return the value of typedState.
458 * @see #setPaTypedState
459 */
460 protected State getPaTypedState() {
461 return paTypedState;
462 }
463
464 /**
465 * The getter method implementation for the persistent
466 * attribute <code>lastStateTime</code>.
467 *
468 * @return the value of lastStateTime.
469 * @see #setPaLastStateTime
470 */
471 protected Date getPaLastStateTime() {
472 return paLastStateTime;
473 }
474
475 /**
476 * The setter method implementation for the persistent
477 * attribute <code>lastStateTime</code>.
478 *
479 * @param newLastStateTime the new value of lastStateTime.
480 * @see #getPaLastStateTime
481 */
482 protected void setPaLastStateTime(Date newLastStateTime) {
483 paLastStateTime = newLastStateTime;
484 }
485
486 /**
487 * The setter method implementation for the persistent
488 * attribute <code>typedState</code>.
489 *
490 * @param newTypedState the new value of typedState.
491 * @see #getPaTypedState
492 */
493 protected void setPaTypedState(State newTypedState) {
494 paTypedState = newTypedState;
495 }
496
497 /**
498 * The getter method implementation for the persistent
499 * attribute <code>startMode</code>.
500 *
501 * @return the value of startMode.
502 * @see #setPaStartMode
503 */
504 protected StartFinishMode getPaStartMode() {
505 return paStartMode;
506 }
507
508 /**
509 * The setter method implementation for the persistent
510 * attribute <code>startMode</code>.
511 *
512 * @param newStartMode the new value of startMode.
513 * @see #getPaStartMode
514 */
515 protected void setPaStartMode(StartFinishMode newStartMode) {
516 paStartMode = newStartMode;
517 }
518
519 /**
520 * The getter method implementation for the persistent
521 * attribute <code>finishMode</code>.
522 *
523 * @return the value of finishMode.
524 * @see #setPaFinishMode
525 */
526 protected StartFinishMode getPaFinishMode() {
527 return paFinishMode;
528 }
529
530 /**
531 * The setter method implementation for the persistent
532 * attribute <code>finishMode</code>.
533 *
534 * @param newFinishMode the new value of finishMode.
535 * @see #getPaFinishMode
536 */
537 protected void setPaFinishMode(StartFinishMode newFinishMode) {
538 paFinishMode = newFinishMode;
539 }
540
541 /**
542 * The getter method implementation for the persistent
543 * attribute <code>joinMode</code>.
544 *
545 * @return the value of joinMode.
546 * @see #setPaJoinMode
547 */
548 protected JoinAndSplitMode getPaJoinMode() {
549 return paJoinMode;
550 }
551
552 /**
553 * The setter method implementation for the persistent
554 * attribute <code>joinMode</code>.
555 *
556 * @param newJoinMode the new value of joinMode.
557 * @see #getPaJoinMode
558 */
559 protected void setPaJoinMode(JoinAndSplitMode newJoinMode) {
560 paJoinMode = newJoinMode;
561 }
562
563 /**
564 * The getter method implementation for the persistent
565 * attribute <code>splitMode</code>.
566 *
567 * @return the value of splitMode.
568 * @see #setPaSplitMode
569 */
570 protected JoinAndSplitMode getPaSplitMode() {
571 return paSplitMode;
572 }
573
574 /**
575 * The setter method implementation for the persistent
576 * attribute <code>splitMode</code>.
577 *
578 * @param newSplitMode the new value of splitMode.
579 * @see #getPaSplitMode
580 */
581 protected void setPaSplitMode(JoinAndSplitMode newSplitMode) {
582 paSplitMode = newSplitMode;
583 }
584
585 /**
586 * The getter method implementation for the persistent
587 * attribute <code>executor</code>.
588 *
589 * @return the value of executor.
590 * @see #setPaExecStat
591 */
592 protected Integer getPaExecStat() {
593 return paExecutor;
594 }
595
596 /**
597 * The getter method implementation for the persistent
598 * attribute <code>performer</code>.
599 *
600 * @return the value of performer.
601 * @see #setPaPerformer
602 */
603 protected String getPaPerformer() {
604 return paPerformer;
605 }
606
607 /**
608 * The setter method implementation for the persistent
609 * attribute <code>performer</code>.
610 *
611 * @param newPerformer the new value of performer.
612 * @see #getPaPerformer
613 */
614 protected void setPaPerformer(String newPerformer) {
615 paPerformer = newPerformer;
616 }
617
618 /**
619 * The setter method implementation for the persistent
620 * attribute <code>executor</code>.
621 *
622 * @param newExecutor the new value of executor.
623 * @see #getPaExecStat
624 */
625 protected void setPaExecStat(Integer newExecutor) {
626 paExecutor = newExecutor;
627 }
628
629 /**
630 * The getter method implementation for the persistent
631 * attribute <code>tools</code>.
632 *
633 * @return the value of tools.
634 * @see #setPaActImpl
635 */
636 protected Implementation[] getPaActImpl() {
637 return paActImpl;
638 }
639
640 /**
641 * The setter method implementation for the persistent
642 * attribute <code>tools</code>.
643 *
644 * @param newTools the new value of tools.
645 * @see #getPaActImpl
646 */
647 protected void setPaActImpl(Implementation[] newTools) {
648 paActImpl = newTools;
649 }
650
651 /**
652 * The getter method implementation for the persistent
653 * attribute <code>threadInfo</code>.
654 *
655 * @see #setPaThreadInfo
656 * @return the value of threadInfo.
657 */
658 protected ThreadInfo getPaThreadInfo() {
659 return paThreadInfo;
660 }
661
662 /**
663 * The setter method implementation for the persistent
664 * attribute <code>threadInfo</code>.
665 *
666 * @param newThreadInfo the new value of threadInfo.
667 * @see #getPaThreadInfo
668 */
669 protected void setPaThreadInfo(ThreadInfo newThreadInfo) {
670 paThreadInfo = newThreadInfo;
671 }
672
673 /**
674 * Describe <code>getPaActivityElement</code> method here.
675 *
676 * @return an <code>Element</code> value
677 */
678 protected Element getPaActivityElement() {
679 return null;
680 }
681
682 /**
683 * The getter method implementation for the persistent
684 * attribute <code>Subflow</code>.
685 *
686 * @see #setPaSubflow
687 * @return the value of Subflow.
688 */
689 protected String getPaSubflow() {
690 return paSubflow;
691 }
692
693 /**
694 * The setter method implementation for the persistent
695 * attribute <code>Subflow</code>.
696 *
697 * @param newSubflow the new value of Subflow.
698 * @see #getPaSubflow
699 */
700 protected void setPaSubflow(String newSubflow) {
701 paSubflow = newSubflow;
702 }
703
704 /**
705 * The getter method implementation for the persistent
706 * attribute <code>deadlines</code>.
707 *
708 * @see #setPaDeadlines
709 * @return the value of deadlines.
710 */
711 protected List getPaDeadlines() {
712 return paDeadlines;
713 }
714
715 /**
716 * The setter method implementation for the persistent
717 * attribute <code>deadlines</code>.
718 *
719 * @param newDeadlines the new value of deadlines.
720 * @see #getPaDeadlines
721 */
722 protected void setPaDeadlines(List newDeadlines) {
723 paDeadlines = newDeadlines;
724 }
725
726 /**
727 * The getter method implementation for the persistent
728 * attribute <code>startTime</code>.
729 *
730 * @see #setPaStartTime
731 * @return the value of startTime.
732 */
733 protected Date getPaStartTime() {
734 return paStartTime;
735 }
736
737 /**
738 * The setter method implementation for the persistent
739 * attribute <code>startTime</code>.
740 *
741 * @param newStartTime the new value of startTime.
742 * @see #getPaStartTime
743 */
744 protected void setPaStartTime(Date newStartTime) {
745 paStartTime = newStartTime;
746 }
747
748 /**
749 * The getter method implementation for the persistent
750 * attribute <code>suspendStart</code>.
751 *
752 * @see #setPaSuspendStart
753 * @return the value of suspendStart.
754 */
755 protected Date getPaSuspendStart() {
756 return paSuspendStart;
757 }
758
759 /**
760 * The setter method implementation for the persistent
761 * attribute <code>suspendStart</code>.
762 *
763 * @param newSuspendStart the new value of suspendStart.
764 * @see #getPaSuspendStart
765 */
766 protected void setPaSuspendStart(Date newSuspendStart) {
767 paSuspendStart = newSuspendStart;
768 }
769
770 /**
771 * The getter method implementation for the persistent
772 * attribute <code>suspendAccum</code>.
773 *
774 * @see #setPaSuspendAccum
775 * @return the value of suspendAccum.
776 */
777 protected long getPaSuspendAccum() {
778 return paSuspendAccum;
779 }
780
781 /**
782 * The setter method implementation for the persistent
783 * attribute <code>suspendAccum</code>.
784 *
785 * @param newSuspendAccum the new value of suspendAccum.
786 * @see #getPaSuspendAccum
787 */
788 protected void setPaSuspendAccum(long newSuspendAccum) {
789 paSuspendAccum = newSuspendAccum;
790 }
791
792 /**
793 * The getter method implementation for the persistent
794 * attribute <code>blockActivity</code>.
795 *
796 * @see #setPaBlockActivity
797 * @return the value of blockActivity.
798 */
799 protected Long getPaBlockActivity() {
800 return paBlockActivity;
801 }
802
803 /**
804 * The setter method implementation for the persistent attribute
805 * <code>blockActivity</code>. May only be used in base class'
806 * init.
807 *
808 * @param newBlockActivity the new value of blockActivity.
809 * @see #getPaBlockActivity
810 */
811 protected void setPaBlockActivity(Long newBlockActivity) {
812 paBlockActivity = newBlockActivity;
813 }
814
815 }
816