Search in sources :

Example 1 with RoleSummaryPanel

use of com.evolveum.midpoint.web.page.admin.roles.component.RoleSummaryPanel in project midpoint by Evolveum.

the class OrgMemberPanel method createManagerContainer.

private WebMarkupContainer createManagerContainer() {
    WebMarkupContainer managerContainer = new WebMarkupContainer(ID_CONTAINER_MANAGER);
    managerContainer.setOutputMarkupId(true);
    managerContainer.setOutputMarkupPlaceholderTag(true);
    RepeatingView view = new RepeatingView(ID_MANAGER_TABLE);
    view.setOutputMarkupId(true);
    ObjectQuery managersQuery = createManagerQuery();
    OperationResult searchManagersResult = new OperationResult(OPERATION_SEARCH_MANAGERS);
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(FocusType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
    List<PrismObject<FocusType>> managers = WebModelServiceUtils.searchObjects(FocusType.class, managersQuery, options, searchManagersResult, getPageBase());
    Task task = getPageBase().createSimpleTask(OPERATION_LOAD_MANAGERS);
    for (PrismObject<FocusType> manager : managers) {
        ObjectWrapper<FocusType> managerWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(manager, RoleType.F_DISPLAY_NAME), "", manager, ContainerStatus.MODIFYING, task, getPageBase());
        WebMarkupContainer managerMarkup = new WebMarkupContainer(view.newChildId());
        AjaxLink<String> link = new AjaxLink<String>(ID_EDIT_MANAGER) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                detailsPerformed(target, summary.getModelObject());
            }
        };
        link.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, managerWrapper.getObject(), null, null, null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #read operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        if (manager.getCompileTimeClass().equals(UserType.class)) {
            managerMarkup.add(new UserSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(RoleType.class)) {
            managerMarkup.add(new RoleSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(OrgType.class)) {
            managerMarkup.add(new OrgSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(ServiceType.class)) {
            managerMarkup.add(new ServiceSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) managerWrapper)));
        }
        link.setOutputMarkupId(true);
        managerMarkup.setOutputMarkupId(true);
        managerMarkup.add(link);
        view.add(managerMarkup);
        AjaxButton removeManager = new AjaxButton(ID_REMOVE_MANAGER) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                removeManagerPerformed(summary.getModelObject(), target);
                getParent().setVisible(false);
                target.add(OrgMemberPanel.this);
            }
        };
        removeManager.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL, null, managerWrapper.getObject(), null, getModelObject().asPrismObject(), null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #unassign operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        removeManager.setOutputMarkupId(true);
        managerMarkup.add(removeManager);
        AjaxButton deleteManager = new AjaxButton(ID_DELETE_MANAGER) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                deleteManagerPerformed(summary.getModelObject(), this, target);
            }
        };
        deleteManager.setOutputMarkupId(true);
        deleteManager.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, null, managerWrapper.getObject(), null, null, null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #delete operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        managerMarkup.add(deleteManager);
    }
    managerContainer.add(view);
    InlineMenu menupanel = new InlineMenu(ID_MANAGER_MENU, new Model<Serializable>((Serializable) createManagersHeaderInlineMenu()));
    add(menupanel);
    menupanel.setOutputMarkupId(true);
    managerContainer.add(menupanel);
    return managerContainer;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Serializable(java.io.Serializable) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) FocusSummaryPanel(com.evolveum.midpoint.web.component.FocusSummaryPanel) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) RoleSummaryPanel(com.evolveum.midpoint.web.page.admin.roles.component.RoleSummaryPanel)

Example 2 with RoleSummaryPanel

use of com.evolveum.midpoint.web.page.admin.roles.component.RoleSummaryPanel in project midpoint by Evolveum.

the class FocusPersonasTabPanel method initLayout.

private void initLayout() {
    WebMarkupContainer container = new WebMarkupContainer(ID_PERSONAS_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    RepeatingView view = new RepeatingView(ID_PERSONAS_TABLE);
    view.setOutputMarkupId(true);
    container.add(view);
    LoadableModel<List<PrismObject<FocusType>>> personasListModel = loadModel();
    if (personasListModel.getObject() == null || personasListModel.getObject().size() == 0) {
        WebMarkupContainer viewChild = new WebMarkupContainer(view.newChildId());
        viewChild.setOutputMarkupId(true);
        view.add(viewChild);
        WebMarkupContainer emptyContainer = new WebMarkupContainer(ID_PERSONAS_SUMMARY);
        emptyContainer.setOutputMarkupId(true);
        viewChild.add(emptyContainer);
        return;
    }
    Task task = pageBase.createSimpleTask(OPERATION_LOAD_PERSONAS);
    for (PrismObject<FocusType> personaObject : personasListModel.getObject()) {
        ObjectWrapper<FocusType> personaWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(personaObject, RoleType.F_DISPLAY_NAME), "", personaObject, ContainerStatus.MODIFYING, task, getPageBase());
        WebMarkupContainer personaPanel = new WebMarkupContainer(view.newChildId());
        personaPanel.setOutputMarkupId(true);
        view.add(personaPanel);
        if (personaObject.getCompileTimeClass().equals(UserType.class)) {
            personaPanel.add(new UserSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) personaWrapper)));
        } else if (personaObject.getCompileTimeClass().equals(RoleType.class)) {
            personaPanel.add(new RoleSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) personaWrapper)));
        } else if (personaObject.getCompileTimeClass().equals(OrgType.class)) {
            personaPanel.add(new OrgSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) personaWrapper)));
        } else if (personaObject.getCompileTimeClass().equals(ServiceType.class)) {
            personaPanel.add(new ServiceSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) personaWrapper)));
        }
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ServiceSummaryPanel(com.evolveum.midpoint.web.page.admin.users.component.ServiceSummaryPanel) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) UserSummaryPanel(com.evolveum.midpoint.web.page.admin.users.component.UserSummaryPanel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) RoleSummaryPanel(com.evolveum.midpoint.web.page.admin.roles.component.RoleSummaryPanel) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) ArrayList(java.util.ArrayList) List(java.util.List) OrgSummaryPanel(com.evolveum.midpoint.web.page.admin.users.component.OrgSummaryPanel)

Aggregations

Task (com.evolveum.midpoint.task.api.Task)2 ObjectWrapper (com.evolveum.midpoint.web.component.prism.ObjectWrapper)2 RoleSummaryPanel (com.evolveum.midpoint.web.page.admin.roles.component.RoleSummaryPanel)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 RepeatingView (org.apache.wicket.markup.repeater.RepeatingView)2 Model (org.apache.wicket.model.Model)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1