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 11:41 Go to next message
Eclipse User
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 12:46 Go to previous messageGo to next message
Eclipse User
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 02:22 Go to previous messageGo to next message
Eclipse User
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 09:46 Go to previous message
Eclipse User
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:Evaluation of transformations with OCL
Next Topic:Re: Running EMFT-OCL
Goto Forum:
  


Current Time: Wed Aug 20 02:50:30 EDT 2014

Powered by FUDForum. Page generated in 0.04303 seconds