-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MID-6393: Added support for per-panel configuration of data providers
- Loading branch information
1 parent
8218e27
commit 7bcd075
Showing
9 changed files
with
466 additions
and
50 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/registry/DataProviderRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (C) 2022 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.api.registry; | ||
|
||
import com.evolveum.midpoint.prism.Containerable; | ||
import com.evolveum.midpoint.web.component.data.ContainerValueDataProviderFactory; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiListDataProviderType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectListViewType; | ||
|
||
/** | ||
* | ||
* Data Provider registry for customizable data providers | ||
* | ||
*/ | ||
public interface DataProviderRegistry { | ||
|
||
/** | ||
* Returns provider factory for supplied data type and configuraitno. | ||
* | ||
* @param <T> Data Type | ||
* @param dataType Data Type | ||
* @param viewConfig View configuration | ||
* @param defaultProvider Configuration type of default provider | ||
* @return null, if no provider matches arguments, if viewport configuration does contain concrete provider configuration returns that provider, otherwise returns default provider. | ||
*/ | ||
default <T extends Containerable> ContainerValueDataProviderFactory<T,?> forContainerValue(Class<T> dataType, GuiObjectListViewType viewConfig, Class<? extends GuiListDataProviderType> defaultProvider) { | ||
if (viewConfig != null) { | ||
GuiListDataProviderType providerConfig = viewConfig.getDataProvider(); | ||
if (providerConfig != null) { | ||
var maybe = forContainerValue(dataType, providerConfig.getClass()); | ||
if (maybe != null) { | ||
return maybe; | ||
} | ||
} | ||
|
||
} | ||
return forContainerValue(dataType, defaultProvider); | ||
} | ||
|
||
/** | ||
* | ||
* @param <T> Data Type | ||
* @param <C> Configuration Type | ||
* @param dataType Data Type | ||
* @param configurationType Configuration Type | ||
* @return Container Value Data Provider Factory for specified type combination, or null if no provider factory matches | ||
*/ | ||
<T extends Containerable, C extends GuiListDataProviderType> ContainerValueDataProviderFactory<T,C> forContainerValue(Class<T> dataType, Class<C> configurationType); | ||
|
||
} |
91 changes: 91 additions & 0 deletions
91
...va/com/evolveum/midpoint/gui/impl/factory/data/InMemoryAssignmentDataProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (C) 2022 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.factory.data; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.wicket.model.IModel; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper; | ||
import com.evolveum.midpoint.gui.impl.component.search.Search; | ||
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; | ||
import com.evolveum.midpoint.prism.Objectable; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.prism.query.ObjectQuery; | ||
import com.evolveum.midpoint.web.component.data.ContainerValueDataProviderFactory; | ||
import com.evolveum.midpoint.web.component.data.ISelectableDataProvider; | ||
import com.evolveum.midpoint.web.component.util.AssignmentListProvider; | ||
import com.evolveum.midpoint.web.session.PageStorage; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.InMemoryAssignmentDataProviderType; | ||
|
||
@Component | ||
public class InMemoryAssignmentDataProviderFactory implements ContainerValueDataProviderFactory<AssignmentType, InMemoryAssignmentDataProviderType>{ | ||
|
||
@Override | ||
public Class<AssignmentType> getDataType() { | ||
return AssignmentType.class; | ||
} | ||
|
||
@Override | ||
public Class<InMemoryAssignmentDataProviderType> getConfigurationType() { | ||
return InMemoryAssignmentDataProviderType.class; | ||
} | ||
|
||
@Override | ||
public boolean isRepositorySearchEnabled() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ISelectableDataProvider<AssignmentType, PrismContainerValueWrapper<AssignmentType>> create( | ||
org.apache.wicket.Component component, @NotNull IModel<Search<AssignmentType>> search, | ||
IModel<List<PrismContainerValueWrapper<AssignmentType>>> model, Class<? extends Objectable> objectType, | ||
String oid, ItemPath path) { | ||
return new AssignmentListProvider(component, search, model); | ||
} | ||
|
||
@Override | ||
public ISelectableDataProvider<AssignmentType, PrismContainerValueWrapper<AssignmentType>> create( | ||
org.apache.wicket.Component component, @NotNull IModel<Search<AssignmentType>> search, | ||
IModel<List<PrismContainerValueWrapper<AssignmentType>>> model, Class<? extends Objectable> objectType, | ||
String oid, ItemPath path, CompiledObjectCollectionView collection, Customization<AssignmentType> customization) { | ||
return doCreate(component, search, model, objectType, oid, path, collection, customization); | ||
} | ||
|
||
/** | ||
* Static method is neccessary to not serialize also factory | ||
*/ | ||
private static ISelectableDataProvider<AssignmentType, PrismContainerValueWrapper<AssignmentType>> doCreate( | ||
org.apache.wicket.Component component, @NotNull IModel<Search<AssignmentType>> search, | ||
IModel<List<PrismContainerValueWrapper<AssignmentType>>> model, Class<? extends Objectable> objectType, | ||
String oid, ItemPath path, CompiledObjectCollectionView collection, Customization<AssignmentType> customization) { | ||
var provider = new AssignmentListProvider(component, search, model) { | ||
|
||
@Override | ||
protected PageStorage getPageStorage() { | ||
return customization.getPageStorage(); | ||
} | ||
|
||
@Override | ||
protected List<PrismContainerValueWrapper<AssignmentType>> postFilter( | ||
List<PrismContainerValueWrapper<AssignmentType>> assignmentList) { | ||
return customization.postFilter(assignmentList); | ||
} | ||
|
||
@Override | ||
protected ObjectQuery getCustomizeContentQuery() { | ||
return customization.getCustomizeContentQuery(); | ||
} | ||
}; | ||
provider.setCompiledObjectCollectionView(collection); | ||
return provider; | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
.../com/evolveum/midpoint/gui/impl/factory/data/RepositoryAssignmentDataProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright (C) 2022 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.factory.data; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.wicket.model.IModel; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper; | ||
import com.evolveum.midpoint.gui.impl.component.search.Search; | ||
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; | ||
import com.evolveum.midpoint.prism.Objectable; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.prism.query.ObjectQuery; | ||
import com.evolveum.midpoint.web.component.data.ContainerValueDataProviderFactory; | ||
import com.evolveum.midpoint.web.component.data.ISelectableDataProvider; | ||
import com.evolveum.midpoint.web.component.util.RepoAssignmentListProvider; | ||
import com.evolveum.midpoint.web.session.PageStorage; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.RepositoryAssignmentDataProviderType; | ||
|
||
@Component | ||
public class RepositoryAssignmentDataProviderFactory implements ContainerValueDataProviderFactory<AssignmentType, RepositoryAssignmentDataProviderType>{ | ||
|
||
@Override | ||
public Class<AssignmentType> getDataType() { | ||
return AssignmentType.class; | ||
} | ||
|
||
@Override | ||
public Class<RepositoryAssignmentDataProviderType> getConfigurationType() { | ||
return RepositoryAssignmentDataProviderType.class; | ||
} | ||
|
||
@Override | ||
public boolean isRepositorySearchEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public ISelectableDataProvider<AssignmentType, PrismContainerValueWrapper<AssignmentType>> create( | ||
org.apache.wicket.Component component, @NotNull IModel<Search<AssignmentType>> search, | ||
IModel<List<PrismContainerValueWrapper<AssignmentType>>> model, Class<? extends Objectable> objectType, | ||
String oid, ItemPath path) { | ||
return new RepoAssignmentListProvider(component, search, model, objectType, oid, path); | ||
} | ||
|
||
@Override | ||
public ISelectableDataProvider<AssignmentType, PrismContainerValueWrapper<AssignmentType>> create( | ||
org.apache.wicket.Component component, @NotNull IModel<Search<AssignmentType>> search, | ||
IModel<List<PrismContainerValueWrapper<AssignmentType>>> model, Class<? extends Objectable> objectType, | ||
String oid, ItemPath path, CompiledObjectCollectionView collection, Customization<AssignmentType> customization) { | ||
return doCreate(component, search, model, objectType, oid, path, collection, customization); | ||
} | ||
|
||
private static ISelectableDataProvider<AssignmentType, PrismContainerValueWrapper<AssignmentType>> doCreate( | ||
org.apache.wicket.Component component, @NotNull IModel<Search<AssignmentType>> search, | ||
IModel<List<PrismContainerValueWrapper<AssignmentType>>> model, Class<? extends Objectable> objectType, | ||
String oid, ItemPath path, CompiledObjectCollectionView collection, Customization<AssignmentType> customization) { | ||
RepoAssignmentListProvider provider = new RepoAssignmentListProvider(component, search, model, objectType, oid, path) { | ||
|
||
@Override | ||
protected PageStorage getPageStorage() { | ||
return customization.getPageStorage(); | ||
} | ||
|
||
@Override | ||
protected List<PrismContainerValueWrapper<AssignmentType>> postFilter( | ||
List<PrismContainerValueWrapper<AssignmentType>> assignmentList) { | ||
return customization.postFilter(assignmentList); | ||
} | ||
|
||
@Override | ||
protected ObjectQuery getCustomizeContentQuery() { | ||
return customization.getCustomizeContentQuery(); | ||
} | ||
}; | ||
provider.setCompiledObjectCollectionView(collection); | ||
return provider; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...n-gui/src/main/java/com/evolveum/midpoint/gui/impl/registry/DataProviderRegistryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2022 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.registry; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.evolveum.midpoint.gui.api.registry.DataProviderRegistry; | ||
import com.evolveum.midpoint.prism.Containerable; | ||
import com.evolveum.midpoint.web.component.data.ContainerValueDataProviderFactory; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiListDataProviderType; | ||
|
||
/** | ||
* | ||
* Spring based Data Provider registry | ||
* | ||
* Factories are expected to be instantiated by Spring using {@link Component} annotation | ||
* and autowired using {@link Autowired} | ||
* | ||
*/ | ||
@Component | ||
public class DataProviderRegistryImpl implements DataProviderRegistry { | ||
|
||
@Autowired | ||
List<ContainerValueDataProviderFactory<?,?>> containerValueFactories; | ||
|
||
@Override | ||
public <T extends Containerable, C extends GuiListDataProviderType> ContainerValueDataProviderFactory<T, C> forContainerValue( | ||
Class<T> dataType, Class<C> configurationType) { | ||
for (ContainerValueDataProviderFactory<?, ?> factory : containerValueFactories) { | ||
if (factory.getConfigurationType().isAssignableFrom(configurationType) && factory.isSupported(dataType)) { | ||
return factory.specializedFor(dataType, configurationType); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.