@@ -137,26 +137,29 @@ def __configuration_mapper_factory(binding_key, configurations, default_mapping)
137
137
def mapping (index , item : Dict ):
138
138
label = item ["properties" ]["label" ] # yjg stores the neo4j node/relationship type in properties["label"]
139
139
if label in configurations and binding_key in configurations .get (label ):
140
+ if binding_key == 'parent_configuration' :
141
+ # the binding may be a lambda that must be resolved first
142
+ binding = configurations .get (label ).get (binding_key )
143
+ if callable (binding ):
144
+ binding = configurations .get (label ).get (binding_key )(item )
145
+ # parent_configuration binding may either resolve to a dict or a string
146
+ if isinstance (binding , dict ):
147
+ group_label = binding .get ('text' , '' )
148
+ else :
149
+ group_label = binding
150
+ result = 'GroupNode' + group_label
140
151
# mapping
141
- if callable (configurations .get (label )[binding_key ]):
152
+ elif callable (configurations .get (label )[binding_key ]):
142
153
result = configurations .get (label )[binding_key ](item )
143
154
# property name
144
155
elif (not isinstance (configurations .get (label )[binding_key ], dict ) and
145
156
configurations .get (label )[binding_key ] in item ["properties" ]):
146
157
result = item ["properties" ][configurations .get (label ).get (binding_key )]
147
- # constant value or dictionary
148
- elif binding_key == 'parent_configuration' :
149
- if isinstance (configurations .get (label ).get (binding_key ), dict ):
150
- result = configurations .get (label ).get (binding_key ).get ('text' , '' )
151
- else :
152
- result = configurations .get (label ).get (binding_key )
153
158
# constant value
154
159
else :
155
160
result = configurations .get (label ).get (binding_key )
156
- if binding_key != 'parent_configuration' :
157
- return result
158
- else :
159
- return 'GroupNode' + str (result )
161
+
162
+ return result
160
163
161
164
if binding_key == "label" :
162
165
return Neo4jGraphWidget .__get_neo4j_item_text (item )
@@ -183,6 +186,10 @@ def __create_group_nodes(self, configurations, widget):
183
186
label = node ['properties' ]['label' ]
184
187
if label in configurations and key in configurations .get (label ):
185
188
group_node = configurations .get (label ).get (key )
189
+
190
+ if callable (group_node ):
191
+ group_node = group_node (node )
192
+
186
193
if isinstance (group_node , str ):
187
194
# string or property value
188
195
if group_node in node ["properties" ]:
0 commit comments