001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.scripting;
034:
035: import com.flexive.shared.AbstractSelectableObjectWithName;
036: import com.flexive.shared.exceptions.FxInvalidParameterException;
037: import org.apache.commons.lang.StringUtils;
038:
039: import java.io.Serializable;
040:
041: /**
042: * Information about a script
043: *
044: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
045: */
046: public class FxScriptInfo extends AbstractSelectableObjectWithName
047: implements Serializable {
048: private static final long serialVersionUID = -2845241882558637595L;
049: protected long id;
050: protected FxScriptEvent event;
051: protected String name;
052: protected String description;
053: protected String code;
054: protected boolean active = false;
055:
056: public FxScriptInfo() {
057: /* empty constructor */
058: }
059:
060: /**
061: * Constructor
062: *
063: * @param id script id
064: * @param event script type
065: * @param name (unique) name of the script
066: * @param description description
067: * @param code the script code
068: * @param active if the script is active
069: * @throws FxInvalidParameterException on errors
070: * @see FxScriptEvent
071: */
072: public FxScriptInfo(long id, FxScriptEvent event, String name,
073: String description, String code, boolean active)
074: throws FxInvalidParameterException {
075: this .id = id;
076: this .event = event;
077: this .name = name;
078: this .description = (description == null ? "" : description);
079: this .code = (code == null ? "" : code);
080: this .active = active;
081: if (StringUtils.isEmpty(this .name) || this .name.length() > 255) {
082: throw new FxInvalidParameterException("NAME",
083: "ex.scripting.name.invalid", name);
084: }
085: }
086:
087: /**
088: * Return this script info as editable object.
089: *
090: * @return script info as editable
091: */
092:
093: public FxScriptInfoEdit asEditable() {
094: return new FxScriptInfoEdit(this );
095: }
096:
097: /**
098: * Get the id of this script
099: *
100: * @return id of this script
101: */
102: public long getId() {
103: return id;
104: }
105:
106: /**
107: * Get the event type of this script
108: *
109: * @return event type of this script
110: * @see FxScriptEvent
111: */
112: public FxScriptEvent getEvent() {
113: return event;
114: }
115:
116: /**
117: * Get the (unique) name of this script
118: *
119: * @return name of this script
120: */
121: public String getName() {
122: return name;
123: }
124:
125: /**
126: * Get the description of this script
127: *
128: * @return description of this script
129: */
130: public String getDescription() {
131: return description;
132: }
133:
134: /**
135: * Get the scripts code
136: *
137: * @return code
138: */
139: public String getCode() {
140: return code;
141: }
142:
143: /**
144: * Returns if the script is set to active.
145: *
146: * @return active
147: */
148: public boolean isActive() {
149: return active;
150: }
151:
152: }
|