This flow comes in the picture if you have parentId present in your request body and that parent campaign should be in created state.
In case a parent campaign is present-
Introduced two new columns in Campaign Details table i.e. isActive (boolean) and parentId (string).
Validate Parent Campaign (if parentId present)
If actionInUrl is create, then parentCampaign should be active or isActive of parentCampaign should be true.
If actionInUrl is update, then parentCampaign should be inActive or isActive of parentCampaign should be false.
Validate Boundaries (If parent campaign is present)
1. Boundaries array in the new campaign should contain only newly added boundaries and the existing boundaries are fetched from the parent campaign and new boundaries are formed by merging both.
If actionInUrl is create and parentCampaign is present, call the generate of templates of all three types(boundary, user, facility).
Create Project -
If new boundaries are selected in the update flow, then projects are created only for those newly added boundaries.
If existing targets are updated, then update project is called with updated project target mappings.
Edit generated facility and user sheets -
Once you are in the update campaign flow, you can edit the existing facility mappings to boundary codes and also make it inactive or active and this would subsequently update the mappings like
Project Facility and Project Staff mappings.
Retry Mechanism -
If the campaign fails, we have added a retry feature so that it can be restarted from the same point where it failed (needs more optimisation).
Once the ongoing campaign is updated and reaches the 'Created' state, the updated sheet templates (i.e., Facility, User, and Target) are consolidated back into the format used during the initial 'Create' flow.
This ensures that when you attempt to update the campaign again, it will be treated as the first update.