Is it a package

General discussions about code engineering

Moderator: Moderators

Is it a package

Postby jvernonjpmc » Tue Sep 12, 2017 8:19 am

I reverse-engineered an Oracle database schema. The result was the creation of an element that visually looks like a package. It looks like a folder, but it's blue instead of yellow. In it is stored the definition of the tables in the schema.

Which meta-data type is it? I need to report the contents of this, e.g. #foreach($package in $Package) ...

Thank you
jvernonjpmc
Forum Beginner
Forum Beginner
 
Posts: 42
Posts Rating:0
Joined: Mon Aug 15, 2016 3:56 pm

Re: Is it a package

Postby gedkvi » Wed Sep 13, 2017 1:18 am

Hello,

You probably refer to the Schema model element, then its meta-data type is Package.
It is blue in the containment tree because it has a stereotype <<Schema>> applied to it, that modifies the icon to visually represent that it is a schema rather than a simple Package.

This is the description of the Schema stereotype.
schema.png


Sincerely,
No Magic Customer Support
You do not have the required permissions to view the files attached to this post.
gedkvi
Customer Support
Customer Support
 
Posts: 55
Posts Rating:7
Joined: Wed Sep 16, 2015 11:25 am

Re: Is it a package

Postby jvernonjpmc » Tue Nov 14, 2017 1:17 pm

I agree with you that when I look at the specification of stereotype Schema in the SQL Profile, the metaclass is Package.

I have the code below. When I run this against the contents of a UML package instance that contains an instance of View, I get results; when I run it against an instance of Schema that contains an instance of View, I get no results.

#foreach($package in $Package)

#*#Iterate across elements in each package*#
#foreach($element in $package.ownedElement)

#*#Check if the element is a View or Table*#
#if($element.humanType == 'View' || $element.humanType == 'Persistent Table' || $element.humanType == 'Entity')

#*#Iterate across each element in the View / Table*#
#foreach($innerElement in $element.ownedElement)

#*#Check if the element huamtype is a Property*#
#if($innerElement.humanType == 'Column' || $innerElement.humanType == 'Property')

$package.getName()
$element.getName()
$innerElement.getName()
$innerElement.getType()
#end
#end
#end
#end
#end

When I tried to print the human type of the Schema element, the script printed nothing for it.

#foreach($package in $Package)

#*#Iterate across elements in each package*#
#foreach($element in $package.ownedElement)

$package.getName()
$element.getName()
$element.humanName
#end
#end
jvernonjpmc
Forum Beginner
Forum Beginner
 
Posts: 42
Posts Rating:0
Joined: Mon Aug 15, 2016 3:56 pm

Re: Is it a package

Postby gedkvi » Wed Nov 15, 2017 8:08 am

Hello,

Sorry for the confusion, the call that you used was $Package(in your first cycle), thus it returned only package(excluding Schemas). If you change your script to the one provided, everything should work correctly.
Note: if specification window shows "Package" then using $Package, will return these packages. If the windows shows "Schema" then using $Schema will return these schema elements. This is due to the fact that the element is customized in the profile. If an element only has a stereotype(not in your case), then you need to check for stereotype using $report.containsStereotype(element, stereotypeName, includeDerived).

I have modified the script a little.
Code: Select all
#foreach($schema in $Schema)
$schema.getName()
#*#Iterate across elements in each schema*#
#foreach($table in $schema.ownedElement)
#*#Check if the element is a View or Table*#
#if($table.humanType == 'View' || $table.humanType == 'Persistent Table' || $table.humanType == 'Entity')
  $table.getName()
#*#Iterate across each element in the View / Table*#
#foreach($innerElement in $table.ownedElement)
#*#Check if the element huamtype is a Property*#
#if($innerElement.humanType == 'Column' || $innerElement.humanType == 'Property')
    $innerElement.getName() - $innerElement.getType().getName()
#end
#end
#end
#end
#end


The result on sample project are:
Code: Select all
TypeDemoSchema
  Person
    name - varchar
    surname - varchar_of_20
    accountBalance - numeric
TableDemoSchema
  Salesman
    name - varchar
    quota - numeric


You can find more information about Report wizard in the user manual at <program.install.dir>\manual\MagicDraw ReportWizard UserGuide.pdf

Sincerely,
No Magic Customer Support
gedkvi
Customer Support
Customer Support
 
Posts: 55
Posts Rating:7
Joined: Wed Sep 16, 2015 11:25 am


Return to Code engineering

Who is online

Users browsing this forum: No registered users and 0 guests