cancel
Showing results for 
Search instead for 
Did you mean: 

Boiler plate text on a table and column comment in PowerDesigner Physical Data model

navinladda
Explorer
0 Kudos

How do I create a boiler plate text in a Power Designer physical data model, for each new Table and a column that I create.

In Erwin, I can create Domains with standard data type and a comment which when then attached to a column, it cascades down the boiler plate text in the domain, down to the Column comment.

I would like something similar here. I tried creating a domain and attaching to a column, but the Comment(or in the Definition) text of Domain does not move down to the Column comment.

Accepted Solutions (1)

Accepted Solutions (1)

Ondrej_Divis
Contributor

Hi Navin,

on the screenshot attached you have everything necessary to achieve following functionality. Each time you attach a domain to a column (or do any other modification of the column) it will verify, whether the comment of column and attached domain are the same. And if they are not equal, it will propagate the domains comment into to comment of the column. If you need something more (like automatically propagate change of domains comment into all already attached columns), you will have to define that handler differently. Contact me if you need some more help with this.

Ondrej

GeorgeMcGeachie
Active Contributor
0 Kudos

This is a great example of how easy it is to change the way that PowerDesigner behaves.

Has anybody built a 'pretend to be Erwin' PowerDesigner model extension?

GeorgeMcGeachie
Active Contributor
0 Kudos

If you don't want to use an Event handler that fires every time you need to look at the Comment property, you could consider a custom check with an automatic fix - it could replace an empty Column Comment with a copy of the Domain Comment. That also allows you to edit a Column Comment without it being automatically changed back.

Answers (4)

Answers (4)

Ondrej_Divis
Contributor

Yes, putting it into Custom check and AutoFix is definitely one of possible solutions. Nothing will happen without your control. But it happens ex-post, after you invoke it. Handlers can act in real-time and you don`t have to pay attention to it. You just have to handle all possible scenarios that can ocurr.

Using Custom check and autofix might be easier to implement, but you have to pay more attention to it during modelling time. Handler is more like implement & forget. But it might be more complicated to implement it.

Regardless of which solution you choose, good luck with your modelling.

navinladda
Explorer
0 Kudos

I had to remove the code from Event Handler as it was wiping out my custom modifications.

I have put it as a Custom Checks and under AutoFix Script as I finally understood what George was referring to.

But I realize now doing this VB Scripting without fully understanding the implications is not going to give me the desired results.

Will have to read up and experiment later as currently busy with deliverable deadlines.

This is what I have in Autofix script

Function %Fix%(obj, outmsg)

' Implement your automatic correction on <obj> here

' filling <outmsg> as you wish

' and return True if successful. outmsg = "Automatic correction not implemented"

If not (obj.Domain is Nothing) and Len(obj.Comment) = 0 then

If Obj.Domain.Comment <> Obj.Comment then Obj.Comment = Obj.Domain.Comment

End If

End If

%Fix% = False

End Function

navinladda
Explorer
0 Kudos

Thanks Ondrej.

One more question, after reading what George wrote.

If I edit the Column level meta-data, this rule keeps triggering and putting back the template from Domain back, wiping out my column level comment modifications. Just wondering if I should change first line to check if Column comment is NULL

If not (obj.Domain is Nothing) and Obj.Comment is Nothing

Ondrej_Divis
Contributor
0 Kudos

Yes, of course. My advice was initial step, you will probably have to tailor it to your needs and implement additional logic. Just please don`t test the emptiness of a comment with "is Nothing" statement. That is used for object properties. The whole command in your case would be:

If not (obj.Domain is Nothing) and obj.Comment = ""

or you can use:

If not (obj.Domain is Nothing) and Len(obj.Comment) = 0
navinladda
Explorer
0 Kudos

Thank you Ondrej, that worked !!

How do I make this code independent of a data model ? Can these be saved outside and then any *New* PDM I generate inherits this code.

George,

I don't fully understand the alternative you mention.

Honestly, Erwin makes this as easy as clicking a button called Domain Inheritance. By default everything about the domain is inherited into the column with an option to overwrite anything you want at column level or sync back to a domain. In PD, they decided to implement the datatype and length to be inherited, but nothing else. In Erwin, I use the Domains to even implement classwords down at the column level with this functionality.

PD gives lot of flexibility, but it is expecting a Data Modeler to learn and write VBScript.

Ondrej_Divis
Contributor

Just open the extension you created according to my advice and use Save As function. It will create new *.xem file which stores your extension. And then you can attach it to all models needed (you can do that through menu Model - Extensions...). And if you go to the very root level in your extension and set the "Auto attach" boolean option to true, this extension will be automatically attached to every new data model you create. Nice and easy.

And regarding learning VBScript. Actually only scripting can give you the oportunity to use everything PowerDesigner can offer. This customizability and extensibility outperforms Erwin overwhelmingly. And if you don`t want to waste your time with VBScript, this is where I can help you. Just let me know.

Please mark my answer as accepted if all your questions have been answered.


Regards,

Ondrej