Search in sources :

Example 91 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class AuditLogViewerPanel method initColumns.

protected List<IColumn<AuditEventRecordType, String>> initColumns() {
    List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<IColumn<AuditEventRecordType, String>>();
    IColumn<AuditEventRecordType, String> linkColumn = new LinkColumn<AuditEventRecordType>(createStringResource("AuditEventRecordType.timestamp"), "timestamp") {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createLinkModel(final IModel<AuditEventRecordType> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
                    return WebComponentUtil.formatDate(time);
                }
            };
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType record = rowModel.getObject();
            try {
                AuditEventRecord.adopt(record, pageBase.getPrismContext());
            } catch (SchemaException e) {
                throw new SystemException("Couldn't adopt event record: " + e, e);
            }
            pageBase.navigateToNext(new PageAuditLogDetails(record));
        }
    };
    columns.add(linkColumn);
    PropertyColumn<AuditEventRecordType, String> initiatorRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.initiatorRef"), AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType auditEventRecordType = rowModel.getObject();
            createReferenceColumn(auditEventRecordType.getInitiatorRef(), item, componentId);
        }
    };
    columns.add(initiatorRefColumn);
    if (visibilityMap == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY) == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY)) {
        IColumn<AuditEventRecordType, String> eventStageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageLabel"), "eventStage");
        columns.add(eventStageColumn);
    }
    IColumn<AuditEventRecordType, String> eventTypeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeLabel"), "eventType");
    columns.add(eventTypeColumn);
    if (visibilityMap == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY)) {
        PropertyColumn<AuditEventRecordType, String> targetRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetRef"), AuditEventRecordType.F_TARGET_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
                AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
                createReferenceColumn(auditEventRecordType.getTargetRef(), item, componentId);
            }
        };
        columns.add(targetRefColumn);
    }
    if (visibilityMap == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY)) {
        PropertyColumn<AuditEventRecordType, String> targetOwnerRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetOwnerRef"), AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
                AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
                createReferenceColumn(auditEventRecordType.getTargetOwnerRef(), item, componentId);
            }
        };
        columns.add(targetOwnerRefColumn);
    }
    IColumn<AuditEventRecordType, String> channelColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.channel"), "channel") {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
            String channel = auditEventRecordType.getChannel();
            if (channel != null) {
                QName channelQName = QNameUtil.uriToQName(channel);
                String return_ = channelQName.getLocalPart();
                item.add(new Label(componentId, return_));
            } else {
                item.add(new Label(componentId, ""));
            }
            item.add(new AttributeModifier("style", new Model<String>("width: 10%;")));
        }
    };
    columns.add(channelColumn);
    IColumn<AuditEventRecordType, String> outcomeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.outcomeLabel"), "outcome");
    columns.add(outcomeColumn);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) QName(javax.xml.namespace.QName) PageAuditLogDetails(com.evolveum.midpoint.web.page.admin.reports.PageAuditLogDetails) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Item(org.apache.wicket.markup.repeater.Item) SystemException(com.evolveum.midpoint.util.exception.SystemException) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 92 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class ResourceConnectorPanel method initLayout.

private void initLayout(final IModel<PrismObject<ResourceType>> model, final PageBase parentPage) {
    setOutputMarkupId(true);
    IModel<List<ConnectorOperationalStatus>> statsModel = new AbstractReadOnlyModel<List<ConnectorOperationalStatus>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<ConnectorOperationalStatus> getObject() {
            PrismObject<ResourceType> resource = model.getObject();
            Task task = parentPage.createSimpleTask(OPERATION_GET_CONNECTOR_OPERATIONAL_STATUS);
            OperationResult result = task.getResult();
            List<ConnectorOperationalStatus> status = null;
            try {
                status = parentPage.getModelInteractionService().getConnectorOperationalStatus(resource.getOid(), task, result);
            } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
                LOGGER.error("Error getting connector status for {}: {}", resource, e.getMessage(), e);
                parentPage.showResult(result);
            }
            return status;
        }
    };
    ListView<ConnectorOperationalStatus> listview = new ListView<ConnectorOperationalStatus>(ID_CONNECTOR_LIST, statsModel) {

        private static final long serialVersionUID = 1L;

        protected void populateItem(ListItem<ConnectorOperationalStatus> item) {
            item.add(new Label("label", item.getModel()));
            IModel<ConnectorOperationalStatus> statModel = item.getModel();
            item.add(createLabel(statModel, ID_CONNECTOR_NAME, ConnectorOperationalStatus.F_CONNECTOR_NAME));
            item.add(createLabel(statModel, ID_CONNECOTR_CLASS, ConnectorOperationalStatus.F_CONNECTOR_CLASS_NAME));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_SIZE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_SIZE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_IDLE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_IDLE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_WAIT_TIMEOUT, ConnectorOperationalStatus.F_POOL_CONFIG_WAIT_TIMEOUT));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME));
            item.add(createLabel(statModel, ID_POOL_STATUS_NUM_IDLE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_IDLE));
            item.add(createLabel(statModel, ID_POOL_STATUS_NUM_ACTIVE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_ACTIVE));
        }
    };
    add(listview);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) Label(org.apache.wicket.markup.html.basic.Label) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ListView(org.apache.wicket.markup.html.list.ListView) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Example 93 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class ResourceContentPanel method createDeleteConfirmString.

private IModel<String> createDeleteConfirmString(final ShadowType selected, final String oneDeleteKey, final String moreDeleteKey) {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            List<ShadowType> selectedShadow = getSelectedShadowsList(selected);
            switch(selectedShadow.size()) {
                case 1:
                    Object first = selectedShadow.get(0);
                    String name = WebComponentUtil.getName(((ShadowType) first));
                    return getPageBase().createStringResource(oneDeleteKey, name).getString();
                default:
                    return getPageBase().createStringResource(moreDeleteKey, selectedShadow.size()).getString();
            }
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Example 94 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class RunReportPopupPanel method createResourceListModel.

private IModel<List<String>> createResourceListModel() {
    OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
    Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
    List<PrismObject<ResourceType>> resources = null;
    final List<String> resourceList = new ArrayList();
    try {
        resources = getPageBase().getModelService().searchObjects(ResourceType.class, new ObjectQuery(), null, task, result);
    } catch (Exception ex) {
        LOGGER.error(ex.getMessage());
    }
    for (PrismObject<ResourceType> resource : resources) {
        resourceList.add(resource.getBusinessDisplayName());
    }
    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            return resourceList;
        }
    };
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException)

Example 95 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class PageResources method createDeleteConfirmString.

/**
	 * @param oneDeleteKey
	 *            message if deleting one item
	 * @param moreDeleteKey
	 *            message if deleting more items
	 * @param resources
	 *            if true selecting resources if false selecting from hosts
	 */
private IModel<String> createDeleteConfirmString(final String oneDeleteKey, final String moreDeleteKey, final boolean resources) {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            List selected = new ArrayList();
            if (singleDelete != null) {
                selected.add(singleDelete);
            } else {
                selected = getResourceTable().getSelectedObjects();
            }
            switch(selected.size()) {
                case 1:
                    Object first = selected.get(0);
                    String name = WebComponentUtil.getName(((ResourceType) first));
                    return createStringResource(oneDeleteKey, name).getString();
                default:
                    return createStringResource(moreDeleteKey, selected.size()).getString();
            }
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)

Aggregations

AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)105 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)60 Label (org.apache.wicket.markup.html.basic.Label)59 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)54 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)41 ArrayList (java.util.ArrayList)34 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)29 ListItem (org.apache.wicket.markup.html.list.ListItem)29 IModel (org.apache.wicket.model.IModel)26 ListView (org.apache.wicket.markup.html.list.ListView)25 List (java.util.List)23 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)23 AttributeModifier (org.apache.wicket.AttributeModifier)21 PropertyModel (org.apache.wicket.model.PropertyModel)20 Model (org.apache.wicket.model.Model)16 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)13 TextField (org.apache.wicket.markup.html.form.TextField)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 Form (org.apache.wicket.markup.html.form.Form)9 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)8