Skip to Content

powerdesigner : Assign domains to data items

Hi,

I have a requirement where i want to assign a <Dummy> domain to all the data items which have <undefined> data type and <undefined> domain; in a conceptual data model (CDM)

The number of such fields is huge, hence would prefer doing this via a script in one of the extensions.

Can someone please help me with the code. I have the below code which seems to be not working:

Sub %Method%(obj)

' (here) obj = conceptual data model

dim data_item, dummy_domain, assign_domain, e

assign_domain = "Dummy"

' loop over all data items in the model

for each data_item in obj.dataitems

for each dummy_domain in obj.domains

if data_item.dataType = "" and dummy_domain.name = "" then

dummy_domain.SetNameAndCode assign_domain, assign_domain

end if

next

next

output "Done!!!"

End Sub

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jun 12 at 09:22 AM

      Hello Amit

      You don't need a script, as you can change all affected Data Items with a single action in a list of Domains, or in a List Report. I would use a List Report, as that saves the filtering for you. Here's what you do:

      • Create a List report, selecting 'Domain' as your object type
      • In the 'Column Filter' select Name, Domain and Data Type
      • Input the Row Filter
      • The Content tab will now show only those Data Items where Data Type = <undefined>
      • Click on the top left corner of the grid to select all of the domains
      • In one of the rows, select the required domain:

      • Every selected Data Item is assigned to the selected domain

      Add comment
      10|10000 characters needed characters exceeded

    • Jun 12 at 10:02 AM

      Try this script:

      dim DIT, DOM, DOMName, domTest
      DOMName = "@Dummy"
      set DOM = ActiveModel.FindChildByName(DOMName, Cls_Domain)
      output DOM
      for each DIT in ActiveModel.DataItems  
         'output DIT & " - " & DIT.DataType
         if DIT.DataType = "" then
      	output DIT & " is undefined"
      	set domTest = DIT.Domain  
      	if domTest is Nothing then
      		output "  - has no domain - Domain set to " & domName
      		DIT.Domain = DOM
      	ElseIf Not domTest.Name = DOMName then
      		output "  - has the wrong domain [" & domTest.Name & "] - Domain changed to " & domName
      		DIT.Domain = DOM
      	End If
         end if
      next 
      output "Done!!!"
      Add comment
      10|10000 characters needed characters exceeded

    • Jun 12 at 10:29 AM

      Hi George,

      Thanks a lot for your quick replies on my issue. It worked for me both ways.

      Thanks again :)

      --Thanks

      Amit

      Add comment
      10|10000 characters needed characters exceeded