Chatee ahora con Soporte
Chat con el soporte

Toad Data Modeler 7.2 - User Guide

Introduction User Interface Models and Model Objects
Physical Data Model
Entity Relationship Diagram Objects Basic Database Design Advanced Database Design
Universal Data Model Logical Data Model Working with Model Objects
Features and Tools
Application Variables Export/Import DDL Script Generation Graphics Model Actions Print Create New Project Reports Reverse Engineering Scripting and Customization About Templates Tips and Tricks Toad for Oracle Integration Toad Intelligence Central (TIC) Integration Tools Version Control
Options and Configuration Databases
Amazon Redshift 1.0 IBM DB2 LUW 9.5 IBM DB2 LUW 9.7 IBM DB2 LUW 10.1 IBM DB2 LUW 10.5 IBM DB2 LUW 11.1 IBM DB2 z/OS 10 IBM DB2 z/OS 11 Greenplum 4.1 Greenplum 4.2 Ingres 9.3 Ingres 10.0 EDB Postgres Advanced Server 10 Microsoft Access 2007/2010 Microsoft Azure SQL Database V12 Microsoft SQL Server 2005 Microsoft SQL Server 2008 Microsoft SQL Server 2012 Microsoft SQL Server 2014 Microsoft SQL Server 2016 Microsoft SQL Server 2017 Microsoft SQL Server 2019 MySQL 5.0 MySQL 5.1 MySQL 5.5 MySQL 5.6 MySQL 5.7 MySQL 8.0 Oracle 10g Oracle 11g Release 1 Oracle 11g Release 2 Oracle 12c Release 1 Oracle 12c Release 2 Oracle 18c Oracle 19c PostgreSQL 9.0 PostgreSQL 9.1 PostgreSQL 9.2 PostgreSQL 9.3 PostgreSQL 9.4 PostgreSQL 9.5 PostgreSQL 10 PostgreSQL 11 PostgreSQL 12 SQLite 3.7 Sybase ASE 15.5 Sybase ASE 15.7 SAP ASE 16.0 Sybase IQ 15.2 Sybase SQL Anywhere 11 SAP SQL Anywhere 17 Teradata 13 Vertica Database 8.0
Copyright Legal Notices

Samples for Message Dialogs

Samples for Message Dialogs:

ShowMessageDialog

System.ShowMessageDialog(1004,'WarningDialog','Please select shapes on your Workspace before running the macro.',2,4);

Dialog type index

0 - warning

1 - error

2 - info

3 - confirm

4 - no icon

Dialog buttons index

0 - no button

1 - yes

2 - no

3 - yes/no

4 - ok

5 - yes/ok

6 - no/ok

7 - yes/no/ok

8 - cancel

9 - yes/cancel

10 - no/cancel

11 - yes/no/cancel….

ShowMessageDialogScript

This way you can create dialog with hyperlinks at the bottom.

var DlgParams = System.CreateObject('DialogParams');

DlgParams.Caption = 'Add Entities Info';// Name appears in Settings | Options in section Dialog Boxes.

DlgParams.DialogIndex = 202; // Unique number, must be above 200

DlgParams.Msg = 'This macro allows you to quickly add entities to your model. Specify one entity caption per line. ';

DlgParams.Msg += 'Spaces in entity captions can be converted to entity names as underscore characters. ';

DlgParams.Msg += 'For more infomation click the Help link at bottom. Do you wish to continue?';

DlgParams.Buttons = 3;

DlgParams.DlgType = 2;

DlgParams.HyperLink = 'http://www.casestudio.com/help/ProductivityPack.aspx';

DlgParams.HyperLinkCaption = 'Help';

DlgParams.ScriptName = 'AddEntitiesMacro';

if(System.ShowMessageDialogScript(DlgParams) != 6)

{

return;

}

Access Property Values via Scripting

You can write scripts inToad Data Modeler , save the scripts to packages, distribute the packages etc. - This will be explained later. Now you will see how to work with Scripting Window that allows you to run scripts at once, without the necessity to have them stored in packages.

Click Expert Mode | Scripting Window to open it. (Of course, Expert Mode has to be turned on.)

The following dialog appears. If you don't see the upper part of the Scripting Window, select View | Show Registered Objects.

On the left, you can see available models. Use the arrows to select model you want to work with. In our example, we will execute script for Videorental model (for Oracle 10g).

In the Name in Script column, you can define name that will be used in the script. Our OrigModel value will represent the selected Videorental model.

Write script to the main() function.

Code:

function main(){

 

  var i, e;  

  var Ent;

  var EntListConfirmed = new Array();

  var EntListNotConfirmed = new Array();

 

  // iterate through entities and check the value of ConfirmedByCustomer property    

  for (i=0; i<OrigModel.Entities.Count; i++)

  {

         

          Ent = OrigModel.Entities.GetObject(i);

          if(Ent.ConfirmedByCustomer == true)

            EntListConfirmed[EntListConfirmed.length] = Ent.Name; // add to list of confirmed entities

          else    

            EntListNotConfirmed[EntListNotConfirmed.length] = Ent.Name; // add to list of not confirmed entities

  }

       

  // write list of confirmed entities to Log.

  Log.Information ("--------------------------------------");

  Log.Information ("List of entities confirmed by customer");

  Log.Information ("--------------------------------------");

  for (e=0; e<EntListConfirmed.length; e++)

  {

    Log.Information(EntListConfirmed[e]);

  }

  Log.Information ("# Number of confirmed entities: "+EntListConfirmed.length.toString());

       

  // write list of NOT confirmed entities to Log.  

  Log.Information ("--------------------------------------");

  Log.Information ("List of entities NOT confirmed by customer");

  Log.Information ("--------------------------------------");

  for (e=0; e<EntListNotConfirmed.length; e++)

  {

    Log.Information(EntListNotConfirmed[e]);

  }  

  Log.Information ("# Number of NOT confirmed entities: "+EntListNotConfirmed.length.toString());

 

}

Where to find information about objects and their properties and methods?

Explanation of Items in Bold:

OrigModel.Entities.Count

  • OrigModel - represents object assigned in the upper part of the Scripting Window (Videorental object renamed to OrigModel).


  • Entities - we work with Physical Entity Relationship model, therefore we need to search for PER object. Model is for Oracle 10g, let's find the PERModelOR10 object in the Reference.

  • Count - represents a feature that is available for all List objects. On the screenshot above, you can see that the Entities datatype is a List. Let's click the List link and see details of the List class.

OrigModel.Entities.GetObject(i)

  • GetObject - belongs to the List class.

Ent.ConfirmedByCustomer

  • Ent - is a variable that holds assigned Entity objects (assigned earlier using the OrigModel.Entities.GetObject(i)function).
  • ConfirmedByCustomer - property of PEREntityOR10 object, added to Metamodel of the CustomerFeedback package.

Ent.Name

  • Ent - is a variable that holds assigned Entity objects (assigned earlier using the OrigModel.Entities.GetObject(i)function).
  • Name - property of PEREntityOR10 object. We still work with PER model and now we need to find property of Entity in Oracle 10g model. Let's see properties of the PEREntityOR10 object.

.length and .toString()

  • both are standard JavaScript items.

Executing the Script

Click Execute Script. Result will be displayed in the Message Explorer and Log area.

For more information, see Create Script.

File System Scripts

You can create new files or folders using simple javascript code.

function CreateFolder(folder)

{

var fso;

fso = new ActiveXObject("Scripting.FileSystemObject");

fso.CreateFolder (folder);

}

 

function CopyFolder(sourceFolder, destinationFolder, overwrite)

{

var fso;

fso = new ActiveXObject("Scripting.FileSystemObject");

fso.CopyFolder (sourceFolder, destinationFolder, overwrite);

}

 

function CopyFile(sourceFile, destinationFile)

{

var fso;

fso = new ActiveXObject("Scripting.FileSystemObject");

fso.CopyFile (sourceFile, destinationFile);

}

Create Script

You know how to execute scripts from the Scripting Window. If you want to store the script and call it from another form in the application, for example, do the following:

Create a new script WriteFeedbackToLog. See the "Adding Events" topic to find out how to create new scripts.

Write there function WriteFeedback.

Code

function WriteFeedback ()

{

  var Log = System.CreateObject('Log');

  var Application = System.GetInterface('Application');

  var OrigModel;

  OrigModel = Application.Models.GetObjectByID(Model.ID);

  ....

  ....

}

Explanation

The WriteFeedback function is almost identical to the Main function we were executing from the Scripting Window.

The only difference is in the definition of OrigModel object. In the Scripting Window, we could select Videorental and define the OrigName name.

However, now we have no means to select the object visually (and we do not need it, the function will be executed for active model). Therefore we need to define the OrigModel object via Application.Models.GetObjectByID method, with parameter Model.ID.

This way we can get the currently active model.

We also need to register object Log. (It is not necessary to register Log in the Scripting Window. Log is registered in the Scripting Window automatically.)

The rest of the script is identical.

For more information, see Call Existing Script from Model Properties Form.

Documentos relacionados

The document was helpful.

Seleccionar calificación

I easily found the information I needed.

Seleccionar calificación