public ICoreCalculationMethod MapFrom(string calculationMethod) { var modelCalcMethod = new CoreCalculationMethod { Name = calculationMethod }; modelCalcMethod.Category = _calculationMethodRepository.FindBy(calculationMethod).Category; var allRates = from cmr in _flatCalculationMethodParameterRateRepository.All() where cmr.CalculationMethod.Equals(calculationMethod) select cmr; foreach (var parameterRate in allRates) { var descriptor = descriptorCriteriaFrom(parameterRate.ParameterId); if (parameterRate.IsOutputParameter) { var paramDescriptor = new ParameterDescriptor(parameterRate.ParameterName, descriptor); modelCalcMethod.AddOutputFormula(_formulaFactory.RateFor(parameterRate.CalculationMethod, parameterRate.Rate, new FormulaCache()), paramDescriptor); } else { var parameterRateMetaData = new ParameterRateMetaData { BuildingBlockType = PKSimBuildingBlockType.Simulation, BuildMode = ParameterBuildMode.Local, CalculationMethod = parameterRate.CalculationMethod, CanBeVaried = parameterRate.CanBeVaried, CanBeVariedInPopulation = parameterRate.CanBeVariedInPopulation, Dimension = parameterRate.Dimension, GroupName = parameterRate.GroupName, ReadOnly = parameterRate.ReadOnly, MinValue = parameterRate.MinValue, MaxValue = parameterRate.MaxValue, MinIsAllowed = parameterRate.MinIsAllowed, MaxIsAllowed = parameterRate.MaxIsAllowed, ParameterName = parameterRate.ParameterName, Rate = parameterRate.Rate, Visible = parameterRate.Visible, Sequence = parameterRate.Sequence }; var helpParameter = _parameterFactory.CreateFor(parameterRateMetaData, new FormulaCache()); modelCalcMethod.AddHelpParameter(helpParameter, descriptor); } } return(modelCalcMethod); }
protected override void Context() { base.Context(); _allCoreCalculationMethods = new List <ICoreCalculationMethod>(); _simulation = new IndividualSimulation { Properties = new SimulationProperties() }; var compound1 = new Compound().WithName("C1"); var compound2 = new Compound().WithName("C2"); _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("C1", PKSimBuildingBlockType.Compound) { BuildingBlock = compound1 }); _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("C2", PKSimBuildingBlockType.Compound) { BuildingBlock = compound2 }); var cm1 = new CalculationMethod { Category = "MOLECULE" }.WithName("CM1"); var cm2 = new CalculationMethod { Category = "MOLECULE" }.WithName("CM2"); var cm3 = new CalculationMethod { Category = "MOLECULE" }.WithName("CM3"); var cm5 = new CalculationMethod { Category = "NOT MOLECULE" }.WithName("CM5"); A.CallTo(() => _calculationMethodCategoryRepository.FindBy("MOLECULE")).Returns(new CalculationMethodCategory { CategoryType = CategoryType.Molecule }); A.CallTo(() => _calculationMethodCategoryRepository.FindBy("NOT MOLECULE")).Returns(new CalculationMethodCategory { CategoryType = CategoryType.Individual }); var cp1 = new CompoundProperties { Compound = compound1 }; var cp2 = new CompoundProperties { Compound = compound2 }; _simulation.Properties.AddCompoundProperties(cp1); _simulation.Properties.AddCompoundProperties(cp2); cp1.AddCalculationMethod(cm1); cp1.AddCalculationMethod(cm2); cp2.AddCalculationMethod(cm2); cp2.AddCalculationMethod(cm3); cp2.AddCalculationMethod(cm5); _coreCM1 = new CoreCalculationMethod { Name = cm1.Name }; _coreCM2 = new CoreCalculationMethod { Name = cm2.Name }; _coreCM3 = new CoreCalculationMethod { Name = cm3.Name }; _coreCM4 = new CoreCalculationMethod { Name = "TOTO" }; _coreCM5 = new CoreCalculationMethod { Name = cm5.Name }; _allCoreCalculationMethods.Add(_coreCM1); _allCoreCalculationMethods.Add(_coreCM2); _allCoreCalculationMethods.Add(_coreCM3); _allCoreCalculationMethods.Add(_coreCM4); _allCoreCalculationMethods.Add(_coreCM5); A.CallTo(() => _coreCalculationMethodRepository.All()).Returns(_allCoreCalculationMethods); }