Page 1 of 1
A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
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
Re: A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
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...
Re: A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
by Gordon Comstock >> Fri, 20 Aug 2004 4:22:38 GMT
Have a look at DbClassMap
Re: A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
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.
Re: A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
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;
Re: A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
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;
Re: A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
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;
Re: A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
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;
Re: A Classes Reference to its Map File
Posted: Fri Aug 07, 2009 12:37 pm
by ConvertFromOldNGs
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;