<task oid="93fe5f38-4b29-4160-a60a-d1046cd43626"
      xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
      xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
      xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
      xmlns:org='http://midpoint.evolveum.com/xml/ns/public/common/org-3'
      xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3">
    <name>Init system config - Demo</name>
    <ownerRef oid="00000000-0000-0000-0000-000000000002"/>
    <executionState>runnable</executionState>
    <schedule>
        <recurrence>single</recurrence>
    </schedule>
    <activity>
        <work>
            <nonIterativeScripting>
                <scriptExecutionRequest>
                    <s:search>
                        <s:type>c:SystemConfigurationType</s:type>
                        <s:options>
                            <option>
                                <options>
                                    <raw>true</raw>
                                </options>
                            </option>
                        </s:options>
                        <s:action>
                            <s:type>modify</s:type>
                            <s:parameter>
                                <s:name>delta</s:name>
                                <c:value>
                                    <s:itemDelta>
                                        <t:modificationType>add</t:modificationType>
                                        <t:path>adminGuiConfiguration/objectCollectionViews/objectCollectionView</t:path>
                                        <t:value>
                                            <identifier>privileged-roles</identifier>
                                            <displayOrder>300</displayOrder>
                                            <type>RoleType</type>
                                            <collection>
                                                <collectionRef oid="00000000-0000-0000-0001-000000000354" relation="org:default" type="c:ObjectCollectionType"/>
                                            </collection>
                                        </t:value>
                                    </s:itemDelta>
                                    <s:itemDelta>
                                        <t:modificationType>delete</t:modificationType>
                                        <t:path>adminGuiConfiguration/objectCollectionViews/objectCollectionView</t:path>
                                        <t:value>
                                            <identifier>application</identifier>
                                            <type>ServiceType</type>
                                            <collection>
                                                <collectionRef oid="00000000-0000-0000-0000-000000000329" relation="org:default" type="c:ArchetypeType">
                                                    <!-- Application -->
                                                </collectionRef>
                                            </collection>
                                        </t:value>
                                    </s:itemDelta>
                                    <s:itemDelta>
                                        <t:modificationType>add</t:modificationType>
                                        <t:path>adminGuiConfiguration/objectCollectionViews/objectCollectionView</t:path>
                                        <t:value>
                                            <identifier>application</identifier>
                                            <display>
                                                <label>Application.panel.applications</label>
                                            </display>
                                            <type>ServiceType</type>
                                            <collection>
                                                <collectionRef oid="00000000-0000-0000-0000-000000000329" relation="org:default" type="c:ArchetypeType"/>
                                            </collection>
                                            <column>
                                                <name>nameColumn</name>
                                                <path>name</path>
                                                <display>
                                                    <label>Name</label>
                                                </display>
                                            </column>
                                            <column>
                                                <name>descriptionColumn</name>
                                                <path>description</path>
                                                <display>
                                                    <label>Description</label>
                                                </display>
                                                <previousColumn>nameColumn</previousColumn>
                                            </column>
                                            <column>
                                                <name>ownerColumn</name>
                                                <display>
                                                    <label>Owner</label>
                                                </display>
                                                <previousColumn>descriptionColumn</previousColumn>
                                                <export>
                                                    <expression>
                                                        <script>
                                                            <code>
                                                                owners = midpoint.getServiceMemberUsers(object.oid, com.evolveum.midpoint.schema.constants.RelationTypes.OWNER.relation)
                                                                return owners.collect{owner -&gt; owner.name}.join(", ")
                                                            </code>
                                                        </script>
                                                    </expression>
                                                </export>
                                            </column>
                                            <column>
                                                <name>classificationColumn</name>
                                                <display>
                                                    <label>Classification</label>
                                                </display>
                                                <previousColumn>ownerColumn</previousColumn>
                                                <export>
                                                    <expression>
                                                        <script>
                                                            <code>
                                                                for ( assignment in object.assignment ) {
                                                                    if (assignment.targetRef.type == com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyType.COMPLEX_TYPE) {
                                                                        policy = midpoint.getObject(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyType, assignment.targetRef.oid)
                                                                        policyArchetypes = midpoint.getArchetypeOids(policy)
                                                                        if ("00000000-0000-0000-0000-000000000330" in policyArchetypes) {
                                                                            return policy.name
                                                                        }
                                                                    }
                                                                }
                                                                return ""
                                                            </code>
                                                        </script>
                                                    </expression>
                                                </export>
                                            </column>
                                        </t:value>
                                    </s:itemDelta>
                                    <s:itemDelta>
                                        <t:modificationType>add</t:modificationType>
                                        <t:path>roleManagement/relations/relation</t:path>
                                        <t:value>
                                            <ref>org:approver</ref>
                                            <processedOnLogin>true</processedOnLogin>
                                            <!-- Categories need to be explicitly mentioned here. Categories are overridden even if no category is specified. -->
                                            <category>administration</category>
                                            <category>governance</category>
                                            <category>organization</category>
                                            <category>selfService</category>
                                        </t:value>
                                    </s:itemDelta>

                                    <s:itemDelta>
                                        <t:modificationType>add</t:modificationType>
                                        <t:path>globalPolicyRule</t:path>
                                        <t:value>
                                            <name>role-approval-approver-relation</name>
                                            <policyConstraints>
                                                <assignment>
                                                    <operation>add</operation>
                                                </assignment>
                                            </policyConstraints>
                                            <policyActions>
                                                <approval>
                                                    <compositionStrategy>
                                                        <order>50</order>
                                                    </compositionStrategy>
                                                    <approvalSchema>
                                                        <stage>
                                                            <name>Role Approver</name>
                                                            <approverRelation>approver</approverRelation>
                                                            <evaluationStrategy>firstDecides</evaluationStrategy>
                                                            <outcomeIfNoApprovers>skip</outcomeIfNoApprovers>
                                                        </stage>
                                                    </approvalSchema>
                                                </approval>
                                            </policyActions>
                                            <focusSelector>
                                                <type>UserType</type>
                                            </focusSelector>
                                            <targetSelector>
                                                <type>RoleType</type>
                                            </targetSelector>
                                        </t:value>
                                    </s:itemDelta>

                                    <s:itemDelta>
                                        <t:modificationType>add</t:modificationType>
                                        <t:path>workflowConfiguration/useDefaultApprovalPolicyRules</t:path>
                                        <t:value>never</t:value>
                                    </s:itemDelta>

                                </c:value>
                            </s:parameter>
                        </s:action>
                    </s:search>
                </scriptExecutionRequest>
            </nonIterativeScripting>
        </work>
    </activity>
</task>
