Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » declaring a parameter of a operation of type Sequence
declaring a parameter of a operation of type Sequence [message #33898] Tue, 24 July 2007 15:41 Go to next message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

Hello,

I successfully created some helpers in my UML environment. Now I would like to
create a operation with a sequence as parameter.

I get something like that,

[...]
variable = org.eclipse.ocl.uml.UMLFactory.eINSTANCE.createVariable();
variable.setType(getOCLStandardLibrary().getSequence());
variable.setName("sequence");
params.add(variable);
[...]
Operation myOperation = defineOperation(getOCLStandardLibrary().getOclAny(),
"myOperation",getBoolean(),params, constraint)

After I want to parse this query
"self.myOperation(Sequence{'aValueA','aValueB'})"

But my operation seems to be not identified. I get:

Cannot find operation (myOperation(Sequence(String))) for the type (NamedElement)

I tried with other type (boolean, string), and it works.

Do I have to precise the Type of the elements in the Sequence and how?

thanks a lots.
--
F. Lagarde
Re: declaring a parameter of a operation of type Sequence [message #33943 is a reply to message #33898] Tue, 24 July 2007 16:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, François,

The SequenceType instance needs to know what its element type is. Defining
the operation using the Sequence(T) generic type from the standard library
doesn't work because it doesn't know what its element type is.

Try this, instead:

[...]
variable = org.eclipse.ocl.uml.UMLFactory.eINSTANCE.createVariable();
variable.setType(org.eclipse.ocl.util.TypeUtil.resolveSequen ceType(
this, getOCLStandardLibrary().getString()));
variable.setName("sequence");
params.add(variable);
[...]
Operation myOperation =
defineOperation(getOCLStandardLibrary().getOclAny(),
"myOperation",getBoolean(),params,
constraint)

HTH,

Christian


François Lagarde wrote:

> Hello,
>
> I successfully created some helpers in my UML environment. Now I would
> like to create a operation with a sequence as parameter.
>
> I get something like that,
>
> [...]
> variable = org.eclipse.ocl.uml.UMLFactory.eINSTANCE.createVariable();
> variable.setType(getOCLStandardLibrary().getSequence());
> variable.setName("sequence");
> params.add(variable);
> [...]
> Operation myOperation =
> defineOperation(getOCLStandardLibrary().getOclAny(),
> "myOperation",getBoolean(),params,
> constraint)
>
> After I want to parse this query
> "self.myOperation(Sequence{'aValueA','aValueB'})"
>
> But my operation seems to be not identified. I get:
>
> Cannot find operation (myOperation(Sequence(String))) for the type
> (NamedElement)
>
> I tried with other type (boolean, string), and it works.
>
> Do I have to precise the Type of the elements in the Sequence and how?
>
> thanks a lots.
Re: declaring a parameter of a operation of type Sequence [message #33967 is a reply to message #33943] Wed, 25 July 2007 06:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

In the last post, on 07/24 about 06h, "Christian" (Christian W Damus) wrote:

Christian> Hi, François, The SequenceType instance needs to know what its
Christian> element type is [...] Try this, instead:

Thanks for your reply. It works.

between, the tutorial "Customizing the Environment" doesn't make any reference
to the definition of a operation thanks to the method defineOperation. It could
be helpful to mention it.


--
F. Lagarde
Re: declaring a parameter of a operation of type Sequence [message #33992 is a reply to message #33967] Wed, 25 July 2007 13:46 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, François,

I'm glad it works, now.

About the documentation: sure, feel free to raise an enhancement request.
The current implementation uses "addOperation"; the defineOperation
approach would be a nice alternative. If you can provide a variant of the
current example that uses defineOperation, that would be particularly
helpful :-)

Cheers,

Christian


François Lagarde wrote:

> In the last post, on 07/24 about 06h, "Christian" (Christian W Damus)
> wrote:
>
> Christian> Hi, François, The SequenceType instance needs to know
> what its
> Christian> element type is [...] Try this, instead:
>
> Thanks for your reply. It works.
>
> between, the tutorial "Customizing the Environment" doesn't make any
> reference to the definition of a operation thanks to the method
> defineOperation. It could be helpful to mention it.
>
>
Previous Topic:Bug getting the CollectionType Name
Next Topic:Re: Running EMFT-OCL
Goto Forum:
  


Current Time: Mon Sep 23 09:38:12 GMT 2024

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

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

Back to the top