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);
}
}
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);
}
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);
}
}
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));
}
}
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);
}
Aggregations