Esempio n. 1
0
 protected CreateProcessPresenter(TView view, IParametersByGroupPresenter parametersPresenter, ICompoundProcessToCompoundProcessDTOMapper processMapper,
                                  ICompoundProcessTask compoundProcessTask, ISpeciesRepository speciesRepository)
     : base(view)
 {
     _parametersPresenter = parametersPresenter;
     _processMapper       = processMapper;
     _compoundProcessTask = compoundProcessTask;
     _speciesRepository   = speciesRepository;
     _view.AddParametersView(_parametersPresenter.View);
     _editCommands = new PKSimMacroCommand();
 }
 protected override void Because()
 {
     _resultOfScaleIndividual = sut.ScaleIndividual(_sourceIndividual) as IPKSimMacroCommand;
 }
 protected override void Because()
 {
     _resultOfCreateIndividual = sut.Create() as IPKSimMacroCommand;
 }
Esempio n. 4
0
        private ICommand synchronizeBuildingBlocks(IPKSimBuildingBlock templateBuildingBlock, IPKSimMacroCommand updateTemplateParametersCommand)
        {
            var simulationSubject = templateBuildingBlock as ISimulationSubject;

            //For now, deal with update from Individual or Population into Expression Profile
            if (simulationSubject == null)
            {
                return(new PKSimEmptyCommand());
            }

            var allExpressionProfileParameterValueCommand = updateTemplateParametersCommand.All()
                                                            .OfType <SetExpressionProfileValueCommand>()
                                                            .ToList();

            if (!allExpressionProfileParameterValueCommand.Any())
            {
                return(new PKSimEmptyCommand());
            }


            var expressionProfilesToUpdate = new HashSet <ExpressionProfile>();
            var macroCommand = new PKSimMacroCommand();

            //We have some commands related to expression profile. We need to update the expression profile
            foreach (var parameterCommand in allExpressionProfileParameterValueCommand)
            {
                var simulationSubjectParameter = _executionContext.Get <IParameter>(parameterCommand.ParameterId);
                if (simulationSubjectParameter == null)
                {
                    continue;
                }

                //This should be the id of the parameter in the expression profile
                var expressionProfileParameterId = simulationSubjectParameter.Origin.ParameterId;
                var expressionProfileParameter   = _executionContext.Get <IParameter>(expressionProfileParameterId);
                if (expressionProfileParameter == null)
                {
                    continue;
                }

                var expressionProfile = _executionContext.BuildingBlockContaining(expressionProfileParameter) as ExpressionProfile;
                if (expressionProfile == null)
                {
                    continue;
                }

                expressionProfilesToUpdate.Add(expressionProfile);

                //We do not update the simulation subject. It will be done at the end of the loop
                var command = new SetExpressionProfileValueCommand(expressionProfileParameter, simulationSubjectParameter.Value, updateSimulationSubjects: false);
                macroCommand.Add(command);
            }

            macroCommand.Run(_executionContext);
            _executionContext.UpdateBuildingBlockPropertiesInCommand(macroCommand, templateBuildingBlock);

            //Now that our expression profile are updated, we need to trigger the synchronization in all building blocks
            expressionProfilesToUpdate.Each(x => _expressionProfileUpdater.SynchronizeAllSimulationSubjectsWithExpressionProfile(x));

            return(macroCommand);
        }