QueryDataSource - anyone use this?

2041
4
Jump to solution
07-10-2013 05:12 AM
AdrianMarsden
Occasional Contributor III
Hi

I have a need to query a single table in my SDE in my API pages.  I stumbled across the QueryDataSource class

https://developers.arcgis.com/en/javascript/jsapi/querydatasource-amd.html

T
here seems no examples of this in use and very scant documentation.  The main thing I realized straight away is I had no idea what the "workspaceId" is beyond the description" The workspace id for the registered file geodatabase, SDE or Shapefile workspace."

Am I right in assuming this is one of the data connections we started to have to define in ArcGIS server 10.1?  I'm not sure it can be as there isn't a note to say it requires 10.1

Cheers

ACM

edit - I have a feeling I'm going to answer this one myself by the end of a the day, but just found this

ArcGIS Server 10.1 also provides the ability to work with data in a registered workspace but not published via a map service. This gives administrators and developers the flexibility to add data to apps that isn't visible from the REST services directory. The caveat is that developers need to know the workspace name and data layer/table name to be able to add it to a web application. To see this in action, click the "Add Lakes" button. The lakes layer can then be reordered within the map service.


My bold/underlining - so is it the NAME I need?

OK failed there, moved onto TableDataSource - same issue with lack of docs and using the Data connection name I get

Unable to find 'workspaceId'in 'dataSource' for dynamic dataLayer with 'id': -1.",

No-where can I find what the ID is.
0 Kudos
1 Solution

Accepted Solutions
nicogis
MVP Frequent Contributor
If you want to dynamically add data to your map service, such as feature layers, shapefiles, rasters, or feature attribute tables, you'll need to set up a workspace to contain the data you want to add. Dynamic workspaces can be any enterprise geodatabase, file geodatabase, or file directory on disk that is accessible to the server. If your dynamic workspace is an enterprise geodatabase, you have the option of limiting user access to the geodatabase by locking the database version.

When you select a workspace, an ID is generated to uniquely identify the workspace within the pool of workspaces available to the map service. The map service uses this ID to connect to the data source specified in dynamic layer requests. You have the option to modify the ID when you configure the dynamic workspace for your map service.

see here how Enabling dynamic layers  and set a workspaceid http://resources.arcgis.com/en/help/main/10.1/00sq/00sq000000m7000000.htm

In service editor of your service you set enabling Allow per request modification of layer order and symbology (tab mapping) and clicking on Manage and add your workspaceid (your alias) associate your sde.
via rest is exposed your workspaceid and no details of connection.

see this sample that use this functionality for update shapefile (to make you understand the logic):
http://www.arcgis.com/home/item.html?id=97e918061ad140dcbab68a38782b408b

View solution in original post

0 Kudos
4 Replies
DianaBenedict
Occasional Contributor III
Adrian

Not sure what workspaceID is but I have a feeling/hunch that it is a record in your SDE database. Either way, I ask, why do you want to use the QueryDataSource object instead of a Query object?  I do not even know what the use of these objects are (they do not document this very well do they? Maybe it has to do with being able to perform a complete SQL query instead of just a where clause.

If you add the table of interest to your MapService (or FeatureService if you are planning on editing it) then you can simply use the Query task to query the table of interest via the http://mymapserviceRL/MapServer/3 where 3 = layerId in your mapservice using a where clause. I do this all the time in my app and it works really well.

Diana
0 Kudos
nicogis
MVP Frequent Contributor
If you want to dynamically add data to your map service, such as feature layers, shapefiles, rasters, or feature attribute tables, you'll need to set up a workspace to contain the data you want to add. Dynamic workspaces can be any enterprise geodatabase, file geodatabase, or file directory on disk that is accessible to the server. If your dynamic workspace is an enterprise geodatabase, you have the option of limiting user access to the geodatabase by locking the database version.

When you select a workspace, an ID is generated to uniquely identify the workspace within the pool of workspaces available to the map service. The map service uses this ID to connect to the data source specified in dynamic layer requests. You have the option to modify the ID when you configure the dynamic workspace for your map service.

see here how Enabling dynamic layers  and set a workspaceid http://resources.arcgis.com/en/help/main/10.1/00sq/00sq000000m7000000.htm

In service editor of your service you set enabling Allow per request modification of layer order and symbology (tab mapping) and clicking on Manage and add your workspaceid (your alias) associate your sde.
via rest is exposed your workspaceid and no details of connection.

see this sample that use this functionality for update shapefile (to make you understand the logic):
http://www.arcgis.com/home/item.html?id=97e918061ad140dcbab68a38782b408b
0 Kudos
DianaBenedict
Occasional Contributor III
Thank you for posting the information on Dynamic Data Source and more importantly for including the links to the supporting documentation.  If Adrian's purpose is to simply query a table then I would say that this seems like a lot of overhead. However, it depends on  whether or not Adrian wants to allow the user to select tables/layers from his workspace to add to the existing map or if he already has a pre-defined table where he simply wants to query from an existing services without providing the user that much control over the layers/tables that they have access to.

Please feel free to correct my observations.
0 Kudos
AdrianMarsden
Occasional Contributor III
Ah - I see - amazingly I went to that page earlier, but didn't read it the same way I do now!

I was looking for a easy way to access a variety of (non-spatial) data tables from different data sources which I currently hit using classic asp script - many of our layers have lots of extra data stashed all over the place in non-spatial corporate systems, which are linked with unique property keys .

I think I may either stick to my classic asp. or add all these as tables to a map service and hit them that way.

On that subject, when I did try adding a table to a map service earlier the layer number was the last layer - I couldn't seem to be able to define the order.  Any ideas on that one?

Cheers

ACM
0 Kudos