Exemplo n.º 1
0
        protected override void DoStart()
        {
            var allFormulationsContainer = _flatContainerRepository.All().Where(ContainerIsFormulation).ToList();

            // loop over FORMULATION ROUTES in order to get formulations in proper sequence
            foreach (var formulationRoute in _formulationRouteRepository.All())
            {
                string formulationName  = formulationRoute.Formulation;
                var    flatFormulations = allFormulationsContainer.Where(f => f.Name.Equals(formulationName)).ToList();

                if (!flatFormulations.Any())
                {
                    continue;
                }

                var flatFormulation = flatFormulations.First();

                var formulation = _formulationMapper.MapFrom(flatFormulation);

                // formulation may appear more than once
                if (_formulations.Contains(formulation.FormulationType))
                {
                    continue;
                }

                _formulations.Add(formulation);
            }
        }
 private IEnumerable <FlatContainer> eventGroupSubContainers(FlatContainer eventGroupFlatContainer)
 {
     return(from flatContainer in _flatContainerRepo.All()
            let parentContainer = _flatContainerRepo.ParentContainerFrom(flatContainer.Id)
                                  where parentContainer != null
                                  where parentContainer.Id == eventGroupFlatContainer.Id
                                  select flatContainer);
 }
Exemplo n.º 3
0
        protected override void DoStart()
        {
            foreach (var flatEventGroupContainer in _flatContainerRepo.All()
                     .Where(c => c.Type.Equals(CoreConstants.ContainerType.EVENT_GROUP) &&
                            !c.ParentId.HasValue))
            {
                var eventGroupBuilder = _eventGroupMapper.MapFrom(flatEventGroupContainer);

                _eventGroupBuilders.Add(eventGroupBuilder);
            }
        }
Exemplo n.º 4
0
        private IEnumerable <FlatContainer> flatSubContainersFor(IContainer container, Func <string, bool> containerTypeCondition)
        {
            var pathToParentContainer = _entityPathResolver.PathFor(container);

            //find parent container in repo
            var flatParentContainer = _flatContainerRepo.ContainerFrom(pathToParentContainer);

            return(from flatContainer in _flatContainerRepo.All()
                   let parentContainer = _flatContainerRepo.ParentContainerFrom(flatContainer.Id)
                                         where parentContainer != null
                                         where parentContainer.Id == flatParentContainer.Id
                                         where containerTypeCondition(flatContainer.Type)
                                         select flatContainer);
        }
Exemplo n.º 5
0
        protected override void DoStart()
        {
            foreach (var flatApplicContainer in _flatContainerRepository.All().Where(c => string.Equals(c.Type, CoreConstants.ContainerType.Application)))
            {
                var applicationType = applicationTypeFrom(flatApplicContainer);
                if (string.IsNullOrEmpty(applicationType))
                {
                    continue;
                }

                var applicBuilder = _applicationMapper.MapFrom(flatApplicContainer);

                //parent container of each application container is formulation!
                var formulationType = applicBuilder.ParentContainer.Name;

                _applicationBuilders.Add(new CompositeKey(applicationType, formulationType), applicBuilder);
            }
        }
Exemplo n.º 6
0
        protected override void Context()
        {
            _entityPathResolver = new EntityPathResolver(new ObjectPathFactoryForSpecs());
            _flatContainerIdToContainerMapper = A.Fake <IFlatContainerIdToContainerMapper>();
            _modelContainerRepo = A.Fake <IFlatModelContainerRepository>();
            _compartment        = A.Fake <IContainer>();
            _populationName     = "HUMAN_POP";

            A.CallTo(() => _modelContainerRepo.All()).Returns(
                new List <FlatModelContainer>
            {
                NewFMC(1, "C1", "ORGAN", "M1"),
                NewFMC(2, "C2", "COMPARTMENT", "M1"),
                NewFMC(3, Constants.ROOT, "SIMULATION", "M1")
            });

            _populationContainerRepo = A.Fake <IFlatPopulationContainerRepository>();
            A.CallTo(() => _populationContainerRepo.AllSubContainerFor(_populationName, 3)).Returns(
                new List <FlatPopulationContainer>
            {
                CreateFlatPopulationContainer(1, "C1", "ORGAN", _populationName),
            });

            A.CallTo(() => _populationContainerRepo.AllSubContainerFor(_populationName, 1)).Returns(
                new List <FlatPopulationContainer>
            {
                CreateFlatPopulationContainer(2, "C2", "COMPARTMENT", _populationName)
            });


            _flatContainerRepo = A.Fake <IFlatContainerRepository>();
            var simulationFlatContainer  = NewFC(3, Constants.ROOT, "SIMULATION", null, "", "");
            var organFlatContainer       = NewFC(1, "C1", "ORGAN", 3, "SIMULATION", Constants.ROOT);
            var compartmentFlatContainer = NewFC(2, "C2", "COMPARTMENT", 1, "C1", "ORGAN");

            A.CallTo(() => _flatContainerRepo.All()).Returns(
                new List <FlatContainer>
            {
                organFlatContainer,
                compartmentFlatContainer,
                simulationFlatContainer
            });

            A.CallTo(() => _flatContainerRepo.ParentContainerFrom(organFlatContainer.Id)).Returns(simulationFlatContainer);
            A.CallTo(() => _flatContainerRepo.ParentContainerFrom(compartmentFlatContainer.Id)).Returns(organFlatContainer);
            A.CallTo(() => _flatContainerRepo.ParentContainerFrom(simulationFlatContainer.Id)).Returns(null);

            A.CallTo(() => _flatContainerRepo.ContainerFrom(organFlatContainer.Id)).Returns(organFlatContainer);
            A.CallTo(() => _flatContainerRepo.ContainerFrom(compartmentFlatContainer.Id)).Returns(compartmentFlatContainer);
            A.CallTo(() => _flatContainerRepo.ContainerFrom(simulationFlatContainer.Id)).Returns(simulationFlatContainer);

            _flatModelCompartment = new FlatModelContainer {
                Id = compartmentFlatContainer.Id
            };
            A.CallTo(() => _flatContainerRepo.ContainerFrom("ROOT")).Returns(organFlatContainer);
            A.CallTo(() => _flatContainerRepo.ContainerFrom("C1")).Returns(organFlatContainer);

            A.CallTo(() => _modelContainerRepo.AllSubContainerFor("M1", 1)).Returns(new[] { _flatModelCompartment });
            A.CallTo(() => _flatContainerIdToContainerMapper.MapFrom(_flatModelCompartment)).Returns(_compartment);
            sut = new ModelContainerQuery(_modelContainerRepo, _populationContainerRepo,
                                          _flatContainerRepo, _flatContainerIdToContainerMapper, _entityPathResolver);
        }