Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Any way to set the default value for a LiteralInteger explicitly?
Any way to set the default value for a LiteralInteger explicitly? [message #1007386] Tue, 05 February 2013 17:13 Go to next message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
I'm running into a situation where I'm generating a UML2 model programmatically, then importing it into Enterprise Architect. I'm having the issue that when I have a LiteralInteger specification where the value is the same as the default (0), the lack of explicit serialization of that value results in it not being recognized by EA.

For example, in the following series of enumeration literals:

<ownedLiteral xmi:id="1" name="noInformation">
<specification xmi:type="uml:LiteralInteger" xmi:id="1_1" value="-999999"/>
</ownedLiteral>
<ownedLiteral xmi:id="2" name="unknown">
<specification xmi:type="uml:LiteralInteger" xmi:id="2_1"/>
</ownedLiteral>

the "value" for the second literal is supposed to be 0, but EMF/UML2 does not store the value since it is the same as the default.

I have a support request in to Sparx Systems about this issue, but I am wondering, in the meantime, if there is any way to "force" the UML2 API to create the "value" attribute even though it matches the default. Is this possible?
Re: Any way to set the default value for a LiteralInteger explicitly? [message #1007391 is a reply to message #1007386] Tue, 05 February 2013 17:21 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You just need to set XMLResource.OPTION_KEEP_DEFAULT_CONTENT in your
Resource save options.

Regards

Ed Willink

On 05/02/2013 17:13, Ellen Badgley wrote:
> I'm running into a situation where I'm generating a UML2 model
> programmatically, then importing it into Enterprise Architect. I'm
> having the issue that when I have a LiteralInteger specification where
> the value is the same as the default (0), the lack of explicit
> serialization of that value results in it not being recognized by EA.
> For example, in the following series of enumeration literals:
>
> <ownedLiteral xmi:id="1" name="noInformation">
> <specification xmi:type="uml:LiteralInteger" xmi:id="1_1"
> value="-999999"/>
> </ownedLiteral>
> <ownedLiteral xmi:id="2" name="unknown">
> <specification xmi:type="uml:LiteralInteger" xmi:id="2_1"/>
> </ownedLiteral>
>
> the "value" for the second literal is supposed to be 0, but EMF/UML2
> does not store the value since it is the same as the default.
>
> I have a support request in to Sparx Systems about this issue, but I
> am wondering, in the meantime, if there is any way to "force" the UML2
> API to create the "value" attribute even though it matches the
> default. Is this possible?
Re: Any way to set the default value for a LiteralInteger explicitly? [message #1007426 is a reply to message #1007391] Tue, 05 February 2013 19:48 Go to previous messageGo to next message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
Ed,

Thanks! That would do the trick.

Looking in the archives I see this subject has been discussed multiple times, but I beg your indulgence: I'm not entirely sure how OPTION_KEEP_DEFAULT_CONTENT would be set in my case, as I'm using the default resource factory for UML2 files.

(I'm also still on Indigo; haven't made the jump to Juno yet for varying reasons, but if it's unavoidable I'll do so.)
Re: Any way to set the default value for a LiteralInteger explicitly? [message #1007432 is a reply to message #1007426] Tue, 05 February 2013 20:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You just the extra options argument to Resource.save(Map).

This hasn't changed for years and years.

Regards

Ed Willink


On 05/02/2013 19:48, Ellen Badgley wrote:
> Ed,
>
> Thanks! That would do the trick.
> Looking in the archives I see this subject has been discussed multiple
> times, but I beg your indulgence: I'm not entirely sure how
> OPTION_KEEP_DEFAULT_CONTENT would be set in my case, as I'm using the
> default resource factory for UML2 files.
> (I'm also still on Indigo; haven't made the jump to Juno yet for
> varying reasons, but if it's unavoidable I'll do so.)
Re: Any way to set the default value for a LiteralInteger explicitly? [message #1007433 is a reply to message #1007432] Tue, 05 February 2013 20:23 Go to previous messageGo to next message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
Thanks. There's a lot I still don't know, as you can tell!
Re: Any way to set the default value for a LiteralInteger explicitly? [message #1007604 is a reply to message #1007433] Wed, 06 February 2013 17:20 Go to previous message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
I'm unfortunately still not getting the defaults. The code I'm using to save the resource is below:

Map<String,Boolean> options = new HashMap<String, Boolean>();
options.put(XMLResource.OPTION_KEEP_DEFAULT_CONTENT, Boolean.TRUE);
resource.save(options);


The "offending" elements are literal integers created as value specifications, for an enumeration literal or otherwise, via the following


EnumerationLiteral literal = enumeration.createOwnedLiteral(name);
...
LiteralInteger litint = org.eclipse.uml2.uml.UMLFactory.eINSTANCE
					.createLiteralInteger();
litint.setValue(Integer.parseInt(this.secondaryCode)); //the value will occasionally be 0
literal.setSpecification(litint); 
Previous Topic:Building an GMF-based editor for an definde UML-profile
Next Topic:Get All Stereotype of Element ( getAppliedStereotypes )
Goto Forum:
  


Current Time: Fri Apr 19 20:49:00 GMT 2024

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

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

Back to the top