PageRenderTime 57ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/code/getDASRegistryOptions.html

http://dasminer.googlecode.com/
HTML | 254 lines | 235 code | 15 blank | 4 comment | 0 complexity | eaae9475bdac34b79be87339aafb35f7 MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/REC-html40/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Description of getDASRegistryOptions</title>
  6. <meta name="keywords" content="getDASRegistryOptions">
  7. <meta name="description" content="GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry">
  8. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  9. <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  10. <meta name="robots" content="index, follow">
  11. <link type="text/css" rel="stylesheet" href="../m2html.css">
  12. </head>
  13. <body>
  14. <a name="_top"></a>
  15. <div><a href="../index.html">Home</a> &gt; <a href="index.html">code</a> &gt; getDASRegistryOptions.m</div>
  16. <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
  17. <td align="right"><a href="index.html">Index for code&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
  18. <h1>getDASRegistryOptions
  19. </h1>
  20. <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
  21. <div class="box"><strong>GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry</strong></div>
  22. <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
  23. <div class="box"><strong>function [optList] = getDASRegistryOptions(varargin) </strong></div>
  24. <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
  25. <div class="fragment"><pre class="comment"> GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry
  26. GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry
  27. that will populated SEARCHREGISTRY_GUI menus with search parameters
  28. SYNTAX: [optList] = getDASRegistryOptions(varargin)
  29. optList - cellstr list with the options according to the
  30. criteria
  31. EXAMPLES:
  32. Get organisms' list
  33. [optList] = getDASRegistryOptions() or
  34. [optList] = getDASRegistryOptions('criteria','organism')
  35. Get coordinate sytems' list
  36. [optList] = getDASRegistryOptions('criteria','type')
  37. Get authorities' list
  38. [optList] = getDASRegistryOptions('criteria','authority')
  39. Get capabilities' list
  40. [optList] = getDASRegistryOptions('criteria','capability')
  41. See also <a href="searchRegistry_gui.html" class="code" title="function varargout = searchRegistry_gui(varargin)">SEARCHREGISTRY_GUI</a>
  42. DASMiner: DAS library and browser for Matlab.
  43. Diogo Veiga, March 2008.</pre></div>
  44. <!-- crossreference -->
  45. <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
  46. This function calls:
  47. <ul style="list-style-image:url(../matlabicon.gif)">
  48. <li><a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a> READDASURL attempts to read the DAS URL within the specified timeout</li></ul>
  49. This function is called by:
  50. <ul style="list-style-image:url(../matlabicon.gif)">
  51. <li><a href="searchRegistry_gui.html" class="code" title="function varargout = searchRegistry_gui(varargin)">searchRegistry_gui</a> SEARCHREGISTRY_GUI is the GUI for DAS Registry search in Browser</li></ul>
  52. <!-- crossreference -->
  53. <h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
  54. <ul style="list-style-image:url(../matlabicon.gif)">
  55. <li><a href="#_sub1" class="code">function [typesList] = parseDASXMLbyType(timeout)</a></li><li><a href="#_sub2" class="code">function [organismList] = parseDASXMLbyOrganism(timeout)</a></li><li><a href="#_sub3" class="code">function [authList] = parseDASXMLbyAuthority(timeout)</a></li><li><a href="#_sub4" class="code">function [capList] = parseDASXMLbyCapability(timeout)</a></li><li><a href="#_sub5" class="code">function [res] = isValidCriteria(x)</a></li></ul>
  56. <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
  57. <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [optList] = getDASRegistryOptions(varargin)</a>
  58. 0002 <span class="comment">% GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry</span>
  59. 0003 <span class="comment">%</span>
  60. 0004 <span class="comment">%GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry</span>
  61. 0005 <span class="comment">%that will populated SEARCHREGISTRY_GUI menus with search parameters</span>
  62. 0006 <span class="comment">%</span>
  63. 0007 <span class="comment">% SYNTAX: [optList] = getDASRegistryOptions(varargin)</span>
  64. 0008 <span class="comment">% optList - cellstr list with the options according to the</span>
  65. 0009 <span class="comment">% criteria</span>
  66. 0010 <span class="comment">%</span>
  67. 0011 <span class="comment">% EXAMPLES:</span>
  68. 0012 <span class="comment">% Get organisms' list</span>
  69. 0013 <span class="comment">% [optList] = getDASRegistryOptions() or</span>
  70. 0014 <span class="comment">% [optList] = getDASRegistryOptions('criteria','organism')</span>
  71. 0015 <span class="comment">%</span>
  72. 0016 <span class="comment">% Get coordinate sytems' list</span>
  73. 0017 <span class="comment">% [optList] = getDASRegistryOptions('criteria','type')</span>
  74. 0018 <span class="comment">%</span>
  75. 0019 <span class="comment">% Get authorities' list</span>
  76. 0020 <span class="comment">% [optList] = getDASRegistryOptions('criteria','authority')</span>
  77. 0021 <span class="comment">%</span>
  78. 0022 <span class="comment">% Get capabilities' list</span>
  79. 0023 <span class="comment">% [optList] = getDASRegistryOptions('criteria','capability')</span>
  80. 0024 <span class="comment">%</span>
  81. 0025 <span class="comment">% See also SEARCHREGISTRY_GUI</span>
  82. 0026 <span class="comment">%</span>
  83. 0027 <span class="comment">% DASMiner: DAS library and browser for Matlab.</span>
  84. 0028 <span class="comment">% Diogo Veiga, March 2008.</span>
  85. 0029
  86. 0030 p = inputParser; <span class="comment">% Create an instance of the class.</span>
  87. 0031
  88. 0032 p.addParamValue(<span class="string">'timeout'</span>, 90000, @isnumeric); <span class="comment">%time in miliseconds</span>
  89. 0033 p.addParamValue(<span class="string">'criteria'</span>, <span class="string">'organism'</span>, @(x) <a href="#_sub5" class="code" title="subfunction [res] = isValidCriteria(x)">isValidCriteria</a>(x));
  90. 0034
  91. 0035 p.KeepUnmatched = true;
  92. 0036 p.FunctionName = <span class="string">'GETDASREGISTRYOPTIONS'</span>;
  93. 0037 p.parse(varargin{:});
  94. 0038
  95. 0039 <span class="keyword">switch</span> p.Results.criteria
  96. 0040
  97. 0041 <span class="keyword">case</span> <span class="string">'type'</span>
  98. 0042 optList = <a href="#_sub1" class="code" title="subfunction [typesList] = parseDASXMLbyType(timeout)">parseDASXMLbyType</a>(p.Results.timeout);
  99. 0043 <span class="keyword">case</span> <span class="string">'organism'</span>
  100. 0044 optList = <a href="#_sub2" class="code" title="subfunction [organismList] = parseDASXMLbyOrganism(timeout)">parseDASXMLbyOrganism</a>(p.Results.timeout);
  101. 0045 <span class="keyword">case</span> <span class="string">'authority'</span>
  102. 0046 optList = <a href="#_sub3" class="code" title="subfunction [authList] = parseDASXMLbyAuthority(timeout)">parseDASXMLbyAuthority</a>(p.Results.timeout);
  103. 0047 <span class="keyword">case</span> <span class="string">'capability'</span>
  104. 0048 optList = <a href="#_sub4" class="code" title="subfunction [capList] = parseDASXMLbyCapability(timeout)">parseDASXMLbyCapability</a>(p.Results.timeout);
  105. 0049
  106. 0050 <span class="keyword">end</span>
  107. 0051
  108. 0052 <a name="_sub1" href="#_subfunctions" class="code">function [typesList] = parseDASXMLbyType(timeout)</a>
  109. 0053
  110. 0054 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(<span class="string">'http://www.dasregistry.org/das1/coordinatesystem'</span>,timeout);
  111. 0055
  112. 0056 <span class="keyword">if</span> (~status)
  113. 0057 <span class="comment">%error('Server is taking too long to respond. Increase timeout and try again.');</span>
  114. 0058 optList = -1;
  115. 0059 <span class="keyword">return</span>;
  116. 0060 <span class="keyword">end</span>
  117. 0061
  118. 0062 <span class="keyword">if</span> (~isstruct(xmlStruct))
  119. 0063 <span class="comment">% error('Problem parsing XML response.');</span>
  120. 0064 optList = -1;
  121. 0065 <span class="keyword">return</span>;
  122. 0066 <span class="keyword">end</span>
  123. 0067
  124. 0068 typesList = {};
  125. 0069 <span class="keyword">for</span> i=1:size(xmlStruct.COORDINATES,2)
  126. 0070
  127. 0071 list = regexp(xmlStruct.COORDINATES{i}.CONTENT,<span class="string">','</span>,<span class="string">'split'</span>);
  128. 0072
  129. 0073 <span class="keyword">for</span> j=1:size(list,2)
  130. 0074
  131. 0075 <span class="keyword">if</span> (~any(strcmpi(list{j},typesList)))
  132. 0076 typesList = [typesList; list{j}];
  133. 0077 <span class="keyword">end</span>
  134. 0078 <span class="keyword">end</span>
  135. 0079 <span class="keyword">end</span>
  136. 0080 typesList = sort(typesList);
  137. 0081
  138. 0082 <a name="_sub2" href="#_subfunctions" class="code">function [organismList] = parseDASXMLbyOrganism(timeout)</a>
  139. 0083
  140. 0084 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(<span class="string">'http://www.dasregistry.org/das1/organism'</span>,timeout);
  141. 0085
  142. 0086 <span class="keyword">if</span> (~status)
  143. 0087 <span class="comment">% error('Server is taking too long to respond. Increase timeout and try again.');</span>
  144. 0088 optList = -1;
  145. 0089 <span class="keyword">return</span>;
  146. 0090 <span class="keyword">end</span>
  147. 0091
  148. 0092 <span class="keyword">if</span> (~isstruct(xmlStruct))
  149. 0093 <span class="comment">% error('Problem parsing XML response.');</span>
  150. 0094 optList = -1;
  151. 0095 <span class="keyword">return</span>;
  152. 0096 <span class="keyword">end</span>
  153. 0097
  154. 0098 organismList = {};
  155. 0099
  156. 0100 <span class="keyword">for</span> i=1:size(xmlStruct.ORGANISM,2)
  157. 0101
  158. 0102 org = xmlStruct.ORGANISM{i}.ATTRIBUTE.scientificName;
  159. 0103
  160. 0104 <span class="keyword">if</span> (~any(strcmpi(org,organismList)))
  161. 0105 organismList = [organismList; org];
  162. 0106 <span class="keyword">end</span>
  163. 0107
  164. 0108 <span class="keyword">end</span>
  165. 0109 organismList = sort(organismList);
  166. 0110
  167. 0111 <a name="_sub3" href="#_subfunctions" class="code">function [authList] = parseDASXMLbyAuthority(timeout)</a>
  168. 0112
  169. 0113 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(<span class="string">'http://www.dasregistry.org/das1/sources/'</span>,timeout);
  170. 0114
  171. 0115 <span class="keyword">if</span> (~status)
  172. 0116 <span class="comment">% error('Server is taking too long to respond. Increase timeout and try again.');</span>
  173. 0117 optList = -1;
  174. 0118 <span class="keyword">return</span>;
  175. 0119 <span class="keyword">end</span>
  176. 0120
  177. 0121 <span class="keyword">if</span> (~isstruct(xmlStruct))
  178. 0122 <span class="comment">% error('Problem parsing XML response.');</span>
  179. 0123 optList = -1;
  180. 0124 <span class="keyword">return</span>;
  181. 0125 <span class="keyword">end</span>
  182. 0126
  183. 0127 authList = {};
  184. 0128 <span class="keyword">for</span> i=1:size(xmlStruct.SOURCE,2)
  185. 0129
  186. 0130 <span class="keyword">if</span> (isfield(xmlStruct.SOURCE{i}.VERSION{1},<span class="string">'COORDINATES'</span>))
  187. 0131
  188. 0132 <span class="keyword">for</span> k=1:size(xmlStruct.SOURCE{i}.VERSION{1}.COORDINATES,2)
  189. 0133
  190. 0134 auth = xmlStruct.SOURCE{i}.VERSION{1}.COORDINATES{k}.ATTRIBUTE.authority;
  191. 0135
  192. 0136 <span class="keyword">if</span> (~any(strcmpi(auth,authList)))
  193. 0137 authList = [authList; auth];
  194. 0138 <span class="keyword">end</span>
  195. 0139 <span class="keyword">end</span>
  196. 0140 <span class="keyword">end</span>
  197. 0141 <span class="keyword">end</span>
  198. 0142
  199. 0143 authList = sort(authList);
  200. 0144
  201. 0145 <a name="_sub4" href="#_subfunctions" class="code">function [capList] = parseDASXMLbyCapability(timeout)</a>
  202. 0146
  203. 0147 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(<span class="string">'http://www.dasregistry.org/das1/sources/'</span>,timeout);
  204. 0148
  205. 0149 <span class="keyword">if</span> (~status)
  206. 0150 <span class="comment">% error('Server is taking too long to respond. Increase timeout and try again.');</span>
  207. 0151 optList = -1;
  208. 0152 <span class="keyword">return</span>;
  209. 0153 <span class="keyword">end</span>
  210. 0154
  211. 0155 <span class="keyword">if</span> (~isstruct(xmlStruct))
  212. 0156 <span class="comment">% error('Problem parsing XML response.');</span>
  213. 0157 optList = -1;
  214. 0158 <span class="keyword">return</span>;
  215. 0159 <span class="keyword">end</span>
  216. 0160
  217. 0161 capList = {};
  218. 0162 <span class="keyword">for</span> i=1:size(xmlStruct.SOURCE,2)
  219. 0163
  220. 0164 <span class="keyword">if</span> (isfield(xmlStruct.SOURCE{i}.VERSION{1},<span class="string">'CAPABILITY'</span>))
  221. 0165
  222. 0166 <span class="keyword">for</span> k=1:size(xmlStruct.SOURCE{i}.VERSION{1}.CAPABILITY,2)
  223. 0167
  224. 0168 capTokens = regexp(xmlStruct.SOURCE{i}.VERSION{1}.CAPABILITY{k}.ATTRIBUTE.type,<span class="string">':'</span>,<span class="string">'split'</span>);
  225. 0169
  226. 0170 <span class="keyword">if</span> (~any(strcmpi(capTokens{2},capList)))
  227. 0171 capList = [capList; capTokens{2}];
  228. 0172 <span class="keyword">end</span>
  229. 0173 <span class="keyword">end</span>
  230. 0174 <span class="keyword">end</span>
  231. 0175 <span class="keyword">end</span>
  232. 0176 capList = sort(capList);
  233. 0177
  234. 0178 <a name="_sub5" href="#_subfunctions" class="code">function [res] = isValidCriteria(x)</a>
  235. 0179
  236. 0180 res = any(strcmpi(x,{<span class="string">'type'</span>,<span class="string">'organism'</span>,<span class="string">'authority'</span>,<span class="string">'capability'</span>}));</pre></div>
  237. <hr><address>Generated on Tue 17-Feb-2009 16:59:45 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
  238. </body>
  239. </html>