Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 10, 2022
2 parents b018174 + 9cd5d26 commit 36213aa
Show file tree
Hide file tree
Showing 24 changed files with 1,724 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="popover-inner">
<div>
<ul class="list-group" wicket:id="validationParentItems">
<li class="list-group-item" wicket:id="validationItems" style="display: flex;">
<li class="list-group-item" wicket:id="validationItems" style="display: flex; border: none !important;">
<div wicket:id="validationItem"></div>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ public static TaskType createIterativeChangeExecutionTask(String taskName, QName
task.setActivity(
new ActivityDefinitionType(PrismContext.get())
.beginWork()
.iterativeChangeExecution(workDef)
.iterativeChangeExecution(workDef)
.end());
// @formatter:on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ private SideBarMenuItem createSelfServiceMenu(boolean experimentalFeaturesEnable
WebComponentUtil.resolveSelfPage(), pageParameters));
menu.addMainMenuItem(createMainMenuItem("PageAdmin.menu.credentials", GuiStyleConstants.CLASS_ICON_CREDENTIALS,
PageSelfCredentials.class));
/** menu item which leads to new self Credentials page
menu.addMainMenuItem(createMainMenuItem("PageAdmin.menu.credentials", GuiStyleConstants.CLASS_ICON_CREDENTIALS,
com.evolveum.midpoint.gui.impl.page.self.credentials.PageSelfCredentials.class));
*/
if (WebModelServiceUtils.getLoggedInFocus() instanceof UserType) {
menu.addMainMenuItem(createMainMenuItem("PageAdmin.menu.request", GuiStyleConstants.CLASS_ICON_REQUEST,
PageAssignmentShoppingCart.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
Expand Down Expand Up @@ -47,6 +48,7 @@
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -78,9 +80,11 @@ public class SaveSearchPanel<C extends Containerable> extends BasePanel<Search<C
private Class<C> type;
IModel<String> feedbackMessageModel = Model.of();
IModel<String> queryNameModel = Model.of();
public SaveSearchPanel(String id, IModel<Search<C>> searchModel, Class<C> type) {
private String defaultCollectionViewIdentifier = null;
public SaveSearchPanel(String id, IModel<Search<C>> searchModel, Class<C> type, String defaultCollectionViewIdentifier) {
super(id, searchModel);
this.type = type;
this.defaultCollectionViewIdentifier = defaultCollectionViewIdentifier;
}

@Override
Expand Down Expand Up @@ -116,7 +120,7 @@ public void onClick(AjaxRequestTarget ajaxRequestTarget) {
ajaxRequestTarget.add(feedbackMessage);
return;
}
saveCustomQuery();
saveCustomQuery(ajaxRequestTarget);
getPageBase().hideMainPopup(ajaxRequestTarget);
}
};
Expand All @@ -133,30 +137,33 @@ public void onClick(AjaxRequestTarget ajaxRequestTarget) {
buttonsPanel.add(cancelButton);
}

private void saveCustomQuery() {
private void saveCustomQuery(AjaxRequestTarget ajaxRequestTarget) {
Search<C> search = getModelObject();
AvailableFilterType availableFilter = new AvailableFilterType();
availableFilter.setDisplay(new DisplayType().label(queryNameModel.getObject()));
availableFilter.setSearchMode(getModelObject().getSearchMode());
SearchItemType searchItem = null;
if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchMode())) {
availableFilter.getSearchItem().addAll(getAvailableFilterSearchItems(type, search.getItems(), search.getSearchMode()));
} else if (SearchBoxModeType.AXIOM_QUERY.equals(getModelObject().getSearchMode())) {
SearchItemType axiomSearchItem = createAxiomSearchItem();
if (axiomSearchItem != null) {
availableFilter.getSearchItem().add(axiomSearchItem);
} else {
if (SearchBoxModeType.AXIOM_QUERY.equals(getModelObject().getSearchMode())) {
searchItem = createAxiomSearchItem();
} else if (SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchMode())) {
searchItem = createAdvancedSearchItem();
} else if (SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchMode())) {
searchItem = createFulltextSearchItem();
} else if (SearchBoxModeType.OID.equals(getModelObject().getSearchMode())) {
searchItem = createOidSearchItem(getModelObject().findOidSearchItemWrapper());
}
} else if (SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchMode())) {
SearchItemType fulltextSearchItem = createFulltextSearchItem();
if (fulltextSearchItem != null) {
availableFilter.getSearchItem().add(fulltextSearchItem);
}
} else if (SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchMode())) {
SearchItemType oidtSearchItem = createOidSearchItem(getModelObject().findOidSearchItemWrapper());
if (oidtSearchItem != null) {
availableFilter.getSearchItem().add(oidtSearchItem);
if (searchItem != null) {
availableFilter.getSearchItem().add(searchItem);
}
}
saveSearchItemToAdminConfig(availableFilter);
if (CollectionUtils.isEmpty(availableFilter.getSearchItem())) {
ajaxRequestTarget.add(getPageBase().getFeedbackPanel());
return;
}
saveSearchItemToAdminConfig(availableFilter, ajaxRequestTarget);
}

private List<SearchItemType> getAvailableFilterSearchItems(Class<C> typeClass, List<AbstractSearchItemWrapper> items, SearchBoxModeType mode) {
Expand Down Expand Up @@ -195,6 +202,22 @@ private SearchItemType createAxiomSearchItem() {
return axiomSearchItem;
} catch (SchemaException e) {
LOGGER.error("Unable to parse axiom filter from query: {}, {}", getModelObject().getDslQuery(), e.getLocalizedMessage());
getPageBase().error("Unable to parse axiom filter from query: " + getModelObject().getDslQuery());
}
return null;
}

private SearchItemType createAdvancedSearchItem() {
try {
SearchItemType advancedSearchItem = new SearchItemType();

SearchFilterType search = PrismContext.get().parserFor(getModelObject().getAdvancedQuery()).type(SearchFilterType.COMPLEX_TYPE).parseRealValue();
ObjectFilter advancedFilter = PrismContext.get().getQueryConverter().parseFilter(search, getModelObject().getTypeClass());
advancedSearchItem.setFilter(PrismContext.get().getQueryConverter().createSearchFilterType(advancedFilter));
return advancedSearchItem;
} catch (Exception e) {
LOGGER.error("Unable to parse advanced filter from query: ", getModelObject().getAdvancedQuery(), e.getLocalizedMessage());
getPageBase().error("Unable to parse advanced filter from query: " + getModelObject().getAdvancedQuery());
}
return null;
}
Expand All @@ -209,6 +232,7 @@ private SearchItemType createFulltextSearchItem() {
return fulltextSearchItem;
} catch (SchemaException e) {
LOGGER.error("Unable to create fulltext filter from query: {}, {}", getModelObject().getFullText(), e.getLocalizedMessage());
getPageBase().error("Unable to parse fulltext filter from query: " + getModelObject().getFullText());
}
return null;
}
Expand All @@ -220,53 +244,116 @@ private SearchItemType createOidSearchItem(OidSearchItemWrapper oidSearchItemWra
oidSearchItem.setFilter(PrismContext.get().getQueryConverter().createSearchFilterType(filter));
return oidSearchItem;
} catch (SchemaException e) {
LOGGER.error("Unable to create oid filter from query: {}, {}", getModelObject().getFullText(), e.getLocalizedMessage());
LOGGER.error("Unable to parse oid filter from query: {}, {}", oidSearchItemWrapper.getValue().getValue(), e.getLocalizedMessage());
getPageBase().error("Unable to parse oid filter from query: " + oidSearchItemWrapper.getValue().getValue());
}
return null;
}

private void saveSearchItemToAdminConfig(AvailableFilterType availableFilter) {
private void saveSearchItemToAdminConfig(AvailableFilterType availableFilter, AjaxRequestTarget ajaxRequestTarget) {
FocusType principalFocus = getPageBase().getPrincipalFocus();
boolean newObjectListView = WebComponentUtil.getPrincipalUserObjectListView(getPageBase(), principalFocus, type, false) == null;
GuiObjectListViewType view = WebComponentUtil.getPrincipalUserObjectListView(getPageBase(), principalFocus, type, true);
if (view == null) {
view = new GuiObjectListViewType();
view.setType(WebComponentUtil.containerClassToQName(PrismContext.get(), type));
//view.setIdentifier(); //todo set collection view identifier
((UserType)principalFocus).getAdminGuiConfiguration().getObjectCollectionViews().objectCollectionView(view);
boolean viewExists = true;
boolean addItemToPath = true;
List<ItemName> path = new ArrayList<>();
Object valueToAdd = null;
if (!(principalFocus instanceof UserType)) {
return;
}
AdminGuiConfigurationType adminGui = ((UserType) principalFocus).getAdminGuiConfiguration();
if (adminGui == null) {
viewExists = false;
adminGui = new AdminGuiConfigurationType();
valueToAdd = adminGui;
addItemToPath = false;
}
path.add(UserType.F_ADMIN_GUI_CONFIGURATION);

GuiObjectListViewsType views = adminGui.getObjectCollectionViews();
if (addItemToPath) {
path.add(AdminGuiConfigurationType.F_OBJECT_COLLECTION_VIEWS);
}
if (views == null) {
viewExists = false;
views = new GuiObjectListViewsType();
if (valueToAdd != null) {
adminGui.objectCollectionViews(views);
} else {
valueToAdd = views;
}
addItemToPath = false;
}

StringValue collectionViewParameter = WebComponentUtil.getCollectionNameParameterValue(getPageBase());
String viewName = collectionViewParameter == null || collectionViewParameter.isNull() ? defaultCollectionViewIdentifier
: collectionViewParameter.toString();
GuiObjectListViewType objectListView = null;
for (GuiObjectListViewType listView : views.getObjectCollectionView()) {
if (viewName.equals(listView.getIdentifier())) {
objectListView = listView;
}
}
if (addItemToPath) {
path.add(GuiObjectListViewsType.F_OBJECT_COLLECTION_VIEW);
}
if (objectListView == null) {
viewExists = false;
objectListView = new GuiObjectListViewType();
objectListView.setType(WebComponentUtil.containerClassToQName(PrismContext.get(), type));
if (valueToAdd != null) {
views.getObjectCollectionView().add(objectListView);
} else {
valueToAdd = objectListView;
}
addItemToPath = false;
}
if (objectListView.getIdentifier() == null) {
StringValue viewIdentifier = WebComponentUtil.getCollectionNameParameterValue(getPageBase());
objectListView.setIdentifier(viewIdentifier == null || viewIdentifier.isNull() || viewIdentifier.isNull() ?
defaultCollectionViewIdentifier : viewIdentifier.toString());
}
SearchBoxConfigurationType searchConfig = objectListView.getSearchBoxConfiguration();
if (addItemToPath) {
path.add(GuiObjectListViewType.F_SEARCH_BOX_CONFIGURATION);
path.add(SearchBoxConfigurationType.F_AVAILABLE_FILTER);
}
SearchBoxConfigurationType searchConfig = view.getSearchBoxConfiguration();
if (searchConfig == null) {
searchConfig = new SearchBoxConfigurationType();
view.searchBoxConfiguration(searchConfig);
if (valueToAdd != null) {
objectListView.setSearchBoxConfiguration(searchConfig);
} else {
valueToAdd = availableFilter;
}
}
if (searchConfig.getAvailableFilter() == null) {
searchConfig.beginAvailableFilter();
}

OperationResult result = new OperationResult("save search to user");
try {
Object[] path;
ObjectDelta<UserType> userDelta = null;
if (newObjectListView) {
if (!viewExists) {
searchConfig.getAvailableFilter().add(availableFilter);
path = new Object[]{UserType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_OBJECT_COLLECTION_VIEWS,
GuiObjectListViewsType.F_OBJECT_COLLECTION_VIEW};
userDelta = getPrismContext().deltaFor(UserType.class)
.item(path)
.add(view).asObjectDelta(principalFocus.getOid());
.item(path.toArray(ItemName[]::new))
.add(valueToAdd).asObjectDelta(principalFocus.getOid());
} else {
path = new Object[]{UserType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_OBJECT_COLLECTION_VIEWS,
GuiObjectListViewsType.F_OBJECT_COLLECTION_VIEW, view.getId(), GuiObjectListViewType.F_SEARCH_BOX_CONFIGURATION,
Object[] viewPath = new Object[]{UserType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_OBJECT_COLLECTION_VIEWS,
GuiObjectListViewsType.F_OBJECT_COLLECTION_VIEW, objectListView.getId(), GuiObjectListViewType.F_SEARCH_BOX_CONFIGURATION,
SearchBoxConfigurationType.F_AVAILABLE_FILTER};
userDelta = getPrismContext().deltaFor(UserType.class)
.item(path)
.item(viewPath)
.add(availableFilter).asObjectDelta(principalFocus.getOid());
}
WebModelServiceUtils.save(userDelta, result, getPageBase().createSimpleTask("task"), getPageBase());
} catch (Exception e) {
LOGGER.error("Unable to save a filter to user, ", e.getLocalizedMessage());
error("Unable to save a filter to user, " + e.getLocalizedMessage());
ajaxRequestTarget.add(getPageBase().getFeedbackPanel());
return;
}
result.recomputeStatus();
getPageBase().showResult(result);
ajaxRequestTarget.add(getPageBase().getFeedbackPanel());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ public boolean isVisible() {
public void onClick(AjaxRequestTarget target) {
SaveSearchPanel<C> panel = new SaveSearchPanel<>(getPageBase().getMainPopupBodyId(),
Model.of(SearchPanel.this.getModelObject()),
SearchPanel.this.getModelObject().getTypeClass());
SearchPanel.this.getModelObject().getTypeClass(),
getCollectionInstanceDefaultIdentifier());
getPageBase().showMainPopup(panel, target);
}
};
Expand Down Expand Up @@ -318,6 +319,11 @@ private boolean isCollectionInstancePage() {
return getPageBase().getClass().getAnnotation(CollectionInstance.class) != null;
}

private String getCollectionInstanceDefaultIdentifier() {
CollectionInstance collectionInstance = getPageBase().getClass().getAnnotation(CollectionInstance.class);
return collectionInstance != null ? collectionInstance.identifier() : null;
}

private boolean isPopupWindow() {
Component parent = SearchPanel.this.getParent();
while (parent != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
package com.evolveum.midpoint.gui.impl.page.admin.resource.component;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.impl.page.self.requestAccess.Tile;
import com.evolveum.midpoint.gui.impl.page.self.requestAccess.TilePanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

import org.apache.wicket.ajax.AjaxEventBehavior;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

package com.evolveum.midpoint.gui.impl.page.admin.resource.component;

import com.evolveum.midpoint.gui.impl.page.self.requestAccess.Tile;

import javax.annotation.Nullable;
import com.evolveum.midpoint.gui.impl.component.tile.Tile;

/**
* @author lskublik
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--
~ Copyright (c) 2022 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="d-flex flex-wrap gap-2">
<div class="col-md-5">
<label class="col-form-label">
<wicket:message key="ChangePasswordPanel.currentPassword"/>
</label>
<div class="">
<div class="password-parent" style="height:30px; position: relative;">
<div class="col-md-12" style="padding: 0px !important;">
<input class="form-control form-control-sm" type="password" autocomplete="new-password" wicket:id="currentPassword" autofocus style="padding-right: 26px;"/>
</div>
<div style="position: absolute; right: 8px; top: 8px; z-index: 5;">
<i class="fa fa-eye" style="float:right;cursor: pointer; color: #555555;" onclick="MidPointTheme.showPassword(this)"></i>
</div>
</div>
</div>
<label class="col-form-label" wicket:id="passwordLabel"/>
<div class="">
<div class="password-panel" wicket:id="passwordPanel"/>
</div>
</div>
<div class="col-md-5">
<label class="col-form-label card-header" style="border: none !important;">
<wicket:message key="ChangePasswordPanel.passwordRequirementsLabel"/>
</label>
<div wicket:id="passwordValidationPanel"/>
</div>
</div>
<wicket:child/>

<div class="main-button-bar">
<a class="btn btn-success" wicket:id="changePassword"/>
</div>
</wicket:panel>
</html>

0 comments on commit 36213aa

Please sign in to comment.