build_get_wfs.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. <!-- eof module local properties -->
  34. <property name="passwordBase64Basic" value="${passwordBase64Basic}"/>
  35. <!--<property name="url" value="${url}"/>-->
  36. <!--<property name="api_url" value="${api_url}"/>-->
  37. <property name="typeName" value="${typeName}" />
  38. <property name="xpath" value="${xpath}"/>
  39. <property name="xpath_value" value="${xpath_value}" />
  40. <property name="php_session_id" value="${php_session_id}"/>
  41. <property name="webRootUrl" value="${webRootUrl}"/>
  42. <target name="read_build_properties" >
  43. <ant antfile="${build_WPS_Functions.xml}" target="save_build_properties"/>
  44. <loadproperties srcfile="${build_WPS_Functions.xml.properties}"/>
  45. <echo level="debug">$api_url to ${api_url} $namespace_prefix ${namespace_prefix}
  46. passwordBase64Basic=${passwordBase64Basic}
  47. </echo>
  48. </target>
  49. <target name="http_first_input">
  50. <echo message="FETCHING '${url}' ..."/>
  51. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  52. <arg line="--cookie 'PHPSESSID=${php_session_id}' '${url}&amp;REQUEST=GetFeature'"/>
  53. </exec>
  54. <echo message="OUTPUT__TYPE__XML"/>
  55. <echo message="OUTPUT__START"/>
  56. <echo message="${wfs_output}"/>
  57. <echo message="webRootUrl"></echo>
  58. <echo message="${webRootUrl}"></echo>
  59. <echo message="OUTPUT__END"/>
  60. <echo message="RESULT__START"/>
  61. <echo message="${wfs_result}"/>
  62. <echo message="RESULT__END"/>
  63. <echo message="ERROR__START"/>
  64. <echo message="${wfs_error}"/>
  65. <echo message="ERROR__END"/>
  66. </target>
  67. <target name="DescribeFeatureType" description="URL_TASK Target DescribeFeatureType">
  68. <echo message="FETCHING '${url}' ..." level="debug"/>
  69. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  70. <arg line="-H 'Authorization: Basic ${passwordBase64Basic}' &#34;${url}&amp;REQUEST=DescribeFeatureType&#34;"/>
  71. </exec>
  72. <echo message="OUTPUT__TYPE__XML"/>
  73. <echo message="OUTPUT__START"/>
  74. <echo message="${wfs_output}"/>
  75. <echo message="webRootUrl"></echo>
  76. <echo message="${webRootUrl}"></echo>
  77. <echo message="OUTPUT__END"/>
  78. <echo message="RESULT__START"/>
  79. <echo message="${wfs_result}"/>
  80. <echo message="RESULT__END"/>
  81. <echo message="ERROR__START"/>
  82. <echo message="${wfs_error}"/>
  83. <echo message="ERROR__END"/>
  84. </target>
  85. <target name="Filter_cond">
  86. <condition property="Filter_cond" taskname="Filter_check">
  87. <or>
  88. <equals arg1="${xpath}" arg2=""/>
  89. <equals arg1="${xpath}" arg2="$${uuid}"/>
  90. </or>
  91. </condition>
  92. </target>
  93. <target name="Filter_check" depends="Filter_cond,Filter_fail,Filter_ok"/>
  94. <target name="Filter_ok" unless="${Filter_cond}">
  95. <!--<mkdir dir="${get_wfs_basedir.temp}"/>
  96. <tempfile destdir="${get_wfs_basedir.temp}" suffix=".xml" prefix="Filter_ok" property="Filter.xml"/>
  97. <echoxml file="${Filter.xml}"></echoxml>
  98. <loadfile property="Filter.xml_file" srcfile="${Filter.xml}"/>-->
  99. <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;"/>
  100. </target>
  101. <target name="Filter_fail" if="${Filter_cond}">
  102. <echo level="debug">#94 filter not set</echo>
  103. </target>
  104. <target name="GetFeature" description="URL_TASK Target GetFeature" depends="read_build_properties,Filter_check">
  105. <property name="get_url" value="${api_url}/${namespace_prefix}?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;typeName=${typeName}&amp;${Filter}"/>
  106. <echo message="FETCHING '${get_url}'" /> <!-- level="debug" -->
  107. <tstamp>
  108. <format property="wfs.timestamp" pattern="yyyy-MM-dd HH:mm:ss"/>
  109. </tstamp>
  110. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  111. <arg line="-H 'Authorization: Basic ${passwordBase64Basic}' '${get_url}'"/><!-- ${Filter} -->
  112. </exec>
  113. <!--<echo message="${wfs_output}" />-->
  114. <echo file="${wfs_output.xml}" message="${wfs_output}"/>
  115. <echo file="${wfs_result.xml}" message="${wfs_result}"/>
  116. <echo file="${wfs_error.xml}" message="${wfs_error}"/>
  117. <echoxml file="${wfs_timestamp.xml}"><wfs_timestamp>${wfs.timestamp}</wfs_timestamp></echoxml>
  118. </target>
  119. <target name="GetFeatureByLastMod" description="URL_TASK Target GetFeatureByLastMod - should do incremental retrievement" depends="read_build_properties,Filter_check"/>
  120. <target name="GetXmlByUrlVerifyRetry" description="To use from recruse ant and be verified">
  121. <!--<echo>GetXmlByUrlVerifyRetry #154 we used </echo>-->
  122. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  123. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  124. <arg line="--connect-timeout 5"/>
  125. <arg line="--max-time 240"/>
  126. <arg line="--retry 5"/>
  127. <arg line="--retry-max-time 1200"/>
  128. </exec>
  129. <!--<echo message="ERROR__START"/>-->
  130. <!--<echo>${wfs_error}</echo>-->
  131. <!--<echo message="ERROR__END"/>-->
  132. <antcall target="GetXmlByUrlVerifyRetry.validate_length"/>
  133. <!--<antcall target="GetXmlByUrlVerifyRetry_verify"/>
  134. <echo> Validate $GetXmlByUrlVerifyRetry_verify: ${GetXmlByUrlVerifyRetry_verify}</echo>
  135. <echo> Validate $warn: ${warn}</echo>-->
  136. </target>
  137. <target name="GetXmlByUrlVerifyRetry.validate_length.condition" description="To verify if downloaded file is correct" >
  138. <length file="${output}" property="output.length"/>
  139. <!--<echo> $output.length = ${output.length}</echo>-->
  140. <condition property="output.length.failed" taskname="GetXmlByUrlVerifyRetry.validate_length">
  141. <equals arg1="${output.length}" arg2="128"/>
  142. </condition>
  143. <condition property="output.length.failed.0" taskname="GetXmlByUrlVerifyRetry.validate_length.0">
  144. <equals arg1="${output.length}" arg2="0"/>
  145. </condition>
  146. </target>
  147. <target name="GetXmlByUrlVerifyRetry.validate_length" depends="GetXmlByUrlVerifyRetry.validate_length.condition">
  148. <antcall target="GetXmlByUrlVerifyRetry.validate_length.failed"/>
  149. <antcall target="GetXmlByUrlVerifyRetry.validate_length.failed.0"/>
  150. </target>
  151. <target name="GetXmlByUrlVerifyRetry.validate_length.failed" if="${output.length.failed}">
  152. <echo>GetXmlByUrlVerifyRetry.validate_length.failed #182 - first retry ! </echo>
  153. <delete file="${output}"/>
  154. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  155. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  156. <arg line="--connect-timeout 5"/>
  157. <arg line="--max-time 240"/>
  158. <arg line="--retry 5"/>
  159. <arg line="--retry-max-time 1200"/>
  160. </exec>
  161. <length file="${output}" property="output.length.try1"/>
  162. <echo> $output.length.try1 = ${output.length.try1}</echo>
  163. </target>
  164. <target name="GetXmlByUrlVerifyRetry.validate_length.failed.0" if="${output.length.failed.0}">
  165. <echo>GetXmlByUrlVerifyRetry.validate_length.failed #198 - first retry - zero length ! </echo>
  166. <delete file="${output}"/>
  167. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  168. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  169. <arg line="--connect-timeout 5"/>
  170. <arg line="--max-time 240"/>
  171. <arg line="--retry 5"/>
  172. <arg line="--retry-max-time 1200"/>
  173. </exec>
  174. <length file="${output}" property="output.length.try.0"/>
  175. <echo> $output.length.try.0 = ${output.length.try.0}</echo>
  176. </target>
  177. <target name="GetXmlByUrlVerifyRetry_verify" description="To verify if downloaded file is correct" >
  178. <xmlvalidate file="${output}" lenient="yes" failonerror="false" warn="warn" />
  179. <echo>#169 after validated ? not set any?</echo>
  180. </target>
  181. </project>