Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values.
[EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values. [message #550628] Tue, 03 August 2010 23:06 Go to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 209
Registered: July 2009
Senior Member
Hi all,

I'm trying to incorporate to my emfatic/ecore metamodel some
constrained datatypes. Unfortunately, I haven't found any clear
documentation about that matter. So, I have mixed things from one site
and another, and I finally found that some constrains can be added with
the @ExtendedMetadata annotation. So I have specified a Name datatype,
and I have written a regular expression in order to constraint the
strings that are candidates to be names. For me, a name has to start
with a letter or an underscore and can be followed by cero or more
characters (letters, digits or underscores). I have written the
following annotation associated to the datatype.

@ExtendedMetadata(name="isIdentifier",
baseType="http://www.eclipse.org/emf/2003/XMLType#string",
pattern="^[a-zA-Z_]([a-zA-Z_0-9])*$")
datatype Name: java.lang.String;

Oher kind of constraint I want to write is related to constraining the
values possible values of other datatype. In this case, I have used the
properties minInclusive and maxInclusive, because my PortNumber has to
be a number between 0 and 65534, both inclusive. Below, I have included
the corresponding annotation.

@ExtendedMetadata(name="PortNumber",
baseType="http://www.eclipse.org/emf/2003/XMLType#integer",
minInclusive="0",
maxInclusive="65534")
datatype PortNumber:java.lang.Integer;

The question is that although the editor I'm generating and the
Reflective EMF Editor seem to have into account the constraints, each
time I write a value for a typed PortNumber attribute or a typed Name
attribute, the value is erased, as if the value does not fulfill the
constraint. I have tested with different values for a typed PortNumber
attribute, such as 0, 1, 65534, 7000.

I also have tested a typed Name attribute, and I have introduced values
such as A, My_Name, ...

I don't know if there's something that I'm missing. I also would
appreciate some extra documentation about this ExtendedMetadata
annotations, what kind of regular expressions can be written in the
pattern section, what other kind of constrains can be specified with
this extendedMetadata annotations, and if there is some way of testing
the regular expressions before writing them in the annotations.

Thanks in advance,
Re: [EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values. [message #550634 is a reply to message #550628] Tue, 03 August 2010 23:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070809040408090904070702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

To


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values. [message #550746 is a reply to message #550634] Wed, 04 August 2010 08:57 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 209
Registered: July 2009
Senior Member
Thanks, Ed

the book you have mentioned is the EMF book, isn't it?



El 04/08/2010 1:29, Ed Merks escribió:
> Toñi,
>
> Comments below.
>
>
> Toñi Reina Quintero wrote:
>> Hi all,
>>
>> I'm trying to incorporate to my emfatic/ecore metamodel some
>> constrained datatypes. Unfortunately, I haven't found any clear
>> documentation about that matter.
> The extended meta data annotations and how they correspond to XML
> schema's constraints are described in detail in the book in and in XML
> Schema to Ecore Mapping
> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
>
>> So, I have mixed things from one site and another, and I finally found
>> that some constrains can be added with the @ExtendedMetadata
>> annotation. So I have specified a Name datatype, and I have written a
>> regular expression in order to constraint the strings that are
>> candidates to be names. For me, a name has to start with a letter or
>> an underscore and can be followed by cero or more characters (letters,
>> digits or underscores). I have written the following annotation
>> associated to the datatype.
> With EMF 2.6 it's possible to express constraints with OCL. Ed Willink
> wrote some nice documentation on the OCL pages...
>>
>> @ExtendedMetadata(name="isIdentifier",
>> baseType="http://www.eclipse.org/emf/2003/XMLType#string",
>> pattern="^[a-zA-Z_]([a-zA-Z_0-9])*$")
>> datatype Name: java.lang.String;
>>
>> Oher kind of constraint I want to write is related to constraining the
>> values possible values of other datatype. In this case, I have used
>> the properties minInclusive and maxInclusive, because my PortNumber
>> has to be a number between 0 and 65534, both inclusive. Below, I have
>> included the corresponding annotation.
>>
>> @ExtendedMetadata(name="PortNumber",
>> baseType="http://www.eclipse.org/emf/2003/XMLType#integer",
>> minInclusive="0",
>> maxInclusive="65534")
>> datatype PortNumber:java.lang.Integer;
>>
>> The question is that although the editor I'm generating and the
>> Reflective EMF Editor seem to have into account the constraints, each
>> time I write a value for a typed PortNumber attribute or a typed Name
>> attribute, the value is erased, as if the value does not fulfill the
>> constraint. I have tested with different values for a typed PortNumber
>> attribute, such as 0, 1, 65534, 7000.
> I'd expect such constraints to be checked only when you invoke Validate...
>>
>> I also have tested a typed Name attribute, and I have introduced
>> values such as A, My_Name, ...
>>
>> I don't know if there's something that I'm missing. I also would
>> appreciate some extra documentation about this ExtendedMetadata
>> annotations, what kind of regular expressions can be written in the
>> pattern section,
> Ones the XML Schema allows.
>> what other kind of constrains can be specified with this
>> extendedMetadata annotations, and if there is some way of testing the
>> regular expressions before writing them in the annotations.
> See the document above. It all comes down to emulating what XML Schema
> supports.
>>
>> Thanks in advance,
Re: [EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values. [message #550866 is a reply to message #550746] Wed, 04 August 2010 13:51 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Toñi,

Yes, the second edition of the EMF book. Everyone should buy one so I
can retire while still relatively young. :-P


Toñi Reina Quintero wrote:
> Thanks, Ed
>
> the book you have mentioned is the EMF book, isn't it?
>
>
>
> El 04/08/2010 1:29, Ed Merks escribió:
>> Toñi,
>>
>> Comments below.
>>
>>
>> Toñi Reina Quintero wrote:
>>> Hi all,
>>>
>>> I'm trying to incorporate to my emfatic/ecore metamodel some
>>> constrained datatypes. Unfortunately, I haven't found any clear
>>> documentation about that matter.
>> The extended meta data annotations and how they correspond to XML
>> schema's constraints are described in detail in the book in and in XML
>> Schema to Ecore Mapping
>> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
>>
>>
>>> So, I have mixed things from one site and another, and I finally found
>>> that some constrains can be added with the @ExtendedMetadata
>>> annotation. So I have specified a Name datatype, and I have written a
>>> regular expression in order to constraint the strings that are
>>> candidates to be names. For me, a name has to start with a letter or
>>> an underscore and can be followed by cero or more characters (letters,
>>> digits or underscores). I have written the following annotation
>>> associated to the datatype.
>> With EMF 2.6 it's possible to express constraints with OCL. Ed Willink
>> wrote some nice documentation on the OCL pages...
>>>
>>> @ExtendedMetadata(name="isIdentifier",
>>> baseType="http://www.eclipse.org/emf/2003/XMLType#string",
>>> pattern="^[a-zA-Z_]([a-zA-Z_0-9])*$")
>>> datatype Name: java.lang.String;
>>>
>>> Oher kind of constraint I want to write is related to constraining the
>>> values possible values of other datatype. In this case, I have used
>>> the properties minInclusive and maxInclusive, because my PortNumber
>>> has to be a number between 0 and 65534, both inclusive. Below, I have
>>> included the corresponding annotation.
>>>
>>> @ExtendedMetadata(name="PortNumber",
>>> baseType="http://www.eclipse.org/emf/2003/XMLType#integer",
>>> minInclusive="0",
>>> maxInclusive="65534")
>>> datatype PortNumber:java.lang.Integer;
>>>
>>> The question is that although the editor I'm generating and the
>>> Reflective EMF Editor seem to have into account the constraints, each
>>> time I write a value for a typed PortNumber attribute or a typed Name
>>> attribute, the value is erased, as if the value does not fulfill the
>>> constraint. I have tested with different values for a typed PortNumber
>>> attribute, such as 0, 1, 65534, 7000.
>> I'd expect such constraints to be checked only when you invoke
>> Validate...
>>>
>>> I also have tested a typed Name attribute, and I have introduced
>>> values such as A, My_Name, ...
>>>
>>> I don't know if there's something that I'm missing. I also would
>>> appreciate some extra documentation about this ExtendedMetadata
>>> annotations, what kind of regular expressions can be written in the
>>> pattern section,
>> Ones the XML Schema allows.
>>> what other kind of constrains can be specified with this
>>> extendedMetadata annotations, and if there is some way of testing the
>>> regular expressions before writing them in the annotations.
>> See the document above. It all comes down to emulating what XML Schema
>> supports.
>>>
>>> Thanks in advance,
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values. [message #623099 is a reply to message #550628] Tue, 03 August 2010 23:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070809040408090904070702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

To


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values. [message #623104 is a reply to message #550634] Wed, 04 August 2010 08:57 Go to previous message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 209
Registered: July 2009
Senior Member
Thanks, Ed

the book you have mentioned is the EMF book, isn't it?



El 04/08/2010 1:29, Ed Merks escribió:
> Toñi,
>
> Comments below.
>
>
> Toñi Reina Quintero wrote:
>> Hi all,
>>
>> I'm trying to incorporate to my emfatic/ecore metamodel some
>> constrained datatypes. Unfortunately, I haven't found any clear
>> documentation about that matter.
> The extended meta data annotations and how they correspond to XML
> schema's constraints are described in detail in the book in and in XML
> Schema to Ecore Mapping
> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
>
>> So, I have mixed things from one site and another, and I finally found
>> that some constrains can be added with the @ExtendedMetadata
>> annotation. So I have specified a Name datatype, and I have written a
>> regular expression in order to constraint the strings that are
>> candidates to be names. For me, a name has to start with a letter or
>> an underscore and can be followed by cero or more characters (letters,
>> digits or underscores). I have written the following annotation
>> associated to the datatype.
> With EMF 2.6 it's possible to express constraints with OCL. Ed Willink
> wrote some nice documentation on the OCL pages...
>>
>> @ExtendedMetadata(name="isIdentifier",
>> baseType="http://www.eclipse.org/emf/2003/XMLType#string",
>> pattern="^[a-zA-Z_]([a-zA-Z_0-9])*$")
>> datatype Name: java.lang.String;
>>
>> Oher kind of constraint I want to write is related to constraining the
>> values possible values of other datatype. In this case, I have used
>> the properties minInclusive and maxInclusive, because my PortNumber
>> has to be a number between 0 and 65534, both inclusive. Below, I have
>> included the corresponding annotation.
>>
>> @ExtendedMetadata(name="PortNumber",
>> baseType="http://www.eclipse.org/emf/2003/XMLType#integer",
>> minInclusive="0",
>> maxInclusive="65534")
>> datatype PortNumber:java.lang.Integer;
>>
>> The question is that although the editor I'm generating and the
>> Reflective EMF Editor seem to have into account the constraints, each
>> time I write a value for a typed PortNumber attribute or a typed Name
>> attribute, the value is erased, as if the value does not fulfill the
>> constraint. I have tested with different values for a typed PortNumber
>> attribute, such as 0, 1, 65534, 7000.
> I'd expect such constraints to be checked only when you invoke Validate...
>>
>> I also have tested a typed Name attribute, and I have introduced
>> values such as A, My_Name, ...
>>
>> I don't know if there's something that I'm missing. I also would
>> appreciate some extra documentation about this ExtendedMetadata
>> annotations, what kind of regular expressions can be written in the
>> pattern section,
> Ones the XML Schema allows.
>> what other kind of constrains can be specified with this
>> extendedMetadata annotations, and if there is some way of testing the
>> regular expressions before writing them in the annotations.
> See the document above. It all comes down to emulating what XML Schema
> supports.
>>
>> Thanks in advance,
Re: [EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values. [message #623109 is a reply to message #550746] Wed, 04 August 2010 13:51 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Toñi,

Yes, the second edition of the EMF book. Everyone should buy one so I
can retire while still relatively young. :-P


Toñi Reina Quintero wrote:
> Thanks, Ed
>
> the book you have mentioned is the EMF book, isn't it?
>
>
>
> El 04/08/2010 1:29, Ed Merks escribió:
>> Toñi,
>>
>> Comments below.
>>
>>
>> Toñi Reina Quintero wrote:
>>> Hi all,
>>>
>>> I'm trying to incorporate to my emfatic/ecore metamodel some
>>> constrained datatypes. Unfortunately, I haven't found any clear
>>> documentation about that matter.
>> The extended meta data annotations and how they correspond to XML
>> schema's constraints are described in detail in the book in and in XML
>> Schema to Ecore Mapping
>> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
>>
>>
>>> So, I have mixed things from one site and another, and I finally found
>>> that some constrains can be added with the @ExtendedMetadata
>>> annotation. So I have specified a Name datatype, and I have written a
>>> regular expression in order to constraint the strings that are
>>> candidates to be names. For me, a name has to start with a letter or
>>> an underscore and can be followed by cero or more characters (letters,
>>> digits or underscores). I have written the following annotation
>>> associated to the datatype.
>> With EMF 2.6 it's possible to express constraints with OCL. Ed Willink
>> wrote some nice documentation on the OCL pages...
>>>
>>> @ExtendedMetadata(name="isIdentifier",
>>> baseType="http://www.eclipse.org/emf/2003/XMLType#string",
>>> pattern="^[a-zA-Z_]([a-zA-Z_0-9])*$")
>>> datatype Name: java.lang.String;
>>>
>>> Oher kind of constraint I want to write is related to constraining the
>>> values possible values of other datatype. In this case, I have used
>>> the properties minInclusive and maxInclusive, because my PortNumber
>>> has to be a number between 0 and 65534, both inclusive. Below, I have
>>> included the corresponding annotation.
>>>
>>> @ExtendedMetadata(name="PortNumber",
>>> baseType="http://www.eclipse.org/emf/2003/XMLType#integer",
>>> minInclusive="0",
>>> maxInclusive="65534")
>>> datatype PortNumber:java.lang.Integer;
>>>
>>> The question is that although the editor I'm generating and the
>>> Reflective EMF Editor seem to have into account the constraints, each
>>> time I write a value for a typed PortNumber attribute or a typed Name
>>> attribute, the value is erased, as if the value does not fulfill the
>>> constraint. I have tested with different values for a typed PortNumber
>>> attribute, such as 0, 1, 65534, 7000.
>> I'd expect such constraints to be checked only when you invoke
>> Validate...
>>>
>>> I also have tested a typed Name attribute, and I have introduced
>>> values such as A, My_Name, ...
>>>
>>> I don't know if there's something that I'm missing. I also would
>>> appreciate some extra documentation about this ExtendedMetadata
>>> annotations, what kind of regular expressions can be written in the
>>> pattern section,
>> Ones the XML Schema allows.
>>> what other kind of constrains can be specified with this
>>> extendedMetadata annotations, and if there is some way of testing the
>>> regular expressions before writing them in the annotations.
>> See the document above. It all comes down to emulating what XML Schema
>> supports.
>>>
>>> Thanks in advance,
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EEF] Label not shown on Widget AdvancedTableComposition
Next Topic:EMF diagram editor
Goto Forum:
  


Current Time: Fri Apr 19 18:32:32 GMT 2024

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

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

Back to the top