Search in sources :

Example 1 with CertCampaignListItemDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.

the class PageCertCampaigns method initLayout.

private void initLayout() {
    Form mainForm = new MidpointForm(ID_MAIN_FORM);
    add(mainForm);
    CertCampaignListItemDtoProvider provider = createProvider();
    provider.setQuery(createCampaignsQuery());
    BoxedTablePanel<CertCampaignListItemDto> table = new BoxedTablePanel<CertCampaignListItemDto>(ID_CAMPAIGNS_TABLE, provider, initColumns(), UserProfileStorage.TableId.PAGE_CERT_CAMPAIGNS_PANEL) {

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new SearchFragment(headerId, ID_TABLE_HEADER, PageCertCampaigns.this, searchModel);
        }
    };
    table.setShowPaging(true);
    table.setOutputMarkupId(true);
    mainForm.add(table);
}
Also used : CertCampaignListItemDtoProvider(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDtoProvider) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Example 2 with CertCampaignListItemDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.

the class PageCertCampaigns method actOnCampaignsPerformed.

private void actOnCampaignsPerformed(AjaxRequestTarget target, String operationName, List<CertCampaignListItemDto> items) {
    int processed = 0;
    AccessCertificationService acs = getCertificationService();
    OperationResult result = new OperationResult(operationName);
    for (CertCampaignListItemDto item : items) {
        try {
            AccessCertificationCampaignType campaign = item.getCampaign();
            Task task = createSimpleTask(operationName);
            if (OPERATION_START_CAMPAIGN.equals(operationName)) {
                if (campaign.getState() == AccessCertificationCampaignStateType.CREATED) {
                    acs.openNextStage(campaign.getOid(), task, result);
                    processed++;
                }
            } else if (OPERATION_CLOSE_CAMPAIGN.equals(operationName)) {
                if (campaign.getState() != AccessCertificationCampaignStateType.CLOSED) {
                    acs.closeCampaign(campaign.getOid(), task, result);
                    processed++;
                }
            } else if (OPERATION_REITERATE_CAMPAIGN.equals(operationName)) {
                if (item.isReiterable()) {
                    acs.reiterateCampaign(campaign.getOid(), task, result);
                    processed++;
                }
            } else {
                throw new IllegalStateException("Unknown action: " + operationName);
            }
        } catch (Exception ex) {
            result.recordPartialError(createStringResource("PageCertCampaigns.message.actOnCampaignsPerformed.partialError").getString(), ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't process campaign", ex);
        }
    }
    if (processed == 0) {
        warn(getString("PageCertCampaigns.message.noCampaignsSelected"));
        target.add(getFeedbackPanel());
        return;
    }
    result.recomputeStatus();
    if (result.isSuccess()) {
        result.recordStatus(OperationResultStatus.SUCCESS, createStringResource("PageCertCampaigns.message.actOnCampaignsPerformed.success", processed).getString());
    }
    WebComponentUtil.safeResultCleanup(result, LOGGER);
    showResult(result);
    target.add(getFeedbackPanel(), (Component) getCampaignsTable());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Example 3 with CertCampaignListItemDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.

the class PageCertCampaigns method createInlineMenuForItem.

private List<InlineMenuItem> createInlineMenuForItem() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    InlineMenuItem item = new InlineMenuItem(createStringResource("PageCertCampaigns.menu.close")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<CertCampaignListItemDto>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    closeCampaignConfirmation(target, getRowModel().getObject());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    item.setVisibilityChecker((rowModel, header) -> isNotClosed(rowModel));
    menuItems.add(item);
    item = new InlineMenuItem(createStringResource("PageCertCampaigns.menu.reiterate")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<CertCampaignListItemDto>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    reiterateCampaignConfirmation(target, getRowModel().getObject());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    item.setVisibilityChecker((rowModel, header) -> isReiterable(rowModel));
    menuItems.add(item);
    menuItems.add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.delete")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<CertCampaignListItemDto>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteCampaignConfirmation(target, getRowModel().getObject());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return menuItems;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto)

Example 4 with CertCampaignListItemDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.

the class PageCertCampaigns method initColumns.

private List<IColumn<CertCampaignListItemDto, String>> initColumns() {
    List<IColumn<CertCampaignListItemDto, String>> columns = new ArrayList<>();
    IColumn column;
    column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = new LinkColumn<CertCampaignListItemDto>(createStringResource("PageCertCampaigns.table.name"), AccessCertificationCampaignType.F_NAME.getLocalPart(), CertCampaignListItemDto.F_NAME) {

        @Override
        public void onClick(AjaxRequestTarget target, IModel<CertCampaignListItemDto> rowModel) {
            campaignDetailsPerformed(target, rowModel.getObject().getOid());
        }
    };
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.description"), CertCampaignListItemDto.F_DESCRIPTION);
    columns.add(column);
    column = new EnumPropertyColumn(createStringResource("PageCertCampaigns.table.state"), CertCampaignListItemDto.F_STATE) {

        @Override
        protected String translate(Enum en) {
            return createStringResourceStatic(getPage(), en).getString();
        }
    };
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.stage"), CertCampaignListItemDto.F_CURRENT_STAGE_NUMBER);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.escalationLevel"), CertCampaignListItemDto.F_ESCALATION_LEVEL_NUMBER);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.stages"), CertCampaignListItemDto.F_NUMBER_OF_STAGES);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.deadline"), CertCampaignListItemDto.F_DEADLINE_AS_STRING);
    columns.add(column);
    column = new SingleButtonColumn<CertCampaignListItemDto>(new Model(), null) {

        @Override
        public boolean isButtonEnabled(IModel<CertCampaignListItemDto> model) {
            final AccessCertificationCampaignType campaign = model.getObject().getCampaign();
            String button = determineAction(campaign);
            return button != null;
        }

        @Override
        public boolean isButtonVisible(IModel<CertCampaignListItemDto> model) {
            final AccessCertificationCampaignType campaign = model.getObject().getCampaign();
            return campaign.getState() != AccessCertificationCampaignStateType.IN_REMEDIATION && campaign.getState() != AccessCertificationCampaignStateType.CLOSED;
        }

        @Override
        public String getCaption() {
            AccessCertificationCampaignType campaign = getRowModel().getObject().getCampaign();
            String button = determineAction(campaign);
            if (button != null) {
                return PageCertCampaigns.this.createStringResource(button).getString();
            } else {
                return "";
            }
        }

        @Override
        public String getButtonCssColorClass() {
            return DoubleButtonColumn.BUTTON_COLOR_CLASS.PRIMARY.toString();
        }

        @Override
        public String getButtonCssSizeClass() {
            return DoubleButtonColumn.BUTTON_SIZE_CLASS.SMALL.toString();
        }

        @Override
        public void clickPerformed(AjaxRequestTarget target, IModel<CertCampaignListItemDto> model) {
            AccessCertificationCampaignType campaign = model.getObject().getCampaign();
            String action = determineAction(campaign);
            switch(action) {
                case OP_START_CAMPAIGN:
                case OP_OPEN_NEXT_STAGE:
                    openNextStagePerformed(target, campaign);
                    break;
                case OP_CLOSE_STAGE:
                    closeStageConfirmation(target, model.getObject());
                    break;
                case OP_START_REMEDIATION:
                    startRemediationPerformed(target, campaign);
                    break;
                // not used
                case OP_CLOSE_CAMPAIGN:
                default:
                    throw new IllegalStateException("Unknown action: " + action);
            }
        }
    };
    columns.add(column);
    columns.add(new InlineMenuHeaderColumn(createInlineMenu()));
    return columns;
}
Also used : InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) EnumPropertyColumn(com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto) EnumPropertyColumn(com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Example 5 with CertCampaignListItemDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto in project midpoint by Evolveum.

the class PageCertCampaigns method deleteCampaignsPerformed.

private void deleteCampaignsPerformed(AjaxRequestTarget target, List<CertCampaignListItemDto> itemsToDelete) {
    if (itemsToDelete.isEmpty()) {
        warn(getString("PageCertCampaigns.message.noCampaignsSelected"));
        target.add(getFeedbackPanel());
        return;
    }
    OperationResult result = new OperationResult(OPERATION_DELETE_CAMPAIGNS);
    for (CertCampaignListItemDto itemToDelete : itemsToDelete) {
        try {
            Task task = createSimpleTask(OPERATION_DELETE_CAMPAIGNS);
            ObjectDelta<AccessCertificationCampaignType> delta = getPrismContext().deltaFactory().object().createDeleteDelta(AccessCertificationCampaignType.class, itemToDelete.getOid());
            getModelService().executeChanges(MiscUtil.createCollection(delta), null, task, result);
        } catch (Exception ex) {
            result.recordPartialError(createStringResource("PageCertCampaigns.message.deleteCampaignsPerformed.partialError").getString(), ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete campaign", ex);
        }
    }
    result.recomputeStatus();
    if (result.isSuccess()) {
        result.recordStatus(OperationResultStatus.SUCCESS, createStringResource("PageCertCampaigns.message.deleteCampaignsPerformed.success").getString());
    }
    Table campaignsTable = getCampaignsTable();
    ObjectDataProvider provider = (ObjectDataProvider) campaignsTable.getDataTable().getDataProvider();
    provider.clearCache();
    WebComponentUtil.safeResultCleanup(result, LOGGER);
    showResult(result);
    target.add(getFeedbackPanel(), (Component) campaignsTable);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Table(com.evolveum.midpoint.web.component.data.Table) DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Aggregations

CertCampaignListItemDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto)6 AccessCertificationCampaignType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 CertCampaignListItemDtoProvider (com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDtoProvider)2 ArrayList (java.util.ArrayList)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AccessCertificationService (com.evolveum.midpoint.model.api.AccessCertificationService)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)1 ObjectDataProvider (com.evolveum.midpoint.web.component.data.ObjectDataProvider)1 Table (com.evolveum.midpoint.web.component.data.Table)1 EnumPropertyColumn (com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn)1 InlineMenuHeaderColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn)1 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)1 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)1 DataTable (org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable)1 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)1 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)1