示例#1
0
        protected override void Context()
        {
            _executionContext = A.Fake <IExecutionContext>();
            _simulationBuildingBlockUpdater = A.Fake <ISimulationBuildingBlockUpdater>();
            _buildingBlockInProjectManager  = A.Fake <IBuildingBlockInProjectManager>();
            sut = new MultipleUsedBuildingBlockNodeContextMenuFactory(_buildingBlockInProjectManager, _executionContext);

            _usedBuildingBlocksTreeNode = new List <ITreeNode>();
            _presenter = A.Fake <IPresenterWithContextMenu <IReadOnlyList <ITreeNode> > >();

            _buildingBlock1 = A.Fake <IPKSimBuildingBlock>().WithId("bb1");
            _buildingBlock2 = A.Fake <IPKSimBuildingBlock>().WithId("bb2");
            _buildingBlock3 = A.Fake <IPKSimBuildingBlock>().WithId("bb3");

            _usedIndividual1 = new UsedBuildingBlock("1", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _buildingBlock1
            };
            _usedIndividual2 = new UsedBuildingBlock("2", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _buildingBlock2
            };
            _usedCompound1 = new UsedBuildingBlock("3", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = _buildingBlock3
            };
            _command = new CompareObjectsUICommand(A.Fake <IEventPublisher>());
            A.CallTo(() => _container.Resolve <CompareObjectsUICommand>()).Returns(_command);
            A.CallTo(() => _executionContext.Resolve <ISimulationBuildingBlockUpdater>()).Returns(_simulationBuildingBlockUpdater);
        }
 protected override void Context()
 {
     base.Context();
     _relatedObject      = A.Fake <IPKSimBuildingBlock>().WithId("XX");
     _relatedItem.Origin = Origins.PKSim;
     A.CallTo(() => _relatedItemSerializer.Deserialize(_relatedItem)).Returns(_relatedObject);
 }
示例#3
0
        protected override void Context()
        {
            base.Context();
            _modelRoot  = new Container();
            _model      = new OSPSuite.Core.Domain.Model();
            _simulation = new IndividualSimulation {
                Model = _model, IsLoaded = true
            }.WithId(_simulationId);
            _model.Root                 = _modelRoot;
            _eventBuidingBlock          = new PKSimEvent().WithId(_eventId);
            _eventParameter             = new Parameter().WithId(_eventParameterId).WithName("P1");
            _eventParameterInSimulation = new Parameter {
                BuildingBlockType = PKSimBuildingBlockType.Event
            }.WithId(_eventParameterInSimulationId).WithName("P1");
            _eventBuidingBlock.Add(_eventParameter);

            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("TempId", PKSimBuildingBlockType.Event)
            {
                BuildingBlock = _eventBuidingBlock
            });

            _eventParameterInSimulation.Origin.ParameterId    = _eventParameter.Id;
            _eventParameterInSimulation.Origin.BuilingBlockId = _eventBuidingBlock.Id;
            _eventParameterInSimulation.Origin.SimulationId   = _simulation.Id;
            _modelRoot.Add(_eventParameterInSimulation);
        }
        protected override void Context()
        {
            base.Context();
            _templateBuildingBlock = A.Fake <IPKSimBuildingBlock>();
            A.CallTo(() => _templateBuildingBlock.StructureVersion).Returns(5);
            A.CallTo(() => _templateBuildingBlock.Id).Returns("templateId");
            _sameIdAndStructVersionUsedBuildingBlock = new UsedBuildingBlock(_templateBuildingBlock.Id, PKSimBuildingBlockType.Compound);
            _sameIdAndStructVersionUsedBuildingBlock.StructureVersion           = _templateBuildingBlock.StructureVersion;
            _sameIdAndOtherStructVersionUsedBuildingBlock                       = new UsedBuildingBlock(_templateBuildingBlock.Id, PKSimBuildingBlockType.Compound);
            _sameIdAndOtherStructVersionUsedBuildingBlock.StructureVersion      = 2;
            _otherIdAndSameStructVersionUsedBuildingBlock                       = new UsedBuildingBlock("another id", PKSimBuildingBlockType.Compound);
            _otherIdAndSameStructVersionUsedBuildingBlock.StructureVersion      = _templateBuildingBlock.StructureVersion;
            _otherIdAndOtherSameStructVersionUsedBuildingBlock                  = new UsedBuildingBlock("another id", PKSimBuildingBlockType.Compound);
            _otherIdAndOtherSameStructVersionUsedBuildingBlock.StructureVersion = 3;
            _templateProtocol = new SimpleProtocol().WithId("_templateProtocol");
            _templateProtocol.StructureVersion = 4;
            _templatePopulation = new RandomPopulation().WithId("_templatePopulation");
            _templatePopulation.StructureVersion = 4;

            _usedProtocolBuildingBlock = new UsedBuildingBlock(_templateProtocol.Id, PKSimBuildingBlockType.Protocol);
            _usedProtocolBuildingBlock.StructureVersion = _templateProtocol.StructureVersion;

            _usedPopulationBuildingBlock = new UsedBuildingBlock(_templatePopulation.Id, PKSimBuildingBlockType.Population);
            _usedPopulationBuildingBlock.StructureVersion = _templatePopulation.StructureVersion;
        }
 public void Visit(RandomPopulationMetaData randomPopulationMetaData)
 {
     _buildingBlock = new RandomPopulation
     {
         Settings = _serializationManager.Deserialize <RandomPopulationSettings>(randomPopulationMetaData.Properties.Data)
     };
 }
示例#6
0
        protected override ITreeNode AddBuildingBlockToTree(IPKSimBuildingBlock buildingBlock)
        {
            switch (buildingBlock)
            {
            case Compound compound:
                return(addCompoundToTree(compound));

            case Formulation formulation:
                return(addFormulationToTree(formulation));

            case Protocol protocol:
                return(addProtocolToTree(protocol));

            case Individual individual:
                return(addIndividualToTree(individual));

            case Population population:
                return(addPopulationToTree(population));

            case PKSimEvent pksimEvent:
                return(addEventToTree(pksimEvent));

            case ObserverSet observerSet:
                return(addObserverSetToTree(observerSet));

            case ExpressionProfile expressionProfile:
                return(addExpressionProfileToTree(expressionProfile));

            case Simulation _:
                return(null);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        protected override ITreeNode AddBuildingBlockToTree(IPKSimBuildingBlock buildingBlock)
        {
            switch (buildingBlock.BuildingBlockType)
            {
            case PKSimBuildingBlockType.Compound:
                return(addCompoundToTree(buildingBlock.DowncastTo <Compound>()));

            case PKSimBuildingBlockType.Formulation:
                return(addFormulationToTree(buildingBlock.DowncastTo <Formulation>()));

            case PKSimBuildingBlockType.Protocol:
                return(addProtocolToTree(buildingBlock.DowncastTo <Protocol>()));

            case PKSimBuildingBlockType.Individual:
                return(addIndividualToTree(buildingBlock.DowncastTo <Individual>()));

            case PKSimBuildingBlockType.Population:
                return(addPopulationToTree(buildingBlock.DowncastTo <Population>()));

            case PKSimBuildingBlockType.Event:
                return(addEventToTree(buildingBlock.DowncastTo <PKSimEvent>()));

            case PKSimBuildingBlockType.Simulation:
                return(null);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void Visit(ImportPopulationMetaData importPopulation)
        {
            var population = new ImportPopulation();

            _serializationManager.Deserialize(population.Settings, importPopulation.Properties.Data);
            _buildingBlock = population;
        }
        private IPKSimBuildingBlock mapFrom(BuildingBlockMetaData buildingBlockMetaData)
        {
            try
            {
                _buildingBlock = null;
                this.Visit(buildingBlockMetaData);
                if (_buildingBlock == null)
                {
                    return(null);
                }

                _buildingBlock.Id               = buildingBlockMetaData.Id;
                _buildingBlock.Name             = buildingBlockMetaData.Name;
                _buildingBlock.Version          = buildingBlockMetaData.Version;
                _buildingBlock.StructureVersion = buildingBlockMetaData.StructureVersion;
                _buildingBlock.Description      = buildingBlockMetaData.Description;
                _buildingBlock.Icon             = buildingBlockMetaData.Icon;

                if (!buildingBlockIsLazyLoaded(_buildingBlock))
                {
                    deserialize(buildingBlockMetaData);
                }

                return(_buildingBlock);
            }
            finally
            {
                _buildingBlock = null;
            }
        }
示例#10
0
 public RemoveBuildingBlockFromProjectIrreversibleCommand(IPKSimBuildingBlock buildingBlock, IExecutionContext context)
 {
     _buildingBlockToRemove = buildingBlock;
     CommandType            = PKSimConstants.Command.CommandTypeDelete;
     ObjectType             = context.TypeFor(buildingBlock);
     context.UpdateBuildinBlockProperties(this, buildingBlock);
 }
示例#11
0
        public IPKSimBuildingBlock CreateCloneFor(IPKSimBuildingBlock buildingBlockToClone)
        {
            //This should never fail
            var expressionProfile = buildingBlockToClone.DowncastTo <ExpressionProfile>();

            var(molecule, _) = expressionProfile;
            _dto             = _expressionProfileDTOMapper.MapFrom(expressionProfile);
            _view.Caption    = Captions.CloneObjectBase(PKSimConstants.ObjectTypes.ExpressionProfile, buildingBlockToClone.Name);

            _view.BindTo(_dto);
            _view.Display();

            if (_view.Canceled)
            {
                return(null);
            }

            //create a new expression profile using the same molecule name as the original so that we can update the values. Then we rename
            var newExpressionProfile = _expressionProfileFactory.Create(molecule.MoleculeType, _dto.Species.Name, molecule.Name);

            newExpressionProfile.Category = _dto.Category;

            //synchronize values
            _expressionProfileUpdater.SynchronizeExpressionProfileWithExpressionProfile(expressionProfile, newExpressionProfile);

            //rename using the new name
            _expressionProfileUpdater.UpdateMoleculeName(newExpressionProfile, _dto.MoleculeName);

            return(newExpressionProfile);
        }
 protected override void Context()
 {
     _buildingBlockTask     = A.Fake <IBuildingBlockTask>();
     _buildingBlockToDelete = A.Fake <IPKSimBuildingBlock>();
     sut = new DeleteBuildingBlockUICommand(_buildingBlockTask);
     sut.For(_buildingBlockToDelete);
 }
示例#13
0
 protected override void Context()
 {
     base.Context();
     _parentBuildingBlock = A.Fake <IPKSimBuildingBlock>();
     _entity = A.Fake <IEntity>();
     A.CallTo(() => _buildingBlockRetriever.BuildingBlockContaining(_entity)).Returns(_parentBuildingBlock);
 }
 protected override void Context()
 {
     _executionContext         = A.Fake <IExecutionContext>();
     _buildingBlock            = A.Fake <IPKSimBuildingBlock>();
     _buildingBlock.HasChanged = false;
     sut = new AddBuildingBlockToProjectCommand(_buildingBlock, _executionContext);
 }
 public bool BuildingBlockSupportsQuickUpdate(IPKSimBuildingBlock templateBuildingBlock)
 {
     return(!templateBuildingBlock.BuildingBlockType.IsOneOf(
                PKSimBuildingBlockType.Protocol,
                PKSimBuildingBlockType.Population,
                PKSimBuildingBlockType.ObserverSet));
 }
示例#16
0
 protected override void Context()
 {
     base.Context();
     _lazyLoadable = A.Fake <IPKSimBuildingBlock>();
     A.CallTo(() => _withIdRepository.ContainsObjectWithId("tata")).Returns(true);
     A.CallTo(() => _withIdRepository.Get("tata")).Returns(_lazyLoadable);
 }
 public void Visit(IndividualMetaData individualMetaData)
 {
     _buildingBlock = new Individual
     {
         OriginData = deserializeProperty <OriginData>(individualMetaData)
     };
 }
示例#18
0
        protected override void Context()
        {
            _project           = A.Fake <IPKSimProject>();
            _entityTask        = A.Fake <IEntityTask>();
            _templateTaskQuery = A.Fake <ITemplateTaskQuery>();
            _executionContext  = A.Fake <IExecutionContext>();
            A.CallTo(() => _executionContext.CurrentProject).Returns(_project);
            _applicationController            = A.Fake <IApplicationController>();
            _buildingBlockInSimulationManager = A.Fake <IBuildingBlockInSimulationManager>();
            _buildingBlockRepository          = A.Fake <IBuildingBlockRepository>();
            _clonePresenter             = A.Fake <ICloneBuildingBlockPresenter>();
            _renamePresenter            = A.Fake <IRenameObjectPresenter>();
            _dialogCreator              = A.Fake <IDialogCreator>();
            _singleStartPresenterTask   = A.Fake <ISingleStartPresenterTask>();
            _lazyLoadTask               = A.Fake <ILazyLoadTask>();
            _presenterSettingsTask      = A.Fake <IPresentationSettingsTask>();
            _simulationReferenceUpdater = A.Fake <ISimulationReferenceUpdater>();

            sut = new BuildingBlockTask(_executionContext, _applicationController, _dialogCreator, _buildingBlockInSimulationManager,
                                        _entityTask, _templateTaskQuery, _singleStartPresenterTask, _buildingBlockRepository, _lazyLoadTask, _presenterSettingsTask, _simulationReferenceUpdater);
            A.CallTo(() => _applicationController.Start <ICloneBuildingBlockPresenter>()).Returns(_clonePresenter);
            A.CallTo(() => _applicationController.Start <IRenameObjectPresenter>()).Returns(_renamePresenter);

            _buildingBlock = A.Fake <IPKSimBuildingBlock>();
        }
        private IPKSimBuildingBlock mapFrom(BuildingBlockMetaData buildingBlockMetaData)
        {
            try
            {
                _buildingBlock = null;
                this.Visit(buildingBlockMetaData);
                if (_buildingBlock == null)
                {
                    return(null);
                }

                _buildingBlock.Id               = buildingBlockMetaData.Id;
                _buildingBlock.Name             = buildingBlockMetaData.Name;
                _buildingBlock.Version          = buildingBlockMetaData.Version;
                _buildingBlock.StructureVersion = buildingBlockMetaData.StructureVersion;
                _buildingBlock.Description      = buildingBlockMetaData.Description;
                _buildingBlock.Icon             = buildingBlockMetaData.Icon;

                if (!buildingBlockIsLazyLoaded(_buildingBlock))
                {
                    deserialize(buildingBlockMetaData);
                }

                //This should be done after deserialization to ensure that all references are updated properly
                //as deserializing a complex object like population may reset the individual
                updateExpressionProfiles(_buildingBlock as ISimulationSubject, buildingBlockMetaData as SimulationSubjectMetaData);
                return(_buildingBlock);
            }
            finally
            {
                _buildingBlock = null;
            }
        }
示例#20
0
 protected override void Context()
 {
     base.Context();
     _buildingBlockInSimulation       = A.Fake <IPKSimBuildingBlock>();
     _usedBuildingBlock.BuildingBlock = _buildingBlockInSimulation;
     _simulation1.AddUsedBuildingBlock(_usedBuildingBlock);
 }
 protected override ITreeNode AddBuildingBlockToTree(IPKSimBuildingBlock buildingBlock)
 {
     if (buildingBlock.BuildingBlockType != PKSimBuildingBlockType.Simulation)
     {
         return(null);
     }
     return(addSimulationToTree(buildingBlock.DowncastTo <Simulation>()));
 }
 protected override void Context()
 {
     base.Context();
     _anotherBuildingBlock = A.Fake <IPKSimBuildingBlock>();
     _buildingBlocks       = new List <IPKSimBuildingBlock> {
         _buildingBlock, _anotherBuildingBlock
     };
 }
 protected override void Context()
 {
     base.Context();
     _buildingBlock.Name  = "AA";
     _clonedBuildingBlock = A.Fake <IPKSimBuildingBlock>();
     A.CallTo(() => _clonePresenter.CreateCloneFor(_buildingBlock)).Returns(_clonedBuildingBlock);
     A.CallTo(() => _executionContext.AddToHistory(A <IPKSimCommand> .Ignored)).Invokes(x => _command = x.GetArgument <AddBuildingBlockToProjectCommand>(0));
 }
示例#24
0
 protected override void Context()
 {
     base.Context();
     _templateBuildingBlock = A.Fake <IPKSimBuildingBlock>();
     _usedBuildingBlock     = new UsedBuildingBlock("X", PKSimBuildingBlockType.Protocol);
     _simulation            = A.Fake <Simulation>();
     A.CallTo(() => _simulationBuildingBlockUpdater.BuildingBlockSupportsQuickUpdate(_templateBuildingBlock)).Returns(false);
 }
 protected override void Context()
 {
     _executionContext = A.Fake <IExecutionContext>();
     _buildingBlock    = A.Fake <IPKSimBuildingBlock>();
     _project          = A.Fake <PKSimProject>();
     A.CallTo(() => _executionContext.CurrentProject).Returns(_project);
     sut = new RemoveBuildingBlockFromProjectCommand(_buildingBlock, _executionContext);
 }
示例#26
0
 public void Edit(IPKSimBuildingBlock buildingBlockToEdit)
 {
     if (buildingBlockToEdit == null)
     {
         return;
     }
     _singleStartPresenterTask.StartForSubject(buildingBlockToEdit);
 }
示例#27
0
 public AddBuildingBlockToProjectCommand(IPKSimBuildingBlock buildingBlock, IExecutionContext context)
 {
     _buildingBlockToAdd   = buildingBlock;
     _buildingBlockToAddId = _buildingBlockToAdd.Id;
     CommandType           = PKSimConstants.Command.CommandTypeAdd;
     ObjectType            = context.TypeFor(buildingBlock);
     context.UpdateBuildinBlockProperties(this, buildingBlock);
 }
示例#28
0
        private void addUsedBuildingBlockToSimulation(Simulation simulation, IPKSimBuildingBlock templateBuildingBlock)
        {
            var previousUsedBuildingBlock = simulation.UsedBuildingBlockById(templateBuildingBlock.Id);
            var newUsedBuildingBlock      = _buildingBlockMapper.MapFrom(templateBuildingBlock, previousUsedBuildingBlock);

            simulation.RemoveUsedBuildingBlock(previousUsedBuildingBlock);
            simulation.AddUsedBuildingBlock(newUsedBuildingBlock);
        }
        public void ShowParametersFor(IPKSimBuildingBlock buildingBlock)
        {
            _view.Caption = $"All Parameters for BuidlingBlock {buildingBlock.Name}";
            var allParameters = buildingBlock.GetAllChildren <IParameter>();

            _view.BindTo(_parametersReportCreator.ExportParametersToTable(allParameters));
            _view.Display();
        }
 protected override void Context()
 {
     base.Context();
     _id            = "tralala";
     _buildingBlock = A.Fake <IPKSimBuildingBlock>();
     A.CallTo(() => _withIdRepository.ContainsObjectWithId(_id)).Returns(true);
     A.CallTo(() => _withIdRepository.Get <IPKSimBuildingBlock>(_id)).Returns(_buildingBlock);
 }