|
|
Re: [emf] cannot control type of id attribute in ecore model [message #719804 is a reply to message #719797] |
Mon, 29 August 2011 05:18 |
tsurdilo Messages: 41 Registered: February 2011 |
Member |
|
|
>> So EAttribute.iD is set to true? -- Yes it is.
>> Both end up mapping to java.lang.String so what exactly are you
expecting to see? -- The difference is that NCName cannot begin with a number, whereas from what I see if I change the type to EString, or ID, the id begins with a number, or it does not, seems random.
This goes back to the useless Semantic.xsd OMG schema which I have to adhere to and it forces me to use NCName for the definitions element id type. What I see is the following: if I set BaseElement id type to NCName in the ecore, I get the following output for example:
<bpmn2:definitions ... id="87B71DAE-7756-41DC-9094-3C02B29C595C">
...
<bpmn2:process ... id="_EB49660E-9F68-4B44-85F7-143F50D54961">
<bpmn2:startEvent id="_0743078E-C560-43C8-A3D8-F7937E09B955" name="">
...
</bpmn2:startEvent>
<bpmn2:endEvent id="_97B71DAE-7756-41DC-9094-3C02B29C594B" name="">
...
</bpmn2:endEvent>
</bpmn2:process>
...
</bpmn2:definitions>
All ids, except definitions root element id start with "_". This made me believe that emf adds this underscore to make sure the id does not begin with a number. However it does not apply to Definitions for some reason which also extends BaseElement, just like StartEvent, and EndEvent. The only thing I could think of was that emf generates the id of the root element differently, but as you mention that should not be so, so I'll keep digging.
Sorry if my question is confusing.
Thanks.
[Updated on: Mon, 29 August 2011 05:32] Report message to a moderator
|
|
|
Re: [emf] cannot control type of id attribute in ecore model [message #720015 is a reply to message #719804] |
Mon, 29 August 2011 16:56 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 28/08/2011 10:18 PM, tsurdilo wrote:
>>> So EAttribute.iD is set to true? -- Yes it is.
>>> Both end up mapping to java.lang.String so what exactly are you
> expecting to see? -- The difference is that NCName cannot begin with a
> number, whereas from what I see if I change the type to EString, or
> ID, the id begins with a number, or it does not, seems random.
Indeed NCName is more restrictive than EString in terms of associated
EMF constraints; what BPMN2 does with that knowledge, I can't comment on.
> This goes back to the useless Semantic.xsd OMG schema which I have to
> adhere to and it forces me to use NCName for the definitions element
> id type. What I see is the following: if I set BaseElement id type to
> NCName, I get the following output for example:
>
>
> <bpmn2:definitions ... id="87B71DAE-7756-41DC-9094-3C02B29C595C">
Some type of horrible non-human readable UUID...
> ..
> <bpmn2:process ... id="_EB49660E-9F68-4B44-85F7-143F50D54961">
> <bpmn2:startEvent id="_0743078E-C560-43C8-A3D8-F7937E09B955" name="">
> ...
> </bpmn2:startEvent>
> <bpmn2:endEvent id="_97B71DAE-7756-41DC-9094-3C02B29C594B" name="">
> ...
> </bpmn2:endEvent>
> </bpmn2:process>
> ..
> </bpmn2:definitions>
>
>
> All elements, except definitions root element start with "_". I deal
> with this now by just hard-coding the id to some string value.
> Sorry if my question is confusing. Thanks.
How BPMN2 assigns IDs is fundamentally a question those folks must
answer for you. In an ideal world, human readable IDs would be assigned...
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: [emf] cannot control type of id attribute in ecore model [message #720486 is a reply to message #720364] |
Tue, 30 August 2011 17:12 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
EMF's generated UUIDs don't have "-" in them like you've shown so it's
unlikely that the "obj.eSet(idAttr, EcoreUtil.generateUUID())" logic is
being reached. Try setting a breakpoint in the setID method to see who
is setting it when...
On 30/08/2011 6:15 AM, tsurdilo wrote:
>>> How BPMN2 assigns IDs is fundamentally a question those folks must
> answer for you. In an ideal world, human readable IDs would be
> assigned... << The API has a class I am using:
> Bpmn2ResourceImpl extends XMLResourceImpl implements Bpmn2Resource {
> ... }
>
> however it does not overwrite the generateUUID() method. It does
> override the createXMLSave() method in which the code makes sure all
> the id's are set using EcoreUtil.generateUUID():
>
> EObject cur;
> Definitions thisDefinitions = ImportHelper.getDefinitions(this);
> for (Iterator<EObject> iter = getAllContents(); iter.hasNext();) {
> cur = iter.next();
>
> setIdIfNotSet(cur);
> ....
>
>
>
> protected static void setIdIfNotSet(EObject obj) {
> if (obj.eClass() != null) {
> EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
> if (idAttr != null && !obj.eIsSet(idAttr)) {
> obj.eSet(idAttr, EcoreUtil.generateUUID());
> }
> }
> }
>
> Seems the id generation is completely deferred to EMF, there is
> nothing custom. I will create small test to try to reproduce the issue
> I am seeing and upload.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03436 seconds