<?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.
  -->

  <!-- This sample is NOT SUPPOSED TO WORK yet. This is a preview of some
       features that are not yet implemented in midPoint. -->

<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:org='http://midpoint.evolveum.com/xml/ns/public/common/org-3'
         xmlns:a="http://prism.evolveum.com/xml/ns/public/types-3"
         xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
         xmlns:role="http://midpoint.evolveum.com/xml/ns/public/common/role-2"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <!-- Functional organizational structure -->

    <org oid="00000000-8888-6666-0000-100000000001">
        <name>F0001</name>
        <description>The office of the most respectful Governor.</description>
        <displayName>Governor Office</displayName>
        <identifier>0001</identifier>
        <subtype>functional</subtype>
        <costCenter>CC0</costCenter>
        <locality>The Governor's Mansion</locality>
    </org>

    <org oid="00000000-8888-6666-0000-100000000002">
        <name>F0002</name>
        <description>Defending the scum since the ancient times.</description>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000001" type="c:OrgType"/>
        <assignment>
            <targetRef oid="00000000-8888-6666-0000-100000000001" type="c:OrgType"/>
        </assignment>
        <displayName>Ministry of Defense</displayName>
        <identifier>0002</identifier>
        <subtype>functional</subtype>
        <locality>The towers, bastions and bars</locality>
    </org>

    <org oid="00000000-8888-6666-0000-100000000003">
        <name>F0003</name>
        <description>Offending. Anyone. Anywhere.</description>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000001" type="c:OrgType"/>
        <assignment>
            <targetRef oid="00000000-8888-6666-0000-100000000001" type="c:OrgType"/>
        </assignment>
        <displayName>Ministry of Offense</displayName>
        <identifier>0003</identifier>
        <subtype>functional</subtype>
        <costCenter>CC666</costCenter>
    </org>

    <org oid="00000000-8888-6666-0000-100000000004">
        <name>F0004</name>
        <description>Why is the rum always gone?</description>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000001" type="c:OrgType"/>
        <assignment>
            <targetRef oid="00000000-8888-6666-0000-100000000001" type="c:OrgType"/>
        </assignment>
        <displayName>Ministry of Rum</displayName>
        <identifier>0004</identifier>
        <subtype>functional</subtype>
        <costCenter>CCRUM</costCenter>
    </org>

    <org oid="00000000-8888-6666-0000-100000000005">
        <name>F0005</name>
        <description>Swashing, buckling and insulting. Hard.</description>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000003" type="c:OrgType"/>
        <assignment>
            <targetRef oid="00000000-8888-6666-0000-100000000003" type="c:OrgType"/>
        </assignment>
        <displayName>Swashbuckler Section</displayName>
        <identifier>0005</identifier>
        <subtype>functional</subtype>
    </org>

    <org oid="00000000-8888-6666-0000-100000000006">
        <name>F0006</name>
        <description>Hosting the worst scumm of the Caribbean.</description>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000003" type="c:OrgType"/>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000004" type="c:OrgType"/>
        <assignment>
            <targetRef oid="00000000-8888-6666-0000-100000000003" type="c:OrgType"/>
        </assignment>
        <assignment>
            <targetRef oid="00000000-8888-6666-0000-100000000004" type="c:OrgType"/>
        </assignment>
        <displayName>Scumm Bar</displayName>
        <identifier>0006</identifier>
        <subtype>functional</subtype>
        <locality>Mêlée Island</locality>
    </org>

    <!-- Project organizational structure -->

    <org oid="00000000-8888-6666-0000-200000000000">
        <name>PRoot</name>
        <description>Project organizational structure root</description>
        <displayName>Projects</displayName>
        <subtype>project</subtype>
    </org>

    <org oid="00000000-8888-6666-0000-200000000001">
        <name>P0001</name>
        <parentOrgRef oid="00000000-8888-6666-0000-200000000000" type="c:OrgType"/>
        <assignment>
            <targetRef oid="00000000-8888-6666-0000-200000000000" type="c:OrgType"/>
        </assignment>
        <displayName>Save Elaine</displayName>
        <identifier>0001</identifier>
        <subtype>project</subtype>
    </org>

    <org oid="00000000-8888-6666-0000-200000000002">
        <name>P0002</name>
        <parentOrgRef oid="00000000-8888-6666-0000-200000000000" type="c:OrgType"/>
        <assignment>
            <targetRef oid="00000000-8888-6666-0000-200000000000" type="c:OrgType"/>
        </assignment>
        <displayName>Kidnap and marry Elaine</displayName>
        <identifier>0002</identifier>
        <subtype>project</subtype>
    </org>

    <!-- Roles -->

    <role oid="00000000-8888-6666-0000-300000000001">
        <name>Manager</name>
        <paramSchema>
            <definition>
                <xsd:schema targetNamespace="http://midpoint.evolveum.com/xml/ns/public/common/role-2">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="orgRef" type="c:ObjectReferenceType">
                                <xsd:annotation>
                                    <xsd:documentation>
                                        Reference to the organization unit that this role manages.
                                    </xsd:documentation>
                                    <xsd:appinfo>
                                        <a:objectReferenceTargetType>c:OrgType</a:objectReferenceTargetType>
                                    </xsd:appinfo>
                                </xsd:annotation>
                            </xsd:element>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:schema>
            </definition>
        </paramSchema>
        <assignment>
            <description>
                Assign the manager to the org that he manages. Make sure that the relation is set appropriately
                so he will not be considered a member of that org.
            </description>
            <org>
                <orgRef>
                    <refConstruction>
                        <oid>
                            <path>$role:orgRef</path>
                        </oid>
                        <relation>
                            <value>org:manager</value>
                        </relation>
                    </refConstruction>
                </orgRef>
            </org>
        </assignment>
        <assignment>
            <description>
                Ability to assign any user to the org defined by $orgRef parameter (and any one below)
            </description>
            <ability>
                <privilege>priv:assign</privilege>
                <objectRange>
                    <q:type>UserType</q:type>
                </objectRange>
                <targetRange>
                    <q:org>
                        <q:orgRef>
                            <refConstruction>
                                <oid>
                                    <path>$role:orgRef</path>
                                </oid>
                            </refConstruction>
                        </q:orgRef>
                        <q:maxDepth>unbounded</q:maxDepth>
                    </q:org>
                </targetRange>
            </ability>
        </assignment>
    </role>

    <!-- Users -->

    <user>
        <name>elaine</name>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000001" type="c:OrgType"/> <!-- No "relation" in the ref means "member" -->
        <parentOrgRef oid="00000000-8888-6666-0000-100000000001" type="c:OrgType" relation="org:manager"/>
        <fullName>Elaine Marley</fullName>
        <givenName>Elaine</givenName>
        <familyName>Marley</familyName>
        <title>Governor</title>
        <assignment>
            <org>
                <orgRef oid="00000000-8888-6666-0000-100000000001"/>
            </org>
        </assignment>
        <assignment>
            <role>
                <roleRef oid="00000000-8888-6666-0000-300000000001"/> <!-- Manager Role -->
                <params>
                    <role:orgRef oid="00000000-8888-6666-0000-100000000001"/>
                </params>
            </role>
        </assignment>
    </user>

    <user>
        <name>cheese</name>
        <description>The owner of Scumm Bar</description>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000006" type="c:OrgType"/>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000006" type="c:OrgType" relation="org:manager"/>
        <fullName>Ignatius Cheese</fullName>
        <givenName>Ignatius</givenName>
        <familyName>Cheese</familyName>
        <assignment>
            <org>
                <orgRef oid="00000000-8888-6666-0000-100000000006"/>
            </org>
        </assignment>
        <assignment>
            <role>
                <roleRef oid="00000000-8888-6666-0000-300000000001"/> <!-- Manager Role -->
                <params>
                    <role:orgRef oid="00000000-8888-6666-0000-100000000006"/>
                </params>
            </role>
        </assignment>
    </user>

    <user>
        <name>chef</name>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000006" type="c:OrgType"/>
        <fullName>Scumm Bar Chef</fullName>
        <givenName>Chef</givenName>
        <familyName>Scumm</familyName>
        <assignment>
            <org>
                <orgRef oid="00000000-8888-6666-0000-100000000006"/>
            </org>
        </assignment>
    </user>

    <user>
        <name>barkeeper</name>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000006" type="c:OrgType"/>
        <fullName>Horridly Scarred Barkeep</fullName>
        <givenName>Barkeeper</givenName>
        <familyName>Scumm</familyName>
        <assignment>
            <org>
                <orgRef oid="00000000-8888-6666-0000-100000000006"/>
            </org>
        </assignment>
    </user>

    <user>
        <name>guybrush</name>
        <!-- Member of Scumm Bar but manager of Ministry of Rum (where he is NOT member) -->
        <parentOrgRef oid="00000000-8888-6666-0000-100000000006" type="c:OrgType"/>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000004" type="c:OrgType" relation="org:manager"/>
        <fullName>Guybrush Threepwood</fullName>
        <givenName>Guybrush</givenName>
        <familyName>Threepwood</familyName>
        <assignment>
            <org>
                <orgRef oid="00000000-8888-6666-0000-100000000006"/>
            </org>
        </assignment>
        <assignment>
            <role>
                <roleRef oid="00000000-8888-6666-0000-300000000001"/> <!-- Manager Role -->
                <params>
                    <role:orgRef oid="00000000-8888-6666-0000-100000000004"/>
                </params>
            </role>
        </assignment>
    </user>

    <user>
        <name>carla</name>
        <parentOrgRef oid="00000000-8888-6666-0000-100000000002" type="c:OrgType"/>
        <parentOrgRef oid="00000000-8888-6666-0000-200000000001" type="c:OrgType"/>
        <fullName>Carla the Swordmaster</fullName>
        <givenName>Carla</givenName>
        <assignment>
            <org>
                <orgRef oid="00000000-8888-6666-0000-100000000002"/>
            </org>
        </assignment>
        <assignment>
            <org>
                <orgRef oid="00000000-8888-6666-0000-200000000001"/>
            </org>
        </assignment>
    </user>

    <user>
        <name>lechuck</name>
        <!-- LeChuck just manages, does not belong to anywhere -->
        <parentOrgRef oid="00000000-8888-6666-0000-200000000002" type="c:OrgType" relation="org:manager"/>
        <fullName>Captain LeChuck</fullName>
        <familyName>LeChuck</familyName>
        <assignment>
            <role>
                <roleRef oid="00000000-8888-6666-0000-300000000001"/> <!-- Manager Role -->
                <params>
                    <role:orgRef oid="00000000-8888-6666-0000-200000000002"/>
                </params>
            </role>
        </assignment>
    </user>

    <user>
        <name>bob</name>
        <parentOrgRef oid="00000000-8888-6666-0000-200000000002" type="c:OrgType"/>
        <fullName>Ghost Pirate Bob</fullName>
        <givenName>Bob</givenName>
        <assignment>
            <org>
                <orgRef oid="00000000-8888-6666-0000-200000000002"/>
            </org>
        </assignment>
    </user>

</objects>
