
/////////////////////////////////////////////////////////
//                                                     //
//              Bold for Delphi                        //
//    Copyright (c) 2003 Borland                       //
//                                                     //
/////////////////////////////////////////////////////////

{ Global compiler directives }
{$include bold.inc}
unit BoldDatabaseAdapterACR;

interface

uses
  ACRMain,
  BoldAbstractDataBaseAdapter,
  BoldDBInterfaces,
  BoldACRInterfaces;

type
  { forward declarations }
  TBoldDatabaseAdapterACR = class;

  { TBoldDatabaseAdapterACR }
  TBoldDatabaseAdapterACR = class(TBoldAbstractDatabaseAdapter)
  private
    fBoldDatabase: TBoldACCDataBase;
    procedure SetDataBase(const Value: TACRDatabase);
    function GetDataBase: TACRDatabase;
  protected
    procedure ReleaseBoldDatabase; override;
    function GetDataBaseInterface: IBoldDatabase; override;
  public
    destructor destroy; override;
  published
    property DataBase: TACRDatabase read GetDataBase write SetDataBase;
    {$IFNDEF T2H}
    property DatabaseEngine;
    {$ENDIF}
  end;
{$R *.dcr}
implementation

uses
  SysUtils,
  BoldDefs,
  BoldRev;

{ TBoldDatabaseAdapterACC }      

destructor TBoldDatabaseAdapterACR.destroy;
begin
  Changed;
  FreePublisher;
  FreeAndNil(fBoldDatabase);
  inherited;
end;

function TBoldDatabaseAdapterACR.GetDataBase: TACRDatabase;
begin
  result := InternalDatabase as TACRDatabase;
end;

function TBoldDatabaseAdapterACR.GetDataBaseInterface: IBoldDatabase;
begin
  if not assigned(Database) then
    raise EBold.CreateFmt('%s.GetDatabaseInterface: The adapter is not connected to a database', [classname]); 
  if not assigned(fBoldDatabase) then
    fBoldDatabase := TBoldACCDataBase.create(Database, SQLDataBaseConfig);
  result := fBoldDatabase;
end;

procedure TBoldDatabaseAdapterACR.ReleaseBoldDatabase;
begin
  FreeAndNil(fBoldDatabase);
end;

procedure TBoldDatabaseAdapterACR.SetDataBase(const Value: TACRDatabase);
begin
  SqlDataBaseConfig.ColumnTypeForBlob := 'BLOB';
  SqlDataBaseConfig.ColumnTypeForCurrency := 'CURRENCY';
  SqlDataBaseConfig.ColumnTypeForDate := 'DATE';
  SqlDataBaseConfig.ColumnTypeForDateTime := 'DATETIME';
  SqlDataBaseConfig.ColumnTypeForInteger := 'INTEGER';
  SqlDataBaseConfig.ColumnTypeForSmallInt := 'INTEGER';
  SqlDataBaseConfig.ColumnTypeForString := 'VARCHAR(%D)';
  SqlDataBaseConfig.ColumnTypeForFloat := 'FLOAT';
  SqlDataBaseConfig.ColumnTypeForTime := 'TIME';
  SqlDataBaseConfig.QuoteNonStringDefaultValues := True;
  InternalDatabase := value;
end;

initialization

end.