build_get_wfs.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns:ogc="http://www.opengis.net/ogc"
  3. basedir="../../." name="example wfs" default="http_first_input">
  4. <description>
  5. Based on ant-url-action module to ordinary retrieve feature from WMF
  6. To be called from CRM_PROCES_Tree etc
  7. </description>
  8. <!-- file:/SE/schema/ant-url_action/default_db.in7_dziennik_koresp/test-get-wfs-xml/build.xml -->
  9. <!-- sample URL which call this exact variables in this ANT build -->
  10. <!-- przykladowy URL ktory przekazuje parametry do tego ANT -->
  11. <!--https://biuro.biall-net.pl/SE/version-git/index.php?_route=UrlAction_Ant&_task=ant&
  12. path=${default_db.in7_dziennik_koresp/test-get-wfs-xml} - this is the place to keep ant build (directory name with build.xml)
  13. &namespace=p5_default_db:Rozdzielcza_test_bzyk_PE&featureID=123 - this is setting the <property name="url" value="${url}"/> - to point what is record/table to download
  14. <property name="uuid" value="${uuid}"/> it is automatically also set to enable uinque transaction and to allow to save data with user
  15. <property name="passwordBase64Basic" value="${passwordBase64Basic}"/> - this is also set - to enable communicate with API -
  16. <property name="DwebRootUrl" value="${$webRootUrl}"/> - this is the place where script is localized to easyli to target user GUI by href to generated output
  17. />
  18. -->
  19. <!-- modules WPS_Functions - to be copied to any module needed -->
  20. <property name="WPS_Functions" location="${basedir}/WPS_Functions"/>
  21. <property name="build_WPS_Functions.xml" location="${WPS_Functions}/build_WPS_Functions.xml"/> <!-- call it to get properties -->
  22. <property name="build_WPS_Functions.xml.properties" location="${build_WPS_Functions.xml}.properties"/>
  23. <!-- eof modules WPS_Functions -->
  24. <!-- module local properties -->
  25. <property name="get_wfs_basedir" location="${basedir}/WPS_Functions/get_wfs"/><!-- to ordinary retrieve wfs data -->
  26. <property name="get_wfs_basedir.temp" location="${get_wfs_basedir}/temp"/>
  27. <property name="get_wfs" location="${get_wfs_basedir}/build_get_wfs.xml"/><!-- to ordinary retrieve wfs data -->
  28. <property name="uuid" value="${uuid}"/>
  29. <property name="wfs_output.xml" location="${get_wfs_basedir.temp}/${uuid}.wfs_output.xml"/>
  30. <property name="wfs_result.xml" location="${get_wfs_basedir.temp}/${uuid}.wfs_result.xml"/>
  31. <property name="wfs_error.xml" location="${get_wfs_basedir.temp}/${uuid}.wfs_error.xml"/>
  32. <property name="wfs_timestamp.xml" location="${get_wfs_basedir.temp}/${uuid}.wfs_timestamp.xml"/>
  33. <!-- for sending xml - param inputs -->
  34. <property name="wfs_input.xml" location="${get_wfs_basedir.temp}/${uuid}.wfs_input.xml"/>
  35. <!-- eof module local properties -->
  36. <property name="passwordBase64Basic" value="${passwordBase64Basic}"/>
  37. <!--<property name="url" value="${url}"/>-->
  38. <!--<property name="api_url" value="${api_url}"/>-->
  39. <property name="typeName" value="${typeName}" />
  40. <property name="xpath" value="${xpath}"/>
  41. <property name="xpath_value" value="${xpath_value}" />
  42. <property name="php_session_id" value="${php_session_id}"/>
  43. <property name="webRootUrl" value="${webRootUrl}"/>
  44. <target name="read_build_properties" >
  45. <ant antfile="${build_WPS_Functions.xml}" target="save_build_properties"/>
  46. <loadproperties srcfile="${build_WPS_Functions.xml.properties}"/>
  47. <echo level="debug">$api_url to ${api_url} $namespace_prefix ${namespace_prefix}
  48. passwordBase64Basic=${passwordBase64Basic}
  49. </echo>
  50. </target>
  51. <target name="http_first_input">
  52. <echo message="FETCHING '${url}' ..."/>
  53. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  54. <arg line="--cookie 'PHPSESSID=${php_session_id}' '${url}&amp;REQUEST=GetFeature'"/>
  55. </exec>
  56. <echo message="OUTPUT__TYPE__XML"/>
  57. <echo message="OUTPUT__START"/>
  58. <echo message="${wfs_output}"/>
  59. <echo message="webRootUrl"></echo>
  60. <echo message="${webRootUrl}"></echo>
  61. <echo message="OUTPUT__END"/>
  62. <echo message="RESULT__START"/>
  63. <echo message="${wfs_result}"/>
  64. <echo message="RESULT__END"/>
  65. <echo message="ERROR__START"/>
  66. <echo message="${wfs_error}"/>
  67. <echo message="ERROR__END"/>
  68. </target>
  69. <target name="DescribeFeatureType" description="URL_TASK Target DescribeFeatureType">
  70. <echo message="FETCHING '${url}' ..." level="debug"/>
  71. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  72. <arg line="-H 'Authorization: Basic ${passwordBase64Basic}' &#34;${url}&amp;REQUEST=DescribeFeatureType&#34;"/>
  73. </exec>
  74. <echo message="OUTPUT__TYPE__XML"/>
  75. <echo message="OUTPUT__START"/>
  76. <echo message="${wfs_output}"/>
  77. <echo message="webRootUrl"></echo>
  78. <echo message="${webRootUrl}"></echo>
  79. <echo message="OUTPUT__END"/>
  80. <echo message="RESULT__START"/>
  81. <echo message="${wfs_result}"/>
  82. <echo message="RESULT__END"/>
  83. <echo message="ERROR__START"/>
  84. <echo message="${wfs_error}"/>
  85. <echo message="ERROR__END"/>
  86. </target>
  87. <target name="Filter_cond">
  88. <condition property="Filter_cond" taskname="Filter_check">
  89. <or>
  90. <equals arg1="${xpath}" arg2=""/>
  91. <equals arg1="${xpath}" arg2="$${uuid}"/>
  92. </or>
  93. </condition>
  94. </target>
  95. <target name="Filter_check" depends="Filter_cond,Filter_fail,Filter_ok"/>
  96. <target name="Filter_ok" unless="${Filter_cond}">
  97. <!--<mkdir dir="${get_wfs_basedir.temp}"/>
  98. <tempfile destdir="${get_wfs_basedir.temp}" suffix=".xml" prefix="Filter_ok" property="Filter.xml"/>
  99. <echoxml file="${Filter.xml}"></echoxml>
  100. <loadfile property="Filter.xml_file" srcfile="${Filter.xml}"/>-->
  101. <property name="Filter" value="&amp;Filter=&lt;ogc:Filter&gt;&lt;ogc:PropertyIsEqualTo&gt;&lt;ogc:PropertyName&gt;${xpath}&lt;/ogc:PropertyName&gt;&lt;ogc:Literal&gt;${xpath_value}&lt;/ogc:Literal&gt;&lt;/ogc:PropertyIsEqualTo&gt;&lt;/ogc:Filter&gt;"/>
  102. </target>
  103. <target name="Filter_fail" if="${Filter_cond}">
  104. <echo level="debug">#94 filter not set</echo>
  105. </target>
  106. <target name="GetFeature" description="URL_TASK Target GetFeature" depends="read_build_properties,Filter_check">
  107. <property name="get_url" value="${api_url}/${namespace_prefix}?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;typeName=${typeName}&amp;${Filter}"/>
  108. <echo message="FETCHING '${get_url}'" /> <!-- level="debug" -->
  109. <tstamp>
  110. <format property="wfs.timestamp" pattern="yyyy-MM-dd HH:mm:ss"/>
  111. </tstamp>
  112. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  113. <arg line="-H 'Authorization: Basic ${passwordBase64Basic}' '${get_url}'"/><!-- ${Filter} -->
  114. </exec>
  115. <!--<echo message="${wfs_output}" />-->
  116. <echo file="${wfs_output.xml}" message="${wfs_output}"/>
  117. <echo file="${wfs_result.xml}" message="${wfs_result}"/>
  118. <echo file="${wfs_error.xml}" message="${wfs_error}"/>
  119. <echoxml file="${wfs_timestamp.xml}"><wfs_timestamp>${wfs.timestamp}</wfs_timestamp></echoxml>
  120. </target>
  121. <target name="PostXmlTransaction" description="TODO to post transaction based on build__for_post_to_wfs and curl_post_wfst">
  122. <exec executable="$curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result" failonerror="true">
  123. <arg value="-H 'Authorization: Basic ${passwordBase64Basic_tested}'"/>
  124. <arg value="-X"/>
  125. <arg value="POST"/>
  126. <arg value="-d"/>
  127. <arg value="${wfs_input.xml}"/>
  128. <arg value="${api_url}"/>
  129. <!--<arg value="-\-user {$Types__x3A__wfs:username}:{$Types__x3A__wfs:username-pass} "/>-->
  130. <arg value="-v"/>
  131. <arg value="--insecure"/>
  132. <!--<arg value="-O"/>
  133. <arg value="{@Target_file}"/>-->
  134. </exec>
  135. <echo file="${wfs_output.xml}" message="${wfs_output}"/>
  136. <echo file="${wfs_result.xml}" message="${wfs_result}"/>
  137. <echo file="${wfs_error.xml}" message="${wfs_error}"/>
  138. </target>
  139. <target name="GetFeatureByLastMod" description="URL_TASK Target GetFeatureByLastMod - should do incremental retrievement" depends="read_build_properties,Filter_check"/>
  140. <target name="GetXmlByUrlVerifyRetry" description="To use from recruse ant and be verified">
  141. <!--<echo>GetXmlByUrlVerifyRetry #154 we used </echo>-->
  142. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  143. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  144. <arg line="--connect-timeout 5"/>
  145. <arg line="--max-time 240"/>
  146. <arg line="--retry 5"/>
  147. <arg line="--retry-max-time 1200"/>
  148. </exec>
  149. <!--<echo message="ERROR__START"/>-->
  150. <!--<echo>${wfs_error}</echo>-->
  151. <!--<echo message="ERROR__END"/>-->
  152. <antcall target="GetXmlByUrlVerifyRetry.validate_length"/>
  153. <!--<antcall target="GetXmlByUrlVerifyRetry_verify"/>
  154. <echo> Validate $GetXmlByUrlVerifyRetry_verify: ${GetXmlByUrlVerifyRetry_verify}</echo>
  155. <echo> Validate $warn: ${warn}</echo>-->
  156. </target>
  157. <target name="GetXmlByUrlVerifyRetry.validate_length.condition" description="To verify if downloaded file is correct" >
  158. <length file="${output}" property="output.length"/>
  159. <!--<echo> $output.length = ${output.length}</echo>-->
  160. <condition property="output.length.failed" taskname="GetXmlByUrlVerifyRetry.validate_length">
  161. <equals arg1="${output.length}" arg2="128"/>
  162. </condition>
  163. <condition property="output.length.failed.0" taskname="GetXmlByUrlVerifyRetry.validate_length.0">
  164. <equals arg1="${output.length}" arg2="0"/>
  165. </condition>
  166. </target>
  167. <target name="GetXmlByUrlVerifyRetry.validate_length" depends="GetXmlByUrlVerifyRetry.validate_length.condition">
  168. <antcall target="GetXmlByUrlVerifyRetry.validate_length.failed"/>
  169. <antcall target="GetXmlByUrlVerifyRetry.validate_length.failed.0"/>
  170. </target>
  171. <target name="GetXmlByUrlVerifyRetry.validate_length.failed" if="${output.length.failed}">
  172. <echo>GetXmlByUrlVerifyRetry.validate_length.failed #182 - first retry ! </echo>
  173. <delete file="${output}" quiet="true"/>
  174. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  175. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  176. <arg line="--connect-timeout 5"/>
  177. <arg line="--max-time 240"/>
  178. <arg line="--retry 5"/>
  179. <arg line="--retry-max-time 1200"/>
  180. </exec>
  181. <length file="${output}" property="output.length.try1"/>
  182. <echo> $output.length.try1 = ${output.length.try1}</echo>
  183. </target>
  184. <target name="GetXmlByUrlVerifyRetry.validate_length.failed.0" if="${output.length.failed.0}">
  185. <echo>GetXmlByUrlVerifyRetry.validate_length.failed #198 - first retry - zero length ! </echo>
  186. <delete file="${output}" quiet="true"/>
  187. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  188. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  189. <arg line="--connect-timeout 5"/>
  190. <arg line="--max-time 240"/>
  191. <arg line="--retry 5"/>
  192. <arg line="--retry-max-time 1200"/>
  193. </exec>
  194. <length file="${output}" property="output.length.try.0"/>
  195. <echo> $output.length.try.0 = ${output.length.try.0}</echo>
  196. </target>
  197. <target name="GetXmlByUrlVerifyRetry_verify" description="To verify if downloaded file is correct" >
  198. <xmlvalidate file="${output}" lenient="yes" failonerror="false" warn="warn" />
  199. <echo>#169 after validated ? not set any?</echo>
  200. </target>
  201. </project>