Commit 0bda662e authored by aperdria's avatar aperdria
Browse files

Restructuration of mindmapping_to_opale to convert several files in the...

Restructuration of mindmapping_to_opale to convert several files in the meantime ; Adding run.sh and run.bat ; Modification of the readme file ;
parent 745a8dcf
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="default">
<property name="module" value="default"/>
<!--
only for the debug
<property name="inputPath" value="test.mm"></property>
<property name="outputPath" value="content.xml"/>
<property name="converting" value="yes"/>
-->
<property name="in" location="${basedir}/input"/>
<property name="out" value="${basedir}/result"/>
<property name="resultFile" value="${basedir}/result"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${basedir}/lib/ant-contrib.jar"/>
</classpath>
</taskdef>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${basedir}/lib/ant-contrib.jar"/>
</classpath>
</taskdef>
<target name="default" depends="preparation">
<echo>----------------------------Begin of conversion----------------------------------</echo>
<!-- Sect Schema : only sect element -->
<antcall target="Makehdoc">
<param name="hdocName" value="sect"/>
</antcall>
<delete dir="${basedir}/temp"/>
<echo>----------------------------Begin of
conversion----------------------------------</echo>
<antcall target="conversion"/>
<echo>----------------------------End of conversion----------------------------------</echo>
</target>
<target depends="ifOSWindows, ifOSUnix" name="conversion"/>
<condition property="isOSUnix">
<os family="unix" />
</condition>
<condition property="isOSWindows">
<os family="windows" />
</condition>
<!-- if the OS is windows call the target run.script.windows -->
<target name="ifOSWindows" if="isOSWindows">
<echo>is Windows........</echo>
<echo>InputPath : ${inputPath}</echo>
<if>
<isset property="inputPath"/>
<then>
<antcall target="conversion.windows.input-path"/>
</then>
<else>
<antcall target="conversion.windows.no-input-path"/>
</else>
</if>
</target>
<!-- if the OS is not windows call the target run.script.unix-->
<target name="ifOSUnix" if="isOSUnix">
<echo>is Unix........</echo>
<echo>InputPath : ${inputPath}</echo>
<if>
<isset property="inputPath"/>
<then>
<antcall target="conversion.linux.input-path"/>
</then>
<else>
<antcall target="conversion.linux.no-input-path"/>
</else>
</if>
</target>
<target name="conversion.windows.input-path">
<basename property="filename" file="${inputPath}" suffix=".mm"/>
<echo>There is an input path in parameter : conversion of this file</echo>
<!-- Conversion from mm to hdoc -->
<exec dir="${basedir}/../mindmapping_to_hdoc" executable="cmd">
<arg value="${basedir}/../mindmapping_to_hdoc/run.bat"/>
<arg line="-DinputPath ./../mindmapping_to_opale/input/${filename}.mm"/>
</exec>
<copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${resultFile}/hdoc"/>
<!-- Conversion from hdoc to scar -->
<!-- Files have to be copied in hdoc_to_opale in order to be treated -->
<copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
<exec dir="${basedir}/../hdoc_to_opale" executable="cmd">
<arg value="${basedir}/../hdoc_to_opale/run.bat"/>
</exec>
<copy todir="${resultFile}/scar/${filename}">
<fileset dir="${basedir}/../hdoc_to_opale/output/${filename}"/>
</copy>
</target>
<target name="conversion.windows.no-input-path">
<echo>There is no input path in parameter : conversion of all the files in ./input</echo>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.mm"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}" suffix=".mm"/>
<!-- Conversion from mm to hdoc -->
<!-- Conversion script is call with the file in parameter (no copy of files in minmapping_to_hdoc) -->
<exec dir="${basedir}/../mindmapping_to_hdoc" executable="cmd">
<arg value="${basedir}/../mindmapping_to_hdoc/run.bat"/>
<arg line="-DinputPath ./../mindmapping_to_opale/input/${filename}.mm"/>
</exec>
<property name="filename" value="${filename}"/>
<copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${resultFile}/hdoc"/>
<!-- Conversion from hdoc to scar -->
<!-- Files have to be copied in hdoc_to_opale in order to be treated -->
<copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
<exec dir="${basedir}/../hdoc_to_opale" executable="cmd">
<arg value="${basedir}/../hdoc_to_opale/run.bat"/>
</exec>
<copy todir="${resultFile}/scar/${filename}">
<fileset dir="${basedir}/../hdoc_to_opale/output/${filename}"/>
</copy>
</sequential>
</for>
</target>
<target name="conversion.linux.input-path">
<basename property="filename" file="${inputPath}" suffix=".mm"/>
<echo>There is an input path in parameter : conversion of the file ${inputPath}</echo>
<!-- Conversion from mm to hdoc -->
<exec dir="${basedir}/../mindmapping_to_hdoc" executable="/bin/sh">
<arg value="${basedir}/../mindmapping_to_hdoc/run.sh"/>
<arg line="-DinputPath ./../mindmapping_to_opale/input/${filename}.mm"/>
</exec>
<copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${resultFile}/hdoc"/>
<!-- Conversion from hdoc to scar -->
<!-- Files have to be copied in hdoc_to_opale in order to be treated -->
<copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
<exec dir="${basedir}/../hdoc_to_opale" executable="/bin/sh">
<arg value="${basedir}/../hdoc_to_opale/run.sh"/>
</exec>
<copy todir="${resultFile}/scar/${filename}">
<fileset dir="${basedir}/../hdoc_to_opale/output/${filename}"/>
</copy>
</target>
<target name="conversion.linux.no-input-path">
<echo>There is no input path in parameter : conversion of all the files in ./input</echo>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.mm"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}" suffix=".mm"/>
<!-- Conversion from mm to hdoc -->
<!-- Conversion script is call with the file in parameter (no copy of files in minmapping_to_hdoc) -->
<exec dir="${basedir}/../mindmapping_to_hdoc" executable="/bin/sh">
<arg value="${basedir}/../mindmapping_to_hdoc/run.sh"/>
<arg line="-DinputPath ./../mindmapping_to_opale/input/${filename}.mm"/>
</exec>
<property name="filename" value="${filename}"/>
<copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${resultFile}/hdoc"/>
<!-- Conversion from hdoc to scar -->
<!-- Files have to be copied in hdoc_to_opale in order to be treated -->
<copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
<exec dir="${basedir}/../hdoc_to_opale" executable="/bin/sh">
<arg value="${basedir}/../hdoc_to_opale/run.sh"/>
</exec>
<copy todir="${resultFile}/scar/${filename}">
<fileset dir="${basedir}/../hdoc_to_opale/output/${filename}"/>
</copy>
</sequential>
</for>
</target>
<!--<target name="hdoc_conversion" depends="hdoc_conversion.input-path, hdoc_conversion.no-input-path" />
-->
<target name="preparation">
<echo>Setting up the conversion</echo>
<delete dir="${basedir}/temp"></delete>
<mkdir dir="${basedir}/temp" />
<delete dir="${basedir}/temp"/>
<mkdir dir="${basedir}/temp"/>
<delete dir="${basedir}/result"/>
<mkdir dir="${basedir}/result"/>
<delete dir="${resultFile}/hdoc"></delete>
<mkdir dir="${resultFile}/hdoc" />
<delete dir="${resultFile}/scar"></delete>
<mkdir dir="${resultFile}/scar" />
<!--<condition>
<equals arg1="${foo}" arg2=""/>
</condition> -->
<!-- //delete temp -->
<echo>--- End ----</echo>
</target>
<!-- Convert a mindMap file into a hdoc, with a xsl schema specified in the parameter -->
<target name="Makehdoc" >
<echo>Begin data conversion</echo>
<!-- to generate scar files -->
<antcall target="hdoc_conversion"/>
<antcall target="opale_conversion"/>
<!-- </condition> -->
<!--<delete dir="${resultFile}/hdoc"></delete>-->
<echo>end data conversion</echo>
</target>
<target name="hdoc_conversion">
<!-- <condition property="converting.set" else="false"> -->
<ant antfile="${basedir}/../mindmapping_to_hdoc/mindmapping_to_hdoc.ant" dir="${basedir}/../mindmapping_to_hdoc">
<property name="InputPath" value="${inputPath}"/>
</ant>
</target>
<target depends="ifOSWindows, ifOSUnix" name="opale_conversion"/>
<condition property="isOSUnix">
<os family="unix" />
</condition>
<condition property="isOSWindows">
<os family="windows" />
</condition>
<!-- if the OS is windows call the target run.script.windows -->
<target name="ifOSWindows" if="isOSWindows">
<echo>is Windows........</echo>
<antcall target="opale_conversion.windows"/>
</target>
<!-- if the OS is not windows call the target run.script.unix-->
<target name="ifOSUnix" if="isOSUnix">
<echo>is Unix........</echo>
<antcall target="opale_conversion.unix"/>
</target>
<target name="opale_conversion.windows">
<echo>This is a Windows machine.</echo>
<copy file="${resultFile}/hdoc/${hdocName}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
<exec dir="${basedir}/../hdoc_to_opale" executable="cmd">
<arg value="${basedir}/../hdoc_to_opale/run.bat"/>
</exec>
<!-- <copy file="${basedir}/../hdoc_to_opale/output/output.scar" todir="${resultFile}/scar/${hdocName}.scar"/>-->
</target>
<target name="opale_conversion.unix">
<echo>This is an Unix machine.</echo>
<copy file="${resultFile}/hdoc/${hdocName}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
<exec dir="${basedir}/../hdoc_to_opale" executable="/bin/sh">
<arg value="${basedir}/../hdoc_to_opale/run.sh"/>
</exec>
<!-- <copy file="${basedir}/../hdoc_to_opale/output/output.scar" todir="${resultFile}/scar/${hdocName}.scar"/>-->
</target>
</project>
<!-- Convert a mindMap file into a hdoc, with a xsl schema specified in the parameter -->
<target name="Makehdoc">
<echo>Begin data conversion</echo>
<mkdir dir="${basedir}/temp/${hdocName}"/>
<mkdir dir="${basedir}/temp/${hdocName}/META-INF"/>
<copy file="${basedir}/mimetype" tofile="${basedir}/temp/${hdocName}/mimetype"/>
<!-- create the container file with an XSLT transformation -->
<xslt classpath="lib/saxon9he.jar" in="${basedir}/${inputPath}"
out="${basedir}/temp/${hdocName}/META-INF/container.xml"
xslresource="${basedir}/xslt/makeContainer.xsl"/>
<!-- create the file which contains the freemind data converted-->
<xslt classpath="lib/saxon9he.jar" in="${basedir}/${inputPath}"
out="${basedir}/temp/${hdocName}/content.xml" xslresource="${basedir}/xslt/${myXSLT}"/>
<!-- zipping files as the hdoc format -->
<zip destfile="${resultFile}/${hdocName}.hdoc" basedir="${basedir}/temp/${hdocName}"/>
<!-- </condition> -->
<echo>end data conversion</echo>
</target>
</project>
# how to use the converter
#1 : you want to convert your freemindFile in Opale
- put your freemind file in the mindmapping_to_opale
- enter the command line :
- linux : ant -buildfile mindmapping_to_opale.ant -DinputPath <yourFilename>
- windows : C:\ant\bin\ant -buildfile mindmapping_to_opale.ant -DinputPath <yourFilename>
you will find the result in the folder result/opale
@echo off
set lib=lib
set ant=mindmapping_to_opale.ant
set antparam=-Dprogram.param=%1
set scJarList=%lib%\*
java.exe -classpath "%scJarList%" -Xmx150m org.apache.tools.ant.Main -buildfile %ant% %antparam%
pause
REM start /MIN java.exe -classpath "%scJarList%" -Xmx150m org.apache.tools.ant.Main -buildfile %ant% %antparam%
#!/bin/sh
lib="lib"
ant="mindmapping_to_opale.ant"
antparam="-Dprogram.param=$1"
inputPath="$2"
#Recherche de java et controle que se soit une version SUN
vJavaCmd="java"
xCheckJava () {
vInputVarName=\$"$1"
vInputVarVal=`eval "expr \"$vInputVarName\" "`
if [ -z "$vInputVarVal" ];then
eval "$1=false"
return
fi
vSunJavaFound=`$vInputVarVal -version 2>&1 | grep -Eo -m 1 "(HotSpot)|(OpenJDK)"`
if [ "$vSunJavaFound" != "HotSpot" ] && [ "$vSunJavaFound" != "OpenJDK" ] ; then
eval "$1=false"
return
fi
}
xCheckJava vJavaCmd
if [ "$vJavaCmd" = "false" ]; then
vJavaCmd="$JAVA_HOME/bin/java"
xCheckJava vJavaCmd
if [ "$vJavaCmd" = "false" ]; then
echo "ERREUR: JRE de SUN introuvable. Veuillez déclarer la variable d'environnement JAVA_HOME."
exit 1
fi
fi
#Lancer la commande
scJarList="$lib/*"
if [ "$inputPath" == '' ] ; then
echo "Appel sans paramètre"
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam
else
echo "Appel avec paramètre"
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam -DinputPath $inputPath
fi
\ No newline at end of file
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