<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">Gustav,</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Thanks for that.  I’ll have a go at doing that later on today.  </div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">-Kev_C</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<br class="">
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 18 Oct 2022, at 02:40, Pálos Gustáv via midPoint <<a href="mailto:midpoint@lists.evolveum.com" class="">midpoint@lists.evolveum.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">
<table cellpadding="10" style="border:2px solid #d19000;border-collapse:collapse;width:100%;background-color: #ffb500;" class="">
<tbody class="">
<tr class="">
<th style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 8pt;background-color: #ffb500; color: #333f48" class="">
<span style="color: #ffb500;display:none;" class="">****************************************************************<br class="">
</span>Caution: This email originated from a sender outside Heriot-Watt University.
<br class="">
Do not follow links or open attachments if you doubt the authenticity of the sender or the content.
<span style="color: #ffb500;display:none;" class=""><br class="">
****************************************************************</span> </th>
</tr>
</tbody>
</table>
<br class="">
<div class="">
<div dir="ltr" class="">
<div class="">Hi Kevin,</div>
<div class=""><br class="">
</div>
<div class="">scripted-sql sample is here: <a href="https://github.com/Evolveum/midpoint-samples/tree/master/samples/resources/scriptedsql" class="">https://github.com/Evolveum/midpoint-samples/tree/master/samples/resources/scriptedsql</a></div>
<div class="">but if you have only one table with data from HR is easier to use build in database table connector:</div>
<div class=""><a href="https://docs.evolveum.com/connectors/resources/databasetable" class="">https://docs.evolveum.com/connectors/resources/databasetable</a><br class="">
</div>
<div class="">Filtering out old data can you do in at least 2 ways:</div>
<div class="">1) creating a DB view with where condition to filter out all old data what you never need in midPoint</div>
<div class="">2) just using resource synchronization/objectSynchronization/condition </div>
<div class="">something like this:</div>
<div class="">
<pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace;font-size:9.8pt" class=""><span style="color:rgb(232,191,106)" class=""><condition><br class=""></span><span style="color:rgb(232,191,106)" class="">    <script><br class=""></span><span style="color:rgb(232,191,106)" class="">        <code></span><![CDATA[<span style="background-color:rgb(54,65,53)" class=""><br class=""></span><span style="background-color:rgb(54,65,53)" class="">            import java.text.SimpleDateFormat;<br class=""></span><span style="background-color:rgb(54,65,53)" class=""><br class=""></span><span style="background-color:rgb(54,65,53)" class="">            String strFireDate = basic.getAttributeValue(shadow, '<a href="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" class="">http://midpoint.evolveum.com/xml/ns/public/resource/instance-3</a>', 'Firedate')<br class=""></span><span style="background-color:rgb(54,65,53)" class="">            if (!basic.isEmpty(strFireDate)) {<br class=""></span><span style="background-color:rgb(54,65,53)" class="">                SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd')<br class=""></span><span style="background-color:rgb(54,65,53)" class="">                Date dateNow = new Date()<br class=""></span><span style="background-color:rgb(54,65,53)" class="">                Date fireDate = sdf.parse(strFireDate)<br class=""></span><span style="background-color:rgb(54,65,53)" class=""><br class=""></span><span style="background-color:rgb(54,65,53)" class="">                if (fireDate < dateNow) {<br class=""></span><span style="background-color:rgb(54,65,53)" class="">                    return false // ignore<br class=""></span><span style="background-color:rgb(54,65,53)" class="">                }<br class=""></span><span style="background-color:rgb(54,65,53)" class="">            }<br class=""></span><span style="background-color:rgb(54,65,53)" class=""><br class=""></span><span style="background-color:rgb(54,65,53)" class="">            return true // import<br class=""></span><span style="background-color:rgb(54,65,53)" class=""><br class=""></span><span style="background-color:rgb(54,65,53)" class="">            </span>]]><span style="color:rgb(232,191,106)" class=""></code><br class=""></span><span style="color:rgb(232,191,106)" class="">    </script><br class=""></span><span style="color:rgb(232,191,106)" class=""></condition></span></pre>
</div>
<div class=""><br class="">
</div>
<div class="">about setting up read only resource you need to set existence to true in schemaHandling/objectType</div>
<div class="">
<pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace;font-size:9.8pt" class=""><span style="color:rgb(232,191,106)" class=""><activation><br class=""></span><span style="color:rgb(232,191,106)" class="">    <existence><br class=""></span><span style="color:rgb(232,191,106)" class="">        <outbound><br class=""></span><span style="color:rgb(232,191,106)" class="">            <name></span>HR don't support shadow delete, so never try to delete...<span style="color:rgb(232,191,106)" class=""></name><br class=""></span><span style="color:rgb(232,191,106)" class="">            <strength></span>weak<span style="color:rgb(232,191,106)" class=""></strength><br class=""></span><span style="color:rgb(232,191,106)" class="">            <expression><br class=""></span><span style="color:rgb(232,191,106)" class="">                <value></span>true<span style="color:rgb(232,191,106)" class=""></value><br class=""></span><span style="color:rgb(232,191,106)" class="">            </expression><br class=""></span><span style="color:rgb(232,191,106)" class="">        </outbound><br class=""></span><span style="color:rgb(232,191,106)" class="">    </existence><br class=""></span><span style="color:rgb(232,191,106)" class=""></activation><br class=""></span></pre>
</div>
<div class="">and also setting up configured capabilities:</div>
<div class="">
<pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace;font-size:9.8pt" class=""><span style="color:rgb(232,191,106)" class=""><capabilities><br class=""></span><span style="color:rgb(232,191,106)" class="">    <configured </span><span style="color:rgb(186,186,186)" class="">xmlns:</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(106,135,89)" class="">="<a href="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3" class="">http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3</a>"</span><span style="color:rgb(232,191,106)" class="">><br class=""></span><span style="color:rgb(232,191,106)" class="">        <</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:delete><br class=""></span><span style="color:rgb(232,191,106)" class="">            <</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:enabled></span>false<span style="color:rgb(232,191,106)" class=""></</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:enabled><br class=""></span><span style="color:rgb(232,191,106)" class="">        </</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:delete><br class=""></span><span style="color:rgb(232,191,106)" class="">        <</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:update><br class=""></span><span style="color:rgb(232,191,106)" class="">            <</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:enabled></span>false<span style="color:rgb(232,191,106)" class=""></</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:enabled><br class=""></span><span style="color:rgb(232,191,106)" class="">        </</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:update><br class=""></span><span style="color:rgb(232,191,106)" class="">        <</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:create><br class=""></span><span style="color:rgb(232,191,106)" class="">            <</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:enabled></span>false<span style="color:rgb(232,191,106)" class=""></</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:enabled><br class=""></span><span style="color:rgb(232,191,106)" class="">        </</span><span style="color:rgb(152,118,170)" class="">cap</span><span style="color:rgb(232,191,106)" class="">:create><br class=""></span><span style="color:rgb(232,191,106)" class="">    </configured><br class=""></span><span style="color:rgb(232,191,106)" class=""></capabilities></span></pre>
</div>
<div class="">+ also use DB user with read only permission only to required tables for security reasons at all.<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">If you need more help with PoC don't hesitate to contact us...</div>
<div class=""><br class="">
</div>
<div class="">Best regards,</div>
<div class=""><br class="">
</div>
<div class="">Gustav</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">po 17. 10. 2022 o 20:10 Collins, Kevin via midPoint <<a href="mailto:midpoint@lists.evolveum.com" class="">midpoint@lists.evolveum.com</a>> napísal(a):<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;" class="">Hi everyone,
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I’ve been working through the MidPoint book and the samples in midPoint 4.4.3 to try answer a couple of problems I’m having putting together a PoC midPoint demo:</div>
<div class=""><br class="">
</div>
<div class="">
<ul class="">
<li class="">How do I filter inbound data from a (Postgres) db table so that it doesn’t try to import stale data? Simplified use case is that an HR system writes data about staff to a Postgres db table.  That data is more or less authoritative for staff. The
 db table contains details about every member of staff who is current but also contains details of every staff person it has ever known about.  This sounds like an ideal job for a scripted-sql connector but I can’t get that to work at all in midPoint. So I’m
 looking at filtering on the inbound data. Unless, of course, anyone has good worked example of a scripted-sql resource that they’d be willing to share…</li><li class=""><br class="">
</li><li class="">How do I prevent the Idm from deleting the entire record from the Postgres db table when I delete it in the IDM ? </li></ul>
<div class=""><br class="">
</div>
<div class="">The HR people “own” the data in the table except for the username, emailAddress and initial password, which are generated by the Idm and passed back to the table.</div>
<div class=""><br class="">
</div>
<div class="">Thanks in advance.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">-Kev_C</div>
<div class="">
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">
<br class="">
</div>
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">
<br class="">
-- <br class="">
Kevin Collins,<br class="">
Senior Specialist,<br class="">
Information Services<br class="">
Heriot-Watt University,<br class="">
EDINBURGH, EH14 4AS,<br class="">
Scotland, UK<br class="">
<br class="">
For IT support queries or requests, please navigate to <a href="https://hwu.topdesk.net/" target="_blank" class="">
https://hwu.topdesk.net/</a>, <a href="mailto:ishelp@hw.ac.uk" target="_blank" class="">
email ishelp@hw.ac.uk</a> or phone ext 4045, with full details of your query or request and your contact details.<br class="">
<br class="">
<a href="http://www.hw.ac.uk/is" target="_blank" class="">http://www.hw.ac.uk/is</a><br class="">
</div>
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">
<br class="">
</div>
<br class="">
</div>
<br class="">
</div>
<u class=""></u>
<div align="center" class="">
<hr size="2" width="100%" align="center" class="">
</div>
<div style="font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 8pt; margin: 0px;" class="">
Founded in 1821, Heriot-Watt is a leader in ideas and solutions. With campuses and students across the entire globe we span the world, delivering innovation and educational excellence in business, engineering, design and the physical, social and life sciences.
 This email is generated from the Heriot-Watt University Group, which includes:</div>
<ol style="margin:0px" class="">
<li style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:8pt" class="">
Heriot-Watt University, a Scottish charity registered under number SC000278</li><li style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:8pt" class="">
Heriot- Watt Services Limited (Oriam), Scotland's national performance centre for sport. Heriot-Watt Services Limited is a private limited company registered is Scotland with registered number SC271030 and registered office at Research & Enterprise Services
 Heriot-Watt University, Riccarton, Edinburgh, EH14 4AS.</li></ol>
<div style="font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 8pt; margin: 0px;" class="">
The contents (including any attachments) are confidential. If you are not the intended recipient of this e-mail, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then
 delete it (including any attachments) from your system.</div>
</div>
_______________________________________________<br class="">
midPoint mailing list<br class="">
<a href="mailto:midPoint@lists.evolveum.com" target="_blank" class="">midPoint@lists.evolveum.com</a><br class="">
<a href="https://lists.evolveum.com/mailman/listinfo/midpoint" rel="noreferrer" target="_blank" class="">https://lists.evolveum.com/mailman/listinfo/midpoint</a><br class="">
</blockquote>
</div>
<br clear="all" class="">
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" class="gmail_signature">s pozdravom
<div class=""><br class="">
</div>
<div class="">Gustáv Pálos</div>
</div>
</div>
</div>
</div>
_______________________________________________<br class="">
midPoint mailing list<br class="">
<a href="mailto:midPoint@lists.evolveum.com" class="">midPoint@lists.evolveum.com</a><br class="">
https://lists.evolveum.com/mailman/listinfo/midpoint<br class="">
</div>
</blockquote>
</div>
<br class="">
<div class="">
<div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<br class="Apple-interchange-newline">
-- <br class="">
Kevin Collins,<br class="">
Senior Specialist,<br class="">
Information Services<br class="">
Heriot-Watt University,<br class="">
EDINBURGH, EH14 4AS,<br class="">
Scotland, UK<br class="">
<br class="">
For IT support queries or requests, please navigate to <a href="https://hwu.topdesk.net/" class="">
https://hwu.topdesk.net/</a>, <a href="mailto:ishelp@hw.ac.uk" class="">email ishelp@hw.ac.uk</a> or phone ext 4045, with full details of your query or request and your contact details.<br class="">
<br class="">
<a href="http://www.hw.ac.uk/is" class="">http://www.hw.ac.uk/is</a><br class="">
</div>
<div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<br class="">
</div>
<br class="Apple-interchange-newline">
</div>
<br class="">
</div>
</body>
</html>