protected override void ExecuteWith(IMoBiContext context)
 {
     base.ExecuteWith(context);
     _oldValueOrigin = _startValue.ValueOrigin.Clone();
     _startValue.UpdateValueOriginFrom(_newValueOrigin);
     Description = AppConstants.Commands.UpdateStartValueValueOrigin(_startValue.Path.PathAsString, _oldValueOrigin.ToString(), _newValueOrigin.ToString(), ObjectType, _buildingBlock.Name);
 }
Ejemplo n.º 2
0
 private ICommand setParameterValueOrigin(IParameter parameter, ValueOrigin newValueOrigin, bool shouldChangeVersion)
 {
     return(new UpdateParameterValueOriginCommand(parameter, newValueOrigin)
     {
         ShouldChangeVersion = shouldChangeVersion
     }.Run(_executionContext));
 }
        protected override void Context()
        {
            _parameter    = DomainHelperForSpecs.ConstantParameterWithValue(10);
            _parameter.Id = "ParameterId";
            _parameter.Origin.ParameterId    = "BuildingBlockInSimulationParameter";
            _parameter.Origin.BuilingBlockId = "BuildingBlockId";
            _parameter.Origin.SimulationId   = "SimulationId";
            _parameter.BuildingBlockType     = PKSimBuildingBlockType.Formulation;

            _valueOrigin = new ValueOrigin
            {
                Description = "Hello",
                Method      = ValueOriginDeterminationMethods.InVitro,
                Source      = ValueOriginSources.Other
            };

            _previousValueOrigin = new ValueOrigin
            {
                Description = "OldValueOrigin",
                Method      = ValueOriginDeterminationMethods.InVivo,
                Source      = ValueOriginSources.ParameterIdentification
            };

            _parameter.ValueOrigin.UpdateFrom(_previousValueOrigin);

            sut = new UpdateParameterValueOriginCommand(_parameter, _valueOrigin);

            _buildingBlockParameter    = DomainHelperForSpecs.ConstantParameterWithValue(20);
            _buildingBlockParameter.Id = _parameter.Origin.ParameterId;

            _context = A.Fake <IExecutionContext>();
            A.CallTo(() => _context.Get <IParameter>(_parameter.Id)).Returns(_parameter);
            A.CallTo(() => _context.Get <IParameter>(_buildingBlockParameter.Id)).Returns(_buildingBlockParameter);
        }
Ejemplo n.º 4
0
 protected StartValueBase()
 {
     Dimension     = Constants.Dimension.NO_DIMENSION;
     StartValue    = null;
     ContainerPath = ObjectPath.Empty;
     ValueOrigin   = new ValueOrigin();
 }
 protected override void ExecuteWith(IMoBiContext context)
 {
     base.ExecuteWith(context);
     _oldValueOrigin = _quantity.ValueOrigin.Clone();
     _quantity.ValueOrigin.UpdateFrom(_valueOrigin);
     Description = AppConstants.Commands.UpdateQuantityValueOriginInSimulation(_quantity.EntityPath(), _oldValueOrigin.ToString(), _valueOrigin.ToString(), ObjectType, _buildingBlock.Name);
 }
Ejemplo n.º 6
0
        protected override void Context()
        {
            base.Context();
            _valueOrigin1 = new ValueOrigin {
                Method = ValueOriginDeterminationMethods.Assumption
            };
            _valueOrigin2 = new ValueOrigin {
                Method = ValueOriginDeterminationMethods.Other
            };

            _distributionFormula = A.Fake <IDistributionFormula>();
            _parameter           = A.Fake <IDistributedParameter>();
            _subParameter        = A.Fake <IParameter>();
            _originData          = new OriginData {
                Age = new OriginDataParameter(40)
            };
            _distributions.Add(new ParameterDistributionMetaData {
                DistributionType = CoreConstants.Distribution.Normal, Age = 20, ValueOrigin = _valueOrigin1
            });
            _distributions.Add(new ParameterDistributionMetaData {
                DistributionType = CoreConstants.Distribution.Normal, Age = 50, ValueOrigin = _valueOrigin2
            });
            A.CallTo(() => _formulaFactory.DistributionFor(A <IEnumerable <ParameterDistributionMetaData> > ._, _parameter, _originData)).Returns(_distributionFormula);
            A.CallTo(() => _objectBaseFactory.CreateDistributedParameter()).Returns(_parameter);
            A.CallTo(() => _objectBaseFactory.CreateParameter()).Returns(_subParameter);
            A.CallTo(() => _objectBaseFactory.Create <ExplicitFormula>()).Returns(new ExplicitFormula());
            A.CallTo(() => _dimensionRepository.DimensionByName(A <string> .Ignored)).Returns(_dimension);
        }
        private Image imageFor(ValueOrigin valueOrigin)
        {
            var sourceImage = valueOrigin.Source.Icon.ToImage(IconSizes.Size16x16);

            if (valueOrigin.Method == ValueOriginDeterminationMethods.Undefined)
            {
                return(sourceImage);
            }

            var methodImage = valueOrigin.Method.Icon.ToImage(IconSizes.Size16x16);

            if (valueOrigin.Source == ValueOriginSources.Undefined)
            {
                return(methodImage);
            }

            var resultImage = new Bitmap(sourceImage.Width + methodImage.Width + IMAGE_OFFSET, sourceImage.Height);

            using (var g = Graphics.FromImage(resultImage))
            {
                g.DrawImage(sourceImage, new PointF(0, 0));
                g.DrawImage(methodImage, new PointF(sourceImage.Width + IMAGE_OFFSET, 0));
            }

            return(resultImage);
        }
Ejemplo n.º 8
0
        private void onValueOriginUpdated(ParameterDTO parameterDTO, ValueOrigin newValueOrigin)
        {
            parameterDTO.UpdateValueOriginFrom(newValueOrigin);

            //Also update first parmaeter with same value origin to test update
            _firstParmaeter.UpdateValueOriginFrom(newValueOrigin);
        }
        public override void Execute(IExecutionContext context)
        {
            _parameters.Each(p => Add(new UpdateParameterValueOriginCommand(p, _valueOrigin)
            {
                Visible = false, ShouldChangeVersion = _shouldChangeBuildingBlockVersion
            }));

            var firstCommand = All().FirstOrDefault();

            //show first command only to ensure a perfect display in history
            if (firstCommand != null)
            {
                firstCommand.Visible = true;
            }

            //update properties from first command
            this.UpdatePropertiesFrom(firstCommand);

            //now execute all commands
            base.Execute(context);

            //clear references
            _parameters  = null;
            _valueOrigin = null;
        }
        protected override void Context()
        {
            base.Context();

            _parameter1           = DomainHelperForSpecs.ConstantParameterWithValue(10).WithName("P1");
            _parameter1.IsDefault = false;

            var alternativeGroup = new ParameterAlternativeGroup().WithName("Gr");

            _parameterAlternative = new ParameterAlternative {
                _parameter1
            };
            _parameterAlternative.Name = "Alt";
            alternativeGroup.AddAlternative(_parameterAlternative);

            _newValueOrigin = new ValueOrigin
            {
                Method = ValueOriginDeterminationMethods.InVivo,
                Source = ValueOriginSources.Database
            };

            var simulation = new IndividualSimulation {
                Properties = new SimulationProperties()
            };

            A.CallTo(() => _buildingBlockRepository.All <Simulation>()).Returns(new[] { simulation });
        }
Ejemplo n.º 11
0
        protected override async Task Context()
        {
            await base.Context();

            _sameValueOrigin = _valueOrigin.Clone();
            A.CallTo(() => _valueOriginRepository.FindBy(_valueOrigin.Id)).Returns(_sameValueOrigin);
        }
        public ICommand UpdateValueOrigin(ParameterAlternative parameterAlternative, ValueOrigin newValueOrigin)
        {
            var shouldChangeBuildingBlockVersion = simulationsAreUsingAlternative(parameterAlternative);
            var updateValueOriginCommand         = new UpdateParametersValueOriginCommand(parameterAlternative.AlllParametersWithSameValueOrigin, newValueOrigin, shouldChangeBuildingBlockVersion);

            return(updateValueOriginCommand.Run(_executionContext));
        }
        public UpdateValueOriginInStartValueCommand(T startValue, ValueOrigin newValueOrigin, IStartValuesBuildingBlock <T> startValuesBuildingBlock) : base(startValuesBuildingBlock)
        {
            _startValue     = startValue;
            _newValueOrigin = newValueOrigin;

            ObjectType  = new ObjectTypeResolver().TypeFor(startValue);
            CommandType = AppConstants.Commands.EditCommand;
        }
 public IndividualSettingsDTO()
 {
     ParameterWeight         = new NullParameterDTO();
     ParameterAge            = new NullParameterDTO();
     ParameterGestationalAge = new NullParameterDTO();
     ParameterHeight         = new NullParameterDTO();
     ParameterBMI            = new NullParameterDTO();
     ValueOrigin             = new ValueOrigin();
 }
Ejemplo n.º 15
0
        public void should_return_a_combination_of_type_and_descriptiion_if_those_properties_are_set()
        {
            var display = new ValueOrigin {
                Source = ValueOriginSources.Internet, Description = "Hello"
            }.Display;

            display.Contains("Hello").ShouldBeTrue();
            display.Contains(ValueOriginSources.Internet.Display).ShouldBeTrue();
        }
 protected override void Context()
 {
     base.Context();
     _synchronizeCommand = A.Fake <IMoBiCommand>();
     _quantity           = new Parameter();
     _newValueOrigin     = new ValueOrigin {
         Method = ValueOriginDeterminationMethods.InVitro
     };
     A.CallTo(() => _quantitySynchronizer.Synchronize(_quantity, _simulation)).Returns(_synchronizeCommand);
 }
Ejemplo n.º 17
0
 protected override void Context()
 {
     base.Context();
     _valueOrigin = new ValueOrigin();
     _startValue  = new MoleculeStartValue {
         Name = "startValue"
     };
     _moleculeStartValueBuildingBlock.Add(_startValue);
     sut.Edit(_moleculeStartValueBuildingBlock);
 }
Ejemplo n.º 18
0
 protected override void Context()
 {
     base.Context();
     _valueOrigin1             = new ValueOrigin();
     _valueOrigin2             = new ValueOrigin();
     _valueOrigin1.Description = "Hello";
     _valueOrigin1.Source      = ValueOriginSources.Database;
     _valueOrigin1.Method      = ValueOriginDeterminationMethods.InVitro;
     _valueOrigin2.UpdateFrom(_valueOrigin1);
 }
Ejemplo n.º 19
0
        protected override void Context()
        {
            base.Context();
            _sourceValueOrigin = new ValueOrigin();
            _targetValueOrigin = new ValueOrigin();

            _sourceValueOrigin.Source      = ValueOriginSources.Database;
            _sourceValueOrigin.Method      = ValueOriginDeterminationMethods.InVitro;
            _sourceValueOrigin.Description = "Hello";
        }
Ejemplo n.º 20
0
 protected override void Context()
 {
     base.Context();
     _buildingBlock = A.Fake <IBuildingBlock>();
     _valueOrigin   = new ValueOrigin();
     _parameter     = new Parameter().WithId("Para");
     _parameterDTO  = new ParameterDTO(_parameter);
     A.CallTo(() => _parameterMapper.MapFrom(_parameter)).Returns(_parameterDTO);
     sut.BuildingBlock = _buildingBlock;
     sut.Edit(_parameter);
 }
Ejemplo n.º 21
0
 protected override void Context()
 {
     base.Context();
     _sourceValueOrigin = new ValueOrigin
     {
         Id          = 10,
         Description = "New description",
         Source      = ValueOriginSources.Database,
         Method      = ValueOriginDeterminationMethods.ManualFit,
     };
 }
Ejemplo n.º 22
0
        protected override void Context()
        {
            base.Context();
            _newValueOrigin = new ValueOrigin
            {
                Description = "TEXT",
                Source      = ValueOriginSources.ParameterIdentification,
                Method      = ValueOriginDeterminationMethods.ManualFit,
            };

            A.CallTo(() => _executionContext.Get <IParameter>(A <string> ._)).Returns(null);
        }
Ejemplo n.º 23
0
        protected override void Context()
        {
            base.Context();
            _newValueOrigin = new ValueOrigin
            {
                Description = "TEXT",
                Source      = ValueOriginSources.ParameterIdentification,
                Method      = ValueOriginDeterminationMethods.ManualFit,
            };

            _parameter.Origin.ParameterId = "Origin";
        }
Ejemplo n.º 24
0
        protected override void Because()
        {
            _startValue = new ParameterStartValue();
            _parameterStartValueBuildingBlock.Add(_startValue);
            _valueOrigin = new ValueOrigin
            {
                Method      = ValueOriginDeterminationMethods.Assumption,
                Description = "hello"
            };

            sut.SetValueOrigin(_parameterStartValueBuildingBlock, _valueOrigin, _startValue);
        }
Ejemplo n.º 25
0
        private ICommand updateValueOriginCommand(IdentificationParameter identificationParameter, IParameter parameter, ISimulation simulation)
        {
            var isoDate     = SystemTime.Now().ToIsoFormat();
            var valueOrigin = new ValueOrigin
            {
                Description = Captions.ParameterIdentification.ValueUpdatedFrom(identificationParameter.ParameterIdentification.Name, isoDate),
                Source      = ValueOriginSources.ParameterIdentification,
                Method      = ValueOriginDeterminationMethods.ParameterIdentification
            };

            return(_parameterTask.UpdateParameterValueOrigin(parameter, valueOrigin, simulation));
        }
Ejemplo n.º 26
0
        protected override void Context()
        {
            base.Context();
            _parameterToReset.Value = 25;
            _parameterToReset.ValueOrigin.Method = ValueOriginDeterminationMethods.ManualFit;
            _parameterToReset.ValueOrigin.Source = ValueOriginSources.ParameterIdentification;
            var valueOrigin = new ValueOrigin
            {
                Method = ValueOriginDeterminationMethods.Assumption,
                Source = ValueOriginSources.Internet,
            };

            A.CallTo(() => _parameterInContainerRepository.ValueOriginFor(_parameterToReset)).Returns(valueOrigin);
        }
        protected override void Context()
        {
            _view = A.Fake <IValueOriginView>();
            sut   = new ValueOriginPresenter(_view);

            _valueOriginToEdit = new ValueOrigin
            {
                Source      = _originalSource,
                Description = _originalDescription,
            };


            A.CallTo(() => _view.BindTo(A <ValueOrigin> ._)).Invokes(x => _dto = x.GetArgument <ValueOrigin>(0));
        }
Ejemplo n.º 28
0
        protected override Task Context()
        {
            _valueOriginRepository = A.Fake <IValueOriginRepository>();

            sut = new ValueOriginMapper(_valueOriginRepository);

            _valueOrigin = new ValueOrigin
            {
                Id     = 5,
                Source = ValueOriginSources.Database,
                Method = ValueOriginDeterminationMethods.InVitro
            };

            return(_completed);
        }
Ejemplo n.º 29
0
        protected override void Context()
        {
            _parameters = new List <IParameter>();
            _parameter1 = DomainHelperForSpecs.ConstantParameterWithValue(10);
            _parameter2 = DomainHelperForSpecs.ConstantParameterWithValue(10);

            _valueOrigin = new ValueOrigin
            {
                Method      = ValueOriginDeterminationMethods.Assumption,
                Source      = ValueOriginSources.Other,
                Description = "Hello"
            };

            _context = A.Fake <IExecutionContext>();

            sut = new UpdateParametersValueOriginCommand(_parameters, _valueOrigin);
        }
Ejemplo n.º 30
0
        public SuperToolTip ToolTipFor(ValueOrigin valueOrigin)
        {
            if (valueOrigin.Source == ValueOriginSources.Undefined)
            {
                return(null);
            }

            var title = new[]
            {
                valueOrigin.Source.Display, valueOrigin.Method.Display
            }.Where(x => !string.IsNullOrWhiteSpace(x)).ToString(" - ");

            if (string.IsNullOrEmpty(valueOrigin.Description))
            {
                return(CreateToolTip(title, withIcon: valueOrigin.Source));
            }

            return(CreateToolTip(valueOrigin.Description, title, withIcon: valueOrigin.Source));
        }