Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Decimal precision for eStructuralFeatures
Decimal precision for eStructuralFeatures [message #902333] Fri, 17 August 2012 06:39 Go to next message
Al B is currently offline Al BFriend
Messages: 47
Registered: June 2012
Member
Is it possible declare the eType of an eStructuralFeatures as decimal? Will this be valid?

<eStructuralFeatures xsi:type="dict:EAttributeParameter" name="toControl" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//Decimal">

Also, can one indicate the precision (e.g. 2 decimals)?

Thanks in advance!

[Updated on: Fri, 17 August 2012 06:40]

Report message to a moderator

Re: Decimal precision for eStructuralFeatures [message #902341 is a reply to message #902333] Fri, 17 August 2012 08:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31482
Registered: July 2009
Senior Member
AJ,

Yes, with extended metadata annotations on an EDataType you can specify
the number of fractional digits as in XML Schema
http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits


On 17/08/2012 8:39 AM, AJ Ben wrote:
> Is it possible declare the eType of an eStructuralFeatures as decimal?
> Will this be valid?
>
> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
> name="toControl" eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>
> Also, can one also indicate the precision (e.g. 2 decimals)?
>
> Thanks in advance!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Decimal precision for eStructuralFeatures [message #902473 is a reply to message #902341] Fri, 17 August 2012 19:09 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
Hi Ed,

Do you mean doing something like this?

<eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
<eAnnotations source="descriptor">
<details key="display_name" value="Pitch"/>
</eAnnotations>
<eType xsi:type="ecore:EDataType"
href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
</eStructuralFeatures>

Or, do you mean embed another eAnnotations like this?

<eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
<eAnnotations source="descriptor">
<details key="display_name" value="Pitch"/>
</eAnnotations>
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="baseType"
value="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
<details key="value" value="2"/>
</eAnnotations>
</eStructuralFeatures>


Thanks!

On 8/17/12 1:04 AM, Ed Merks wrote:
> AJ,
>
> Yes, with extended metadata annotations on an EDataType you can specify
> the number of fractional digits as in XML Schema
> http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
>
>
> On 17/08/2012 8:39 AM, AJ Ben wrote:
>> Is it possible declare the eType of an eStructuralFeatures as decimal?
>> Will this be valid?
>>
>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>> name="toControl" eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>>
>> Also, can one also indicate the precision (e.g. 2 decimals)?
>>
>> Thanks in advance!
>
Re: Decimal precision for eStructuralFeatures [message #902476 is a reply to message #902473] Fri, 17 August 2012 20:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31482
Registered: July 2009
Senior Member
AJ,

No, the annotation must be on the EDataType. So you need to define an
EDataType that wraps BigDecimal and put the annotation on that. Easiest
is to write a small schema and look at how that's converted to Ecore.


On 17/08/2012 9:09 PM, AJ wrote:
> Hi Ed,
>
> Do you mean doing something like this?
>
> <eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
> <eAnnotations source="descriptor">
> <details key="display_name" value="Pitch"/>
> </eAnnotations>
> <eType xsi:type="ecore:EDataType"
> href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
> </eStructuralFeatures>
>
> Or, do you mean embed another eAnnotations like this?
>
> <eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
> <eAnnotations source="descriptor">
> <details key="display_name" value="Pitch"/>
> </eAnnotations>
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="baseType"
> value="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
> <details key="value" value="2"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
> Thanks!
>
> On 8/17/12 1:04 AM, Ed Merks wrote:
>> AJ,
>>
>> Yes, with extended metadata annotations on an EDataType you can specify
>> the number of fractional digits as in XML Schema
>> http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
>>
>>
>> On 17/08/2012 8:39 AM, AJ Ben wrote:
>>> Is it possible declare the eType of an eStructuralFeatures as decimal?
>>> Will this be valid?
>>>
>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>> name="toControl" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>>>
>>> Also, can one also indicate the precision (e.g. 2 decimals)?
>>>
>>> Thanks in advance!
>>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Decimal precision for eStructuralFeatures [message #902500 is a reply to message #902476] Sat, 18 August 2012 00:12 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
Ed,

As you suggested, I created a small schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
ecore:nsPrefix="test" ecore:package="test" targetNamespace="test">
<xsd:simpleType ecore:name="ThreeDecimalsType" name="ThreeDecimals_Type">
<xsd:restriction base="xsd:decimal">
<xsd:fractionDigits value="3"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>


And EMF generated an EDataType like this:

<eClassifiers xsi:type="ecore:EDataType" name="ThreeDecimalsType"
instanceClassName="java.math.BigDecimal">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="ThreeDecimals_Type"/>
<details key="baseType"
value="http://www.eclipse.org/emf/2003/XMLType#decimal"/>
<details key="fractionDigits" value="3"/>
</eAnnotations>
</eClassifiers>


However, I am still able to enter more than 3 decimals when I added this
new type to the feature:

<eStructuralFeatures xsi:type="dict:EAttributeParameter"
name="acrPitch" eType="//ThreeDecimalsType">
<eAnnotations source="descriptor">
<details key="display_name" value="Pitch"/>
</eAnnotations>
</eStructuralFeatures>


I can see that BasicExtendedMetaData::basicGetBaseType() detects the new
type, but neither basicGetFractionDigitsFacet() or
setFractionDigitsFacet() are called.


Did I miss anything else?

Thanks again!


On 8/17/12 1:01 PM, Ed Merks wrote:
> AJ,
>
> No, the annotation must be on the EDataType. So you need to define an
> EDataType that wraps BigDecimal and put the annotation on that. Easiest
> is to write a small schema and look at how that's converted to Ecore.
>
>
> On 17/08/2012 9:09 PM, AJ wrote:
>> Hi Ed,
>>
>> Do you mean doing something like this?
>>
>> <eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
>> <eAnnotations source="descriptor">
>> <details key="display_name" value="Pitch"/>
>> </eAnnotations>
>> <eType xsi:type="ecore:EDataType"
>> href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
>> </eStructuralFeatures>
>>
>> Or, do you mean embed another eAnnotations like this?
>>
>> <eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
>> <eAnnotations source="descriptor">
>> <details key="display_name" value="Pitch"/>
>> </eAnnotations>
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="baseType"
>> value="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
>> <details key="value" value="2"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>>
>>
>> Thanks!
>>
>> On 8/17/12 1:04 AM, Ed Merks wrote:
>>> AJ,
>>>
>>> Yes, with extended metadata annotations on an EDataType you can specify
>>> the number of fractional digits as in XML Schema
>>> http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
>>>
>>>
>>> On 17/08/2012 8:39 AM, AJ Ben wrote:
>>>> Is it possible declare the eType of an eStructuralFeatures as decimal?
>>>> Will this be valid?
>>>>
>>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>>> name="toControl" eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>>>>
>>>> Also, can one also indicate the precision (e.g. 2 decimals)?
>>>>
>>>> Thanks in advance!
>>>
>>
>
Re: Decimal precision for eStructuralFeatures [message #902521 is a reply to message #902500] Sat, 18 August 2012 05:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31482
Registered: July 2009
Senior Member
AJ,

EObjectValidator validates such things, but only when you invoke the
validator. I'd expect PropertyDescriptor.EDataTypeValueHandler.isValid
to invoke validation. What do you mean by "able to enter"? Via the
properties view?


On 18/08/2012 2:12 AM, AJ wrote:
> Ed,
>
> As you suggested, I created a small schema:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> ecore:nsPrefix="test" ecore:package="test" targetNamespace="test">
> <xsd:simpleType ecore:name="ThreeDecimalsType"
> name="ThreeDecimals_Type">
> <xsd:restriction base="xsd:decimal">
> <xsd:fractionDigits value="3"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:schema>
>
>
> And EMF generated an EDataType like this:
>
> <eClassifiers xsi:type="ecore:EDataType" name="ThreeDecimalsType"
> instanceClassName="java.math.BigDecimal">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="ThreeDecimals_Type"/>
> <details key="baseType"
> value="http://www.eclipse.org/emf/2003/XMLType#decimal"/>
> <details key="fractionDigits" value="3"/>
> </eAnnotations>
> </eClassifiers>
>
>
> However, I am still able to enter more than 3 decimals when I added
> this new type to the feature:
>
> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
> name="acrPitch" eType="//ThreeDecimalsType">
> <eAnnotations source="descriptor">
> <details key="display_name" value="Pitch"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
> I can see that BasicExtendedMetaData::basicGetBaseType() detects the
> new type, but neither basicGetFractionDigitsFacet() or
> setFractionDigitsFacet() are called.
>
>
> Did I miss anything else?
>
> Thanks again!
>
>
> On 8/17/12 1:01 PM, Ed Merks wrote:
>> AJ,
>>
>> No, the annotation must be on the EDataType. So you need to define an
>> EDataType that wraps BigDecimal and put the annotation on that. Easiest
>> is to write a small schema and look at how that's converted to Ecore.
>>
>>
>> On 17/08/2012 9:09 PM, AJ wrote:
>>> Hi Ed,
>>>
>>> Do you mean doing something like this?
>>>
>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>> name="acrPitch">
>>> <eAnnotations source="descriptor">
>>> <details key="display_name" value="Pitch"/>
>>> </eAnnotations>
>>> <eType xsi:type="ecore:EDataType"
>>> href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
>>> </eStructuralFeatures>
>>>
>>> Or, do you mean embed another eAnnotations like this?
>>>
>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>> name="acrPitch">
>>> <eAnnotations source="descriptor">
>>> <details key="display_name" value="Pitch"/>
>>> </eAnnotations>
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="baseType"
>>> value="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
>>> <details key="value" value="2"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>>
>>>
>>> Thanks!
>>>
>>> On 8/17/12 1:04 AM, Ed Merks wrote:
>>>> AJ,
>>>>
>>>> Yes, with extended metadata annotations on an EDataType you can
>>>> specify
>>>> the number of fractional digits as in XML Schema
>>>> http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
>>>>
>>>>
>>>> On 17/08/2012 8:39 AM, AJ Ben wrote:
>>>>> Is it possible declare the eType of an eStructuralFeatures as
>>>>> decimal?
>>>>> Will this be valid?
>>>>>
>>>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>>>> name="toControl" eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>>>>>
>>>>> Also, can one also indicate the precision (e.g. 2 decimals)?
>>>>>
>>>>> Thanks in advance!
>>>>
>>>
>>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Decimal precision for eStructuralFeatures [message #902527 is a reply to message #902500] Sat, 18 August 2012 07:28 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 47
Registered: June 2012
Member
Ed,

Yes, via the properties view.
Re: Decimal precision for eStructuralFeatures [message #902588 is a reply to message #902527] Sat, 18 August 2012 17:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31482
Registered: July 2009
Senior Member
AJ,

Have you set a breakpoint to see what's going on?

On 18/08/2012 9:28 AM, AJ Ben wrote:
> Ed,
>
> Yes, via the properties view.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Decimal precision for eStructuralFeatures [message #902591 is a reply to message #902588] Sat, 18 August 2012 18:07 Go to previous message
Al B is currently offline Al BFriend
Messages: 47
Registered: June 2012
Member
Hey Eduardus Antonius Theodorus,

I think I got it.

Your previous comment about the EDataTypeValueHandler.isValid, pointed me to the right direction. Using BasicExtendedMetaData.getFractionDigitsFacet() allows me to validate/format the entered input.

Thanks a lot and best regards!

PS: I like your Roman Emperor name Wink
Previous Topic:Error CDO/Teneo/Postgres
Next Topic:[CDO/DAWN] Missing Constraints while trying to reproduce &quot;Getting Started With Dawn Web&
Goto Forum:
  


Current Time: Fri Sep 25 01:42:27 GMT 2020

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

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

Back to the top