Select to view content in your preferred language

Extracting Metadata from SDE

2882
8
06-28-2010 05:29 PM
EbonyWickramanayake
Deactivated User
Hello,

I've running an application derived from the Sample Flex Viewer 1.3 and am looking to integrate the metadata button in the table of contents. I have successfully integrated the webservice that pulls metadata as described here: http://forums.esri.com/thread.asp?c=158&f=2421&t=290218 (code written by Robert Scheitlin).

All good so far, and if I use the URL http://myserver/getMetadata/metadata.aspx?sdeFeatName="+SDELAYERNAME+"&"+"outFormat=FGDC_ESRI" it works just fine. However, since I'm trying to integrate it with the table of contents (TocItemRenderer.as), I am unable to reconcile the fact that flex uses REST map service names to identify layers instead of the original SDE Layer names. I know there was a previous discussion on manually exporting metadata to html and placing in a folder which is accessed by the itemrenderer.

Yet I want the best of both worlds. What's the best way to merge the two ideas? Using the webservice, and integrating it seamlessly into the Table of Contents?

Thanks in advance.

Regards,
Ebony
Tags (2)
0 Kudos
8 Replies
ManuelFrias
Regular Contributor
Hi Ebony,

have a look at this thread

http://forums.esri.com/Thread.asp?c=158&f=2421&t=294149&mc=25

Hope it helps!

Regards,
Manolo
0 Kudos
EbonyWickramanayake
Deactivated User
Thanks Manuel,

I had a look at that. You implemented some code in your TocItemRenderer:

var sdeName:ArrayCollection = new ArrayCollection([
{label:"labelInFlex", data:"labelInSDE"}
]);
if (sdeName[label] == item.label){
item.label = sdeName[data];
var url:String = "http://myserver/getMetadata/metadata.aspx?sdeFeatName="+item.label+"&"+"outFormat=ISO";  

But you said it didn't work - did you ever figure out a solution? I tried it; I even tried it with a loop function that I saw on your Adobe Thread, but no go. I'm not comfortable enough with .NET to edit the webservice code too much although I might have to. However, if you managed a definitive solution to the problem, would you care to share? 🙂

Thanks!

Ebony
0 Kudos
ManuelFrias
Regular Contributor
Hi Ebony,

First, you would need to create a web service. To do that, follow this thread which I'm sure you have already seen:

http://forums.esri.com/Thread.asp?c=158&f=2421&t=290218&mc=18

Then replace the metadata.aspx.vb with the one I attached.

As you see, the idea of the function sqlSDENameLookUp() is to look for the alias in the sde.GDB_OBJECTCLASSES table. Look for that table and modify it if you want. Then, if there is one layer with different alias names the function sqlSDENameLookUpAliasTable() takes care of that. You might not need it, though.

The function in TocItenRenderer.as looks like this:

private function showMeta(evt:Event):void
  {
   if (data is TocItem) {
    var item:TocItem = TocItem(data);
    var mlItem:TocMapLayerItem;
    if(item.parent is TocMapLayerItem){
     mlItem = item.parent as TocMapLayerItem;
    } else if (item.parent.parent is TocMapLayerItem) {
     mlItem = item.parent.parent as TocMapLayerItem;
    } else if (item.parent.parent.parent is TocMapLayerItem) {
     mlItem = item.parent.parent.parent as TocMapLayerItem;
    }
   
    var url:String = "http://server/website/getMetadata/metadata.aspx?sdeFeatName="+item.label+"&"+"outFormat=ISO";
    var window:String = "_blank";
    var features:String = "toolbar=no,location=no,resizable=no,directories=no,status=no,scrollbars=yes,copyhistory=no,width=610,height=700";
    var WINDOW_OPEN_FUNCTION : String = "window.open";
    ExternalInterface.call( WINDOW_OPEN_FUNCTION, url, window, features );
      }
  }

Let me know if you have problems implementing this.

Regards,
Manolo
0 Kudos
EbonyWickramanayake
Deactivated User
Hi Manolo,

Thanks for that. Sorry for the delay, but I was on leave and have only just been able to test this out.

I've hit some obstacles...

I've managed to integrate everything - when I click on the metadata icon, it opens a new window with "We can not find any metadata for this file or an error has occurred." So I know the webservice is working. The url, for example is:

http://server/getMetadata/metadata.aspx?sdeFeatName=Route Positions 1m  (1:500)&outFormat=ISO

which is the correct alias used in the mxd. However, I've had a look at the sde.GDB_OBJECTCLASSES, and under the field AliasName, everything is NULL. Do I have to populate this manually?

Also, do I have to create a table called "sde.GISDATA.ALIASTABLE_H" and populate with all aliases?

Thanks in advance - I feel like I'm almost there! If you need more info, let me know.

Regards,
Ebony
0 Kudos
EbonyWickramanayake
Deactivated User
Robert/Manolo,

Quick question - when I integrate the TocItemRenderer.as, the metadata button also gets placed on the map service level (so it is under the right-facing expand arrow of the tree).

Here is the code:

if (data is TocItem) {
   var item:TocItem = TocItem(data);
   var mlItem:TocMapLayerItem;
   if(item.parent is TocMapLayerItem){
    mlItem = item.parent as TocMapLayerItem;
   } else if (item.parent.parent is TocMapLayerItem) {
    mlItem = item.parent.parent as TocMapLayerItem;
   } else if (item.parent.parent.parent is TocMapLayerItem) {
    mlItem = item.parent.parent.parent as TocMapLayerItem;
   } 

Is it possible to only show the metadata button on individual feature classes, and not the map service name?

Thanks!

Regards,
Ebony
0 Kudos
EbonyWickramanayake
Deactivated User
Hi Manuel,

It works perfectly! Thank you. When I created the table, I forgot to add an additional space for one of the aliases; took awhile to pinpoint that.

My only other question is if it's possible to add the metadata button only to the individual layers, and not the group names. It annoys me that the metadata button falls underneath the expand/collapse tree arrow.

Once again, thank you!

Regards,
Ebony
0 Kudos
ManuelFrias
Regular Contributor
Hi Ebony,

sorry for the delay. I was waiting for an email alerting me of your answer but it turns out that those email alerts are not available in this new forum... or I have not yet figured out how to set them up.

I am glad everything worked. I always get the metadata button for individual layers so something must be wrong in the TocItemRenderer.as in the beginning of the function showMeta. Have you tried to modify it to see what happens?

Manolo
0 Kudos
ManuelFrias
Regular Contributor
Or what about adding this?:

   var btnVisible:Boolean = true;
    if (item.isGroupLayer()||item.isTopLevel()) {
     btnVisible = false;
    }
    _btn.visible = btnVisible;
    _checkbox.visible = checkboxVisible;
0 Kudos