Home » Modeling » Epsilon » adding new element F to Containmentreference(I am using EOL to change an emf model that an instance of emf metamodel)
adding new element F to Containmentreference [message #1755257] |
Wed, 01 March 2017 17:36 |
taghreed altamimi Messages: 184 Registered: October 2014 |
Senior Member |
|
|
Hi ,
I am using the following code to add new element type task to D2 which is a processor . task is the Containmentreference between the processor and task that means parent of task is processor D2.
I got error says that Property 'eRef' not found in object processor [name=D2, multiplicity=1, speedfactor=1.0, scheduling=default, replication=1, quantum=0.0, ]
[ var vprocessor=Lqn!processor;
for (p in vprocessor){
p.name=getName(SrightId);//this operation returns name of processor D2
"D2 ".print()+p.name.println();
var target=Lqn!task;
var t:new Lqn!task;
t.name=getName(valueIdS);\\return task its name is F
for (g in target){
var parentSource=g.closure(x | x.eContainer()) ;
"parent of task ".print()+parentSource.first().eClass.name.println();
var eRef=t.closure(x | x.eContainmentFeature);
"Containmentreference".print()+eRef.println();
var type=parentSource.eClass.println();
p.eRef.name.add(t);
}
} ][/code]
Can you please help me .
Metamodel and instance of metamodel are attached
[Updated on: Wed, 01 March 2017 17:39] Report message to a moderator
|
|
| | | |
Re: adding new element F to Containmentreference [message #1755358 is a reply to message #1755285] |
Thu, 02 March 2017 15:50 |
taghreed altamimi Messages: 184 Registered: October 2014 |
Senior Member |
|
|
Hi Dimitris,
I tried to test my metamodel with this code: var tasks = Lqn!task;
for (p in tasks ){
"parent".print()+ p.asSequence().closure(x | x.eContainer()).println();
var eRef :Sequence =p.closure(x | x.eContainmentFeature);
"eRef ".print()+ eRef.println;
Then i got this in the console:
parentSequence {processor [name=D1, multiplicity=1, speedfactor=1.0, scheduling=default, replication=1, quantum=0.0, ], lqnmodel [name=model To lqn, description=null, lqnSchemaVersion=1, lqnCoreSchemaVersion=1, xmldebug=false, ]}
eRef Sequence {EReference [name=task, ordered=true, unique=true, lowerBound=1, upperBound=-1, many=true, required=true, changeable=true, volatile=false, transient=false, defaultValueLiteral=null, defaultValue=null, unsettable=false, derived=false, containment=true, container=false, resolveProxies=true, ], EReference [name=eStructuralFeatures, ordered=true, unique=true, lowerBound=0, upperBound=-1, many=true, required=false, changeable=true, volatile=false, transient=false, defaultValueLiteral=null, defaultValue=null, unsettable=false, derived=false, containment=true, container=false, resolveProxies=false, ]}
parentSequence {processor [name=D2, multiplicity=1, speedfactor=1.0, scheduling=default, replication=1, quantum=0.0, ], lqnmodel [name=model To lqn, description=null, lqnSchemaVersion=1, lqnCoreSchemaVersion=1, xmldebug=false, ]}
eRef Sequence {EReference [name=task, ordered=true, unique=true, lowerBound=1, upperBound=-1, many=true, required=true, changeable=true, volatile=false, transient=false, defaultValueLiteral=null, defaultValue=null, unsettable=false, derived=false, containment=true, container=false, resolveProxies=true, ], EReference [name=eStructuralFeatures, ordered=true, unique=true, lowerBound=0, upperBound=-1, many=true, required=false, changeable=true, volatile=false, transient=false, defaultValueLiteral=null, defaultValue=null, unsettable=false, derived=false, containment=true, container=false, resolveProxies=false, ]}
for each processor (parent) there are tasks (children) and i tried to add new task to processor p=D2 by this code :
p.task.add(t); it did work but when i replaced task with a variable eRef it generated the error.
Cheers,
Taghreed
[Updated on: Thu, 02 March 2017 16:02] Report message to a moderator
|
|
| |
Re: adding new element F to Containmentreference [message #1755481 is a reply to message #1755425] |
Fri, 03 March 2017 16:24 |
taghreed altamimi Messages: 184 Registered: October 2014 |
Senior Member |
|
|
Hi Dimitris,
I am using Eclipse version 1.3.201602270002.
Steps to produce the proplem:
-Run queryEtl(1) run configuration
-open oldexampleLqn.model by its default editor
-You will see that task F was added to the root (Lqnmodel) not to its parent which is Processor D2.
I know that i need to use p.task.add(t) to add F to its parent (processor D2) but i need to use a variable that holds task instead of using p.task.add(t) like this . I identified task as belows:
var eRef=g.closure(x | x.eContainmentFeature); then adding task(F) to D2 by using this code p.eRef.add(t);
I wish that i explained the problem more clearly now.
Cheers,
Taghreed
[Updated on: Fri, 03 March 2017 16:29] Report message to a moderator
|
|
| |
Re: adding new element F to Containmentreference [message #1755489 is a reply to message #1755485] |
Fri, 03 March 2017 17:32 |
taghreed altamimi Messages: 184 Registered: October 2014 |
Senior Member |
|
|
but eRef is just a variable i mean eRef=task that is a reference in the Lqn metamodel :
class processor {
attr String name;
attr int multiplicity=1;
attr float speedfactor=1;
attr PSchedulerType scheduling;
attr int replication=1;
attr float quantum=0;
val task[+] #host task;
}
Did u mean that i canot use a variable that holds the name of the reference ??to do the trick u need to use it as it is?
Thanks,
Taghreed
[Updated on: Fri, 03 March 2017 17:36] Report message to a moderator
|
|
| |
Goto Forum:
Current Time: Wed Apr 24 22:46:31 GMT 2024
Powered by FUDForum. Page generated in 0.03502 seconds
|