<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="RDS" 
Name="EXPORT_FRLLO_RECIPE" 
Description="Выгрузка данных в ФРЛЛО по рецептам" 
PrimaryKey="ExportFrlloRecipeID">
  <Fields>
    <Attribute Name="ExportFrlloRecipeID" Type="guid" Description="Идентификатор" />
    <Parent Name="Entities" Type="VCLib.ENTITIES" Description="Сущность метаданных" Required="1" />
    <Parent Name="Users" Type="RDS.USERS" Description="Пользователи системы" Required="1" />
    <Attribute Name="Condition" Type="text" Description="Фильтр" />
    <Attribute Name="ActualDate" Type="date" Description="Дата актуальности" Required="1" />
    <Child Name="ExportFrlloDatas" Type="RDS.EXPORT_FRLLO_RECIPE_DATA" Description="Выгруженные в ФРЛЛО данные" ChildAttribute="ExportFrlloRecipe" />
    <Choice Name="Status" Description="Статус" Required="1">
      <Item Name="Новый" Index="0" />
      <Item Name="Данные для выгрузки сформированы" Index="1" />
    </Choice>
    <Choice Name="DataType" Description="Тип" Required="1">
      <Item Name="Выписанные" Index="0" />
      <Item Name="Реализованные" Index="1" />
    </Choice>
    <Attribute Name="ItemsCount" Type="int" Description="Всего элементов" />
    <Attribute Name="SuccessItemsCount" Type="int" Description="Количество успешно загруженных элементов" />
    <Attribute Name="ErrorItemsCount" Type="int" Description="Количество элементов с ошибками" />
    <Attribute Name="RecipeCount" Type="int" Description="Количество рецептов" />
    <Child Name="FrlloMessages" Type="RDS.FRLLO_MESSAGE" Description="Сообщение в ФРЛЛО" ChildAttribute="ExportFrlloRecipe" />
    <Attribute Name="Unloaded" Type="bool" Description="Выгружена" Required="1" />
  </Fields>
  <DbMapping>
    <Table name="T_EXPORT_FRLLO_RECIPE">
      <Map Name="ExportFrlloRecipeID" Column="ExportFrlloRecipeID" />
      <Map Name="Entities" Column="Entities" />
      <Map Name="Users" Column="Users" />
      <Map Name="Condition" Column="Condition" />
      <Map Name="ActualDate" Column="ActualDate" />
      <Map Name="Status" Column="Status" />
      <Map Name="DataType" Column="DataType" />
      <Map Name="Unloaded" Column="Unloaded" />
    </Table>
    <Lexem>
      <Map Name="ItemsCount">
        <lx:QueryValue entity="RDS.EXPORT_FRLLO_RECIPE_DATA" top="-1" offset="0" hints="" xmlns:lx="lexem">
          <condition>
            <lx:Criteria type="And">
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="ExportFrlloRecipe" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepString name="ExportFrlloRecipeID" />
                </lx:Path>
              </lx:Criterion>
            </lx:Criteria>
          </condition>
          <value>
            <lx:LexemList>
              <lx:Count />
            </lx:LexemList>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="SuccessItemsCount">
        <lx:QueryValue entity="RDS.EXPORT_FRLLO_RECIPE_DATA" top="-1" offset="0" xmlns:lx="lexem">
          <condition>
            <lx:Criteria type="And">
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="ExportFrlloRecipe" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepString name="ExportFrlloRecipeID" />
                </lx:Path>
              </lx:Criterion>
              <lx:Criterion not="1" type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="FrlloStatus" />
                </lx:Path>
                <lx:ChoiceOperand Entity="RDS.EXPORT_FRLLO_RECIPE_DATA" AttributeName="FrlloStatus" type="Int32" PrimaryKey="400" />
              </lx:Criterion>
              <lx:Criterion not="1" type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="FrlloStatus" />
                </lx:Path>
                <lx:ChoiceOperand Entity="RDS.EXPORT_FRLLO_RECIPE_DATA" AttributeName="FrlloStatus" type="Int32" PrimaryKey="1" />
              </lx:Criterion>
            </lx:Criteria>
          </condition>
          <value>
            <lx:LexemList>
              <lx:Count />
            </lx:LexemList>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="ErrorItemsCount">
        <lx:QueryValue entity="RDS.EXPORT_FRLLO_RECIPE_DATA" top="-1" offset="0" xmlns:lx="lexem">
          <condition>
            <lx:Criteria type="And">
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="ExportFrlloRecipe" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepString name="ExportFrlloRecipeID" />
                </lx:Path>
              </lx:Criterion>
              <lx:Criterion not="1" type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="FrlloStatus" />
                </lx:Path>
                <lx:ChoiceOperand Entity="RDS.EXPORT_FRLLO_RECIPE_DATA" AttributeName="FrlloStatus" type="Int32" PrimaryKey="200" />
              </lx:Criterion>
              <lx:Criterion not="1" type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="FrlloStatus" />
                </lx:Path>
                <lx:ChoiceOperand Entity="RDS.EXPORT_FRLLO_RECIPE_DATA" AttributeName="FrlloStatus" type="Int32" PrimaryKey="208" />
              </lx:Criterion>
            </lx:Criteria>
          </condition>
          <value>
            <lx:LexemList>
              <lx:Count />
            </lx:LexemList>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="RecipeCount">
        <lx:QueryValue entity="RDS.RECIPE" top="-1" offset="0" hints="" xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="IN">
              <lx:Path OwnerQueryLevel="1">
                <lx:StepString name="ExportFrlloRecipeID" />
              </lx:Path>
              <lx:LexemList>
                <lx:QueryValue entity="RDS.RECIPE_ELEMENT" top="-1" offset="0" hints="">
                  <condition>
                    <lx:CriterionExists entity="RDS.EXPORT_FRLLO_RECIPE_DATA" top="-1" offset="0">
                      <condition>
                        <lx:Criteria type="And">
                          <lx:Criterion type="=">
                            <lx:Path OwnerQueryLevel="0">
                              <lx:StepString name="ObjId" />
                            </lx:Path>
                            <lx:Path OwnerQueryLevel="1">
                              <lx:StepString name="RecipeElementID" />
                            </lx:Path>
                          </lx:Criterion>
                          <lx:Criterion type="=">
                            <lx:Path OwnerQueryLevel="0">
                              <lx:StepString name="ExportFrlloRecipe" />
                            </lx:Path>
                            <lx:Path OwnerQueryLevel="3">
                              <lx:StepString name="ExportFrlloRecipeID" />
                            </lx:Path>
                          </lx:Criterion>
                        </lx:Criteria>
                      </condition>
                    </lx:CriterionExists>
                  </condition>
                  <value>
                    <lx:LexemList>
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepString name="Recipe" />
                      </lx:Path>
                    </lx:LexemList>
                  </value>
                </lx:QueryValue>
              </lx:LexemList>
            </lx:Criterion>
          </condition>
          <value>
            <lx:LexemList>
              <lx:Count />
            </lx:LexemList>
          </value>
        </lx:QueryValue>
      </Map>
    </Lexem>
  </DbMapping>
</Entity>