[midPoint] Problem with java script with dates
Richard Richter
virgo at evolveum.com
Wed Jan 6 02:00:03 CET 2021
Hello
Couple of points here:
* If possible, errors as copy/pasted text are better than images, it is easier to copy/paste from it for us too when Googling error messages.
* The script code is "nearly Java", it's actually Groovy and the message "Cannot compare" is error from Groovy language/runtime.
* As for the problem, this answer may help: [ https://stackoverflow.com/a/1333733/658826 | https://stackoverflow.com/a/1333733/658826 ]
The issue is that XMLGregorianCalendar really is not comparable, so it can't be used with > operator (which is Groovy extension, Java would not allow this between two objects).
Regards
Richard Richter
midPoint developer
From: "midPoint General Discussion" <midpoint at lists.evolveum.com>
To: "midPoint General Discussion" <midpoint at lists.evolveum.com>
Cc: "Andrea Picconi" <andrea.picconi at innovery.net>, "Marianna De Biasio" <marianna.debiasio at innovery.net>, "Jacopo Giuliano" <jacopo.giuliano at innovery.net>
Sent: Tuesday, January 5, 2021 3:51:50 PM
Subject: [midPoint] Problem with java script with dates
Hi all,
we have a problem with an operation that should lead to outbound on an Oracle DB the furthest date in time between three dates that we have as values on MIDPOINT.
First example below just works if only one of the three (dates) attribute field is populated, when we have two fields populated it gives us an error:
<script xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3">
<code>
import java.text.SimpleDateFormat;
import java.text.DateFormat;
graceful = Date1;
if (Date2 != null) {
if (graceful == null || Date2 > graceful) {
graceful = Date2; }
}
else if (Date3 != null) {
if (graceful == null || Date3 > graceful) {
graceful = Date3; }
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
return df.format(com.evolveum.midpoint.util.MiscUtil.asDate(graceful));
</code>
</script>
Below, instead, the error when we try with two or more fields populated:
Any idea how to resolve it?
Thank you and regards,
Andrea Picconi
IAM (Identity Access Management)
Skype: precons
T: +39 06 51963439 (int. 196)
Strada Quattro Palazzina A6 c/o Centro Direzionale Milanofiori, 20057 Assago (MI).
[ http://www.innovery.net/ | www.innovery.net ] | T: +39 06 519 63 439
_______________________________________________
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/20210106/2f19b576/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 47210 bytes
Desc: image003.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20210106/2f19b576/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 8058 bytes
Desc: image004.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20210106/2f19b576/attachment-0003.png>
More information about the midPoint
mailing list