Search in sources :

Example 1 with AccessCertificationDefinitionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.

the class PageCertDefinitions method initColumns.

private List<IColumn<SelectableBean<AccessCertificationDefinitionType>, String>> initColumns() {
    List<IColumn<SelectableBean<AccessCertificationDefinitionType>, String>> columns = new ArrayList<>();
    IColumn column;
    column = new PropertyColumn(createStringResource("PageCertDefinitions.table.description"), "value.description");
    columns.add(column);
    column = new MultiButtonColumn<SelectableBean<AccessCertificationDefinitionType>>(new Model(), 3) {

        private final String[] captionKeys = { "PageCertDefinitions.button.createCampaign", "PageCertDefinitions.button.showCampaigns", "PageCertDefinitions.button.deleteDefinition" };

        private final DoubleButtonColumn.BUTTON_COLOR_CLASS[] colors = { DoubleButtonColumn.BUTTON_COLOR_CLASS.PRIMARY, DoubleButtonColumn.BUTTON_COLOR_CLASS.DEFAULT, DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER };

        @Override
        public String getCaption(int id) {
            return PageCertDefinitions.this.createStringResource(captionKeys[id]).getString();
        }

        @Override
        public String getButtonColorCssClass(int id) {
            return colors[id].toString();
        }

        @Override
        public void clickPerformed(int id, AjaxRequestTarget target, IModel<SelectableBean<AccessCertificationDefinitionType>> model) {
            switch(id) {
                case 0:
                    createCampaignPerformed(target, model.getObject().getValue());
                    break;
                case 1:
                    showCampaignsPerformed(target, model.getObject().getValue());
                    break;
                case 2:
                    deleteConfirmation(target, model.getObject().getValue());
                    break;
            }
        }
    };
    columns.add(column);
    return columns;
}
Also used : AccessCertificationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType) 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) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model)

Example 2 with AccessCertificationDefinitionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.

the class PageCertDefinitions method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<AccessCertificationDefinitionType> mainPanel = new MainObjectListPanel<AccessCertificationDefinitionType>(ID_TABLE, AccessCertificationDefinitionType.class, TableId.PAGE_CERT_DEFINITIONS_PANEL, null, this) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IColumn<SelectableBean<AccessCertificationDefinitionType>, String> createCheckboxColumn() {
            return null;
        }

        @Override
        public void objectDetailsPerformed(AjaxRequestTarget target, AccessCertificationDefinitionType service) {
            PageCertDefinitions.this.detailsPerformed(target, service);
        }

        @Override
        protected List<IColumn<SelectableBean<AccessCertificationDefinitionType>, String>> createColumns() {
            return PageCertDefinitions.this.initColumns();
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return null;
        }

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target) {
            navigateToNext(PageCertDefinition.class);
        }
    };
    mainPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_CERT_DEF_BOX_CSS_CLASSES);
    mainForm.add(mainPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) AccessCertificationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType) Form(org.apache.wicket.markup.html.form.Form) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 3 with AccessCertificationDefinitionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.

the class RAccessCertificationDefinition method toJAXB.

@Override
public AccessCertificationDefinitionType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
    AccessCertificationDefinitionType object = new AccessCertificationDefinitionType();
    RUtil.revive(object, prismContext);
    RAccessCertificationDefinition.copyToJAXB(this, object, prismContext, options);
    return object;
}
Also used : AccessCertificationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType)

Example 4 with AccessCertificationDefinitionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.

the class ReportFunctions method searchCertificationDefinitions.

// TODO implement if needed
//    <O extends Containerable> RefFilter createReferenceEqualFilter(QName propertyName, Class<O> type, String... oids) {
//        return RefFilter.createReferenceEqual(propertyName, type, prismContext, oids);
//    }
//    <O extends Containerable> RefFilter createReferenceEqualFilter(ItemPath propertyPath, Class<O> type, String... oids) throws SchemaException {
//        return RefFilter.createReferenceEqual(propertyPath, type, prismContext, oids);
//    }
//    Object parseObjectFromXML (String xml) throws SchemaException {
//        return prismContext.parserFor(xml).xml().parseAnyData();
//    }
/**
     * Retrieves all definitions.
     * Augments them by count of campaigns (all + open ones).
     *
     * TODO query parameters, customizable sorting
     * definitions and campaigns counts are expected to be low, so we can afford to go through all of them here
     */
public Collection<PrismObject<AccessCertificationDefinitionForReportType>> searchCertificationDefinitions() throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
    Task task = taskManager.createTaskInstance();
    OperationResult result = task.getResult();
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createResolveNames());
    List<PrismObject<AccessCertificationDefinitionType>> definitions = model.searchObjects(AccessCertificationDefinitionType.class, null, options, task, result);
    final Map<String, PrismObject<AccessCertificationDefinitionForReportType>> definitionsForReportMap = new HashMap<>();
    for (PrismObject<AccessCertificationDefinitionType> definition : definitions) {
        // create subclass with the values copied from the superclass
        PrismObject<AccessCertificationDefinitionForReportType> definitionForReport = prismContext.createObjectable(AccessCertificationDefinitionForReportType.class).asPrismObject();
        for (Item<?, ?> item : definition.getValue().getItems()) {
            definitionForReport.getValue().add(item.clone());
        }
        definitionsForReportMap.put(definition.getOid(), definitionForReport);
    }
    ResultHandler<AccessCertificationCampaignType> handler = (campaignObject, parentResult) -> {
        AccessCertificationCampaignType campaign = campaignObject.asObjectable();
        if (campaign.getDefinitionRef() != null) {
            String definitionOid = campaign.getDefinitionRef().getOid();
            PrismObject<AccessCertificationDefinitionForReportType> definitionObject = definitionsForReportMap.get(definitionOid);
            if (definitionObject != null) {
                AccessCertificationDefinitionForReportType definition = definitionObject.asObjectable();
                int campaigns = definition.getCampaigns() != null ? definition.getCampaigns() : 0;
                definition.setCampaigns(campaigns + 1);
                AccessCertificationCampaignStateType state = campaign.getState();
                if (state != AccessCertificationCampaignStateType.CREATED && state != CLOSED) {
                    int openCampaigns = definition.getOpenCampaigns() != null ? definition.getOpenCampaigns() : 0;
                    definition.setOpenCampaigns(openCampaigns + 1);
                }
            }
        }
        return true;
    };
    model.searchObjectsIterative(AccessCertificationCampaignType.class, null, handler, null, task, result);
    List<PrismObject<AccessCertificationDefinitionForReportType>> rv = new ArrayList<>(definitionsForReportMap.values());
    Collections.sort(rv, (o1, o2) -> {
        String n1 = o1.asObjectable().getName().getOrig();
        String n2 = o2.asObjectable().getName().getOrig();
        if (n1 == null) {
            n1 = "";
        }
        return n1.compareTo(n2);
    });
    for (PrismObject<AccessCertificationDefinitionForReportType> defObject : rv) {
        AccessCertificationDefinitionForReportType def = defObject.asObjectable();
        if (def.getCampaigns() == null) {
            def.setCampaigns(0);
        }
        if (def.getOpenCampaigns() == null) {
            def.setOpenCampaigns(0);
        }
    }
    return rv;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) F_STATE(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType.F_STATE) Trace(com.evolveum.midpoint.util.logging.Trace) F_NAME(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType.F_NAME) TaskManager(com.evolveum.midpoint.task.api.TaskManager) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) RetrieveOption(com.evolveum.midpoint.schema.RetrieveOption) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) CLOSED(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.CLOSED) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) AuditService(com.evolveum.midpoint.audit.api.AuditService) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) Task(com.evolveum.midpoint.task.api.Task) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) AuditEventTypeType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventTypeType) ModelService(com.evolveum.midpoint.model.api.ModelService) QueryBuilder(com.evolveum.midpoint.prism.query.builder.QueryBuilder) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) AuditEventStageType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) Entry(java.util.Map.Entry) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QName(javax.xml.namespace.QName) Validate(org.apache.commons.lang.Validate) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions)

Example 5 with AccessCertificationDefinitionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType in project midpoint by Evolveum.

the class PageCertCampaigns method createPageTitleModel.

// endregion
// region Layout
@Override
protected IModel<String> createPageTitleModel() {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (definitionOid == null) {
                return createStringResource("PageCertCampaigns.title", "").getString();
            }
            Task task = createSimpleTask("dummy");
            PrismObject<AccessCertificationDefinitionType> definitionPrismObject = WebModelServiceUtils.loadObject(AccessCertificationDefinitionType.class, definitionOid, PageCertCampaigns.this, task, task.getResult());
            String name = definitionPrismObject == null ? "" : WebComponentUtil.getName(definitionPrismObject);
            return createStringResource("PageCertCampaigns.title", name).getString();
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Task(com.evolveum.midpoint.task.api.Task) AccessCertificationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType)

Aggregations

AccessCertificationDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType)5 Task (com.evolveum.midpoint.task.api.Task)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)1 AuditEventStage (com.evolveum.midpoint.audit.api.AuditEventStage)1 AuditEventType (com.evolveum.midpoint.audit.api.AuditEventType)1 AuditService (com.evolveum.midpoint.audit.api.AuditService)1 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)1 ModelService (com.evolveum.midpoint.model.api.ModelService)1 com.evolveum.midpoint.prism (com.evolveum.midpoint.prism)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 QueryBuilder (com.evolveum.midpoint.prism.query.builder.QueryBuilder)1 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)1 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)1 RetrieveOption (com.evolveum.midpoint.schema.RetrieveOption)1