<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2010-2017 Evolveum
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<c:objects xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
       xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
           xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
           xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
           xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
           xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3"
           xmlns:syncext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3">

    <c:resource oid="66245ea2-07d9-11e7-ac98-67b627683b1b">

        <name>HR</name>
        <description>HR data source simulated by CSV file</description>

        <connectorRef type="ConnectorType">
            <filter>
                <q:text>connectorType = "com.evolveum.polygon.connector.csv.CsvConnector"</q:text>
            </filter>
        </connectorRef>

        <connectorConfiguration xmlns:icfi="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector">

            <icfc:configurationProperties>
                <icfi:filePath>/var/opt/midpoint-evolveum/resources/hr.csv</icfi:filePath>
                <icfi:encoding>utf-8</icfi:encoding>
                <icfi:fieldDelimiter>,</icfi:fieldDelimiter>
                <icfi:multivalueDelimiter>;</icfi:multivalueDelimiter>
                <icfi:uniqueAttribute>empno</icfi:uniqueAttribute>
            </icfc:configurationProperties>

        </connectorConfiguration>

        <schemaHandling>

            <objectType>
                <default>true</default>
                <objectClass>ri:AccountObjectClass</objectClass>

                <attribute>
                    <ref>ri:empno</ref>
                    <displayName>Employee ID</displayName>
                    <inbound>
                        <target>
                            <path>employeeNumber</path>
                        </target>
                    </inbound>
                </attribute>

                <attribute>
                    <ref>ri:fullname</ref>
                    <inbound>
                        <target>
                            <path>$user/fullName</path>
                        </target>
                    </inbound>

                </attribute>
                <attribute>
                    <ref>ri:firstname</ref>
                    <inbound>
                        <target>
                            <path>$user/givenName</path>
                        </target>
                    </inbound>

                </attribute>
                <attribute>
                    <ref>ri:lastname</ref>
                    <inbound>
                        <target>
                            <path>$user/familyName</path>
                        </target>
                    </inbound>
                </attribute>

                <attribute>
                    <ref>ri:orgId</ref>
                    <inbound>
                        <target>
                            <path>$user/organizationalUnit</path>
                        </target>
                    </inbound>
                </attribute>

                <attribute>
                    <ref>ri:job</ref>
                    <inbound>
                        <target>
                            <path>$user/title</path>
                        </target>
                    </inbound>
                </attribute>

                <activation>
                    <administrativeStatus>
                        <inbound>
                            <strength>weak</strength>
                        </inbound>
                    </administrativeStatus>
                </activation>

                <credentials>
                    <password>
                        <inbound>
                            <strength>weak</strength>
                            <expression>
                                <generate/>
                            </expression>
                        </inbound>
                    </password>
                </credentials>

            </objectType>
        </schemaHandling>
        <capabilities xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3">
            <configured>
                <cap:activation>
                    <cap:status>
                        <cap:attribute>ri:active</cap:attribute>
                        <cap:enableValue>true</cap:enableValue>
                        <cap:disableValue>false</cap:disableValue>
                    </cap:status>
                </cap:activation>
            </configured>
        </capabilities>

        <projection>
            <assignmentPolicyEnforcement>none</assignmentPolicyEnforcement>
        </projection>

        <synchronization>
            <objectSynchronization>
                <enabled>true</enabled>

                <correlation>
                    <q:equal>
                        <q:path>c:employeeNumber</q:path>
                        <expression>
                            <path>$account/attributes/empno</path>
                        </expression>
                    </q:equal>
                </correlation>

                <reaction>
                    <situation>linked</situation>
                    <synchronize>true</synchronize>
                </reaction>
                <reaction>
                    <situation>deleted</situation>
                    <synchronize>true</synchronize>
                    <action>
                        <handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#deleteFocus</handlerUri>
                    </action>
                </reaction>
                <reaction>
                    <situation>unlinked</situation>
                    <synchronize>true</synchronize>
                    <action>
                        <handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#link</handlerUri>
                    </action>
                </reaction>
                <reaction>
                    <situation>unmatched</situation>
                    <synchronize>true</synchronize>
                    <action>
                        <handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addFocus</handlerUri>
                    </action>
                </reaction>
            </objectSynchronization>
        </synchronization>
    </c:resource>

    <task oid="c8c74686-07da-11e7-ade5-772d2eae600d">
        <name>Synchronization: HR</name>
        <taskIdentifier>c8c74686-07da-11e7-ade5-772d2eae600d</taskIdentifier>
        <ownerRef oid="00000000-0000-0000-0000-000000000002"/>
        <executionState>runnable</executionState>
        <objectRef oid="66245ea2-07d9-11e7-ac98-67b627683b1b" type="c:ResourceType"/>
        <binding>tight</binding>
        <schedule>
            <recurrence>recurring</recurrence>
            <interval>5</interval>
        </schedule>
        <activity>
            <work>
                <liveSynchronization>
                    <resourceObjects>
                        <resourceRef oid="66245ea2-07d9-11e7-ac98-67b627683b1b"/>
                        <objectclass>ri:AccountObjectClass</objectclass>
                    </resourceObjects>
                </liveSynchronization>
            </work>
        </activity>
    </task>

</c:objects>
