Esempio n. 1
0
        public ActionResult Details(JhroCaseViewModel vm)
        {
            if (vm != null)
            {
                JhroCase jc = null;
                if (vm.Id > 0)
                {
                    jc = this.sourceTasks.GetJhroCase(vm.Id);
                }
                else if (!string.IsNullOrEmpty(vm.CaseNumber))
                {
                    jc = this.sourceTasks.GetJhroCase(vm.CaseNumber);
                }

                if (jc != null)
                {
                    ViewBag.JhroCase = jc;

                    HrdbCase hrdbCase = (HrdbCase)StreamUtil.Deserialize(jc.HrdbContentsSerialized);

                    return(View(hrdbCase));
                }
            }
            return(new HttpNotFoundResult());
        }
Esempio n. 2
0
        public JsonNetResult FindMatchingEventCandidates(int id)
        {
            JhroCase jc = this.sourceTasks.GetJhroCase(id);

            if (jc != null)
            {
                // if not already linked to an Event...
                if (!jc.Events.Any())
                {
                    HrdbCase hrdbCase = (HrdbCase)StreamUtil.Deserialize(jc.HrdbContentsSerialized);

                    // ...find potential matching Events to link to this case
                    return(JsonNet(new
                    {
                        Events = this.eventMatchingTasks.FindMatchingEventCandidates(jc, hrdbCase)
                    }));
                }
                else
                {
                    Response.StatusCode        = (int)HttpStatusCode.InternalServerError;
                    Response.StatusDescription = "That case already has an event linked.";
                    return(JsonNet(Response.StatusDescription));
                }
            }
            else
            {
                Response.StatusCode        = (int)HttpStatusCode.NotFound;
                Response.StatusDescription = "That case doesn't exist.";
                return(JsonNet(Response.StatusDescription));
            }
        }
Esempio n. 3
0
        public HrdbCaseViewModel(JhroCase jc)
        {
            if (jc != null)
            {
                this.Id = jc.Id;
                if (jc.Events != null && jc.Events.Any())
                {
                    // currently assuming one Event (but data model can take multiple)
                    this.EventId = jc.Events[0].Id;
                }

                HrdbCase hc = (HrdbCase)StreamUtil.Deserialize(jc.HrdbContentsSerialized);
                if (hc != null)
                {
                    this.HrdbCase = hc;

                    this.HrdbPerpetrators = hc.Perpetrators.Select(x => new HrdbPerpetratorViewModel(x)).ToList();

                    // pre-populate new Event fields
                    this.Event = new EventViewModel();
                    this.Event.PopulateDropDowns(ServiceLocator.Current.GetInstance <IEventTasks>().GetAllEventVerifiedStatuses());
                    this.Event.ViolationIds = string.Join(",", this.HrdbPerpetrators.Select(x => x.GetViolationIds()).Aggregate(new List <int>(), (x, y) => x.Concat(y).ToList()));
                    this.Event.NarrativeEn  = string.Join("\n\n", new string[] { "Summary", hc.Summary, "Analysis", hc.AnalysisDesc, "Facts", hc.FactAnalysis, "Legal", hc.LegalAnalysis, "Methodology", hc.Methodology });
                    if (hc.StartDate.HasValue)
                    {
                        this.Event.YearOfStart  = hc.StartDate.Value.Year;
                        this.Event.MonthOfStart = hc.StartDate.Value.Month;
                        this.Event.DayOfStart   = hc.StartDate.Value.Day;
                    }
                    if (hc.EndDate.HasValue)
                    {
                        this.Event.YearOfEnd  = hc.EndDate.Value.Year;
                        this.Event.MonthOfEnd = hc.EndDate.Value.Month;
                        this.Event.DayOfEnd   = hc.EndDate.Value.Day;
                    }
                    // location
                    Location loc = ServiceLocator.Current.GetInstance <ILocationTasks>().GetOrCreateLocation(hc.IncidentAddr, hc.TownVillage, hc.Subregion, hc.Region, hc.GetLatitude(), hc.GetLongitude());
                    if (loc != null)
                    {
                        this.Event.LocationId = loc.Id;
                    }
                    // notes
                    this.Event.EventVerifiedStatusId = ServiceLocator.Current.GetInstance <IEventTasks>().GetEventVerifiedStatus(
                        hc.IsComplaintCode() ? EventVerifiedStatus.ALLEGATION : EventVerifiedStatus.JHRO_VERIFIED).Id;
                    this.Event.JhroCaseIds = jc.Id.ToString();
                }
            }

            this.OrganizationResponsibilityTypes = ServiceLocator.Current.GetInstance <IResponsibilityTasks>().GetOrgResponsibilityTypes()
                                                   .Select(x => new SelectListItem()
            {
                Text = x.OrganizationResponsibilityTypeName, Value = x.Id.ToString()
            })
                                                   .ToList();

            this.PersonResponsibilityTypes = ServiceLocator.Current.GetInstance <IResponsibilityTasks>().GetPersonResponsibilityTypes()
                                             .Select(x => new SelectListItem()
            {
                Text = x.PersonResponsibilityTypeName, Value = x.Id.ToString()
            })
                                             .ToList();
        }
Esempio n. 4
0
        public IDictionary <string, IList <object> > FindMatchingEventCandidates(JhroCase jhroCase, HrdbCase hrdbCase)
        {
            IDictionary <string, IList <object> > results = new Dictionary <string, IList <object> >();

            string caseCode = jhroCase != null ? jhroCase.CaseNumber : (hrdbCase != null ? hrdbCase.CaseCode : null);

            // search Event.Notes field for mention of the case code
            results["CodeInEventNotes"] = this.eventTasks.SearchEventNotes(caseCode).Select(x => x.ToShortHeadlineJSON()).ToList();

            // search EventSource commentaries and notes for mention of the case code
            results["CodeInEventSourceCommentary"] = this.sourceAttachmentTasks.SearchEventSources(caseCode)
                                                     .Select(x => x.Event)
                                                     .Distinct()
                                                     .Select(x => x.ToShortHeadlineJSON())
                                                     .ToList();

            // search fields indexed by Lucene
            if (hrdbCase != null)
            {
                results["DateAndLocation"] = this.luceneTasks
                                             .FindMatchingEventCandidates(hrdbCase.StartDate.HasValue ? hrdbCase.StartDate : null,
                                                                          hrdbCase.EndDate.HasValue ? hrdbCase.EndDate : null,
                                                                          hrdbCase.CaseCode, hrdbCase.TownVillage, hrdbCase.Subregion, hrdbCase.Region)
                                             .Select(x => this.eventTasks.GetEvent(new EventDataTableView(x).Id).ToShortHeadlineJSON())
                                             .Distinct()
                                             .ToList();
            }

            return(results);
        }