Toad World® Forums

Entity custom properties

Good afternoon, we’d like to set additional properties to Model Entity, so that we can use them later when we create our object from Model itself: for example the information if a field can be modified by application or by scripting.

Is there a chance to do this ?

Thanks a lot in advance for any help

Jackomino

Hello Jackomino,

You can add new custom properties to objects in TDM, though is it a bit complex. For example, see how you can add a new custom "ScriptingModifiable" property to entity:

  1. Enable Expert Mode inside TDM. This option can be found in Settings Menu | Options | General | Expert Mode.

MetaModel1.png

  1. Now go to Expert Mode Menu | Customization | **New Custom Package...

MetaModel2.png**

  1. In General Tab, enter whatever name you want. Then switch to Package Extension tab. Now, for which databases do you want to create the custom property?

One specific database
Select the specific database Package (e.g. Database Oracle 10g)
Entire database platform
Select the database platform Package (e.g. Database Oracle)
All databases
Select Physical Entity Relationship Model
In this case I'll create the custom property for all Oracle databases.

3757.MetaModel3.png

  1. Create the Package by clicking OK and then restart TDM.
  2. Go to Expert Mode Menu | Customization | **Package Explorer. **Find your custom Package (you can hide all system Packages using a button on Project Explorer toolbar), right-click it and choose Open Metamodel.

MetaModel4.png

  1. Create a new Class via Model Objects toolbar.
    4331.MetaModel5.png

  2. Double-click the created Class to open its Class Properties. In General tab, fill in the following fields:
    Name - Depends on the Package you extended before. For example:

Database Oracle 10g
PEREntityOR10
Database Oracle
PEREntityOR
Physical Entity Relationship Model
PEREntity
These are class names that can be found in Reference Guide (Expert Mode Menu)
Caption - Enter anything you want
Object Type - Set it to 2002, that is Entity (Object Type numbers can be found in Reference Guide as well).

  1. Switch to Properties tab and Add a new Property.
  2. Double-click the Property to open its Property Properties. In General tab, enter any Name, Caption and Data Type you want (I'll use Boolean in this example) and check the External option.

  1. Switch to Attributes tab and check Editable and Store attributes (Editable attribute allows you to change the property value in forms and Store attribute ensures storing the property value on disc).

  1. Save all changes and restart TDM.
    Your custom property is now available and ready for use. To verify this, follow these steps:

  2. Create a new model (any Oracle model in our case) and create a blank Entity.

  3. Go to Expert Mode Menu and choose **Scripting Window.

5811.MetaModel9.png**

  1. In Scripting Window move your Oracle model to the Selected Objects (to the right).
  2. Now write the same code as on the screenshot below:

MetaModel10.png

  1. Execute the script using button on Scripting Window toolbar and you should see this result in **Message Explorer:

MetaModel11.png**

  1. If you see the same result, your custom property is configured correctly and you may continue.
    Now that you have verified that your custom property works, it would be useful to put it somewhere into UI, so you can change its value for each Entity graphically and not by scripting.

  2. Open Entity Properties (in any Oracle model in our case), right-click anywhere and choose Customize form As... (if this option is disabled, go to Settings Menu | Options | Expert Mode and uncheck the Save the definitions to the 'My Package' option.

  1. From Package List choose your custom Package.

MetaModel13.png

  1. Once you confirm the selection, the Entity Properties form will switch to editable mode and four other windows will be displayed.
  2. Let's create a new tab for the custom property. Right-click any of the existing tabs and choose New Page.

  1. Switch to the new tab/page. Now click on DataCheckBox in Component Palette and then click anywhere in the form (we use CheckBox since our custom property is Boolean). Now we need to edit a few properties in Component Inspector.

  1. Make sure you have got the CheckBox in your form selected and edit the following properties:
    Name - Enter anything you want, has to be unique
    Caption - Enter the checkbox caption
    DataField - Set to your Property Name (step 9), which is ScriptingModifiable in our case
    DataSource - Set to Entity

  1. Exit form editable mode by clicking the cross in upper-right corner of the form.

  1. Finally, right-click anywhere in the form and choose Save Form to User Package Name (ScriptingModifiable).


Now you can start using your custom property in UI. You can check its functionality by checking it in Entity Properties and then running the code mentioned above. This time, you should get the following result:

You might want to know that we currently plan to simplify the entire process a lot by implementing direct support for custom user properties. However, it is not sure if this improvement will be implemented in the next version of Toad Data Modeler.

Regards,

Lukas

Thanks a lot for your answer, we’ll try to implement it

We’ll let you know the result :wink:

Hello, I followed this guide and successfully created a custom property for “PERAttribute”.

I created a tab page in the Entity edit form, with a Grid View that show me the property for all entity’s attributes.

I also created a macro that successfully access this custom property to do some checks.

Then I copied the package.txg (plus Metamodels/package.txm) to another Toad installation.

When I launch the macro, Toad hangs forever.

If I copy the very same code in the scripting window, it executes fine!

Moreover, if I comment out the code that access the custom property, and save the modified macro, it runs fine.

What could it be the problem?

Hi Tommaso,

Try looking into MyPackage, there might be something stored in it that should be part of the package.txm and therefore is missing in the other installation.

You can also tell us the version of the two installations and send us the package (use my email - lukas.knapek@quest.com) and we will look into it.

Regards,

Lukas

Hi Lukas,

unfortunately I also checked my MyPackage and it seems to be completely empty.

This is the Ascii content:

<?xml version="1.0" encoding="utf-8"?>

{557B2EB1-4B4F-40A8-9E75-073862035409}

My Package

0

0

0

0

0

0

0

For future reference:

I found the culprit. It was the model itself.

Opening a model without the attribute’s custom property set (on the second installation) caused Toad to fill it with random values for some tables (really big integers, instead of 0).

Manually modifying the TXP, substituting \d+ with 0 fixed the issue.

I found that Toad fills the custom property with nearly random values (0, 19, 1852399986, -16777196) for new tables or fields.

I see I forgot to set a default for the property, so now I modified the metamodel and set “0” as default. I’ll keep you up-to-date about that.