Search in sources :

Example 1 with SessionStorage

use of com.evolveum.midpoint.web.session.SessionStorage in project midpoint by Evolveum.

the class AbstractOrgTabPanel method changeTabPerformed.

protected void changeTabPerformed(int index) {
    if (roots != null && index >= 0 && index <= roots.size()) {
        SessionStorage storage = getPageBase().getSessionStorage();
        SelectableBean<OrgType> selected = new SelectableBean<OrgType>();
        selected.setValue(roots.get(index).asObjectable());
        storage.getUsers().setSelectedItem(selected);
        storage.getUsers().setSelectedTabId(index);
    }
}
Also used : OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage)

Example 2 with SessionStorage

use of com.evolveum.midpoint.web.session.SessionStorage in project midpoint by Evolveum.

the class AssignmentCatalogPanel method initCartButton.

private void initCartButton(WebMarkupContainer headerPanel) {
    AjaxButton cartButton = new AjaxButton(ID_CART_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            pageBase.navigateToNext(PageAssignmentsList.class);
        }
    };
    cartButton.add(new VisibleEnableBehaviour() {

        public boolean isVisible() {
            return !isCatalogOidEmpty();
        }
    });
    cartButton.setOutputMarkupId(true);
    headerPanel.add(cartButton);
    Label cartItemsCount = new Label(ID_CART_ITEMS_COUNT, new LoadableModel<String>(true) {

        private static final long serialVersionUID = 1L;

        @Override
        public String load() {
            return Integer.toString(getRoleCatalogStorage().getAssignmentShoppingCart().size());
        }
    });
    cartItemsCount.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SessionStorage storage = pageBase.getSessionStorage();
            if (storage.getRoleCatalog().getAssignmentShoppingCart().size() == 0) {
                return false;
            } else {
                return true;
            }
        }
    });
    cartItemsCount.setOutputMarkupId(true);
    cartButton.add(cartItemsCount);
}
Also used : AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Label(org.apache.wicket.markup.html.basic.Label) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage)

Example 3 with SessionStorage

use of com.evolveum.midpoint.web.session.SessionStorage in project midpoint by Evolveum.

the class PageAssignmentsList method onSingleUserRequestPerformed.

private void onSingleUserRequestPerformed(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_REQUEST_ASSIGNMENTS);
    ObjectDelta<UserType> delta;
    try {
        PrismObject<UserType> user = getTargetUser();
        delta = user.createModifyDelta();
        PrismContainerDefinition def = user.getDefinition().findContainerDefinition(UserType.F_ASSIGNMENT);
        handleAssignmentDeltas(delta, addAssignmentsToUser(user.asObjectable()), def);
        getModelService().executeChanges(Collections.singletonList(delta), createOptions(), createSimpleTask(OPERATION_REQUEST_ASSIGNMENTS), result);
        result.recordSuccess();
        SessionStorage storage = getSessionStorage();
        storage.getRoleCatalog().getAssignmentShoppingCart().clear();
    } catch (Exception e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Could not save assignments ", e);
        error("Could not save assignments. Reason: " + e);
        target.add(getFeedbackPanel());
    } finally {
        result.recomputeStatus();
    }
    findBackgroundTaskOperation(result);
    if (backgroundTaskOperationResult != null && StringUtils.isNotEmpty(backgroundTaskOperationResult.getBackgroundTaskOid())) {
        result.setMessage(createStringResource("operation.com.evolveum.midpoint.web.page.self.PageRequestRole.taskCreated").getString());
        showResult(result);
        setResponsePage(PageAssignmentShoppingKart.class);
        return;
    }
    showResult(result);
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        target.add(getFeedbackPanel());
        target.add(PageAssignmentsList.this.get(ID_FORM));
    } else {
        setResponsePage(PageAssignmentShoppingKart.class);
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 4 with SessionStorage

use of com.evolveum.midpoint.web.session.SessionStorage in project midpoint by Evolveum.

the class PageAssignmentsList method onMultiUserRequestPerformed.

private void onMultiUserRequestPerformed(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_REQUEST_ASSIGNMENTS);
    Task operationalTask = createSimpleTask(OPERATION_REQUEST_ASSIGNMENTS);
    try {
        TaskType task = WebComponentUtil.createSingleRecurrenceTask(createStringResource(OPERATION_REQUEST_ASSIGNMENTS).getString(), UserType.COMPLEX_TYPE, getTaskQuery(), prepareDelta(result), createOptions(), TaskCategory.EXECUTE_CHANGES, PageAssignmentsList.this);
        WebModelServiceUtils.runTask(task, operationalTask, result, PageAssignmentsList.this);
    } catch (SchemaException e) {
        result.recordFatalError(result.getOperation(), e);
        LoggingUtils.logUnexpectedException(LOGGER, "Failed to execute operaton " + result.getOperation(), e);
        target.add(getFeedbackPanel());
    }
    findBackgroundTaskOperation(result);
    if (backgroundTaskOperationResult != null && StringUtils.isNotEmpty(backgroundTaskOperationResult.getBackgroundTaskOid())) {
        result.setMessage(createStringResource("operation.com.evolveum.midpoint.web.page.self.PageRequestRole.taskCreated").getString());
        showResult(result);
        setResponsePage(PageAssignmentShoppingKart.class);
        return;
    }
    if (WebComponentUtil.isSuccessOrHandledError(result) || OperationResultStatus.IN_PROGRESS.equals(result.getStatus())) {
        SessionStorage storage = getSessionStorage();
        if (storage.getRoleCatalog().getAssignmentShoppingCart() != null) {
            storage.getRoleCatalog().getAssignmentShoppingCart().clear();
        }
        if (storage.getRoleCatalog().getTargetUserList() != null) {
            storage.getRoleCatalog().getTargetUserList().clear();
        }
        setResponsePage(PageAssignmentShoppingKart.class);
    } else {
        showResult(result);
        target.add(getFeedbackPanel());
        target.add(PageAssignmentsList.this.get(ID_FORM));
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage)

Example 5 with SessionStorage

use of com.evolveum.midpoint.web.session.SessionStorage in project midpoint by Evolveum.

the class AbstractOrgTabPanel method initLayout.

private void initLayout() {
    final IModel<List<ITab>> tabModel = new LoadableModel<List<ITab>>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<ITab> load() {
            LOGGER.debug("Loading org. roots for tabs for tabbed panel.");
            roots = loadOrgRoots();
            final List<ITab> tabs = new ArrayList<>();
            for (PrismObject<OrgType> root : roots) {
                final String oid = root.getOid();
                tabs.add(new AbstractTab(createTabTitle(root)) {

                    private static final long serialVersionUID = 1L;

                    private int tabId = tabs.size();

                    @Override
                    public WebMarkupContainer getPanel(String panelId) {
                        add(new AjaxEventBehavior("load") {

                            private static final long serialVersionUID = 1L;

                            protected void onEvent(final AjaxRequestTarget target) {
                                SessionStorage storage = getPageBase().getSessionStorage();
                                storage.getUsers().setSelectedTabId(tabId);
                            }
                        });
                        Panel panel = createTreePanel(panelId, new Model(oid), getPageBase());
                        panel.setOutputMarkupId(true);
                        return panel;
                    }
                });
            }
            LOGGER.debug("Tab count is {}", new Object[] { tabs.size() });
            return tabs;
        }
    };
    final SessionStorage storage = getPageBase().getSessionStorage();
    int selectedTab = storage.getUsers().getSelectedTabId() == -1 ? 0 : storage.getUsers().getSelectedTabId();
    List<ITab> tabsList = tabModel.getObject();
    if (tabsList == null || (selectedTab > tabsList.size() - 1)) {
        storage.getUsers().setSelectedTabId(0);
        selectedTab = 0;
    }
    AjaxTabbedPanel<ITab> tabbedPanel = new AjaxTabbedPanel<ITab>(ID_TABS, tabModel.getObject(), new Model<>(selectedTab), null) {

        private static final long serialVersionUID = 1L;

        @Override
        public TabbedPanel<ITab> setSelectedTab(int index) {
            changeTabPerformed(index);
            return super.setSelectedTab(index);
        }
    };
    tabbedPanel.setOutputMarkupId(true);
    if (tabsList == null || tabsList.size() == 0) {
        tabbedPanel.setVisible(false);
    }
    add(tabbedPanel);
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ArrayList(java.util.ArrayList) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxTabbedPanel(com.evolveum.midpoint.web.component.AjaxTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) AjaxTabbedPanel(com.evolveum.midpoint.web.component.AjaxTabbedPanel) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) ArrayList(java.util.ArrayList) List(java.util.List) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage)

Aggregations

SessionStorage (com.evolveum.midpoint.web.session.SessionStorage)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 RepositoryQueryDiagRequest (com.evolveum.midpoint.schema.RepositoryQueryDiagRequest)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 AjaxTabbedPanel (com.evolveum.midpoint.web.component.AjaxTabbedPanel)1 TabbedPanel (com.evolveum.midpoint.web.component.TabbedPanel)1 Search (com.evolveum.midpoint.web.component.search.Search)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 RepoQueryDto (com.evolveum.midpoint.web.page.admin.configuration.dto.RepoQueryDto)1 MidPointAuthWebSession (com.evolveum.midpoint.web.security.MidPointAuthWebSession)1