Skip to content

Commit

Permalink
MID-4525 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Apr 17, 2018
1 parent b30b119 commit 5205d64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Expand Up @@ -234,7 +234,7 @@ protected void executeCustomAction(AjaxRequestTarget target, ShadowType object)

@Override
protected void executeCustomRemoveAction(AjaxRequestTarget target) {
ExpressionUtil.createShadowRefEvaluatorValue(ExpressionValuePanel.this.getModelObject(), null, pageBase.getPrismContext());
ExpressionUtil.removeEvaluatorByName(ExpressionValuePanel.this.getModelObject(), SchemaConstantsGenerated.C_VALUE);
}

@Override
Expand Down
@@ -1,9 +1,6 @@
package com.evolveum.midpoint.web.component.prism;

import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.repo.common.expression.Expression;
import com.evolveum.midpoint.util.exception.SchemaException;
Expand Down Expand Up @@ -53,19 +50,21 @@ public void setConstruction(ConstructionType construction) {
public boolean hasChanged() {
for (ValueWrapper valueWrapper : values) {
ExpressionType expression = (ExpressionType) ((PrismPropertyValue) valueWrapper.getValue()).getValue();
ExpressionType oldExpressionValue = (ExpressionType)((PrismPropertyValue)valueWrapper.getOldValue()).getValue();
try {
switch (valueWrapper.getStatus()) {
case DELETED:
return true;
case ADDED:
case NOT_CHANGED:
if (valueWrapper.hasValueChanged()) {
return true;
} else if (ExpressionUtil.isEmpty(expression)) {
return false;
} else if (!ExpressionUtil.isAssociationTargetSearchNotEmpty(expression) && !ExpressionUtil.isLiteralExpressionValueNotEmpty(expression)
&& !ExpressionUtil.isShadowRefNotEmpty(expression)) {
if (ExpressionUtil.areAllExpressionValuesEmpty(oldExpressionValue) && ExpressionUtil.areAllExpressionValuesEmpty(expression)) {
return false;
} else if (!ExpressionUtil.areAllExpressionValuesEmpty(oldExpressionValue) && ExpressionUtil.areAllExpressionValuesEmpty(expression)) {
return true;
} else if (ExpressionUtil.areAllExpressionValuesEmpty(oldExpressionValue) && !ExpressionUtil.areAllExpressionValuesEmpty(expression)) {
return true;
} else if (valueWrapper.hasValueChanged()) {
return true;
}
}
} catch (SchemaException e) {
Expand Down
Expand Up @@ -270,6 +270,10 @@ public static boolean isLiteralExpressionValueNotEmpty(ExpressionType expression
return values != null && values.size() > 0;
}

public static boolean areAllExpressionValuesEmpty(ExpressionType expression) throws SchemaException{
return !isShadowRefNotEmpty(expression) && !isLiteralExpressionValueNotEmpty(expression) && !isAssociationTargetSearchNotEmpty(expression);
}

public static void parseExpressionEvaluators(String xml, ExpressionType expressionObject, PrismContext context) throws SchemaException {
expressionObject.getExpressionEvaluator().clear();
if (StringUtils.isNotBlank(xml)) {
Expand Down

0 comments on commit 5205d64

Please sign in to comment.