protected override void Context()
        {
            base.Context();
            _c1 = new CalculationMethod {
                Name = "C1", Category = "C"
            };
            _c1.AddSpecies(_originData.Species.Name);
            _c2 = new CalculationMethod {
                Name = "C2", Category = "C"
            };
            _c2.AddSpecies(_originData.Species.Name);
            var modelConfiguration = new ModelConfiguration();

            modelConfiguration.ModelName   = "Model";
            modelConfiguration.SpeciesName = "Species";
            var category = new CalculationMethodCategory {
                Name = "C"
            };

            category.Add(_c1);
            category.Add(_c2);
            modelConfiguration.AddCalculationMethodCategory(category);
            _oldModelProperties = new ModelProperties {
                ModelConfiguration = modelConfiguration
            };
            _newModelProperties = new ModelProperties {
                ModelConfiguration = modelConfiguration
            };
            _oldModelProperties.AddCalculationMethod(_c1);
            _newModelProperties.AddCalculationMethod(_c2);
        }
        protected override void Context()
        {
            base.Context();
            _c1 = new CalculationMethod {
                Name = "C1", Category = "C"
            };
            _c2 = new CalculationMethod {
                Name = "C2", Category = "C"
            };
            _c3 = new CalculationMethod {
                Name = "C3", Category = "AnotherCategory"
            };
            var modelConfiguration1 = new ModelConfiguration();

            modelConfiguration1.ModelName   = "Model";
            modelConfiguration1.SpeciesName = "Species";
            var category = new CalculationMethodCategory {
                Name = "C"
            };

            category.Add(_c1);
            category.Add(_c2);
            var anotherCategory = new CalculationMethodCategory {
                Name = "AnotherCategory"
            };

            anotherCategory.Add(_c3);
            var modelConfiguration2 = new ModelConfiguration();

            modelConfiguration2.ModelName   = "Model2";
            modelConfiguration2.SpeciesName = "Species2";

            modelConfiguration1.AddCalculationMethodCategory(category);
            modelConfiguration2.AddCalculationMethodCategory(category);
            modelConfiguration2.AddCalculationMethodCategory(anotherCategory);
            _oldModelProperties = new ModelProperties {
                ModelConfiguration = modelConfiguration1
            };
            _newModelProperties = new ModelProperties {
                ModelConfiguration = modelConfiguration2
            };

            _oldModelProperties.AddCalculationMethod(_c1);
            _newModelProperties.AddCalculationMethod(_c2);
            _newModelProperties.AddCalculationMethod(_c3);
        }
Esempio n. 3
0
        public ModelProperties DefaultFor(ModelConfiguration modelConfiguration, OriginData originData)
        {
            var modelProperties = new ModelProperties();

            foreach (var cmCategory in modelConfiguration.CalculationMethodCategories.Where(x => !x.IsIndividual))
            {
                modelProperties.AddCalculationMethod(cmCategory.DefaultItemForSpecies(originData.Species));
            }

            //now add origin data calculation methods
            originData.AllCalculationMethods().Each(modelProperties.AddCalculationMethod);

            modelProperties.ModelConfiguration = modelConfiguration;
            return(modelProperties);
        }
Esempio n. 4
0
        //Make sure that newly added categories in the pksim db are available
        public void UpdateCategoriesIn(ModelProperties modelProperties, OriginData originData)
        {
            var defaultModelProperties = DefaultFor(modelProperties.ModelConfiguration, originData);

            foreach (var defaultCalculationMethod in defaultModelProperties.AllCalculationMethods())
            {
                var calculationMethod = modelProperties.CalculationMethodFor(defaultCalculationMethod.Category);
                if (calculationMethod != null)
                {
                    continue;
                }

                //cm does not exist in model properties. Yet it's defined in the default=> just add the new value
                modelProperties.AddCalculationMethod(defaultCalculationMethod);
            }
        }
Esempio n. 5
0
        public ModelProperties MapFrom(ModelConfigurationDTO modelConfigurationDTO)
        {
            if (modelConfigurationDTO == null)
            {
                return(null);
            }

            var modelProperties = new ModelProperties {
                ModelConfiguration = modelConfigurationDTO.ModelConfiguration
            };

            foreach (var calculationMethodDTO in modelConfigurationDTO.CalculationMethodDTOs)
            {
                modelProperties.AddCalculationMethod(calculationMethodDTO.CalculationMethod);
            }
            return(modelProperties);
        }
Esempio n. 6
0
        public ModelProperties Update(ModelProperties oldModelProperties, ModelProperties newModelProperties, OriginData originData)
        {
            if (oldModelProperties == null)
            {
                UpdateCategoriesIn(newModelProperties, originData);
                return(newModelProperties);
            }

            var oldModelConfig = oldModelProperties.ModelConfiguration;
            var newModelConfig = newModelProperties.ModelConfiguration;

            //same species and same model=>we can return the old one
            if (areCompatible(oldModelConfig, newModelConfig))
            {
                UpdateCategoriesIn(oldModelProperties, originData);
                return(oldModelProperties);
            }

            //in that case. Try to update as much CM as we can
            foreach (var calculationMethod in newModelProperties.AllCalculationMethods().ToList())
            {
                string category             = calculationMethod.Category;
                var    oldCalculationMethod = oldModelProperties.CalculationMethodFor(category);
                var    newCategory          = newModelConfig.CalculationMethodCategories.FindByName(category);

                if (oldCalculationMethod == null || !newCategory.AllItems().Contains(oldCalculationMethod))
                {
                    continue;
                }

                newModelProperties.RemoveCalculationMethod(calculationMethod);
                newModelProperties.AddCalculationMethod(oldCalculationMethod);
            }

            return(newModelProperties);
        }