Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to define an abstract behavior in the ".dmodel" file?(xtext behavior)
How to define an abstract behavior in the ".dmodel" file? [message #1036405] Mon, 08 April 2013 10:38 Go to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
I am following the "domain-model" tutorial.I create the ".dmodel" file in the run-time eclipse. In the .dmodel file, I would like to define a behavior function for a specific class. However, the behavior is somewhat abstract because I would prefer to instantialize it later. But, according to the schema of the "domain-model" example, the code are automatically generated when I save the ".dmodel" file. Therefore, I think it is not a good idea to modify the generated code. Then, how can I define an abstract behavior in the ".dmodel" file?
Re: How to define an abstract behavior in the ".dmodel" file? [message #1036518 is a reply to message #1036405] Mon, 08 April 2013 13:38 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Maybe I did not clearly explain my problem. In my case, I cannot define the behaviors because the classes are not instantiated yet. Only after the properties of the class have concrete values, the behavior can be defined. But once the code is automatically generated, I think it is not good to change it manually. Is there a good way to deal with this situation?
Re: How to define an abstract behavior in the ".dmodel" file? [message #1036521 is a reply to message #1036518] Mon, 08 April 2013 13:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi the intention is that you write the manual code with expressions
in the dmodel file.

You may have a look at the generation gap pattern too

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to define an abstract behavior in the ".dmodel" file? [message #1036544 is a reply to message #1036521] Mon, 08 April 2013 14:18 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you very much for your reply!
The difficulty for me is that I cannot write the manual code with expressions in the dmodel file for the behaviors. The reason is that when I create the dmodel file, I still cannot give values to the properties especially when the behaviors need values from other classes.

You mentioned, I can have a look at the "generation gap pattern", do you have some good documentation or some information about it?
Thank you again!

Re: How to define an abstract behavior in the ".dmodel" file? [message #1036557 is a reply to message #1036544] Mon, 08 April 2013 14:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi. No this is basically: don't use xbase and write the generator
yourself and let it generate a abstract class and generate once a
concrete class

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to define an abstract behavior in the ".dmodel" file? [message #1036561 is a reply to message #1036557] Mon, 08 April 2013 14:43 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Sorry, I cannot understand "don't use xbase and write the generator
yourself and let it generate a abstract class and generate once a
concrete class",Could you explain more? Sorry, I am only a very beginner for xbase and xtext. Thank you!
Re: How to define an abstract behavior in the ".dmodel" file? [message #1036586 is a reply to message #1036561] Mon, 08 April 2013 15:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

if you use xbase you should be able to keep 100%logik in the .dmodel file.
if you dont use xbase you can do everything yourself.

(look at 15m extended tutorial)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 08 April 2013 15:19]

Report message to a moderator

Re: How to define an abstract behavior in the ".dmodel" file? [message #1036733 is a reply to message #1036586] Mon, 08 April 2013 18:42 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you!
Is it possible to describe an abstract behavior like the activity diagram in UML? I would like to use the automatically generated code. I do not give up the xText and xBase.
Re: How to define an abstract behavior in the ".dmodel" file? [message #1036742 is a reply to message #1036733] Mon, 08 April 2013 18:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

can you please come up with a real example. it is hard to give tipps on such general and abstract requirements


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to define an abstract behavior in the ".dmodel" file? [message #1037089 is a reply to message #1036742] Tue, 09 April 2013 06:54 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you very much for your patience!
For example, I have the following model in the .dmodel file. In the function of "getCurrentHobby", I do not want to predefine the values of the "Music", "Dancing", "Cooking" in the dmodel. I would like to instantiate all these values when I instantiate a concrete model. However, the relation in-between is just dependent on the currrent value of the "hobby".


entity Father {
id: String
name: String
wife: Mother
sons: List <Son>
daughters: List <Daughter>
hobbyList: List<String>


op getCurrentHobby() : String {
var currentHobbyStr = "Not Processed";

if (wife.hobbyList.contains("Music")&&
(sons.iterator.head.hobbyList.contains("Dancing"))&&
(daughters.iterator.head.hobbyList.contains("Cooking"))
)
{
//firstName = "eer";
currentHobbyStr ="Music";
}

return currentHobbyStr;
}
}

entity Mother
{
id: String
name: String
husband: Father
hobbyList: List<String>
}

entity Son
{
id: String
name: String
hobbyList: List<String>
}

entity Daughter
{
id: String
name: String
hobbyList: List<String>
}
Re: How to define an abstract behavior in the &amp;amp;quot;.dmodel&amp;amp;quot; file? [message #1037100 is a reply to message #1037089] Tue, 09 April 2013 07:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Still don't get the problem - you don't want the op at all in the
dmodel?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to define an abstract behavior in the &amp;amp;quot;.dmodel&amp;amp;quot; file? [message #1037104 is a reply to message #1037100] Tue, 09 April 2013 07:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
P.S: and if the stuff is dynamic why dont you simply define callback ops, params etc?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to define an abstract behavior in the &amp;amp;quot;.dmodel&amp;amp;quot; file? [message #1037108 is a reply to message #1037104] Tue, 09 April 2013 07:18 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you for your quick reply!
I need the definition of the behavior to show that there is a dependency in-between, But I do not want to predefine the values of the "Music", "Dancing", "Cooking" in the dmodel. For the "callback ops, params etc", could you give me more information about them? I have no idea about that.
Re: How to define an abstract behavior in the &amp;amp;quot;.dmodel&amp;amp;quot; file? [message #1037115 is a reply to message #1037108] Tue, 09 April 2013 07:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

???????

op getCurrentHobby(String hobby1, String hobby2, String hobby3 ) : String {
}





??????


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to define an abstract behavior in the &amp;amp;quot;.dmodel&amp;amp;quot; file? [message #1037120 is a reply to message #1037115] Tue, 09 April 2013 07:31 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you!
Sorry, maybe I have made some mistakes. If I have questions, I will ask again.

Christian Dietrich wrote on Tue, 09 April 2013 03:28
Hi,

???????

op getCurrentHobby(String hobby1, String hobby2, String hobby3 ) : String {
}





??????

Re: How to define an abstract behavior in the &amp;amp;quot;.dmodel&amp;amp;quot; file? [message #1037292 is a reply to message #1037120] Tue, 09 April 2013 11:39 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
For example, I have a list of requirements ("entity SystemRequirementItem ") of a system, which are defined as "entity SystemRequirements". I would suppose that the level of "entity SystemRequirements" is higher than the level of "entity SystemRequirementItem ". In order to define the workflow (activities) of the whole system, I would like to define behaviors in the "entity SystemRequirements". But I cannot, because I do not have the instances of the requirements yet. Only after I have all the specific requirements, I can define the behaviors of the whole system, which I think should be defined in the "entity SystemRequirements" right now. Could you have some idea?

entity SystemRequirements{
requirementLists: List <SystemRequirementItem>

//here, I need to define the activity diagram for the whole subsystem
op systemWorkflow(): void {
//
//For example, here, I want to define the activity diagram, but I cannot at the moment, because I still do not have the instances of the requirements. //
}
}

entity SystemRequirementItem //system requirement level
{
id: String
systemRequirementStatement: String
sysReqStateVariable: List<StateVariable>

}
Re: How to define an abstract behavior in the &amp;amp;quot;.dmodel&amp;amp;quot; file? [message #1037307 is a reply to message #1037292] Tue, 09 April 2013 12:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Sorry i have currently no idea to diggg that much,
but as said before: have a look on generating code without xbase


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to define an abstract behavior in the &amp;amp;quot;.dmodel&amp;amp;quot; file? [message #1037310 is a reply to message #1037307] Tue, 09 April 2013 12:03 Go to previous message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you for your support!
what kind of "generating code without xbase" might be possible to resolve this problem?

Christian Dietrich wrote on Tue, 09 April 2013 08:00
Sorry i have currently no idea to diggg that much,
but as said before: have a look on generating code without xbase

Previous Topic:Xtext grammar repository?
Next Topic:The code for the static initializer is exceeding the 65535 bytes limit
Goto Forum:
  


Current Time: Thu Mar 28 16:41:47 GMT 2024

Powered by FUDForum. Page generated in 0.02653 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top