<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="VCLib" 
Name="REPORT_MENU_ITEM" 
Description="Ссылка меню на отчет" 
PrimaryKey="ReportMenuItemID">
  <Fields>
    <Attribute Name="ReportMenuItemID" Index="3230001" Type="guid" Description="Идентификатор" />
    <Attribute Name="Name" Index="3230003" Type="string" Description="Наименование" Required="1" />
    <Attribute Name="OrderNum" Index="3230004" Type="string" Description="Порядковый номер" Required="1" />
    <Choice Name="MenuType" Description="Тип меню" Cashed="1">
      <Item Name="Отчет из файла" Index="0" />
      <Item Name="Генератор отчетов" Index="1" />
      <Item Name="Отчет" Index="2" />
      <Item Name="Папка" Index="4" />
      <Item Name="Экспорт данных" Index="5" />
      <Item Name="XML отчет" Index="6" />
      <Item Name="Справка" Index="7" />
    </Choice>
    <Parent Name="Parent" Type="VCLib.REPORT_MENU_ITEM" Description="Родительский элемент" />
    <Choice Name="ReportType" Description="Тип отчета" Required="1">
      <Item Name="Отчет" Index="0" />
      <Item Name="Справка" Index="1" />
    </Choice>
  </Fields>
  <DbMapping>
    <Table name="T_REPORT_MENU_ITEM">
      <Map Name="ReportMenuItemID" Column="ReportMenuItemID" />
      <Map Name="Name" Column="Name" />
      <Map Name="OrderNum" Column="OrderNum" />
      <Map Name="ReportType" Column="ReportType" />
    </Table>
    <Lexem>
      <Map Name="MenuType">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:Criterion type="ExactIs">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="String"><![CDATA[VCLib.REPORT_MENU_ITEM]]></lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:ConstOperand type="Decimal">4</lx:ConstOperand>
          </Then>
          <When>
            <lx:Criterion type="IS">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="String"><![CDATA[VCLib.GENERIC_REPORT_MENU_ITEM]]></lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:ConstOperand type="Decimal">1</lx:ConstOperand>
          </Then>
          <When>
            <lx:Criterion type="IS">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="String"><![CDATA[VCLib.SIMPLE_REPORT_MENU_ITEM]]></lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:ConstOperand type="Decimal">2</lx:ConstOperand>
          </Then>
          <When>
            <lx:Criterion type="IS">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="String"><![CDATA[VCLib.FILE_REPORT_MENU_ITEM]]></lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:ConstOperand type="Decimal">0</lx:ConstOperand>
          </Then>
          <When>
            <lx:Criterion type="IS">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="String"><![CDATA[VCLib.EXPORT_DATA_MENU_ITEM]]></lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:ConstOperand type="Decimal">5</lx:ConstOperand>
          </Then>
          <When>
            <lx:Criterion type="IS">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="String"><![CDATA[VCLib.XML_REPORT_MENU_ITEM]]></lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:ConstOperand type="Decimal">6</lx:ConstOperand>
          </Then>
          <When>
            <lx:Criterion type="IS">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="String"><![CDATA[VCLib.HELP_REPORT_MENU_ITEM]]></lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:ConstOperand type="Decimal">7</lx:ConstOperand>
          </Then>
          <Else>
            <lx:ConstOperand isNull="1" />
          </Else>
        </lx:Case>
      </Map>
      <Map Name="Parent">
        <lx:QueryValue entity="VCLib.REPORT_MENU_ITEM" top="1" xmlns:lx="lexem">
          <condition>
            <lx:Criteria type="And">
              <lx:Criterion not="1" type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="ReportMenuItemID" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepString name="ReportMenuItemID" />
                </lx:Path>
              </lx:Criterion>
              <lx:Criterion type="Like">
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepString name="OrderNum" />
                </lx:Path>
                <lx:MathOperator sign="+">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="OrderNum" />
                  </lx:Path>
                  <lx:ConstOperand type="String"><![CDATA[.%]]></lx:ConstOperand>
                </lx:MathOperator>
              </lx:Criterion>
            </lx:Criteria>
          </condition>
          <orderBy>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="OrderNum" />
            </lx:Path>
            <desc>True</desc>
          </orderBy>
          <value>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="ReportMenuItemID" />
            </lx:Path>
          </value>
        </lx:QueryValue>
      </Map>
    </Lexem>
  </DbMapping>
  <CalculatingAttributes>
    <Child Name="cRoles" Type="VCLib.ROLES" Description="Роли, имеющие право доступа" RequiredAttributes="{As VCLib.XML_REPORT_MENU_ITEM / XmlReport / XmlReportRoles / Roles / RoleID};{As VCLib.GENERIC_REPORT_MENU_ITEM / Report / GenericReportRights / Roles / RoleID};{As VCLib.FILE_REPORT_MENU_ITEM / GenericReportFile / GenericReportFileRightss / Roles / RoleID};{As VCLib.SIMPLE_REPORT_MENU_ITEM / Report / Access / RoleID / RoleID};{As VCLib.EXPORT_DATA_MENU_ITEM / ExportData / ExportDataRoles / Roles / RoleID};{As VCLib.HELP_REPORT_MENU_ITEM/Help/AddDocumentLinkRoless/Roles/RoleID}" PathAttributes="{As VCLib.XML_REPORT_MENU_ITEM / XmlReport / XmlReportRoles / Roles};{As VCLib.GENERIC_REPORT_MENU_ITEM / Report / GenericReportRights / Roles};{As VCLib.FILE_REPORT_MENU_ITEM / GenericReportFile / GenericReportFileRightss / Roles};{As VCLib.SIMPLE_REPORT_MENU_ITEM / Report / Access / RoleID};{As VCLib.EXPORT_DATA_MENU_ITEM / ExportData / ExportDataRoles / Roles};{As VCLib.HELP_REPORT_MENU_ITEM/Help/AddDocumentLinkRoless/Roles}" />
  </CalculatingAttributes>
</Entity>