Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » OCL generation templates: getEAllOperations() vs. getEOperations()
OCL generation templates: getEAllOperations() vs. getEOperations() [message #51321] Wed, 20 September 2006 15:24 Go to next message
Eclipse UserFriend
Originally posted by: acv.modeldrivendevelopment.co.uk

Dear Christian,

Please let me know if this has already been fixed or posted.

I have a metamodel with a validation operation validateName(DiagnosticChain,
Map):Boolean
in an abstract superclass NamedElement.

When this validation is executed on an instance of a subtype,
the generated code in the validateName method fails,
when attempting to retrieve the operation by index.
The index is out of bounds of the eOperations of the receiver class,
because the index used to retrieve the operation is relative to the
list of operations of the implementing class (NamedElement, index = 0),
and not to list of operations in the receiver class.

Furthermore, even if the receiver class had enough operations to avoid the
out-of-bounds condition,
it would retrieve another operation - no the expected one - possibly without
ocl and/or invariant.


The original generated code was:

public boolean validatePrimaryKeyColumnsTable(DiagnosticChain diagnostics,
Map context) {

if (validatePrimaryKeyColumnsTableInvOCL == null) {

EOperation eOperation = (EOperation) eClass().getEOperations().get(1);



After correction of the templates:

public boolean validatePrimaryKeyColumnsTable(DiagnosticChain diagnostics,
Map context) {

if (validatePrimaryKeyColumnsTableInvOCL == null) {

EOperation eOperation = (EOperation) eClass().getEAllOperations().get(1);



------------

genOperation.override.javajetinc used to read:


if (<%=expr%> == null) {

<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%> eOperation
= (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
eClass().getEOperations().get(< %=eOperation.getEContainingClass().getEOperations().indexOf( eOperation)% >);


now it reads:


if (<%=expr%> == null) {

<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%> eOperation
= (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
eClass().getEAllOperations().get(< %=eOperation.getEContainingClass().getEAllOperations().index Of(eOperation)% >);

--------------

I have also changed all the similar uses in the templates of
getEOperations() with getEAllOperations(), and getEEstructuralFeatures()
with getEAllEstructuralFeatures().


Thanks,
Antonio Carrasco-Valero
Model Driven Developement, SL
Re: OCL generation templates: getEAllOperations() vs. getEOperations() [message #51488 is a reply to message #51321] Thu, 21 September 2006 09:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Antonio,

Thanks for catching that! I don't think I used an Ecore model having EClass
specializations in developing my article, so I never noticed this problem.

I suppose that there is some process for following up articles with errata
or revisions. I'll have to see what I can do. In the mean-time, hopefully
everyone who is using those templates sees your posting, here.

Thanks again!

Christian


Antonio Carrasco Valero wrote:

> Dear Christian,
>
> Please let me know if this has already been fixed or posted.
>
> I have a metamodel with a validation operation
> validateName(DiagnosticChain, Map):Boolean
> in an abstract superclass NamedElement.
>
> When this validation is executed on an instance of a subtype,
> the generated code in the validateName method fails,
> when attempting to retrieve the operation by index.
> The index is out of bounds of the eOperations of the receiver class,
> because the index used to retrieve the operation is relative to the
> list of operations of the implementing class (NamedElement, index = 0),
> and not to list of operations in the receiver class.
>
> Furthermore, even if the receiver class had enough operations to avoid the
> out-of-bounds condition,
> it would retrieve another operation - no the expected one - possibly
> without ocl and/or invariant.
>
>
> The original generated code was:
>
> public boolean validatePrimaryKeyColumnsTable(DiagnosticChain diagnostics,
> Map context) {
>
> if (validatePrimaryKeyColumnsTableInvOCL == null) {
>
> EOperation eOperation = (EOperation) eClass().getEOperations().get(1);
>
>
>
> After correction of the templates:
>
> public boolean validatePrimaryKeyColumnsTable(DiagnosticChain diagnostics,
> Map context) {
>
> if (validatePrimaryKeyColumnsTableInvOCL == null) {
>
> EOperation eOperation = (EOperation) eClass().getEAllOperations().get(1);
>
>
>
> ------------
>
> genOperation.override.javajetinc used to read:
>
>
> if (<%=expr%> == null) {
>
> <%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>
> eOperation =
> (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
>
eClass().getEOperations().get(< %=eOperation.getEContainingClass().getEOperations().indexOf( eOperation)% >);
>
>
> now it reads:
>
>
> if (<%=expr%> == null) {
>
> <%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>
> eOperation =
> (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
>
eClass().getEAllOperations().get(< %=eOperation.getEContainingClass().getEAllOperations().index Of(eOperation)% >);
>
> --------------
>
> I have also changed all the similar uses in the templates of
> getEOperations() with getEAllOperations(), and getEEstructuralFeatures()
> with getEAllEstructuralFeatures().
>
>
> Thanks,
> Antonio Carrasco-Valero
> Model Driven Developement, SL
OCL validation in subclasses: error fix [message #51607 is a reply to message #51488] Thu, 21 September 2006 11:09 Go to previous message
Eclipse UserFriend
Originally posted by: acv.modeldrivendevelopment.co.uk

Thanks, Christian,

I hope you don't minf that I have re-posted with new subject,
as the previous:
Re: OCL generation templates: getEAllOperations() vs. getEOperations()
is too obscure to be of any help for whom may look for a solution.

Cheers,
Antonio Carrasco Valero
Model Driven Development SL


"Christian W. Damus" <cdamus@ca.ibm.com> wrote in message
news:eeu2m3$qg9$1@utils.eclipse.org...
>
> Hi, Antonio,
>
> Thanks for catching that! I don't think I used an Ecore model having
> EClass
> specializations in developing my article, so I never noticed this problem.
>
> I suppose that there is some process for following up articles with errata
> or revisions. I'll have to see what I can do. In the mean-time,
> hopefully
> everyone who is using those templates sees your posting, here.
>
> Thanks again!
>
> Christian
>
>
> Antonio Carrasco Valero wrote:
>
>> Dear Christian,
>>
>> Please let me know if this has already been fixed or posted.
>>
>> I have a metamodel with a validation operation
>> validateName(DiagnosticChain, Map):Boolean
>> in an abstract superclass NamedElement.
>>
>> When this validation is executed on an instance of a subtype,
>> the generated code in the validateName method fails,
>> when attempting to retrieve the operation by index.
>> The index is out of bounds of the eOperations of the receiver class,
>> because the index used to retrieve the operation is relative to the
>> list of operations of the implementing class (NamedElement, index = 0),
>> and not to list of operations in the receiver class.
>>
>> Furthermore, even if the receiver class had enough operations to avoid
>> the
>> out-of-bounds condition,
>> it would retrieve another operation - no the expected one - possibly
>> without ocl and/or invariant.
>>
>>
>> The original generated code was:
>>
>> public boolean validatePrimaryKeyColumnsTable(DiagnosticChain
>> diagnostics,
>> Map context) {
>>
>> if (validatePrimaryKeyColumnsTableInvOCL == null) {
>>
>> EOperation eOperation = (EOperation) eClass().getEOperations().get(1);
>>
>>
>>
>> After correction of the templates:
>>
>> public boolean validatePrimaryKeyColumnsTable(DiagnosticChain
>> diagnostics,
>> Map context) {
>>
>> if (validatePrimaryKeyColumnsTableInvOCL == null) {
>>
>> EOperation eOperation = (EOperation) eClass().getEAllOperations().get(1);
>>
>>
>>
>> ------------
>>
>> genOperation.override.javajetinc used to read:
>>
>>
>> if (<%=expr%> == null) {
>>
>> <%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>
>> eOperation =
>> (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
>>
> eClass().getEOperations().get(< %=eOperation.getEContainingClass().getEOperations().indexOf( eOperation)% >);
>>
>>
>> now it reads:
>>
>>
>> if (<%=expr%> == null) {
>>
>> <%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>
>> eOperation =
>> (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
>>
> eClass().getEAllOperations().get(< %=eOperation.getEContainingClass().getEAllOperations().index Of(eOperation)% >);
>>
>> --------------
>>
>> I have also changed all the similar uses in the templates of
>> getEOperations() with getEAllOperations(), and getEEstructuralFeatures()
>> with getEAllEstructuralFeatures().
>>
>>
>> Thanks,
>> Antonio Carrasco-Valero
>> Model Driven Developement, SL
>
Re: OCL generation templates: getEAllOperations() vs. getEOperations() [message #591582 is a reply to message #51321] Thu, 21 September 2006 09:05 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Antonio,

Thanks for catching that! I don't think I used an Ecore model having EClass
specializations in developing my article, so I never noticed this problem.

I suppose that there is some process for following up articles with errata
or revisions. I'll have to see what I can do. In the mean-time, hopefully
everyone who is using those templates sees your posting, here.

Thanks again!

Christian


Antonio Carrasco Valero wrote:

> Dear Christian,
>
> Please let me know if this has already been fixed or posted.
>
> I have a metamodel with a validation operation
> validateName(DiagnosticChain, Map):Boolean
> in an abstract superclass NamedElement.
>
> When this validation is executed on an instance of a subtype,
> the generated code in the validateName method fails,
> when attempting to retrieve the operation by index.
> The index is out of bounds of the eOperations of the receiver class,
> because the index used to retrieve the operation is relative to the
> list of operations of the implementing class (NamedElement, index = 0),
> and not to list of operations in the receiver class.
>
> Furthermore, even if the receiver class had enough operations to avoid the
> out-of-bounds condition,
> it would retrieve another operation - no the expected one - possibly
> without ocl and/or invariant.
>
>
> The original generated code was:
>
> public boolean validatePrimaryKeyColumnsTable(DiagnosticChain diagnostics,
> Map context) {
>
> if (validatePrimaryKeyColumnsTableInvOCL == null) {
>
> EOperation eOperation = (EOperation) eClass().getEOperations().get(1);
>
>
>
> After correction of the templates:
>
> public boolean validatePrimaryKeyColumnsTable(DiagnosticChain diagnostics,
> Map context) {
>
> if (validatePrimaryKeyColumnsTableInvOCL == null) {
>
> EOperation eOperation = (EOperation) eClass().getEAllOperations().get(1);
>
>
>
> ------------
>
> genOperation.override.javajetinc used to read:
>
>
> if (<%=expr%> == null) {
>
> <%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>
> eOperation =
> (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
>
eClass().getEOperations().get(< %=eOperation.getEContainingClass().getEOperations().indexOf( eOperation)% >);
>
>
> now it reads:
>
>
> if (<%=expr%> == null) {
>
> <%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>
> eOperation =
> (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
>
eClass().getEAllOperations().get(< %=eOperation.getEContainingClass().getEAllOperations().index Of(eOperation)% >);
>
> --------------
>
> I have also changed all the similar uses in the templates of
> getEOperations() with getEAllOperations(), and getEEstructuralFeatures()
> with getEAllEstructuralFeatures().
>
>
> Thanks,
> Antonio Carrasco-Valero
> Model Driven Developement, SL
OCL validation in subclasses: error fix [message #591620 is a reply to message #51488] Thu, 21 September 2006 11:09 Go to previous message
Eclipse UserFriend
Originally posted by: acv.modeldrivendevelopment.co.uk

Thanks, Christian,

I hope you don't minf that I have re-posted with new subject,
as the previous:
Re: OCL generation templates: getEAllOperations() vs. getEOperations()
is too obscure to be of any help for whom may look for a solution.

Cheers,
Antonio Carrasco Valero
Model Driven Development SL


"Christian W. Damus" <cdamus@ca.ibm.com> wrote in message
news:eeu2m3$qg9$1@utils.eclipse.org...
>
> Hi, Antonio,
>
> Thanks for catching that! I don't think I used an Ecore model having
> EClass
> specializations in developing my article, so I never noticed this problem.
>
> I suppose that there is some process for following up articles with errata
> or revisions. I'll have to see what I can do. In the mean-time,
> hopefully
> everyone who is using those templates sees your posting, here.
>
> Thanks again!
>
> Christian
>
>
> Antonio Carrasco Valero wrote:
>
>> Dear Christian,
>>
>> Please let me know if this has already been fixed or posted.
>>
>> I have a metamodel with a validation operation
>> validateName(DiagnosticChain, Map):Boolean
>> in an abstract superclass NamedElement.
>>
>> When this validation is executed on an instance of a subtype,
>> the generated code in the validateName method fails,
>> when attempting to retrieve the operation by index.
>> The index is out of bounds of the eOperations of the receiver class,
>> because the index used to retrieve the operation is relative to the
>> list of operations of the implementing class (NamedElement, index = 0),
>> and not to list of operations in the receiver class.
>>
>> Furthermore, even if the receiver class had enough operations to avoid
>> the
>> out-of-bounds condition,
>> it would retrieve another operation - no the expected one - possibly
>> without ocl and/or invariant.
>>
>>
>> The original generated code was:
>>
>> public boolean validatePrimaryKeyColumnsTable(DiagnosticChain
>> diagnostics,
>> Map context) {
>>
>> if (validatePrimaryKeyColumnsTableInvOCL == null) {
>>
>> EOperation eOperation = (EOperation) eClass().getEOperations().get(1);
>>
>>
>>
>> After correction of the templates:
>>
>> public boolean validatePrimaryKeyColumnsTable(DiagnosticChain
>> diagnostics,
>> Map context) {
>>
>> if (validatePrimaryKeyColumnsTableInvOCL == null) {
>>
>> EOperation eOperation = (EOperation) eClass().getEAllOperations().get(1);
>>
>>
>>
>> ------------
>>
>> genOperation.override.javajetinc used to read:
>>
>>
>> if (<%=expr%> == null) {
>>
>> <%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>
>> eOperation =
>> (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
>>
> eClass().getEOperations().get(< %=eOperation.getEContainingClass().getEOperations().indexOf( eOperation)% >);
>>
>>
>> now it reads:
>>
>>
>> if (<%=expr%> == null) {
>>
>> <%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>
>> eOperation =
>> (<%=genModel.getImportedName("org.eclipse.emf.ecore.EOperation ")%>)
>>
> eClass().getEAllOperations().get(< %=eOperation.getEContainingClass().getEAllOperations().index Of(eOperation)% >);
>>
>> --------------
>>
>> I have also changed all the similar uses in the templates of
>> getEOperations() with getEAllOperations(), and getEEstructuralFeatures()
>> with getEAllEstructuralFeatures().
>>
>>
>> Thanks,
>> Antonio Carrasco-Valero
>> Model Driven Developement, SL
>
Previous Topic:java.lang.ClassCircularityError with Teneo
Next Topic:EMFT-JET 0.7.1 Build Announcements
Goto Forum:
  


Current Time: Fri Apr 25 19:35:17 EDT 2025

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

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

Back to the top