示例#1
0
        /// <summary>
        /// Increments the point counts in a <see cref="FiftyMeterDataEntry"/> object.
        /// </summary>
        /// <typeparam name="T">Must be of type FiftyMeterPointObservation</typeparam>
        /// <param name="pointSurveyId">The point survey id.</param>
        /// <param name="dataEntryList">The data entry list.</param>
        /// <param name="countList">The beyond50 list.</param>
        public static void IncrementPointCounts <T>(Guid pointSurveyId, List <FiftyMeterDataEntry> dataEntryList, List <T> countList) where T : FiftyMeterPointObservation
        {
            if (countList == null)
            {
                return;
            }
            foreach (T pointCount in countList)
            {
                FiftyMeterDataEntry entry = dataEntryList.Find(y => y.SpeciesCode.Equals(pointCount.SpeciesCode) &&
                                                               y.PointSurveyId.Equals(pointSurveyId));
                if (entry == null)    // match wasn't found, must create a new entry
                {
                    entry = new FiftyMeterDataEntry()
                    {
                        Comments      = pointCount.Comments,
                        PointSurveyId = pointSurveyId,
                        SpeciesCode   = pointCount.SpeciesCode
                    };
                    dataEntryList.Add(entry);
                }

                Type ty = typeof(T);
                if (ty == typeof(PointCountBeyond50))
                {
                    entry.CountBeyond50++;
                }
                else if (ty == typeof(PointCountWithin50))
                {
                    entry.CountWithin50++;
                }
            }
        }
        public void t_UpdateCountAndList_Beyond50_Decrement()
        {
            FiftyMeterDataEntry entry = new FiftyMeterDataEntry()
            {
                Comments      = "Comments",
                CountBeyond50 = 0,
                PointSurveyId = DbTestHelper.TestGuid1,
                SpeciesCode   = DbTestHelper.SPECIES_1_CODE
            };
            List <PointCountBeyond50> beyond50List = new List <PointCountBeyond50>()
            {
                new PointCountBeyond50()
                {
                    Comments        = entry.Comments,
                    EventId         = entry.PointSurveyId,
                    MarkForDeletion = false,
                    SpeciesCode     = entry.SpeciesCode
                }
            };
            int count = 0;

            FiftyMeterDataEntryTss.UpdateCountAndList <PointCountBeyond50>(beyond50List, count, entry);

            Assert.AreEqual(1, beyond50List.Count(), "Does not contain 1 object");
            Assert.AreEqual(entry.Comments, beyond50List[0].Comments, "Comments");
            Assert.AreEqual(entry.PointSurveyId, beyond50List[0].EventId, "Point Survey ID");
            Assert.AreEqual(entry.SpeciesCode, beyond50List[0].SpeciesCode, "SpeciesCode");
            // Now it _should_ be marked for deletion
            Assert.IsTrue(beyond50List[0].MarkForDeletion, "MarkFordeletion");
        }
        public ReviewObservation(FiftyMeterPointSurvey survey, FiftyMeterDataEntry entry, IUserStateManager state, IGlobalMap globalMap)
        {
            State     = state;
            DataEntry = entry;

            SamplingPointName =
                state.PointsRemaining.Union(state.PointsCompleted).Single(x => x.Id.Equals(survey.LocationId)).Name;

            Species species = globalMap.SpeciesList.Find(x => x.AlphaCode.Equals(entry.SpeciesCode));

            if (species == null)
            {
                Warning = "Unknown species code. ";
            }
            else
            {
                SpeciesName = species.CommonName;

                if (entry.CountBeyond50 > species.WarningCount)
                {
                    Warning += "Unusually high count beyond 50m, please verify. ";
                }
                if (entry.CountWithin50 > species.WarningCount)
                {
                    Warning += "Unusually high count within 50m, please verify. ";
                }
            }
        }
示例#4
0
 public static void ValidateFiftyMeterDataEntryObject(Guid pointSurveyId, string comments1, List<FiftyMeterDataEntry> entryList, string whichSpecies, int expectedCount, int expectedCountWithin50, string speciesCode)
 {
     FiftyMeterDataEntry species1 = entryList.Single(x => x.SpeciesCode.Equals(speciesCode) && x.PointSurveyId.Equals(pointSurveyId));
     Assert.IsNotNull(species1, "species " + whichSpecies + " isn't in the list");
     Assert.AreEqual(expectedCount, species1.CountBeyond50, "Count beyond 50 is wrong for species " + whichSpecies);
     Assert.AreEqual(expectedCountWithin50, species1.CountWithin50, "count within 50 is wrong for species " + whichSpecies);
     Assert.AreEqual(comments1, species1.Comments, "wrong count for species " + whichSpecies);
     Assert.AreEqual(pointSurveyId, species1.PointSurveyId, "wrong point survey id for species " + whichSpecies);
 }
        public void t_CountByPointSurveyId_Beyond50()
        {
            List <FiftyMeterDataEntry> dataEntryList = new List <FiftyMeterDataEntry>();
            List <PointCountBeyond50>  fiftyList     = new List <PointCountBeyond50>()
            {
                // 2 of species 1 at same point
                new PointCountBeyond50()
                {
                    EventId     = TestHelper.TestGuid1,
                    SpeciesCode = TestHelper.SPECIES_1_CODE
                },
                new PointCountBeyond50()
                {
                    EventId     = TestHelper.TestGuid1,
                    SpeciesCode = TestHelper.SPECIES_1_CODE
                },
                // 1 of species 1 at different point
                new PointCountBeyond50()
                {
                    EventId     = TestHelper.TestGuid2,
                    SpeciesCode = TestHelper.SPECIES_1_CODE
                },
                // 1 of different species at the second point
                new PointCountBeyond50()
                {
                    EventId     = TestHelper.TestGuid2,
                    SpeciesCode = TestHelper.SPECIES_2_CODE
                }
            };

            // Exercise the system under test
            FiftyMeterDataEntryFactory.CreateEntriesFromPointCounts <PointCountBeyond50>(fiftyList, dataEntryList);

            // There should be three entries:
            // 1. Species 1 at point 1 with count 2
            // 2. Species 1 at point 2 with count 1
            // 3. Species 2 at point 2 with count 1
            Assert.AreEqual(3, dataEntryList.Count(), "wrong number of results");
            FiftyMeterDataEntry entry1 = dataEntryList.Single(x => x.PointSurveyId.Equals(TestHelper.TestGuid1) &&
                                                              x.SpeciesCode.Equals(TestHelper.SPECIES_1_CODE));

            Assert.IsNotNull(entry1, "entry 1 missing");
            Assert.AreEqual(2, entry1.CountBeyond50, "entry 1 wrong count");

            FiftyMeterDataEntry entry2 = dataEntryList.Single(x => x.PointSurveyId.Equals(TestHelper.TestGuid2) &&
                                                              x.SpeciesCode.Equals(TestHelper.SPECIES_1_CODE));

            Assert.IsNotNull(entry2, "entry 1 missing");
            Assert.AreEqual(1, entry2.CountBeyond50, "entry 2 wrong count");

            FiftyMeterDataEntry entry3 = dataEntryList.Single(x => x.PointSurveyId.Equals(TestHelper.TestGuid2) &&
                                                              x.SpeciesCode.Equals(TestHelper.SPECIES_2_CODE));

            Assert.IsNotNull(entry3, "entry 1 missing");
            Assert.AreEqual(1, entry3.CountBeyond50, "entry 3 wrong count");
        }
 protected void ObservationsList_ItemDataBound(object sender, ListViewItemEventArgs e)
 {
     if (e.Item.ItemType == ListViewItemType.DataItem)
     {
         Control ctl = e.Item.FindControl("CommonName");
         if (ctl != null)
         {
             FiftyMeterDataEntry rowView = e.Item.DataItem as FiftyMeterDataEntry;
             Label commonName            = (Label)ctl;
             commonName.Text =
                 GlobalMap.SpeciesList.Find(x => x.AlphaCode.Equals(rowView.SpeciesCode.ToUpper())).CommonName;
         }
     }
 }
        public void t_UpdateCountAndList_Less50_Increment()
        {
            FiftyMeterDataEntry entry = new FiftyMeterDataEntry()
            {
                Comments      = "Comments",
                CountWithin50 = 0,
                PointSurveyId = DbTestHelper.TestGuid1,
                SpeciesCode   = DbTestHelper.SPECIES_1_CODE
            };
            List <PointCountWithin50> less50List = new List <PointCountWithin50>();
            int count = 1;

            FiftyMeterDataEntryTss.UpdateCountAndList <PointCountWithin50>(less50List, count, entry);

            Assert.AreEqual(1, less50List.Count(), "Does not contain 1 object");
            Assert.AreEqual(entry.Comments, less50List[0].Comments, "Comments");
            Assert.AreEqual(entry.PointSurveyId, less50List[0].EventId, "Point Survey ID");
            Assert.AreEqual(entry.SpeciesCode, less50List[0].SpeciesCode, "SpeciesCode");
            Assert.IsFalse(less50List[0].MarkForDeletion, "MarkFordeletion");
        }
        public void Update(FiftyMeterDataEntry entry)
        {
            entry.SpeciesCode = entry.SpeciesCode.ToUpper();
            List <PointCountBeyond50> beyond50 = entry.GetListBeyond50();
            List <PointCountWithin50> within50 = entry.GetListWithin50();

            beyond50.FindAll(y => y.Id.Equals(0)).ForEach(x =>
            {
                ObservationMapper.Update(x);
                _state.PointSurvey.Observations.Add(x);
            });
            within50.FindAll(y => y.Id.Equals(0)).ForEach(x =>
            {
                ObservationMapper.Update(x);
                _state.PointSurvey.Observations.Add(x);
            });



            int deleteBeyond = _state.PointSurvey.Observations.OfType <PointCountBeyond50>().Where(x => x.SpeciesCode.Equals(entry.SpeciesCode)).Count() - beyond50.Count();
            int deleteWithin = _state.PointSurvey.Observations.OfType <PointCountWithin50>().Where(x => x.SpeciesCode.Equals(entry.SpeciesCode)).Count() - within50.Count();

            if (deleteBeyond > 0)
            {
                var toDelete = _state.PointSurvey.Observations.Where(x => x.SpeciesCode.Equals(entry.SpeciesCode)).Take(deleteBeyond);
                toDelete.ToList().ForEach(x =>
                {
                    ObservationMapper.Delete(x);
                    _state.PointSurvey.Observations.Remove(x);
                });
            }
            if (deleteWithin > 0)
            {
                var toDelete = _state.PointSurvey.Observations.Where(x => x.SpeciesCode.Equals(entry.SpeciesCode)).Take(deleteWithin);
                toDelete.ToList().ForEach(x =>
                {
                    ObservationMapper.Delete(x);
                    _state.PointSurvey.Observations.Remove(x);
                });
            }
        }
        public void Insert(FiftyMeterDataEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            entry.SpeciesCode = entry.SpeciesCode.ToUpper();
            List <PointCountBeyond50> beyond50 = entry.GetListBeyond50();
            List <PointCountWithin50> within50 = entry.GetListWithin50();

            beyond50.FindAll(y => !y.MarkForDeletion).ForEach(x =>
            {
                ObservationMapper.Insert(x);
                _state.PointSurvey.Observations.Add(x);
            });
            within50.FindAll(y => !y.MarkForDeletion).ForEach(x =>
            {
                ObservationMapper.Insert(x);
                _state.PointSurvey.Observations.Add(x);
            });
        }
示例#10
0
        public void t_Insert()
        {
            FiftyMeterDataEntry entry = new FiftyMeterDataEntry()
            {
                Comments = "comments",
                CountBeyond50 = 1,
                CountWithin50 = 2,
                PointSurveyId = DbTestHelper.TestGuid4,
                SpeciesCode = DbTestHelper.SPECIES_2_CODE
            };

            // Todo: fix this
            FiftyMeterDataEntryFacade.Insert(entry);

            using (IbaUnitTestEntities iba = new IbaUnitTestEntities())
            {
                var observationQuery = from observations in iba.Observation_ado select observations;
                Assert.IsNotNull(observationQuery, "observationQuery is null");
                Assert.AreEqual(3, observationQuery.Count(), "observationQuery has wrong count");

                Observation_ado beyond50 = observationQuery.First(x => x.ObservationTypeId.Equals(PointCountBeyond50.ObservationTypeGuid));
                Assert.IsNotNull(beyond50, "no object added for Beyond 50 count");
                Assert.AreEqual(entry.Comments, beyond50.Comments, "comments beyond");
                Assert.AreEqual(entry.PointSurveyId, beyond50.EventId, "event id beyond");
                Assert.AreEqual(new Guid(DbTestHelper.SPECIES_2_ID), beyond50.SpeciesId, "species ID beyond");

                List<Observation_ado> withinList = observationQuery.Where(x => x.ObservationTypeId.Equals(PointCountWithin50.ObservationTypeGuid)).ToList();
                Assert.IsNotNull(withinList, "withinList is null");

                Assert.AreEqual(entry.Comments, withinList[0].Comments, "within 1 comments");
                Assert.AreEqual(entry.PointSurveyId, withinList[0].EventId, "within 1 event id");
                Assert.AreEqual(new Guid(DbTestHelper.SPECIES_2_ID), withinList[0].SpeciesId, "within 1 species id");

                Assert.AreEqual(entry.Comments, withinList[1].Comments, "within 2 comments");
                Assert.AreEqual(entry.PointSurveyId, withinList[1].EventId, "within 2 event id");
                Assert.AreEqual(new Guid(DbTestHelper.SPECIES_2_ID), withinList[1].SpeciesId, "within 2 species id");
            }
        }
        public void Delete(FiftyMeterDataEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            ObservationMapper.DeleteTopX(entry.PointSurveyId, PointCountWithin50.ObservationTypeGuid,
                                         entry.SpeciesCode, entry.CountWithin50);
            ObservationMapper.DeleteTopX(entry.PointSurveyId, PointCountBeyond50.ObservationTypeGuid,
                                         entry.SpeciesCode, entry.CountBeyond50);

            entry.GetListBeyond50().ForEach(x =>
            {
                _state.PointSurvey.Observations.RemoveAll(y => y.ObservationTypeId.Equals(x.ObservationTypeId) &&
                                                          y.SpeciesCode.Equals(x.SpeciesCode));
            });
            entry.GetListWithin50().ForEach(x =>
            {
                _state.PointSurvey.Observations.RemoveAll(y => y.ObservationTypeId.Equals(x.ObservationTypeId) &&
                                                          y.SpeciesCode.Equals(x.SpeciesCode));
            });
        }
 public static new void UpdateCountAndList <T>(List <T> countList, int count, FiftyMeterDataEntry entry) where T : FiftyMeterPointObservation
 {
     FiftyMeterDataEntry.UpdateCountAndList <T>(countList, count, entry);
 }
        public void t_FiftyMeterDataEntry()
        {
            FiftyMeterDataEntry target = new FiftyMeterDataEntry();

            Assert.IsNotNull(target);
        }