From a2f34f6b460dd89168c1be5b18c40078164d8e53 Mon Sep 17 00:00:00 2001 From: vovasty Date: Wed, 18 Feb 2009 22:22:31 +0300 Subject: [PATCH] initial coords import --- rentdom-web/pom.xml | 111 +++++++++++---------- .../ru/rentdom/services/tools/CoordsImport.java | 32 ++++++ .../rentdom/services/tools/CoordsImportTest.java | 13 +++ 3 files changed, 103 insertions(+), 53 deletions(-) create mode 100644 rentdom-web/src/main/java/ru/rentdom/services/tools/CoordsImport.java create mode 100644 rentdom-web/src/test/ru/rentdom/services/tools/CoordsImportTest.java diff --git a/rentdom-web/pom.xml b/rentdom-web/pom.xml index bd8a4f4..4e90367 100644 --- a/rentdom-web/pom.xml +++ b/rentdom-web/pom.xml @@ -52,56 +52,61 @@ - org.apache.tapestry - tapestry-hibernate - ${tapestry-release-version} + org.apache.tapestry + tapestry-hibernate + ${tapestry-release-version} + + + org.hibernate + hibernate-core + + + org.hibernate + hibernate-annotations + + + + + postgresql + postgresql + 8.3-603.jdbc4 + + + org.hibernate + hibernate-core + ${hibernate-core-release-version} + + + org.hibernate + hibernate-annotations + ${hibernate-annontations-release-version} - - org.hibernate - hibernate-core - - - org.hibernate - hibernate-annotations - - - - - postgresql - postgresql - 8.3-603.jdbc4 - - - org.hibernate - hibernate-core - ${hibernate-core-release-version} - - - org.hibernate - hibernate-annotations - ${hibernate-annontations-release-version} - - - org.hibernate - hibernate - - - - - net.aramzamzam.commons - commons-hibernate - 1.0-SNAPSHOT - - - net.aramzamzam.commons - commons-tokens - 1.0-SNAPSHOT - - - net.aramzamzam.commons - commons-pages-behavoir - 1.0-SNAPSHOT - + + org.hibernate + hibernate + + + + + net.aramzamzam.commons + commons-hibernate + 1.0-SNAPSHOT + + + net.aramzamzam.commons + commons-tokens + 1.0-SNAPSHOT + + + net.aramzamzam.commons + commons-pages-behavoir + 1.0-SNAPSHOT + + + dk.eobjects.metamodel + MetaModel-full + 1.1.4 + rentdom-web @@ -173,10 +178,10 @@ OpenQA Release Repository http://archiva.openqa.org/repository/releases/ - - localhost.nu - http://www.localhost.nu/java/mvn - + + localhost.nu + http://www.localhost.nu/java/mvn + diff --git a/rentdom-web/src/main/java/ru/rentdom/services/tools/CoordsImport.java b/rentdom-web/src/main/java/ru/rentdom/services/tools/CoordsImport.java new file mode 100644 index 0000000..365d43f --- /dev/null +++ b/rentdom-web/src/main/java/ru/rentdom/services/tools/CoordsImport.java @@ -0,0 +1,32 @@ +package ru.rentdom.services.tools; + +import java.io.File; + +import dk.eobjects.metamodel.DataContext; +import dk.eobjects.metamodel.DataContextFactory; +import dk.eobjects.metamodel.data.DataSet; +import dk.eobjects.metamodel.query.Query; +import dk.eobjects.metamodel.schema.Column; +import dk.eobjects.metamodel.schema.Schema; +import dk.eobjects.metamodel.schema.Table; + +public class CoordsImport { + public void process() + { + DataContext dataContext = DataContextFactory.createExcelDataContext(new File("/Users/vovasty/Documents/SampleData.xls"), false); + Schema schema = dataContext.getDefaultSchema(); + // A simple way of getting the table object is just to pick the first one (the first sheet in the spreadsheet) + Table table = schema.getTables()[0]; + Column countryColumn = table.getColumnByName("country"); + Column townColumn = table.getColumnByName("town"); + Column districtColumn = table.getColumnByName("district"); + Column streetColumn = table.getColumnByName("street"); + Column metroColumn = table.getColumnByName("metro"); + Query q = new Query().select(countryColumn, townColumn, districtColumn, streetColumn, metroColumn).from(table); + DataSet dataSet = dataContext.executeQuery(q); + while (dataSet.next()) { + System.out.println(dataSet.getRow()); + } + dataSet.close(); + } +} diff --git a/rentdom-web/src/test/ru/rentdom/services/tools/CoordsImportTest.java b/rentdom-web/src/test/ru/rentdom/services/tools/CoordsImportTest.java new file mode 100644 index 0000000..452a09a --- /dev/null +++ b/rentdom-web/src/test/ru/rentdom/services/tools/CoordsImportTest.java @@ -0,0 +1,13 @@ +package ru.rentdom.services.tools; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class CoordsImportTest extends Assert{ + @Test + public void testProcess() + { + CoordsImport im=new CoordsImport(); + im.process(); + } +} -- 2.11.4.GIT