Resource

Resource Basics

Resource Name Not Stacked OR Stacked without Top Item
Resource Version 1.01
Category Search Scripts
Downloads 598
Release Date 11/16/2022 9:28:07 PM
 

Resource Details

Description This script will return:
All images that are not in a stack, OR images that are in a stack without a top item
Installation Instructions na
Usage Instructions 1. In Photo Supreme, click the dropdown in the Tab Bar above the thumbs
2. Select From Repository and then this script
Changes in this version na
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

const
  cGUID = 'CEC535371C4A431690F5EAE1166554A8';

  procedure OpenNewTabForGroup(AGroup: TCatalogPropGroup);
  var
    AElem: TidElement;
  begin
    // delete results from a former run
    PublicCatalog.RemoveItemsFromTempList(AGroup.IncludeItems);

    // do search
    AElem := TidElement.Create(nil);
    try
      AElem.Prop['OpenNewTab'] := True;
      AElem.Data := AGroup;
      PublicBroadcast(nil, 'ShowGroupResults', AElem);
    finally
      AElem.Free;
    end;
  end;

  function MainFilter: WideString;
  begin
    result := 'select GUID ' +
              'from   idCatalogItem i ' +
              'where  coalesce(i.GroupGUID, '''') <> '''' ' +
              'and    not exists (select 1 from idCatalogItem i2 where i2.GroupGUID = i.GroupGUID and i2.GroupOrder = 0)  ' +
              'and    not exists (select 1 from idImageVersion i2 where i2.GroupGUID = i.GroupGUID and i2.GroupOrder = 0)  ' +
              'union all ' +
              'select GUID ' +
              'from   idImageVersion i ' +
              'where  coalesce(i.GroupGUID, '''') <> '''' ' +
              'and    not exists (select 1 from idCatalogItem i2 where i2.GroupGUID = i.GroupGUID and i2.GroupOrder = 0)  ' +
              'and    not exists (select 1 from idImageVersion i2 where i2.GroupGUID = i.GroupGUID and i2.GroupOrder = 0)  ' +
              'union all ' +
              'select GUID ' +
              'from   idCatalogItem i ' +
              'where  coalesce(i.GroupGUID, '''') = '''' ' +
              'union all ' +
              'select GUID ' +
              'from   idImageVersion i ' +
              'where  coalesce(i.GroupGUID, '''') = '''' ' +
              '';
    end;

var
  AGroup: TCatalogPropGroup;
  ADs: TDBXOMClientDataSet;
begin
  AGroup := TCatalogPropGroup.Create(nil);
  AGroup.GroupName := 'Not Stacked or Stacked without Top Item';
  AGroup.IncludeItems.GUID := cGUID;  // fix the GUID

  ADs := PublicCatalog.NewDataset;
  ADs.CommandText := 'select ' + PublicCatalog.FullColumnList('i.') + ' ' +
                     'from   v_catalogitem i ' +
                     'inner join (' + MainFilter + ') as f on f.GUID = i.GUID ' +
                     'UNION ALL ' +
                     'select ' + PublicCatalog.FullColumnList('i.') + ' ' +
                     'from   v_catalogitemversion i ' +
                     'inner join (' + MainFilter + ') as f on f.GUID = i.GUID ' +
                     '';
  ADs.LockType := ReadLockType;
  ADs.OpenSet;
  AGroup.IncludeItems.AddDataset(ADs, True);
  AGroup.IncludeItems.Disconnect;
  PublicCatalog.FreeDataset(ADs);

  OpenNewTabForGroup(AGroup);
end;