Alex Thieme
2012-11-20 23:27:47 UTC
Here's the best I could come up with. Create a property and then write a groovy expression against that property. This did not work if I used #[json:relationshipName] in the choice expression. And, I think no whitespace within the expression is significant.
<splitter expression="#[json:childRelationships]"/>
<message-properties-transformer scope="outbound">
<add-message-property key="relationshipName" value="#[json:relationshipName]"/>
</message-properties-transformer>
<choice>
<when expression="#[groovy:message.getOutboundProperty('relationshipName')!='null']">
<logger level="ERROR" message="creating relationship = #[message.payload]"/>
</when>
<otherwise>
<logger level="ERROR" message="skipping relationship = #[message.payload]"/>
</otherwise>
</choice>
<splitter expression="#[json:childRelationships]"/>
<message-properties-transformer scope="outbound">
<add-message-property key="relationshipName" value="#[json:relationshipName]"/>
</message-properties-transformer>
<choice>
<when expression="#[groovy:message.getOutboundProperty('relationshipName')!='null']">
<logger level="ERROR" message="creating relationship = #[message.payload]"/>
</when>
<otherwise>
<logger level="ERROR" message="skipping relationship = #[message.payload]"/>
</otherwise>
</choice>
I am attempting a null check on an attribute in a json map. I feel as if I've tried all possible expression variations using, json, json-node, groovy, groovy + json, groovy + json-node, null in single quotes, null without single quotes. Clearly something is wrong with my expression. The log shows a null relationshipName, but the "skipping relationship" condition is never met.
<flow name="service.salesforce.graph.node.children.neo4j">
...
<splitter expression="#[json:childRelationships]"/>
<choice>
<when expression="#[json-node:relationshipName != null]">
<logger level="ERROR" message="creating relationship = #[message.payload]"/>
</when>
<otherwise>
<logger level="ERROR" message="skipping relationship = #[message.payload]"/>
</otherwise>
</choice>
</flow>
And yet, the log clearly shows relationshipName is evaluating to NOT NULL when in fact the values is null.
[11-20 14:50:08] ERROR LoggerMessageProcessor: creating relationship = {"parent":"Parent","relationshipName":null,"child":"Child"}
<flow name="service.salesforce.graph.node.children.neo4j">
...
<splitter expression="#[json:childRelationships]"/>
<choice>
<when expression="#[json-node:relationshipName != null]">
<logger level="ERROR" message="creating relationship = #[message.payload]"/>
</when>
<otherwise>
<logger level="ERROR" message="skipping relationship = #[message.payload]"/>
</otherwise>
</choice>
</flow>
And yet, the log clearly shows relationshipName is evaluating to NOT NULL when in fact the values is null.
[11-20 14:50:08] ERROR LoggerMessageProcessor: creating relationship = {"parent":"Parent","relationshipName":null,"child":"Child"}