Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Merge/AssessmentSectionMergeHandler.cs
===================================================================
diff -u -re35ffc492405e22b041aee22033f7ebc4b942036 -rc08ebb644861c250c6cbff98edfcb438528cb73f
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Merge/AssessmentSectionMergeHandler.cs (.../AssessmentSectionMergeHandler.cs) (revision e35ffc492405e22b041aee22033f7ebc4b942036)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Merge/AssessmentSectionMergeHandler.cs (.../AssessmentSectionMergeHandler.cs) (revision c08ebb644861c250c6cbff98edfcb438528cb73f)
@@ -32,13 +32,11 @@
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Data.Structures;
-using Ringtoets.DuneErosion.Data;
using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.GrassCoverErosionOutwards.Data;
using Ringtoets.HeightStructures.Data;
using Ringtoets.Integration.Data;
using Ringtoets.Integration.Data.Merge;
-using Ringtoets.Integration.Data.StandAlone;
using Ringtoets.Integration.Plugin.Properties;
using Ringtoets.MacroStabilityInwards.Data;
using Ringtoets.Piping.Data;
@@ -95,7 +93,7 @@
};
changedObjects.AddRange(MergeHydraulicBoundaryLocations(targetAssessmentSection, mergeData.AssessmentSection));
- MergeFailureMechanisms(targetAssessmentSection, mergeData.FailureMechanisms);
+ MergeFailureMechanisms(targetAssessmentSection, mergeData);
AfterMerge(changedObjects);
}
@@ -181,176 +179,143 @@
/// Merge the failure mechanism to the .
///
/// The assessment section to merge to.
- /// The failure mechanisms to merge.
- /// Thrown when
- /// contains an element that can't be merged.
- private static void MergeFailureMechanisms(AssessmentSection targetAssessmentSection, IEnumerable failureMechanismsToMerge)
+ /// The data to merge.
+ private static void MergeFailureMechanisms(AssessmentSection targetAssessmentSection, AssessmentSectionMergeData mergeData)
{
ObservableList hydraulicBoundaryLocations = targetAssessmentSection.HydraulicBoundaryDatabase.Locations;
- foreach (IFailureMechanism failureMechanism in failureMechanismsToMerge)
+ AssessmentSection sourceAssessmentSection = mergeData.AssessmentSection;
+
+ if (mergeData.MergePiping)
{
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.Piping = mechanism))
- {
- UpdateCalculationHydraulicBoundaryLocationReferences(
- targetAssessmentSection.Piping, hydraulicBoundaryLocations);
- continue;
- }
+ targetAssessmentSection.Piping = sourceAssessmentSection.Piping;
+ UpdateCalculationHydraulicBoundaryLocationReferences(
+ targetAssessmentSection.Piping, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.Piping);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.GrassCoverErosionInwards = mechanism))
- {
- UpdateCalculationHydraulicBoundaryLocationReferences(
- targetAssessmentSection.GrassCoverErosionInwards, hydraulicBoundaryLocations);
- continue;
- }
+ if (mergeData.MergeGrassCoverErosionInwards)
+ {
+ targetAssessmentSection.GrassCoverErosionInwards = sourceAssessmentSection.GrassCoverErosionInwards;
+ UpdateCalculationHydraulicBoundaryLocationReferences(
+ targetAssessmentSection.GrassCoverErosionInwards, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.GrassCoverErosionInwards);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.MacroStabilityInwards = mechanism))
- {
- UpdateCalculationHydraulicBoundaryLocationReferences(
- targetAssessmentSection.MacroStabilityInwards, hydraulicBoundaryLocations);
- continue;
- }
+ if (mergeData.MergeMacroStabilityInwards)
+ {
+ targetAssessmentSection.MacroStabilityInwards = sourceAssessmentSection.MacroStabilityInwards;
+ UpdateCalculationHydraulicBoundaryLocationReferences(
+ targetAssessmentSection.MacroStabilityInwards, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.MacroStabilityInwards);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.MacroStabilityOutwards = mechanism))
- {
- continue;
- }
+ if (mergeData.MergeMacroStabilityOutwards)
+ {
+ targetAssessmentSection.MacroStabilityOutwards = sourceAssessmentSection.MacroStabilityOutwards;
+ LogMergeMessage(targetAssessmentSection.MacroStabilityOutwards);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.Microstability = mechanism))
- {
- continue;
- }
+ if (mergeData.MergeMicrostability)
+ {
+ targetAssessmentSection.Microstability = sourceAssessmentSection.Microstability;
+ LogMergeMessage(targetAssessmentSection.Microstability);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.StabilityStoneCover = mechanism))
- {
- UpdateCalculationHydraulicBoundaryLocationReferences(
- targetAssessmentSection.StabilityStoneCover, hydraulicBoundaryLocations);
- continue;
- }
+ if (mergeData.MergeStabilityStoneCover)
+ {
+ targetAssessmentSection.StabilityStoneCover = sourceAssessmentSection.StabilityStoneCover;
+ UpdateCalculationHydraulicBoundaryLocationReferences(
+ targetAssessmentSection.StabilityStoneCover, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.StabilityStoneCover);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.WaveImpactAsphaltCover = mechanism))
- {
- UpdateCalculationHydraulicBoundaryLocationReferences(
- targetAssessmentSection.WaveImpactAsphaltCover, hydraulicBoundaryLocations);
- continue;
- }
+ if (mergeData.MergeWaveImpactAsphaltCover)
+ {
+ targetAssessmentSection.WaveImpactAsphaltCover = sourceAssessmentSection.WaveImpactAsphaltCover;
+ UpdateCalculationHydraulicBoundaryLocationReferences(
+ targetAssessmentSection.WaveImpactAsphaltCover, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.WaveImpactAsphaltCover);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.WaterPressureAsphaltCover = mechanism))
- {
- continue;
- }
+ if (mergeData.MergeWaterPressureAsphaltCover)
+ {
+ targetAssessmentSection.WaterPressureAsphaltCover = sourceAssessmentSection.WaterPressureAsphaltCover;
+ LogMergeMessage(targetAssessmentSection.WaterPressureAsphaltCover);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.GrassCoverErosionOutwards = mechanism))
- {
- UpdateLocationCalculationHydraulicBoundaryLocationReferences(targetAssessmentSection.GrassCoverErosionOutwards, hydraulicBoundaryLocations);
- UpdateCalculationHydraulicBoundaryLocationReferences(
- targetAssessmentSection.GrassCoverErosionOutwards, hydraulicBoundaryLocations);
- continue;
- }
+ if (mergeData.MergeGrassCoverErosionOutwards)
+ {
+ targetAssessmentSection.GrassCoverErosionOutwards = sourceAssessmentSection.GrassCoverErosionOutwards;
+ UpdateLocationCalculationHydraulicBoundaryLocationReferences(targetAssessmentSection.GrassCoverErosionOutwards, hydraulicBoundaryLocations);
+ UpdateCalculationHydraulicBoundaryLocationReferences(
+ targetAssessmentSection.GrassCoverErosionOutwards, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.GrassCoverErosionOutwards);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.GrassCoverSlipOffOutwards = mechanism))
- {
- continue;
- }
+ if (mergeData.MergeGrassCoverSlipOffOutwards)
+ {
+ targetAssessmentSection.GrassCoverSlipOffOutwards = sourceAssessmentSection.GrassCoverSlipOffOutwards;
+ LogMergeMessage(targetAssessmentSection.GrassCoverSlipOffOutwards);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.GrassCoverSlipOffInwards = mechanism))
- {
- continue;
- }
+ if (mergeData.MergeGrassCoverSlipOffInwards)
+ {
+ targetAssessmentSection.GrassCoverSlipOffInwards = sourceAssessmentSection.GrassCoverSlipOffInwards;
+ LogMergeMessage(targetAssessmentSection.GrassCoverSlipOffInwards);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.HeightStructures = mechanism))
- {
- UpdateCalculationHydraulicBoundaryLocationReferences, HeightStructuresInput>(
- targetAssessmentSection.HeightStructures, hydraulicBoundaryLocations);
- continue;
- }
+ if (mergeData.MergeHeightStructures)
+ {
+ targetAssessmentSection.HeightStructures = sourceAssessmentSection.HeightStructures;
+ UpdateCalculationHydraulicBoundaryLocationReferences, HeightStructuresInput>(
+ targetAssessmentSection.HeightStructures, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.HeightStructures);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.ClosingStructures = mechanism))
- {
- UpdateCalculationHydraulicBoundaryLocationReferences, ClosingStructuresInput>(
- targetAssessmentSection.ClosingStructures, hydraulicBoundaryLocations);
- continue;
- }
+ if (mergeData.MergeClosingStructures)
+ {
+ targetAssessmentSection.ClosingStructures = sourceAssessmentSection.ClosingStructures;
+ UpdateCalculationHydraulicBoundaryLocationReferences, ClosingStructuresInput>(
+ targetAssessmentSection.ClosingStructures, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.ClosingStructures);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.PipingStructure = mechanism))
- {
- continue;
- }
+ if (mergeData.MergePipingStructure)
+ {
+ targetAssessmentSection.PipingStructure = sourceAssessmentSection.PipingStructure;
+ LogMergeMessage(targetAssessmentSection.PipingStructure);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.StabilityPointStructures = mechanism))
- {
- UpdateCalculationHydraulicBoundaryLocationReferences, StabilityPointStructuresInput>(
- targetAssessmentSection.StabilityPointStructures, hydraulicBoundaryLocations);
- continue;
- }
+ if (mergeData.MergeStabilityPointStructures)
+ {
+ targetAssessmentSection.StabilityPointStructures = sourceAssessmentSection.StabilityPointStructures;
+ UpdateCalculationHydraulicBoundaryLocationReferences, StabilityPointStructuresInput>(
+ targetAssessmentSection.StabilityPointStructures, hydraulicBoundaryLocations);
+ LogMergeMessage(targetAssessmentSection.StabilityPointStructures);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.StrengthStabilityLengthwiseConstruction = mechanism))
- {
- continue;
- }
+ if (mergeData.MergeStrengthStabilityLengthwiseConstruction)
+ {
+ targetAssessmentSection.StrengthStabilityLengthwiseConstruction = sourceAssessmentSection.StrengthStabilityLengthwiseConstruction;
+ LogMergeMessage(targetAssessmentSection.StrengthStabilityLengthwiseConstruction);
+ }
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.DuneErosion = mechanism))
- {
- continue;
- }
-
- if (TryMergeFailureMechanism(
- targetAssessmentSection, failureMechanism,
- (section, mechanism) => section.TechnicalInnovation = mechanism))
- {
- continue;
- }
-
- throw new NotSupportedException("Failure mechanism can't be merged.");
+ if (mergeData.MergeDuneErosion)
+ {
+ targetAssessmentSection.DuneErosion = sourceAssessmentSection.DuneErosion;
+ LogMergeMessage(targetAssessmentSection.DuneErosion);
}
- }
- private static bool TryMergeFailureMechanism(AssessmentSection targetAssessmentSection, IFailureMechanism failureMechanismToMerge,
- Action mergeFailureMechanismAction)
- where TFailureMechanism : class, IFailureMechanism
- {
- var failureMechanism = failureMechanismToMerge as TFailureMechanism;
- if (failureMechanism != null)
+ if (mergeData.MergeTechnicalInnovation)
{
- mergeFailureMechanismAction(targetAssessmentSection, failureMechanism);
- log.InfoFormat(Resources.AssessmentSectionMergeHandler_TryMergeFailureMechanism_FailureMechanism_0_replaced, failureMechanism.Name);
- return true;
+ targetAssessmentSection.TechnicalInnovation = sourceAssessmentSection.TechnicalInnovation;
+ LogMergeMessage(targetAssessmentSection.TechnicalInnovation);
}
+ }
- return false;
+ private static void LogMergeMessage(IFailureMechanism failureMechanism)
+ {
+ log.InfoFormat(Resources.AssessmentSectionMergeHandler_TryMergeFailureMechanism_FailureMechanism_0_replaced, failureMechanism.Name);
}
private static void UpdateCalculationHydraulicBoundaryLocationReferences(