Forgot password? | Forgot username? | Register

Using 'describe' Through a texxmlserver HTTP GET Request

Using 'describe' Through a texxmlserver HTTP GET Request

Hello,

I'm working on a web application where the output of the 'describe' Texql command would be immensely useful for the dynamic construction of certain queries.

Basically, there are a few ways that a particular field in a record can specify data in another table. The ends of the field names usually describe the relationship like '_tab', '_nesttab', 'Ref', 'Ref_tab'. 'describe' generates a nicely formatted version of the same data. For example:

describe ecatalog;:
IdeTaxonRef_tab[
IdeTaxonRef integer
],
IdeIdentifiedByRef_nesttab[
IdeIdentifiedByRef_tab[
IdeIdentifiedByRef integer
]
]

I want to parse this data structure and be able to use it to populate lists of the database fields in a given table that fit into a given type, such as an integer reference in etaxonomy. However, it seems that an HTTP GET request (such as "GET texql=/?texql=(describe%20emultimedia)") does not work properly. Of course, regular select-from-where queries do work using the same server, so I think that it's an issue of an incapability or misconfiguration of server itself.

The response that I get from the texxmlserver is XML with an element that contains 'results status="failed" error="Syntax error."'.

I included some rationale in this post so that anyone who might know of a way to glean something of the database structure without using 'describe' could still chime in, since I'm not set on using it.

In short, though, I'm just wondering whether or not it's possible to have 'describe' work through the texxmlserver or a similar service that a regular EMu setup would have installed already.
@ The Field Museum of Natural History

Edited by: - 01-Jan-70 09:00:00

Administrator has disabled public posting. Please login or register in order to proceed.

Re: Using 'describe' Through a texxmlserver HTTP GET Request

Hi Kyle,

There are a few ways of doing this. The most basic and safe way is to use the efieldhelp table, which acts as a data dictionary of sorts. You can query this like any other table (eg: Select%20ColColumnField%20from%20efieldhelp%20where%20ColColumnModule=%27ecatalogue%27)

With this option, you’re accessing derived information. The table is built when EMu is upgraded. Therefore it is not a dynamic representation of the table structure. If the method used to derive this data is working properly, this shouldn't be an issue. Whether this might present problems really depends on the nature of the application you're building .

There are other more powerful options. However these are risky, complex and undocumented.

Regards

Forbes Hawkins
Museum Victoria

Administrator has disabled public posting. Please login or register in order to proceed.

Re: Using 'describe' Through a texxmlserver HTTP GET Request

Thanks for the response Forbes!

I have been working on implementing your suggestion for the past few days and I haven't come across any real roadblocks yet. The real test will come when I have someone who is more familiar with the types and range of fields that will be used in the final application play around with the resultant interface to see whether or not the fields can be properly referenced.

efieldhelp is being used as a data source for a combination validator/autocomplete field that generates paths to fields in other tables. For instance, ecatalogue.IdeTaxonRef_tab contains references to records in etaxonomy. If the user types in IdeTaxonRef_tab, I want my application to know that the records referenced will be in etaxonomy so that I can do autocomplete on a subsequent field. The subsequent field is only generated because efieldhelp also tells me that IdeTaxonRef_tab is a table with references to etaxonomy. If the user had typed in an atom-type field, an addition field wouldn't be generated since they can't burrow down further by hopping to referenced tables.

A strange thing that I noticed is that fields like IdeTaxonRef_tab aren't listed as their own records in efieldhelp, even though they have their own entries in the output of 'describe'. Is that because they are 'hidden' fields? I've only heard that term used in conversation, so I don't know if it's an actual property of a field or if it's just a term used to describe fields that don't show up everywhere that other fields do in EMu. I was able to work around that shortcoming by gleaning information about those fields from the ColReferenceLink XML record element.

Anyway, thanks again for the information that you've provided so far. Any more input that you or anyone else has is still appreciated!
@ The Field Museum of Natural History

Administrator has disabled public posting. Please login or register in order to proceed.

Re: Using 'describe' Through a texxmlserver HTTP GET Request

Hello Kyle,

I have altered the scripts that generate Field Help records ("emuhelpdump" in the "bin" directory on the server) to now include all Ref and Ref_* fields. They were excluded originally as the Field Help module was designed to contain records for fields that appear in the client and can be selected via the "What's this Help?" facility. As the Ref and Ref_* columns cannot be clicked on (they sit behind the viewable reference fields) their help records were not generated.

As you are using the Field Help module as a data dictionary it make sense to include these columns. It will also make your code a little simpler I suspect :-). The change is incorporated in EMu 4.0.01-0908211 or later.

Regards

bern.
Bernard Marshall
KE Software
Melbourne, Australia

Bernard Marshall (Axiell Melbourne)
useravatar
Offline
43 Posts
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Using 'describe' Through a texxmlserver HTTP GET Request

Hi Bernard,

I took a look at the emuhelpdump script in our current installation. I got the Ref and Ref_ fields to show up in efieldhelp by commenting out the line "#next if ($field =~ /Ref$/ || $field =~ /Ref_/);". (I realize that this is probably similar to what you did for EMu 4.0.01-0908211, but I was eager to test the changes).

The weird thing is that the records for those fields in efieldhelp are quite a bit more barren than I expected. Basically, the only structurally descriptive fields that are given back are these: (ColColumnType: dtInteger, ColColumnKind: dkTable, ColColumnModule: ecatalogue, ColColumnField: IdeTaxonRef_tab)

Maybe my expectations are just incorrect, but shouldn't IdeTaxonRef_tab know that it holds a reference to etaxonomy? It seems strange to have to use the ColReferenceLink field from one of the other efieldhelp records to get that information. There are, for example, 26 fields in ecatalogue that have IdeTaxonRef_tab as a ColReferenceLink, and I can learn from each of those records that IdeTaxonRef_tab holds references to records in etaxonomy. At the moment, I'm just picking the first of those fields since they all have the same information, but it feels like that shouldn't be the correct approach.

Thanks for your help!
@ The Field Museum of Natural History

Administrator has disabled public posting. Please login or register in order to proceed.

Re: Using 'describe' Through a texxmlserver HTTP GET Request

Hello Kyle,

I have listed the diffs below. If you apply them (via "patch") you will get a version of "emuhelpdump" that will include the name of the table to which "Ref" and Ref_*" columns link.

Regards

bern.


141d140
< next if ($field =~ /Ref$/ || $field =~ /Ref_/);
283a283
> my $reftable;
288a289
> return($reftable) if (defined($reftable = $schema->{"RefTable"}));
290,294c291,292
< if (defined($Schema{$module}->{"columns"}->{$reflink}->{"RefTable"}))
< {
< return($Schema{$module}->{"columns"}->{$reflink}->{"RefTable"});
< }
< return("");
---
> $reftable = $Schema{$module}->{"columns"}->{$reflink}->{"RefTable"};
> return(defined($reftable) ? $reftable : "");
Bernard Marshall
KE Software
Melbourne, Australia

Bernard Marshall (Axiell Melbourne)
useravatar
Offline
43 Posts
Administrator has disabled public posting. Please login or register in order to proceed.
There are 0 guests and 0 other users also viewing this topic