<!--
  ~ Copyright (c) 2020 Evolveum and contributors
  ~
  ~ Licensed under the EUPL-1.2 or later.
  -->

<archetype oid="00000000-0000-0000-0000-000000000516"
        xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
        xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
        xmlns:mext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3">
    <name>Delete long time not updated shadows task</name>
    <archetypeType>auxiliary</archetypeType>
    <archetypePolicy>
        <display>
            <label>
                <orig>Delete long time not updated shadows task</orig>
                <translation>
                    <key>DeleteLongTimeNotUpdatedShadowsTask.label</key>
                </translation>
            </label>
            <pluralLabel>
                <orig>Delete long time not updated shadows task</orig>
                <translation>
                    <key>TaskHandlerSelector.model.synchronization.task.delete.not.updated.shadow.handler</key>
                </translation>
            </pluralLabel>
            <icon>
                <cssClass>fa fa-wrench</cssClass>
                <color>green</color>
            </icon>
        </display>
        <itemConstraint id="1">
            <path>extension</path>
            <visibility>vacant</visibility>
        </itemConstraint>
        <itemConstraint id="2">
            <path>extension/mext:objectclass</path>
            <visibility>visible</visibility>
        </itemConstraint>
        <itemConstraint id="3">
            <path>extension/mext:kind</path>
            <visibility>visible</visibility>
        </itemConstraint>
        <itemConstraint id="4">
            <path>extension/mext:intent</path>
            <visibility>visible</visibility>
        </itemConstraint>
        <itemConstraint id="5">
            <path>extension/mext:objectQuery</path>
            <visibility>visible</visibility>
        </itemConstraint>
        <itemConstraint id="6">
            <path>extension/mext:searchOptions</path>
            <visibility>visible</visibility>
        </itemConstraint>
        <itemConstraint id="7">
            <path>extension/mext:iterationMethod</path>
            <visibility>visible</visibility>
        </itemConstraint>
        <itemConstraint id="8">
            <path>extension/mext:failedObjectsSelector</path>
            <visibility>visible</visibility>
        </itemConstraint>
        <itemConstraint id="9">
            <path>extension/mext:notUpdatedShadowsDuration</path>
            <visibility>visible</visibility>
        </itemConstraint>
        <adminGuiConfiguration>
            <objectDetails>
                <type>TaskType</type>
                <panel id="10">
                    <identifier>activity</identifier>
                    <panel id="11">
                        <identifier>work</identifier>
                        <container id="12">
                            <identifier>work-shadowCleanup</identifier>
                            <path>activity/work/shadowCleanup</path>
                        </container>
                    </panel>
                </panel>
            </objectDetails>
        </adminGuiConfiguration>
    </archetypePolicy>
    <assignment id="13">
        <identifier>holderType</identifier>
        <assignmentRelation id="14">
            <holderType>TaskType</holderType>
        </assignmentRelation>
    </assignment>
    <inducement id="15">
        <identifier>nameMapping</identifier>
        <focusMappings>
            <mapping id="16">
                <strength>weak</strength>
                <expression>
                    <script>
                        <code>
                            import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType
                            import org.apache.commons.lang3.StringUtils

                            def task = focus as TaskType

                            String name = source.name

                            String description = midpoint.describeResourceObjectSet(task?.activity?.work?.shadowCleanup?.shadows)
                            if(StringUtils.isNotEmpty(description)) {
                                return name + ': ' + description
                            }

                            return name
                        </code>
                    </script>
                </expression>
                <target>
                    <path>name</path>
                </target>
            </mapping>
        </focusMappings>
    </inducement>
</archetype>
