-
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.
object collection view list search item (draft)
- Loading branch information
Kateryna Honchar
committed
May 4, 2022
1 parent
2a59ba6
commit 65c21b7
Showing
4 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
.../com/evolveum/midpoint/gui/impl/component/search/ObjectCollectionListSearchItemPanel.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,28 @@ | ||
/* | ||
* 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.component.search; | ||
|
||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
|
||
import org.apache.wicket.Component; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.model.Model; | ||
import org.apache.wicket.model.PropertyModel; | ||
|
||
public class ObjectCollectionListSearchItemPanel extends AbstractSearchItemPanel<ObjectCollectionListSearchItemWrapper> { | ||
|
||
public ObjectCollectionListSearchItemPanel(String id, IModel<ObjectCollectionListSearchItemWrapper> searchItemModel) { | ||
super(id, searchItemModel); | ||
} | ||
|
||
@Override | ||
protected Component initSearchItemField() { | ||
return WebComponentUtil.createDropDownChoices( | ||
ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), "value"), | ||
Model.ofList(getModelObject().getViewNameList()), true, getPageBase()); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
...om/evolveum/midpoint/gui/impl/component/search/ObjectCollectionListSearchItemWrapper.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,94 @@ | ||
/* | ||
* 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.component.search; | ||
|
||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; | ||
import com.evolveum.midpoint.prism.Containerable; | ||
import com.evolveum.midpoint.prism.query.ObjectFilter; | ||
import com.evolveum.midpoint.schema.expression.VariablesMap; | ||
import com.evolveum.midpoint.util.DisplayableValue; | ||
import com.evolveum.midpoint.util.logging.Trace; | ||
import com.evolveum.midpoint.util.logging.TraceManager; | ||
import com.evolveum.midpoint.web.component.search.SearchValue; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public class ObjectCollectionListSearchItemWrapper<C extends Containerable> extends AbstractSearchItemWrapper<String> { | ||
|
||
private static final Trace LOGGER = TraceManager.getTrace(ObjectCollectionSearchItemWrapper.class); | ||
private Class<C> type; | ||
Map<String, CompiledObjectCollectionView> collectionViewLightMap = new HashMap<>(); | ||
|
||
public ObjectCollectionListSearchItemWrapper(@NotNull Class<C> type, List<CompiledObjectCollectionView> collectionViews) { | ||
this.type = type; | ||
initCollectionViews(collectionViews); | ||
} | ||
|
||
private void initCollectionViews(List<CompiledObjectCollectionView> collectionViews) { | ||
if (collectionViews == null) { | ||
return; | ||
} | ||
collectionViews.forEach(view -> { | ||
CompiledObjectCollectionView lightView = new CompiledObjectCollectionView(); | ||
lightView.setFilter(view.getFilter()); | ||
lightView.setViewIdentifier(view.getViewIdentifier()); | ||
collectionViewLightMap.put(getObjectCollectionViewLabel(view), lightView); | ||
}); | ||
} | ||
|
||
private String getObjectCollectionViewLabel (CompiledObjectCollectionView view) { | ||
return view.getDisplay() != null && view.getDisplay().getLabel() != null ? | ||
WebComponentUtil.getTranslatedPolyString(view.getDisplay().getLabel()) : view.getViewIdentifier(); | ||
} | ||
|
||
public List<DisplayableValue<String>> getViewNameList() { | ||
return collectionViewLightMap.keySet().stream().map(name -> new SearchValue<>(name)).collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
public Class<ObjectCollectionListSearchItemPanel> getSearchItemPanelClass() { | ||
return ObjectCollectionListSearchItemPanel.class; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ObjectTypeGuiDescriptor.objectCollection"; | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getHelp() { | ||
return null; | ||
} | ||
|
||
|
||
@Override | ||
public ObjectFilter createFilter(Class type, PageBase pageBase, VariablesMap variables) { | ||
String value = (String) getValue().getValue(); | ||
if (value == null) { | ||
return null; | ||
} | ||
return collectionViewLightMap.get(value).getFilter(); | ||
} | ||
|
||
@Override | ||
public DisplayableValue<String> getDefaultValue() { | ||
return new SearchValue<>(); | ||
} | ||
|
||
} |
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