Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Code creation for data validation
Code creation for data validation [message #1822056] Wed, 26 February 2020 12:49 Go to next message
Mohan Radhakrishnan is currently offline Mohan RadhakrishnanFriend
Messages: 19
Registered: July 2009
Junior Member
Hi,

I usually come across projects that have a UI that collects data. Sometimes this data is quite complicated and many cross-validation scenarios have to be handled. We have a Java backend that validates this data using validators and Drools rules.

Code for this is boiler-plate because the domain logic is the tricky validation. There is no other complex code needed except this validation. Financial control central authorities will collect this data.

I would like to create some code to help such teams. So I started looking at JetBrains MPS and Eclipse tools. How does Eclipse xTend/xText help here ?

The code is composed of Java POJO's with validator annotations and if I could create some of it automatically it would be very interesting.

I have used Antlr for some tasks.

Thanks.
Re: Code creation for data validation [message #1822057 is a reply to message #1822056] Wed, 26 February 2020 12:56 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 114
Registered: February 2016
Senior Member
Hi Mohan,

as a starting point, you can take a look at
1. the Xtext Domainmodel Tutorial: https://www.eclipse.org/Xtext/documentation/102_domainmodelwalkthrough.html
2. the Xtext Domainmodel Example shipped with the Xtext Framework

Hope this helps,
Tamás
Re: Code creation for data validation [message #1822063 is a reply to message #1822057] Wed, 26 February 2020 13:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
Xtext can do two things (together or independent)
- you can model the data (and or the validations - did not get how the validations derive from the data)
- you can write code generators (with the models as input)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code creation for data validation [message #1822097 is a reply to message #1822063] Thu, 27 February 2020 09:16 Go to previous messageGo to next message
Mohan Radhakrishnan is currently offline Mohan RadhakrishnanFriend
Messages: 19
Registered: July 2009
Junior Member
I have a XSD that is parsed and POJO is populated. I assume that the POJO can be generated too.

But mainly It is the validator that I want to generate. As I know how this Java code is structured I want to create a grammar that creates as much of the code as possible.

So the grammar is dependent on eclipse framework. But the generaed code is plain Java. Is that correct ?

Thanks,
Mohan
Re: Code creation for data validation [message #1822104 is a reply to message #1822097] Thu, 27 February 2020 11:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
Xtext can run Standalone/Gradle/Maven; as Language Server in VSCode and others and as Eclipse Plugins.
All these make use of Eclipse/Xtext/EMF apis at modeling and generation time.
The generated code is independent of any of these
(you basically generate text that can "by chance" by compilable and executable java)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code creation for data validation [message #1822216 is a reply to message #1822104] Sun, 01 March 2020 16:10 Go to previous messageGo to next message
Mohan Radhakrishnan is currently offline Mohan RadhakrishnanFriend
Messages: 19
Registered: July 2009
Junior Member
Thanks. I understood some of it quickly from these links. These may help others.


https://www.youtube.com/watch?v=fXM0e00fS9o

These blogs

http://blog.efftinge.de/
https://www.nikostotz.de/blog/

Since I want to use lambdas and good functional programming patterns I found this announcement interesting.

What's new in Xtext 2.14 will be presented by Xtext committer of itemis, Holger Schill.
Major Changes in Xtext 2.14:

Java 9 and 10 Support
JUnit 5 Support

So I can use functional interfaces and lambdas. Right ?

I also read that IntelliJ 15 preview has support for XText/XTend.

XTend syntax looks odd. Is that a language in itself ? Internal DSL ?
Re: Code creation for data validation [message #1822223 is a reply to message #1822216] Mon, 02 March 2020 06:17 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
- The IntelliJ support was dropped. But you may have a look at the Language Server Protocol which is supported by Xtext
- In Xtext 2.20+ Java is used for the most part of the code
- Xtend is a own language

=> You can write all of your Xtext related code in Java 8+ which has lambda support


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtext Hover Documentation [Duplicate - https://www.eclipse.org/forums/index.php/m/1822037/#msg_18220
Next Topic:Spaces for indentation
Goto Forum:
  


Current Time: Wed Oct 21 14:23:18 GMT 2020

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

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

Back to the top