Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Generic DSL based on POJO(Generic DSL based on POJO)
Generic DSL based on POJO [message #1172970] Wed, 06 November 2013 07:40 Go to next message
Malinga Purnasiri is currently offline Malinga PurnasiriFriend
Messages: 6
Registered: November 2013
Junior Member
Hi All,

I have a requrement like this to be developed with XText

I have set of POJO classes like, (couldnt draw a diagram for this, hope this is clear enf)

<< A_POJO >> ------- Level 1

<< B_POJO extends A_POJO >> ------- Level 2
<< C_POJO extends A_POJO >> ------- Level 2

<< D_POJO extends C_POJO >> ------- Level 3
<< E_POJO extends C_POJO >> ------- Level 3
<< F_POJO extends C_POJO >> ------- Level 3

And then I will have this POJO classes in my class path of the eclipse where i developing this DSL. And my chalage is the developa grammer file looks like

<<B_POJO or child class of it>> name=ID {
[
<<C_POJO or child class of it>> name=ID {Attribute of <<C_POJO>>}
<<C_POJO or child class of it>> name=ID {Attribute of <<C_POJO>>}
<<C_POJO or child class of it>> name=ID {Attribute of <<C_POJO>>}
<<C_POJO or child class of it>> name=ID {Attribute of <<C_POJO>>}
<<C_POJO or child class of it>> name=ID {Attribute of <<C_POJO>>}
]
}

Sample

User xx {
[
vField userName {length=25}
vField firstName {length:50}
vField otherNames {length:100}
vField password {length:25}
vField email {length:100}
]
}

Any idea is really appriciated
Re: Generic DSL based on POJO [message #1173754 is a reply to message #1172970] Wed, 06 November 2013 18:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

so you want to have a wizard that derives a grammar from a bunch of classes?
or do you want to have a generic dsl that can be configured by a bunch of classes (at compile time)?
or do you want to have a generic dsl that is configured by the bunch of classes (at runtime) on the classpath of the model project?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Generic DSL based on POJO [message #1174428 is a reply to message #1173754] Thu, 07 November 2013 05:04 Go to previous messageGo to next message
Malinga Purnasiri is currently offline Malinga PurnasiriFriend
Messages: 6
Registered: November 2013
Junior Member
Hi Dietrich,

Thanks you very much for your very quick reply on this,

What is want is "want to have a generic dsl that is configured by the bunch of classes (at runtime) on the classpath of the model project"

So when some one gives a bunch of pojos, we should be able to create a grammer file, so then developes can type in the editor with that grammer and define a relation ships amound the PJOS and have a business solution.
Re: Generic DSL based on POJO [message #1174434 is a reply to message #1174428] Thu, 07 November 2013 05:07 Go to previous messageGo to next message
Malinga Purnasiri is currently offline Malinga PurnasiriFriend
Messages: 6
Registered: November 2013
Junior Member
Hi Dietrich,

What i thought of doing is, write a normall Java module which will read the pojos from reflection api and write a grammer on the compile time. So then we can use that grammer to create the editor...

is it a good solution or do we have any betterways of doing this ?
Re: Generic DSL based on POJO [message #1174591 is a reply to message #1174434] Thu, 07 November 2013 07:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

You are using the term "generate a grammar"
The grammar has to be generated by the DSL developer.

So every time something changes you would have to regenerate the
grammar and ship a new version of the DSL.

Xtext allows to define references to Java elements in your DSL. Thus
you could make this generic.

I am not sure what you exactly want to model. From your example that
was not clean. Can you post your pojos and a sample model?

--
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: Generic DSL based on POJO [message #1174688 is a reply to message #1174591] Thu, 07 November 2013 08:56 Go to previous messageGo to next message
Malinga Purnasiri is currently offline Malinga PurnasiriFriend
Messages: 6
Registered: November 2013
Junior Member
hi,

My POJOs looks like,

StringField <<extends>> Field
XField <<extends>> Field

StringField will have int attaributes names Att1, Att2, Att3, Att4
XField will have int attaributes names xAtt1

and i want to have my DSL like,

Obj1 user {
fields: [
StringField S1 {Att1=25}
StringField S2 {Att2:50}
StringField S3 {Att3:100}
StringField S4 {Att1:25}
StringField S5 {Att1:100}
]
}

Obj2 project {
fields: [
XField X1{xAtt1:50}
StringField S6{Att2:20}
]
}

But ... when DSL developer type StringField S6{ then it should dynamically go to the StringField POJO and suggest what are the available attributes in there.

and in the newline when he press Ctrl + Space it should sugest all the POJOs manes (ex Obj1 , Obj2)

Re: Generic DSL based on POJO [message #1174742 is a reply to message #1174688] Thu, 07 November 2013 09:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

and what are Obj1 and Obj2


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Generic DSL based on POJO [message #1174836 is a reply to message #1174742] Thu, 07 November 2013 10:42 Go to previous message
Malinga Purnasiri is currently offline Malinga PurnasiriFriend
Messages: 6
Registered: November 2013
Junior Member
It is a class that we need to generate
Previous Topic:Customizing Xtext Model
Next Topic:Disable validation of imported metamodel
Goto Forum:
  


Current Time: Sat Apr 20 03:16:40 GMT 2024

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

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

Back to the top