Search in sources :

Example 36 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class AbstractTreeTablePanel method createOrgChildQuery.

protected ObjectQuery createOrgChildQuery() {
    SelectableBean<OrgType> dto = selected.getObject();
    String oid = dto != null && dto.getValue() != null ? dto.getValue().getOid() : getModel().getObject();
    BasicSearchPanel<String> basicSearch = (BasicSearchPanel) get(createComponentPath(ID_SEARCH_FORM, ID_BASIC_SEARCH));
    String object = basicSearch.getModelObject();
    DropDownChoice<String> searchScopeChoice = (DropDownChoice) get(createComponentPath(ID_SEARCH_FORM, ID_SEARCH_SCOPE));
    String scope = searchScopeChoice.getModelObject();
    if (StringUtils.isBlank(object)) {
        object = null;
    }
    PageBase page = getPageBase();
    PrismContext context = page.getPrismContext();
    S_AtomicFilterExit q;
    if (object == null || SEARCH_SCOPE_ONE.equals(scope)) {
        q = QueryBuilder.queryFor(OrgType.class, context).isDirectChildOf(oid);
    } else {
        q = QueryBuilder.queryFor(OrgType.class, context).isChildOf(oid);
    }
    if (object == null) {
        return q.build();
    }
    PolyStringNormalizer normalizer = context.getDefaultPolyStringNormalizer();
    String normalizedString = normalizer.normalize(object);
    if (StringUtils.isEmpty(normalizedString)) {
        return q.build();
    }
    ObjectQuery query = q.and().block().item(OrgType.F_NAME).containsPoly(normalizedString).matchingNorm().or().item(OrgType.F_DISPLAY_NAME).containsPoly(normalizedString).matchingNorm().build();
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Searching child orgs of org {} with query:\n{}", oid, query.debugDump());
    }
    return query;
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) BasicSearchPanel(com.evolveum.midpoint.web.component.BasicSearchPanel) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) PrismContext(com.evolveum.midpoint.prism.PrismContext) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 37 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class AssignmentPreviewDialog method initLayout.

public void initLayout() {
    List<IColumn<AssignmentsPreviewDto, String>> columns = initColumns();
    ListDataProvider provider = new ListDataProvider(pageBase, data);
    WebMarkupContainer content = new WebMarkupContainer(ID_CONTENT);
    content.setOutputMarkupId(true);
    add(content);
    TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
    table.setOutputMarkupId(true);
    content.add(table);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.selectButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<AssignmentsPreviewDto> previewDtos = data.getObject();
            List<AssignmentsPreviewDto> selectedDtos = new ArrayList<>();
            for (AssignmentsPreviewDto dto : previewDtos) {
                if (dto.isSelected()) {
                    selectedDtos.add(dto);
                }
            }
            AssignmentPreviewDialog.this.addButtonClicked(target, selectedDtos);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return multiselect;
        }
    });
    content.add(addButton);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("AssignmentPreviewDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            ((PageBase) getPage()).hideMainPopup(ajaxRequestTarget);
        }
    };
    content.add(cancelButton);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) ArrayList(java.util.ArrayList) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 38 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class TreeTablePanel method deleteNodeConfirmedPerformed.

private void deleteNodeConfirmedPerformed(SelectableBean<OrgType> orgToDelete, AjaxRequestTarget target) {
    getPageBase().hideMainPopup(target);
    OperationResult result = new OperationResult(OPERATION_DELETE_OBJECT);
    PageBase page = getPageBase();
    if (orgToDelete == null) {
        orgToDelete = getTreePanel().getRootFromProvider();
    }
    if (orgToDelete.getValue() == null) {
        return;
    }
    String oidToDelete = orgToDelete.getValue().getOid();
    WebModelServiceUtils.deleteObject(OrgType.class, oidToDelete, result, page);
    result.computeStatusIfUnknown();
    page.showResult(result);
    // TODO is this ok? [pmed]
    throw new RestartResponseException(getPage().getClass());
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 39 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class ResourceListPanel method initLayout.

protected void initLayout() {
    TablePanel resources = new TablePanel("table", new ObjectDataProvider((PageBase) getPage(), ResourceType.class), initColumns());
    resources.setOutputMarkupId(true);
    add(resources);
}
Also used : ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 40 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class AssignmentEditorPanel method getTargetObject.

private <O extends ObjectType> PrismObject<O> getTargetObject(AssignmentEditorDto dto) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    PrismContainerValue<AssignmentType> assignment = dto.getOldValue();
    PrismReference targetRef = assignment.findReference(AssignmentType.F_TARGET_REF);
    if (targetRef == null) {
        return null;
    }
    PrismReferenceValue refValue = targetRef.getValue();
    if (refValue != null && refValue.getObject() != null) {
        PrismObject object = refValue.getObject();
        return object;
    }
    String oid = targetRef.getOid();
    OperationResult result = new OperationResult(OPERATION_LOAD_OBJECT);
    PageBase page = getPageBase();
    ModelService model = page.getMidpointApplication().getModel();
    Task task = page.createSimpleTask(OPERATION_LOAD_OBJECT);
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
    Class<O> type = (Class<O>) ObjectType.class;
    if (refValue.getTargetType() != null) {
        type = getPageBase().getPrismContext().getSchemaRegistry().determineCompileTimeClass(refValue.getTargetType());
    }
    PrismObject<O> object = model.getObject(type, oid, options, task, result);
    refValue.setObject(object);
    return object;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) ModelService(com.evolveum.midpoint.model.api.ModelService) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions)

Aggregations

PageBase (com.evolveum.midpoint.gui.api.page.PageBase)44 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 Task (com.evolveum.midpoint.task.api.Task)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 SystemException (com.evolveum.midpoint.util.exception.SystemException)6 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 ModelService (com.evolveum.midpoint.model.api.ModelService)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)4 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)4 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)4 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 RestartResponseException (org.apache.wicket.RestartResponseException)3