Search in sources :

Example 1 with ActionDto

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);
    }
}
Also used : UserDto(de.symeda.sormas.api.user.UserDto) ActionDto(de.symeda.sormas.api.action.ActionDto)

Example 2 with ActionDto

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));
}
Also used : CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) ActionDto(de.symeda.sormas.api.action.ActionDto)

Example 3 with ActionDto

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);
}
Also used : Window(com.vaadin.ui.Window) ActionDto(de.symeda.sormas.api.action.ActionDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)

Example 4 with ActionDto

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);
    }
}
Also used : Label(com.vaadin.ui.Label) ActionDto(de.symeda.sormas.api.action.ActionDto)

Example 5 with ActionDto

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));
}
Also used : UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) ActionDto(de.symeda.sormas.api.action.ActionDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Aggregations

ActionDto (de.symeda.sormas.api.action.ActionDto)11 UserDto (de.symeda.sormas.api.user.UserDto)4 Label (com.vaadin.ui.Label)2 EventDto (de.symeda.sormas.api.event.EventDto)2 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)2 PersonDto (de.symeda.sormas.api.person.PersonDto)2 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)2 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)2 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)2 Test (org.junit.Test)2 ClickListener (com.vaadin.ui.Button.ClickListener)1 Window (com.vaadin.ui.Window)1 FacadeProvider (de.symeda.sormas.api.FacadeProvider)1 ActionContext (de.symeda.sormas.api.action.ActionContext)1 ActionCriteria (de.symeda.sormas.api.action.ActionCriteria)1 Captions (de.symeda.sormas.api.i18n.Captions)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1 UserRight (de.symeda.sormas.api.user.UserRight)1 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)1 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)1