Skip to content

Commit

Permalink
expression panel little improvements + preview expression value
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Dec 11, 2017
1 parent 2e28040 commit a5b6417
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 13 deletions.
Expand Up @@ -20,7 +20,7 @@
<div class=btn-group>
<div wicket:id="addExpressionValueButton" />
</div>
<div wicket:id="shadowRefValueContainer" class="row">
<div wicket:id="shadowRefValueContainer">
<div class="row">
<h4 class="col-md-4 box-title"><wicket:message key="ExpressionValuePanel.shadowRefValueTitle"/></h4>
<a wicket:id="deleteShadowRefValueButton" class="btn btn-sm btn-danger pull-right" title="Remove">
Expand All @@ -30,7 +30,7 @@ <h4 class="col-md-4 box-title"><wicket:message key="ExpressionValuePanel.shadowR
<div wicket:id="shadowRefValueInput"/>

</div>
<div wicket:id="literalValueContainer" class="row">
<div wicket:id="literalValueContainer">
<div class="row">
<h4 class="col-md-4 box-title"><wicket:message key="ExpressionValuePanel.literalValueTitle"/></h4>
<a wicket:id="deleteLiteralValueButton" class="btn btn-sm btn-danger pull-right" title="Remove">
Expand All @@ -41,7 +41,7 @@ <h4 class="col-md-4 box-title"><wicket:message key="ExpressionValuePanel.literal

</div>

<div wicket:id="associationTargetSearchContainer" class="row">
<div wicket:id="associationTargetSearchContainer">
<div class="row">
<h4 class="col-md-4 box-title"><wicket:message key="ExpressionValuePanel.associationTargetSearchTitle" /></h4>
<a wicket:id="deleteTargetSearchExpressionButton" class="btn btn-sm btn-danger pull-right" title="Remove">
Expand Down
Expand Up @@ -294,7 +294,13 @@ protected void onUpdate(AjaxRequestTarget target){
if (getModelObject() == null){
getModel().setObject(new ExpressionType());
}
ExpressionUtil.updateAssociationTargetSearchPath(getModelObject(), new ItemPathType(pathValue));
try {
ExpressionUtil.updateAssociationTargetSearchPath(getModelObject(), new ItemPathType(pathValue));
} catch (Exception ex){
getPageBase().getFeedbackPanel().getFeedbackMessages().add(new FeedbackMessage(ExpressionValuePanel.this,
ex.getLocalizedMessage(), 0));
target.add(getPageBase().getFeedbackPanel());
}
}
});
targetSearchContainer.add(targetSearchFilterPathInput);
Expand Down
Expand Up @@ -22,7 +22,7 @@
<button wicket:id="showEmptyFields" wicket:message="title:PrismObjectPanel.showEmpty" class="btn btn-box-tool" trigger="hover" about="showEmptyFields"><i class="fa fa-arrows-alt"></i></button>
<button wicket:id="addChildContainer" wicket:message="title:PrismObjectPanel.addChildContainer" class="btn btn-box-tool" trigger="hover"><i class="fa fa-plus-circle"></i></button>
<button wicket:id="removeContainer" wicket:message="title:PrismObjectPanel.deleteContainer" class="btn btn-box-tool" trigger="hover"><i class="fa fa-minus-circle"></i></button>
<div class="pull-right" wicket:id="childContainersSelectorPanel">
<div class="col-md-2 pull-right" wicket:id="childContainersSelectorPanel">
<div class="col-xs-8" wicket:id="childContainersList" />
<div class="col-xs-2 btn btn-xs btn-success" wicket:id="addButton" />
</div>
Expand Down
Expand Up @@ -156,7 +156,7 @@ private void choosePerformed(AjaxRequestTarget target, T object){
LOGGER.trace("Choose operation performed: {} ({})", o.getName(), o.getOid());
}

target.add(get(ID_OBJECT_NAME));
target.add(get(ID_INPUT_CONTAINER).get(ID_OBJECT_NAME));
executeCustomAction(target, object);
}

Expand Down
Expand Up @@ -310,7 +310,13 @@ public String getDesc() {

@Override
public String toString() {
return "XNode(map:"+subnodes.size()+" entries)";
StringBuilder sb = new StringBuilder("XNode(map:"+subnodes.size()+" entries)");
sb.append("\n");
subnodes.forEach(entry -> {
sb.append(entry.toString());
sb.append("; \n");
});
return sb.toString();
}

private Entry findEntry(QName qname) {
Expand Down
Expand Up @@ -22,18 +22,15 @@
import com.evolveum.midpoint.prism.xnode.PrimitiveXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LoginEventType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ScheduleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import com.evolveum.prism.xml.ns._public.types_3.RawType;
import org.springframework.expression.common.ExpressionUtils;

import javax.xml.bind.JAXBElement;
import javax.xml.datatype.XMLGregorianCalendar;
Expand Down Expand Up @@ -142,6 +139,32 @@ public static String toStringValue(PrismPropertyValue propertyValue) {
return "(binary data)";
} else if (value instanceof RawType) {
return PrettyPrinter.prettyPrint(value);
} else if (value instanceof ExpressionType) {
StringBuilder expressionString = new StringBuilder();
if (((ExpressionType)value).getExpressionEvaluator() != null && ((ExpressionType) value).getExpressionEvaluator().size() > 0){
((ExpressionType) value).getExpressionEvaluator().forEach(evaluator -> {
if (evaluator.getValue() instanceof RawType){
expressionString.append(PrettyPrinter.prettyPrint(evaluator.getValue()));
expressionString.append("; ");
} else if (evaluator.getValue() instanceof SearchObjectExpressionEvaluatorType){
SearchObjectExpressionEvaluatorType evaluatorValue = (SearchObjectExpressionEvaluatorType)evaluator.getValue();
if (evaluatorValue.getFilter() != null) {
DebugUtil.debugDumpMapMultiLine(expressionString, evaluatorValue.getFilter().getFilterClauseXNode(),
0, false, null);
// expressionString.append(evaluatorValue.getFilter().getFilterClauseXNode().debugDump(0));
// expressionString.append("; ");
while (expressionString.indexOf("}") >= 0 && expressionString.indexOf("{") >= 0 &&
expressionString.indexOf("}") - expressionString.indexOf("{") > 0){
expressionString.replace(expressionString.indexOf("{"), expressionString.indexOf("}") + 1, "");
}
}
} else {
expressionString.append("(a value of type " + value.getClass().getSimpleName() + ")");

}
});
}
return expressionString.toString();
} else {
return "(a value of type " + value.getClass().getSimpleName() + ")"; // todo i18n
}
Expand Down

0 comments on commit a5b6417

Please sign in to comment.