Converse agora com nosso suporte
Chat com o suporte

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

Getting Settings Information

In Toad Data Modeler you can access Application Settings via ApplicationConfig class:

function main(){

var App = System.GetInterface("Application");

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

var Model = App.Models.GetObject(0);

Log.Information(App.ApplicationConfig.PackagePath);

}

If you need to find out the path to the folder where your model is stored, use the property FilePath of the Model object (PERModel class):

function main(){

var App = System.GetInterface("Application");

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

var Model = App.Models.GetObject(0);

Log.Information(Model.FilePath);

}

More information can be found in Reference Guide (in Expert Mode main menu, Expert Mode has to be enabled first).

Iterate Entity And Attributes

This sample shows you how to iterate entities and attributes and how to recognize PK, PFK or FK attributes.

function main()

{

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

var Model = app.Models.GetObject(0); // gets first model in application

var e, a, iterEntity, iterAttribute;

Model.Lock();

for (e=0; e<Model.Entities.Count; e++) // iterate entities

{

iterEntity = Model.Entities.GetObject(e);

iterEntity.Lock();

for (a=0; a<iterEntity.Attributes.Count; a++) // iterate attributes

{

iterAttribute = iterEntity.Attributes.GetObject(a);

if(iterAttribute.IsPrimaryKey == 1) // check if attribute is PK

{

if(iterAttribute.FKForeignKeys.Count !=0)

Log.Information(iterEntity.Name+'-'+iterAttribute.Name+'-PFK');

else

Log.Information(iterEntity.Name+'-'+iterAttribute.Name+'-PK');

}

else

{

if(iterAttribute.FKForeignKeys.Count !=0)

Log.Information(iterEntity.Name+'-'+iterAttribute.Name+'-FK');

}

}

iterEntity.UnLock();

}

Model.UnLock();

Model.RefreshModel();

}

Call Existing Script from Model Properties Form

Edit the Model Properties form. See the "Modify Form" topic to find out how to edit existing form.

Add there a new button and remember the name of the form - FmPERModelEdit. The name can be found in the Form Explorer.

Defined caption for the button - Write Customer Feedback To Log.

Set the name of the button to FeedbackButton.

Create a new script with the name of the Model Properties form - FmPERModelEdit.

Write event function to the script.

Code

function FeedbackButtonOnClick()

{

  WriteFeedbackToLog.WriteFeedback()

}

Explanation

  • FeedbackButton = name of the button.
  • OnClick = event.
  • WriteFeedbackToLog = name of script that contains called function.
  • WriteFeedback = called function.

When you click the button, an output will be displayed in Message Explorer (Log).

For more information, see Modify HTML Reports.

Modify HTML Reports

To modify HTML reports, we need to extend existing method. The first thing we need to do is to find out what script should be extended.

In Script Explorer, you can see BasicHTMLPERReportOR script with function ReportTableUserProperties. This is the script that generates Tables pages in HTML reports, specifically the section Table Properties.

You can also see script BasicHTMLPERReportOR10 that extends the BasicHTMLPERReportOR script.

Now we now need to write a script that will extend the ReportTableUserProperties function defined in the BasicHTMLPERReportOR script.

For that purpose, we need to open our CustomerFeedback metamodel and the method there.

Open the CustomerFeedback metamodel, add there a new class (see the Class icon in the toolbar), edit the class and set the name to BasicHTMLPERReportOR10. (One extension of that class already exists, in our metamodel we will create another extension of the class).

Define Object Type (the value can be currently found out in metamodel to HTML report for Oracle 10g package).

Add the ReportTableUserProperties method to the class.

Add two new parameters to the method. (The method name and number of parameters must be identical to the original method - see the first screenshot).

Return back to the General tab. Click Reload. Script name and method name will appear there. Add a prefix My to it (this will be changed in future, no manual modification will be required).

Click Edit Script.

Click OK and define code for the ReportTableUserProperties method that extends the existing method of the same name.

Code:

function ReportTableUserProperties(Document, Entity)

{  

  // Table definition

  Table = Document.CreateTable(false,true);

  Table.CreateColumn(20);

  Table.CreateColumn(80);

  var row = -1;

 

  if (Entity.ConfirmedByCustomer == true)

  {

    Table.CreateCell( ++row,0,'Confirmed' );

    Table.CreateCell( row,1,'Yes' );

  }

  else if (Entity.ConfirmedByCustomer == false)

  {

    Table.CreateCell( ++row,0,'Confirmed' );

    Table.CreateCell( row,1,'No' );

  }

  else

  {

    Table.CreateCell( ++row,0,'Confirmed' );

    Table.CreateCell( row,1,'Undefined' );

  }

 

  if (Entity.NotesFromCustomer.length > 0)

  {

    Table.CreateCell( ++row,0,'Notes from Customer' );

    Table.CreateCell( row,1, Entity.NotesFromCustomer );

  }

 

  if (row > -1)

  {

    Document.WriteStyled( 'CAPTION2', 'Customer Feedback' );

    Table.Draw();

    Table.Close();

  }        

 

  Instance.ReportTableUserProperties(Document, Entity);

 

 

};

Explanation

Table.CreateColumn(20) - the CreateColumn function belongs to the HTMLReportTable class. All functions related to the Table object can be found in the Toad Data Modeler Reference.

Entity.ConfirmedByCustomer - represents the variable we added earlier to the CustomerFeedback metamodel.

Entity.NotesFromCustomer.length - standard JavaScript function that returns number of characters of the NotesFromCustomer string.

Document.WriteStyled - represents function that belongs to the HTMLDocument class.

Instance.ReportTableUserProperties(Document, Entity);

  • Instance - using the Instance keyword, we can call existing function we extended. We could copy and paste the content of the ReportTableUserProperties function defined in the BasicHTMLPERReportOR script. However, if a change was made to the script later, we would have to update our script too, which would be difficult to maintain. That's why it's better to write code that will extend the existing functionality only, and call the rest from existing script via the Instance keyword.
  • ReportTableUserProperties - represents existing function we call.

When you generate HTML reports now, you will see the following output. New section Customer Feedback is generated on top, followed by the Table Properties part, as originally defined in the ReportTableUserProperties function in script BasicHTMLPERReportOR.

Documentos relacionados

The document was helpful.

Selecione a classificação

I easily found the information I needed.

Selecione a classificação