use of de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationController method getImmunizationDataEditComponent.
public CommitDiscardWrapperComponent<ImmunizationDataForm> getImmunizationDataEditComponent(ImmunizationDto immunizationDto) {
ImmunizationDataForm immunizationDataForm = new ImmunizationDataForm(immunizationDto.isPseudonymized(), immunizationDto.getRelatedCase());
immunizationDataForm.setValue(immunizationDto);
UserProvider currentUserProvider = UserProvider.getCurrent();
CommitDiscardWrapperComponent<ImmunizationDataForm> editComponent = new CommitDiscardWrapperComponent<ImmunizationDataForm>(immunizationDataForm, currentUserProvider != null && currentUserProvider.hasUserRight(UserRight.IMMUNIZATION_EDIT), immunizationDataForm.getFieldGroup()) {
@Override
public void discard() {
immunizationDataForm.discard();
super.discard();
}
};
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getImmunizationFacade().getAutomaticDeletionInfo(immunizationDto.getUuid());
if (automaticDeletionInfoDto != null) {
editComponent.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
editComponent.addCommitListener(() -> {
if (!immunizationDataForm.getFieldGroup().isModified()) {
ImmunizationDto immunizationDtoValue = immunizationDataForm.getValue();
List<ImmunizationDto> similarImmunizations = findSimilarImmunizations(immunizationDtoValue);
if (similarImmunizations.isEmpty()) {
FacadeProvider.getImmunizationFacade().save(immunizationDtoValue);
if (immunizationDtoValue.getImmunizationStatus() == ImmunizationStatus.ACQUIRED) {
NotificationHelper.showNotification(I18nProperties.getString(Strings.messageImmunizationSavedVaccinationStatusUpdated), Notification.Type.WARNING_MESSAGE, -1);
} else {
Notification.show(I18nProperties.getString(Strings.messageImmunizationSaved), Notification.Type.WARNING_MESSAGE);
}
SormasUI.refreshView();
} else {
showSimilarImmunizationPopup(immunizationDtoValue, similarImmunizations.get(0), this::saveImmunization);
}
}
});
// Initialize 'Delete' button
if (UserProvider.getCurrent().hasUserRight(UserRight.IMMUNIZATION_DELETE)) {
editComponent.addDeleteListener(() -> {
FacadeProvider.getImmunizationFacade().deleteImmunization(immunizationDto.getUuid());
UI.getCurrent().getNavigator().navigateTo(ImmunizationsView.VIEW_NAME);
}, I18nProperties.getString(Strings.entityImmunization));
}
// Initialize 'Archive' button
if (UserProvider.getCurrent().hasUserRight(UserRight.IMMUNIZATION_ARCHIVE)) {
boolean archived = FacadeProvider.getImmunizationFacade().isArchived(immunizationDto.getUuid());
Button archiveButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
if (editComponent.isModified()) {
editComponent.commit();
}
if (archived) {
ControllerProvider.getArchiveController().dearchiveEntity(immunizationDto, FacadeProvider.getImmunizationFacade(), Strings.headingDearchiveImmunization, Strings.confirmationDearchiveImmunization, Strings.entityImmunization, Strings.messageImmunizationDearchived, () -> navigateToImmunization(immunizationDto.getUuid()));
} else {
ControllerProvider.getArchiveController().archiveEntity(immunizationDto, FacadeProvider.getImmunizationFacade(), Strings.headingArchiveImmunization, Strings.confirmationArchiveImmunization, Strings.entityImmunization, Strings.messageImmunizationArchived, () -> navigateToImmunization(immunizationDto.getUuid()));
}
}, ValoTheme.BUTTON_LINK);
editComponent.getButtonsPanel().addComponentAsFirst(archiveButton);
editComponent.getButtonsPanel().setComponentAlignment(archiveButton, Alignment.BOTTOM_LEFT);
}
return editComponent;
}
use of de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto in project SORMAS-Project by hzi-braunschweig.
the class CaseController method getCaseDataEditComponent.
// public CommitDiscardWrapperComponent<? extends Component> getCaseCombinedEditComponent(final String caseUuid,
// final ViewMode viewMode) {
//
// CaseDataDto caze = findCase(caseUuid);
// PersonDto person = FacadeProvider.getPersonFacade().getPersonByUuid(caze.getPerson().getUuid());
//
// CaseDataForm caseEditForm = new CaseDataForm(person, caze.getDisease(), viewMode);
// caseEditForm.setValue(caze);
//
// HospitalizationForm hospitalizationForm = new HospitalizationForm(caze, viewMode);
// hospitalizationForm.setValue(caze.getHospitalization());
//
// SymptomsForm symptomsForm = new SymptomsForm(caze, caze.getDisease(), person, SymptomsContext.CASE, viewMode);
// symptomsForm.setValue(caze.getSymptoms());
//
// EpiDataForm epiDataForm = new EpiDataForm(caze.getDisease(), viewMode);
// epiDataForm.setValue(caze.getEpiData());
//
// CommitDiscardWrapperComponent<? extends Component> editView = AbstractEditForm
// .buildCommitDiscardWrapper(caseEditForm, hospitalizationForm, symptomsForm, epiDataForm);
//
// editView.addCommitListener(new CommitListener() {
// @Override
// public void onCommit() {
// CaseDataDto cazeDto = caseEditForm.getValue();
// cazeDto.setHospitalization(hospitalizationForm.getValue());
// cazeDto.setSymptoms(symptomsForm.getValue());
// cazeDto.setEpiData(epiDataForm.getValue());
//
// saveCase(cazeDto);
// }
// });
//
// appendSpecialCommands(caze, editView);
//
// return editView;
// }
public CommitDiscardWrapperComponent<CaseDataForm> getCaseDataEditComponent(final String caseUuid, final ViewMode viewMode) {
CaseDataDto caze = findCase(caseUuid);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getCaseFacade().getAutomaticDeletionInfo(caseUuid);
CaseDataForm caseEditForm = new CaseDataForm(caseUuid, FacadeProvider.getPersonFacade().getPersonByUuid(caze.getPerson().getUuid()), caze.getDisease(), caze.getSymptoms(), viewMode, caze.isPseudonymized());
caseEditForm.setValue(caze);
CommitDiscardWrapperComponent<CaseDataForm> editView = new CommitDiscardWrapperComponent<CaseDataForm>(caseEditForm, UserProvider.getCurrent().hasUserRight(UserRight.CASE_EDIT), caseEditForm.getFieldGroup());
if (automaticDeletionInfoDto != null) {
editView.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
editView.addCommitListener(() -> {
CaseDataDto oldCase = findCase(caseUuid);
CaseDataDto cazeDto = caseEditForm.getValue();
saveCaseWithFacilityChangedPrompt(cazeDto, oldCase);
});
editView.addDiscardListener(() -> caseEditForm.onDiscard());
appendSpecialCommands(caze, editView);
return editView;
}
use of de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantsController method getEventParticipantDataEditComponent.
public CommitDiscardWrapperComponent<?> getEventParticipantDataEditComponent(String eventParticipantUuid) {
final EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(eventParticipantUuid);
final EventDto event = FacadeProvider.getEventFacade().getEventByUuid(eventParticipant.getEvent().getUuid(), false);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getEventParticipantFacade().getAutomaticDeletionInfo(eventParticipantUuid);
final EventParticipantEditForm editForm = new EventParticipantEditForm(event, eventParticipant.isPseudonymized(), eventParticipant.getPerson().isPseudonymized(), false);
editForm.setValue(eventParticipant);
editForm.setWidth(100, Unit.PERCENTAGE);
final CommitDiscardWrapperComponent<EventParticipantEditForm> editComponent = createEventParticipantEditCommitWrapper(editForm, null);
if (automaticDeletionInfoDto != null) {
editComponent.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_DELETE)) {
editComponent.addDeleteListener(() -> {
FacadeProvider.getEventParticipantFacade().deleteEventParticipant(eventParticipant.toReference());
ControllerProvider.getEventController().navigateToParticipants(eventParticipant.getEvent().getUuid());
}, I18nProperties.getString(Strings.entityEventParticipant));
}
// Initialize 'Archive' button
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_ARCHIVE)) {
boolean archived = FacadeProvider.getEventParticipantFacade().isArchived(eventParticipant.getUuid());
Button archiveButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
if (editComponent.isModified()) {
editComponent.commit();
}
if (archived) {
ControllerProvider.getArchiveController().dearchiveEntity(eventParticipant, FacadeProvider.getEventParticipantFacade(), Strings.headingDearchiveEventParticipant, Strings.confirmationDearchiveEventParticipant, Strings.entityEventParticipant, Strings.messageEventParticipantDearchived, () -> navigateToData(eventParticipant.getUuid()));
} else {
ControllerProvider.getArchiveController().archiveEntity(eventParticipant, FacadeProvider.getEventParticipantFacade(), Strings.headingArchiveEventParticipant, Strings.confirmationArchiveEventParticipant, Strings.entityEventParticipant, Strings.messageEventParticipantArchived, () -> navigateToData(eventParticipant.getUuid()));
}
}, ValoTheme.BUTTON_LINK);
editComponent.getButtonsPanel().addComponentAsFirst(archiveButton);
editComponent.getButtonsPanel().setComponentAlignment(archiveButton, Alignment.BOTTOM_LEFT);
}
return editComponent;
}
use of de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto in project SORMAS-Project by hzi-braunschweig.
the class EventController method getEventDataEditComponent.
public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(final String eventUuid, Consumer<EventStatus> saveCallback) {
EventDto event = findEvent(eventUuid);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getEventFacade().getAutomaticDeletionInfo(eventUuid);
EventDataForm eventEditForm = new EventDataForm(false, event.isPseudonymized());
eventEditForm.setValue(event);
final CommitDiscardWrapperComponent<EventDataForm> editView = new CommitDiscardWrapperComponent<EventDataForm>(eventEditForm, UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT), eventEditForm.getFieldGroup());
if (automaticDeletionInfoDto != null) {
editView.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
editView.addCommitListener(() -> {
if (!eventEditForm.getFieldGroup().isModified()) {
EventDto eventDto = eventEditForm.getValue();
final UserDto user = UserProvider.getCurrent().getUser();
final RegionReferenceDto userRegion = user.getRegion();
final DistrictReferenceDto userDistrict = user.getDistrict();
final RegionReferenceDto epEventRegion = eventDto.getEventLocation().getRegion();
final DistrictReferenceDto epEventDistrict = eventDto.getEventLocation().getDistrict();
final Boolean eventOutsideJurisdiction = (userRegion != null && !userRegion.equals(epEventRegion) || userDistrict != null && !userDistrict.equals(epEventDistrict));
if (eventOutsideJurisdiction) {
VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingEventJurisdictionUpdated), new Label(I18nProperties.getString(Strings.messageEventJurisdictionUpdated)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 500, confirmed -> {
if (confirmed) {
saveEvent(saveCallback, eventDto);
}
});
} else {
saveEvent(saveCallback, eventDto);
}
}
});
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_DELETE)) {
editView.addDeleteListener(() -> {
if (!existEventParticipantsLinkedToEvent(event)) {
try {
FacadeProvider.getEventFacade().deleteEvent(event.getUuid());
} catch (ExternalSurveillanceToolException e) {
Notification.show(String.format(I18nProperties.getString(Strings.ExternalSurveillanceToolGateway_notificationEntryNotDeleted), DataHelper.getShortUuid(event.getUuid())), "", Type.ERROR_MESSAGE);
}
} else {
VaadinUiUtil.showSimplePopupWindow(I18nProperties.getString(Strings.headingEventNotDeleted), I18nProperties.getString(Strings.messageEventsNotDeletedReason));
}
UI.getCurrent().getNavigator().navigateTo(EventsView.VIEW_NAME);
}, I18nProperties.getString(Strings.entityEvent));
}
// Initialize 'Archive' button
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_ARCHIVE)) {
boolean archived = FacadeProvider.getEventFacade().isArchived(eventUuid);
Button archiveEventButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
if (editView.isModified()) {
editView.commit();
}
if (archived) {
ControllerProvider.getArchiveController().dearchiveEntity(event, FacadeProvider.getEventFacade(), Strings.headingDearchiveEvent, Strings.confirmationDearchiveEvent, Strings.entityEvent, Strings.messageEventDearchived, () -> navigateToData(event.getUuid()));
} else {
ControllerProvider.getArchiveController().archiveEntity(event, FacadeProvider.getEventFacade(), Strings.headingArchiveEvent, Strings.confirmationArchiveEvent, Strings.entityEvent, Strings.messageEventArchived, () -> navigateToData(event.getUuid()));
}
}, ValoTheme.BUTTON_LINK);
editView.getButtonsPanel().addComponentAsFirst(archiveEventButton);
editView.getButtonsPanel().setComponentAlignment(archiveEventButton, Alignment.BOTTOM_LEFT);
}
return editView;
}
use of de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto in project SORMAS-Project by hzi-braunschweig.
the class AbstractCoreFacadeEjb method getAutomaticDeletionInfo.
@Override
public AutomaticDeletionInfoDto getAutomaticDeletionInfo(String uuid) {
DeletionConfiguration deletionConfiguration = deletionConfigurationService.getCoreEntityTypeConfig(getCoreEntityType());
if (deletionConfiguration.getDeletionPeriod() == null || deletionConfiguration.getDeletionReference() == null) {
return null;
}
Object[] deletionData = getDeletionData(uuid, deletionConfiguration);
Date referenceDate = (Date) deletionData[0];
Date deletiondate = DateHelper.addDays(referenceDate, deletionConfiguration.getDeletionPeriod());
return new AutomaticDeletionInfoDto(deletiondate, (Date) deletionData[1], deletionConfiguration.getDeletionPeriod());
}
Aggregations