forked from claeis/ili2db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new option --beautifyEnumDispName to replace underscore with space fr…
…om dispName (fixes claeis#24)
- Loading branch information
Showing
11 changed files
with
191 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed, 21 Dec 2016 10:32:43 +0100 | ||
#Fri Apr 11 13:48:33 CEST 2008 | ||
versionMicro=1 | ||
versionMinor=5 | ||
versionMicro=0 | ||
versionMinor=6 | ||
versionDate=20161221 | ||
versionMajor=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Fri, 25 Nov 2016 14:52:18 +0100 | ||
#Fri Apr 11 13:48:33 CEST 2008 | ||
versionMicro=1 | ||
versionMinor=5 | ||
versionMicro=0 | ||
versionMinor=6 | ||
versionDate=20161125 | ||
versionMajor=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
INTERLIS 2.3; | ||
|
||
MODEL Enum23 | ||
AT "mailto:ce@eisenhutinformatik.ch" VERSION "2016-12-21" = | ||
|
||
DOMAIN | ||
Enum1 = (Test1, Test2_ele, Test3 (ele1, ele_2)); | ||
|
||
TOPIC TestA = | ||
|
||
CLASS ClassA1 = | ||
attr1 : TEXT*60; | ||
attr2 : Enum1; | ||
END ClassA1; | ||
|
||
END TestA; | ||
|
||
|
||
END Enum23. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package ch.ehi.ili2db; | ||
|
||
import java.io.File; | ||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.ResultSet; | ||
import java.sql.Statement; | ||
|
||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import ch.ehi.basics.logging.EhiLogger; | ||
import ch.ehi.ili2db.base.DbUrlConverter; | ||
import ch.ehi.ili2db.base.Ili2db; | ||
import ch.ehi.ili2db.base.Ili2dbException; | ||
import ch.ehi.ili2db.gui.Config; | ||
import ch.ehi.ili2db.mapping.NameMapping; | ||
|
||
//-Ddburl=jdbc:postgresql:dbname -Ddbusr=usrname -Ddbpwd=1234 | ||
public class Enum23Test { | ||
private static final String DBSCHEMA = "Enum23"; | ||
String dburl=System.getProperty("dburl"); | ||
String dbuser=System.getProperty("dbusr"); | ||
String dbpwd=System.getProperty("dbpwd"); | ||
Connection jdbcConnection=null; | ||
Statement stmt=null; | ||
@Before | ||
public void initDb() throws Exception | ||
{ | ||
Class driverClass = Class.forName("org.postgresql.Driver"); | ||
jdbcConnection = DriverManager.getConnection( | ||
dburl, dbuser, dbpwd); | ||
stmt=jdbcConnection.createStatement(); | ||
} | ||
@After | ||
public void endDb() throws Exception | ||
{ | ||
if(jdbcConnection!=null){ | ||
jdbcConnection.close(); | ||
} | ||
} | ||
public Config initConfig(String xtfFilename,String dbschema,String logfile) { | ||
Config config=new Config(); | ||
new ch.ehi.ili2pg.PgMain().initConfig(config); | ||
|
||
|
||
config.setDburl(dburl); | ||
config.setDbusr(dbuser); | ||
config.setDbpwd(dbpwd); | ||
if(dbschema!=null){ | ||
config.setDbschema(dbschema); | ||
} | ||
if(logfile!=null){ | ||
config.setLogfile(logfile); | ||
} | ||
|
||
|
||
config.setXtffile(xtfFilename); | ||
if(xtfFilename!=null && Ili2db.isItfFilename(xtfFilename)){ | ||
config.setItfTransferfile(true); | ||
} | ||
return config; | ||
|
||
} | ||
|
||
@Test | ||
public void importWithoutBeautify() throws Exception | ||
{ | ||
stmt.execute("DROP SCHEMA IF EXISTS "+DBSCHEMA+" CASCADE"); | ||
|
||
File data=new File("test/data/Enum23/Enum23.ili"); | ||
Config config=initConfig(data.getPath(),DBSCHEMA,data.getPath()+".log"); | ||
config.setFunction(Config.FC_SCHEMAIMPORT); | ||
config.setCreateFk(config.CREATE_FK_YES); | ||
config.setTidHandling(Config.TID_HANDLING_PROPERTY); | ||
config.setBasketHandling(config.BASKET_HANDLING_READWRITE); | ||
config.setCreateEnumDefs(Config.CREATE_ENUM_DEFS_MULTI); | ||
config.setCatalogueRefTrafo(null); | ||
config.setMultiSurfaceTrafo(null); | ||
config.setMultilingualTrafo(null); | ||
config.setInheritanceTrafo(null); | ||
Ili2db.readSettingsFromDb(config); | ||
Ili2db.run(config,null); | ||
|
||
{ | ||
String stmtTxt="SELECT dispName FROM "+DBSCHEMA+".enum1 WHERE ilicode ='Test2_ele'"; | ||
Assert.assertTrue(stmt.execute(stmtTxt)); | ||
ResultSet rs=stmt.getResultSet(); | ||
Assert.assertTrue(rs.next()); | ||
Assert.assertEquals("Test2_ele",rs.getString(1)); | ||
} | ||
{ | ||
String stmtTxt="SELECT dispName FROM "+DBSCHEMA+".enum1 WHERE ilicode ='Test3.ele_2'"; | ||
Assert.assertTrue(stmt.execute(stmtTxt)); | ||
ResultSet rs=stmt.getResultSet(); | ||
Assert.assertTrue(rs.next()); | ||
Assert.assertEquals("Test3.ele_2",rs.getString(1)); | ||
} | ||
|
||
} | ||
@Test | ||
public void importWithBeautify() throws Exception | ||
{ | ||
stmt.execute("DROP SCHEMA IF EXISTS "+DBSCHEMA+" CASCADE"); | ||
|
||
File data=new File("test/data/Enum23/Enum23.ili"); | ||
Config config=initConfig(data.getPath(),DBSCHEMA,data.getPath()+".log"); | ||
config.setFunction(Config.FC_SCHEMAIMPORT); | ||
config.setCreateFk(config.CREATE_FK_YES); | ||
config.setTidHandling(Config.TID_HANDLING_PROPERTY); | ||
config.setBasketHandling(config.BASKET_HANDLING_READWRITE); | ||
config.setCreateEnumDefs(Config.CREATE_ENUM_DEFS_MULTI); | ||
config.setBeautifyEnumDispName(Config.BEAUTIFY_ENUM_DISPNAME_UNDERSCORE); | ||
config.setCatalogueRefTrafo(null); | ||
config.setMultiSurfaceTrafo(null); | ||
config.setMultilingualTrafo(null); | ||
config.setInheritanceTrafo(null); | ||
Ili2db.readSettingsFromDb(config); | ||
Ili2db.run(config,null); | ||
|
||
{ | ||
String stmtTxt="SELECT dispName FROM "+DBSCHEMA+".enum1 WHERE ilicode ='Test2_ele'"; | ||
Assert.assertTrue(stmt.execute(stmtTxt)); | ||
ResultSet rs=stmt.getResultSet(); | ||
Assert.assertTrue(rs.next()); | ||
Assert.assertEquals("Test2 ele",rs.getString(1)); | ||
} | ||
{ | ||
String stmtTxt="SELECT dispName FROM "+DBSCHEMA+".enum1 WHERE ilicode ='Test3.ele_2'"; | ||
Assert.assertTrue(stmt.execute(stmtTxt)); | ||
ResultSet rs=stmt.getResultSet(); | ||
Assert.assertTrue(rs.next()); | ||
Assert.assertEquals("Test3.ele 2",rs.getString(1)); | ||
} | ||
|
||
} | ||
|
||
} |