|
Re: problem with adding element to ordered set [message #1758650 is a reply to message #1758636] |
Fri, 31 March 2017 07:46 |
|
Hi Taghreed,
"taskactivity" is a collection so "taskactivity.activity" returns a collection of collections, which you're then adding "activity" to. This is the expected behaviour; it appears that you're adding "activity" to the wrong collection.
Thanks a lot for the additional effort you've put into preparing your minimal example. A couple more things if I may:
- In Ecore there's a strong convention for class names to start with an upper-case letter and to be in singular (i.e. "class TaskActivity" instead of "class taskactivities")
- It's usually a good idea for variable names to be consistent with the values they hold. For example, in "var taskactivity = t.taskactivities;" your variable should be called "taskactivities" instead of "taskactivity" as you're expecting its value to be assigned to a collection. This can help make your code more readable and maintainable.
- I would recommend using "var tasks = Lqn!task.all;" in the first statement of your program. The current syntax works as "tasks" is then consumed in a for loop but "tasks.size()" for example wouldn't work as expected because the value of "tasks" in your version of the program is a model element type; not a collection of all its instances.
Cheers,
Dimitris
[Updated on: Fri, 31 March 2017 07:57] Report message to a moderator
|
|
|
|
Re: problem with adding element to ordered set [message #1758687 is a reply to message #1758681] |
Fri, 31 March 2017 16:16 |
|
Hi Taghreed,
You just need to add your "activity" under the "activity" containment reference of a "taskactivities" model element.
One more piece of advice that I forgot to mention in my previous message:
- It is also very useful for the names of attributes/references to reflect their multiplicities e.g. "val activity[1..*] activity;" should read "val Activity[1..*] activities;" instead
If you can try to refactor your metamodel according to these principles I will be able to help more effectively.
Cheers,
Dimitris
[Updated on: Sat, 01 April 2017 07:29] Report message to a moderator
|
|
|
|
|
|
|
Re: problem with adding element to ordered set [message #1758745 is a reply to message #1758730] |
Sat, 01 April 2017 15:16 |
taghreed altamimi Messages: 184 Registered: October 2014 |
Senior Member |
|
|
Hi Dimitris,
i added a loop to for taskactivities sequence then i used ta.activity.add(a) .Thanks for your help.
var tasks = Lqn!task.all;
for (t in tasks){
if (t.name="Artifact3"){
var ta=t.taskactivities.println();
if (not ta.isEmpty()){
var a :new Lqn!activity;
a.name="OpaqueAction999";
for (tac in t.taskactivities) {
tac.activity.add(a);}
"activity2.name ".print()+a.name.println();
}
}
}
[Updated on: Sat, 01 April 2017 15:18] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03636 seconds