<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
      xmlns:apti="http://midpoint.evolveum.com/xml/ns/public/common/api-types-3"
      xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
      xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
      xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"
      xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
      xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
      xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      oid="metarole-OrgToOrg">
      <name>Metarole: Org to Org</name>
      <description>This will add, create, or update the organization attribute on the focus object</description>
      <activation>
      	 <administrativeStatus>enabled</administrativeStatus>
         <effectiveStatus>enabled</effectiveStatus>
      </activation>
      <iteration>0</iteration>
      <iterationToken/>
      <displayName>Metarole: Org to Org</displayName>
      <inducement id="1">
         <focusMappings>
            <mapping>
               <source>
                  <c:path>$immediateRole/name</c:path>
               </source>
               <expression>
               		<script>
               			<code>
               				log.info("Mapping Org to User; Org Name: " + name + "; From Metarole Org to Org");
               				org = basic.uc(basic.stringify(name));
               				return org;
               			</code>
               		</script>
               </expression>
               <target>
                  <c:path>$focus/organization</c:path>
               </target>
               	  <condition>
					 <script>
					 	 <code>operation == 'add'</code>
					 </script>
				  </condition>
            </mapping>
         </focusMappings>
         <order>2</order>
         <focusType>c:UserType</focusType>
      </inducement>
      <inducement id="2">
        <policyRule>
            <name>Org Unit Policy</name>
            <policyConstraints>
                <exclusion id="21">
                    <targetRef relation="org:default" type="c:OrgType">
                        <filter>
                            <q:text>assignment/targetRef matches (oid="metarole-OrgToOrg" and targetType = RoleType and relation = org:default)</q:text>
                        </filter>
                        <resolutionTime>run</resolutionTime>
                    </targetRef>
                </exclusion>
            </policyConstraints>
            <policyActions>
                <prune/>
            </policyActions>
        </policyRule>
    </inducement>
	<requestable>false</requestable>
</role>
