<?xml version="1.0"?>

<!-- This is a test setup for SQL directories that is similar to the
  default-sql-directories-bundles.xml setup except that the datasource is set
  to a in memory backend -->

<component name="org.nuxeo.ecm.directory.sql.storage">

  <implementation
    class="org.nuxeo.ecm.directory.sql.SQLDirectoryDescriptor" />

  <require>org.nuxeo.ecm.directory.sql.SQLDirectoryFactory</require>

  <extension target="org.nuxeo.ecm.directory.sql.SQLDirectoryFactory"
    point="directories">

    <directory name="userDirectory">

      <schema>user</schema>
      <types>
        <type>system</type>
      </types>
      <dataSource>java:/nxsqldirectory</dataSource>
      <table>users</table>
      <idField>username</idField>
      <passwordField>password</passwordField>
      <passwordHashAlgorithm>SSHA</passwordHashAlgorithm>
      <substringMatchType>subany</substringMatchType>
      <autoincrementIdField>false</autoincrementIdField>
      <dataFile>test-users.csv</dataFile>
      <createTablePolicy>always</createTablePolicy>
      <querySizeLimit>100</querySizeLimit>

      <references>
        <tableReference field="groups" directory="groupDirectory"
          table="user2group" sourceColumn="userId"
          targetColumn="groupId" dataFile="test-user2group.csv" />
      </references>

    </directory>


    <directory name="groupDirectory">

      <schema>group</schema>
      <types>
        <type>system</type>
      </types>
      <dataSource>java:/nxsqldirectory</dataSource>
      <table>groups</table>
      <idField>groupname</idField>
      <autoincrementIdField>false</autoincrementIdField>
      <dataFile>test-groups.csv</dataFile>
      <createTablePolicy>always</createTablePolicy>

      <references>
        <inverseReference field="members" directory="userDirectory"
          dualReferenceField="groups" />
        <tableReference field="subGroups" directory="groupDirectory"
          table="group2group" sourceColumn="childGroupId"
          targetColumn="parentGroupId" />
        <inverseReference field="parentGroups"
          directory="groupDirectory" dualReferenceField="subGroups" />
      </references>

    </directory>

  </extension>
</component>
