| behavior.java |
1 package hudsonfog.voc.system;
2
3 import com.fogx.webdav.DavResource;
4 import com.fogx.webdav.DavClass;
5 import com.fogx.webdav.DavBean;
6 import com.fogx.webdav.DavProperty;
7 import static com.fogx.webdav.DavProperty.*;
8 import com.fogx.webdav.packages.DavBeanPackage;
9 import com.fogx.webdav.util.DavResourceSupport;
10 import com.fogx.webdav.util.UrlUtil;
11 import java.util.Date;
12 import java.util.Map;
13 import java.util.HashMap;
14 import java.util.List;
15 import java.util.Collections;
16 import java.util.Arrays;
17
18 import hudsonfog.voc.system.primitiveTypes.*;
19 import hudsonfog.voc.system.XMLSchema.*;
20
21 import hudsonfog.voc.system.fog.*;
22
23
24 public abstract class behavior {
25
26 /**
27 * Interfaces that exhibit some behavioral aspect must extend this interface.
28 * Used by new class creator UI to present a choice of possible behaviors (e.g via tabs)
29 */
30 public static interface ApplicationAspect {
31 }
32
33 /**
34 * Resources of class implementing this interface can be marked as template.
35 * New resources can be created from such template resource.
36 */
37 public static interface Templatable {
38 public Boolean isTemplate = null; //* allows to mark this Resource as a template
39 @_readOnly
40 @_where("isTemplate == true")
41 public Templatable basedOnTemplate = null; //* allows to choose a template for this resource at the time of its creation
42 }
43
44 /**
45 * Classes implementing this interface delegate to some other resource
46 */
47 @DavClass._avoidIndexing
48 @DavClass._avoidEditing
49 public static interface Delegator {
50 @_mustImplement
51 @_immutable
52 @_alwaysReturnToClient
53 public DavResource forResource = null; //* resource to which we delegate
54 @_readOnly
55 @_mustImplement
56 @_immutable
57 public DavClass forClass = null; //* class of the resource to which we delegate
58 @_readOnly
59 @_immutable
60 public String resourceDisplayName = null; //* display name of the resource to which we delegate
61 }
62
63 /**
64 * Classes implementing this interface delegate to some other resource
65 */
66 @DavClass._avoidIndexing
67 @DavClass._avoidEditing(false)
68 public static interface Delegator1 {
69 @_mustImplement
70 @_alwaysReturnToClient
71 @_immutable
72 public DavResource forResource = null; //* resource to which we delegate
73 @_mustImplement
74 @_immutable
75 public DavClass forClass = null; //* class of the resource to which we delegate
76 @_immutable
77 public String resourceDisplayName = null; //* display name of the resource to which we delegate
78 }
79
80 /**
81 * Classes implementing this interface are being delegated to. This solved problem for:
82 * Button-> FoodMenu
83 */
84 public static interface Delegatable {
85 }
86
87 /**
88 * Resources of Classes implementing this interface can not be modified after they are sealed.
89 */
90 public static interface Sealable {
91 @_readOnly
92 @_alwaysReturnToClient // Needed by UI painter to make decision about allowing to add container members.
93 @_avoidDisplaying
94 public Boolean sealed = null;
95 }
96
97 /**
98 * Same as Sealable but allows conditional (temporary) breaking of the seal.
99 * Business rules (in the script or in the handler) are responsible for allowing to break the seal.
100 * Seal can not be broken from client application (prevented by annotating seal property as readOnly).
101 * When seal is broken property sealed is set to false and sealWasBroken to true.
102 * When seal is repaired property sealed is set to true again.
103 * It is up to the business rules to allow or forbid further reopening of the seal.
104 * sealBroken property remains set to true to indicate that seal was broken at some point.
105 * When seal is broken - ModifcationHistory tracking is performed even if -avoidModificationTracking is false.
106 */
107 public static interface Resealable extends Sealable {
108 @_readOnly
109 @_avoidDisplaying
110 public Boolean sealWasBroken = writeJS("sealWasBroken ? sealWasBroken : getThisBeforeChange() && getThisBeforeChange().sealed && getThisChange() && !getThisChange().sealed ? true : sealWasBroken");
111 }
112
113 /*
114 * LineItem resources are like OrderItems, InvoiceItems, Task, TransactionDetail
115 * are always added as Items to the main resource such as Order, Invoice, Project, Transaction
116 */
117 public static interface LineItem {
118 @_mustImplement
119 public DavResource item = null; // for example, an item that is being ordered, e.g. TreatmentProcedure (Massage, Facial, etc.)
120 }
121
122 /**
123 * Used to submit information specific to the client's machine (local time, etc.)
124 */
125 public static interface BrowserState {
126 @_invisibleInput
127 @_clientScript("onSubmit: setTime(this)")
128 public dateTime clientTime = null; //* time on the machine from which request arrived
129 }
130
131 /*
132 * Allows to cancel some resources without deleting them
133 */
134 public static interface Cancellable {
135 @_allowEditInList
136 @_icon("icons/status_cancelled.gif")
137 @_avoidDisplayingOnCreate
138 @_colorCoding("'False' icons/status_not_cancelled.gif; 'True' icons/status_cancelled.gif")
139 public Boolean cancelled = null;
140 @_readOnly
141 @_avoidDisplaying
142 public Boolean inactive = null; // may not be cancelled, but not used - like WorkResource with no assignments
143 }
144
145 /*
146 * Allows to archive some resources without deleting them
147 */
148 public static interface Archived {
149 @_allowEditInList
150 @_icon("icons/status_archived.gif")
151 @_avoidDisplayingOnCreate
152 @_colorCoding("'False' icons/status_not_cancelled.gif; 'True' icons/status_archived.gif")
153 public Boolean archived = null;
154 }
155 }
156