Example #1
0
        public static PreflightConcepts ReadConcepts(SqlMapper.GridReader grid)
        {
            var preflight = grid.Read <ConceptPreflightCheckResultRecord>();
            var concepts  = HydratedConceptReader.Read(grid);

            return(new PreflightConcepts
            {
                PreflightCheck = new ConceptPreflightCheck {
                    Results = preflight.Select(p => p.ConceptPreflightCheckResult())
                },
                Concepts = concepts?.ToArray()
            });
        }
Example #2
0
        public async Task <IEnumerable <Concept> > GetRootsAsync()
        {
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var grid = await cn.QueryMultipleAsync(
                    queryRoots,
                    new { user = user.UUID, groups = GroupMembership.From(user), admin = user.IsAdmin },
                    commandTimeout : opts.DefaultTimeout,
                    commandType : CommandType.StoredProcedure
                    );

                return(HydratedConceptReader.Read(grid));
            }
        }
Example #3
0
        public async Task <IEnumerable <Concept> > GetAsync(HashSet <string> universalIds)
        {
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var grid = await cn.QueryMultipleAsync(
                    queryManyUniversal,
                    new
                {
                    uids   = ResourceUniversalIdTable.From(universalIds),
                    user   = user.UUID,
                    groups = GroupMembership.From(user),
                    admin  = user.IsAdmin
                },
                    commandTimeout : opts.DefaultTimeout,
                    commandType : CommandType.StoredProcedure
                    );

                return(HydratedConceptReader.Read(grid));
            }
        }
Example #4
0
        public async Task <Concept> GetAsync(Guid id)
        {
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var grid = await cn.QueryMultipleAsync(
                    querySingle,
                    new
                {
                    id,
                    user   = user.UUID,
                    groups = GroupMembership.From(user),
                    admin  = user.IsAdmin
                },
                    commandTimeout : opts.DefaultTimeout,
                    commandType : CommandType.StoredProcedure
                    );

                return(HydratedConceptReader.Read(grid).FirstOrDefault());
            }
        }
Example #5
0
        PanelDatasetCompilerContext ReadContextGrid(ConceptDatasetExecutionRequest request, SqlMapper.GridReader gridReader)
        {
            var queryCtx = gridReader.Read <QueryContext>().FirstOrDefault();
            var concept  = HydratedConceptReader.Read(gridReader).FirstOrDefault();
            var pi       = request.PanelItem;
            var panel    = new Panel
            {
                SubPanels = new List <SubPanel>
                {
                    new SubPanel
                    {
                        PanelItems = new List <PanelItem>
                        {
                            pi.PanelItem(concept)
                        }
                    }
                }
            };

            if (request.EarlyBound != null && request.LateBound != null)
            {
                panel.DateFilter = new DateBoundary
                {
                    Start = new DateFilter {
                        Date = (DateTime)request.EarlyBound, DateIncrementType = DateIncrementType.Specific
                    },
                    End = new DateFilter {
                        Date = (DateTime)request.LateBound, DateIncrementType = DateIncrementType.Specific
                    }
                };
            }

            return(new PanelDatasetCompilerContext
            {
                QueryContext = queryCtx,
                Panel = panel
            });
        }
Example #6
0
        public async Task <IEnumerable <Concept> > GetWithParentsBySearchTermAsync(Guid?rootId, string[] terms)
        {
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var grid = await cn.QueryMultipleAsync(
                    queryParentsBySearchTerm,
                    new
                {
                    terms = SearchTermTable.From(terms),
                    rootId,
                    user   = user.UUID,
                    groups = GroupMembership.From(user),
                    admin  = user.IsAdmin
                },
                    commandTimeout : opts.DefaultTimeout,
                    commandType : CommandType.StoredProcedure
                    );

                return(HydratedConceptReader.Read(grid));
            }
        }
Example #7
0
        public async Task <ConceptTree> GetTreetopAsync()
        {
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var grid = await cn.QueryMultipleAsync(
                    queryRootsPanelFilters,
                    new { user = user.UUID, groups = GroupMembership.From(user), admin = user.IsAdmin },
                    commandTimeout : opts.DefaultTimeout,
                    commandType : CommandType.StoredProcedure
                    );

                var roots         = HydratedConceptReader.Read(grid);
                var filterRecords = grid.Read <PanelFilterRecord>();
                var filters       = filterRecords.Select(f => f.ToPanelFilter());

                return(new ConceptTree
                {
                    PanelFilters = filters,
                    Concepts = roots
                });
            }
        }