[midPoint] scriptedsql example
Jason Everling
jeverling at bshp.edu
Tue Aug 14 20:00:09 CEST 2018
forgot to mention, you can also hide the string value within the gui if you
don't want it to be visible, that way only the date type is displayed.
<item>
<c:ref xmlns:yours="http://yournamespace
">c:extension/yours:yourStringValue</c:ref>
<limitations>
<layer>presentation</layer>
<ignore>true</ignore>
</limitations>
</item>
JASON
On Tue, Aug 14, 2018 at 12:50 PM, Jason Everling <jeverling at bshp.edu> wrote:
> Basically, you would end up having 2 different schema extensions, 1 to
> pull in and store it as a string value yyyymmdd and then you use the other
> to take the string value and store it as date by using objectTemplate
> mapping.
>
> <mapping>
> <strength>strong</strength>
> <source>
> <path>extension/yourStringValue</path>
> </source>
> <expression>
> <script>
> <code>
> import com.evolveum.midpoint.prism.xml.XmlTypeConverter
> Date dt = Date.parse('yyyyMMdd', yourStringValue)
> XmlTypeConverter.createXMLGregorianCalendar(dt)
> </code>
> </script>
> </expression>
> <target>
> <path>extension/yourDateTimeValue</path>
> </target>
> </mapping>
>
> JASON
>
> On Tue, Aug 14, 2018 at 12:20 PM, Frigerio, Joshua <joshua at uic.edu> wrote:
>
>> Ah, Ok. I guess I was assuming that Midpoint would have to import it as a
>> date in order to use the value as a date? (ie, so that rules can be made
>> that depend on date values).
>> Is that not the case? Can I import them as strings and Midpoint will
>> still be able to use them as dates?
>>
>>
>> -----Original Message-----
>> From: midPoint <midpoint-bounces at lists.evolveum.com> on behalf of
>> František Dvořák <valtri at civ.zcu.cz>
>> Reply-To: midPoint General Discussion <midpoint at lists.evolveum.com>
>> Date: Tuesday, August 14, 2018 at 11:49 AM
>> To: midPoint General Discussion <midpoint at lists.evolveum.com>
>> Subject: Re: [midPoint] scriptedsql example
>>
>> >Hello,
>> >
>> >Frigerio, Joshua píše v Út 14. 08. 2018 v 14:23 +0000:
>> >> Hey, can anyone throw me a rope. How do I get a scriptedsql resource
>> >> to
>> >> read the “datetime” type as a date into Midpoint?
>> >> I tried setting “All native” to true. No help.
>> >> I keep getting the same error:
>> >>
>> >> "Attribute 'birth' type 'class java.sql.Timestamp' is not
>> >> supported.’"
>> >>
>> >
>> >As I understand, ConnId framework doesn't support date types. It needs
>> >to be converted to Long or String inside the SQL groovy script.
>> >
>> >But there are exciting plans in midPoint 3.9 about newer ConnId and
>> >native date types support:
>> >
>> >https://wiki.evolveum.com/display/midPoint/Release+3.9+-+PL
>> ANNED#Release3.
>> >9-PLANNED-Changeswithrespecttoversion3.8
>> >
>> > Frantisek
>> >
>> >> Thanks.
>> >>
>> >>
>> >> -----Original Message-----
>> >> From: midPoint <midpoint-bounces at lists.evolveum.com> on behalf of joe
>> >> schmoe <joshua at uic.edu>
>> >> Reply-To: midPoint General Discussion <midpoint at lists.evolveum.com>
>> >> Date: Friday, August 3, 2018 at 8:21 PM
>> >> To: midPoint General Discussion <midpoint at lists.evolveum.com>
>> >> Subject: Re: [midPoint] scriptedsql example
>> >>
>> >> > >
>> >> > > If you don't want to handle this date as a real date, just
>> >> > > convert it to
>> >> > > string using mysql cast function:
>> >> >
>> >> > I want it to remain a date.
>> >> > I figured in the SchemaScript.groovy, I’d change it to tell
>> >> > Midpoint it’s
>> >> > a date, using this line:
>> >> >
>> >> > account.addAttributeInfo(AttributeInfoBuilder.build("birthdate",
>> >> > String.class));
>> >> >
>> >> > But nothing I change it to matters, same error every time:
>> >> > "Attribute
>> >> > 'birthdate' type 'class java.sql.Timestamp' is not supported.”. :-
>> >> > (
>> >> >
>> >> > Or am I going about it wrong? How do I get it to see that datetime
>> >> > field
>> >> > as a datetime field?
>> >> >
>> >> >
>> >> >
>> >> > >
>> >> > > select cast(timestamp as char) as timestamp
>> >> > >
>> >> > >
>> >> > > W dniu 03.08.2018 o 21:27, Frigerio, Joshua pisze:
>> >> > > > > 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])} );
>> >> > > >
>> >> > > > Ug, that was right there in the example too, somehow I missed
>> >> > > > thatŠ.
>> >> > > > Thanks!
>> >> > > >
>> >> > > > Although it doesn¹t work for date fields (datetime or timestamp
>> >> > > > mysql
>> >> > > > types). If I try to add the ³timestamp² field or the
>> >> > > > ³birthdate" field,
>> >> > > > it
>> >> > > > says, ³Got unexpected exception:
>> >> > > > java.lang.IllegalArgumentException:
>> >> > > > Attribute 'birthdate' type 'class java.sql.Timestamp' is not
>> >> > > > supported."
>> >> > > > In the schema groovy script, I told it to treat it as a
>> >> > > > String.class,
>> >> > > > but
>> >> > > > it doesn¹t work anyway. :-(
>> >> > > >
>> >> > > > _______________________________________________
>> >> > > > midPoint mailing list
>> >> > > > midPoint at lists.evolveum.com
>> >> > > > http://lists.evolveum.com/mailman/listinfo/midpoint
>> >> > >
>> >> > > --
>> >> > > Wojciech Staszewski
>> >> > > Administrator Systemów Sieciowych
>> >> > > tel. kom: 663 680 236
>> >> > > www.diagnostyka.pl
>> >> > > Diagnostyka Sp. z o. o.
>> >> > > ul. Prof. M. Życzkowskiego 16, 31-864 Kraków
>> >> > > Numer KRS: 0000381559 (Sąd Rejonowy dla Krakowa-Śródmieścia w
>> >> > > Krakowie,
>> >> > > XI Wydział Gospodarczy KRS)
>> >> > > NIP: 675-12-65-009; REGON: 356366975
>> >> > > Kapitał zakładowy: 33 756 500 zł.
>> >> > >
>> >> > > Pomyśl o środowisku zanim wydrukujesz ten e-mail.
>> >> > >
>> >> > > _______________________________________________
>> >> > > midPoint mailing list
>> >> > > midPoint at lists.evolveum.com
>> >> > > http://lists.evolveum.com/mailman/listinfo/midpoint
>> >> >
>> >> > _______________________________________________
>> >> > midPoint mailing list
>> >> > midPoint at lists.evolveum.com
>> >> > http://lists.evolveum.com/mailman/listinfo/midpoint
>> >>
>> >> _______________________________________________
>> >> midPoint mailing list
>> >> midPoint at lists.evolveum.com
>> >> http://lists.evolveum.com/mailman/listinfo/midpoint
>> >_______________________________________________
>> >midPoint mailing list
>> >midPoint at lists.evolveum.com
>> >http://lists.evolveum.com/mailman/listinfo/midpoint
>>
>> _______________________________________________
>> midPoint mailing list
>> midPoint at lists.evolveum.com
>> http://lists.evolveum.com/mailman/listinfo/midpoint
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20180814/0b9d64f7/attachment.htm>
More information about the midPoint
mailing list