воскресенье, 12 апреля 2026 г.

m3AndQueryExecutor

{$IfDef FPC}{$CodePage cp1251}{$EndIf FPC}

unit m3AndQueryExecutor;

// --------------------------------------------------------------------------
// Родители: "Queries" <> MUID: (66FB115B029F) :: "m3" <> MUID: (66FB10950007) :: "Shared Delphi For Archi" <> MUID: (4ABA2360025A)
// --------------------------------------------------------------------------
// Модуль: "w:\common\components\rtl\Garant\m3\m3AndQueryExecutor.pas" GeneratorVersion: 1.0.0.883901
// Стереотип: "<>"
// Элемент модели: "Tm3AndQueryExecutor" MUID: (670641300230)
// --------------------------------------------------------------------------

//#UC START# *670641300230BeforeDefines*
//#UC END# *670641300230BeforeDefines*
{$Include daDefine.inc}

interface

uses
 l3IntfUses
 , daAndQueryParams
 , m3QueryInterfaces
 , daQueryParams
 , l3Ranges
 , m4SearchResult
 , m3AttrIndexInterfaces
 , daQueryInterfaces
 , daEnumerableInterfaces
 , l3Interfaces
 , l3LongintList
 , daTypes
 , evdDATypes
 , daAbstractQueryExecutor
;

type
 {$If not Defined(_ParamsType_Defined_) }
  {Tm3AndQueryExecutor.}_ParamsType_ = TdaAndQueryParams;
  {$Define _ParamsType_Defined_ }
  {$Define _ParamsType_IsClass_ }
  {$Define _ParamsType_IsAcceptableForScripts_ }
 {$IfEnd} // not Defined(_ParamsType_Defined_)
 {$Include Mm3QueryExecutor_imp.pas}
 Tm3AndQueryExecutor = class(_Mm3QueryExecutor_)
  private
   f_TextExecutor: Im3QueryExecutor;
  protected
   function FindByParams(const aParams: TdaAndQueryParams;
    const aSearcher: Im3AttrIndexSearcher): Il3RangeEnumerable; override;
   procedure DoDropResult; override;
   function DoGetAddressList: Tm4SearchResult; override;
   procedure ClearFields; override;
  public
   {$If NOT Defined(l3NoSRT)}
   function SetRefTo(var thePlace: Tm3AndQueryExecutor): Boolean; overload; {$If Defined(l3HasInl)}inline;{$IfEnd}
   {$IfEnd} // NOT Defined(l3NoSRT)
   class function ParamClass: TdaQueryParamsClass; override;
 end;//Tm3AndQueryExecutor

implementation

uses
 l3ImplUses
 , daTextQueryParams
 , m3QueryResultSetFromLongintList
 , daQueryExecutorFactory
 , m3AttrIndexSearcher
 , SysUtils
 , l3Enumerators
 , l3InterfacedIntegerList
 , k2Tags
 //#UC START# *670641300230impl_uses*
 //#UC END# *670641300230impl_uses*
;

{$Include Mm3QueryExecutor_imp.pas}

{$If NOT Defined(l3NoSRT)}
function Tm3AndQueryExecutor.SetRefTo(var thePlace: Tm3AndQueryExecutor): Boolean;
begin
 if (thePlace = Self) then
  Result := false
 else
 begin
  Result := true;
  thePlace.Free;
  thePlace := Self.Use;
 end;//thePlace = Self
end;//Tm3AndQueryExecutor.SetRefTo
{$IfEnd} // NOT Defined(l3NoSRT)

function Tm3AndQueryExecutor.FindByParams(const aParams: TdaAndQueryParams;
 const aSearcher: Im3AttrIndexSearcher): Il3RangeEnumerable;
//#UC START# *670660CF0357_670641300230_var*
(*var
 I : Integer;
 l_Executor: IdtQueryExecutor;*)
var
 l_Executor : Im3QueryExecutor;
 l_Found : Il3RangeEnumerable;
 l_Index : Integer;
//#UC END# *670660CF0357_670641300230_var*
begin
//#UC START# *670660CF0357_670641300230_impl*
 Result := nil;
 f_TextExecutor := nil;
 if (aParams.QueryList.Count = 0) then
  Result := aSearcher.AllDocuments
  //f_Sab := MakeEmptySab(Get_MainTblPhoto)
 else
 begin
  l_Executor := Self.MakeIntExecutor(aParams.QueryList.Items[0].Query);

  if aParams.QueryList.Items[0].Query is TdaTextQueryParams then
   f_TextExecutor := l_Executor;

  Result := l_Executor.Find;
  if (aParams.QueryList.Count = 1) then
  begin
   Exit;
  end;//aParams.QueryList.Count = 1

  for l_Index := 1 to Pred(aParams.QueryList.Count) do
  begin
   l_Executor := Self.MakeIntExecutor(aParams.QueryList.Items[l_Index].Query);
   if (f_TextExecutor = nil) and (aParams.QueryList.Items[l_Index].Query is TdaTextQueryParams) then
    f_TextExecutor := l_Executor;
   l_Found := l_Executor.Find;
   if (l_Found = nil)
      OR l_Found.Empty then
   begin
    //Assert(false);
    // - пересечение с пустым множеством это что?
    Result := nil;
    break;
    // пересечение это общие элементы обоих множеств = пусто
   end//l_Found = nil
   else
   begin
    Result := Il3RangeEnumerable_Intersect(Result, l_Found);
    if (Result = nil)
       OR Result.Empty then
     break;
     // - нет смысла дальше искать
   end;//l_Found = nil
  end;//for l_Index

(*  l_Executor := TdtQueryExecutorFactory.Instance.MakeIntExecutor(aParams.QueryList.Items[0].Query);
  if aParams.QueryList.Items[0].Query is TdaTextQueryParams then
   f_TextExecutor := l_Executor;
  l_Executor.MainTblPhoto := Get_MainTblPhoto;
  f_Sab := MakeSabCopy(l_Executor.FoundListSab);
  l_Executor.DropResult;
  for I := 1 to Pred(aParams.QueryList.Count) do
  begin
   if not f_Sab.IsEmpty then // если у нас пустой результат,
   begin
    l_Executor := TdtQueryExecutorFactory.Instance.MakeIntExecutor(aParams.QueryList.Items[I].Query);
    if (f_TextExecutor = nil) and (aParams.QueryList.Items[I].Query is TdaTextQueryParams) then
     f_TextExecutor := l_Executor;
    l_Executor.MainTblPhoto := Get_MainTblPhoto;
    f_Sab.AndSab(l_Executor.FoundListSab);
    l_Executor.DropResult;
   end
   else
    if (f_TextExecutor = nil) and (aParams.QueryList.Items[I].Query is TdaTextQueryParams) then
     f_TextExecutor := TdtQueryExecutorFactory.Instance.MakeIntExecutor(aParams.QueryList.Items[I].Query);
  end;*)
  //Assert(false);
 end;//aParams.QueryList.Count = 0
//#UC END# *670660CF0357_670641300230_impl*
end;//Tm3AndQueryExecutor.FindByParams

class function Tm3AndQueryExecutor.ParamClass: TdaQueryParamsClass;
//#UC START# *5EEB473B012C_670641300230_var*
//#UC END# *5EEB473B012C_670641300230_var*
begin
//#UC START# *5EEB473B012C_670641300230_impl*
 Result := inherited ParamClass;
//#UC END# *5EEB473B012C_670641300230_impl*
end;//Tm3AndQueryExecutor.ParamClass

procedure Tm3AndQueryExecutor.DoDropResult;
//#UC START# *5F148B0D0239_670641300230_var*
//#UC END# *5F148B0D0239_670641300230_var*
begin
//#UC START# *5F148B0D0239_670641300230_impl*
 inherited;
 f_TextExecutor := nil;
//#UC END# *5F148B0D0239_670641300230_impl*
end;//Tm3AndQueryExecutor.DoDropResult

function Tm3AndQueryExecutor.DoGetAddressList: Tm4SearchResult;
//#UC START# *670F8AF6026D_670641300230_var*
//#UC END# *670F8AF6026D_670641300230_var*
begin
//#UC START# *670F8AF6026D_670641300230_impl*
 if (f_TextExecutor = nil) then
  Result := nil
 else
  Result := f_TextExecutor.AddressList;
//#UC END# *670F8AF6026D_670641300230_impl*
end;//Tm3AndQueryExecutor.DoGetAddressList

procedure Tm3AndQueryExecutor.ClearFields;
begin
 f_TextExecutor := nil;
 inherited;
end;//Tm3AndQueryExecutor.ClearFields


//#UC START# *670641300230forDiagramm*
(*
*)
//#UC END# *670641300230forDiagramm*

end.

Комментариев нет:

Отправить комментарий