hdoc_to_mongo.ant 1.99 KB
Newer Older
1
<project name="hdoc_to_mongo" default="mongoDB">
2
3
4

	<property file="build.properties"/>
	
5
6
7
8
9
10
	<taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="lib/ant-contrib.jar"/>
        </classpath>
    </taskdef> 
		
11
	<target name="preparation">
12
13
        <mkdir dir="${tmpdir}"/>
        <chmod perm="777" dir="${tmpdir}"></chmod>
14
15
16
17
18
		<delete dir="${outputPath}" />
        <mkdir dir="${outputPath}"/>
        <chmod perm="777" dir="${outputPath}"></chmod>
    </target>
	
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
	<target name="main" depends="preparation">
        <for param="file">
            <path>
                <fileset dir="${inputPath}" includes="*.hdoc"/>
            </path>
            <sequential>
                <var name="fileName" unset="true"/>
                <basename file="@{file}" property="fileName"/>
                
                <antcall target="unzipHdoc">
                    <param name="file" value="${fileName}"/>
                </antcall>
                
                <antcall target="convertHdoc">
                    <param name="file" value="${fileName}"/>
                </antcall>
				
				<antcall target="clean" />
            </sequential>
        </for>
    </target>
	
    <target name="unzipHdoc">        
        <echo>Unzip ${inputPath}/${file}</echo>
43
44
		
		<!--unzips the hdoc to be converted-->
45
		<unzip dest="${tmpdir}" src="${inputPath}/${file}"/>
46
47
    </target>
	
48
49
50
	<target name="convertHdoc">
		<echo>Convert ${inputPath}/${file}</echo>
		<basename property="basename" file="${inputPath}/${file}" suffix=".hdoc"/>
51
        <xslt in="${tmpdir}/content.xml" out="${outputPath}/${basename}.json" style="xsl/main.xsl">
52
			<param name="fileName" expression="${basename}"/>
53
54
			<param name="inputPath" expression="${inputPath}"/>
		</xslt>
55
56
    </target>
	
57
58
59
60
	<target name="clean">
		<delete dir="${tmpdir}" />
    </target>
	
61
	<target name="mongoDB" depends="main">
62
63
64
        <exec executable="node" dir="mongo">
            <arg line="main.js"/>
        </exec>
65
    </target>
66
</project>