[midPoint] scriptedsql example
Wojciech Staszewski
wojciech.staszewski at diagnostyka.pl
Fri Aug 3 09:14:56 CEST 2018
Hello!
You have to add all used attributes to the search query.
You have:
sql.eachRow("SELECT name,timestamp,id,notes,birthdate,netid FROM person " + where, {result.add([__UID__:it.id, __NAME__:it.netid, ])} );
Should be:
sql.eachRow("SELECT name,timestamp,id,notes,birthdate,netid FROM person " + where, {result.add([__UID__:it.id, __NAME__:it.netid, notes:it.notes, birthdate:it.birthdate])} );
Also, if your "netid" attribute in Schema script = "__NAME__" attribute and "id" = "__UID__", you don't have to declare it in Schema script explicitly,
so it should look like this:
account.setType(ObjectClass.ACCOUNT_NAME);
account.addAttributeInfo(AttributeInfoBuilder.build("name", String.class));
account.addAttributeInfo(AttributeInfoBuilder.build("notes", String.class));
account.addAttributeInfo(AttributeInfoBuilder.build("birthdate", String.class));
account.addAttributeInfo(OperationalAttributeInfos.ENABLE);
because __NAME__ and __UID__ are always declared by default.
Regards!
WS
W dniu 03.08.2018 o 02:59, Frigerio, Joshua pisze:
> I’m not having any luck with the documents, so I’ll beg for help here. :-)
>
> I’m trying to get the most simple example of a scriptedsql connection to work, simply as proof a of concept at this point, but I can’t seem to make it happen … could someone tell me what blindingly obvious thing I have overlooked this time?
>
> I took the samples and changed them minimally. It successfully gets a user list from the table I’m querying. The table it’s querying is very simple, this is everything in it:
>
> +------------+---------------------+---------------------+-----------------+----+-------+
> | name | timestamp | birthdate | notes | id | netid |
> +------------+---------------------+---------------------+-----------------+----+-------+
> | joe schmoe | 2018-06-05 13:08:08 | 2001-12-12 00:00:00 | new notes here | 2 | joe |
> | fred jones | 2018-07-29 23:36:39 | 2001-12-12 00:00:00 | added from doit | 4 | fred |
> +------------+---------------------+---------------------+-----------------+----+-------+
>
> So I told the SearchScript.groovy to use “id" as __UID__and “netid" as __NAME__.
>
> Where it fails is: under Resources, I click on ACCOUNTS, and then on the “RESOURCE” button, then when I click on one of the users, it only shows me the connld UID and connld Name attributes for the user, but NONE of the other attributes show up. But they’re all in the schema, why won’t they show up?
>
> Also, what if the SELECT I do only has a single unique key, can I use only one instead of both UID and NAME ?
>
> A totally unrelated question: How dow one increase the Timeout value for the Admin GUI? It logs me out all the time and I have to keep logging back in again.
>
> Thanks in advance!!!
>
>
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>
More information about the midPoint
mailing list