// Copyright (C) Stichting Deltares 2018. All rights reserved.
//
// This file is part of the Dam Engine.
//
// The Dam Engine is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System.Collections.Generic;
using Deltares.DamEngine.Data.General;
using Deltares.DamEngine.Data.General.Results;
using Deltares.DamEngine.Data.Standard.Calculation;
namespace Deltares.DamEngine.Data.RegionalAssessmentResults
{
///
/// Class holding evaluation job
///
public class EvaluationJob
{
private string dikeName = "";
private List locations = new List();
private List failedEvaluatedLocations = new List();
private List results = new List();
///
/// Gets or sets the name of the dike.
///
///
/// The name of the dike.
///
public string DikeName
{
get { return dikeName; }
set { dikeName = value; }
}
///
/// Gets or sets the locations.
///
///
/// The locations.
///
public List Locations
{
get { return locations; }
set { locations = value; }
}
///
/// Gets or sets the results.
///
///
/// The results.
///
public List Results
{
get { return results; }
set { results = value; }
}
///
/// Gets or sets the failed evaluated locations.
///
///
/// The failed evaluated locations.
///
public List FailedEvaluatedLocations
{
get { return failedEvaluatedLocations; }
set { failedEvaluatedLocations = value; }
}
///
/// Attaches the results.
///
/// The location jobs.
public void AttachResults(IEnumerable locationJobs)
{
foreach (LocationJob locationJob in locationJobs)
{
foreach (Location location in this.locations)
{
if (locationJob.Location.Name.Equals(location.Name))
{
if (locationJob.LocationResult == null)
{
locationJob.LocationResult = new LocationResult();
}
if ((this.locations.IndexOf(location) < 0) || (this.locations.IndexOf(location) >= this.results.Count))
{
var failedRes = new RegionalScenariosResult();
failedRes.CalculationResult = CalculationResult.UnexpectedError;
locationJob.LocationResult.RegionalScenariosResult = failedRes;
}
else
{
locationJob.LocationResult.RegionalScenariosResult = this.results[this.locations.IndexOf(location)];
}
}
}
}
}
}
}