Any way to set the default value for a LiteralInteger explicitly? [message #1007386] |
Tue, 05 February 2013 12:13  |
Eclipse User |
|
|
|
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 #1007604 is a reply to message #1007433] |
Wed, 06 February 2013 12:20  |
Eclipse User |
|
|
|
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);
|
|
|
Powered by
FUDForum. Page generated in 0.57893 seconds