use of de.symeda.sormas.api.contact.MapContactDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testMapContactListCreation.
@Test
public void testMapContactListCreation() {
TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = useSurveillanceOfficerLogin(rdcf);
PersonDto cazePerson = creator.createPerson("Case", "Person");
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
PersonDto contactPerson = creator.createPerson("Contact", "Person", p -> {
p.getAddress().setLatitude(0.0);
p.getAddress().setLongitude(0.0);
});
creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), caze.getDisease(), rdcf);
Long count = getContactFacade().countContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
List<MapContactDto> mapContactDtos = getContactFacade().getContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
// List should have one entry
assertEquals((long) count, mapContactDtos.size());
assertEquals((long) 1, mapContactDtos.size());
}
use of de.symeda.sormas.api.contact.MapContactDto 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.contact.MapContactDto in project SORMAS-Project by hzi-braunschweig.
the class ContactService method getContactsForMap.
public List<MapContactDto> getContactsForMap(Region region, District district, Disease disease, Date from, Date to) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<MapContactDto> cq = cb.createQuery(MapContactDto.class);
Root<Contact> contact = cq.from(getElementClass());
Join<Contact, Person> person = contact.join(Contact.PERSON, JoinType.LEFT);
Join<Person, Location> contactPersonAddress = person.join(Person.ADDRESS, JoinType.LEFT);
Join<Contact, Case> caze = contact.join(Contact.CAZE, JoinType.LEFT);
Join<Case, Person> casePerson = caze.join(Case.PERSON, JoinType.LEFT);
Join<Case, Symptoms> symptoms = caze.join(Case.SYMPTOMS, JoinType.LEFT);
Predicate filter = createMapContactsFilter(cb, cq, contact, caze, contactPersonAddress, region, district, disease, from, to);
List<MapContactDto> result;
if (filter != null) {
cq.where(filter);
cq.multiselect(contact.get(Contact.UUID), contact.get(Contact.CONTACT_CLASSIFICATION), contact.get(Contact.REPORT_LAT), contact.get(Contact.REPORT_LON), contactPersonAddress.get(Location.LATITUDE), contactPersonAddress.get(Location.LONGITUDE), symptoms.get(Symptoms.ONSET_DATE), caze.get(Case.REPORT_DATE), contact.get(Contact.REPORT_DATE_TIME), person.get(Person.FIRST_NAME), person.get(Person.LAST_NAME), casePerson.get(Person.FIRST_NAME), casePerson.get(Person.LAST_NAME));
result = em.createQuery(cq).getResultList();
// #1274 Temporarily disabled because it severely impacts the performance of the
// Dashboard
// for (MapContactDto mapContactDto : result) {
// Visit lastVisit =
// visitService.getLastVisitByContact(getByUuid(mapContactDto.getUuid()),
// VisitStatus.COOPERATIVE);
// if (lastVisit != null) {
// mapContactDto.setLastVisitDateTime(lastVisit.getVisitDateTime());
// }
// }
} else {
result = Collections.emptyList();
}
return result;
}
use of de.symeda.sormas.api.contact.MapContactDto in project SORMAS-Project by hzi-braunschweig.
the class DashboardMapComponent method showContactMarkers.
private void showContactMarkers(List<MapContactDto> contacts) {
clearContactMarkers();
List<LeafletMarker> contactMarkers = new ArrayList<LeafletMarker>();
for (MapContactDto contact : contacts) {
// Don't show a marker for contacts that don't have geo coordinates
if (contact.getAddressLat() == null || contact.getAddressLon() == null) {
if (contact.getReportLat() == null || contact.getReportLon() == null) {
continue;
}
}
// Don't show a marker for contacts that are filtered out
if (!showUnconfirmedContacts && contact.getContactClassification() == ContactClassification.UNCONFIRMED) {
continue;
}
if (!showConfirmedContacts && contact.getContactClassification() != ContactClassification.UNCONFIRMED) {
continue;
}
MarkerIcon icon;
// }
switch(contact.getContactClassification()) {
case CONFIRMED:
icon = MarkerIcon.CONTACT_LONG_OVERDUE;
break;
case UNCONFIRMED:
icon = MarkerIcon.CONTACT_OVERDUE;
break;
case NO_CONTACT:
icon = MarkerIcon.CONTACT_OK;
break;
default:
icon = MarkerIcon.CONTACT_OK;
break;
}
LeafletMarker marker = new LeafletMarker();
marker.setIcon(icon);
if (contact.getAddressLat() != null && contact.getAddressLon() != null) {
marker.setLatLon(contact.getAddressLat(), contact.getAddressLon());
} else {
marker.setLatLon(contact.getReportLat(), contact.getReportLon());
}
markerContacts.add(contact);
contactMarkers.add(marker);
}
map.addMarkerGroup(CONTACTS_GROUP_ID, contactMarkers);
}
Aggregations