hdoc_to_elasticsearch.ant 1.71 KB
Newer Older
Gregory's avatar
Gregory committed
1
2
<project name="hdoc_to_elasticsearch" default="clean"> 
	
Gregory's avatar
Gregory committed
3
4
5
6
7
8
9
	<!-- Use contribant -->
	<taskdef resource="net/sf/antcontrib/antcontrib.properties">
	  <classpath>
		<pathelement location="lib/ant-contrib-0.3.jar"/>
	  </classpath>
	</taskdef>

Gregory's avatar
Gregory committed
10
11
	<property file="build.properties"/>     
	
Gregory's avatar
Gregory committed
12
	<target name="jsonFiles"> 
Gregory's avatar
Gregory committed
13
		<echo message="Conversion begin" />
Gregory's avatar
Gregory committed
14
		<echo>Entry file : ${fileToParse}</echo>
Gregory's avatar
Gregory committed
15

Gregory's avatar
Gregory committed
16
		<!-- create subdirectory for each file -->
Gregory's avatar
Gregory committed
17
18
19
20
21
22
23
24
		<mkdir dir="${tmpHdoc}" />
		<basename property="fileToParseName" file="${inputPath}/${fileToParse}" suffix=".hdoc" />
		<mkdir dir="${tmpHdoc}/${fileToParseName}"/>
		
		<!--unzips the hdoc to be converted into the previously created directory --> 
		<unzip dest="${tmpHdoc}/${fileToParseName}">
			<fileset dir="${inputPath}"> 			
				<include name="${fileToParseName}.hdoc"/> 			
Gregory's avatar
Gregory committed
25
26
27
28
			</fileset> 		
		</unzip> 		

		<echo message="JSON File creation" /> 		
Gregory's avatar
Gregory committed
29
		<xslt in="${tmpHdoc}/${fileToParseName}/content.xml" out="${outputPath}/${fileToParseName}.json" style="xsl/content_extractor.xsl"/>
Gregory's avatar
Gregory committed
30
	</target> 			
Gregory's avatar
Gregory committed
31
	
Gregory's avatar
Gregory committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
	<!-- Parcours la liste des fichiers pour les transformer -->
	<target name="targetAllFiles">
		<delete>
		   <fileset dir="${outputPath}">
			  <include name="*.json"/>
		   </fileset>
		</delete>
		<foreach target="jsonFiles" param="fileToParse">
			<fileset dir="${inputPath}">
				<include name="*.hdoc"/>
			</fileset>
		</foreach>
	</target> 
	
	
Gregory's avatar
Gregory committed
47
	<!-- Clear tmp files --> 	
Gregory's avatar
Gregory committed
48
	<target name="clean" depends="targetAllFiles">         
Gregory's avatar
Gregory committed
49
50
51
52
53
54
55
56
57
58
		<echo message="Clean files" />
		<!-- -->
		<delete includeemptydirs="true" verbose="true">
			<fileset dir="${tmpHdoc}"> </fileset>
			<dirset dir="${tmpHdoc}" includes="**/*" />
		</delete>
		<echo message="Conversion end" />
	</target> 	

</project>
Gregory's avatar
Gregory committed
59