My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
* Creates the default {@model Event}s, {@model Operation}s and {@model Predicate}s of
* {@model VisibleThing}s.
*/
package org.openiaml.model.drools.rules.visible

#list any import classes here.
import org.openiaml.model.drools.*;

import org.openiaml.model.inference.*;
import org.openiaml.model.datatypes.*;

import org.openiaml.model.model.*;
import org.openiaml.model.model.impl.*;
import org.openiaml.model.model.wires.*;
import org.openiaml.model.model.visual.*;
import org.openiaml.model.model.operations.*;
import org.openiaml.model.model.scopes.*;
import org.openiaml.model.model.components.*;
import org.openiaml.model.model.users.*;

#declare any global variables here
global OverridableCreateElementsHelper handler;
global DroolsInsertionQueue queue;
global DroolsHelperFunctions functions;

/**
* @inference VisibleThing,Event
* {@model VisibleThing}s have an {@model Event} named {@model VisibleThing#onInput}.
*/
rule "VisibleThings have an event onInput"
when
field : VisibleThing ( )
not ( event : Event ( field.onInput == event ))

eval ( handler.veto( field ))

then
Event event = handler.generatedEventOnInput(field, field);
handler.setName(event, "onInput");
queue.add(event, drools);

end

/**
* We only create currentInput for things that can actually use it, to
* simplify the completed model; i.e. only text fields.
*
* @inference InputTextField,Value
* {@model InputTextField}s have an {@model Value} named {@model InputTextField#currentInput}.
*/
rule "InputTextFields have a Value currentInput"
when
field : InputTextField ( )
type : EXSDDataType( definition != null,
definition.URI == "http://openiaml.org/model/datatypes#iamlString" )
not ( property : Value ( field.currentInput == property ))

eval ( handler.veto( field ))

then
Value property = handler.generatedValueCurrentInput(field, field);
handler.setName(property, "currentInput");
handler.setType(property, type);
queue.add(property, drools);

end

/**
* @inference VisibleThing,Event
* {@model VisibleThing}s have an {@model Event} named {@model VisibleThing#onClick}.
*/
rule "VisibleThings have an event onClick"
when
f : VisibleThing( )
not (event : Event( f.onClick == event ))

eval ( handler.veto( f ))

then
Event event = handler.generatedEventOnClick(f, f);
queue.add(event, drools);

end

/**
* @inference VisibleThing,BuiltinProperty
* {@model VisibleThing}s have an {@model BuiltinProperty} named {@model VisibleThing#empty}.
*/
rule "VisibleThings have a BuiltinProperty 'empty'"
when
f : VisibleThing( )

type : EXSDDataType( definition != null,
definition.name == "boolean" )

not (condition : Function( f.empty == condition ))

eval ( handler.veto( f ))

then
BuiltinProperty condition = handler.generatedBuiltinProperty(f, f,
ModelPackage.eINSTANCE.getVisibleThing_Empty());
handler.setName(condition, "empty");
handler.setType(condition, type);
queue.add(condition, drools);

end

/**
* @inference VisibleThing,BuiltinProperty
* {@model VisibleThing}s have an {@model BuiltinProperty} named {@model VisibleThing#notEmpty}.
*/
rule "VisibleThings have a BuiltinProperty 'not empty'"
when
f : VisibleThing( )

type : EXSDDataType( definition != null,
definition.name == "boolean" )

not (condition : Function( f.notEmpty == condition ))

eval ( handler.veto( f ))

then
BuiltinProperty condition = handler.generatedBuiltinProperty(f, f,
ModelPackage.eINSTANCE.getVisibleThing_NotEmpty());
handler.setName(condition, "not empty");
handler.setType(condition, type);
queue.add(condition, drools);

end

/**
* @inference VisibleThing,BuiltinOperation
* A {@model VisibleThing} has a {@model BuiltinOperation} named {@model BuiltinOperation#hide}.
*/
rule "Create 'hide' BuiltinOperation for VisibleThing"
when
tf : VisibleThing( )
not ( op : Operation ( name == "hide", eContainer == tf ))

eval ( handler.veto( tf ))

then
BuiltinOperation warning = handler.generatedBuiltinOperation(tf, tf);
handler.setName(warning, "hide");
queue.add(warning, drools);

end

/**
* @inference VisibleThing,BuiltinOperation
* A {@model VisibleThing} has a {@model BuiltinOperation} named {@model BuiltinOperation#show}.
*/
rule "Create 'show' BuiltinOperation for VisibleThing"
when
tf : VisibleThing( )
not ( op : Operation ( name == "show", eContainer == tf ))

eval ( handler.veto( tf ))

then
BuiltinOperation warning = handler.generatedBuiltinOperation(tf, tf);
handler.setName(warning, "show");
queue.add(warning, drools);

end

Change log

r3158 by soundasleep on Apr 2, 2012   Diff
fixing documentation typo
Go to: 
Project members, sign in to write a code review

Older revisions

r3149 by soundasleep on Oct 13, 2011   Diff
improving model completion rule
documentation for Event,
BuiltinOperation, BuiltinProperty
Email.onFailure and Email.onSent were
not being generated automatically
r3147 by soundasleep on Oct 6, 2011   Diff
cleaning up Drools rule package
documentation
r3087 by soundasleep on Sep 15, 2011   Diff
improving the grammar and structure of
the model completion rules
documentation
All revisions of this file

File info

Size: 4796 bytes, 169 lines
Powered by Google Project Hosting