Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Oct 27, 2022
2 parents 4261208 + 86c9fe9 commit a9255c6
Show file tree
Hide file tree
Showing 14 changed files with 465 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.List;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.util.QNameUtil;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -172,7 +174,7 @@ protected List<ITab> createAssignmentTabs(AssignmentObjectRelation relationSpec)
List<ObjectReferenceType> archetypeRefList = relationSpec != null && !CollectionUtils.isEmpty(relationSpec.getArchetypeRefs()) ?
relationSpec.getArchetypeRefs() : getArchetypeRefList();
tabs.add(new CountablePanelTab(getPageBase().createStringResource("ObjectTypes.USER"),
new VisibleBehaviour(() -> objectTypes == null || objectTypes.contains(UserType.COMPLEX_TYPE))) {
new VisibleBehaviour(() -> objectTypes == null || QNameUtil.contains(objectTypes, UserType.COMPLEX_TYPE))) {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -205,7 +207,7 @@ public String getCount() {
});

tabs.add(new CountablePanelTab(getPageBase().createStringResource("ObjectTypes.ROLE"),
new VisibleBehaviour(() -> objectTypes == null || objectTypes.contains(RoleType.COMPLEX_TYPE))) {
new VisibleBehaviour(() -> objectTypes == null || QNameUtil.contains(objectTypes, RoleType.COMPLEX_TYPE))) {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -239,7 +241,7 @@ public String getCount() {

tabs.add(
new CountablePanelTab(getPageBase().createStringResource("ObjectTypes.ORG"),
new VisibleBehaviour(() -> objectTypes == null || objectTypes.contains(OrgType.COMPLEX_TYPE))) {
new VisibleBehaviour(() -> objectTypes == null || QNameUtil.contains(objectTypes, OrgType.COMPLEX_TYPE))) {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -280,7 +282,7 @@ public String getCount() {

if (archetypeRefList == null || archetypeRefList.isEmpty()) {
tabs.add(new CountablePanelTab(createStringResource("TypedAssignablePanel.orgTreeView"),
new VisibleBehaviour(() -> isOrgTreeVisible() && (objectTypes == null || objectTypes.contains(OrgType.COMPLEX_TYPE)))) {
new VisibleBehaviour(() -> isOrgTreeVisible() && (objectTypes == null || QNameUtil.contains(objectTypes, OrgType.COMPLEX_TYPE)))) {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -316,7 +318,7 @@ public String getCount() {

tabs.add(
new CountablePanelTab(getPageBase().createStringResource("ObjectTypes.SERVICE"),
new VisibleBehaviour(() -> objectTypes == null || objectTypes.contains(ServiceType.COMPLEX_TYPE))) {
new VisibleBehaviour(() -> objectTypes == null || QNameUtil.contains(objectTypes, ServiceType.COMPLEX_TYPE))) {

private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2021 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;

import com.evolveum.midpoint.gui.api.component.MainObjectListPanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.component.search.Search;
import com.evolveum.midpoint.gui.impl.component.search.SearchConfigurationWrapper;
import com.evolveum.midpoint.gui.impl.component.search.SearchFactory;
import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.util.QNameUtil;
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.component.data.ISelectableDataProvider;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import java.util.Arrays;

public abstract class AbstractObjectListPanel<O extends ObjectType> extends MainObjectListPanel<O> {

private final ObjectDetailsModels<O> objectDetailsModel;

public AbstractObjectListPanel(String id, ObjectDetailsModels<O> model, ContainerPanelConfigurationType config) {
super(id, (Class<O>) ObjectType.class, null, config);
objectDetailsModel = model;
}

public ObjectDetailsModels<O> getObjectDetailsModel() {
return objectDetailsModel;
}

@Override
protected boolean isCreateNewObjectEnabled() {
return false;
}

@Override
protected ISelectableDataProvider<SelectableBean<O>> createProvider() {
return createSelectableBeanObjectDataProvider(() -> getCustomizeContentQuery(), null);
}

protected ObjectQuery getCustomizeContentQuery(){
return null;
}

@Override
protected Search createSearch(Class<O> type) {
return SearchFactory.createSearch(createSearchBoxConfigurationWrapper(), getPageBase());
}

protected SearchConfigurationWrapper<O> createSearchBoxConfigurationWrapper() {
CompiledObjectCollectionView view = getObjectCollectionView();

SearchConfigurationWrapper<O> searchWrapper;
if (getPanelConfiguration() != null
&& getPanelConfiguration().getListView() != null
&& getPanelConfiguration().getListView().getSearchBoxConfiguration() != null) {
searchWrapper = new SearchConfigurationWrapper<>(getType(), getPanelConfiguration().getListView().getSearchBoxConfiguration(), getPageBase());
} else if (view != null && view.getSearchBoxConfiguration() != null) {
searchWrapper = new SearchConfigurationWrapper<>(getType(), view.getSearchBoxConfiguration(), getPageBase());
} else {
searchWrapper = new SearchConfigurationWrapper<>(getType(), getPageBase());
}

if (view != null
&& view.getCollection() != null
&& view.getCollection().getCollectionRef() != null
&& QNameUtil.match(ObjectCollectionType.COMPLEX_TYPE, view.getCollection().getCollectionRef().getType())) {
searchWrapper.setCollectionRefOid(view.getCollection().getCollectionRef().getOid());
}

return searchWrapper;
}

@Override
protected String getStorageKey() {
String suffix = getTableId().name();
if (getPanelConfiguration() != null) {
suffix = getPanelConfiguration().getIdentifier();
}
return WebComponentUtil.getObjectListPageStorageKey(suffix);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ private static <C extends Containerable> Search<C> createSearch(
ObjectTypeSearchItemWrapper typeItem = new ObjectTypeSearchItemWrapper(searchConfWrapper.getAllowedTypeList(),
WebComponentUtil.containerClassToQName(PrismContext.get(), searchConfWrapper.getTypeClass()));
typeItem.setAllowAllTypesSearch(searchConfWrapper.isAllowAllTypeSearch());
if (searchConfWrapper.getAllowedTypeList().size() == 1) {
typeItem.setVisible(false);
}
searchConfWrapper.getItemsList().add(typeItem);
}
if (searchConfWrapper.getAllowedModeList().contains(SearchBoxModeType.OID)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon;
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private CompiledObjectCollectionView getCompiledCollectionViewFromPanelConfigura
if (collectionRefSpecificationType == null) {
compiledCollectionViewFromPanelConfiguration = new CompiledObjectCollectionView();
getPageBase().getModelInteractionService().applyView(compiledCollectionViewFromPanelConfiguration, getPanelConfiguration().getListView());
return null;
return compiledCollectionViewFromPanelConfiguration;
}
Task task = getPageBase().createSimpleTask("Compile collection");
OperationResult result = task.getResult();
Expand Down Expand Up @@ -431,15 +431,15 @@ private SearchConfigurationWrapper createSearchConfigWrapper(Class<? extends Obj
if (searchConfig.getTenantConfiguration() == null && !isNotRole()) {
searchConfig.setTenantConfiguration(searchBoxConfig.getDefaultTenantConfiguration());
}
SearchConfigurationWrapper searchConfigWrapper = new SearchConfigurationWrapper(defaultObjectType, searchConfig, getPageBase());
SearchConfigurationWrapper<?> searchConfigWrapper = new SearchConfigurationWrapper<>(defaultObjectType, searchConfig, getPageBase());
SearchFactory.createAbstractRoleSearchItemWrapperList(searchConfigWrapper, searchConfig);
if (additionalPanelConfig != null) {
searchConfigWrapper.setAllowToConfigureSearchItems(!Boolean.FALSE.equals(additionalPanelConfig.isAllowToConfigureSearchItems()));
}
searchConfigWrapper.getItemsList().forEach(item -> {
if (item instanceof ObjectTypeSearchItemWrapper) {
((ObjectTypeSearchItemWrapper) item).setAllowAllTypesSearch(true);
((ObjectTypeSearchItemWrapper) item).setValueForNull(
((ObjectTypeSearchItemWrapper<?>) item).setAllowAllTypesSearch(true);
((ObjectTypeSearchItemWrapper<?>) item).setValueForNull(
WebComponentUtil.classToQName(getPageBase().getPrismContext(), getChoiceForAllTypes()));
}
});
Expand Down Expand Up @@ -624,7 +624,7 @@ protected R getAssignmentTargetRefObject() {

@Override
protected List<QName> getAvailableObjectTypes() {
return null;
return getSearchBoxConfiguration().getSupportedObjectTypes();
}

@Override
Expand Down Expand Up @@ -1427,7 +1427,7 @@ private boolean checkRelationNotSelected(Collection<QName> relations, String mes
return getSearchBoxConfiguration().getSupportedRelations();
}

protected ObjectQuery getActionQuery(IModel rowModel, QueryScope scope, @NotNull Collection<QName> relations) {
protected ObjectQuery getActionQuery(IModel<?> rowModel, QueryScope scope, @NotNull Collection<QName> relations) {
AssignmentHolderType assignmentHolder = getAssignmetHolderFromRow(rowModel);
if (assignmentHolder == null) {
return getActionQuery(scope, relations);
Expand Down Expand Up @@ -1459,7 +1459,7 @@ protected List<QName> getDefaultSupportedObjectTypes(boolean includeAbstractType
}

protected List<QName> getNewMemberObjectTypes() {
return WebComponentUtil.createFocusTypeList();
return getSearchBoxConfiguration().getSupportedObjectTypes();
}

protected MainObjectListPanel<FocusType> getMemberTable() {
Expand Down Expand Up @@ -1575,17 +1575,9 @@ protected SearchBoxConfigurationHelper getSearchBoxConfiguration() {
}
searchBoxConfiguration = new SearchBoxConfigurationHelper(additionalPanelConfig);
searchBoxConfiguration.setDefaultSupportedRelations(getSupportedRelations());
searchBoxConfiguration.setDefaultSupportedObjectTypes(getDefaultSupportedObjectTypes(false));
searchBoxConfiguration.setDefaultSupportedObjectTypes(getDefaultSupportedObjectTypes(true));
searchBoxConfiguration.setDefaultObjectType(WebComponentUtil.classToQName(getPrismContext(), getDefaultObjectType()));

// MemberPanelStorage storage = (MemberPanelStorage) pageStorage;
//
// storage.setIndirectSearchItem(searchBoxCofig.getDefaultIndirectConfiguration());
// storage.setRelationSearchItem(searchBoxCofig.getDefaultRelationConfiguration());
// storage.setScopeSearchItem(searchBoxCofig.getDefaultSearchScopeConfiguration());
// storage.setObjectTypeSearchItem(searchBoxCofig.getDefaultObjectTypeConfiguration());
// storage.setTenantSearchItem(searchBoxCofig.getDefaultTenantConfiguration());
// storage.setProjectSearchItem(searchBoxCofig.getDefaultProjectConfiguration());
return searchBoxConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.page.admin.abstractrole.component;

import com.evolveum.midpoint.gui.impl.component.AbstractObjectListPanel;
import com.evolveum.midpoint.gui.impl.component.search.SearchConfigurationWrapper;
import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.web.application.*;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import java.util.Arrays;

@PanelType(name = "inducedBy")
@PanelInstance(identifier = "inducedBy",
applicableForType = AbstractRoleType.class,
display = @PanelDisplay(label = "InducedByPanel.label", order = 130))
public class InducedByPanel<AR extends AbstractRoleType> extends AbstractObjectListPanel<AR> {

public InducedByPanel(String id, ObjectDetailsModels<AR> model, ContainerPanelConfigurationType config) {
super(id, model, config);
}

@Override
protected Class<AR> getDefaultType() {
return (Class<AR>) AbstractRoleType.class;
}

protected ObjectQuery getCustomizeContentQuery(){
return PrismContext.get().queryFor(AbstractRoleType.class)
.item(ItemPath.create(AbstractRoleType.F_INDUCEMENT, AssignmentType.F_TARGET_REF))
.ref(getObjectDetailsModel().getObjectWrapper().getOid()).build();
}

protected SearchConfigurationWrapper<AR> createSearchBoxConfigurationWrapper() {
SearchConfigurationWrapper<AR> searchWrapper = super.createSearchBoxConfigurationWrapper();
if (searchWrapper.getAllowedTypeList().isEmpty()) {
searchWrapper.getAllowedTypeList()
.addAll(Arrays.asList(
AbstractRoleType.class,
OrgType.class,
ArchetypeType.class,
RoleType.class,
ServiceType.class));
}
return searchWrapper;
}

@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PANEL_INDUCT_BY;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2021 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.page.admin.assignmentholder.component;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.component.AbstractObjectListPanel;
import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
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.*;

@PanelType(name = "roleMemberships")
public class RoleMembershipPanel<AH extends AssignmentHolderType> extends AbstractObjectListPanel<AH> {

public RoleMembershipPanel(String id, ObjectDetailsModels<AH> model, ContainerPanelConfigurationType config) {
super(id, model, config);
}

@Override
protected Class<AH> getDefaultType() {
return (Class<AH>) AssignmentHolderType.class;
}

protected ObjectQuery getCustomizeContentQuery() {

if (getPageBase().isNativeRepo()) {
return getPrismContext().queryFor(AbstractRoleType.class)
.referencedBy(getObjectDetailsModel().getObjectType().getClass(), AssignmentHolderType.F_ROLE_MEMBERSHIP_REF)
.id(getObjectDetailsModel().getObjectWrapper().getOid())
.and().not().type(ArchetypeType.class)
.build();
}

String[] oids = getObjectDetailsModel().getObjectType().getRoleMembershipRef().stream()
.filter(r -> r.getOid() != null)
.map(r -> r.getOid())
.toArray(String[]::new);

return getPrismContext().queryFor(AbstractRoleType.class)
.id(oids)
.and().not().type(ArchetypeType.class)
.build();
}

@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PANEL_ROLE_MEMBERSHIP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public enum TableId {
PANEL_MAPPING_OVERRIDE_WIZARD,
PANEL_SYNCHRONIZATION_REACTION_WIZARD,
PANEL_CORRELATION_ITEMS_WIZARD,

PANEL_CORRELATION_ITEM_WIZARD,
PAGE_REQUEST_ACCESS_ROLE_CATALOG
PAGE_REQUEST_ACCESS_ROLE_CATALOG,
PANEL_INDUCT_BY,
PANEL_ROLE_MEMBERSHIP
}

private final Map<String, Integer> tables = new HashMap<>();
Expand Down

0 comments on commit a9255c6

Please sign in to comment.