Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Re: using the Type: MyProfile::MyStereotype
Re: using the Type: MyProfile::MyStereotype [message #45636] Fri, 30 November 2007 13:20 Go to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, asma,

These questions really are more about OCL than about UML, so I am replying
to the OCL newsgroup as well.

See some replies in-line, below.

HTH,

Christian

charfi asma wrote:

> Hello,
> Is Element.base_Component refer to the metaclass?

Do you mean, MyStereoytype::base_Component? Yes, this is the property of
the stereotype that references the extended metaclass. It is one end of
the Extension.


> for example, I write this constraint (context=Component):
> self.ownedPort... when I evaluated it did not find theoperation ownedPort
> although a component has ownedPort!

Probably you are parsing at M1 level? (using the component in your model as
the context classifier instead of the Component metaclass)

At M1 level, OCL will expect your component in your model to own an
attribute named ownedPort. It is the Component metaclass (which is a
Class) in the UML metamodel that has ownedPort, so you want M2 level.

Use OCLHelper::setInstanceContext(Object) to set an M2 context instead of
OCLHelper::setContext(Classifier) which sets M1 context.


> when I write the same constraint (context=MyComponent)
> self.base_Component.ownedPort it works perfectly

Right, because on the stereotype you use M1 context (which is correct). The
stereotype in your profile has a base_Component property referencing the
Class named "Component" (the UML Component metaclass). From the
perspective of a profile, the UML Metamodel is at the M1 level, whereas
from the perspective of a model, the UML metamodel is at the M2 level.


> also, the Type MyProfile::MyStereotype is not recongnized unless I change
> context to MyComponent not the metacalss Component.

The OCL parser should be able to find the MyProfile namespace in your
resource set if your profile resource is loaded in that resource set. Can
you be more specific about how to reproduce this problem?


> in which level of modeling we can use the type MyProfile::MyStereotype ?

Well, either one, actually. It depends on what you are trying to do,
whether you are modeling (creating an instance of the UML metamodel) or
metamodeling (creating customizations/extensions of the UML metamodel or
even completely new metamodels).


> (I
> supposed that I have profile with stereotype and I added constraints to
> the stereotype to evaluate them on model that apply the profile)
>
> thanks
Re: using the Type: MyProfile::MyStereotype [message #45667 is a reply to message #45636] Mon, 03 December 2007 13:56 Go to previous messageGo to next message
Eclipse User
Originally posted by: asma.charfi.com

Hi Chistian,

" The OCL parser should be able to find the MyProfile namespace in your
resource set if your profile resource is loaded in that resource set. Can
you be more specific about how to reproduce this problem? "

in fact, My profile is defined using UMLEditor->profile->define. I load it
in the model using also UMLEditor.
LoadRessource and I chose the profile file to be loaded in my model. after
that I apply my profile to the model using UMLEditor->package->apply
profile.
I d'ont really undrestand where should I put the namespace?


"Well, either one, actually. It depends on what you are trying to do,
whether you are modeling (creating an instance of the UML metamodel) or
metamodeling (creating customizations/extensions of the UML metamodel or
even completely new metamodels)"

I am modeling (creating profile and model). so why the oclparser did not
recognize the type MyProfile::MyStereotype?

thank you
asma

"Christian W. Damus" <cdamus@ca.ibm.com> a
Re: using the Type: MyProfile::MyStereotype [message #45695 is a reply to message #45667] Mon, 03 December 2007 06:06 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Asma,

By "namespace" I am referring to the MyProfile profile in its capacity as
a UML Namespace in qualified names.

Another consideration is whether you are using the Ecore or the UML
environment (sorry, I forget now which one you are using). The UML
environment looks in loaded UML packages (including profiles) in the
resource when resolving qualified name references. The Ecore environment,
however, looks in the package registry. When you apply your defined
profile to your UML model, the UML editor should be putting the profile
definition (an EPackage) into the resource set's local package registry.

If you are using the Ecore environment, you should construct your
EcoreEnvironmentFactory using the resource set's package registry
(ResourceSet::getPackageRegistry() method) instead of the default, which
is the global package registry. This will ensure that your profile
definition is visible.

If you are using the UML environment, then it would seem that it is
correctly initialized with the resource se, since it can find your
stereotype in the component context. Try putting a breakpoint in the
OCLUMLUtil::findNamespace method and debug to see why the parser doesn't
find your stereotype (or, perhaps, the profile).

HTH,

Christian

charfi asma wrote:

> Hi Chistian,

> " The OCL parser should be able to find the MyProfile namespace in your
> resource set if your profile resource is loaded in that resource set. Can
> you be more specific about how to reproduce this problem? "

> in fact, My profile is defined using UMLEditor->profile->define. I load it
> in the model using also UMLEditor.
> LoadRessource and I chose the profile file to be loaded in my model. after
> that I apply my profile to the model using UMLEditor->package->apply
> profile.
> I d'ont really undrestand where should I put the namespace?


> "Well, either one, actually. It depends on what you are trying to do,
> whether you are modeling (creating an instance of the UML metamodel) or
> metamodeling (creating customizations/extensions of the UML metamodel or
> even completely new metamodels)"

> I am modeling (creating profile and model). so why the oclparser did not
> recognize the type MyProfile::MyStereotype?

> thank you
> asma

-----8<-----
Re: using the Type: MyProfile::MyStereotype [message #45725 is a reply to message #45695] Mon, 03 December 2007 23:21 Go to previous messageGo to next message
Eclipse User
Originally posted by: asma.charfi.com

Hi Christian,
I am using UML Environnement (in fact I have 2 plugins, one for UML
Environnement and the other for Ecore one :-))
I am interested in the first one, (UML Environement)

I imported org.eclipse.ocl, I put a breakpoint in front of
OCLUMLUtil::findNamespace method and I debug but nothing is happen.
when I put breakpoint in my code next to this line oclInv = (Constraint)
oclHelper.createInvariant(stereotype.getOwnedRules().get(i). getSpecification().stringValue())
it returns oclInv=null.

I tried to put breakpoints in org.eclipse.ocl.SemanticException and in
org.eclipse.ocl.internal.parser.OCLParser but when I debug nothing is happen

oclInv = (Constraint)
oclHelper.createInvariant(stereotype.getOwnedRules().get(i). getSpecification().stringValue())
is surrounded by try and catch.

I can not understand why the breakpoints are disabled? my plugin use
org;eclipse.ocl.uml (it appear in plugin dependancies..)
thank you!
asma

org.eclipse.ocl.SemanticException: ERROR in
(enumerationOrClassLiteralExpCS): (Unknown type ([P, Port]))

at org.eclipse.ocl.internal.parser.OCLParser.ERR(OCLParser.java :596)



"Christian W. Damus" <cdamus@ca.ibm.com> a
Re: using the Type: MyProfile::MyStereotype [message #45812 is a reply to message #45725] Tue, 04 December 2007 16:48 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Asma,

> org.eclipse.ocl.SemanticException: ERROR in
> (enumerationOrClassLiteralExpCS): (Unknown type ([P, Port]))

I think I recall seeing, before, that these aren't actually the real names
of your profile and your stereotype, but just examples that you used on the
newsgroup for simplicity?

If that's not the problem, then perhaps you can attach your model and
profile, and specify exactly the OCL expression that you are trying to
parse. I can give a try and debug it when I have a free moment.

I'm out of guesses as to what the problem might be.

Cheers,

Christian

charfi asma wrote:

> Hi Christian,
> I am using UML Environnement (in fact I have 2 plugins, one for UML
> Environnement and the other for Ecore one :-))
> I am interested in the first one, (UML Environement)
>
> I imported org.eclipse.ocl, I put a breakpoint in front of
> OCLUMLUtil::findNamespace method and I debug but nothing is happen.
> when I put breakpoint in my code next to this line oclInv = (Constraint)
>
oclHelper.createInvariant(stereotype.getOwnedRules().get(i). getSpecification().stringValue())
> it returns oclInv=null.
>
> I tried to put breakpoints in org.eclipse.ocl.SemanticException and in
> org.eclipse.ocl.internal.parser.OCLParser but when I debug nothing is
> happen
>
> oclInv = (Constraint)
>
oclHelper.createInvariant(stereotype.getOwnedRules().get(i). getSpecification().stringValue())
> is surrounded by try and catch.
>
> I can not understand why the breakpoints are disabled? my plugin use
> org;eclipse.ocl.uml (it appear in plugin dependancies..)
> thank you!
> asma
>
> org.eclipse.ocl.SemanticException: ERROR in
> (enumerationOrClassLiteralExpCS): (Unknown type ([P, Port]))
>
> at org.eclipse.ocl.internal.parser.OCLParser.ERR(OCLParser.java :596)
>

-----8<-----
Re: using the Type: MyProfile::MyStereotype [message #45841 is a reply to message #45812] Wed, 05 December 2007 03:08 Go to previous messageGo to next message
Eclipse User
Originally posted by: asma.charfi.com

Hi,
that's right Christian, I put these names to simplify in newsgroups.
I don't think that problem comes from OCLUMLUtil::findNamespace because when
I change context to element and not the metaclass Component, and add
base_Component to the constraint, paring works perfectly and the type
MyProfile:MyStereotype is recongnized.
why the OCLUMLUtil::findNamespace finf the right profile when I cahnge
context and did not find it when I put element as context?I would be very
thankful if you can test it (I gave my code in previous msg Re: constraints
with Set...28 novembre 2007 18:58 )

thanks
asma



"Christian W. Damus" <cdamus@ca.ibm.com> a
Re: using the Type: MyProfile::MyStereotype [message #45871 is a reply to message #45841] Tue, 04 December 2007 18:18 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Asma,

I doubt that I will have the time to both debug *and* write the code. You
provided a snippet, earlier, that has to be boot-strapped with some kind of
main() method or JUnit test case, followed by loading models into resource
sets, etc.

It would be most helpful if you can provide a ZIPped-up Eclipse project
containing a JUnit test that loads your models and attempts to parse this
OCL constraint on them. I can't follow all of the code snippets ...

Thanks,

Christian

charfi asma wrote:

> Hi,
> that's right Christian, I put these names to simplify in newsgroups.
> I don't think that problem comes from OCLUMLUtil::findNamespace because
> when I change context to element and not the metaclass Component, and add
> base_Component to the constraint, paring works perfectly and the type
> MyProfile:MyStereotype is recongnized.
> why the OCLUMLUtil::findNamespace finf the right profile when I cahnge
> context and did not find it when I put element as context?I would be very
> thankful if you can test it (I gave my code in previous msg Re:
> constraints with Set...28 novembre 2007 18:58 )
>
> thanks
> asma
>

-----8<-----
Re: using the Type: MyProfile::MyStereotype [message #45903 is a reply to message #45871] Wed, 05 December 2007 15:52 Go to previous messageGo to next message
Eclipse User
Originally posted by: asma.charfi.com

Hi Christian,
I send my plugin with model.uml and profil.uml to cdamus@ca.ibm.com
I hope you will find time to debug the code
thank you a lot!
Asma
"Christian W. Damus" <cdamus@ca.ibm.com> a
Re: using the Type: MyProfile::MyStereotype [message #45926 is a reply to message #45903] Wed, 05 December 2007 08:27 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Asma,

For the benefit of others, I will repeat the conclusion of my investigation
that I sent to you in reply to your example.

The problem was that the OCL environment was initialized using the default
constructor, which creates a new, empty resource set. Thus, the profile
was not available in the environment's resource when trying to resolve the
qualified stereotype name in the component context. References to UML
metaclasses always resolve because the environment knows how to load the
UML metamodel into its resource set.

The problem is fixed by initializing the OCL environment on the UML editor's
resource set, which already has the profile (and the UML metamodel) loaded.

Cheers,

Christian

charfi asma wrote:

> Hi Christian,
> I send my plugin with model.uml and profil.uml to cdamus@ca.ibm.com
> I hope you will find time to debug the code
> thank you a lot!
> Asma
> "Christian W. Damus" <cdamus@ca.ibm.com> a �rit dans le message de news:
> fj4n7q$sul$1@build.eclipse.org...

-----8<-----
Re: using the Type: MyProfile::MyStereotype [message #46000 is a reply to message #45926] Wed, 05 December 2007 19:40 Go to previous message
Eclipse User
Originally posted by: asma.charfi.com

Hi Christian!
I am so glaaaaaaaaaaaaaaaaaaaaad!
I don't know how to thank you!
I always learn from you!
this newsgroup is the best one all over the world!
Asma

"Christian W. Damus" <cdamus@ca.ibm.com> a
Re: using the Type: MyProfile::MyStereotype [message #46029 is a reply to message #46000] Wed, 05 December 2007 11:07 Go to previous message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Aw, shucks! Thanks for the vote of support.

I'm happy that you're back on track.

cW

charfi asma wrote:

> Hi Christian!
> I am so glaaaaaaaaaaaaaaaaaaaaad!
> I don't know how to thank you!
> I always learn from you!
> this newsgroup is the best one all over the world!
> Asma

-----8<-----
Previous Topic:constraints with Set...
Next Topic:Re: EMF Validation OCLParser EcoreEnvironment.findPackage and empty packages.
Goto Forum:
  


Current Time: Sun Aug 31 00:32:01 EDT 2014

Powered by FUDForum. Page generated in 0.10076 seconds