Giter Site home page Giter Site logo

mvc_ar_entitygenerator's Introduction

MVC ActiveRecord Entity Generator (by senCille)

Tired of creating the descendants of TActiveRecord by hand?

https://github.com/juanccilleruelo/MVC_AR_EntityGenerator Is an OpenSource project developed in Delphi XE 12 that takes the metadata of your Database and creates one class ActiveRecord of each Table in the Database.

You can generate the AR of one table or one AR class for each table in the Database. You can indicate in which folder the AR file should be deployed, and the program will remember it. Each AR is generated in an independent .pas file.

And this is only the Beta version.

You save all the information used to generate the AR; when you need to develop it again, you only need to use it.

In the next version, we plan to implement more types of AR, like, for example, AR with a Master-Detail Relationship.

In the current version, you can change the name of the Class generated. This is useful when you want, for example, the AR class representing one member of the entity Customers, instead of being named TCustomers, to be named TCustomer; that is more accurate.

I want to implement, too, a connection with the AI (probably Chat-GPT) to ask directly for the translation of the plural table names to singular class names. In this target, I want the AI to modify the table name to respect the Camel Style of Pascal Class names. For example, a table named Items_Owned_by_user is currently created as TItemsownedbyuser. The AI can easily convert this to TItemsOwnedByUser, which is more accurate to the style of Pascal code.

And many more things can be made with an open-source project. Do you don't think it!!

Try it, and let us know what you think!

Thanks

PD: The project is also an excellent example of using SQLite as a memory store for the data and treating this data as a standalone project, in contrast to the concept of a Database on Disk, which is more current in Delphi.

Woring in progress...

Road Map

1- Improve the modifications that the user can make to generate the ActiveRecord. (Eg: The name of the properties or the data type) Sometimes, with SQLite databases, the data type suggested by the application is not the most appropriate for the program. Ref: Dynamic Type System of SQLite.

2- Implement how we are going to manage the modifications in the Real DB after we modified his data in the program. (if a field disappeared, if there is a new field on DB or if a field definition has been modified)

2- Use of OpenAI IA connection for things like GetSingular Names for the entities and convert the names of the fields to Camel Style (Pascal).

mvc_ar_entitygenerator's People

Contributors

juanccilleruelo avatar

Stargazers

Mohamed BENAMMAR avatar Stefaan Lesage avatar abdollah nouri avatar  avatar Yosof avatar Ali Dehbansiahkarbon avatar  avatar Dmitry Shumko avatar  avatar  avatar

Watchers

Yosof avatar  avatar  avatar  avatar

mvc_ar_entitygenerator's Issues

Firebird 3 Recordcount for large view > 50 Fields is not working correct & Improvement TMain.SetOnViewDataFromMemory

Hola Juan,

this is a cool project. Congratulations. I tested the Version (2024-01-16 09:00) with Delphi 12 and Firebird 3.0.9.

Maybe there is a problem with TFDMetaInfoQuery Component. It doesnt returned the correct Recordcount for large view > 50 Fields.

My Suggestion (which works fine for FB3):

function TARGeneratorController.GetUniqueIdentifiers(const MetaData           :TFDMetaInfoQuery;
                                                     const FormatAsPascalCase :Boolean): TArray<string>;
var
    List      :TStringList;
    Field     :string;
    FTemp     :string;
    Count     :Integer;
    FieldName :string;
begin
   MetaData.First;
   List := TStringList.Create;
   try
      List.Sorted := True;
      while not MetaData.EOF do begin
         FieldName := MetaData.FieldByName(META_F_COLUMN_NAME).AsString;

         if FormatAsPascalCase then
            Field := CamelCase(FieldName, True)
         else Field := FieldName;

         {if the Field exists previously...}
         if List.IndexOf(Field) > -1 then Field := FieldName;
         FTemp := Field;

         {If the FieldName is a Pascal Reserved keyword...}
         if IsReservedKeyword(FTemp) then begin
            FTemp := '_' + FTemp;
         end;

         {Add a number at the end of field number to assure the FieldName is Unique}
         Count := 0;
         while List.IndexOf(FTemp) > -1 do begin
            Inc(Count);
            FTemp := Field + '_' + IntToStr(Count);
         end;

         Field := FTemp;
         List.Add(Field);

         MetaData.Next;
      end;

      SetLength(Result, List.Count);
      Result := List.ToStringArray;

   finally
      List.Free;
   end;
end;

and I had to open the MemTables to make Controller.FillViewData work.

procedure TMain.SetOnViewDataFromMemory;
begin
   {Fill with data from Database}
   dsTables.DisableControls;
   dsFields.DisableControls;
   dsTables.Active := true;
   dsFields.Active := true;
   try
      Controller.FillViewData(dsTables, dsFields);
      TabSheetTables.Caption := 'Tables (' + dsTables.RecordCount.ToString + ')';
   finally
      dsTables.EnableControls;
      dsFields.EnableControls;
   end;
end;

Saludos
HP

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.