<?xml version="1.0" ?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_4.2.xsd">

  <module name="dms" package="com.axelor.dms.db"/>

  <entity name="DMSFile" table="DMS_FILE" repository="none">
    <string name="fileName" required="true" namecolumn="true" />
    <boolean name="isDirectory" />
    <many-to-one name="parent" ref="DMSFile" />

    <!-- for internal use only, used for attachments -->
    <long name="relatedId" hidden="true" />
    <string name="relatedModel" hidden="true" title="Related object" />

    <!-- the real file -->
    <many-to-one name="metaFile" ref="com.axelor.meta.db.MetaFile" />

    <!-- permissions -->
    <one-to-many name="permissions" ref="DMSPermission" mappedBy="file" />

    <!-- tags -->
    <many-to-many name="tags" ref="DMSFileTag" orderBy="name" />

    <!-- content -->
    <string name="content" large="true" />
    <string name="contentType" />

  </entity>

  <entity name="DMSFileTag" table="DMS_FILE_TAG" repository="none">
    <string name="code" required="true" unique="true" min="2" />
    <string name="name" namecolumn="true" required="true" unique="true" min="2" />
    <string name="style" selection="dms.tag.style.selection" />
  </entity>

  <entity name="DMSPermission" table="DMS_PERMISSION" repository="none">
    <string name="value" required="true" selection="dms.permission.selection" />
    <many-to-one name="file" column="file_id" ref="DMSFile" />
    <many-to-one name="group" column="group_id" ref="com.axelor.auth.db.Group" />
    <many-to-one name="user" column="user_id" ref="com.axelor.auth.db.User" />
    <many-to-one name="permission" column="permission_id" ref="com.axelor.auth.db.Permission" />
  </entity>

</domain-models>
