<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2010-2020 Evolveum and contributors
  ~
  ~ Licensed under the EUPL-1.2 or later.
  -->

<report xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
        xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
        xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
        oid="00000000-0000-0000-0000-000000000100">
    <name>Reconciliation report</name>
    <description>Reconciliation report for selected resource.</description>
    <assignment id="1">
        <identifier>archetype</identifier>
        <targetRef oid="00000000-0000-0000-0000-000000000171" type="ArchetypeType"/>
    </assignment>
    <objectCollection>
        <collection>
            <baseCollectionRef>
                <collectionRef oid="00000000-0000-0000-0001-000000000008" type="ObjectCollectionType"/>
            </baseCollectionRef>
            <filter>
                <q:text>
                    resourceRef = yaml```
                            queryInterpretationOfNoValue: filterAll
                            path: "$resourceRef"
                    ``` and synchronizationSituation = yaml```
                            queryInterpretationOfNoValue: filterAll
                            path: "$situation"
                    ``` and objectClass = yaml```
                            queryInterpretationOfNoValue: filterAll
                            script:
                                code: |
                                    import javax.xml.namespace.QName;
                                    if (objectClass != null)
                                        return new QName("http://midpoint.evolveum.com/xml/ns/public/resource/instance-3", objectClass)
                    ``` and kind = yaml```
                            queryInterpretationOfNoValue: filterAll
                            path: "$kind"
                    ``` and intent = yaml```
                            queryInterpretationOfNoValue: filterAll
                            path: "$intent"
                    ```
                </q:text>
            </filter>
        </collection>
        <parameter id="2">
            <name>intent</name>
            <type>string</type>
            <display>
                <label>
                    <orig>intent</orig>
                    <translation>
                        <key>ShadowType.intent</key>
                    </translation>
                </label>
            </display>
        </parameter>
        <parameter id="3">
            <name>objectClass</name>
            <type>string</type>
            <display>
                <label>
                    <orig>objectClass</orig>
                    <translation>
                        <key>ShadowType.objectClass</key>
                    </translation>
                </label>
            </display>
        </parameter>
        <parameter id="4">
            <name>kind</name>
            <type>ShadowKindType</type>
            <display>
                <label>
                    <orig>kind</orig>
                    <translation>
                        <key>ShadowType.kind</key>
                    </translation>
                </label>
            </display>
        </parameter>
        <parameter id="5">
            <name>situation</name>
            <type>SynchronizationSituationType</type>
            <display>
                <label>
                    <orig>situation</orig>
                    <translation>
                        <key>ShadowType.synchronizationSituation</key>
                    </translation>
                </label>
            </display>
        </parameter>
        <parameter id="6">
            <name>resourceRef</name>
            <type>c:ObjectReferenceType</type>
            <targetType>c:ResourceType</targetType>
            <display>
                <label>
                    <orig>resource</orig>
                    <translation>
                        <key>ObjectTypeGuiDescriptor.resource</key>
                    </translation>
                </label>
            </display>
        </parameter>
        <view>
            <type>ShadowType</type>
            <column id="7">
                <name>nameColumn</name>
                <path>name</path>
            </column>
            <column id="8">
                <name>resourceColumn</name>
                <path>resourceRef</path>
                <previousColumn>nameColumn</previousColumn>
            </column>
            <column id="9">
                <name>situationColumn</name>
                <path>synchronizationSituation</path>
                <previousColumn>resourceColumn</previousColumn>
            </column>
            <column id="10">
                <name>ownerColumn</name>
                <display>
                    <label>
                        <orig>Owner</orig>
                        <translation>
                            <key>reportReconciliation.ownerColumn.label</key>
                        </translation>
                    </label>
                </display>
                <export>
                    <expression>
                        <script>
                            <code>
                                import com.evolveum.midpoint.schema.GetOperationOptions;
                                import com.evolveum.midpoint.schema.SelectorOptions;
                                import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
                                import com.evolveum.midpoint.prism.query.*

                                query = midpoint.getPrismContext().queryFor(FocusType.class)
                                .item(FocusType.F_LINK_REF).ref(object.getOid())
                                .build();

                                options = SelectorOptions.createCollection(GetOperationOptions.createRaw())
                                return midpoint.searchObjects(FocusType.class, query, options);
                            </code>
                        </script>
                    </expression>
                </export>
                <previousColumn>situationColumn</previousColumn>
            </column>
            <column id="11">
                <name>synchTimestampColumn</name>
                <path>synchronizationTimestamp</path>
                <previousColumn>ownerColumn</previousColumn>
            </column>
        </view>
    </objectCollection>
</report>
