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
/**
* Creates the {@model DomainInstance}s within {@model DomainIterator}s and refreshes
* {@model DomainAttributeInstance} mappings with respect to the connecting {@model DomainType}
* of the iterator.
*/
# Update the attributes in "new instance" objects when they
# are connected to DomainTypes.
package org.openiaml.model.drools.rules.new_instance

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

import org.openiaml.model.*;
import org.openiaml.model.model.*; // for ModelPackage
import org.openiaml.model.model.domain.*;
import org.openiaml.model.model.wires.*;
import org.openiaml.model.model.operations.*;
import org.eclipse.emf.ecore.*;

import org.openiaml.model.inference.*; // for handler

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

/**
* @inference DomainIterator,DomainInstance
* All {@model DomainIterator}s will be populated with a single
* instance of a {@model DomainInstance}, representing the
* {@model DomainIterator#currentInstance} of that iterator.
*/
rule "Create Current Instance for all Domain Iterators"
when
iterator : DomainIterator ( )

not ( DomainInstance ( eContainer == iterator ))

eval ( handler.veto( iterator ))

then
DomainInstance inst = handler.generatedDomainInstance(iterator, iterator);
handler.setName(inst, "Current instance");
queue.add(inst, drools);

end

/**
* @inference DomainInstance,DomainAttribute,DomainAttributeInstance
* An {@model DomainInstance} will be populated with {@model DomainAttributeInstance}s
* for every {@model DomainAttribute} in the defining
* {@model DomainType} of the instance's containing {@model DomainIterator}.
*/
rule "Refresh Iterator Object mappings"
when
schema : DomainType ( )
source : DomainSource ( )
iterator : DomainIterator ( )
instance : DomainInstance ( iterator.currentInstance == instance )

schemaEdge : SchemaEdge ( from == source, to == schema )
selectEdge : SelectEdge ( from == iterator, to == source )
attribute : DomainAttribute ( eContainer == schema )

not ( DomainAttributeInstance( eContainer == instance, name == attribute.name ))

eval ( handler.veto( instance ))

then
# create a new one
DomainAttributeInstance attr = handler.generatedDomainAttributeInstance(instance, instance);
handler.setName(attr, attribute.getName());
# set type
handler.setType(attr, (EDataType) attribute.getEType());
queue.add(attr, drools);

# mark it as an extension
ExtendsEdge ex = handler.generatedExtendsEdge(instance, attr, attr, attribute);
queue.add(ex, drools);

end

/**
* @inference DomainAttributeInstance,ExtendsEdge
* A {@model DomainAttributeInstance} created within a {@model DomainInstance}
* referencing a particular {@model DomainAttribute} will be marked
* as an extension of that attribute through an {@model ExtendsEdge}.
*/
rule "Mark AttributeInstances as extensions of the identically-named Attributes (NewInstanceWire)"
when
schema : DomainType ( )
source : DomainSource ( )
iterator : DomainIterator ( )
instance : DomainInstance ( iterator.currentInstance == instance )

schemaEdge : SchemaEdge ( from == source, to == schema )
selectEdge : SelectEdge ( from == iterator, to == source )

attribute : DomainAttribute ( eContainer == schema )
attrinst : DomainAttributeInstance( eContainer == instance, name == attribute.name )

not ( ExtendsEdge ( from == attrinst, to == attribute ) )

eval ( handler.veto( attrinst ))

then
# mark it as an extension
ExtendsEdge w = handler.generatedExtendsEdge(attrinst, attrinst, attrinst, attribute);
queue.add(w, drools);

end

/**
* @inference DomainIterator,BuiltinOperation
* A {@model DomainIterator} contains an {@model Operation}
* named {@model DomainIterator#save}.
*/
rule "Create 'save' operation for DomainIterators"
when
instance : DomainIterator ( )

not ( Operation( eContainer == instance, name == "save" ))

eval ( handler.veto( instance ))

then
# create a new one
BuiltinOperation op = handler.generatedBuiltinOperation(instance, instance);
handler.setName(op, "save");
queue.add(op, drools);

end

Change log

r3147 by soundasleep on Oct 6, 2011   Diff
cleaning up Drools rule package
documentation
Go to: 
Project members, sign in to write a code review

Older revisions

r3090 by soundasleep on Sep 15, 2011   Diff
fixing error in modeldoc LaTeX config
minor documentation fixes, removing
fixed TODOs
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: 4402 bytes, 132 lines
Powered by Google Project Hosting