[midPoint] Midpoint Query API

Richard Richter virgo at evolveum.com
Thu Nov 11 14:03:01 CET 2021


Hi 

I was confused from "whenCreated" attribute so I rather didn't answer, however, if indeed metadata/createTimestamp (or modifyTimestamp) are meant, then sure, these are indexed in DB and available for query against repository. 
However, these are timestamps and <equal> with date is virtually sure to return nothing (not sure about all DBs, but conceptually it should not). 
For example, to find users created on 2021-11-11, use this instead: 

<query> 
<filter> 
<and> 
<greaterOrEqual> 
<path>metadata/createTimestamp</path> 
<value>2021-11-11</value> 
</greaterOrEqual> 
<less> 
<path>metadata/createTimestamp</path> 
<value>2021-11-12</value> 
</less> 
</and> 
</filter> 
</query> 

This results in proper HQL query: 
select 
u.oid, 
u.fullObject 
from 
RUser u 
where 
( 
u.createTimestamp >= :createTimestamp and 
u.createTimestamp < :createTimestamp2 
) 

Parameters are expanded to complete timestamps at midnight (also, the timezone can be an issue, depending on the TZ of your DB too): 
createTimestamp2 = 2021-11-12T00:00:00.000Z 
createTimestamp = 2021-11-11T00:00:00.000Z 

It is always preferable to use >= and < combination for timestamps in queries. 

This can be tested in Query playground, the one-but-last main menu item, just above About. More info about Query API here: [ https://docs.evolveum.com/midpoint/reference/concepts/query/query-api/ | https://docs.evolveum.com/midpoint/reference/concepts/query/query-api/ ] 

Cheers 

Richard Richter 
Evolveum SW Developer 

From: "midPoint General Discussion" <midpoint at lists.evolveum.com> 
To: "midPoint General Discussion" <midpoint at lists.evolveum.com> 
Cc: "Paulo Fernandes de Souza Junior" <PFSJ at senado.leg.br> 
Sent: Thursday, November 11, 2021 12:50:14 PM 
Subject: Re: [midPoint] Midpoint Query API 



You can use: 





<query> 


<filter> 


<equal> 


<path>metadata/createTimestamp</path> 


<value>2021-07-20</value> 


</equal> 


</filter> 


</query> 





Or <path>metadata/modifyTimestamp</path> 





[]s, 





Paulo Fernandes de Souza Júnior 
NQPPPS 
Senado Federal - PRODASEN 
Fone: 61 3303.3924 





De: midPoint <midpoint-bounces at lists.evolveum.com> em nome de Jérôme ROGER via midPoint <midpoint at lists.evolveum.com> 
Enviado: quarta-feira, 10 de novembro de 2021 12:41 
Para: midpoint at lists.evolveum.com 
Cc: Jérôme ROGER 
Assunto: [midPoint] Midpoint Query API 


hello, 



I am running midpoint 4.0.2 and for a new Hr software, I need to query the midpoint database to get all users by querying the attributes whenCreated and WhenChanged. I've tried with query Api with no success. I'd like to know if those attributes are requestable or if a better solution exists. 


Thank you for your help. 



Best regards, 



Jerome 

_______________________________________________ 
midPoint mailing list 
midPoint at lists.evolveum.com 
https://lists.evolveum.com/mailman/listinfo/midpoint 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20211111/7079ccd5/attachment.htm>


More information about the midPoint mailing list