jellyflow_core/ops/mutation/planner/
groups.rs1use crate::core::GroupId;
2use crate::ops::{GraphOp, GraphTransaction};
3
4use super::GraphMutationPlanner;
5use crate::ops::mutation::GraphMutationError;
6use crate::ops::mutation::collect::{bindings_for_group, detached_nodes_for_group};
7
8impl GraphMutationPlanner<'_> {
9 pub fn remove_group_op(&self, id: GroupId) -> Result<GraphOp, GraphMutationError> {
10 let group = self
11 .graph
12 .groups
13 .get(&id)
14 .cloned()
15 .ok_or(GraphMutationError::MissingGroup(id))?;
16
17 Ok(GraphOp::RemoveGroup {
18 id,
19 group,
20 detached: detached_nodes_for_group(self.graph, id),
21 bindings: bindings_for_group(self.graph, id),
22 })
23 }
24
25 pub fn remove_group_tx(
26 &self,
27 id: GroupId,
28 label: impl Into<String>,
29 ) -> Result<GraphTransaction, GraphMutationError> {
30 Ok(GraphTransaction::new()
31 .with_label(label)
32 .with_ops([self.remove_group_op(id)?]))
33 }
34}