Skip to content

Commit

Permalink
Resource Wizard bugFix - Synchronization Editor - fix for correlation…
Browse files Browse the repository at this point in the history
… filterClause serialization and deserialization
  • Loading branch information
Erik Suta committed Oct 2, 2014
1 parent fefc840 commit 47bc4e6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
Expand Up @@ -42,7 +42,7 @@
</dt>
<dd>
<!--TODO - enable this button when problem with SearchFilterType and RootXNode serialization is fixed-->
<a wicket:id="update" class="btn btn-success disabled">
<a wicket:id="update" class="btn btn-success">
<span><wicket:message key="SearchFilterPanel.button.update" /></span>
</a>
</dd>
Expand Down
Expand Up @@ -56,13 +56,12 @@ public SearchFilterTypeDto(SearchFilterType filter, PrismContext prismContext){
}

private String loadFilterClause(PrismContext prismContext){
MapXNode clause = filterObject.getFilterClauseXNode();
String fClause;

try {
//TODO - fix the problem with RootElement
RootXNode rootClause = new RootXNode(new QName("fixMe"), clause);
fClause = prismContext.serializeXNodeToString(rootClause, PrismContext.LANG_XML);
RootXNode clause = filterObject.getFilterClauseAsRootXNode();

fClause = prismContext.serializeXNodeToString(clause, PrismContext.LANG_XML);
} catch (SchemaException e){
LoggingUtils.logException(LOGGER, "Could not load filterClause from SearchFilterType object.", e);

Expand All @@ -84,11 +83,9 @@ public void updateFilterClause(PrismContext context) throws SchemaException{
LOGGER.trace("Filter Clause to serialize: " + filterClause);
}

XNode filterClauseNode = context.parseToXNode(filterClause, PrismContext.LANG_XML);
RootXNode filterClauseNode = (RootXNode) context.parseToXNode(filterClause, PrismContext.LANG_XML);

MapXNode newClause = new MapXNode();
newClause.setParent(filterClauseNode);
filterObject.setFilterClauseXNode(newClause);
filterObject.setFilterClauseXNode(filterClauseNode);
}
}

Expand Down
Expand Up @@ -46,6 +46,7 @@
import com.evolveum.midpoint.prism.util.PrismUtil;
import com.evolveum.midpoint.prism.xnode.MapXNode;
import com.evolveum.midpoint.prism.xnode.PrimitiveXNode;
import com.evolveum.midpoint.prism.xnode.RootXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.DebugDumpable;
Expand Down Expand Up @@ -126,6 +127,15 @@ public void setFilterClauseXNode(MapXNode filterClauseXNode) {
this.filterClauseXNode = filterClauseXNode;
}

public void setFilterClauseXNode(RootXNode filterClauseNode) {
if (filterClauseNode == null) {
this.filterClauseXNode = null;
} else {
this.filterClauseXNode = new MapXNode();
this.filterClauseXNode.put(filterClauseNode.getRootElementName(), filterClauseNode.getSubnode());
}
}

@Deprecated // use the version without prismContext instead
public MapXNode getFilterClauseXNode(PrismContext prismContext) throws SchemaException {
return getFilterClauseXNode();
Expand All @@ -139,6 +149,20 @@ public MapXNode getFilterClauseXNode() {
}
}

public RootXNode getFilterClauseAsRootXNode() throws SchemaException {
MapXNode clause = getFilterClauseXNode();
if (clause == null) {
return null;
}

Entry<QName, XNode> singleEntry = clause.getSingleSubEntry("getFilterClauseAsRootXNode");
if (singleEntry == null) {
return null;
}

return new RootXNode(singleEntry.getKey(), singleEntry.getValue());
}

public Element getFilterClauseAsElement() throws SchemaException {
if (filterClauseXNode == null) {
return null;
Expand Down Expand Up @@ -672,4 +696,5 @@ public String debugDump(int indent) {
}
return sb.toString();
}

}

0 comments on commit 47bc4e6

Please sign in to comment.