use of de.symeda.sormas.api.dashboard.DashboardEventDto in project SORMAS-Project by hzi-braunschweig.
the class DashboardMapComponent method onMarkerClicked.
private void onMarkerClicked(String groupId, int markerIndex) {
switch(groupId) {
case CASES_GROUP_ID:
if (markerIndex < markerCaseFacilities.size()) {
FacilityReferenceDto facility = markerCaseFacilities.get(markerIndex);
VerticalLayout layout = new VerticalLayout();
Window window = VaadinUiUtil.showPopupWindow(layout);
CasePopupGrid caseGrid = new CasePopupGrid(window, facility, DashboardMapComponent.this);
caseGrid.setHeightMode(HeightMode.ROW);
layout.addComponent(caseGrid);
layout.setMargin(true);
FacilityDto facilityDto = FacadeProvider.getFacilityFacade().getByUuid(facility.getUuid());
window.setCaption(I18nProperties.getCaption(Captions.dashboardCasesIn) + " " + facilityDto.toString());
} else {
markerIndex -= markerCaseFacilities.size();
MapCaseDto caze = mapCaseDtos.get(markerIndex);
ControllerProvider.getCaseController().navigateToCase(caze.getUuid(), true);
}
break;
case CONTACTS_GROUP_ID:
MapContactDto contact = markerContacts.get(markerIndex);
ControllerProvider.getContactController().navigateToData(contact.getUuid(), true);
break;
case EVENTS_GROUP_ID:
DashboardEventDto event = markerEvents.get(markerIndex);
ControllerProvider.getEventController().navigateToData(event.getUuid(), true);
break;
}
}
use of de.symeda.sormas.api.dashboard.DashboardEventDto in project SORMAS-Project by hzi-braunschweig.
the class DashboardService method getNewEvents.
public List<DashboardEventDto> getNewEvents(DashboardCriteria dashboardCriteria) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<DashboardEventDto> cq = cb.createQuery(DashboardEventDto.class);
Root<Event> event = cq.from(Event.class);
EventQueryContext eventQueryContext = new EventQueryContext(cb, cq, event);
EventJoins<Event> eventJoins = (EventJoins<Event>) eventQueryContext.getJoins();
Join<Event, Location> eventLocation = eventJoins.getLocation();
Join<Location, District> eventDistrict = eventJoins.getDistrict();
Predicate filter = eventService.createDefaultFilter(cb, event);
filter = CriteriaBuilderHelper.and(cb, filter, buildEventCriteriaFilter(dashboardCriteria, eventQueryContext));
filter = CriteriaBuilderHelper.and(cb, filter, eventService.createUserFilter(cb, cq, event));
List<DashboardEventDto> result;
if (filter != null) {
cq.where(filter);
cq.multiselect(event.get(Event.UUID), event.get(Event.EVENT_STATUS), event.get(Event.EVENT_INVESTIGATION_STATUS), event.get(Event.DISEASE), event.get(Event.DISEASE_DETAILS), event.get(Event.START_DATE), event.get(Event.REPORT_LAT), event.get(Event.REPORT_LON), eventLocation.get(Location.LATITUDE), eventLocation.get(Location.LONGITUDE), eventJoins.getReportingUser().get(User.UUID), eventJoins.getResponsibleUser().get(User.UUID), eventJoins.getRegion().get(Region.UUID), eventDistrict.get(District.NAME), eventDistrict.get(District.UUID), eventJoins.getCommunity().get(Community.UUID), JurisdictionHelper.booleanSelector(cb, eventService.inJurisdictionOrOwned(eventQueryContext)));
result = em.createQuery(cq).getResultList();
} else {
result = Collections.emptyList();
}
return result;
}
use of de.symeda.sormas.api.dashboard.DashboardEventDto in project SORMAS-Project by hzi-braunschweig.
the class DashboardFacadeEjbTest method testDashboardEventListCreation.
@Test
public void testDashboardEventListCreation() {
TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
EventDto event = creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, new Date(), new Date(), user.toReference(), user.toReference(), Disease.EVD, rdcf.district);
List<DashboardEventDto> dashboardEventDtos = getDashboardFacade().getNewEvents(new DashboardCriteria().region(event.getEventLocation().getRegion()).district(event.getEventLocation().getDistrict()).disease(event.getDisease()).dateBetween(DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1)));
// List should have one entry
assertEquals(1, dashboardEventDtos.size());
}
use of de.symeda.sormas.api.dashboard.DashboardEventDto in project SORMAS-Project by hzi-braunschweig.
the class DashboardMapComponent method showEventMarkers.
private void showEventMarkers(List<DashboardEventDto> events) {
clearEventMarkers();
List<LeafletMarker> eventMarkers = new ArrayList<LeafletMarker>();
for (DashboardEventDto event : events) {
MarkerIcon icon;
switch(event.getEventStatus()) {
case EVENT:
icon = MarkerIcon.EVENT_OUTBREAK;
break;
case SIGNAL:
icon = MarkerIcon.EVENT_RUMOR;
break;
default:
continue;
}
// Because events are pulled from the dashboardDataProvider, we do not need to add additional filters for event dates here
LeafletMarker marker = new LeafletMarker();
if (event.getLocationLat() != null && event.getLocationLon() != null) {
marker.setLatLon(event.getLocationLat(), event.getLocationLon());
} else if (event.getReportLat() != null && event.getReportLon() != null) {
marker.setLatLon(event.getReportLat(), event.getReportLon());
} else if (event.getDistrict() != null) {
GeoLatLon districtCenter = FacadeProvider.getGeoShapeProvider().getCenterOfDistrict(event.getDistrict());
if (districtCenter != null) {
marker.setLatLon(districtCenter.getLat(), districtCenter.getLon());
} else {
GeoLatLon countryCenter = FacadeProvider.getConfigFacade().getCountryCenter();
marker.setLatLon(countryCenter.getLat(), countryCenter.getLon());
}
} else {
continue;
}
marker.setIcon(icon);
markerEvents.add(event);
eventMarkers.add(marker);
}
map.addMarkerGroup(EVENTS_GROUP_ID, eventMarkers);
}
Aggregations