Comparing object identity using XPath in Java

0
I've got a Java action in which I hold an IMendixIdentifier and I want to compare objects with this using XPath, retrieving objects which are associated with it, like this. IMendixIdentifier id = someJobFile.getObject().getId(); String target = [some function of id] List list = Core.retrieveXPathQueryEscaped(getContext(), "//PipsAndSubbies.JobTaskMapping [PipsAndSubbies.JobTaskMapping_Job/PipsAndSubbies.Job/PipsAndSubbies.Job_JobFile/PipsAndSubbies.JobFile/id = %s and [some other constraints]" , target); Question: how to I get the target string to pass into Core.retrieveXPathQueryEscaped and substitute for %s, given the IMendixIdentifier, to match an object's id field?
asked
1 answers
4

You can use id.getGuid(). This method returns a variable of type long. You can also use someJobFile.getGUID(). This method returns a variable of type String and is direct suitable to use as target.

It is possible to optimize your query a little bit. Look at this query:

//PipsAndSubbies.JobTaskMapping
[PipsAndSubbies.JobTaskMappingJob/PipsAndSubbies.Job/PipsAndSubbies.JobJobFile = %s]

When you use the constraint 'association = some_guid', it works the same like 'association/object/id = %s'.

answered