A Classes Reference to its Map File

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by Glen Richards >> Fri, 20 Aug 2004 0:24:44 GMT

Hi,

Excuse my ignorance/missing anything obvious...

I'm trying to write a little schema/database analyser app to try & get a better understanding of Jade & DB administration - i.e I want to understand the database better at a lower (file) level.

I can get references to classes in a database & I can get references to dbfiles in a database, but I can't find any references between the 2. Yet there must be, as when you define a class you set the map file for it. So is it a hidden/undocumented reference? Any help on this is much appreciated.

Also, if any guru's out there have any resources on this (white papers, links to good topics in the Jade doco's) - info would be much appreciated :)

Cheers,


Glen Richards
Encos

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by Glen Richards >> Fri, 20 Aug 2004 2:12:41 GMT

OK - In answer to my own question...

There are hidden methods...

vars
ms: MethodSet;begin

create ms transient;
DbFile.allMethods(ms);
foreach meth in ms do
write meth.name;
endforeach;
delete ms;
end;

I guess there are hidden properties as well...

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by Gordon Comstock >> Fri, 20 Aug 2004 4:22:38 GMT

Have a look at DbClassMap

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by Glen Richards >> Sun, 22 Aug 2004 21:41:48 GMT

The Class class has a hidden method: _displayDetails() which returns details of the class as a string. I can parse this to get the map file of a class. This is the best I can do so far. I found some other methods that looked useful but were flagged as systemOnly & I can't access them.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by Gordon Comstock >> Mon, 23 Aug 2004 1:51:37 GMT

You could get the map file for a class from DbClassMap by making a method like this on Class...

getMyMapFile():DbFile;
vars
map:DbClassMap;begin

foreach map in DbClassMap.instances
where map.diskClass=self do
return map.diskFile;
endforeach;
return null;
end;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by Anonymous >> Mon, 23 Aug 2004 1:57:13 GMT

See if this is of any use. I have used the schema global class as
an example.


vars
dbClassMap: DbClassMap;
dbClassMapSet: DbClassMapSet;
dbFile: DbFile;
begin
dbClassMapSet := <insert global.class.getPropertyValue("classMapRefs").DbClassMapSet;
dbClassMap := dbClassMapSet.first();
dbFile := dbClassMap.getPropertyValue("diskFile").DbFile;
write dbFile.name;

end;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by Anonymous >> Mon, 23 Aug 2004 1:57:26 GMT

See if this is of any use. I have used the schema global class as
an example.


vars
dbClassMap: DbClassMap;
dbClassMapSet: DbClassMapSet;
dbFile: DbFile;
begin
dbClassMapSet := global.class.getPropertyValue("classMapRefs").DbClassMapSet;
dbClassMap := dbClassMapSet.first();
dbFile := dbClassMap.getPropertyValue("diskFile").DbFile;
write dbFile.name;

end;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by dennis >> Mon, 23 Aug 2004 22:19:48 GMT

Better yet, to avoid any need less typeguarding you
can add a method to the Class class.

returnClassMapFile(): DbFile;
vars
dbClassMap: DbClassMap;
begin
dbClassMap := classMapRefs.first();
return dbClassMap.diskFile;
end;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: A Classes Reference to its Map File

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:37 pm

by dennis >> Tue, 24 Aug 2004 4:11:54 GMT

Sorry I forgot this method won't work if a class has its map
file as the default schema map file so I have amended
the above code to the following:

returnClassMapFile(): DbFile;
vars
dbClassMap: DbClassMap;
begin
dbClassMap := classMapRefs.first();

if dbClassMap = null then
return currentSchema.allDatabases.first().getPropertyValue("defaultFile").DbFile; else
return dbClassMap.diskFile;
endif;
end;


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 33 guests