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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/**
* Completes the functionality of {@model DetailWire}s.
*/
package org.openiaml.model.drools.rules.detail_wires

#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.*;
import org.openiaml.model.model.domain.*;

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

/**
* @inference DetailWire
* When a {@model DetailWire} is connected from a {@model Frame} that contains a
* {@model DomainIterator} to a <em>target</em> {@model Frame},
* a {@model QueryParameter} will be created in the <em>target</em> {@model Frame} to provide the primary key value.
*/
rule "Create QueryParameter for target container of DetailWire"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator( )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

source : VisibleThing ( eContainer == container )
target : Frame ( )
instanceSet : SetWire ( from == instance, to == source )

detail : DetailWire ( from == source, to == target )

pk : DomainAttribute ( eContainer == schema, primaryKey == true )

not ( queryPk : QueryParameter ( eContainer == target, name == pk.name ) )

eval ( handler.veto( detail ))

then
QueryParameter qp = handler.generatedQueryParameter(detail, target);
handler.setName(qp, pk.getName());
queue.add(qp, drools);

end

/**
* @inference DetailWire,Parameter
* When a {@model DetailWire} is connected from a {@model Frame} that contains a
* {@model DomainIterator} to a <em>target</em> {@model Frame},
* a new <em>selected</em> {@model DomainIterator} will be used to select content based on primary key.
*/
rule "Create a relevant DomainIterator, with SelectWire, in the destination for the DetailWire"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator( eContainer == container )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

pk : DomainAttribute ( eContainer == schema, primaryKey == true )

source : VisibleThing ( eContainer == container )
target : Frame ( )
instanceSet : SetWire ( from == instance, to == source )

detail : DetailWire ( from == source, to == target )

queryPk : QueryParameter ( eContainer == target, name == pk.name )

not ( DomainIterator ( eContainer == target,
name != null && eval( name.equals("Current " + schema.getName() + " instance") ) ))

eval ( handler.veto( detail ))

then
DomainIterator i2 = handler.generatedDomainIterator(detail, target);
handler.setName(i2, "Current " + schema.getName() + " instance");
// set the query
handler.setLimit(i2, 1);
handler.setQuery(i2, functions.safeNameString(pk.getName()) + " = :pk");
queue.add(i2, drools);

// connect QueryParameter
Parameter param = handler.generatedParameter(detail, target, queryPk, i2);
handler.setName(param, "pk");
queue.add(param, drools);

end

/**
* @inference DetailWire
* If a {@model VisibleThing} to browse the <em>selected</em> {@model DomainIterator} from a
* {@model DetailWire} does not exist in the <em>target</em> {@model Frame},
* a <em>view instance</em> {@model InputForm} will be created.
*/
rule "Create a View Instance Form for target of DetailWire"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator( eContainer == container )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

source : VisibleThing ( eContainer == container )
target : Frame ( )
instanceSet : SetWire ( from == instance, to == source )

detail : DetailWire ( from == source, to == target )

i2 : DomainIterator ( eContainer == target,
name != null && eval( name.equals("Current " + schema.getName() + " instance") ) )

not ( VisibleThing ( eContainer == target, eval( ("View " + schema.getName()).equals(name) ) ) )

eval ( handler.veto( detail ))

then
InputForm form = handler.generatedInputForm(detail, target);
handler.setName(form, "View " + schema.getName());
queue.add(form, drools);

end

/**
* @inference DetailWire
* A <em>view instance</em> {@model InputForm} generated by a {@model DetailWire}
* will be connected with a {@model SetWire} from the <em>selected</em> {@model DomainIterator}.
*/
rule "Connect View Instance Form with a SetWire to the DomainIterator"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator( eContainer == container )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

source : VisibleThing ( eContainer == container )
target : Frame ( )

detail : DetailWire ( from == source, to == target )

i2 : DomainIterator ( eContainer == target,
name != null && eval( name.equals("Current " + schema.getName() + " instance") ) )

form : VisibleThing ( eContainer == target, eval( ("View " + schema.getName()).equals(name) ) )

not ( set : SetWire ( from == i2, to == form ) )

eval ( handler.veto( detail ))

then
SetWire set = handler.generatedSetWire(detail, target, i2, form);
handler.setName(set, "set");
queue.add(set, drools);

end

/**
* @inference DetailWire
* A <em>link</em> {@model Button} will be created in the container of the source {@model DomainIterator} for a {@model DetailWire},
* in order to browse to the <em>target</em> {@model Frame}.
*/
rule "Create a Link Button for the source of a DetailWire"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator( eContainer == container )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

source : VisibleThing ( eContainer == container )
target : Frame ( )

detail : DetailWire ( from == source, to == target )

not ( button : VisibleThing ( eContainer == source, name == "link" ))

eval ( handler.veto( detail ))

then
Button link = handler.generatedButton(detail, source);
handler.setName(link, "link");
queue.add(link, drools);

end

/**
* @inference DetailWire
* The <em>link</em> {@model Button} generated for a {@model DetailWire} will be connected with an
* {@model ECARule} to navigate to the <em>target</em> {@model Frame} when {@model Button#onClick clicked}.
*/
rule "Create a Link Button for the source of a DetailWire: Connect ECARule"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator( eContainer == container )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

source : VisibleThing ( eContainer == container )
target : Frame ( )

detail : DetailWire ( from == source, to == target )

button : VisibleThing ( eContainer == source, name == "link" )
onClick : Event ( button.onClick == onClick )

not ( ECARule ( trigger == onClick, target == target ))

eval ( handler.veto( detail ))

then
ECARule nav = handler.generatedECARule(detail, source, onClick, target);
handler.setName(nav, "View detail");
queue.add(nav, drools);

end

/**
* @inference DetailWire,Parameter
* The {@model ECARule navigation rule} from the <em>link</em> {@model Button} generated for a {@model DetailWire},
* not contained by an {@model IteratorList},
* will be supplied the {@model DomainAttributeInstance current value} within the source {@model DomainInstance},
* representing the {@model DomainAttribute#primaryKey} of the source {@model DomainType}.
*/
rule "Create a Link Button for the source of a DetailWire (not IteratorList): Add Parameter from AttributeInstance"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator ( eContainer == container )
inst2 : DomainInstance ( instance.currentInstance == inst2 )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

source : VisibleThing ( eContainer == container )
# ignoring IteratorLists
not ( IteratorList ( this == source ))
target : Frame ( )

detail : DetailWire ( from == source, to == target )

button : VisibleThing ( eContainer == source, name == "link" )
onClick : Event ( button.onClick == onClick )
nav : ECARule ( trigger == onClick, target == target )

pkAttribute : DomainAttribute ( eContainer == schema, primaryKey == true )
pkInstance : DomainAttributeInstance ( eContainer == inst2 )
ExtendsEdge ( from == pkInstance, to == pkAttribute )

pk : Value ( pkInstance.fieldValue == pk )

not ( Parameter ( parameterValue == pk, parameterTerm == nav ))

eval ( handler.veto( detail ))

then
Parameter param = handler.generatedParameter(detail, source, pk, nav);
handler.setName(param, pkAttribute.getName());
queue.add(param, drools);

end

/**
* @inference DetailWire,Parameter
* The {@model ECARule navigation rule} from the <em>link</em> {@model Button} generated for a {@model DetailWire},
* as contained by an {@model IteratorList},
* will be supplied the {@model DomainAttributeInstance current value} within the source {@model DomainInstance},
* representing the {@model DomainAttribute#primaryKey} of the source {@model DomainType}.
*/
rule "Create a Link Button for the source of a DetailWire (IteratorList): Add Parameter from AttributeInstance"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator ( eContainer == container )
inst2 : DomainInstance ( instance.currentInstance == inst2 )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

source : IteratorList ( eContainer == container )
target : Frame ( )

detail : DetailWire ( from == source, to == target )

button : VisibleThing ( eContainer == source, name == "link" )
onClick : Event ( button.onClick == onClick )
nav : ECARule ( trigger == onClick, target == target )

pkAttribute : DomainAttribute ( eContainer == schema, primaryKey == true )
pkInstance : DomainAttributeInstance ( eContainer == inst2 )
ExtendsEdge ( from == pkInstance, to == pkAttribute )

# attribute instance is connected to the Container by a SetWire or SyncWire to a Hidden
hidden : Label ( eContainer == source, visible == false )
set : SetWire ( from == pkInstance, to == hidden )

pk : Value ( hidden.fieldValue == pk )

not ( Parameter ( parameterValue == pk, parameterTerm == nav ))

eval ( handler.veto( detail ))

then
Parameter param = handler.generatedParameter(detail, source, pk, nav);
handler.setName(param, pkAttribute.getName());
queue.add(param, drools);

end

/**
* @inference DetailWire,DomainIterator
* The <em>selected</em> {@model DomainIterator} used to select one instance of a
* {@model DetailWire} source is given the same {@model DomainSource} as the
* source {@model DomainIterator}.
*/
rule "The view one DomainIterator is connected to the same DomainSource as the view many DomainIterator"
when
container : Frame( )

schema : DomainType ( )
domainSource : DomainSource ( )
instance : DomainIterator( eContainer == container )

selectEdge : SelectEdge ( from == instance, to == domainSource )
schemaEdge : SchemaEdge ( from == domainSource, to == schema )

source : VisibleThing ( eContainer == container )
target : Frame ( )
instanceSet : SetWire ( from == instance, to == source )

detail : DetailWire ( from == source, to == target )

iterator2 : DomainIterator ( eContainer == target,
name != null && eval( name.equals("Current " + schema.getName() + " instance") ) )

not ( SelectEdge ( from == iterator2 ))

eval ( handler.veto( detail ))

then
SelectEdge select = handler.generatedSelectEdge(detail, iterator2, iterator2, domainSource);
queue.add(select, drools);

end

Change log

r3161 by soundasleep on Apr 2, 2012   Diff
removing instances where model element
links are in italics, to fix whitespace
errors in latex output
Go to: 
Project members, sign in to write a code review

Older revisions

r3153 by soundasleep on Oct 13, 2011   Diff
more minor changes to rule
documentation
r3087 by soundasleep on Sep 15, 2011   Diff
improving the grammar and structure of
the model completion rules
documentation
r3068 by soundasleep on Aug 8, 2011   Diff
improving modeldoc documentation
across inference rules, codegen
templates, ecore, and additional
documentation includes
All revisions of this file

File info

Size: 13224 bytes, 380 lines
Powered by Google Project Hosting