Scripts (vbs)

How to copy satellites with mappings to a new datasource

Summary Script: CopySatellites.vbs The aim of the automation script “CopySatellites.vbs” is to copy satellites with all columns and specific configurations…

Summary

Script: CopySatellites.vbs

The aim of the automation script “CopySatellites.vbs” is to copy satellites with all columns and specific configurations and create new satellite mappings and integrity load mappings for them connecting to a new data source.

 The script was tested with PowerDesigner Version 16.7.3.0

The script was tested with ExMeX Version 2.13

Input Parameters

Parameter Description
scriptMode

Script has Test and Execution mode:

  • Set variable "T" for Test mode
  • Set variable "E" for Execution mode
copyToSourceSpecificObject

Script can copy satellites, that are referencing a source specific hub

  • set variable to "True" if Satellites are referencing a source specific hub
  • set variable to "False" if not
copyAllSatellitesFromSource

Script can copy all satellites from the datasource at once

  • set variable to "True" all Satellites from the Source should be copied
  • set variable to "False" if not

 filenameTargetModel

The file name of the target model, in which the script should copy the satellites.

Example: "C:\Repo\Models\Core\Production"

 filenameNewSourceModel

The file name of the source model, which is the input source of the new mappings.

Example: "C:\Repo\Models\Stage\ProdLineB"

 filenameOldSourceModel

The file name of the source model, which is the input source of the existing mappings.

Example: C:\Repo\Models\Stage\ProdLineA

 arrayOfSatellites
(only CopySatellitesByList)

An array of satellites the script should copy. Each array Entry consists of three positions:

  1. Code of the old satellite (to be copied)
  2. Source of the new satellite
  3. Boolean variable (“true” or “false) if the source is a view

One example entry for view source might be:
arrayOfSatellites = AddItem(arrayOfSatellites , Array("Production_Item", "V_ProdLineItem", "true"))

 Replace_String_Source

A string the script should replace from the old satellite and the old mappings. This String gets replaces with “Replace_String_Target”

Example: "A"

 Replace_String_Target

A string the script should insert instead of the upper variable “Replace_String_Source”.

Example: "B"

 oldDatasourceCode

The code of the datasource of the existing mappings.

Example: "STAG_PRODLINEA"

 newDatasourceCode

The code of the datasource of the new mappings.

Example: STAG_PRODLINEB

hashkeySuffix

The suffix of the hashkey naming convention

Example: "_HK"

Preparation

At first, open all necessary models in the PowerDesigner that the script should use – these are the target core model and the old and new stage models. Before using the script, you have to define the new data source in the core model.

Make sure that the datasources are named identical in the stage models and core model!

Using the script

Open the script via

     Tools --> Execute Commands --> Edit/Run Script

and Click on the folder Button (or CTRL + O) to open the vbs file or copy the script into the editor.

Before executing the script, you have to define the input parameters at the top of the script.

Now you can execute the script. If the script runs into an error state, PowerDesigner will show you an error message and in which line the error occurred. There are also some info boxes added to give you a more precise help where you may search for the mistake. If an error occurs, PowerDesigner should roll back all changes made by the script.

Sometimes if your model or your satellites are very big, the PowerDesigner Application seems to be bugged and stops working (Not responding) – then wait until success or error state. The Application is still working!

The script will show some output for your information in the bottom script message tab. It also outputs a WARNING if there is a column in the old stage table, which is not in the new stage table. The script then creates the mapping, but you have to verify this column mapping manually.

Remember: The automation script only copies things and renames them – If the objects to copy are already wrong, then wrong things are copied! Make sure you always adhere to your naming convention to have copied satellites that follow also to the naming convention.

Final manual steps

After executing the script in execution mode, the script created the new satellites with their corresponding mappings. Of course, it is always a good task to validate the results.

A last task is to add the new generated satellite tables to the desired diagram. The script only creates the tables in the model, but doesn´t add it to a diagram.

Posted 2 years agoby Stephan.Volkmann

How to check for missing and incorrect mappings?

Summary The aim of the automation script “CheckMappings.vbs” is to search for missing or incomplete mappings in the current active…

Summary

The aim of the automation script “CheckMappings.vbs” is to search for missing or incomplete mappings in the current active model in PowerDesigner.

Input Parameters

hashKeySuffix: The suffix for your hashkey naming convention, for example *_HK

Preparation

Only preparation is to open the model you want to check in PowerDesigner. Make sure it is the current active model (any diagram of the model is the active diagram window).

Using the script

Open the script via

     Tools --> Execute Commands --> Edit/Run Script

and Click on the folder Button (or CTRL + O) to open the vbs file.

Now you can execute the script. If the script runs into an error state, PowerDesigner will show you an error message and in which line the error occurred. If an error occurs, PowerDesigner should roll back all changes made by the script.

The script will show some output for your information in the bottom script message tab.

Following things are checked

  • Warnings: missing table mapping, missing column mapping
  • Errors: missing MappedTo in table mapping, missing MappedTo in column mapping

The script ignores following fields: "HashDiff" ,  "LoadEndDate" , "LoadDate" , "AuditId" , "AUDIT_ID" , "EntityId"

For a Hub the script checks, if there is no mapping to a column with code %_HK.

Final manual steps

After executing, the script outputs the warnings and errors in the output log. The user then can manually verify these messages and correct the model.

Posted 2 years agoby Stephan.Volkmann