Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Mapping dateTime(How to map a dateTime in ECore so it can be used in a GUI and in an XSD)
Mapping dateTime [message #1790522] Tue, 12 June 2018 10:51 Go to next message
Ewoud Werkman is currently offline Ewoud WerkmanFriend
Messages: 28
Registered: January 2018
Junior Member
Hi all,

My project uses and leverages ECore for two pipelines:

  1. Generate Java code, edit, editor code and a Sirius plugin to edit instance models of my ECore model
  2. Generate an XSD to facilitate Python users using python's generateDS program

Now my model uses currently an EDate to describe DateTime information. My problem now is that for pipeline 1: the generated Java code uses the old-fashioned Date-object instead of LocalDateTime (available in Java8). If I use a EDataType to wrap a LocalDateTime, I am not able to use the generated editors to edit the value of the field, and I am unsure how to map that datatype onto the XSD.

For pipeline 2, on the other hand, the generator converts it to an xsd:string when I do the automatic generation of an XML schema (using the XML option of the genmodel), instead of and xsd:dateTime. If I use XMLTypes in my model, the XSD does not change and does not use xsd:dateTime, but the Java code is generated using an XMLGegorianCalendar instead of a LocalDateTime, which I cannot edit in the generated editor either.

How can I solve this issue?
Is there planned support for LocalDateTime in EMF?
Thanks!
Ewoud



Re: Mapping dateTime [message #1790527 is a reply to message #1790522] Tue, 12 June 2018 12:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
No, there are no plans to support LocalDateTime. It's always possible to create your own EDataType to support any Java class for which you can support conversion to and from a string representation. When you used your own EDataType to wrap LocalDateTime, did you modify the generated factory to implement the createXyzFromString/convertXyzToString method? Certainly the XML Types, e.g., dateTime, are editable in a generated editor; they're edited via their string representation. These two new features of EMF 2.14 (part of this month's Photon release) might be of interest:

https://wiki.eclipse.org/EMF/Recipes#Recipe:_Generating_data_types_that_support_date.2Ftime_format
https://wiki.eclipse.org/EMF/Recipes#Recipe:_Use_Nebula-based_Cell_Editors_to_Modify_Date.2FTime_Properties



Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Mapping dateTime [message #1790765 is a reply to message #1790527] Fri, 15 June 2018 21:25 Go to previous messageGo to next message
Ewoud Werkman is currently offline Ewoud WerkmanFriend
Messages: 28
Registered: January 2018
Junior Member
Hi Ed,

Thanks for your fast reply. The extensions look promising! I'll have a look when the stable version of Photon is released at the end of the month.
I did check the createXyzFromString() methods, but that only works in a deployed plugin that uses the generated/adapted factory, but not when using the dynamic instances that I am currently using to do fast model development (BTW a very nice feature). That's why I hoped for internal support for LocalDateTime.
Just curious: Is the 'new' java Time API not supported, because it is in JDK8 and not in JDK5? Or is there another reason?
Re: Mapping dateTime [message #1790766 is a reply to message #1790765] Fri, 15 June 2018 21:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
I was not even aware this existed.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Mapping dateTime [message #1790808 is a reply to message #1790766] Mon, 18 June 2018 09:26 Go to previous message
Ewoud Werkman is currently offline Ewoud WerkmanFriend
Messages: 28
Registered: January 2018
Junior Member
If you need to deal with time, its awesome! It makes time handling in Java so much better than using the crippled Date/Calendar implementation. See for an intro here: http://www.baeldung.com/java-8-date-time-intro
Previous Topic:Dynamic Enumeration-based Attributes
Next Topic:Problem Reloading Genmodel. `<>` operator is not allowed for source level below 1.7
Goto Forum:
  


Current Time: Thu Apr 25 01:29:30 GMT 2024

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

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

Back to the top