Skip to content

Commit

Permalink
still working on cleaner code for search, fixed bugs in gui profile c…
Browse files Browse the repository at this point in the history
…ompiler, different fixes for saved searches, etc.
  • Loading branch information
katkav committed Dec 15, 2022
1 parent 7c91b80 commit cede993
Show file tree
Hide file tree
Showing 38 changed files with 350 additions and 577 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ protected Set<SearchItemType> getSpecialItems() {
// return searchConfigWrapper;
// }

// protected Set<SerializableSupplier<AbstractSearchItemWrapper>> getSpecialSearchItemWrappers() {
// protected Set<SerializableSupplier<FilterableSearchItemWrapper>> getSpecialSearchItemWrappers() {
// return Collections.emptySet();
// }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public interface PrismReferenceWrapper<R extends Referencable> extends ItemWrapp

List<QName> getTargetTypes();

// Set<SerializableSupplier<AbstractSearchItemWrapper>> getSpecialSearchItemFunctions();
// void setSpecialSearchItemFunctions(Set<SerializableSupplier<AbstractSearchItemWrapper>> specialItems);
// Set<SerializableSupplier<FilterableSearchItemWrapper>> getSpecialSearchItemFunctions();
// void setSpecialSearchItemFunctions(Set<SerializableSupplier<FilterableSearchItemWrapper>> specialItems);

Set<SearchItemType> getPredefinedSearchItem();
void setPredefinedSearchItem(Set<SearchItemType> searchItems);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import java.util.stream.Collectors;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.impl.component.search.wrapper.FilterableSearchItemWrapper;
import com.evolveum.midpoint.gui.impl.component.search.wrapper.SearchConfigurationWrapper;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.web.component.*;

import com.evolveum.midpoint.gui.impl.component.search.wrapper.AbstractSearchItemWrapper;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType;

Expand Down Expand Up @@ -81,7 +81,7 @@ private SearchConfigurationWrapper<C> createSearchConfigWrapper(Class<C> type) {
// searchConfigWrapper.setCollectionRefOid(collectionView.getCollection().getCollectionRef().getOid());
// }
PrismContainerDefinition<C> containerDefinition = getTypeDefinitionForSearch();
List<AbstractSearchItemWrapper> items = (List<AbstractSearchItemWrapper>) initSearchableItemWrappers(containerDefinition);
List<FilterableSearchItemWrapper> items = (List<FilterableSearchItemWrapper>) initSearchableItemWrappers(containerDefinition);
if (items != null) {
searchConfigWrapper.getItemsList().addAll(items);
}
Expand All @@ -98,7 +98,7 @@ protected PrismContainerDefinition<C> getTypeDefinitionForSearch() {
return getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(getType());
}

protected List<? super AbstractSearchItemWrapper> initSearchableItemWrappers(PrismContainerDefinition<C> containerDef){
protected List<? super FilterableSearchItemWrapper> initSearchableItemWrappers(PrismContainerDefinition<C> containerDef){
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.component.search.wrapper.AbstractRoleSearchItemWrapper;
import com.evolveum.midpoint.gui.impl.component.search.wrapper.AbstractSearchItemWrapper;
import com.evolveum.midpoint.gui.impl.component.search.wrapper.FilterableSearchItemWrapper;
import com.evolveum.midpoint.gui.impl.component.search.panel.Popover;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.util.SelectableRow;
Expand Down Expand Up @@ -43,7 +43,7 @@
* Popupable panel with listed items which can be searched and selected
* The component can be used as More button popup or saved searches popup on search panel
*/
public abstract class SelectableItemListPopoverPanel<T extends AbstractSearchItemWrapper> extends BasePanel<List<T>> {
public abstract class SelectableItemListPopoverPanel<T extends FilterableSearchItemWrapper> extends BasePanel<List<T>> {

private static final long serialVersionUID = 1L;
private static final String ID_POPOVER = "popover";
Expand Down Expand Up @@ -115,7 +115,7 @@ protected void onUpdate(AjaxRequestTarget target) {
@Override
protected void populateItem(final ListItem<T> item) {
CheckBox check = new CheckBox(ID_ITEM_CHECKBOX,
new PropertyModel<>(item.getModel(), AbstractSearchItemWrapper.F_SELECTED));
new PropertyModel<>(item.getModel(), FilterableSearchItemWrapper.F_SELECTED));
check.add(new AjaxFormComponentUpdatingBehavior("change") {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public SearchConfigurationWrapper getSearchConfigurationWrapper() {
return searchConfigurationWrapper;
}

public List<AbstractSearchItemWrapper> getItems() {
public List<FilterableSearchItemWrapper> getItems() {
return searchConfigurationWrapper.getItemsList();
}

Expand Down Expand Up @@ -315,8 +315,8 @@ private ObjectQuery createObjectQueryOid(PageBase pageBase) {
}

public OidSearchItemWrapper findOidSearchItemWrapper() {
List<AbstractSearchItemWrapper> items = searchConfigurationWrapper.getItemsList();
for (AbstractSearchItemWrapper item : items) {
List<FilterableSearchItemWrapper> items = searchConfigurationWrapper.getItemsList();
for (FilterableSearchItemWrapper item : items) {
if (item instanceof OidSearchItemWrapper) {
return (OidSearchItemWrapper) item;
}
Expand All @@ -325,8 +325,8 @@ public OidSearchItemWrapper findOidSearchItemWrapper() {
}

public ObjectCollectionSearchItemWrapper findObjectCollectionSearchItemWrapper() {
List<AbstractSearchItemWrapper> items = searchConfigurationWrapper.getItemsList();
for (AbstractSearchItemWrapper item : items) {
List<FilterableSearchItemWrapper> items = searchConfigurationWrapper.getItemsList();
for (FilterableSearchItemWrapper item : items) {
if (item instanceof ObjectCollectionSearchItemWrapper) {
return (ObjectCollectionSearchItemWrapper) item;
}
Expand All @@ -335,8 +335,8 @@ public ObjectCollectionSearchItemWrapper findObjectCollectionSearchItemWrapper()
}

public ObjectTypeSearchItemWrapper findObjectTypeSearchItemWrapper() {
List<AbstractSearchItemWrapper> items = searchConfigurationWrapper.getItemsList();
for (AbstractSearchItemWrapper item : items) {
List<FilterableSearchItemWrapper> items = searchConfigurationWrapper.getItemsList();
for (FilterableSearchItemWrapper item : items) {
if (item instanceof ObjectTypeSearchItemWrapper) {
return (ObjectTypeSearchItemWrapper) item;
}
Expand Down Expand Up @@ -400,7 +400,7 @@ private ObjectQuery mergeQueries(ObjectQuery origQuery, ObjectQuery query) {
}

private ObjectQuery createObjectQuerySimple(VariablesMap defaultVariables, PageBase pageBase) {
List<AbstractSearchItemWrapper> searchItems = getItems();
List<FilterableSearchItemWrapper> searchItems = getItems();
if (searchItems.isEmpty()) {
return null;
}
Expand All @@ -425,31 +425,37 @@ public List<ObjectFilter> getSearchItemFilterList(PageBase pageBase, VariablesMa
if (!SearchBoxModeType.BASIC.equals(getSearchMode())) {
return conditions;
}
boolean abstractRoleFilterCheck = false;
for (AbstractSearchItemWrapper item : getItems()) {
if (hasParameter(item) ||
!item.isApplyFilter(getSearchMode()) ||
(item instanceof AbstractRoleSearchItemWrapper && abstractRoleFilterCheck)) {
continue;
}
// boolean abstractRoleFilterCheck = false;
for (FilterableSearchItemWrapper item : getItems()) {

ObjectFilter filter = item.createFilter(getTypeClass(), pageBase, defaultVariables);
if (filter != null) {
conditions.add(filter);
}
if (item instanceof AbstractRoleSearchItemWrapper) {
abstractRoleFilterCheck = true;
}

// if (//hasParameter(item) ||
// !item.isApplyFilter(getSearchMode()) ||
// (item instanceof AbstractRoleSearchItemWrapper && abstractRoleFilterCheck)) {
// continue;
// }
// ObjectFilter filter = item.createFilter(getTypeClass(), pageBase, defaultVariables);
// if (filter != null) {
// conditions.add(filter);
// }
// if (item instanceof AbstractRoleSearchItemWrapper) {
// abstractRoleFilterCheck = true;
// }
}
return conditions;
}

private boolean hasParameter(AbstractSearchItemWrapper<?> searchItemWrapper) {
return StringUtils.isNotEmpty(searchItemWrapper.getParameterName());
}
// private boolean hasParameter(FilterableSearchItemWrapper<?> searchItemWrapper) {
// return StringUtils.isNotEmpty(searchItemWrapper.getParameterName());
// }

public VariablesMap getFilterVariables(VariablesMap defaultVariables, PageBase pageBase) {
VariablesMap variables = defaultVariables == null ? new VariablesMap() : defaultVariables;
List<AbstractSearchItemWrapper> items = getItems();
List<FilterableSearchItemWrapper> items = getItems();
items.forEach(item -> {
if (StringUtils.isNotEmpty(item.getParameterName())) {
Object parameterValue = item.getValue() != null ? item.getValue().getValue() : null;
Expand All @@ -475,8 +481,8 @@ public void setFullText(String fullText) {
fulltextQueryWrapper.setFullText(fullText);
}

public boolean allPropertyItemsPresent(List<AbstractSearchItemWrapper> items) {
for (AbstractSearchItemWrapper item : items) {
public boolean allPropertyItemsPresent(List<FilterableSearchItemWrapper> items) {
for (FilterableSearchItemWrapper item : items) {
if (item instanceof PropertySearchItemWrapper && ((PropertySearchItemWrapper)item).getPath() != null &&
findPropertySearchItem(((PropertySearchItemWrapper<?>) item).getPath()) == null) {
return false;
Expand All @@ -486,7 +492,7 @@ public boolean allPropertyItemsPresent(List<AbstractSearchItemWrapper> items) {
}

public PropertySearchItemWrapper findPropertyItemByPath(ItemPath path) {
for (AbstractSearchItemWrapper searchItemWrapper : getItems()) {
for (FilterableSearchItemWrapper searchItemWrapper : getItems()) {
if (!(searchItemWrapper instanceof PropertySearchItemWrapper)) {
continue;
}
Expand All @@ -503,7 +509,7 @@ public boolean isTypeChanged() {
}

public ObjectTypeSearchItemWrapper getObjectTypeSearchItemWrapper() {
for (AbstractSearchItemWrapper item : getItems()) {
for (FilterableSearchItemWrapper item : getItems()) {
if (item instanceof ObjectTypeSearchItemWrapper) {
return (ObjectTypeSearchItemWrapper) item;
}
Expand All @@ -515,7 +521,7 @@ public PropertySearchItemWrapper findPropertySearchItem(ItemPath path) {
if (path == null) {
return null;
}
for (AbstractSearchItemWrapper searchItem : getItems()) {
for (FilterableSearchItemWrapper searchItem : getItems()) {
if (!(searchItem instanceof PropertySearchItemWrapper)) {
continue;
}
Expand All @@ -536,8 +542,8 @@ public String debugDump(int indent) {
DebugUtil.debugDumpWithLabelLn(sb, "advancedError", advancedError, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "type", getTypeClass(), indent + 1);
DebugUtil.dumpObjectSizeEstimate(sb, "itemsList", searchConfigurationWrapper, indent + 2);
List<AbstractSearchItemWrapper> items = searchConfigurationWrapper.getItemsList();
for (AbstractSearchItemWrapper item : items) {
List<FilterableSearchItemWrapper> items = searchConfigurationWrapper.getItemsList();
for (FilterableSearchItemWrapper item : items) {
DebugUtil.dumpObjectSizeEstimate(sb, "item " + item.getName(), item, indent + 2);
}

Expand Down

0 comments on commit cede993

Please sign in to comment.