27
27
PlanFeatureLayer ,
28
28
PlanLayer ,
29
29
PlanRegulationLayer ,
30
+ RegulationGroupAssociationLayer ,
30
31
RegulationGroupLayer ,
31
32
plan_layers ,
32
33
)
@@ -229,7 +230,7 @@ def save_plan(plan_data: Plan) -> QgsFeature:
229
230
for regulation_group in plan_data .general_regulations :
230
231
plan_id = plan_feature ["id" ]
231
232
regulation_group_feature = save_regulation_group (regulation_group , plan_id )
232
- save_regulation_grop_assosiation ( plan_id , regulation_group_feature ["id" ])
233
+ save_regulation_group_association ( regulation_group_feature ["id" ], PlanLayer . name , plan_id )
233
234
234
235
return plan_feature
235
236
@@ -250,11 +251,9 @@ def save_plan_feature(plan_feature: PlanFeature, plan_id: str | None = None) ->
250
251
if not layer_class :
251
252
msg = f"Could not find plan feature layer class for layer name { plan_feature .layer_name } "
252
253
raise ValueError (msg )
253
- feature = layer_class .feature_from_model (plan_feature )
254
- layer = layer_class .get_from_project ()
255
254
256
- if plan_id :
257
- feature [ "plan_id" ] = plan_id
255
+ feature = layer_class . feature_from_model ( plan_feature , plan_id )
256
+ layer = layer_class . get_from_project ()
258
257
259
258
_save_feature (
260
259
feature = feature ,
@@ -266,7 +265,8 @@ def save_plan_feature(plan_feature: PlanFeature, plan_id: str | None = None) ->
266
265
# Handle regulation groups
267
266
if plan_feature .regulation_groups :
268
267
for group in plan_feature .regulation_groups :
269
- save_regulation_group (group )
268
+ regulation_group_feature = save_regulation_group (group )
269
+ save_regulation_group_association (regulation_group_feature ["id" ], plan_feature .layer_name , feature ["id" ])
270
270
271
271
return feature
272
272
@@ -291,8 +291,13 @@ def save_regulation_group(regulation_group: RegulationGroup, plan_id: str | None
291
291
return feature
292
292
293
293
294
- def save_regulation_grop_assosiation (plan_id : str , regulation_group_id : str ):
295
- pass
294
+ def save_regulation_group_association (regulation_group_id : str , layer_name : str , feature_id : str ) -> QgsFeature :
295
+ feature = RegulationGroupAssociationLayer .feature_from (regulation_group_id , layer_name , feature_id )
296
+ layer = RegulationGroupAssociationLayer .get_from_project ()
297
+
298
+ _save_feature (feature = feature , layer = layer , id_ = None , edit_text = "Kaavamääräysryhmän assosiaation lisäys" )
299
+
300
+ return feature
296
301
297
302
298
303
def save_regulation (regulation : Regulation ) -> QgsFeature :
0 commit comments