コード例 #1
0
        public async Task <LocationSubSearchModel> GetLocationByLogIdAsync(int logId)
        {
            var log = await _context.Logs.Include(l => l.Location)
                      .Where(l => l.LogId == logId).FirstOrDefaultAsync();

            var location       = log == null ? null : log.Location;
            var locationSearch = LocationOperator.SetLocationSubSearchModel(location);

            return(locationSearch);
        }
コード例 #2
0
        public async Task <LocationSubSearchModel> GetLocationByAlarmIdAsync(int alarmId)
        {
            var alarm = await _context.Alarms
                        .Include(a => a.Location).Where(a => a.AlarmId == alarmId).FirstOrDefaultAsync();

            var location       = alarm == null ? null : alarm.Location;
            var locationSearch = LocationOperator.SetLocationSubSearchModel(location);

            return(locationSearch);
        }
コード例 #3
0
        public async Task <IEnumerable <LocationSubSearchModel> > GetLocationsByProjectIdAsync(int projectId)
        {
            var queryData = _context.Locations.Where(g => g.ProjectId == projectId);
            var result    = QueryOperate <Location> .Execute(queryData);

            var locations = await result.ToListAsync();

            var locationsSearch = LocationOperator.SetLocationSubSearchModel(locations);

            return(locationsSearch);
        }
コード例 #4
0
        public LocationSearchModel FindById(int locationId)
        {
            var result = _context.Locations.Where(v => v.LocationId == locationId);

            result = (IQueryable <Location>)ExpandOperator.ExpandRelatedEntities <Location>(result);

            var location       = result.FirstOrDefault();
            var locationSearch = LocationOperator.SetLocationSearchModelCascade(location);

            return(locationSearch);
        }
コード例 #5
0
        /// <summary>
        /// Checks importability of subsequences.
        /// </summary>
        /// <exception cref="Exception">
        /// Thrown if subsequences are not importable.
        /// Thrown if feature contains no leaf location or
        /// if source length not equals to parent sequence length or
        /// if feature length is less than 1.
        /// </exception>
        private void CheckImportability()
        {
            for (int i = 1; i < features.Count; i++)
            {
                FeatureItem      feature       = features[i];
                ILocation        location      = feature.Location;
                List <ILocation> leafLocations = location.GetLeafLocations();

                if (feature.Key == "source")
                {
                    throw new Exception($"Sequence seems to be chimeric as it is several 'source' records in file. Second source location: {leafLocations[0].StartData}");
                }

                if (!FeatureRepository.FeatureExists(feature.Key))
                {
                    throw new Exception($"Unknown feature. Feature name = {feature.Key}");
                }

                if (feature.Key == gene)
                {
                    // checking if there is any feature with identical location
                    if (allNonGenesLeafLocations.Any(l => LocationsEqual(leafLocations, l)))
                    {
                        continue;
                    }
                }

                if (location.SubLocations.Count > 0)
                {
                    LocationOperator subLocationOperator = location.SubLocations[0].Operator;

                    foreach (ILocation subLocation in location.SubLocations)
                    {
                        if (subLocation.Operator != subLocationOperator)
                        {
                            throw new Exception($"SubLocation operators does not match: {subLocationOperator} and {subLocation.Operator}");
                        }
                    }
                }

                if (leafLocations.Count == 0)
                {
                    throw new Exception("No leaf locations");
                }

                if (leafLocations.Any(leafLocation => leafLocation.LocationEnd < leafLocation.LocationStart))
                {
                    throw new Exception("Subsequence length cant be less than 1.");
                }
            }
        }
コード例 #6
0
        public async Task <IEnumerable <LocationSubSearchModel> > GetLocationsByGroupIdAsync(int groupId)
        {
            var queryData = _context.GroupLocations
                            .Where(gl => gl.GroupId == groupId)
                            .Select(gl => gl.Location);

            var result = QueryOperate <Location> .Execute(queryData);

            var locations = await result.ToListAsync();

            var locationsSearch = LocationOperator.SetLocationSubSearchModel(locations);

            return(locationsSearch);
        }
コード例 #7
0
        public async Task <IEnumerable <LocationSubSearchModel> > GetLocationsByUserId(string userId)
        {
            var queryData = _context.UserLocations
                            .Where(u => u.UserId == userId)
                            .Select(u => u.Location);

            var result = QueryOperate <Location> .Execute(queryData);

            var locations = await result.ToListAsync();

            var locationsSearch = LocationOperator.SetLocationSubSearchModel(locations);

            return(locationsSearch);
        }
コード例 #8
0
        public async Task <IEnumerable <LocationSearchModel> > GetAllAsync()
        {
            var queryData = from L in _context.Locations
                            select L;

            var result = QueryOperate <Location> .Execute(queryData);

            result = (IQueryable <Location>)ExpandOperator.ExpandRelatedEntities <Location>(result);

            //以下执行完后才会去数据库中查询
            var locations = await result.ToListAsync();

            var locationsSearch = LocationOperator.SetLocationSearchModelCascade(locations);

            return(locationsSearch);
        }