Skip to content

Commit

Permalink
filter config panel fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Sep 7, 2020
1 parent c427baf commit 079c52f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
Expand Up @@ -1375,6 +1375,20 @@ public static <C extends Containerable> String getDisplayName(PrismContainerValu
return StringEscapeUtils.escapeHtml4(displayName);
}

public static String getItemDefinitionDisplayNameOrName(ItemDefinition def, Component component) {
if (def == null) {
return null;
}

if (def.getDisplayName() != null) {
StringResourceModel nameModel = PageBase.createStringResourceStatic(component, def.getDisplayName());
if (StringUtils.isNotEmpty(nameModel.getString()) && !def.getDisplayName().equals(nameModel.getString())) {
return nameModel.getString();
}
}
return def.getItemName().getLocalPart();
}

private static String getAcquisitionDescription(ProvenanceAcquisitionType acquisitionType) {
if (acquisitionType == null) {
return null;
Expand Down
Expand Up @@ -8,6 +8,8 @@

import java.io.Serializable;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.wicket.model.StringResourceModel;
Expand Down Expand Up @@ -37,7 +39,7 @@ public ItemDefinition getDefinition() {
}

public String getName() {
return getItemDefinitionName(definition);
return WebComponentUtil.getItemDefinitionDisplayNameOrName(definition, null);
}

public boolean isSelected() {
Expand Down Expand Up @@ -69,8 +71,8 @@ public int hashCode() {

@Override
public int compareTo(Property o) {
String n1 = getItemDefinitionName(definition);
String n2 = getItemDefinitionName(o.definition);
String n1 = WebComponentUtil.getItemDefinitionDisplayNameOrName(definition, null);
String n2 = WebComponentUtil.getItemDefinitionDisplayNameOrName(o.definition, null);

if (n1 == null || n2 == null) {
return 0;
Expand All @@ -79,23 +81,6 @@ public int compareTo(Property o) {
return String.CASE_INSENSITIVE_ORDER.compare(n1, n2);
}

private String getItemDefinitionName(ItemDefinition def) {
if (def == null) {
return null;
}

if (def.getDisplayName() != null) {
StringResourceModel nameModel = PageBase.createStringResourceStatic(null, def.getDisplayName());
if (StringUtils.isNotEmpty(nameModel.getString())) {
return nameModel.getString();
}
}
String name = def.getDisplayName(); // TODO this is always null here, isn't it?
if (StringUtils.isEmpty(name)) {
name = def.getItemName().getLocalPart();
}
return name;
}

@Override
public String toString() {
Expand Down
Expand Up @@ -13,6 +13,8 @@
import java.util.List;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;

import org.apache.commons.collections4.CollectionUtils;

import com.evolveum.midpoint.prism.*;
Expand Down Expand Up @@ -117,16 +119,19 @@ public QName getMatchingRuleName() {
public ValueSearchFilterItem(ValueFilter filter, boolean applyNegation) {
this.filter = filter;
this.applyNegation = applyNegation;
propertyName = filter.getElementName().toString();
propertyPath = filter.getElementName();
propertyDef = filter.getDefinition();
propertyName = WebComponentUtil.getItemDefinitionDisplayNameOrName(propertyDef, null);
value = CollectionUtils.isNotEmpty(filter.getValues()) ? filter.getValues().get(0) : null;
if (propertyDef instanceof PrismReferenceDefinition && value == null) {
value = new ObjectReferenceType();
}
this.expression = filter.getExpression();
parseFilterName();
}

public ValueSearchFilterItem(Property property, boolean applyNegation) {
propertyName = property.getDefinition().getItemName().toString();
propertyName = property.getName();
propertyPath = property.getDefinition().getItemName();
propertyDef = property.getDefinition();
this.applyNegation = applyNegation;
Expand Down Expand Up @@ -267,6 +272,8 @@ private void parseFilterName() {
}
}



public List<FilterName> getAvailableFilterNameList() {
if (propertyDef == null) {
return Arrays.asList(FilterName.values());
Expand Down

0 comments on commit 079c52f

Please sign in to comment.