use of de.symeda.sormas.api.action.ActionDto in project SORMAS-Project by hzi-braunschweig.
the class ActionEditForm method updateByCreating.
private void updateByCreating() {
ActionDto value = getValue();
if (value != null) {
boolean creating = value.getCreationDate() == null;
UserDto user = UserProvider.getCurrent().getUser();
boolean creator = user.equals(value.getCreatorUser());
setVisible(!creating, ActionDto.REPLY);
if (creating) {
discard(ActionDto.REPLY);
} else {
updateCreationInfo();
}
setReadOnly(!creator, ActionDto.DESCRIPTION, ActionDto.TITLE);
}
}
use of de.symeda.sormas.api.action.ActionDto in project SORMAS-Project by hzi-braunschweig.
the class ActionController method create.
/**
* Show a create form for an action.
*
* @param context of the action
* @param entityRef of the action
* @param callback on save
*/
public void create(ActionContext context, ReferenceDto entityRef, Runnable callback) {
ActionEditForm createForm = new ActionEditForm(true);
createForm.setValue(createNewAction(context, entityRef));
final CommitDiscardWrapperComponent<ActionEditForm> editView = new CommitDiscardWrapperComponent<>(createForm, UserProvider.getCurrent().hasUserRight(UserRight.ACTION_CREATE), createForm.getFieldGroup());
editView.addCommitListener(() -> {
if (!createForm.getFieldGroup().isModified()) {
ActionDto dto = createForm.getValue();
FacadeProvider.getActionFacade().saveAction(dto);
callback.run();
}
});
VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getString(Strings.headingCreateNewAction));
}
use of de.symeda.sormas.api.action.ActionDto in project SORMAS-Project by hzi-braunschweig.
the class ActionController method edit.
/**
* Show an edit form for an action.
*
* @param dto of the action
* @param callback on save
*/
public void edit(ActionDto dto, Runnable callback) {
// get fresh data
ActionDto newDto = FacadeProvider.getActionFacade().getByUuid(dto.getUuid());
ActionEditForm form = new ActionEditForm(false);
form.setValue(newDto);
final CommitDiscardWrapperComponent<ActionEditForm> editView = new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.ACTION_EDIT), form.getFieldGroup());
Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getString(Strings.headingEditAction));
editView.addCommitListener(() -> {
if (!form.getFieldGroup().isModified()) {
ActionDto dto1 = form.getValue();
dto1.setLastModifiedBy(FacadeProvider.getUserFacade().getCurrentUser().toReference());
FacadeProvider.getActionFacade().saveAction(dto1);
popupWindow.close();
callback.run();
}
});
// Add delete button if user has role
if (UserProvider.getCurrent().hasUserRole(UserRole.ADMIN)) {
editView.addDeleteListener(() -> {
FacadeProvider.getActionFacade().deleteAction(newDto);
UI.getCurrent().removeWindow(popupWindow);
callback.run();
}, I18nProperties.getString(Strings.entityAction));
}
editView.addDiscardListener(popupWindow::close);
}
use of de.symeda.sormas.api.action.ActionDto in project SORMAS-Project by hzi-braunschweig.
the class ActionList method reload.
@Override
public void reload() {
List<ActionDto> actions = FacadeProvider.getActionFacade().getActionList(actionCriteria, null, null);
setEntries(actions);
showPage(1);
if (actions.isEmpty()) {
Label noActionsLabel = new Label(String.format(I18nProperties.getCaption(Captions.actionNoActions), context.toString()));
listLayout.addComponent(noActionsLabel);
}
}
use of de.symeda.sormas.api.action.ActionDto in project SORMAS-Project by hzi-braunschweig.
the class ActionFacadeEjbTest method testGetAllUuids.
@Test
public void testGetAllUuids() throws ParseException {
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 eventDto = creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Some Event", "...where people meet", "Sourcy", "McSourceFace", "12345", TypeOfPlace.PUBLIC_PLACE, DATE_FORMAT.parse("12/11/2020"), DATE_FORMAT.parse("13/11/2020"), user.toReference(), user.toReference(), Disease.CORONAVIRUS, rdcf.district);
String uuid1 = "ABCDE-FGHIJ-KLMNO-PQRST";
String uuid2 = "BCDEF-GHIJK-LMNOP-QRSTU";
ActionDto actionDto1 = new ActionDto();
actionDto1.setUuid(uuid1);
actionDto1.setTitle("An action");
actionDto1.setActionContext(ActionContext.EVENT);
actionDto1.setDate(DATE_FORMAT.parse("16/11/2020"));
actionDto1.setDescription("Here is what to do.");
actionDto1.setReply("This is your reply.");
actionDto1.setEvent(eventDto.toReference());
getActionFacade().saveAction(actionDto1);
ActionDto actionDto2 = new ActionDto();
actionDto2.setUuid(uuid2);
actionDto2.setTitle("Another action");
actionDto2.setActionContext(ActionContext.EVENT);
actionDto2.setDate(DATE_FORMAT.parse("15/11/2020"));
actionDto2.setDescription("This action hast no reply");
actionDto2.setEvent(eventDto.toReference());
getActionFacade().saveAction(actionDto2);
List<String> allUuids = getActionFacade().getAllUuids();
assertEquals(2, allUuids.size());
assertTrue(allUuids.contains(uuid1));
assertTrue(allUuids.contains(uuid2));
}
Aggregations