<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><style>/*<![CDATA[*/p.MsoNormal, li.MsoNormal, div.MsoNormal {
margin: 0.0cm;
font-size: 11.0pt;
font-family: Calibri , sans-serif;
}
span.StileMessaggioDiPostaElettronica17 {
font-family: Calibri , sans-serif;
color: windowtext;
}
*.MsoChpDefault {
font-family: Calibri , sans-serif;
}
div.WordSection1 {
page: WordSection1;
}
/*]]>*/</style></div><div data-marker="__QUOTED_TEXT__"><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt;color:#000000"><div></div><div>Hello<br></div><br><div>Couple of points here:</div><ul><li>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.<br></li><li>The script code is "nearly Java", it's actually Groovy and the message "Cannot compare" is error from Groovy language/runtime.<br data-mce-bogus="1"></li><li>As for the problem, this answer may help: <a href="https://stackoverflow.com/a/1333733/658826">https://stackoverflow.com/a/1333733/658826</a><br data-mce-bogus="1"></li></ul><div>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).<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Regards<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Richard Richter<br data-mce-bogus="1"></div><div>midPoint developer<br data-mce-bogus="1"></div><br><hr id="zwchr"><div><b>From: </b>"midPoint General Discussion" <midpoint@lists.evolveum.com><br><b>To: </b>"midPoint General Discussion" <midpoint@lists.evolveum.com><br><b>Cc: </b>"Andrea Picconi" <andrea.picconi@innovery.net>, "Marianna De Biasio" <marianna.debiasio@innovery.net>, "Jacopo Giuliano" <jacopo.giuliano@innovery.net><br><b>Sent: </b>Tuesday, January 5, 2021 3:51:50 PM<br><b>Subject: </b>[midPoint] Problem with java script with dates<br></div><br><div>
<div class="WordSection1">
<p class="MsoNormal">Hi all,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span lang="EN-US">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.
</span></p>
<p class="MsoNormal"><span lang="EN-US">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:</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><i><span lang="EN-US"><script xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> <code></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> import java.text.SimpleDateFormat;</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> import java.text.DateFormat;</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> </span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> graceful = Date1;</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> if (Date2 != null) {<!-- --></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> if (graceful == null || Date2 > graceful) {<!-- --></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> graceful = Date2; }</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> }</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> else if (Date3 != null) {<!-- --></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> if (graceful == null || Date3 > graceful) {<!-- --></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> graceful = Date3; }</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> }</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> return df.format(com.evolveum.midpoint.util.MiscUtil.asDate(graceful));</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> </code></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"></script></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> </span></i></p>
<p class="MsoNormal"><span lang="EN-US">Below, instead, the error when we try with two or more fields populated:</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><img style="width:16.9687in;height:1.052in" id="Immagine_x0020_2" src="cid:image003.png@01D6E378.995CE130" width="1629" height="101"><span lang="EN-US"></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:'source sans pro' , sans-serif;color:#333333;background:whitesmoke" lang="EN-US">Any idea how to resolve it?</span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:'source sans pro' , sans-serif;color:#333333;background:whitesmoke" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:'source sans pro' , sans-serif;color:#333333;background:whitesmoke" lang="EN-US">Thank you and regards,</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><b><span style="font-size:10pt" lang="EN-US">Andrea Picconi</span></b></p>
<p class="MsoNormal"><i><span style="font-size:10pt">IAM (Identity Access Management)</span></i><span style="font-size:10pt"><br>
<br>
</span></p>
<p class="MsoNormal"><span lang="EN-US"><img style="width:1.4166in;height:0.3437in" id="Immagine_x0020_1" src="cid:image004.png@01D6E37A.979A37B0" alt="Innovery" width="136" height="33"></span><span style="font-size:10pt"><br>
Skype: precons</span><br>
<span style="font-size:10pt">T: +39 06 51963439 (int. 196) <br>
</span><span style="font-size:12pt"><br>
</span><span style="font-size:10pt;color:black">Strada Quattro Palazzina A6 c/o Centro Direzionale Milanofiori, 20057 Assago (MI).<br>
</span><span style="font-size:10pt"><a href="http://www.innovery.net/" rel="nofollow noopener noreferrer nofollow noopener noreferrer" target="_blank"><span style="color:#0563c1">www.innovery.net</span></a> | T: +39 06 519 63 439</span></p>
<p class="MsoNormal"> </p>
</div>
<br>_______________________________________________<br>midPoint mailing list<br>midPoint@lists.evolveum.com<br>https://lists.evolveum.com/mailman/listinfo/midpoint</div></div><br></div></div></body></html>