Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » InstanceSpecification of a Modeled Class
InstanceSpecification of a Modeled Class [message #537829] Thu, 03 June 2010 19:10 Go to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Hello,

I have been playing with the ExtendedPO2, the example given in "Getting Started with UML2" and I'm trying to create an instance of one of the modeled classes using InstanceSpecification.

What I'm doing is: I create an instance specification, then I create a slot for the property "name", and then to assign a value I'm using the setValue() method, but it requires a StereoType.

Do I have to create a stereotype for the class? or maybe this is not the right approach.

InstanceSpecification is = UMLFactory.eINSTANCE.createInstanceSpecification();
is.setName("supplierInstance");
is.getClassifiers().add(supplierClass);
Slot sn = is.createSlot();
Property name = supplierClass.getAttribute("name", stringPrimitiveType);
sn.setDefiningFeature(name);
//sn.setValue(StereoType, ..., ...)????

Thank you.

Hector
Re: InstanceSpecification of a Modeled Class [message #537859 is a reply to message #537829] Thu, 03 June 2010 21:46 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
hi

i guess after adding a slot you have to add some thing literal (right click on slot and choose your value type) whether it is string, integer or instance for example, and then set there your value, is that what you are asking about?
Re: InstanceSpecification of a Modeled Class [message #537866 is a reply to message #537859] Thu, 03 June 2010 22:27 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Hi Wafaa,

Thanks for the replay. I'm trying to achieve a similar result but programmatically, not in the editor. Something like the code I have in my first post.

Hector

Re: InstanceSpecification of a Modeled Class [message #537944 is a reply to message #537866] Fri, 04 June 2010 09:52 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
yes, I see.
Sorry I did not see the code Very Happy


but so, can you tell me why do you use code, what is its benefits than editor..(I might ask about the target of programming it)
Re: InstanceSpecification of a Modeled Class [message #538005 is a reply to message #537829] Fri, 04 June 2010 13:25 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Hector,

Slots have multiple values. Get the value collection:

EList<ValueSpecification> Slot::getValues()

and add some kind of a ValueSpecification to it.

The setValue(Stereotype, ...) method is the API on the Element type that
sets stereotype attribute values. That has nothing to do with your
requirement.

Cheers,

Christian


On 03/06/10 03:10 PM, Hector Chavez wrote:
> Hello,
>
> I have been playing with the ExtendedPO2, the example given in "Getting
> Started with UML2" and I'm trying to create an instance of one of the
> modeled classes using InstanceSpecification.
>
> What I'm doing is: I create an instance specification, then I create a
> slot for the property "name", and then to assign a value I'm using the
> setValue() method, but it requires a StereoType.
> Do I have to create a stereotype for the class? or maybe this is not the
> right approach.
>
>
> InstanceSpecification is =
> UMLFactory.eINSTANCE.createInstanceSpecification();
> is.setName("supplierInstance");
> is.getClassifiers().add(supplierClass);
> Slot sn = is.createSlot();
> Property name = supplierClass.getAttribute("name", stringPrimitiveType);
> sn.setDefiningFeature(name);
> //sn.setValue(StereoType, ..., ...)????
>
> Thank you.
>
> Hector
Re: InstanceSpecification of a Modeled Class [message #538081 is a reply to message #537944] Fri, 04 June 2010 21:02 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Some times you may want to automatically generate object diagrams without user intervention for testing purposes. Which is what I'm trying to do.

wafaa wrote on Fri, 04 June 2010 05:52
yes, I see.
Sorry I did not see the code Very Happy


but so, can you tell me why do you use code, what is its benefits than editor..(I might ask about the target of programming it)


Re: InstanceSpecification of a Modeled Class [message #538082 is a reply to message #538005] Fri, 04 June 2010 21:05 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Thank you Christian, it is working now. I was looking at the wrong method.

Hector

Christian W. Damus wrote on Fri, 04 June 2010 09:25
Hi, Hector,

Slots have multiple values. Get the value collection:

EList<ValueSpecification> Slot::getValues()

and add some kind of a ValueSpecification to it.

The setValue(Stereotype, ...) method is the API on the Element type that
sets stereotype attribute values. That has nothing to do with your
requirement.

Cheers,

Christian


On 03/06/10 03:10 PM, Hector Chavez wrote:
> Hello,
>
> I have been playing with the ExtendedPO2, the example given in "Getting
> Started with UML2" and I'm trying to create an instance of one of the
> modeled classes using InstanceSpecification.
>
> What I'm doing is: I create an instance specification, then I create a
> slot for the property "name", and then to assign a value I'm using the
> setValue() method, but it requires a StereoType.
> Do I have to create a stereotype for the class? or maybe this is not the
> right approach.
>
>
> InstanceSpecification is =
> UMLFactory.eINSTANCE.createInstanceSpecification();
> is.setName("supplierInstance");
> is.getClassifiers().add(supplierClass);
> Slot sn = is.createSlot();
> Property name = supplierClass.getAttribute("name", stringPrimitiveType);
> sn.setDefiningFeature(name);
> //sn.setValue(StereoType, ..., ...)????
>
> Thank you.
>
> Hector

Re: InstanceSpecification of a Modeled Class [message #628482 is a reply to message #537829] Thu, 03 June 2010 21:46 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
hi

i guess after adding a slot you have to add some thing literal (right click on slot and choose your value type) whether it is string, integer or instance for example, and then set there your value, is that what you are asking about?
Re: InstanceSpecification of a Modeled Class [message #628484 is a reply to message #628482] Thu, 03 June 2010 22:27 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Hi Wafaa,

Thanks for the replay. I'm trying to achieve a similar result but programmatically, not in the editor. Something like the code I have in my first post.

Hector
Re: InstanceSpecification of a Modeled Class [message #628492 is a reply to message #628484] Fri, 04 June 2010 09:52 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
yes, I see.
Sorry I did not see the code :d


but so, can you tell me why do you use code, what is its benefits than editor..(I might ask about the target of programming it)
Re: InstanceSpecification of a Modeled Class [message #628493 is a reply to message #537829] Fri, 04 June 2010 13:25 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Hector,

Slots have multiple values. Get the value collection:

EList<ValueSpecification> Slot::getValues()

and add some kind of a ValueSpecification to it.

The setValue(Stereotype, ...) method is the API on the Element type that
sets stereotype attribute values. That has nothing to do with your
requirement.

Cheers,

Christian


On 03/06/10 03:10 PM, Hector Chavez wrote:
> Hello,
>
> I have been playing with the ExtendedPO2, the example given in "Getting
> Started with UML2" and I'm trying to create an instance of one of the
> modeled classes using InstanceSpecification.
>
> What I'm doing is: I create an instance specification, then I create a
> slot for the property "name", and then to assign a value I'm using the
> setValue() method, but it requires a StereoType.
> Do I have to create a stereotype for the class? or maybe this is not the
> right approach.
>
>
> InstanceSpecification is =
> UMLFactory.eINSTANCE.createInstanceSpecification();
> is.setName("supplierInstance");
> is.getClassifiers().add(supplierClass);
> Slot sn = is.createSlot();
> Property name = supplierClass.getAttribute("name", stringPrimitiveType);
> sn.setDefiningFeature(name);
> //sn.setValue(StereoType, ..., ...)????
>
> Thank you.
>
> Hector
Re: InstanceSpecification of a Modeled Class [message #628495 is a reply to message #628492] Fri, 04 June 2010 21:02 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Some times you may want to automatically generate object diagrams without user intervention for testing purposes. Which is what I'm trying to do.

wafaa wrote on Fri, 04 June 2010 05:52
> yes, I see.
> Sorry I did not see the code :d
>
>
> but so, can you tell me why do you use code, what is its benefits than editor..(I might ask about the target of programming it)
Re: InstanceSpecification of a Modeled Class [message #628496 is a reply to message #538005] Fri, 04 June 2010 21:05 Go to previous message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Thank you Christian, it is working now. I was looking at the wrong method.

Hector

Christian W. Damus wrote on Fri, 04 June 2010 09:25
> Hi, Hector,
>
> Slots have multiple values. Get the value collection:
>
> EList<ValueSpecification> Slot::getValues()
>
> and add some kind of a ValueSpecification to it.
>
> The setValue(Stereotype, ...) method is the API on the Element type that
> sets stereotype attribute values. That has nothing to do with your
> requirement.
>
> Cheers,
>
> Christian
>
>
> On 03/06/10 03:10 PM, Hector Chavez wrote:
> > Hello,
> >
> > I have been playing with the ExtendedPO2, the example given in "Getting
> > Started with UML2" and I'm trying to create an instance of one of the
> > modeled classes using InstanceSpecification.
> >
> > What I'm doing is: I create an instance specification, then I create a
> > slot for the property "name", and then to assign a value I'm using the
> > setValue() method, but it requires a StereoType.
> > Do I have to create a stereotype for the class? or maybe this is not the
> > right approach.
> >
> >
> > InstanceSpecification is =
> > UMLFactory.eINSTANCE.createInstanceSpecification();
> > is.setName("supplierInstance");
> > is.getClassifiers().add(supplierClass);
> > Slot sn = is.createSlot();
> > Property name = supplierClass.getAttribute("name", stringPrimitiveType);
> > sn.setDefiningFeature(name);
> > //sn.setValue(StereoType, ..., ...)????
> >
> > Thank you.
> >
> > Hector
Previous Topic:Re: how to attach ocl constraint to uml class
Next Topic:Re: Help! Not understanding state machine diagram to implementation
Goto Forum:
  


Current Time: Thu Mar 28 11:44:09 GMT 2024

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

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

Back to the top