[midPoint] Mapping a date in outbound to database table

Ivan Noris ivan.noris at evolveum.com
Thu Aug 6 08:51:46 CEST 2020


Hi Eduard,

the error message states that the "input" property is not declared in
the mapping context. midPoint does not know which attribute is the
source of the mapping "by default". In inbound mapping, the attribute in
<ref> corresponds to "input" property. In outbound, you typically define
source(s).

My example from DatabaseTable connector resource outbound for Oracle db
table's BIRTHDATE column:

           <attribute>
                <ref>ri:BIRTHDATE</ref>
                <outbound>
                    <strength>strong</strength>
                    <source>
                        <path>*extension/birthDate*</path>
                    </source>
                    <expression>
                        <script>
                            <code>
                                return basic.formatDateTime("yyyy-MM-dd
HH:mm:ss.S", *birthDate*)

                                <!-- birthDate is extension/birthDate -->

                            </code>
                        </script>
                    </expression>
                </outbound>
            </attribute>

The mapping will take midPoint's extension/birthDate of the currently
processed focus object (e.g. user) and convert it to the format which my
database (Oracle) needs for DBTable connector.

So first, you need to use proper property, which is declared as a source
in the mapping.

Second, you need to convert the date from midPoint's format
(XMLGregorianCalendar) to whatever the database and/or connector
requires. I think the DBTable connector does not support xsd:date and
uses xsd:string - you can check that in the schema that is returned from
the target system and stored in the resource <schema> element for
BIRTHDATE attribute. Other connectors may have different types.

Best regards,

Ivan

On 6. 8. 2020 1:06, Eduard Stan wrote:
>
> Hi,
>
> I’m using the following expression for importing date from DATABASE to
> MIDPOINT, and it works:
>
> <script
> xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3">
>
>     <code>
>
>       import java.text.SimpleDateFormat;
>
>       import java.text.DateFormat;
>
>      
>
>       DateFormat dtf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
>
>      
>
>       if (input!=null) {
>
>         Date dt = dtf.parse(input);
>
>         log.info("convertedValidFrom = " + dt);
>
>         return
> com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar(dt);
>
>       } else {
>
>         return null;
>
>       }
>
>     </code>
>
> </script>
>
>  
>
> Using the same expression for outbound throws the following error:
>
>  
>
> No such property: input for class:
> expression_in_mapping_in_inbound_expression_for_DATA
> _in_resource_67952a4d-218b-4b1d-952d-7e1fe1a9d58b(HR) in expression in
> mapping in outbound mapping for {.../resource/instance-3}DATA in
> resource:28d3861d-df87-494b-8c65-597ca787ba08(Users)(null (focus,
> user)=user:1056841c-1dc9-489b-bead-3054bfa1882a();
> configuration=systemConfiguration:00000000-0000-0000-0000-000000000001(SystemConfiguration);
> resource=resource:28d3861d-df87-494b-8c65-597ca787ba08(Users);
> iterationToken=;
> actor=user:00000000-0000-0000-0000-000000000002(administrator); DATA
> =PPV(XMLGregorianCalendarImpl:1979-11-10T12:00:00.000+01:00);
> legal=true; iteration=0; assigned=true; projection (shadow,
> account)=null; operation=add; ) in expression in mapping in outbound
> mapping for {.../resource/instance-3}DATA in
> resource:28d3861d-df87-494b-8c65-597ca787ba08(Users)
>
>  
>
> Can anyone advise?
>
> Thank you.**
>
>  
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> https://lists.evolveum.com/mailman/listinfo/midpoint

-- 
Ivan Noris
Senior Identity Engineer
evolveum.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20200806/ee65bde7/attachment.htm>


More information about the midPoint mailing list