Home | Uploading | Viewing Data | Search | Making Public | Lists | Sample Attributes | Chemical Analysis Attributes | Image Attributes | XML Output |  To MetPetDB


XML Output for Http Requests

Users can communicate with the MetPetDB database by sending http get and post requests.

Http Get Requests

Http Get requests can by made by simply appending various parameters to the MetPetDB URL. The URL format changes depending on the query, but the response is always in xml. The base URL is  http://metpetdb.rpi.edu/metpetweb/searchIPhone.svc? There are several query strings that, along with valid parameters will produce the desired output. Sample XML output can be viewed by clicking on any of the following URLs:

Queries returning samples and all attributes

The following two queries are basic database queries that return all the samples in the specified search region along with all of their attributes.

 http://metpetdb.rpi.edu/metpetweb/searchIPhone.svc?north=42.449964&south=41.550036&east=-72.394514&west=-73.605486

This query takes the upper and lower latitude and longitude bounds and creates a geographic search box. The "north" query string represents the upper-bound latitude, "south" represents the lower-bound latitude, "east" represents the upper-bound longitude, and "west" represents the lower-bound longitude. In the iphone app, these numbers are derived from a center point, which is either the user's current location or an input coordinate, and a search radius that is provided by the user. All of the information about all the samples in this box is returned in the output for this query. All of the samples returned are within the <set> tags and for each sample, all relevant information is within the <sample> tags. The following are some sample attributes and their XML tags:

Sample name (a ":" indicates that the sample came from a publication):

<number>

<string>102-1:1979-006302</string>

</number>

Unique sample id number (this is the sample number in the database, and while it is generally not seen by users, it is required for many of the queries described on this page):

<id>

<long>405</long>

</id>

Rock type (the actual rock type is within the <rockType> tags and the id indicates the database id of that type):

<rockType> <edu.rpi.metpetdb.client.model.RockType>

<id>3</id> <rockType>Schist</rockType>

</edu.rpi.metpetdb.client.model.RockType> </rockType>

Minerals contained in the sample:

<minerals>

<string>Apatite (x)</string> <string>Muscovite (x)</string> <string>Chlorite (x)</string> <string>Quartz (x)</string> <string>Magnetite (x)</string> <string>Biotite (x)</string> <string>Plagioclase (x)</string> <string>Garnet (x)</string> <string>Hornblende (x)</string>

</minerals>

Metamorphic grades contained in the sample:

<metamorphicGrades>

<string>Amphibolite</string>

</metamorphicGrades>

Public/private status (if the data is public the <boolean> tag will be true):

<publicData>

<boolean>true</boolean>

</publicData>

Longitude and Latitude (respectively) of the sample:

<x>-73.43169403076172</x> <y>42.0546989440918</y>

Sample Owner (if the sample is published, the owner will be PUBLICATION, otherwise it will be a name):

<owner>

<string>PUBLICATION</string>

</owner>

 http://metpetdb.rpi.edu/metpetweb/searchIPhone.svc?searchRegion=BritishColumbia

The output for this query is the same as the previously described query, but the query string and the parameters are different. The query string is searchRegion, and the parameter is one of the search regions in the database. These search regions must match exactly what is in the database or no samples will be returned. To view the valid search regions, use the url query string (described below) regions=t. The output will be all the samples in the database that are in the specified region. The xml tags for each sample will be identical to those above.

Sample Information Queries

With the exception of the "large image" query, all of the following queries use the unique id number of a sample and return information about that particular sample.

 http://metpetdb.rpi.edu/metpetweb/searchIPhone.svc?subsampleInfo=342

Using the unique id number of a sample, this query will return a summary of the subsample and chemical analysis information for the sample. In the example above, the sample id is 342. The XML tags include:

The number of subsamples associated with the sample:

<subsamples> <int>1</int>

The number of images associated with the sample (this includes sample and subsample images):

<imageCount>

<int>16</int>

</imageCount>

The number of chemical analyses associated with the sample:

<analysisCount>

<int>0</int>

</analysisCount>

Boolean that indicates whether there is a bulk rock analysis available for the sample:

<bulkRock>

<boolean>false</boolean>

</bulkRock>

 http://metpetdb.rpi.edu/metpetweb/searchIPhone.svc?thumbnails=342

Using the unique id number of a sample, this query will return a list of image checksum numbers. These checksums represent the thumbnail versions of all the sample AND subsample images for a sample. To view the thumbnail image, append any thumbnail checksum number to the following URL:  http://metpetdb.rpi.edu/metpetweb//image/?checksum=

Example:  http://metpetdb.rpi.edu/metpetweb//image/?checksum=04cfebb70d2e2e03cb7fa8115a1ec027bfd7326e1391514925

The XML tags include: The checksum number for the thumbnail:

<image>

<string>0442d83d64744a7c72d8e694b3259cd09675a2ecf905adb6f2</string>

</image>

The unique id number of the image (this is used to obtain the larger mobile-sized image):

<imageID>

<long>228</long>

</imageID>

 http://metpetdb.rpi.edu/metpetweb/searchIPhone.svc?comments=342

Using the unique id number of a sample, this query will return a list of all the comments that have been made about that sample. If there are no comments for the sample you are searching for, the XML output will be <comments />.

 http://metpetdb.rpi.edu/metpetweb/searchIPhone.svc?large_image=214

The parameter for this query is an image id number, NOT a sample id number. Given the id of an image, the checksum for the mobile sized image in the database will be returned. To view this image, append the checksum to the following url:  http://metpetdb.rpi.edu/metpetweb//image/?checksum=

Example:  http://metpetdb.rpi.edu/metpetweb//image/?checksum=04de072b0f5cb440c3eba1b900f46461512a94693c35d02bd7

The XML output includes:

The checksum of the mobile-sized image:

<path>

<string>04de072b0f5cb440c3eba1b900f46461512a94693c35d02bd7</string>

</path>

The filename of the image:

<filename>

<string>V15A-A-297x239(sps).tif</string>

</filename>]

Other queries

 http://metpetdb.rpi.edu/metpetweb/searchIPhone.svc?regions=t

One of the search options in the iphone app is to use a predefined search region and have all the samples within that region returned. This query will return all the regions in the database that contain samples. In XML format, each region is in a <string> tag.

Http Post Requests

Users can also communicate with MetPetDB using Post requests. There is a wider range of information available with Post methods including summaries of the various characteristics of all the samples returned from a search. It is important for post requests that the formatting is EXACTLY as described below. If there are additional spaces, punctuation, etc. the server will not parse the input correctly and valid output will not be sent.

All components of a post requests are in the format parameter= value\n There must be a new line character in after EVERY search criteria that is included in the request. The examples below include at least one example of all the different search criteria that can be specified. It is important to note which parameters must be combined with geographic specifications. For example, simply passing a username and password to the server will not return meaningful information. If, however, a username and password are provided in addition to a search region or geographic coordinates, the samples in the geographic area will

Criteria Summaries

For Post requests, there are two main categories of requests: those requesting a summary of the search criteria of the samples returned from a search, and those requesting all the attributes of all the samples returned from a search. If a request is sent for the search criteria of the samples returned from a search, the output will include information such as the number of samples in the search, a list of all the minerals in all the samples, a list of all the rock types of all the samples, a list of all the metamorphic grades of all the samples, etc. In order to get this summary information, the user must append criteriaSummary= true\n to the http post string being sent to the server. This search parameter MUST be used in conjunction with either a search region or geographic coordinates.

If the user is not interested in a summary of the search criteria of the samples, they can instead get a set of samples returned. This set will include information about each of the samples returned in the search. criteriaSummary= false\n should be appended to the http post string being sent to the server.

Sample Type

The sample type parameter indicates where the samples returned will be private samples, public samples, or both types of samples. In order for private samples or both types to be returned, a MetPetDB username and password must be sent to the server along with the request.

Login with Usernames and Passwords

After a user has registered with MetPetDB, they can use their username and password to view any private samples they may have in the database. If only authentication is being tested, the server returns the string "authentication succeeded", and if not it returns "authentication failed". No other information will be returned with only the username and password parameters.

Example (a valid username and password obviously need to be substituted):

username= yourUsername\npassword= yourPassword\n

Search Regions

The criteria type for the pre-defined regions in the database is searchRegion= region name\n. The type of samples within this region as well as the whether or not a criteria summary is desired must also be specified.

Example without criteria summary: searchRegion= British Columbia\ncriteriaSummary= false\nsampleType= public

The attached file at the bottom of this page entitled "searchRegionOutput.txt" contains the output of this query.

Example with criteria summary: searchRegion= British Columbia\ncriteriaSummary= true\nsampleType= public

The attached file at the bottom of this page entitled "regionCriteria.txt" contains the output of this query.

Geographic Coordinate Search

Alternatively, users can use a coordinate box to search for samples. This requires 4 parameters representing 4 geographic coordinates. They are maximum latitude (north parameter), minimum latitude (south parameter), maximum longitude (east parameter), and minimum longitude (west parameter). The criteriaSummary, sampleType, username, and password parameters function the same with this type of search as they did with the searchRegion parameter.

Example using coordinates, searchCriteria as false, and only public samples:

north= 44.483256\nsouth= 40.881544\neast= -72.960826\nwest= -77.859574\nsampleType= public\ncriteriaSummary= false

The attached file at the bottom of the page entitled "coordinateResults.txt" contains the output of this query.

=== Sample Characteristic Searches == The following represent searches that can be done to query the database for samples with certain characteristics. The features that can be queried are rock type, metamorphic grade, minerals, and sample owner. The parameter name as they must be specified in the search are: rockType, metamorphicGrade, mineral, and owner. Only one value can be specified for each parameter and these can and usually are combined with geographic searches. For example, to search for samples with the mineral quartz and the mineral biotite, the correct post string would be mineral= quartz\nmineral= biotite When the same parameter is provided multiple times, the search will have an "or", but across criteria, it will have an "and" effect. The previous mineral search will therefore return all samples that have quartz, all samples that have biotite, and all samples that have both. For the below search that specifies a rock type and a mineral, the search will return only samples containing the rock type AND the mineral. These searches do not require a specification of geographic area (search coordinates or search region,) but any number of any of these can be coupled with a search criteria.

Criteria can be combined like the following example: rockType= amphibolite\nmineral= quartz

The attached file at the bottom of the page entitled "rockTypeMineralOutput.txt" contains the output of this query.

Images

The checksum values of both thumbnail images and full sized images can be obtained via http post requests. To get all the checksum images for a sample, the syntax is thumnails= sampleID\n The unique id of a sample is needed in order to get its thumbnails. In the xml returned from a thumbnail query, the checksum numbers for the thumbnail image can be obtained. The checksum numbers are within the <image><string> </image></string> tags. The thumbnail images can be obtained by appending the checksum value to the following url:  http://metpetdb.rpi.edu/metpetweb//image/?checksum= The id of the image can be found between the <id></id> tags.

Example:  http://metpetdb.rpi.edu/metpetweb//image/?checksum=04ed3b2b2fa11b00a16e153eefc1247185b3f6900530aedf43

Example of obtaining thumbnails in a post request: thumbnails= 342\n

The attached file at the bottom of the page entitled "thumbnailOutput.txt" contains the output of this query.

Post requests can also be used to get the checksum of a full sized image, provided the id of the image is known. Typically, the ids of the samples would be obtained by making a thumbnail request. Those image ids can then be used in the format largeImage= imageID\n to get the checksum of the full-sized image. The checksum of the full size image can be found between the <path><string> </path></string> tags. This checksum can also be appended to the url:  http://metpetdb.rpi.edu/metpetweb//image/?checksum=

Example:  http://metpetdb.rpi.edu/metpetweb//image/?checksum=043a12062d7b0b07904d9f40dbfb928f9d79efcffd376cb9f8

Example of obtaining full size images in a post request: largeImage= 5\n

The attached file at the bottom of the page entitled "largeImageOutput.txt" contains the output of this query.

Comments

Any comments that have been made on a sample can be obtained with the format comments= sampleId\n

=== A summary of information about a sample's subsamples can be obtained with the format subsampleInfo= sampleId\n The information returned included the number of subsamples, the number of images, the number of analyses, and a boolean indicating whether or not the sample is a bulk rock sample. The first pair of <int></int> tags indicate the number of subsamples.

Example: subsampleInfo= 342\n

The attached file at the bottom of the page entitled "subsampleInfoOutput.txt" contains the output of this query.

Regions

To get a list of all the regions that contain samples in the database, the query regions =true\n can be made.

The attached file at the bottom of the page entitled "regionsOutput.txt" contains the output of this query.


Home | Uploading | Viewing Data | Search | Making Public | Lists | Sample Attributes | Chemical Analysis Attributes | Image Attributes | XML Output |  To MetPetDB

Attachments