Commit e09fad7e authored by Tyrannas's avatar Tyrannas

supporting multiFiles

parent cc199b9d
<?xml version="1.0" encoding="UTF-8"?>
<project name="antModule" default="main" basedir="./">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib.jar"/>
</classpath>
</taskdef>
<property name="node" value="false" ></property>
<target name="main" depends="transformation, testNode, insertion">
<echo>On a fini!!</echo>
<target name="main" depends="preparation, testNode">
<for param="filename">
<path>
<fileset dir="./input" includes="*.hdoc"/>
</path>
<sequential>
<var name="newFileName" unset="true"/>
<basename property="newFileName" file="@{filename}"/>
<antcall target="unZip">
<param name="file" value="${newFileName}"/>
</antcall>
<antcall target="transformation">
<param name="file" value="${newFileName}"/>
</antcall>
<echo>${newFileName}</echo>
</sequential>
</for>
<antcall target="insertion"/>
</target>
<target name="transformation" depends="preparation">
<echo>On transforme le fichier!!</echo>
<xslt in="./input/unziped/content.xml" out="./output/result.cql" style="./xsl/hdoc_to_neo4j.xsl" classpath="./lib/saxon9he.jar">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</target>
<target name="preparation">
<echo>On initialise le dossier!</echo>
<delete dir="./output"></delete>
<mkdir dir="./output"></mkdir>
<delete dir="./input/unziped"></delete>
<mkdir dir='./input/unziped'></mkdir>
<unzip src="./input/result.hdoc" dest="./input/unziped/"/>
</target>
<target name="unZip">
<unzip src="./input/${file}" dest="./input/unziped/" overwrite="false"/>
</target>
<target name="transformation">
<sequential>
<xslt in="./input/unziped/content.xml" out="./output/${file}.cql" style="./xsl/hdoc_to_neo4j.xsl" classpath="./lib/saxon9he.jar">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<delete dir="./input/unziped"/>
<mkdir dir="./input/unziped"/>
</sequential>
</target>
<target name="insertion" if="wantToInsert">
<exec executable="node" dir="./node">
......
const fs = require('fs');
var maki = require('maki-sushi');
const config = JSON.parse(fs.readFileSync('config.json'));
const testFolder = '../output/';
fs.readdir(testFolder, (err, files) => {
files.forEach(file => {
let q = fs.readFileSync("../output/" + file).toString().replace(/[\n\t\r]/g,'').replace(/\s{4,}/g,'').split(';');
q.pop();
insert(q);
});
})
maki.config.setId(config.db,config.pwd);
maki.config.setEndpoint(config.host, config.path);
maki.config.setPort(config.port);
var queries = fs.readFileSync('../output/result.cql').toString().replace(/[\n\t\r]/g,'').replace(/\s{4,}/g,'').split(';');
queries.pop();
(function main(){
function insert(queries){
for(let i = 0; i < queries.length; ++i){
let q = queries[i];
console.log(q + ";");
......@@ -26,5 +35,5 @@ queries.pop();
});
}
}
})();
}
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