Skip to content

Commit

Permalink
attempt to untangle code a bit, create provider for shadow search in …
Browse files Browse the repository at this point in the history
…repo
  • Loading branch information
katkav committed Jul 4, 2023
1 parent c004f8e commit 2c0199b
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.component.data.provider;

import com.evolveum.midpoint.gui.impl.component.search.Search;
import com.evolveum.midpoint.schema.GetOperationOptionsBuilder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;

import java.util.Set;

import static com.evolveum.midpoint.schema.DefinitionProcessingOption.FULL;
import static com.evolveum.midpoint.schema.DefinitionProcessingOption.ONLY_IF_EXISTS;

public class RepositoryShadowBeanObjectDataProvider extends SelectableBeanObjectDataProvider<ShadowType> {

public RepositoryShadowBeanObjectDataProvider(Component component, IModel<Search<ShadowType>> search, Set<ShadowType> selected) {
super(component, search, selected);
setEmptyListOnNullQuery(true);
setSort(null);
setDefaultCountIfNull(Integer.MAX_VALUE);
}

public RepositoryShadowBeanObjectDataProvider(Component component, Set<ShadowType> selected) {
this(component, null, selected);
}



@Override
protected GetOperationOptionsBuilder postProcessOptions(GetOperationOptionsBuilder optionsBuilder) {
optionsBuilder = optionsBuilder.item(ShadowType.F_ASSOCIATION).dontRetrieve()
.noFetch();

if (isEmptyListOnNullQuery()) {
return optionsBuilder
.definitionProcessing(ONLY_IF_EXISTS)
.item(ShadowType.F_FETCH_RESULT).definitionProcessing(FULL)
.item(ShadowType.F_AUXILIARY_OBJECT_CLASS).definitionProcessing(FULL);
}
return super.postProcessOptions(optionsBuilder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
*/
package com.evolveum.midpoint.gui.impl.component.data.provider;

import static com.evolveum.midpoint.schema.DefinitionProcessingOption.FULL;
import static com.evolveum.midpoint.schema.DefinitionProcessingOption.ONLY_IF_EXISTS;

import java.util.Collection;
import java.util.List;
import java.util.Set;
Expand All @@ -35,7 +32,6 @@
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.util.SelectableBeanImpl;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

/**
* @author lazyman
Expand Down Expand Up @@ -121,15 +117,6 @@ public void detach() {

@Override
protected GetOperationOptionsBuilder postProcessOptions(GetOperationOptionsBuilder optionsBuilder) {
if (isEmptyListOnNullQuery()) {
// TODO also for other classes
if (ShadowType.class.equals(getType())) {
return optionsBuilder
.definitionProcessing(ONLY_IF_EXISTS)
.item(ShadowType.F_FETCH_RESULT).definitionProcessing(FULL)
.item(ShadowType.F_AUXILIARY_OBJECT_CLASS).definitionProcessing(FULL);
}
}
return optionsBuilder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.evolveum.midpoint.web.application.PanelDisplay;
import com.evolveum.midpoint.web.application.PanelInstance;
import com.evolveum.midpoint.web.application.PanelType;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.model.StringResourceModel;
Expand Down Expand Up @@ -43,4 +44,9 @@ protected ShadowKindType getKind() {
protected StringResourceModel getLabelModel() {
return getPageBase().createStringResource("PageResource.tab.content.account");
}

@Override
protected UserProfileStorage.TableId getRepositorySearchTableId() {
return UserProfileStorage.TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import java.util.List;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.component.util.SelectableBean;

import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand All @@ -27,8 +25,9 @@
import com.evolveum.midpoint.gui.api.component.data.provider.ISelectableDataProvider;
import com.evolveum.midpoint.gui.api.component.form.CheckBoxPanel;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.impl.component.data.provider.SelectableBeanObjectDataProvider;
import com.evolveum.midpoint.gui.impl.component.data.provider.RepositoryShadowBeanObjectDataProvider;
import com.evolveum.midpoint.gui.impl.component.search.CollectionPanelType;
import com.evolveum.midpoint.gui.impl.component.search.Search;
import com.evolveum.midpoint.gui.impl.component.search.SearchContext;
import com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel;
Expand All @@ -55,6 +54,7 @@
import com.evolveum.midpoint.web.component.dialog.ConfirmationPanel;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
import com.evolveum.midpoint.web.component.input.ResourceObjectTypeChoiceRenderer;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.web.page.admin.resources.SynchronizationTaskFlavor;
Expand Down Expand Up @@ -199,11 +199,11 @@ private Integer countFor(ObjectFilter situationFilter) {
}

private void createShadowTable() {
ShadowTablePanel shadowTablePanel = new ShadowTablePanel(ID_TABLE, createSearchOptions(), getPanelConfiguration()) {
ShadowTablePanel shadowTablePanel = new ShadowTablePanel(ID_TABLE, null, getPanelConfiguration()) {

@Override
protected UserProfileStorage.TableId getTableId() {
return null;
return ResourceObjectsPanel.this.getRepositorySearchTableId();
}

@Override
Expand All @@ -213,11 +213,9 @@ public PageStorage getPageStorage() {

@Override
protected ISelectableDataProvider<SelectableBean<ShadowType>> createProvider() {
SelectableBeanObjectDataProvider<ShadowType> provider = createSelectableBeanObjectDataProvider(() -> getResourceContentQuery(), null);
provider.setEmptyListOnNullQuery(true);
provider.setSort(null);
provider.setDefaultCountIfNull(Integer.MAX_VALUE);
return provider;

return ResourceObjectsPanel.this.createProvider(getSearchModel(), (CompiledShadowCollectionView) getObjectCollectionView());
// return provider;
}

@Override
Expand Down Expand Up @@ -255,20 +253,32 @@ protected List<Component> createToolbarButtonsList(String buttonId) {
shadowTablePanel.setOutputMarkupId(true);
add(shadowTablePanel);
}

//case GENERIC:
// return UserProfileStorage.TableId.PAGE_RESOURCE_GENERIC_PANEL_REPOSITORY_MODE;
// case ENTITLEMENT:
// return UserProfileStorage.TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE;
protected abstract UserProfileStorage.TableId getRepositorySearchTableId();
protected abstract StringResourceModel getLabelModel();

protected final RepositoryShadowBeanObjectDataProvider createProvider(IModel<Search<ShadowType>> searchModel, CompiledShadowCollectionView collection) {
RepositoryShadowBeanObjectDataProvider provider = new RepositoryShadowBeanObjectDataProvider(
getPageBase(), searchModel, null) {
@Override
protected PageStorage getPageStorage() {
return getPageBase().getSessionStorage().getResourceContentStorage(getKind());
}

private Collection<SelectorOptions<GetOperationOptions>> createSearchOptions() {
GetOperationOptionsBuilder builder = getPageBase().getOperationOptionsBuilder()
.item(ShadowType.F_ASSOCIATION).dontRetrieve();
builder = addAdditionalOptions(builder);
return builder.build();
}
@Override
protected ObjectQuery getCustomizeContentQuery() {
return getResourceContentQuery();
}

protected GetOperationOptionsBuilder addAdditionalOptions(GetOperationOptionsBuilder builder) {
return builder.root().noFetch();
};
provider.setCompiledObjectCollectionView(collection);
return provider;
}

protected abstract ShadowKindType getKind();

private ObjectQuery getResourceContentQuery() {
Expand Down Expand Up @@ -342,9 +352,9 @@ private void createReclassifyTask(AjaxRequestTarget target) throws RestartRespon
ResourceTaskCreator.forResource(resource, getPageBase())
.ofFlavor(SynchronizationTaskFlavor.IMPORT)
.withCoordinates(
getKind(), // FIXME not static
getIntent(), // FIXME not static
getObjectClass()) // FIXME not static
getKind(),
getIntent(),
getObjectClass())
.withExecutionMode(ExecutionModeType.PREVIEW)
.withPredefinedConfiguration(PredefinedConfigurationType.DEVELOPMENT)
.withSubmissionOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ private UserProfileStorage.TableId getTableId() {

if (searchMode.equals(SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT)) {
switch (kind) {
case ACCOUNT:
return UserProfileStorage.TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE;
case GENERIC:
return UserProfileStorage.TableId.PAGE_RESOURCE_GENERIC_PANEL_REPOSITORY_MODE;
case ENTITLEMENT:
return UserProfileStorage.TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE;
// case ACCOUNT:
// return UserProfileStorage.TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE;
// case GENERIC:
// return UserProfileStorage.TableId.PAGE_RESOURCE_GENERIC_PANEL_REPOSITORY_MODE;
// case ENTITLEMENT:
// return UserProfileStorage.TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE;

default:
return UserProfileStorage.TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL;
Expand Down

0 comments on commit 2c0199b

Please sign in to comment.