Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs
===================================================================
diff -u -rffe405e6b0f8b4d10e6be78cf7735c554eb42a93 -rf0cb7e6ac97630b32ec1b9571107e4db1bcb70d5
--- Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs (.../RingtoetsDataSynchronizationService.cs) (revision ffe405e6b0f8b4d10e6be78cf7735c554eb42a93)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs (.../RingtoetsDataSynchronizationService.cs) (revision f0cb7e6ac97630b32ec1b9571107e4db1bcb70d5)
@@ -28,7 +28,9 @@
using Ringtoets.ClosingStructures.Service;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Structures;
using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.GrassCoverErosionInwards.Service;
using Ringtoets.GrassCoverErosionOutwards.Data;
@@ -38,6 +40,7 @@
using Ringtoets.HydraRing.Data;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Service;
+using Ringtoets.Revetment.Data;
using Ringtoets.StabilityPointStructures.Data;
using Ringtoets.StabilityPointStructures.Service;
using Ringtoets.StabilityStoneCover.Data;
@@ -288,6 +291,228 @@
return list;
}
+ ///
+ /// Removes a given from the
+ /// and clears all data that depends on it, either directly or indirectly.
+ ///
+ /// The failure mechanism containing at least one profile.
+ /// The profile residing in
+ /// that should be removed.
+ /// All observable objects affected by this method.
+ /// Thrown when
+ /// or is null.
+ public static IEnumerable RemoveForeshoreProfile(HeightStructuresFailureMechanism failureMechanism, ForeshoreProfile profile)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+ if (profile == null)
+ {
+ throw new ArgumentNullException("profile");
+ }
+
+ var changedObservables = new List();
+ StructuresCalculation[] calculations = failureMechanism.Calculations
+ .Cast>()
+ .ToArray();
+ StructuresCalculation[] calculationWithRemovedForeshoreProfile = calculations
+ .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile))
+ .ToArray();
+ foreach (StructuresCalculation calculation in calculationWithRemovedForeshoreProfile)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ changedObservables.Add(calculation.InputParameters);
+ }
+
+ failureMechanism.ForeshoreProfiles.Remove(profile);
+ changedObservables.Add(failureMechanism.ForeshoreProfiles);
+
+ return changedObservables;
+ }
+
+ ///
+ /// Removes a given from the
+ /// and clears all data that depends on it, either directly or indirectly.
+ ///
+ /// The failure mechanism containing at least one profile.
+ /// The profile residing in
+ /// that should be removed.
+ /// All observable objects affected by this method.
+ /// Thrown when
+ /// or is null.
+ public static IEnumerable RemoveForeshoreProfile(ClosingStructuresFailureMechanism failureMechanism, ForeshoreProfile profile)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+ if (profile == null)
+ {
+ throw new ArgumentNullException("profile");
+ }
+
+ var changedObservables = new List();
+ StructuresCalculation[] calculations = failureMechanism.Calculations
+ .Cast>()
+ .ToArray();
+ StructuresCalculation[] calculationWithRemovedForeshoreProfile = calculations
+ .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile))
+ .ToArray();
+ foreach (StructuresCalculation calculation in calculationWithRemovedForeshoreProfile)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ changedObservables.Add(calculation.InputParameters);
+ }
+
+ failureMechanism.ForeshoreProfiles.Remove(profile);
+ changedObservables.Add(failureMechanism.ForeshoreProfiles);
+
+ return changedObservables;
+ }
+
+ ///
+ /// Removes a given from the
+ /// and clears all data that depends on it, either directly or indirectly.
+ ///
+ /// The failure mechanism containing at least one profile.
+ /// The profile residing in
+ /// that should be removed.
+ /// All observable objects affected by this method.
+ /// Thrown when
+ /// or is null.
+ public static IEnumerable RemoveForeshoreProfile(StabilityPointStructuresFailureMechanism failureMechanism, ForeshoreProfile profile)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+ if (profile == null)
+ {
+ throw new ArgumentNullException("profile");
+ }
+
+ var changedObservables = new List();
+ StructuresCalculation[] calculations = failureMechanism.Calculations
+ .Cast>()
+ .ToArray();
+ StructuresCalculation[] calculationWithRemovedForeshoreProfile = calculations
+ .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile))
+ .ToArray();
+ foreach (StructuresCalculation calculation in calculationWithRemovedForeshoreProfile)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ changedObservables.Add(calculation.InputParameters);
+ }
+
+ failureMechanism.ForeshoreProfiles.Remove(profile);
+ changedObservables.Add(failureMechanism.ForeshoreProfiles);
+
+ return changedObservables;
+ }
+
+ ///
+ /// Removes a given from the
+ /// and clears all data that depends on it, either directly or indirectly.
+ ///
+ /// The failure mechanism containing at least one profile.
+ /// The profile residing in
+ /// that should be removed.
+ /// All observable objects affected by this method.
+ /// Thrown when
+ /// or is null.
+ public static IEnumerable RemoveForeshoreProfile(StabilityStoneCoverFailureMechanism failureMechanism, ForeshoreProfile profile)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+ if (profile == null)
+ {
+ throw new ArgumentNullException("profile");
+ }
+
+ var changedObservables = new List();
+ WaveConditionsInput[] calculationInputs = failureMechanism.Calculations
+ .Cast()
+ .Select(c => c.InputParameters)
+ .ToArray();
+ changedObservables.AddRange(OnWaveConditionsInputForeshoreProfileRemoved(profile, calculationInputs));
+
+ failureMechanism.ForeshoreProfiles.Remove(profile);
+ changedObservables.Add(failureMechanism.ForeshoreProfiles);
+
+ return changedObservables;
+ }
+
+ ///
+ /// Removes a given from the
+ /// and clears all data that depends on it, either directly or indirectly.
+ ///
+ /// The failure mechanism containing at least one profile.
+ /// The profile residing in
+ /// that should be removed.
+ /// All observable objects affected by this method.
+ /// Thrown when
+ /// or is null.
+ public static IEnumerable RemoveForeshoreProfile(WaveImpactAsphaltCoverFailureMechanism failureMechanism, ForeshoreProfile profile)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+ if (profile == null)
+ {
+ throw new ArgumentNullException("profile");
+ }
+
+ var changedObservables = new List();
+ WaveConditionsInput[] calculationInputs = failureMechanism.Calculations
+ .Cast()
+ .Select(c => c.InputParameters)
+ .ToArray();
+ changedObservables.AddRange(OnWaveConditionsInputForeshoreProfileRemoved(profile, calculationInputs));
+
+ failureMechanism.ForeshoreProfiles.Remove(profile);
+ changedObservables.Add(failureMechanism.ForeshoreProfiles);
+
+ return changedObservables;
+ }
+
+ ///
+ /// Removes a given from the
+ /// and clears all data that depends on it, either directly or indirectly.
+ ///
+ /// The failure mechanism containing at least one profile.
+ /// The profile residing in
+ /// that should be removed.
+ /// All observable objects affected by this method.
+ /// Thrown when
+ /// or is null.
+ public static IEnumerable RemoveForeshoreProfile(GrassCoverErosionOutwardsFailureMechanism failureMechanism, ForeshoreProfile profile)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+ if (profile == null)
+ {
+ throw new ArgumentNullException("profile");
+ }
+
+ var changedObservables = new List();
+ WaveConditionsInput[] calculationInputs = failureMechanism.Calculations
+ .Cast()
+ .Select(c => c.InputParameters)
+ .ToArray();
+ changedObservables.AddRange(OnWaveConditionsInputForeshoreProfileRemoved(profile, calculationInputs));
+
+ failureMechanism.ForeshoreProfiles.Remove(profile);
+ changedObservables.Add(failureMechanism.ForeshoreProfiles);
+
+ return changedObservables;
+ }
+
private static IEnumerable ClearReferenceLineDependentData(IFailureMechanism failureMechanism)
{
failureMechanism.ClearAllSections();
@@ -296,5 +521,16 @@
failureMechanism
};
}
+
+ private static IEnumerable OnWaveConditionsInputForeshoreProfileRemoved(ForeshoreProfile profile, WaveConditionsInput[] calculationInputs)
+ {
+ var changedObservables = new List();
+ foreach (WaveConditionsInput input in calculationInputs.Where(input => ReferenceEquals(input.ForeshoreProfile, profile)))
+ {
+ input.ForeshoreProfile = null;
+ changedObservables.Add(input);
+ }
+ return changedObservables;
+ }
}
}
\ No newline at end of file