Open chrabyrd opened 2 years ago
Personally, I feel if we tweak the proposed pattern a little that some questions will answer themselves. The above Person
LabelBasedGraph is roughly what fell out of committee; below is my personal spin on the proposed pattern:
{
"@display_description": 'DISPLAY DESCRIPTION',
"@display_name": 'DISPLAY NAME',
"@graph_id": '1111111-11111-1111111',
"@legacy_id": undefined,
"@map_popup": null,
"@resource_instance_id": '2222222-22222-222222222',
"@datatype": "resource_instance",
"@nodes": [
{
"@display_name": "Name",
"@datatype": "semantic",
"@cardinality": "n",
"@node_id": "333333-3333-333333333",
"@tile_id": "444444-4444-444444444",
"@direct_children": [
{
"@display_name": "First Name",
"@datatype": "string",
"@node_id": "55555-55555-5555555",
"@tile_id": "66666-66666-6666666",
"@value": "Bob",
},
{
"@display_name": "Last Name",
"@datatype": "string",
"@node_id": "55555-55555-5555555",
"@value": undefined,
}
]
},
{
"@display_name": "Nicknames",
"@datatype": "string",
"@cardinality": "n",
"@node_id": "77777-7777-7777777",
"@value": [
{
"@tile_id": "99999-99999-999999",
"@value": "Bobert"
}
],
},
{
"@display_name": "Knacknames",
"@datatype": "string",
"@cardinality": "n",
"@node_id": "88888-88888-88888888",
"@value": undefined
},
{
"@display_name": "Eye Color",
"@datatype": "string",
"@cardinality": 1,
"@node_id": "95499-94599-99945999",
"@value": undefined
},
{
"@display_name": "Pets",
"@datatype": "resource_instance_list",
"@cardinality": "n",
"@node_id": "AAAAA-AAAA-AAAAAAA",
"@value": [
{
"@datatype": "resource_instance",
"@cardinality": 1,
"@tile_id": "CCCCC-CCCCC-CCCCCC",
"@value": "Bark Ruffalo"
},
{
"@datatype": "resource_instance",
"@cardinality": 1,
"@tile_id": "DDDDD-DDDDD-DDDDDD",
"@value": "Meowry Pawvitch"
}
],
},
]
}
With the above pattern, we get the following wins:
@nodes
and @display_name
keys, every key becomes explicit. Having keys be node names in the uncompacted graph can make iteration tricky. We could also drop the @
prefix.@type
key. Instead, the shape of @value
is derived from @datatype
+ @cardinality
@value
keynull
and undefined
values for @value
. This will help distinguish uninstantiated nodes from instantiated nodes with no value.@node_id
to @value
s of cardinality n
.@datatype
allows for later graph expansion ( eg show all related resource graphs )However, some issues still remain:
Last Name
) can look instantiated.undefined
only makes sense with JS consumption, is there a more reliable way to show instantiation?@nodes
be? Should it only exist when there are children?n
nodes ( eg Knacknames
), be undefined
or []
?@chrabyrd it feels this is a significant change to the structure. The great thing about the original one was you could following the structure using the node names as keys, making it much quicker to use it in the UI.
The HTML export templates are built around this principal. You could chain through the node names and then retrieve the @display_value
...
{{ resource_data|val_from_key:"System Reference Numbers"|val_from_key:"PrimaryReferenceNumber"|val_from_key:"Primary Reference Number"|val_from_key:"@display_value" }}
The original structure provided that "human readable" structure which felt like the original purpose. v2 added some additional metadata and the more consistent @display_value
, which was good but generally maintained the same overall pattern.
Adding additional @metadata attributes within the existing structure would be more preferable.
should the cardinality value be different datatypes?
The LabelBasedGraph is becoming further integrated into arches-core and various arches projects; this increased use has resulted in a direct need for a more descriptive data structure, additional data returned, and reduced database queries. ( Also, we should consolidate around a name )
Specifically, the proposed changes are:
Add an
@type
key ( or equivalent name ) into each node-object returned by the graph. This is meant to self describe the shape of the node-object and has the following values ( or equivalent names):node
,nodeset
,resource_instance
.nodeset
node-objects'@value
key should always be an array, and should not contain an@tileid
key.@displaydescription
,@displayname
,@graph_id
,@legacyid
,@map_popup
, and@resourceinstanceid
toresource_instance
typeThe
@value
key should only exist if the node is data-collecting.If a parent node exists, all child nodes should have a node-object even if they do not contain data. Currently this logic is based on tile presence/absence.
Consider a simplified
Person
resource:Without having seen the
Person
graph, we can infer a good deal from this:Name
,Nicknames
,Knacknames
,Eye Color
, andPets
.Name
does not collect dataName
has 2 direct child nodesFirst Name
, andLast Name
Last Name
was not instantiatedNicknames
collects data and has cardinalityn
Knacknames
has cardinalityn
, and was not instantiatedEye Color
has cardinality 1, and was not instantiatedPets
collects data and has cardinalityn
However, some questions remain:
resource_instance
types embrace proper delineation, or stay inline with the previous versions? ( eg@display_description
vs@displaydescription
)@nodes
key, or leave child nodes as top-level keys of node names?@type
is derived from cardinality. Should we not use@type
?@datatype
? Doing so could give us a unique solution for handling related resources in the future.@cardinality
?nodeset
type, there is duplication of@node_id
. Is that acceptable?map_popup
in "undefined", and that's the only place where such a value exists in the LabelBasedGraph. Should we continue only usingnull
, or should we also includeundefined
? The logic to differentiate would be the same as in JavaScript, loosely:undefined
= was not instantiated,null
= saved without a value.