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.exceptions.FxNotFoundException;
036:
037: /**
038: * All kinds of scripts used in flexive,
039: * depending on the type scripts are initialized with different bindings
040: *
041: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
042: */
043: public enum FxScriptEvent {
044:
045: /**
046: * Manually execute script, not dependent on any 'trigger point' - will be executed on demand
047: */
048: Manual(1, FxScriptScope.All),
049:
050: /**
051: * Fired before an existing content is saved
052: */
053: BeforeContentSave(2, FxScriptScope.Type, "FxContent content"),
054:
055: /**
056: * Fired after an existing content is saved
057: */
058: AfterContentSave(3, FxScriptScope.Type, "FxPK pk"),
059:
060: /**
061: * Fired before a new content is created
062: */
063: BeforeContentCreate(4, FxScriptScope.Type, "FxContent content"),
064:
065: /**
066: * Fired after a new content is created
067: */
068: AfterContentCreate(5, FxScriptScope.Type, "FxPK pk"),
069:
070: /**
071: * Fired before a content is removed
072: */
073: BeforeContentRemove(6, FxScriptScope.Type, "FxPK pk",
074: "FxContentSecurityInfo securityInfo"),
075:
076: /**
077: * Fired after a content is removed
078: */
079: AfterContentRemove(7, FxScriptScope.Type, "FxPK pk"),
080:
081: /**
082: * Fired after a content is loaded
083: */
084: AfterContentLoad(8, FxScriptScope.Type, "FxContent content"),
085:
086: /**
087: * Fired after a new content instance is initialized with default values
088: */
089: AfterContentInitialize(9, FxScriptScope.Type, "FxContent content"),
090:
091: /**
092: * Fired for ContentEngine.prepareSave() for new contents
093: */
094: PrepareContentCreate(10, FxScriptScope.Type, "FxContent content"),
095:
096: /**
097: * Fired for ContentEngine.prepareSave() for existing contents
098: */
099: PrepareContentSave(11, FxScriptScope.Type, "FxContent content"),
100:
101: /**
102: * Fired before a FxData update of an existing existance
103: */
104: BeforeDataChangeUpdate(12, FxScriptScope.Assignment,
105: "FxContent content", "FxDeltaChange change"),
106:
107: /**
108: * Fired after a FxData update of an existing existance
109: */
110: AfterDataChangeUpdate(13, FxScriptScope.Assignment,
111: "FxContent content", "FxDeltaChange change"),
112:
113: /**
114: * Fired before a FxData is removed from an existing existance, instance will <b>not</b> be removed!
115: */
116: BeforeDataChangeDelete(14, FxScriptScope.Assignment,
117: "FxContent content", "FxDeltaChange change"),
118:
119: /**
120: * Fired after a FxData is removed from an existing existance, instance will <b>not</b> be removed!
121: */
122: AfterDataChangeDelete(15, FxScriptScope.Assignment,
123: "FxContent content", "FxDeltaChange change"),
124:
125: /**
126: * Fired before a FxData is updated in an existing existance
127: */
128: BeforeDataChangeAdd(16, FxScriptScope.Assignment,
129: "FxContent content", "FxDeltaChange change"),
130:
131: /**
132: * Fired after a FxData is updated in an existing existance
133: */
134: AfterDataChangeAdd(17, FxScriptScope.Assignment,
135: "FxContent content", "FxDeltaChange change"),
136:
137: /**
138: * Fired before a new instance is created that will contain the assignment
139: */
140: BeforeAssignmentDataCreate(18, FxScriptScope.Assignment,
141: "FxContent content", "FxAssignment assignment"),
142:
143: /**
144: * Fired after a new instance is created that will contain the assignment
145: */
146: AfterAssignmentDataCreate(19, FxScriptScope.Assignment, "FxPK pk",
147: "FxAssignment assignment"),
148:
149: /**
150: * Fired before an existing instance is saved that contains the assignment
151: */
152: BeforeAssignmentDataSave(20, FxScriptScope.Assignment,
153: "FxContent content", "FxAssignment assignment"),
154:
155: /**
156: * Fired after an existing instance is saved that contains the assignment
157: */
158: AfterAssignmentDataSave(21, FxScriptScope.Assignment, "FxPK pk",
159: "FxAssignment assignment"),
160:
161: /**
162: * Fired before an instance is deleted <b>could</b> contain the assignment,
163: * no guarantee can be made that the instance actually contains FxData for the assignment!
164: */
165: BeforeAssignmentDataDelete(22, FxScriptScope.Assignment, "FxPK pk",
166: "FxAssignment assignment"),
167:
168: /**
169: * Fired after an instance is deleted <b>could</b> contain the assignment,
170: * no guarantee can be made that the instance actually contains FxData for the assignment!
171: */
172: AfterAssignmentDataDelete(23, FxScriptScope.Assignment, "FxPK pk",
173: "FxAssignment assignment"),
174:
175: BinaryPreviewProcess(24, FxScriptScope.BinaryProcessing,
176: "boolean processed", "boolean useDefaultPreview",
177: "int defaultId", "String mimeType", "String metaData",
178: "File binaryFile", "File previewFile1",
179: "File previewFile2", "File previewFile3",
180: "int[] dimensionPreview1", "int[] dimensionPreview2",
181: "int[] dimensionPreview3"),
182:
183: /**
184: * Fired after a new user account has been created. The account ID and the
185: * contact data PK are bound as "accountId" and "pk" .
186: */
187: AfterAccountCreate(25, FxScriptScope.Accounts, "long accountId",
188: "FxPK pk"),
189:
190: AfterTreeNodeAdded(26, FxScriptScope.Tree), AfterTreeNodeRemoved(
191: 27, FxScriptScope.Tree), BeforeTreeNodeRemoved(28,
192: FxScriptScope.Tree), AfterTreeNodeActivated(29,
193: FxScriptScope.Tree), BeforeTreeNodeActivated(30,
194: FxScriptScope.Tree), AfterTreeNodeFolderReplacement(31,
195: FxScriptScope.Tree), BeforeTreeNodeFolderReplacement(32,
196: FxScriptScope.Tree);
197:
198: private long id;
199: private FxScriptScope scope;
200: private String[] bindingInfo;
201:
202: /**
203: * Constructore
204: *
205: * @param id type id
206: * @param scope script scope
207: * @param bindingInfo provided variable bindings
208: */
209: FxScriptEvent(int id, FxScriptScope scope, String... bindingInfo) {
210: this .id = id;
211: this .scope = scope;
212: this .bindingInfo = bindingInfo;
213: }
214:
215: /**
216: * Get the scope of this script, ie if it is independent, for types or assignments
217: *
218: * @return scope
219: */
220: public FxScriptScope getScope() {
221: return scope;
222: }
223:
224: /**
225: * Get a list of all bindings available to the script.
226: * Binding descriptions are human readable in the form "datatype variablename"
227: *
228: * @return list of all bindings available to the script
229: */
230: public String[] getBindingInfo() {
231: return bindingInfo.clone();
232: }
233:
234: /**
235: * Getter for the internal id
236: *
237: * @return internal id
238: */
239: public long getId() {
240: return id;
241: }
242:
243: public String getName() {
244: if (id >= 1) {
245: try {
246: return getById(id).name();
247: } catch (FxNotFoundException e) {
248: return "Not_Defined";
249: }
250: }
251: return "";
252: }
253:
254: /**
255: * Get a FxScriptEvent by its id
256: *
257: * @param id requested id
258: * @return FxScriptEvent
259: * @throws FxNotFoundException on errors
260: */
261: public static FxScriptEvent getById(long id)
262: throws FxNotFoundException {
263: for (FxScriptEvent event : FxScriptEvent.values())
264: if (event.id == id)
265: return event;
266: throw new FxNotFoundException("ex.scripting.type.notFound", id);
267: }
268: }
|