Commit 16fe948d authored by Vincent Keller's avatar Vincent Keller

Update hdoc_to_elasticsearch READ.ME. Check if input directory is empty

parent dbe218e9
......@@ -16,4 +16,11 @@ Hdoc to ElasticSearch module extract data from an Hdoc file to use it with Elast
## Dependence
-------------
No depedencies
\ No newline at end of file
No depedencies
##Utilisation
-------------
Pour utiliser ce convertisseur, veuillez suivre les étapes suivantes :
1 - Placer le(s) fichier(s) hdoc que vous souhaitez convertir dans le dossier input (des exemples sont fournis dans le dossier sample).
2 - Lancer l'un des executable run.bat ou run.sh en fonction du système d'exploitation de votre ordinateur.
3 - Récupérer le(s) résultat(s) dans le dossier output.
\ No newline at end of file
<project name="hdoc_to_elasticsearch" default="clean">
<project name="hdoc_to_elasticsearch" default="executeTransformation">
<!-- Use contribant -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
......@@ -27,32 +27,51 @@
<echo message="JSON File creation" />
<xslt in="${tmpHdoc}/${fileToParseName}/content.xml" out="${outputPath}/${fileToParseName}.json" style="xsl/content_extractor.xsl"/>
</target>
</target>
<!-- Check if input directory is empty -->
<target name="check.dir">
<fileset dir="${inputPath}" id="fileset">
<include name="*.hdoc"/>
</fileset>
<pathconvert refid="fileset" property="dir.contains-files" setonempty="false"/>
</target>
<!-- Parcours la liste des fichiers pour les transformer -->
<target name="targetAllFiles">
<!-- Use converter on all files in input -->
<target name="targetAllFiles" depends="check.dir" if="dir.contains-files">
<delete>
<fileset dir="${outputPath}">
<include name="*.json"/>
</fileset>
</delete>
<foreach target="jsonFiles" param="fileToParse">
<fileset dir="${inputPath}">
<include name="*.hdoc"/>
</fileset>
<path id="hdocFiles">
<fileset dir="${inputPath}">
<include name="*.hdoc"/>
</fileset>
</path>
</foreach>
</target>
<!-- Clear tmp files -->
<target name="clean" depends="targetAllFiles">
<echo message="Clean files" />
<!-- -->
<!-- Clear tmp files -->
<delete includeemptydirs="true" verbose="true">
<fileset dir="${tmpHdoc}"> </fileset>
<dirset dir="${tmpHdoc}" includes="**/*" />
</delete>
<echo message="Conversion end" />
</target>
<!-- Tell user that he needs to provide input -->
<target name="noFileToUse" depends="check.dir" unless="dir.contains-files">
<delete>
<fileset dir="${outputPath}">
<include name="*.json"/>
</fileset>
</delete>
<echo message="You need to provide file in input directory." />
</target>
<!-- Main target -->
<target name="executeTransformation" depends="targetAllFiles, noFileToUse">
<echo message="End transformation" />
</target>
</project>
......
......@@ -8,10 +8,17 @@
</taskdef>
<property file="build.properties"/>
<!-- Parcours la liste des fichiers pour les transformer -->
<target name="targetAllFiles">
<!-- Check if input directory is empty -->
<target name="check.dir">
<fileset dir="${inputPath}" id="fileset">
<include name="*.scar"/>
</fileset>
<pathconvert refid="fileset" property="dir.contains-files" setonempty="false"/>
</target>
<!-- Use converter on all files in input -->
<target name="targetAllFiles" depends="check.dir" if="dir.contains-files">
<delete>
<fileset dir="${outputPath}">
<include name="*.json"/>
......@@ -35,9 +42,18 @@
</target>
<!-- Tell user that he needs to provide input -->
<target name="noFileToUse" depends="check.dir" unless="dir.contains-files">
<delete>
<fileset dir="${outputPath}">
<include name="*.json"/>
</fileset>
</delete>
<echo message="You need to provide file in input directory." />
</target>
<!-- Clear tmp files -->
<target name="clean" depends="targetAllFiles">
<target name="clean" depends="targetAllFiles, noFileToUse" if="dir.contains-files">
<echo message="Clean files" />
<!-- -->
<delete includeemptydirs="true" verbose="true">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment