Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jan 15, 2021
2 parents 01a58c9 + c67b3b2 commit a1498ed
Show file tree
Hide file tree
Showing 232 changed files with 8,316 additions and 4,184 deletions.
Expand Up @@ -277,7 +277,7 @@ public boolean isVisible() {
@Override
public void onClick(AjaxRequestTarget target) {
clearCache();
refreshTable((Class<O>) getType(), target);
refreshTable(target);

target.add((Component) getTable());
}
Expand Down
Expand Up @@ -6,9 +6,8 @@
*/
package com.evolveum.midpoint.gui.api.component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.*;
import java.util.function.Function;

import javax.xml.namespace.QName;

Expand All @@ -19,6 +18,8 @@
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.web.component.search.Search;
import com.evolveum.midpoint.web.component.search.SearchItem;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

import org.apache.wicket.Component;
Expand Down Expand Up @@ -209,11 +210,24 @@ protected ObjectQuery getCustomizeContentQuery() {
protected List<O> getPreselectedObjectList(){
return selectedObjectsList;
}

@Override
protected Search createSearch(Class<? extends O> type) {
Search search = super.createSearch(type);
getSpecialSearchItemFunctions().forEach(function -> {
search.addSpecialItem(function.apply(search));
});
return search;
}
};
listPanel.setOutputMarkupId(true);
return listPanel;
}

protected Set<Function<Search, SearchItem>> getSpecialSearchItemFunctions() {
return Collections.emptySet();
}

protected void addPerformed(AjaxRequestTarget target, QName type, List<O> selected) {
parentPage.hideMainPopup(target);
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
import com.evolveum.midpoint.gui.impl.component.ContainerableListPanel;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.util.DisplayableValue;
import com.evolveum.midpoint.web.component.data.ISelectableDataProvider;
import com.evolveum.midpoint.web.component.data.column.ObjectNameColumn;
import com.evolveum.midpoint.web.component.search.*;
Expand Down Expand Up @@ -54,16 +55,6 @@ public abstract class ObjectListPanel<O extends ObjectType> extends Containerabl
private static final String DOT_CLASS = ObjectListPanel.class.getName() + ".";
private static final String OPERATION_LOAD_CUSTOM_MENU_ITEMS = DOT_CLASS + "loadCustomMenuItems";

private ObjectTypes type;

public Class<O> getType() {
return (Class) type.getClassDefinition();
}

public void setType(Class<? extends O> type) {
this.type = type != null ? ObjectTypes.getObjectType(type) : null;
}

/**
* @param defaultType specifies type of the object that will be selected by default. It can be changed.
*/
Expand All @@ -76,7 +67,6 @@ public ObjectListPanel(String id, Class<? extends O> defaultType) {
*/
public ObjectListPanel(String id, Class<? extends O> defaultType, Collection<SelectorOptions<GetOperationOptions>> options) {
super(id, defaultType, options);
this.type = defaultType != null ? ObjectTypes.getObjectType(defaultType) : null;
}

protected String getSearchByNameParameterValue() {
Expand All @@ -92,9 +82,10 @@ protected String getSearchByNameParameterValue() {
return value.toString();
}

protected Search createSearch() {
return SearchFactory.createSearch(type.getClassDefinition(), isCollectionViewPanelForCompiledView() ? getCollectionNameParameterValue().toString() : null,
getFixedSearchItems(), null, getPageBase(), true);
@Override
protected Search createSearch(Class<? extends O> type) {
return SearchFactory.createSearch(new ContainerTypeSearchItem<O>(new SearchValue(type, "")), isCollectionViewPanelForCompiledView() ? getCollectionNameParameterValue().toString() : null,
getFixedSearchItems(), null, getPageBase(), null, true, true, Search.PanelType.DEFAULT);
}

protected List<ItemPath> getFixedSearchItems() {
Expand All @@ -106,7 +97,7 @@ protected List<ItemPath> getFixedSearchItems() {
protected ISelectableDataProvider createProvider() {
List<O> preSelectedObjectList = getPreselectedObjectList();
SelectableBeanObjectDataProvider<O> provider = new SelectableBeanObjectDataProvider<O>(
getPageBase(), (Class) type.getClassDefinition(), preSelectedObjectList == null ? null : new HashSet<>(preSelectedObjectList)) {
getPageBase(), getSearchModel(), preSelectedObjectList == null ? null : new HashSet<>(preSelectedObjectList)) {
private static final long serialVersionUID = 1L;

@Override
Expand Down Expand Up @@ -139,8 +130,8 @@ protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam
}

@Override
public ObjectQuery getQuery() {
return createQuery();
protected ObjectQuery getCustomizeContentQuery() {
return ObjectListPanel.this.getCustomizeContentQuery();
}
};
provider.setCompiledObjectCollectionView(getObjectCollectionView());
Expand Down Expand Up @@ -194,4 +185,11 @@ protected boolean isObjectDetailsEnabled(IModel<SelectableBean<O>> rowModel) {
}

protected void objectDetailsPerformed(AjaxRequestTarget target, O object){};

protected ContainerTypeSearchItem getTypeItem(Class<? extends O> type, List<DisplayableValue<Class<? extends O>>> allowedValues){
@NotNull ObjectTypes objectType = ObjectTypes.getObjectType(type);
return new ContainerTypeSearchItem<O>(new SearchValue(objectType.getClassDefinition(),
"ObjectType." + objectType.getTypeQName().getLocalPart()),
allowedValues);
}
}
Expand Up @@ -7,17 +7,21 @@
package com.evolveum.midpoint.gui.api.prism.wrapper;

import java.util.List;
import java.util.Set;
import java.util.function.Function;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.impl.prism.wrapper.PrismReferenceValueWrapperImpl;
import com.evolveum.midpoint.prism.PrismReference;
import com.evolveum.midpoint.prism.PrismReferenceDefinition;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.web.component.search.Search;
import com.evolveum.midpoint.web.component.search.SearchItem;
import com.evolveum.midpoint.web.component.search.SpecialSearchItem;

/**
* @author katka
*
*/
public interface PrismReferenceWrapper<R extends Referencable> extends ItemWrapper<PrismReference, PrismReferenceValueWrapperImpl<R>>, PrismReferenceDefinition {

Expand All @@ -26,6 +30,6 @@ public interface PrismReferenceWrapper<R extends Referencable> extends ItemWrapp

List<QName> getTargetTypes();



Set<Function<Search, SearchItem>> getSpecialSearchItemFunctions();
void setSpecialSearchItemFunctions(Set<Function<Search, SearchItem>> specialItems);
}
Expand Up @@ -753,6 +753,14 @@ private static ObjectReferenceType getArchetypeReference(AssignmentHolderType as
return archetypeRef;
}

private static String getArchetypeOid(AssignmentHolderType assignmentHolder) {
ObjectReferenceType archetypeRef = getArchetypeReference(assignmentHolder);
if (archetypeRef != null) {
return archetypeRef.getOid();
}
return null;
}

public static void iterativeExecuteBulkAction(PageBase pageBase, ExecuteScriptType script, Task task, OperationResult result)
throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException,
CommunicationException, ConfigurationException {
Expand Down Expand Up @@ -1994,7 +2002,7 @@ public static boolean isOfKind(QName relation, RelationKindType kind) {
return getRelationRegistry().isOfKind(relation, kind);
}

protected static RelationRegistry getRelationRegistry() {
public static RelationRegistry getRelationRegistry() {
if (staticallyProvidedRelationRegistry != null) {
return staticallyProvidedRelationRegistry;
} else {
Expand Down Expand Up @@ -2261,9 +2269,8 @@ public static String createObjectColletionIcon() {
return getObjectNormalIconStyle(GuiStyleConstants.CLASS_OBJECT_COLLECTION_ICON);
}

public static ObjectFilter evaluateExpressionsInFilter(ObjectFilter objectFilter, OperationResult result, PageBase pageBase) {
public static ObjectFilter evaluateExpressionsInFilter(ObjectFilter objectFilter, ExpressionVariables variables, OperationResult result, PageBase pageBase) {
try {
ExpressionVariables variables = new ExpressionVariables();
return ExpressionUtil.evaluateFilterExpressions(objectFilter, variables, MiscSchemaUtil.getExpressionProfile(),
pageBase.getExpressionFactory(), pageBase.getPrismContext(), "collection filter",
pageBase.createSimpleTask(result.getOperation()), result);
Expand All @@ -2275,6 +2282,11 @@ public static ObjectFilter evaluateExpressionsInFilter(ObjectFilter objectFilter
return objectFilter;
}

public static ObjectFilter evaluateExpressionsInFilter(ObjectFilter objectFilter, OperationResult result, PageBase pageBase) {
ExpressionVariables variables = new ExpressionVariables();
return evaluateExpressionsInFilter(objectFilter, variables, result, pageBase);
}

public static String createReportIcon() {
return getObjectNormalIconStyle(GuiStyleConstants.CLASS_REPORT_ICON);
}
Expand Down Expand Up @@ -3047,9 +3059,8 @@ public static void refreshResourceSchema(@NotNull PrismObject<ResourceType> reso
target.add(pageBase.getFeedbackPanel());
}

public static List<QName> getCategoryRelationChoices(AreaCategoryType category, ModelServiceLocator pageBase) {
public static List<QName> getCategoryRelationChoices(AreaCategoryType category, List<RelationDefinitionType> defList) {
List<QName> relationsList = new ArrayList<>();
List<RelationDefinitionType> defList = getRelationDefinitions(pageBase);
defList.sort(new Comparator<RelationDefinitionType>() {
@Override
public int compare(RelationDefinitionType rD1, RelationDefinitionType rD2) {
Expand Down Expand Up @@ -3081,6 +3092,10 @@ public int compare(RelationDefinitionType rD1, RelationDefinitionType rD2) {
return relationsList;
}

public static List<QName> getCategoryRelationChoices(AreaCategoryType category, ModelServiceLocator pageBase) {
return getCategoryRelationChoices(category, getRelationDefinitions(pageBase));
}

private static RelationKindType getHighestRelationKind(List<RelationKindType> kinds) {
RelationKindType ret = null;
for (RelationKindType kind : kinds){
Expand Down Expand Up @@ -3377,7 +3392,10 @@ public void bind(Component component) {
super.bind(component);

component.add(AttributeModifier.replace("onkeydown",
Model.of("if(event.keyCode == 13) {$('[about=\"" + submitButtonAboutAttribute + "\"]').click();}")));
Model.of("if(event.keyCode == 13) {"
+ "event.die();"
+ "$('[about=\"" + submitButtonAboutAttribute + "\"]').click();"
+ "}")));
}
};
}
Expand Down Expand Up @@ -4737,6 +4755,10 @@ public static Class<? extends PageBase> resolveSelfPage() {

public static <I extends Item> PrismObject<LookupTableType> findLookupTable(ItemDefinition<I> definition, PageBase page) {
PrismReferenceValue valueEnumerationRef = definition.getValueEnumerationRef();
return findLookupTable(valueEnumerationRef, page);
}

public static <I extends Item> PrismObject<LookupTableType> findLookupTable(PrismReferenceValue valueEnumerationRef, PageBase page) {
if (valueEnumerationRef == null) {
return null;
}
Expand Down Expand Up @@ -4836,4 +4858,20 @@ public static CompositedIcon createCreateReportIcon() {
builder.appendLayerIcon(plusIcon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
return builder.build();
}

public static CompiledObjectCollectionView getCollectionViewByObject(AssignmentHolderType assignmentHolder, PageBase pageBase) {
String archetypeOid = getArchetypeOid(assignmentHolder);
if (!StringUtils.isEmpty(archetypeOid)) {
List<CompiledObjectCollectionView> collectionViews =
pageBase.getCompiledGuiProfile().getObjectCollectionViews();
for (CompiledObjectCollectionView view : collectionViews) {
if (view.getCollection() != null && view.getCollection().getCollectionRef() != null
&& archetypeOid.equals(view.getCollection().getCollectionRef().getOid())) {
return view;
}
}
}
QName type = classToQName(pageBase.getPrismContext(), assignmentHolder.getClass());
return pageBase.getCompiledGuiProfile().findObjectCollectionView(type, null);
}
}
Expand Up @@ -6,6 +6,8 @@
*/
package com.evolveum.midpoint.gui.impl.component;

import com.evolveum.midpoint.gui.impl.component.icon.LayerIcon;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.markup.html.AjaxLink;
Expand Down Expand Up @@ -79,16 +81,16 @@ public void onComponentTagBody(final MarkupStream markupStream, final ComponentT
}

if (icon.hasLayerIcons()) {
for (IconType entry : icon.getLayerIcons()) {
for (LayerIcon entry : icon.getLayerIcons()) {
if (entry == null) {
continue;
}
if (StringUtils.isNotEmpty(entry.getCssClass())) {
sb.append("<i class=\"").append(entry.getCssClass()).append("\"");
if (StringUtils.isNotEmpty(entry.getColor())) {
sb.append(" style=\"color: ").append(entry.getColor()).append(";\"");
if (StringUtils.isNotEmpty(entry.getIconType().getCssClass())) {
sb.append("<i class=\"").append(entry.getIconType().getCssClass()).append("\"");
if (StringUtils.isNotEmpty(entry.getIconType().getColor())) {
sb.append(" style=\"color: ").append(entry.getIconType().getColor()).append(";\"");
}
sb.append("></i> ");
sb.append(">").append(entry.hasLabel() ? entry.getLabelModel().getObject() : "").append("</i> ");
}
}
}
Expand Down

0 comments on commit a1498ed

Please sign in to comment.