Template Studio: How to...

Posts   
 
    
Paddy
User
Posts: 20
Joined: 07-Jun-2007
# Posted on: 07-Jun-2007 22:45:11   

Hi,

I added some modifications to the EntityFactories template file (entityFactories.template) but when I run the preset (F7), I never see the changes reflected in the generated files.

What it is also extrange, is that even following the tutorial didn't work ("Creating a custom include template (TDL)"). I tried with several predefined Template IDs also but nothing seems to happen.

So I finally deleted the entityFactories.template file, press F7, and it continued to work! So where should I go to make the modifications?

I'm new to LLBL Gen (first day) so it is possible me but still... (I know I'm dumb, but not that much! smile )

Thank you.

LLBL Pro Gen Version: 2.0.0.0 Release: May 23rd 2007

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39833
Joined: 17-Aug-2003
# Posted on: 08-Jun-2007 12:00:45   

It is likely the 'feature' of vista which makes copies of files placed in the program files folder, which then all of a sudden are gone as they're copied to another folder by vista.

You should do the following. In LLBLGen Pro, load your project. Right click the project node and select 'properties'. Now, fill in a folder where you have write permissions, so for example c:\projects\mytemplates, for AdditionalTemplatesFolder.

Click OK and save the project.

Close the designer and start templatestudio. Load the project in template studio. As template studio knows the additional templates folder specified in the project, you can now save your templatebindings file in c:\projects\mytemplates and it will show up in template studio. Also, when loading the project in llblgen pro, it will also use that folder to obtain additional templates and bindings. This way you don't have to store the templates in program files.

A different approach, is to install llblgen pro in a folder other than program files.

Frans Bouma | Lead developer LLBLGen Pro
Paddy
User
Posts: 20
Joined: 07-Jun-2007
# Posted on: 08-Jun-2007 15:19:05   

Hi Otis,

Thank you for your patience smile

Ok, so maybe you assumed that I was using Vista because of the bug described in http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=10135 Well, I still got the problem so I'm using another computer to avoid any OS related problems.

I gave it a try anyway; I changed the additional path in the designer, I copied the templates there and re-tried but there is still no changes to the source generated code. To avoid "Human-Developer" error, I told a collegue to follow the tutorial in his computer; same result cry

So I know there must be something we didn't understand or a setup maybe. I'm used to CodeSmith so I expected to be as straigthforward as CS is.

I'm going to try to install it into another folder and see what happens...

Btw, I'm not planning on changing the code in the templates already shipped by you 'cause that will screw future updates (or bug fixes) from you. I just want to modify the EntityFactory Create's method to create a class that will inherit from the entity generated by llblgen; I want to create a separation layer between our code and your code so, first we don't mess up with your code in any way, and second if something doesn't work in the way we want we could make the changes there or completely switch to another O/R model without losing out business logic (but that would never happen wink )

Thank you very much for you time and sorry for nagging you so much (I hate when clients call for what it could be 'read-the-manual-first' question wink ).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39833
Joined: 17-Aug-2003
# Posted on: 08-Jun-2007 16:24:18   

No problem with the error reporting, just report the glitches you run into, we'll try to fix them.

Could you answer the following please? The CHANGED factory template, is that a different template FILE ? If so, is that bound to the SAME templateID as the normal factory template shipped with llblgen pro? If so, did you make this binding in a separate templatebindings file? If yes, did you move that bindings file ABOVE the default one in the list of bindings at tab two in the code generator dialog? If not, the standard one might overrule your bindings still (this mechanism lets you overrule template bindings using precedence of template bindings files).

Frans Bouma | Lead developer LLBLGen Pro
Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Jun-2007 16:24:38   

Btw, I'm not planning on changing the code in the templates already shipped by you 'cause that will screw future updates (or bug fixes) from you. I just want to modify the EntityFactory Create's method to create a class that will inherit from the entity generated by llblgen; I want to create a separation layer between our code and your code so, first we don't mess up with your code in any way, and second if something doesn't work in the way we want we could make the changes there or completely switch to another O/R model without losing out business logic

Why don't you use Manager Templates For BusinessLayer classes? Or Two-Class Presets to have Classes inheriting from the entityClasses?

  • Manager Templates: can be found in the 3rd party section in the downloads page.
  • Two-Class Presets: In the "Configure the code generation process" window, go to the third tab "Task queue to execute" -> Select the 2 class scenario from the "Select Preset" dropdown list.
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39833
Joined: 17-Aug-2003
# Posted on: 08-Jun-2007 16:25:23   

Also, I'll check if I can repro your 'I can't see any templatebindings' thing on vista.

Frans Bouma | Lead developer LLBLGen Pro
Paddy
User
Posts: 20
Joined: 07-Jun-2007
# Posted on: 08-Jun-2007 17:02:05   

Thanks for the rapid response,

so, to respond your question:

"The CHANGED factory template, is that a different template FILE?"

R: nope, it is the same that comes with llblgen; the one that is installed in Templates\SharedTemplates\Net2.x\C# (I'm changing this version).

This is what I thought should have worked:

  1. In TemplateStudio, TemplateBindings viewer I select SD.TemplateBindings.SharedTemplates.NET20

  2. From the list of templates I select then SD_EntityFactoriesTemplate and click "Edit selected files".

  3. In the editor I add, lets say:

using System.Collections;

  1. I save all, press F7 and generate the code.

So, I expected to see "using System.Collections;" in the new EntityFactories.cs file

It should have worked or I'm missing something?

Paddy
User
Posts: 20
Joined: 07-Jun-2007
# Posted on: 08-Jun-2007 17:08:25   

Hello Walaa,

"Why don't you use Manager Templates For BusinessLayer classes?" Cool! I had no idea that more template existed. I'll take a look, thanks!

"Or Two-Class Presets to have Classes inheriting from the entityClasses?" Yeah, I saw them (I did the template's Tutorial many times! wink ) it's just that I didn't have time to check them.

Paddy
User
Posts: 20
Joined: 07-Jun-2007
# Posted on: 08-Jun-2007 17:24:57   

ok, the Two-Class Presets seems to be what we want; it generates the factories also. Anyway, as we already have some of our business entities already coded (we are migrating) we are going to: need to edit the template to add custom to the subclass -or- directly inherit from your code and change the factories.

In both cases I'm going to need to modify the templates. Also, as we are supporting dynamic tables (i.e. we run some ALTER TABLE scripts in runtime) we will need to change -or- just add (via an association, we don't want to change llblgen source code much) some behavior to deal with this scenario.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39833
Joined: 17-Aug-2003
# Posted on: 08-Jun-2007 17:53:06   

That indeed should have changed the output. Can you check with notepad that the template file is indeed changed? (as vista might deny your changes) (llblgen pro install folder\templates\shared templates\Net2x\C# )

Frans Bouma | Lead developer LLBLGen Pro
Paddy
User
Posts: 20
Joined: 07-Jun-2007
# Posted on: 08-Jun-2007 19:06:54   

I found the problem! As we all presumed (me included) it was located between the keyboard and the chair! smile

The thing was that I changed the entityFactories.template file and then generated the code with template group Adapter. I don't know why, but I assumed that entityFactories_Adapter.template will generate an EntityFactories_Adapter.cs file so that's why I never used it (Duh!).

Well, after all my dad was right: I'm dumb.

Thank you and sorry for all the time I've taken from you. flushed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39833
Joined: 17-Aug-2003
# Posted on: 08-Jun-2007 21:48:18   

Paddy wrote:

I found the problem! As we all presumed (me included) it was located between the keyboard and the chair! smile

Let's blame Friday-itis instead wink

The thing was that I changed the entityFactories.template file and then generated the code with template group Adapter. I don't know why, but I assumed that entityFactories_Adapter.template will generate an EntityFactories_Adapter.cs file so that's why I never used it (Duh!).

Well, after all my dad was right: I'm dumb.

Thank you and sorry for all the time I've taken from you. flushed

hehe simple_smile Glad it's solved Paddy simple_smile

Frans Bouma | Lead developer LLBLGen Pro