[lsc-changes] r475 - in lsc/trunk/sample: . csvtosql

sbahloul at lsc-project.org sbahloul at lsc-project.org
Sun Nov 29 16:42:22 CET 2009


Author: sbahloul
Date: 2009-11-29 16:42:22 +0100 (Sun, 29 Nov 2009)
New Revision: 475

Added:
   lsc/trunk/sample/csvtosql.jar
   lsc/trunk/sample/csvtosql/
   lsc/trunk/sample/csvtosql/sample-utf8.csv
   lsc/trunk/sample/csvtosql/sample.csv
   lsc/trunk/sample/csvtosql/sample.xml
   lsc/trunk/sample/shutdown.sql
Modified:
   lsc/trunk/sample/build.xml
   lsc/trunk/sample/sample-pregen.sql
Log:
Synchronize sample files with lsc-sample (#103)

Modified: lsc/trunk/sample/build.xml
===================================================================
--- lsc/trunk/sample/build.xml	2009-11-29 15:21:54 UTC (rev 474)
+++ lsc/trunk/sample/build.xml	2009-11-29 15:42:22 UTC (rev 475)
@@ -1,39 +1,35 @@
 <project name="lsc-sample">
 
-	<property name="sample.dir" value="." />
-	<property name="dbmonster.home" value="${sample.dir}/dbmonster" />
-	<property file="build.properties" />
-
 	<target name="createHsqlDB" unless="${execution.path}" description="Create the HsqlDB structure">
+		<echo>Creating database structure from SQL files</echo>
 		<property file="${sample.dir}/database.properties" />
-		<sql autocommit="true" caching="false" showheaders="true" classpathref="execution.path" driver="${driver}" password="${password}" url="${url}" userid="${username}" onerror="abort" src="${sample.dir}/sample-pregen.sql"/>
+		<sql autocommit="true" caching="false" showheaders="true" classpathref="execution.path" driver="${driver}" password="${password}" url="${url}" userid="${username}" onerror="abort" src="${sample.dir}/sample-pregen.sql" />
 	</target>
 
-	<target name="runDbMonster" description="Run the dbMonster tool to fill the inline HsqlDB database">
-		<available file="${dbmonster.home}" type="dir" property="dbmonster.home.ok" />
-		<antcall target="untarDbMonster"/>
-		<available file="${dbmonster.home}" type="dir" property="dbmonster.home.ok" />
-		<fail unless="dbmonster.home.ok" message="'dbmonster.home' must be set in build.properties" />
-		<path id="dbmonster.classpath">
+	<target name="runCsvToSql" description="Run the csvtosql tool to fill the inline HsqlDB database">
+		<copy todir="${sample.dir}/csvtosql" encoding='ISO8859-1' outputencoding='UTF-8'>
+			<fileset dir="${sample.dir}/csvtosql" includes="**/*.csv"/>
+			<mapper type="glob" from="*.csv" to="*-utf8.csv"/>
+		</copy>
+		<path id="csvtosql.path">
 			<path refid="execution.path"/>
-			<fileset dir="${dbmonster.home}" includes="**/*.jar" />
+			<fileset dir="${sample.dir}" includes="**/csvtosql.jar" />
 		</path>
-		<taskdef name="dbmonster" classname="pl.kernelpanic.dbmonster.ant.DBMonsterTask" classpathref="dbmonster.classpath" />
-
-		<!-- Adding close.sql to shutdown HsqlDB engine in order to be able to launch synchronization -->
-		<dbmonster config="${sample.dir}/dbmonster.properties" verbose="true" postscript="${sample.dir}/close.sql" >
-			<fileset dir="${sample.dir}" includes="dbmonster-schema.xml" />
-		</dbmonster>
+		<echo>Launching CsvToSql engine on ${source.name} CSV file</echo>
+                <java classname="net.sf.csv2sql.frontends.console.ConsoleMain" classpathref="csvtosql.path" fork="true" maxmemory="512M" dir="${build.classes.dir}">
+                        <arg line="-d '${sample.dir}/csvtosql/${source.name}.xml'" /> 
+                </java>
+		<concat destfile="${build.classes.dir}/sample.sql" append="true">
+			<fileset dir="${sample.dir}" includes="shutdown.sql"/>
+		</concat>
+		<property file="${sample.dir}/database.properties" />
+		<sql autocommit="true" caching="false" showheaders="true" classpathref="execution.path" driver="${driver}" password="${password}" url="${url}" userid="${username}" onerror="abort" src="${build.classes.dir}/sample.sql" />
 	</target>
 
-	<target name="all" depends="createHsqlDB,runDbMonster" description="run all sample tasks" />
-
-	<target name="untarDbMonster" description="Untar the dbmonster archive" unless="${dbmonster.home.ok}">
-		<untar src="${sample.dir}/dbmonster.tgz" compression="gzip" overwrite="false" dest="${sample.dir}"/>
+	<target name="all" depends="createHsqlDB,runCsvToSql" description="run all sample tasks" />
+	
+	<target name="clean" description="Clean the directory">
+		<delete file="${sample.dir}/csvtosql/sample-utf8.csv" />
 	</target>
-
-	<target name="clean" description="Remove the dbmonster directory">
-		<delete dir="${dbmonster.home}" />
-	</target>
 </project>
 

Added: lsc/trunk/sample/csvtosql/sample-utf8.csv
===================================================================
--- lsc/trunk/sample/csvtosql/sample-utf8.csv	                        (rev 0)
+++ lsc/trunk/sample/csvtosql/sample-utf8.csv	2009-11-29 15:42:22 UTC (rev 475)
@@ -0,0 +1,12 @@
+"id";"uid";"endOfValidity";"sn";"cn";"givenName";"mail";"address";"telephoneNumber"
+;"m.kowalski";"10/27/1999";"Kowalski";"Mike Kowalski";"Mike";"a0g03 at unb.ca";"2682 Route 690 Sunnyside Beach, New Brunswick";"(506) 385-2183"
+;"j.laporte";"10/28/1999";"Laporte";"Jean Laporte";"Jean";"jeanlaporte at videotron.ca";"1620 dfe la Seigneurie, Charlesbourg (Québec) G2L 2C1";"000""000""000""000""000""000""000""000""000""000""000"
+;"c.murrant";"10/28/1999";"Murrant";"Catherine L. Murrant";"Catherine";"shearwater at seascape.ns.ca";"466 Sand Lake Rd. RR 1 Port Morien, Nova Scotia, B0A 1T0";"(902)737-2684"
+;"m.boschat";"10/28/1999";"Boschat";"Michael Boschat";"Michael";"mboschat at ns.sympatico.ca";"6306 Cork St., Apt.512, Halifax, Nova Scotia";"902-455-6831"
+;"t.macphee-davidson";"10/28/1999";"MacPhee-Davidson";"Tammie MacPhee-Davidson";"Tammie";"macphetd at gov.ns.ca";"103 Kearney Lake Road, Apt. 202";"(902)443-8761"
+;"b.wagar";"10/28/1999";"Wagar";"Brent Wagar";"Brent";"bwagar at trojanuv.com";"275 Berkshire Drive";"(519) 471-0927"
+;"s.weir";"10/28/1999";"Weir";"Shawna Weir";"Shawna";"shawna at beaconsecurities.ns.ca";;
+;"g.kijek";"10/28/1999";"Kijek";"Gord Kijek";"Gord";"kijek at planet.eon.net";"13028 - 32 Street, Edmonton, AB T5A 3E3";"(780)475-4058"
+;"j.parker";"10/29/1999";"Parker";"Janet Parker";"Janet";"grammy at nb.sympatico.ca";"24 Hazelton Rd. Doaktown, N B";"506-365-7817"
+;"d.tindall";"10/29/1999";"Tindall";"David Tindall";"David";"david.tindall at dal.ca";"3231 Glendale Road hailfax, NS B3L 3S4";"(902) 455-7456"
+;"c.boivin";"10/31/1999";"Boivin";"Claude Boivin";"Claude";"cboivin at destination.ca";"1265 des Cormiers St-Félicien";"418-679-8194"

Added: lsc/trunk/sample/csvtosql/sample.csv
===================================================================
--- lsc/trunk/sample/csvtosql/sample.csv	                        (rev 0)
+++ lsc/trunk/sample/csvtosql/sample.csv	2009-11-29 15:42:22 UTC (rev 475)
@@ -0,0 +1,12 @@
+"id";"uid";"endOfValidity";"sn";"cn";"givenName";"mail";"address";"telephoneNumber"
+;"m.kowalski";"10/27/1999";"Kowalski";"Mike Kowalski";"Mike";"a0g03 at unb.ca";"2682 Route 690 Sunnyside Beach, New Brunswick";"(506) 385-2183"
+;"j.laporte";"10/28/1999";"Laporte";"Jean Laporte";"Jean";"jeanlaporte at videotron.ca";"1620 dfe la Seigneurie, Charlesbourg (Québec) G2L 2C1";
+;"c.murrant";"10/28/1999";"Murrant";"Catherine L. Murrant";"Catherine";"shearwater at seascape.ns.ca";"466 Sand Lake Rd. RR 1 Port Morien, Nova Scotia, B0A 1T0";"(902)737-2684"
+;"m.boschat";"10/28/1999";"Boschat";"Michael Boschat";"Michael";"mboschat at ns.sympatico.ca";"6306 Cork St., Apt.512, Halifax, Nova Scotia";"902-455-6831"
+;"t.macphee-davidson";"10/28/1999";"MacPhee-Davidson";"Tammie MacPhee-Davidson";"Tammie";"macphetd at gov.ns.ca";"103 Kearney Lake Road, Apt. 202";"(902)443-8761"
+;"b.wagar";"10/28/1999";"Wagar";"Brent Wagar";"Brent";"bwagar at trojanuv.com";"275 Berkshire Drive";"(519) 471-0927"
+;"s.weir";"10/28/1999";"Weir";"Shawna Weir";"Shawna";"shawna at beaconsecurities.ns.ca";;
+;"g.kijek";"10/28/1999";"Kijek";"Gord Kijek";"Gord";"kijek at planet.eon.net";"13028 - 32 Street, Edmonton, AB T5A 3E3";"(780)475-4058"
+;"j.parker";"10/29/1999";"Parker";"Janet Parker";"Janet";"grammy at nb.sympatico.ca";"24 Hazelton Rd. Doaktown, N B";"506-365-7817"
+;"d.tindall";"10/29/1999";"Tindall";"David Tindall";"David";"david.tindall at dal.ca";"3231 Glendale Road hailfax, NS B3L 3S4";"(902) 455-7456"
+;"c.boivin";"10/31/1999";"Boivin";"Claude Boivin";"Claude";"cboivin at destination.ca";"1265 des Cormiers St-Félicien";"418-679-8194"

Added: lsc/trunk/sample/csvtosql/sample.xml
===================================================================
--- lsc/trunk/sample/csvtosql/sample.xml	                        (rev 0)
+++ lsc/trunk/sample/csvtosql/sample.xml	2009-11-29 15:42:22 UTC (rev 475)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+	<!-- CONFIGURATOR DATA -->
+	<descriptor version="3"/>
+		<!-- DEFINE HERE TABLE STRUCTURE -->
+		<structure tablename="inetOrgPerson">
+			<field name="id" type="VARCHAR"/>
+			<field name="uid" type="VARCHAR"/>
+			<field name="endOfValidity" type="VARCHAR"/>
+			<field name="sn" type="VARCHAR"/>
+			<field name="cn" type="VARCHAR"/>
+			<field name="givenName" type="VARCHAR"/>
+			<field name="mail" type="VARCHAR"/>
+			<field name="address" type="VARCHAR"/>
+			<field name="telephoneNumber" type="VARCHAR"/>
+		</structure>
+
+		<!-- WHAT GRAMMAR USE -->
+		<grammar class="net.sf.csv2sql.grammars.standard.GrammarFactory"/>
+
+		<!-- TEMPORARY STORAGE -->
+		<storage class="net.sf.csv2sql.storage.Memory"/>
+
+		<!-- RENDERER CONFIGURATION -->
+		<render class="net.sf.csv2sql.renders.SqlInsertRenderer">
+
+		<param name="inputfile" value="sample-utf8.csv"/>
+		<param name="separator" value=";"/>
+		<!--optional-->
+		<param name="trimdata"           value="true"/>
+		<param name="suppressheader"     value="true"/>
+		<param name="removedoublequotes" value="true"/>
+	</render>
+
+	<!-- WRITER CONFIGURATION -->
+	<output>
+    <writerAppender active="true"
+        class="net.sf.csv2sql.writers.SqlFileWriter">
+        <param name="filename"  value="sample.sql"/>
+    </writerAppender>
+
+<!--
+		<writerAppender active="true" class="net.sf.csv2sql.writers.JdbcWriter">
+		<param name="driver"   value="org.hsqldb.jdbcDriver"/>
+		<param name="url"      value="jdbc:hsqldb:file:hsqldb/lsc"/>
+		<param name="username" value="sa"/>
+		<param name="password" value=""/>
+
+		<param name="commit"   value="false"/>
+		<param name="commitbatchcount"   value="0"/>
+
+	</writerAppender>
+-->
+
+	</output>
+</root>

Added: lsc/trunk/sample/csvtosql.jar
===================================================================
(Binary files differ)


Property changes on: lsc/trunk/sample/csvtosql.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: lsc/trunk/sample/sample-pregen.sql
===================================================================
--- lsc/trunk/sample/sample-pregen.sql	2009-11-29 15:21:54 UTC (rev 474)
+++ lsc/trunk/sample/sample-pregen.sql	2009-11-29 15:42:22 UTC (rev 475)
@@ -1,53 +1,17 @@
-CREATE TABLE person (
-	id integer NOT NULL PRIMARY KEY,
-	sn varchar(30) NOT NULL,
-	givenName varchar(20) NOT NULL,
-	end_of_validity timestamp NOT NULL,
-	general_title_id integer default NULL,
-	manager_id integer NOT NULL,
-	structure_id integer NOT NULL,
-	location_id integer default NULL
+CREATE TABLE inetOrgPerson (
+	id INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
+	uid varchar(255),
+	endOfValidity varchar(255),
+	sn varchar(255),
+	cn varchar(255),
+	givenName varchar(255),
+	mail varchar(255),
+	telephoneNumber varchar(255),
+	address varchar(255)
 );
 
-CREATE INDEX person_manager ON person (manager_id);
-CREATE INDEX person_structure ON person (structure_id);
-CREATE INDEX person_location ON person (location_id);
+CREATE INDEX inetOrgPerson_id ON inetOrgPerson (id);
+CREATE INDEX inetOrgPerson_uid ON inetOrgPerson (uid);
 
-CREATE TABLE structure (
-	id integer NOT NULL PRIMARY KEY,
-	code varchar(20) NOT NULL,
-	description varchar(255) default NULL
-);
-
-CREATE TABLE activity (
-	id integer NOT NULL PRIMARY KEY,
-	person_id integer NOT NULL,
-	structure_id integer NOT NULL,
-	title_id integer NOT NULL
-);
-
-CREATE INDEX activity_person ON activity (person_id);
-CREATE INDEX activity_structure ON activity (structure_id);
-
-CREATE TABLE title (
-	id integer NOT NULL PRIMARY KEY,
-	code varchar(20) NOT NULL,
-	description varchar(255) default NULL
-);
-
-CREATE TABLE location (
-	id integer NOT NULL PRIMARY KEY,
-	street varchar(255) NOT NULL,
-	postal_code integer NOT NULL,
-	l varchar(255) NOT NULL
-);
-
-CREATE TABLE computer (
-	id integer NOT NULL PRIMARY KEY,
-	hostname varchar(255) NOT NULL,
-	end_of_validity timestamp NOT NULL,
-	password varchar(255) NOT NULL
-);
-
 COMMIT;
 SHUTDOWN;

Added: lsc/trunk/sample/shutdown.sql
===================================================================
--- lsc/trunk/sample/shutdown.sql	                        (rev 0)
+++ lsc/trunk/sample/shutdown.sql	2009-11-29 15:42:22 UTC (rev 475)
@@ -0,0 +1,2 @@
+SHUTDOWN;
+



More information about the lsc-changes mailing list