[QFJ-216] Support recursive custom group definitions in the code generator Created: 27/Jul/07  Updated: 27/Apr/11

Status: Open
Project: QuickFIX/J
Component/s: Message Generation
Affects Version/s: 1.2.1
Fix Version/s: Future Releases

Type: New Feature Priority: Default
Reporter: Lev Grevnin Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

windows XP/java 1.5_06



 Description   

Suppose I have the following xml message definition

<message name="FirmPrice" msgtype="UN020" msgcat="app">
<field name="Symbol" required="Y"/>
<field name="Size" required="Y"/>
<group name="NoPriceEntries" required="Y">
<component name="PriceComponent" required="Y"/>
</group>
<group name="NoLegEntries" required="N">
<component name="LegComponent" required="N"/>
</group>
</message>

...

<component name="LegComponent">
<field name="Size" required="Y"/>
<field name="Symbol" required="Y"/>
<group name="NoPriceEntries" required="Y">
<component name="PriceComponent" required="Y"/>
</group>
</component>

The message generation creates a MessageFactory.java which has the following snippet of code in it:

if("UN020".equals(msgType)) {
switch(correspondingFieldID)

{ case liquidity.quickfix.fields.NoPriceEntries.FIELD: return new liquidity.quickfix.messages.FirmPrice.NoPriceEntries(); case liquidity.quickfix.fields.NoLegEntries.FIELD: return new liquidity.quickfix.messages.FirmPrice.NoLegEntries(); case liquidity.quickfix.fields.NoPriceEntries.FIELD: return new liquidity.quickfix.messages.FirmPrice.NoLegEntries.NoPriceEntries(); }

}

This cannot compile, obviously, as it has a duplicate case label. So, it seems like the usage of a field in both, the enclosing message and the nested component is not handled properly by the generated code.

Looks like this is due to "NoPriceEntries" appearing twice: once in the main body of the message, and once in the subcomponent "LegComponent".



 Comments   
Comment by Steve Bate [ 16/Aug/07 ]

Toli, any ideas on what we should do about this issue? The only idea I have is to have a second group generation method that accepts a list of message and group fields to identify the specific nested group to create.

Comment by Toli Kuznets [ 17/Aug/07 ]

Steve,

This bug is a case of a group appearing twice in a message, once inside a "top-level" and then once again in a nested subgroup.

If QFJ were to support this case, it'll probably make sense to make it available for any deep level of nesting, right?
That becomes a much more complicated problem, right? For every level of nesting you need to keep passing some additional arguments in to be able to reconstruct how all of this is related, correct?

What does the FIX spec say about that? Can you have same groups showing up multiple times in different nested subgroups? I couldn't see the spec specifically disallowing it, so my guess is that this is allowed and we need to support it?

A message specification is a hierarchical tree, with different fields appearing in different locations. Are the group fieldIDs treated as unique IDs that specify their location? (kind of like the <id> tag in HTML?)
Looks like we are trying to flatten out a hierarchical structure that has is indexed by field names/ids. We are only specifying a fieldID per field, and it seems that it follows a built-in assumption that having only 1 fieldID is enough to specify the position of the field inside the hierarchy of the message specification.
If you have a message with repeating field names at different level of nesting, then they'll cause a collision when flattened out - which is what we are seeing with this bug.

Sounds like we may need to pass all the information/context about the level of nesting into the factory message in order to able to create the groups at the right level of nesting...

A workaround would certainly be to create more specific field types or change the name of some sub-group. Maybe create a NoPriceEntriesPerLeg ? This would be a straight-forward short-term workaround.

Comment by Lev Grevnin [ 27/Nov/07 ]

Hi. Did anyone manage to have a look at this? Is it still an issue?

Comment by Lev Grevnin [ 20/Dec/07 ]

Yes, indeed, it appears the quickfix 1.3.0 still suffers from this problem. It would be really nice to correct it.

Comment by Steve Bate [ 26/Apr/11 ]

I don't know if the specification prohibits it, but apparently there are no standard FIX group definitions that contain a repeating group of the same type (recursive group definition). Therefore, I changed this from a bug to a feature request and dropped the priority. I'm curious about whether the message parser will handle the recursive groups.

Comment by Eric Deshayes [ 27/Apr/11 ]

As it is a new feature that would have some impact on the generated classes (and therefore not be backward compatible), it is descoped from the 1.5.1 release.

Generated at Sat May 18 06:15:03 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.