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 public enum ScriptLanguage { 57 BeanShell, 58 Groovy 59 } 60 private String name; 61 62 private String script; 63 64 private int event; 65 66 // TODO: what's the expected type here? 67 // private Collection projectFields; 68 private int numUses; 69 70 private ScriptLanguage language; 71 /* 72 * This class used to have a <code>projectFields</code> attribute, which 73 * was a Collection<ProjectScript>. This has been removed because the 74 * association WorkflowScript - ProjectScript doesn't need to be navigatable 75 * in this direction. 76 */ 77 78 public int getEvent() { 79 return event; 80 } 81 82 public void setEvent(int event) { 83 this.event = event; 84 } 85 86 public String getName() { 87 return name; 88 } 89 90 public void setName(String name) { 91 this.name = name; 92 } 93 94 /* 95 * public Collection getProjectFields() { return projectFields; } 96 * 97 * public void setProjectFields(Collection projectFields) { 98 * this.projectFields = projectFields; } 99 */ 100 public String getScript() { 101 return script; 102 } 103 104 public void setScript(String script) { 105 this.script = script; 106 } 107 108 109 public ScriptLanguage getLanguage() { 110 return language; 111 } 112 113 public void setLanguage(ScriptLanguage language) { 114 this.language = language; 115 } 116 117 @Override 118 public String toString() { 119 return new ToStringBuilder(this).append("id", getId()).append("name", getName()) 120 .append("event", getEvent()).append("language", getLanguage()).append( 121 "script", getScript()).toString(); 122 } 123 124 }