I’m trying to describe a union on a reference set in a collection with an acyclic graph constraint. This is what I have:
'Partijen': collection ['Partij'] = ^ ^ .'Partijen'* .'Soort partij'?'Deelpartij'.'Bewerkingen'.'Etiketteren'?'Ja'.'Ingepland'?'Ja'.'Uitgevoerd'?'Nee' {
'Partij': text -> ^ ^ ^ .'Partijen'[] .'Soort partij'?'Deelpartij'.'Bewerkingen'.'Etiketteren'?'Ja'.'Ingepland'?'Ja'.'Uitgevoerd'?'Nee'
= key
'Deelpartijen': collection ['Partij'] = union (
'In partij' = >'Partij' ^ ^ ^ ^ ^ <'Deelpartijen'[ ^ ^ ^ .'Partijen' sibling * ] // <-- errors here!
) {
'Partij': text -> ^ ^ ^ ^ .'Partijen'[] = key
}
...
}
But this results in 2 errors I don’t understand and can’t resolve:
equality constraint violation for ‘dependency of reference set’:
- expected: ‘dependency’ of type ‘step’
defined by .‘Productie’.‘Etiketteren’.‘Partijen’.‘Partij’ of type ‘erface_notification/schema.alan.json’!‘node’.‘attributes’.‘type’?‘property’.‘type’?‘text’.‘has reference’?‘yes’
- but found: ‘dependency’ of type ‘self’
defined by .<root> of type ‘erface_notification/schema.alan.json’
no valid ‘head node type’ found for ‘type’ option ‘sibling’. Unexpected ‘value object’:
- expected: ‘node’
- but found: ‘collection’
defined by .‘Partijen’ of type ‘erface_notification/schema.alan.json’!‘node’.‘attributes’.‘type’?‘property’
I tried several combinations of node path, sibling and * without success.
When making a union based on a reference-set, the key of the derived collection needs to be the identical path as the path between [ ].
So in your example:
'Partij': text -> ^ ^ ^ .'Partijen' sibling = key
or alternatively:
<'Deelpartijen' [ ^ ^ ^ ^ .'Partijen' * ]
Unfortunately this solutions results in an error as well:
'Partijen': collection ['Partij'] = ^ ^ .'Partijen'* .'Soort partij'?'Deelpartij'.'Bewerkingen'.'Etiketteren'?'Ja'.'Ingepland'?'Ja'.'Uitgevoerd'?'Nee' {
'Partij': text -> ^ ^ ^ .'Partijen'[] .'Soort partij'?'Deelpartij'.'Bewerkingen'.'Etiketteren'?'Ja'.'Ingepland'?'Ja'.'Uitgevoerd'?'Nee'
= key
'Deelpartijen': collection ['Partij'] = union (
'In partij' = >'Partij' ^ ^ ^ ^ ^ <'Deelpartijen'[ ^ ^ ^ .'Partijen'* ] // <-- error between [ ] !
) {
'Partij': text -> ^ ^ ^ ^ .'Partijen'[] = key
}
...
}
With error message:
equality constraint violation for ‘dependency of reference set’:
- expected: ‘relative object location’ of type ‘sibling entity’
defined by .‘Partijen’.‘Bron’ of type ‘erface_notification/schema.alan.json’!‘graph constraints definition’.‘graphs’
- but found: ‘relative object location’ of type ‘context entity’
defined by .‘Partijen’ of type ‘erface_notification/schema.alan.json’!‘node’.‘attributes’.‘type’?‘property’
Which to me indicates I need to use sibling somehow.
According to the grammar this should be possible, but I can’t seem to figure out how:
'reference set subset step' {
'subset': stategroup (
'no' { [ * ] }
'yes' { [ [, ] ]
'head': component 'variablized object path'
'type': [, * ] stategroup (
'simple' { }
'sibling' { [ sibling ] } // <-- !!
)
}
)
}
Try
[ >'Partij' ^ ^ ^ ^ ^ sibling ]
And define the key accordingly.
Thanks! That did it. Only needed an asterisk (*) at the end:
'Deelpartijen': collection ['Partij'] = union (
'In partij' = >'Partij' ^ ^ ^ ^ ^ <'Deelpartijen'[ >'Partij' ^ ^ ^ ^ ^ sibling * ]
) { ... }
I have a similar issue. I wish to create a collection that represents siblings for the same supplier. How can I achieve this?
'Sibling Purchase Orders': collection ['Purchase Order'] = union (
'' = >'Supplier'<'Purchase Orders'[ ^ sibling * ]
) @hidden {
'Purchase Order': text -> ^ sibling = key
}
This results in the following error:
state constraint violation for ‘sibling reference set’. Unexpected state for ‘root’:
- expected: ‘sibling’ at /home/coder/project/models/model/application.alan:3687:42 to 3687:51
- but found: ‘context’ at /home/coder/project/models/model/application.alan:3525:70 to 3525:70
defined by .‘Suppliers’.‘Purchase Orders’ of type ‘application’!‘node’.‘attributes’.‘type’?‘reference set’.‘referenced type path’ at /home/coder/project/models/model/application.alan:3525:70 to 3525:70
More context. I wanted to use it in an action, but only enable a user to chose from Purchase Orders with the same Supplier. If fixed it with a where-rule.
'Copy Order Line': action {
'Delivery Date': number 'date' @default: ^ ^ .'Delivery Date'
'Purchase Order': stategroup (
'Existing' {
'Purchase Order': text -> ^ ^ ^ sibling as $'p'
where 'Supplier' -> $'p'>'Supplier' is ( ^ ^ >'Supplier' )
}
'New' { }
)
}
1 Like