예제 #1
0
        private void moveMoleculeCalculationMethod(ModelProperties modelProperties, CompoundProperties compoundProperties, string category)
        {
            var cm = modelProperties.CalculationMethodFor(category);

            if (cm == null)
            {
                return;
            }
            modelProperties.RemoveCalculationMethod(cm);
            compoundProperties.AddCalculationMethod(cm);
        }
예제 #2
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);
            }
        }
예제 #3
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);
        }