Search in sources :

Example 1 with DashboardEventDto

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;
    }
}
Also used : Window(com.vaadin.ui.Window) MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) VerticalLayout(com.vaadin.ui.VerticalLayout) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto)

Example 2 with DashboardEventDto

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;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EventQueryContext(de.symeda.sormas.backend.event.EventQueryContext) Predicate(javax.persistence.criteria.Predicate) Event(de.symeda.sormas.backend.event.Event) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) EventJoins(de.symeda.sormas.utils.EventJoins) District(de.symeda.sormas.backend.infrastructure.district.District) Location(de.symeda.sormas.backend.location.Location)

Example 3 with DashboardEventDto

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());
}
Also used : UserDto(de.symeda.sormas.api.user.UserDto) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) EventDto(de.symeda.sormas.api.event.EventDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) DashboardCriteria(de.symeda.sormas.api.dashboard.DashboardCriteria) Date(java.util.Date) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 4 with DashboardEventDto

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);
}
Also used : LeafletMarker(de.symeda.sormas.ui.map.LeafletMarker) ArrayList(java.util.ArrayList) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) MarkerIcon(de.symeda.sormas.ui.map.MarkerIcon) GeoLatLon(de.symeda.sormas.api.geo.GeoLatLon)

Aggregations

DashboardEventDto (de.symeda.sormas.api.dashboard.DashboardEventDto)4 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1 MapCaseDto (de.symeda.sormas.api.caze.MapCaseDto)1 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)1 DashboardCriteria (de.symeda.sormas.api.dashboard.DashboardCriteria)1 EventDto (de.symeda.sormas.api.event.EventDto)1 GeoLatLon (de.symeda.sormas.api.geo.GeoLatLon)1 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)1 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)1 Event (de.symeda.sormas.backend.event.Event)1 EventQueryContext (de.symeda.sormas.backend.event.EventQueryContext)1 District (de.symeda.sormas.backend.infrastructure.district.District)1 Location (de.symeda.sormas.backend.location.Location)1 LeafletMarker (de.symeda.sormas.ui.map.LeafletMarker)1 MarkerIcon (de.symeda.sormas.ui.map.MarkerIcon)1 EventJoins (de.symeda.sormas.utils.EventJoins)1