Search in sources :

Example 21 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class ContainerableListPanel method isCollectionViewPanelForWidget.

protected boolean isCollectionViewPanelForWidget() {
    PageParameters parameters = getPageBase().getPageParameters();
    if (parameters != null) {
        StringValue widget = parameters.get(PageBase.PARAMETER_DASHBOARD_WIDGET_NAME);
        StringValue dashboardOid = parameters.get(PageBase.PARAMETER_DASHBOARD_TYPE_OID);
        return widget != null && widget.toString() != null && dashboardOid != null && dashboardOid.toString() != null;
    }
    return false;
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue)

Example 22 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class AuditLogViewerPanel method initLayout.

private void initLayout() {
    ContainerableListPanel<AuditEventRecordType, SelectableBean<AuditEventRecordType>> auditLogViewerTable = new ContainerableListPanel<>(ID_AUDIT_LOG_VIEWER_TABLE, AuditEventRecordType.class) {

        @Override
        protected List<IColumn<SelectableBean<AuditEventRecordType>, String>> createDefaultColumns() {
            return AuditLogViewerPanel.this.createColumns();
        }

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

        @Override
        protected IColumn<SelectableBean<AuditEventRecordType>, String> createNameColumn(IModel<String> displayModel, GuiObjectColumnType customColumn, ItemPath itemPath, ExpressionType expression) {
            return AuditLogViewerPanel.this.createNameColumn();
        }

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

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

        @Override
        protected Search createSearch(Class<AuditEventRecordType> type) {
            // TODO: use storage?
            AuditLogStorage storage = (AuditLogStorage) getPageStorage();
            Search search = SearchFactory.createContainerSearch(new ContainerTypeSearchItem(new SearchValue(type, "")), AuditEventRecordType.F_TIMESTAMP, getPageBase(), true);
            DateSearchItem timestampItem = (DateSearchItem) search.findPropertySearchItem(AuditEventRecordType.F_TIMESTAMP);
            if (timestampItem != null && timestampItem.getFromDate() == null && timestampItem.getToDate() == null && !isCollectionViewPanelForWidget()) {
                Date todayDate = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant());
                timestampItem.setFromDate(MiscUtil.asXMLGregorianCalendar(todayDate));
            }
            return search;
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER;
        }

        @Override
        protected String getStorageKey() {
            String collectionNameValue = null;
            if (isCollectionViewPanelForCompiledView()) {
                StringValue collectionName = getCollectionNameParameterValue();
                collectionNameValue = collectionName != null ? collectionName.toString() : "";
            }
            return getAuditStorageKey(collectionNameValue);
        }

        @Override
        protected ISelectableDataProvider createProvider() {
            PageStorage pageStorage = getPageStorage();
            SelectableBeanContainerDataProvider<AuditEventRecordType> provider = new SelectableBeanContainerDataProvider<AuditEventRecordType>(AuditLogViewerPanel.this, getSearchModel(), null, false) {

                @Override
                protected PageStorage getPageStorage() {
                    return pageStorage;
                }

                @Override
                protected Integer countObjects(Class<? extends AuditEventRecordType> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result) throws CommonException {
                    return getPageBase().getModelAuditService().countObjects(query, currentOptions, task, result);
                }

                @Override
                protected List<AuditEventRecordType> searchObjects(Class<? extends AuditEventRecordType> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result) throws CommonException {
                    return getPageBase().getModelAuditService().searchObjects(query, options, task, result);
                }

                @NotNull
                @Override
                protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
                    if (sortParam != null && sortParam.getProperty() != null) {
                        OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
                        return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ItemPath.create(new QName(AuditEventRecordType.COMPLEX_TYPE.getNamespaceURI(), sortParam.getProperty())), order));
                    } else {
                        return Collections.emptyList();
                    }
                }

                @Override
                protected ObjectQuery getCustomizeContentQuery() {
                    return AuditLogViewerPanel.this.getCustomizeContentQuery();
                }
            };
            provider.setSort(AuditEventRecordType.F_TIMESTAMP.getLocalPart(), SortOrder.DESCENDING);
            return provider;
        }

        @Override
        protected AuditEventRecordType getRowRealValue(SelectableBean<AuditEventRecordType> rowModelObject) {
            if (rowModelObject == null) {
                return null;
            }
            return rowModelObject.getValue();
        }

        @Override
        protected List<Component> createToolbarButtonsList(String idButton) {
            List<Component> buttonsList = new ArrayList<>();
            CsvDownloadButtonPanel exportDataLink = new CsvDownloadButtonPanel(idButton) {

                private static final long serialVersionUID = 1L;

                @Override
                protected String getFilename() {
                    return "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
                }

                @Override
                protected DataTable<?, ?> getDataTable() {
                    return getTable().getDataTable();
                }
            };
            exportDataLink.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_CSV_EXPORT_ACTION_URI);
                }
            });
            buttonsList.add(exportDataLink);
            AjaxCompositedIconButton createReport = new AjaxCompositedIconButton(idButton, WebComponentUtil.createCreateReportIcon(), getPageBase().createStringResource("MainObjectListPanel.createReport")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    createReportPerformed(target);
                }
            };
            createReport.add(AttributeAppender.append("class", "btn btn-default btn-sm btn-margin-right"));
            buttonsList.add(createReport);
            return buttonsList;
        }
    };
    auditLogViewerTable.setOutputMarkupId(true);
    add(auditLogViewerTable);
}
Also used : AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) Task(com.evolveum.midpoint.task.api.Task) GuiObjectColumnType(com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectColumnType) AuditLogStorage(com.evolveum.midpoint.web.session.AuditLogStorage) ContainerableListPanel(com.evolveum.midpoint.gui.impl.component.ContainerableListPanel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) StringValue(org.apache.wicket.util.string.StringValue) Component(org.apache.wicket.Component) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) PageStorage(com.evolveum.midpoint.web.session.PageStorage) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) LocalDate(java.time.LocalDate) CsvDownloadButtonPanel(com.evolveum.midpoint.gui.api.component.button.CsvDownloadButtonPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 23 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class PageDashboardConfigurable method initDashboardObject.

private IModel<DashboardType> initDashboardObject() {
    return new LoadableModel<DashboardType>(false) {

        @Override
        public DashboardType load() {
            StringValue dashboardOid = getPageParameters().get(OnePageParameterEncoder.PARAMETER);
            if (dashboardOid == null || StringUtils.isEmpty(dashboardOid.toString())) {
                getSession().error(getString("PageDashboardConfigurable.message.oidNotDefined"));
                throw new RestartResponseException(PageDashboardInfo.class);
            }
            Task task = createSimpleTask("Search dashboard");
            return WebModelServiceUtils.loadObject(DashboardType.class, dashboardOid.toString(), PageDashboardConfigurable.this, task, task.getResult()).getRealValue();
        }
    };
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RestartResponseException(org.apache.wicket.RestartResponseException) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) StringValue(org.apache.wicket.util.string.StringValue) DashboardType(com.evolveum.midpoint.xml.ns._public.common.common_3.DashboardType)

Example 24 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class PageAdminObjectDetails method getObjectOidParameter.

protected String getObjectOidParameter() {
    PageParameters parameters = getPageParameters();
    LOGGER.trace("Page parameters: {}", parameters);
    StringValue oidValue = parameters.get(OnePageParameterEncoder.PARAMETER);
    LOGGER.trace("OID parameter: {}", oidValue);
    if (oidValue == null) {
        return null;
    }
    String oid = oidValue.toString();
    if (StringUtils.isBlank(oid)) {
        return null;
    }
    return oid;
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue)

Example 25 with StringValue

use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.

the class LeftMenuPanel method isObjectCollectionMenuActive.

private boolean isObjectCollectionMenuActive(CompiledObjectCollectionView objectView) {
    PageParameters params = getPageBase().getPageParameters();
    if (params == null) {
        return false;
    }
    StringValue collectionNameParam = params.get(PageBase.PARAMETER_OBJECT_COLLECTION_NAME);
    if (collectionNameParam.isEmpty()) {
        return false;
    }
    return collectionNameParam.toString().equals(objectView.getViewIdentifier());
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue)

Aggregations

StringValue (org.apache.wicket.util.string.StringValue)54 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 Test (org.junit.Test)7 Task (com.evolveum.midpoint.task.api.Task)6 Url (org.apache.wicket.request.Url)5 IOException (java.io.IOException)4 WebSession (org.apache.openmeetings.web.app.WebSession)4 RestartResponseException (org.apache.wicket.RestartResponseException)4 IRequestHandler (org.apache.wicket.request.IRequestHandler)3 AbstractResource (org.apache.wicket.request.resource.AbstractResource)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 ObjectViewDto (com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)2 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)2 Vertex (com.tinkerpop.blueprints.Vertex)2 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)2 Template (eu.esdihumboldt.hale.server.model.Template)2 User (eu.esdihumboldt.hale.server.model.User)2 NonUniqueResultException (eu.esdihumboldt.util.blueprints.entities.NonUniqueResultException)2