use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjb method getIndexList.
@Override
public List<ContactIndexDto> getIndexList(ContactCriteria contactCriteria, Integer first, Integer max, List<SortProperty> sortProperties) {
CriteriaQuery<ContactIndexDto> query = listCriteriaBuilder.buildIndexCriteria(contactCriteria, sortProperties);
List<ContactIndexDto> dtos = QueryHelper.getResultList(em, query, first, max);
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
pseudonymizer.pseudonymizeDtoCollection(ContactIndexDto.class, dtos, ContactIndexDto::getInJurisdiction, (c, isInJurisdiction) -> {
if (c.getCaze() != null) {
pseudonymizer.pseudonymizeDto(CaseReferenceDto.class, c.getCaze(), c.getCaseInJurisdiction(), null);
}
});
return dtos;
}
use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.
the class ContactController method showBulkContactDataEditComponent.
public void showBulkContactDataEditComponent(Collection<? extends ContactIndexDto> selectedContacts, String caseUuid) {
if (selectedContacts.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
// Check if cases with multiple districts have been selected
String districtUuid = null;
for (ContactIndexDto selectedContact : selectedContacts) {
String selectedDistrictUuid = selectedContact.getDistrictUuid();
if (districtUuid == null) {
districtUuid = selectedDistrictUuid;
} else if (!districtUuid.equals(selectedDistrictUuid)) {
districtUuid = null;
break;
}
}
DistrictReferenceDto district = districtUuid != null ? FacadeProvider.getDistrictFacade().getReferenceByUuid(districtUuid) : null;
// Create a temporary contact in order to use the CommitDiscardWrapperComponent
ContactBulkEditData bulkEditData = new ContactBulkEditData();
BulkContactDataForm form = new BulkContactDataForm(district, selectedContacts);
form.setValue(bulkEditData);
final CommitDiscardWrapperComponent<BulkContactDataForm> editView = new CommitDiscardWrapperComponent<BulkContactDataForm>(form, form.getFieldGroup());
Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getString(Strings.headingEditContacts));
editView.addCommitListener(() -> {
ContactBulkEditData updatedBulkEditData = form.getValue();
ContactFacade contactFacade = FacadeProvider.getContactFacade();
boolean classificationChange = form.getClassificationCheckBox().getValue();
boolean contactOfficerChange = district != null ? form.getContactOfficerCheckBox().getValue() : false;
int changedContacts = bulkEdit(selectedContacts, updatedBulkEditData, contactFacade, classificationChange, contactOfficerChange);
popupWindow.close();
if (caseUuid == null) {
overview();
} else {
caseContactsOverview(caseUuid);
}
if (changedContacts == selectedContacts.size()) {
Notification.show(I18nProperties.getString(Strings.messageContactsEdited), Type.HUMANIZED_MESSAGE);
} else {
NotificationHelper.showNotification(String.format(I18nProperties.getString(Strings.messageContactsEditedExceptArchived), changedContacts), Type.HUMANIZED_MESSAGE, -1);
}
});
editView.addDiscardListener(() -> popupWindow.close());
}
use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.
the class AbstractContactGrid method initColumns.
@SuppressWarnings("unchecked")
protected void initColumns() {
Column<IndexDto, String> diseaseShortColumn = addColumn(entry -> DiseaseHelper.toString(entry.getDisease(), entry.getDiseaseDetails()));
diseaseShortColumn.setId(DISEASE_SHORT);
diseaseShortColumn.setSortProperty(ContactIndexDto.DISEASE);
Column<IndexDto, String> visitsColumn = addColumn(entry -> {
if (FacadeProvider.getDiseaseConfigurationFacade().hasFollowUp(entry.getDisease())) {
int numberOfVisits = entry.getVisitCount();
int numberOfRequiredVisits = FollowUpLogic.getNumberOfRequiredVisitsSoFar(entry.getReportDateTime(), entry.getFollowUpUntil());
int numberOfMissedVisits = numberOfRequiredVisits - numberOfVisits;
// Set number of missed visits to 0 when more visits than expected have been done
if (numberOfMissedVisits < 0) {
numberOfMissedVisits = 0;
}
return String.format(I18nProperties.getCaption(Captions.formatNumberOfVisitsFormat), numberOfVisits, numberOfMissedVisits);
} else {
return "-";
}
});
visitsColumn.setId(NUMBER_OF_VISITS);
visitsColumn.setSortable(false);
addComponentColumn(indexDto -> {
Label label = new Label(indexDto.getCompleteness() != null ? new DecimalFormat("#").format(indexDto.getCompleteness() * 100) + " %" : "-");
if (indexDto.getCompleteness() != null) {
if (indexDto.getCompleteness() < 0.25f) {
CssStyles.style(label, CssStyles.LABEL_CRITICAL);
} else if (indexDto.getCompleteness() < 0.5f) {
CssStyles.style(label, CssStyles.LABEL_IMPORTANT);
} else if (indexDto.getCompleteness() < 0.75f) {
CssStyles.style(label, CssStyles.LABEL_RELEVANT);
} else {
CssStyles.style(label, CssStyles.LABEL_POSITIVE);
}
}
return label;
}).setId(COLUMN_COMPLETENESS);
getColumn(COLUMN_COMPLETENESS).setCaption(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.COMPLETENESS));
getColumn(COLUMN_COMPLETENESS).setSortable(false);
boolean tasksFeatureEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TASK_MANAGEMENT);
if (tasksFeatureEnabled) {
Column<IndexDto, String> pendingTasksColumn = addColumn(entry -> String.format(I18nProperties.getCaption(Captions.formatSimpleNumberFormat), FacadeProvider.getTaskFacade().getPendingTaskCountByContact(entry.toReference())));
pendingTasksColumn.setId(NUMBER_OF_PENDING_TASKS);
pendingTasksColumn.setSortable(false);
}
setColumns(getColumnList().toArray(String[]::new));
if (!FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY)) {
getColumn(ContactIndexDto.CONTACT_CATEGORY).setHidden(true);
}
if (!FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY) && !FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
getColumn(CaseIndexDto.EXTERNAL_ID).setHidden(true);
getColumn(CaseIndexDto.EXTERNAL_TOKEN).setHidden(true);
}
getColumn(ContactIndexDto.CONTACT_PROXIMITY).setWidth(200);
((Column<ContactIndexDto, String>) getColumn(ContactIndexDto.UUID)).setRenderer(new UuidRenderer());
((Column<ContactIndexDto, String>) getColumn(ContactIndexDto.PERSON_UUID)).setRenderer(new UuidRenderer());
((Column<ContactIndexDto, Date>) getColumn(ContactIndexDto.FOLLOW_UP_UNTIL)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat()));
if (!FacadeProvider.getConfigFacade().isExternalJournalActive()) {
getColumn(ContactIndexDto.SYMPTOM_JOURNAL_STATUS).setHidden(true);
}
for (Column<IndexDto, ?> column : getColumns()) {
column.setCaption(I18nProperties.findPrefixCaptionWithDefault(column.getId(), column.getCaption(), ContactIndexDto.I18N_PREFIX, PersonDto.I18N_PREFIX, LocationDto.I18N_PREFIX));
column.setStyleGenerator(FieldAccessColumnStyleGenerator.getDefault(getBeanType(), column.getId()));
}
}
use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.
the class ContactsView method createStatusFilterBar.
public HorizontalLayout createStatusFilterBar() {
HorizontalLayout statusFilterLayout = new HorizontalLayout();
statusFilterLayout.setMargin(false);
statusFilterLayout.setSpacing(true);
statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
statusButtons = new HashMap<>();
Button statusAll = ButtonHelper.createButton(I18nProperties.getCaption(Captions.all), e -> {
criteria.contactStatus(null);
navigateTo(criteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
statusAll.setCaptionAsHtml(true);
if (ContactsViewType.FOLLOW_UP_VISITS_OVERVIEW.equals(viewConfiguration.getViewType())) {
CssStyles.style(statusAll, CssStyles.FORCE_CAPTION);
}
statusFilterLayout.addComponent(statusAll);
statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
activeStatusButton = statusAll;
for (ContactStatus status : ContactStatus.values()) {
Button statusButton = ButtonHelper.createButton("status-" + status.toString(), status.toString(), e -> {
criteria.contactStatus(status);
navigateTo(criteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
statusButton.setCaptionAsHtml(true);
statusButton.setData(status);
if (ContactsViewType.FOLLOW_UP_VISITS_OVERVIEW.equals(viewConfiguration.getViewType())) {
CssStyles.style(statusButton, CssStyles.FORCE_CAPTION);
}
statusFilterLayout.addComponent(statusButton);
statusButtons.put(statusButton, status.toString());
}
HorizontalLayout actionButtonsLayout = new HorizontalLayout();
actionButtonsLayout.setSpacing(true);
{
// Show active/archived/all dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) {
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.AUTOMATIC_ARCHIVING, CoreEntityType.CONTACT)) {
int daysAfterContactGetsArchived = FacadeProvider.getFeatureConfigurationFacade().getProperty(FeatureType.AUTOMATIC_ARCHIVING, CoreEntityType.CONTACT, FeatureTypeProperty.THRESHOLD_IN_DAYS, Integer.class);
if (daysAfterContactGetsArchived > 0) {
relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedContacts), daysAfterContactGetsArchived), ContentMode.HTML);
relevanceStatusInfoLabel.setVisible(false);
relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
}
}
relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
relevanceStatusFilter.setId("relevanceStatus");
relevanceStatusFilter.setWidth(140, Unit.PERCENTAGE);
relevanceStatusFilter.setNullSelectionAllowed(false);
relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.contactActiveContacts));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.contactArchivedContacts));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.contactAllContacts));
relevanceStatusFilter.addValueChangeListener(e -> {
if (relevanceStatusInfoLabel != null) {
relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
}
criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(criteria);
});
actionButtonsLayout.addComponent(relevanceStatusFilter);
}
// Bulk operation dropdown
if (isBulkEditAllowed()) {
statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
boolean hasBulkOperationsRight = UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS);
List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>(Arrays.asList(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().showBulkContactDataEditComponent(items, null)), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().cancelFollowUpOfAllSelectedItems(items, () -> navigateTo(criteria))), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp(items, () -> navigateTo(criteria))), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().deleteAllSelectedItems(items, () -> navigateTo(criteria)), true), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.sormasToSormasShare), VaadinIcons.SHARE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getSormasToSormasController().shareSelectedContacts(items, () -> navigateTo(criteria))), FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser())));
if (isDocGenerationAllowed() && grid instanceof AbstractContactGrid) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> grid.bulkActionHandler(items -> {
List<ReferenceDto> references = ((AbstractContactGrid<?>) grid).asMultiSelect().getSelectedItems().stream().map(ContactIndexDto::toReference).collect(Collectors.toList());
if (references.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
ControllerProvider.getDocGenerationController().showBulkQuarantineOrderDocumentDialog(references, DocumentWorkflow.QUARANTINE_ORDER_CONTACT);
})));
}
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLinkToEvent), VaadinIcons.PHONE, mi -> grid.bulkActionHandler(items -> {
List<ContactIndexDto> selectedContacts = grid.asMultiSelect().getSelectedItems().stream().map(item -> (ContactIndexDto) item).collect(Collectors.toList());
if (selectedContacts.isEmpty()) {
new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
if (!selectedContacts.stream().allMatch(contact -> contact.getDisease().equals(selectedContacts.stream().findAny().get().getDisease()))) {
new Notification(I18nProperties.getString(Strings.messageBulkContactsWithDifferentDiseasesSelected), Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
return;
}
ControllerProvider.getEventController().selectOrCreateEventForContactList(selectedContacts.stream().map(ContactIndexDto::toReference).collect(Collectors.toList()));
})));
}
bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
actionButtonsLayout.addComponent(bulkOperationsDropdown);
}
}
statusFilterLayout.addComponent(actionButtonsLayout);
statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
return statusFilterLayout;
}
use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.
the class SourceContactList method drawDisplayedEntries.
@Override
protected void drawDisplayedEntries() {
List<ContactIndexDto> displayedEntries = getDisplayedEntries();
for (int i = 0, displayedEntriesSize = displayedEntries.size(); i < displayedEntriesSize; i++) {
ContactIndexDto contact = displayedEntries.get(i);
SourceContactListEntry listEntry = new SourceContactListEntry(contact);
if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EDIT)) {
listEntry.addEditListener(i, (ClickListener) e -> ControllerProvider.getContactController().navigateToData(listEntry.getContact().getUuid()));
}
listLayout.addComponent(listEntry);
}
}
Aggregations