<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2020 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.
  -->

<resource oid="775189a9-3b7e-4d6f-ad5b-13259fd81c96"
          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:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
          xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">
    <name>Midprivacy Students registry</name>
    <connectorRef type="c:ConnectorType">
        <filter>
            <q:text>c:connectorType = 'com.evolveum.polygon.connector.csv.CsvConnector'</q:text>
        </filter>
    </connectorRef>

    <connectorConfiguration>
        <icfc:configurationProperties xmlns:icfcsv="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector">
            <icfcsv:filePath>/var/tmp/midpoint-resources/midprivacy/students.csv</icfcsv:filePath>
            <icfcsv:encoding>utf-8</icfcsv:encoding>
            <icfcsv:quote>"</icfcsv:quote>
            <icfcsv:fieldDelimiter>,</icfcsv:fieldDelimiter>
            <icfcsv:multivalueDelimiter>;</icfcsv:multivalueDelimiter>
            <icfcsv:uniqueAttribute>identifier</icfcsv:uniqueAttribute>
            <icfcsv:ignoreSurroundingSpaces>true</icfcsv:ignoreSurroundingSpaces>
        </icfc:configurationProperties>
    </connectorConfiguration>

    <schemaHandling>
        <objectType>
            <kind>account</kind>
            <intent>default</intent>
            <displayName>Default Account</displayName>
            <default>true</default>
            <objectClass>ri:AccountObjectClass</objectClass>

            <provenance>
                <originRef oid="a125c1c0-1031-49dc-94d2-422deec76c03" type="ServiceType"/>
                <metadataItemPopulator>
                    <expression>
                        <script>
                            <code>
                                DEFAULT_LOA = 0

                                loa = basic.getAttributeValue(projection, 'loa')
                                loa != null ? loa : DEFAULT_LOA
                            </code>
                        </script>
                    </expression>
                    <target>
                        <path>extension/assurance/loa</path>
                    </target>
                </metadataItemPopulator>
            </provenance>


            <attribute>
                <ref>ri:identifier</ref>
                <displayName>Identifier</displayName>
                <inbound>
                    <target>
                        <path>name</path>
                    </target>
                </inbound>
            </attribute>

            <attribute>
                <ref>ri:firstName</ref>
                <displayName>First name</displayName>

                <inbound>
                    <target>
                        <path>givenName</path>
                    </target>
                </inbound>
            </attribute>

            <attribute>
                <ref>ri:lastName</ref>
                <displayName>Last name</displayName>
                <inbound>
                    <target>
                        <path>familyName</path>
                    </target>
                </inbound>
            </attribute>

            <attribute>
                <ref>ri:organization</ref>
                <displayName>Organization</displayName>

                <limitations>
                    <maxOccurs>unbounded</maxOccurs>
                </limitations>

                <inbound>
                    <strength>strong</strength>
                    <target>
                        <path>organization</path>
                        <set>
                            <predefined>matchingProvenance</predefined>
                        </set>
                    </target>
                </inbound>
            </attribute>

            <attribute>
                <ref>ri:organizationalUnit</ref>
                <displayName>Organizational Unit</displayName>

                <limitations>
                    <maxOccurs>unbounded</maxOccurs>
                </limitations>

                <inbound>
                    <strength>strong</strength>
                    <target>
                        <path>organizationalUnit</path>
                    </target>
                </inbound>
            </attribute>

            <attribute>
                <ref>ri:loa</ref>
                <displayName>LoA</displayName>
                <documentation>Level of assurance</documentation>
            </attribute>

            <activation>
                <administrativeStatus>
                    <inbound/>
                </administrativeStatus>
            </activation>

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


        </objectType>
    </schemaHandling>
    <capabilities>
        <native xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3">
            <cap:schema/>
            <cap:liveSync/>
            <cap:testConnection/>
            <cap:create/>
            <cap:update>
                <cap:addRemoveAttributeValues>true</cap:addRemoveAttributeValues>
            </cap:update>
            <cap:delete/>
            <cap:read>
                <cap:returnDefaultAttributesOption>false</cap:returnDefaultAttributesOption>
            </cap:read>
        </native>
        <configured xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3">
            <cap:create>
                <cap:enabled>false</cap:enabled>
            </cap:create>
            <cap:activation>
                <cap:enabled>false</cap:enabled>
                <cap:lockoutStatus>
                    <cap:enabled>false</cap:enabled>
                    <cap:returnedByDefault>false</cap:returnedByDefault>
                    <cap:ignoreAttribute>true</cap:ignoreAttribute>
                </cap:lockoutStatus>
            </cap:activation>
            <cap:countObjects>
                <cap:simulate>sequentialSearch</cap:simulate>
            </cap:countObjects>
            <cap:liveSync>
                <cap:enabled>true</cap:enabled>
            </cap:liveSync>
            <cap:testConnection>
                <cap:enabled>true</cap:enabled>
            </cap:testConnection>
            <cap:read>
                <cap:enabled>true</cap:enabled>
                <cap:returnDefaultAttributesOption>false</cap:returnDefaultAttributesOption>
            </cap:read>
        </configured>
    </capabilities>
    <synchronization>
        <objectSynchronization>
            <name>Default account</name>
            <kind>account</kind>
            <intent>default</intent>
            <enabled>true</enabled>
            <correlation>
                <q:equal>
                    <q:path>name</q:path>
                    <expression>
                        <path>$projection/attributes/ri:identifier</path>
                    </expression>
                </q:equal>
            </correlation>
            <reconcile>false</reconcile>
            <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#unlink</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>
</resource>