Entities generator

Issue #218 closed
Rodrigo Farias Rezino created an issue

I saw in marshmellow wiki that they have an entity generator. Do someone know where can I find it ?

code.png

Comments (3)

  1. Stefan Glienke repo owner

    See #75 - Todd offered his (or his coworkers) help but I did not hear anything from them again after.

  2. Francisco Armando DueƱas Rodriguez

    Hi, Hope Todd could do something with this, If not I Have the sources of Marshmallow's entity generator (dated 2013-09-12), I think those are the latest sources shared as Marshmallow ORM, we only have to change the used unitd to get ti working with latest Sprint4D, I can share it here.

    I Haven't used Spring4D yet, because of lack of time. But I have followed Stefan's work time ago.

    Here is the link for downloading the sources and exe: Obviously it generates the unit using Marshmellow's unit names https://drive.google.com/open?id=0B-63npOppyMianhGSnV0VG85WjQ

    If some can help us will be great. I will have spare time the next week so I can take a look on that.

    just an additional comment, Time ago I have used an opensource Database Designer for MySQL, it was made in Delphi 7 /Kylix, It is the predecessor of Modern MySQL WorkBench (Before they screwed it up and made it in .NET :P), It has Diagraming tools and a lot of stuff, That maybe can be a good start of a Visual entity designer .

    Sources where realeased under GNU General Public License.

    [SecreenShot] http://fabforce.eu/dbdesigner4/screenshot_image.php?screenshot=dbd4_ss_simplemodel.png dbd4_ss_simplemodel.png

    [Download Section] http://fabforce.eu/downloads.php

    Obviously the download link is broken.

    But I have downloaded the sources time ago, here links from my GoodleDrive account: DBDesigner 4.0.5.6 - Sources DBDesigner 4.0.5.6 - Installer

  3. Cesar Romero

    I have played with marshmellow generator before, but I choose another way more flexible, I wrote a tool using mustache template engine to process database metadata in json format. Right now, in a rustic form, I have it all done for PostgreSQL, since PostgreSQL has native JSON support, I can extract all database metadata and process in one pass.

    My plan for near future is to use FireDAC to extract metadata and generate the JSON, then it will make easy to do the same for any database.

    I have used this tool in other projects in my company, and it was also usefull for Java and C# projects.

    If anyone has interest in this tool, I can make it public and start to improve ASAP.

    This is how a template looks like, using this approach, I can customize my code generation without recompile the project.

    unit Persistence.Entity;
    
    interface
    
    uses
      System.Classes,
      Spring,
      Spring.Persistence.Mapping.Attributes,
      Persistence.Consts;
    
    type{{#tabelas}}
      TCommon{{& entity_name}} = class(TObject)
      strict private{{#colunas}}  
        F{{& attribute_name}}: {{#is_nullable}}Nullable<{{/is_nullable}}{{& data_type}}{{#is_nullable}}>{{/is_nullable}};{{/colunas}}
      protected{{#colunas}}  
        property {{& attribute_name}}: {{#is_nullable}}Nullable<{{/is_nullable}}{{& data_type}}{{#is_nullable}}>{{/is_nullable}} read F{{& attribute_name}} write F{{& attribute_name}};{{/colunas}}  
      end;
    
      [Entity]
      [Table({{& table_name_const}}, {{& table_schema_const}})]{{#sequences}} 
      [Sequence({{& sequence_name_const}}, 1, 1)] {{/sequences}}
      T{{& entity_name}} = class(TCommon{{& entity_name}})
      public{{#colunas}} 
        {{#-first}}[AutoGenerated]{{/-first}} 
        [Column({{& column_name_const}}, [{{#-first}}cpPrimaryKey, {{/-first}}{{^is_nullable}}cpRequired{{/is_nullable}}]{{#size}}, {{& size}}{{/size}})]
        property {{& attribute_name}};{{/colunas}}  
      end;
    {{/tabelas}}
    
    implementation
    
    end.
    

    And this is the output class

      TCommonProxy = class(TVersionedEntity)
      strict private
        FEndereco: string;
        FPorta: Integer;
        FUsuario: Nullable<string>;
        FSenha: Nullable<string>;
      protected
        property Endereco: string read FEndereco write FEndereco;
        property Porta: Integer read FPorta write FPorta;
        property Usuario: Nullable<string> read FUsuario write FUsuario;
        property Senha: Nullable<string> read FSenha write FSenha;
      end;
    
      [Entity]
      [Table(WEB_PROXY_TABLE, CENTRALDF_SCHEMA)]
      [Sequence(WEB_PROXY_PROXY_ID_SEQ, 1, 1)]
      TProxy = class(TCommonProxy)
      public
        [AutoGenerated]
        [Column(PROXY_ID_COL, [cpPrimaryKey, cpRequired])]
        property Id;
    
        [Column(ENDERECO_COL, [cpRequired], 100)]
        property Endereco;
    
        [Column(PORTA_COL, [cpRequired])]
        property Porta;
    
        [Column(USUARIO_COL, [], 50)]
        property Usuario;
    
        [Column(SENHA_COL, [], 50)]
        property Senha;
    
        [Column(ACTIVE_COL, [cpRequired])]
        property Active;
    
        [Column(CREATED_COL, [cpRequired])]
        property Created;
    
        [Column(UPDATED_COL, [])]
        property Updated;
      end;
    
  4. Log in to comment