1 /*
2 * This software was designed and created by Jason Carroll.
3 * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4 * The author can be reached at jcarroll@cowsultants.com
5 * ITracker website: http://www.cowsultants.com
6 * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it only under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19 package org.itracker.model;
20
21 import org.apache.commons.lang.builder.ToStringBuilder;
22
23 /**
24 * A BeanShell script to execute on a particular event.
25 * <p> The script is interpreted on it's event fired<br />
26 * in the environment there is available:</p>
27 * <ul> <li>event (event type-id)
28 * </li><li>fieldId (is a field id associated with event)
29 * </li><li>currentValue (is a set of current values)
30 * </li><li>currentErrors (is a container for occurred errors)
31 * </li><li>currentForm (is a form instance, holding values)
32 * </li> </ul>
33 * <p>
34 * currentValue will be applied to the currentForm, property field</p>
35 * </p>
36 * <p>
37 * This allows to dynamically customize the system by executing custom actions
38 * at given extension points where an event is generated.
39 * </p>
40 * <p>
41 * A WorkflowScript needs to be configured to be executed for a particular field
42 * of a Project. This configuration is represented as a ProjectScript. <br>
43 * WorkflowScript - ProjectScript is a 1-N relationship.
44 * </p>
45 *
46 * @author ready
47 * @see ProjectScript
48 */
49 public class WorkflowScript extends AbstractEntity {
50
51 /**
52 *
53 */
54 private static final long serialVersionUID = 1L;
55
56 private String name;
57
58 private String script;
59
60 private int event;
61
62 // TODO: what's the expected type here?
63 // private Collection projectFields;
64 private int numUses;
65
66 /*
67 * This class used to have a <code>projectFields</code> attribute, which
68 * was a Collection<ProjectScript>. This has been removed because the
69 * association WorkflowScript - ProjectScript doesn't need to be navigatable
70 * in this direction.
71 */
72
73 public int getEvent() {
74 return event;
75 }
76
77 public void setEvent(int event) {
78 this.event = event;
79 }
80
81 public String getName() {
82 return name;
83 }
84
85 public void setName(String name) {
86 this.name = name;
87 }
88
89 /*
90 * public Collection getProjectFields() { return projectFields; }
91 *
92 * public void setProjectFields(Collection projectFields) {
93 * this.projectFields = projectFields; }
94 */
95 public String getScript() {
96 return script;
97 }
98
99 public void setScript(String script) {
100 this.script = script;
101 }
102
103 public int getNumberUses() {
104 return numUses;
105 }
106
107 public void setNumberUses(int value) {
108 numUses = value;
109 }
110
111 @Override
112 public String toString() {
113 return new ToStringBuilder(this).append("id", getId()).append("name", getName())
114 .append("event", getEvent()).append("numberUses", getNumberUses()).append(
115 "script", getScript()).toString();
116 }
117
118 }