Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How do you specify a Type when calling Parameter.setType(Type)?(I am attempting to programmatically create an operation on an interface in my model. I have been successful adding the operation to the interface, and adding parameters to the operation, but I am hav)
How do you specify a Type when calling Parameter.setType(Type)? [message #652428] Thu, 03 February 2011 20:54 Go to next message
Ian Goodsell is currently offline Ian GoodsellFriend
Messages: 2
Registered: February 2011
Junior Member
I am attempting to programmatically create an operation on an interface in my model. I have been successful adding the operation to the interface, and adding parameters to the operation, but I am having difficulty setting the parameter type. I am kind of new at this, so please forgive me if I am missing something basic.

For example, the operation I was trying to create on the interface has the signature:

bool recordExists( int recordId );

I was hoping to be able to do something like this (using a Package in a model named 'aPackage'):

// add an interface to the package
Interface iRecordManager = (Interface)aPackage.createOwnedInterface("recordManager");

// add an operation to the interface
Operation recordExists = (Operation)iRecordManager.createOwnedOperation("recordExists ", null, null, null);


Now I would like to add the parameter and the return value to the operation, doing something like this:

Parameter param = (Parameter)recordExists.createOwnedParameter("recordId", null);
param.setVisibility(VisibilityKind.PRIVATE_LITERAL);
param.setType(null);
Parameter retParam = (Parameter)recordExists.createReturnResult("ret", null);


How do I specify the type to param.setType(Type) and recordExists.createReturnResult(String, Type)? I've done a lot of searching on how to do this, but I haven't been able to find anything.

Hope someone could point me in the right direction.

Thanks, all --

Ian



Re: How do you specify a Type when calling Parameter.setType(Type)? [message #652456 is a reply to message #652428] Fri, 04 February 2011 01:21 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
You can create the types you will need, or import them from a different model.

For creating your own types, createOwnedPrimitiveType, createOwnedClass, createdOwnedEnumeration etc. In your case, I guess you want them to be primitive types.


For the Type hierarchy, see:

http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. uml2.doc/references/javadoc/org/eclipse/uml2/uml/class-use/T ype.html

For an example in TextUML, see:

package UML2Example;

primitive int;
primitive bool;

interface RecordManager 
    operation recordExists(recordId : int) : bool;
end;
        
end.


Hope it helps,

Rafael Chaves
http://abstratt.com
Re: How do you specify a Type when calling Parameter.setType(Type)? [message #652581 is a reply to message #652456] Fri, 04 February 2011 15:41 Go to previous message
Ian Goodsell is currently offline Ian GoodsellFriend
Messages: 2
Registered: February 2011
Junior Member
Thank you very much for pointing me to the Type hierarchy, I was able to use getOwnedType(String) to get the type reference I needed.

I'm also going to check out TextUML, looks very interesting.

Thanks again,

Ian
Previous Topic:Delete UML Proxy without loading it
Next Topic:Additional Operation for uml::Classifier (meta model)
Goto Forum:
  


Current Time: Sat Dec 20 19:31:41 GMT 2014

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

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