diff --git a/db.properties b/db.properties new file mode 100644 index 0000000..8ec6509 --- /dev/null +++ b/db.properties @@ -0,0 +1,7 @@ +URL=jdbc:postgresql://localhost/petroparser +USER=petroparser +PASSWORD=petroparser +WOERTERBUCH=woerterbuch.woerterbuch +SCHLUESSELTYPEN=woerterbuch.schluesseltypen +SCHLUESSELMAPPING=bml.bml_schluesselmapping +DATEFIELD=PETRO diff --git a/src/main/antlr4/org/sep3tools/gen/PetroGrammar.g4 b/src/main/antlr4/org/sep3tools/gen/PetroGrammar.g4 index 2bc6921..2324732 100644 --- a/src/main/antlr4/org/sep3tools/gen/PetroGrammar.g4 +++ b/src/main/antlr4/org/sep3tools/gen/PetroGrammar.g4 @@ -10,13 +10,16 @@ bestandteile: ; uebergang_bes: - b1=bestandteil '-' b2=bestandteil + bestandteil ('-' bestandteil)+ | '(' uebergang_bes ')' ( '(' attribute ')' )? ; bestandteil: - TEIL ( '(' attribute ')' )? - | '(' TEIL ( '(' attribute ')' )? ')'; + TEIL ( '(' attribute ')' )? # bestandteil_simple + | '(' bestandteil ')' # bestandteil_klammer + | bestandteil FRAGLICH # bestandteil_fraglich + | bestandteil SICHER # bestandteil_sicher +; attribute: attribut # att @@ -24,6 +27,7 @@ attribute: | attr=attribute '(' unter=attribute ')' # unter_Attribute | attribute ',' attribute # Aufzaehlung_a ; + uebergang_att: attribut '-' attribut; attribut: @@ -31,7 +35,7 @@ attribut: | attribut FRAGLICH # attr_fraglich | attribut SICHER # attr_sicher | TIEFE # attr_tiefe - ; +; TIEFE: ([0-9]|'.')+; TEIL: ANY+; diff --git a/src/main/java/org/sep3tools/BmlVisitor.java b/src/main/java/org/sep3tools/BmlVisitor.java index 0da39cb..8513df6 100644 --- a/src/main/java/org/sep3tools/BmlVisitor.java +++ b/src/main/java/org/sep3tools/BmlVisitor.java @@ -46,13 +46,11 @@ public String visitSchichtbeschreibung(PetroGrammarParser.SchichtbeschreibungCon return visitChildren(ctx); } - /** - * process single soil, remove quantifier, if present - * @param ctx the parse tree - * @return translated string for soil parse tree - */ - @Override - public String visitBestandteil(PetroGrammarParser.BestandteilContext ctx) { + public String visitBestandteil_klammer(PetroGrammarParser.Bestandteil_klammerContext ctx) { + return visitBestandteil_simple((PetroGrammarParser.Bestandteil_simpleContext) ctx.bestandteil()); + } + + public String visitBestandteil_simple(PetroGrammarParser.Bestandteil_simpleContext ctx) { String boden = getBodenTerm(ctx.TEIL().getText()); String attrib; if (isNull(ctx.attribute())) { @@ -73,6 +71,26 @@ else if (attr.startsWith(" (")) { return boden + "," + attrib; } + /** + * Visit a parse tree produced by the {@code bestandteil_sicher} labeled alternative + * in {@link PetroGrammarParser}. + * @param ctx the parse tree + * @return the visitor result + */ + public String visitBestandteil_sicher(PetroGrammarParser.Bestandteil_sicherContext ctx) { + return visitChildren(ctx); + } + + /** + * Visit a parse tree produced by the {@code bestandteil_fraglich} labeled alternative + * in {@link PetroGrammarParser}. + * @param ctx the parse tree + * @return the visitor result + */ + public String visitBestandteil_fraglich(PetroGrammarParser.Bestandteil_fraglichContext ctx) { + return visitChildren(ctx); + } + private String getBodenTerm(String boden) { String bodenTerm = getBmlResultSet(boden); if (!bodenTerm.isEmpty()) @@ -122,14 +140,21 @@ public String visitAttr(PetroGrammarParser.AttrContext ctx) { */ @Override public String visitUebergang_bes(PetroGrammarParser.Uebergang_besContext ctx) { - String teile; + String teile = ""; String attrib; if (ctx.getText().startsWith(" (")) { teile = visit(ctx.uebergang_bes()); } else { - teile = visit(ctx.b1) + ", " + visit(ctx.b2); + for (PetroGrammarParser.BestandteilContext teil : ctx.bestandteil()) { + if (teile.isEmpty()) { + teile = visit(teil); + } + else { + teile = teile + ", " + visit(teil); + } + } } if (isNull(ctx.attribute())) { attrib = ""; diff --git a/src/main/java/org/sep3tools/JavaConnector.java b/src/main/java/org/sep3tools/JavaConnector.java index 47f70b3..e932446 100644 --- a/src/main/java/org/sep3tools/JavaConnector.java +++ b/src/main/java/org/sep3tools/JavaConnector.java @@ -1,6 +1,11 @@ package org.sep3tools; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.sql.*; +import java.util.Properties; import java.util.logging.Logger; /** @@ -12,25 +17,54 @@ */ public final class JavaConnector { + private static boolean credChanged = true; + private static final Logger LOG = Logger.getLogger(JavaConnector.class.getName()); private static String m_url = "jdbc:default:connection"; - private static String user = ""; + private static String user; + + private static String pass; - private static String pass = ""; + private static String wb; - private static String wb = "woerterbuch.\"Woerterbuch\""; + private static String st; - private static String st = "woerterbuch.\"Schluesseltypen\""; + private static String sm; - private static String sm = "bml.bml_schluesselmapping"; + private static String df; - private static String df = "PETRO"; + private static Connection conn; private JavaConnector() { } + public static void setPropertiesFile(String filename) { + credChanged = true; + try { + File file = new File(filename); + FileInputStream fileInput = new FileInputStream(file); + Properties properties = new Properties(); + properties.load(fileInput); + fileInput.close(); + + setUrl(properties.getProperty("URL")); + setUser(properties.getProperty("USER")); + setPass(properties.getProperty("PASSWORD")); + setWb(properties.getProperty("WOERTERBUCH")); + setSt(properties.getProperty("SCHLUESSELTYPEN")); + setSm(properties.getProperty("SCHLUESSELMAPPING")); + setDf(properties.getProperty("DATEFIELD")); + } + catch (FileNotFoundException e) { + e.printStackTrace(); + } + catch (IOException e) { + e.printStackTrace(); + } + } + public static void setWb(String wb) { JavaConnector.wb = wb; } @@ -47,20 +81,30 @@ public static void setDf(String df) { JavaConnector.df = df; } - public static void setUser(String user) { - JavaConnector.user = user; + public static void setUser(String newUser) { + credChanged = true; + JavaConnector.user = newUser; } - public static void setPass(String pass) { - JavaConnector.pass = pass; + public static void setPass(String newPass) { + credChanged = true; + JavaConnector.pass = newPass; } - public static void setUrl(String url) { - JavaConnector.m_url = url; + public static void setUrl(String newUrl) { + credChanged = true; + JavaConnector.m_url = newUrl; } // String query = "SELECT Klartext from woerterbuch.Woerterbuch where Kuerzel="; + private static void setConn(String url, String user, String pass) throws SQLException { + if (conn != null && !conn.isClosed()) + conn.close(); + JavaConnector.conn = DriverManager.getConnection(url, user, pass); + credChanged = false; + } + /** * translates a SEP3 code to clear text * @param sep3Code code for translation @@ -68,11 +112,12 @@ public static void setUrl(String url) { * @throws SQLException if DB error occurs */ public static String getS3Name(String sep3Code) throws SQLException { - Connection conn = DriverManager.getConnection(m_url, user, pass); - String query = "select \"Kuerzel\", \"Klartext\" from " + wb + " w join " + st + " s " - + "on w.\"Typ\" = s.\"Nebentypbez\" where (s.\"Datenfeld\" = '" + df + "' " - + "OR s.\"Datenfeld\" = 'diverse') AND \"Kuerzel\"= ?"; + String query = "select kuerzel, klartext from " + wb + " w join " + st + " s " + + "on w.typ = s.nebentypbez where (s.datenfeld = '" + df + "' " + + "OR s.datenfeld = 'diverse') AND kuerzel= ?"; + if (credChanged) + setConn(m_url, user, pass); PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, sep3Code); LOG.fine("Executing statement: " + stmt); @@ -83,6 +128,10 @@ public static String getS3Name(String sep3Code) throws SQLException { result = rs.getString(2); } LOG.fine("Returning: " + result); + + rs.close(); + stmt.close(); + return result; } } @@ -94,9 +143,10 @@ public static String getS3Name(String sep3Code) throws SQLException { * @throws SQLException if DB error occurs */ public static String getS3AsBMmlLitho(String sep3Code) throws SQLException { - Connection conn = DriverManager.getConnection(m_url, user, pass); String query = "select bml_code from " + sm + " where sep3_codelist = 'S3PETRO' AND sep3_code = ?"; + if (credChanged) + setConn(m_url, user, pass); PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, sep3Code); LOG.fine("Executing statement: " + stmt); @@ -107,6 +157,10 @@ public static String getS3AsBMmlLitho(String sep3Code) throws SQLException { result = rs.getString(1); } LOG.fine("Returning: " + result); + + rs.close(); + stmt.close(); + return result; } } @@ -118,10 +172,10 @@ public static String getS3AsBMmlLitho(String sep3Code) throws SQLException { * @throws SQLException if DB error occurs */ public static String getAllowedAttribs(String sep3Code) throws SQLException { - Connection conn = DriverManager.getConnection(m_url, user, pass); - String query = "select \"Kuerzel\", \"Attribute\" from " + wb + " w join " + st + " s " - + "on w.\"Typ\" = s.\"Nebentypbez\" " - + "where (s.\"Datenfeld\" = 'PETRO' OR s.\"Datenfeld\" = 'diverse') AND \"Kuerzel\"= ?"; + String query = "select kuerzel, attribute from " + wb + " w join " + st + " s " + "on w.typ = s.nebentypbez " + + "where (s.datenfeld = 'PETRO' OR s.datenfeld = 'diverse') AND kuerzel= ?"; + if (credChanged) + setConn(m_url, user, pass); PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, sep3Code); LOG.fine("Executing statement: " + stmt); @@ -132,6 +186,10 @@ public static String getAllowedAttribs(String sep3Code) throws SQLException { result = rs.getString(2); } LOG.fine("Returning: " + result); + + rs.close(); + stmt.close(); + return result; } } @@ -150,9 +208,10 @@ public static String getBodenQuant(String sep3Code, String quant) throws SQLExce allowedAttributes = getAllowedAttribs(sep3Code); quantBez = getQuantBezFromAttribs(allowedAttributes); - Connection conn = DriverManager.getConnection(m_url, user, pass); - String query = "select w.\"Kuerzel\", w.\"Klartext\", s.\"Nebentypbez\" from " + wb + " w join " + st + " s " - + "on w.\"Typ\" = s.\"Nebentypbez\" where (s.\"Nebentypbez\" = ? AND w.\"Kuerzel\" = ?);"; + String query = "select w.kuerzel, w.klartext, s.nebentypbez from " + wb + " w join " + st + " s " + + "on w.typ = s.nebentypbez where (s.nebentypbez = ? AND w.kuerzel = ?);"; + if (credChanged) + setConn(m_url, user, pass); PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, quantBez); stmt.setString(2, quant); @@ -165,6 +224,9 @@ public static String getBodenQuant(String sep3Code, String quant) throws SQLExce } LOG.fine("Returning: " + result); + rs.close(); + stmt.close(); + return result; } } diff --git a/src/main/java/org/sep3tools/Launch.java b/src/main/java/org/sep3tools/Launch.java index 8e72958..b818e84 100644 --- a/src/main/java/org/sep3tools/Launch.java +++ b/src/main/java/org/sep3tools/Launch.java @@ -7,6 +7,8 @@ import org.postgresql.pljava.annotation.Function; import org.sep3tools.gen.*; +import java.sql.SQLException; + /** * Command line launcher for SEP3 tools * @@ -38,6 +40,10 @@ else if (args.length == 0 || args[0].isEmpty()) { else if (args.length == 1) { sep3String = args[0]; } + else if (args.length == 2) { + JavaConnector.setPropertiesFile(args[0]); + sep3String = args[1]; + } else { System.out.println("Aufruf mit folgenden Parametern:\n" + "[JDBC-URL] [DB-User] [DB-Passwort] [Woerterbuch-Tabelle] [Schlüsseltypen-Tabelle] \n\n" diff --git a/src/main/java/org/sep3tools/LaunchBML.java b/src/main/java/org/sep3tools/LaunchBML.java index 637c94f..83a0f37 100644 --- a/src/main/java/org/sep3tools/LaunchBML.java +++ b/src/main/java/org/sep3tools/LaunchBML.java @@ -8,12 +8,13 @@ import org.sep3tools.gen.PetroGrammarLexer; import org.sep3tools.gen.PetroGrammarParser; +import java.sql.SQLException; import java.util.*; import static java.util.Objects.isNull; /** - * Command line launcher for SEP3 to BML tool + * Command line launcher for SEP3 to BML tool. * * @author Jeronimo Wanhoff */ @@ -21,7 +22,7 @@ public class LaunchBML { /** * Launches SEP3 tool with arguments: - * @param args DB URL, DB user, DB password, Schluesselmapping table name SEP3 string + * @param args DB URL, DB user, DB password, Schluesselmapping table name SEP3 string. * to process */ public static void main(String[] args) { @@ -120,10 +121,10 @@ public static String S3_AsBmlLitho(String s3String, String sm) { * @return BML format of SEP3 input */ @Function - public static String S3_AsBmlLitho_verbose(String s3String, String sm) { + public static String s3AsBmlLithoVerbose(final String s3String, final String sm) { JavaConnector.setSm(sm); String result = S3_AsBmlLitho(s3String); return result; } -} \ No newline at end of file +} diff --git a/src/main/java/org/sep3tools/PetroVisitor.java b/src/main/java/org/sep3tools/PetroVisitor.java index befb1e0..a530642 100644 --- a/src/main/java/org/sep3tools/PetroVisitor.java +++ b/src/main/java/org/sep3tools/PetroVisitor.java @@ -47,12 +47,22 @@ public String visitSchichtbeschreibung(PetroGrammarParser.SchichtbeschreibungCon } /** - * process single soil takes quantifier into account, if present + * Visit a parse tree produced by the {@code bestandteil_klammer} labeled alternative + * in {@link PetroGrammarParser}. * @param ctx the parse tree - * @return translated string for soil parse tree + * @return the visitor result */ - @Override - public String visitBestandteil(PetroGrammarParser.BestandteilContext ctx) { + public String visitBestandteil_klammer(PetroGrammarParser.Bestandteil_klammerContext ctx) { + return visitBestandteil_simple((PetroGrammarParser.Bestandteil_simpleContext) ctx.bestandteil()); + } + + /** + * Visit a parse tree produced by the {@code bestandteil_simple} labeled alternative + * in {@link PetroGrammarParser}. + * @param ctx the parse tree + * @return the visitor result + */ + public String visitBestandteil_simple(PetroGrammarParser.Bestandteil_simpleContext ctx) { String boden = getBodenTerm(ctx.TEIL().getText()); String attrib; if (isNull(ctx.attribute())) { @@ -70,11 +80,29 @@ else if (attr.trim().startsWith("(")) { attrib = " (" + attr + ")"; } } - // if (ctx.getText().startsWith("(")) - // return "(" + boden + attrib + ")"; return boden + attrib; } + /** + * Visit a parse tree produced by the {@code bestandteil_sicher} labeled alternative + * in {@link PetroGrammarParser}. + * @param ctx the parse tree + * @return the visitor result + */ + public String visitBestandteil_sicher(PetroGrammarParser.Bestandteil_sicherContext ctx) { + return visitChildren(ctx) + " sicher"; + } + + /** + * Visit a parse tree produced by the {@code bestandteil_fraglich} labeled alternative + * in {@link PetroGrammarParser}. + * @param ctx the parse tree + * @return the visitor result + */ + public String visitBestandteil_fraglich(PetroGrammarParser.Bestandteil_fraglichContext ctx) { + return visitChildren(ctx) + " fraglich"; + } + private String getBodenTerm(String boden) { String bodenTerm = getS3ResultSet(boden); if (!bodenTerm.isEmpty()) @@ -170,15 +198,21 @@ public String visitAttr(PetroGrammarParser.AttrContext ctx) { */ @Override public String visitUebergang_bes(PetroGrammarParser.Uebergang_besContext ctx) { - String teile; + String teile = ""; String attrib; if (ctx.getText().trim().startsWith("(")) { teile = "(" + visit(ctx.uebergang_bes()) + ")"; } else { - teile = visit(ctx.b1) + " bis " + visit(ctx.b2); + for (PetroGrammarParser.BestandteilContext teil : ctx.bestandteil()) { + if (teile.isEmpty()) { + teile = visit(teil); + } + else { + teile = teile + " bis " + visit(teil); + } + } } - if (isNull(ctx.attribute())) { attrib = ""; } diff --git a/src/main/resources/beschbgtest.properties b/src/main/resources/beschbgtest.properties new file mode 100644 index 0000000..3349e2a --- /dev/null +++ b/src/main/resources/beschbgtest.properties @@ -0,0 +1 @@ +kb2,kb3(un)=schlechte Kornbindung, mäßige Kornbindung (unten) \ No newline at end of file diff --git a/src/main/resources/beschbvtest.properties b/src/main/resources/beschbvtest.properties new file mode 100644 index 0000000..1e4fa59 --- /dev/null +++ b/src/main/resources/beschbvtest.properties @@ -0,0 +1 @@ +spvl(30%-40%,tv(29.02-29.23))=Spülverlust [Prozent] (30% bis 40%, Teufe von (29,02 bis 29,23)) \ No newline at end of file diff --git a/src/main/resources/bgruppetest.properties b/src/main/resources/bgruppetest.properties new file mode 100644 index 0000000..81bc73e --- /dev/null +++ b/src/main/resources/bgruppetest.properties @@ -0,0 +1 @@ +GE=Kies, enggestuft \ No newline at end of file diff --git a/src/main/resources/bmltest.properties b/src/main/resources/bmltest.properties new file mode 100644 index 0000000..b60438b --- /dev/null +++ b/src/main/resources/bmltest.properties @@ -0,0 +1,3 @@ +^hzk,\ fS(ms2,\ "gl"2)=fS,mS +G(fg-gg,ms-gs,mats,mata,grs(tw)),fX-mX(mata),mS(fs,grs,fg-mg2,mx(voe))=G,fG,gG,mS,gS,eG,X,fS,mG +U(hz(res),H(res),zg1)=U,Pfl,H \ No newline at end of file diff --git a/src/main/resources/farbetest.properties b/src/main/resources/farbetest.properties new file mode 100644 index 0000000..6725632 --- /dev/null +++ b/src/main/resources/farbetest.properties @@ -0,0 +1,24 @@ +ro=rot +bn=braun +dro=dunkelrot +hbn=hellbraun +gr=grau +bl=blau +dd=sehr dunkel +hgr=hellgrau +mt=matt +ol=oliv +olst=olivstichig +sw=schwarz +ge=gelb +dgr=dunkelgrau +gn=grün +rs=rosa +gnli=grünlich +grst=graustichig +# robn= +# blro=blaurot +# drohbngr,blro,ddro,hgrbn,mtgr,mtol,mtolst= +dro-hgr=dunkelrot bis hellgrau +# robn,sw,ge,dgr-gn,swgerobnrs= +gnli,grst=grünlich, graustichig \ No newline at end of file diff --git a/src/main/resources/genesetest.properties b/src/main/resources/genesetest.properties new file mode 100644 index 0000000..bc7d506 --- /dev/null +++ b/src/main/resources/genesetest.properties @@ -0,0 +1 @@ +as,Lou(lok)=Abspülung, Schwemmlöss (lokal) \ No newline at end of file diff --git a/src/main/resources/kalkgehtest.properties b/src/main/resources/kalkgehtest.properties new file mode 100644 index 0000000..017857d --- /dev/null +++ b/src/main/resources/kalkgehtest.properties @@ -0,0 +1 @@ +zg1-zg2(ob)=sehr schwach zersetzt bis schwach zersetzt (oben) \ No newline at end of file diff --git a/src/main/resources/petrotest.properties b/src/main/resources/petrotest.properties new file mode 100644 index 0000000..b4b6417 --- /dev/null +++ b/src/main/resources/petrotest.properties @@ -0,0 +1,21 @@ +^ms=Mittelsandstein +^u=Schluffstein +^gs=Grobsandstein +W,^gs(l-fs),^u=Wasser, Grobsandstein (lehmig bis feinsandig), Schluffstein +^ms(r2,r3(tw),gs(lw,r2-r3)),^u(t,lw),^gs(r3,bei(113),nf?)=Mittelsandstein (kantengerundet, mäßig gerundet (teilweise), grobsandig (lagenweise, kantengerundet bis mäßig gerundet)), Schluffstein (tonig, lagenweise), Grobsandstein (mäßig gerundet, bei 113, Nachfall (fraglich)) +^ksw-^kal(mas,fe,spt,brc,cav2(bei(25.5)),p(unz,tv(40.4))),Rfl("ca"),^if2(knl,bei(31.4,32.8,34.65,35.8,40.4))=Schwammkalk bis Algenkalk (massig, fest, splittrig, brechend, schwach kavernös (bei 25,5), porös (unten zunehmend, Teufe von 40,4)), Hohlraumfüllung (Kalzit), wenig Flint (knollig, bei 31,4, 32,8, 34,65, 35,8, 40,4) +G(fg-gg,ms-gs,mats,mata,grs(tw)),fX-mX(mata),mS(fs,grs,fg-mg,mx(voe))=Kies [gerundet] (feinkiesig bis grobkiesig, mittelsandig bis grobsandig, Schwarzwaldmaterial, alpines Material, grusig (teilweise)), Feinsteinstücke [2,0-6,3 mm] bis Mittelsteinstücke [6,3-20 mm] (alpines Material), Mittelsand [0,2-0,63 mm] (feinsandig, grusig, feinkiesig bis mittelkiesig, mittelsteinig (vereinzelt vorhanden)) +G(fg-gg,ms-gs,mats,mata,grs(tw)),fX-mX(mata),mS(fs,grs,fg-mg2,mx(voe))=Kies [gerundet] (feinkiesig bis grobkiesig, mittelsandig bis grobsandig, Schwarzwaldmaterial, alpines Material, grusig (teilweise)), Feinsteinstücke [2,0-6,3 mm] bis Mittelsteinstücke [6,3-20 mm] (alpines Material), Mittelsand [0,2-0,63 mm] (feinsandig, grusig, feinkiesig bis schwach mittelkiesig, mittelsteinig (vereinzelt vorhanden)) +U(hz(res),H(res),zg1)=Schluff (Holzreste (Reste), Torf (Reste), sehr schwach zersetzt) +(S-G)(u,t,pf(zg,vw))=(Sand [allgemein] bis Kies [gerundet]) (schluffig, tonig, Pflanzenreste (zersetzt, verwittert)) +U(ms2,x(+Gr(gro(0.005))))=Schluff (schwach mittelsandig, steinig (Granit (groß 0,005))) +(^u(fs)-^fs(u)),^d(u,"ba")=(Schluffstein (feinsandig) bis Feinsandstein (schluffig)), Dolomitstein (schluffig, Baryt) +(fG-gG)(x)=(Feinkies [2,0-6,3 mm] bis Grobkies [20-63 mm]) (steinig) +(^u(t,fs(tw)),^gs,^fs,^d(s,ikl))(wl)=(Schluffstein (tonig, feinsandig (teilweise)), Grobsandstein, Feinsandstein, Dolomitstein (sandig, intraklastisch)) (wechsellagernd) +(U,fS)(ms2)=(Schluff, Feinsand [0,063-0,2 mm]) (schwach mittelsandig) +(^k(mas,fla,pof,bel)),(fls(rgu))=Kalkstein (massig, flaserig, Porifera, Belemniten), Flasern (unregelmäßig) +"ca"=Kalzit +ca=Calamiten +(gG-mG-fG)(gs-fs)=(Grobkies [20-63 mm] bis Mittelkies [6,3-20 mm] bis Feinkies [2,0-6,3 mm]) (grobsandig bis feinsandig) +G?=Kies [gerundet] fraglich +G!=Kies [gerundet] sicher diff --git a/src/main/resources/zusatztest.properties b/src/main/resources/zusatztest.properties new file mode 100644 index 0000000..de8200e --- /dev/null +++ b/src/main/resources/zusatztest.properties @@ -0,0 +1 @@ +AS=Sattelfläche \ No newline at end of file diff --git a/src/test/java/org/sep3tools/BmlExamplesTest.java b/src/test/java/org/sep3tools/BmlExamplesTest.java index ebef69a..b22cc6e 100644 --- a/src/test/java/org/sep3tools/BmlExamplesTest.java +++ b/src/test/java/org/sep3tools/BmlExamplesTest.java @@ -18,6 +18,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.sql.SQLException; import java.util.Enumeration; import java.util.Properties; @@ -28,21 +29,13 @@ @Ignore("Class not ready for automatic tests, integrations tests depend on running database") public class BmlExamplesTest { - static final String DB_URL = "jdbc:postgresql://localhost/petroparser"; - static final String USER = "petroparser"; - static final String PASS = "PetroParser"; - static final String SMTABLE = "bml.bml_schluesselmapping"; - @Test public void verifyBmlExamples() { - JavaConnector.setUrl(DB_URL); - JavaConnector.setUser(USER); - JavaConnector.setPass(PASS); - JavaConnector.setSm(SMTABLE); - try { - File file = new File("bmltest.properties"); + JavaConnector.setPropertiesFile("db.properties"); + + File file = new File("src/main/resources/bmltest.properties"); FileInputStream fileInput = new FileInputStream(file); Properties properties = new Properties(); properties.load(fileInput); diff --git a/src/test/java/org/sep3tools/SepExamplesTest.java b/src/test/java/org/sep3tools/SepExamplesTest.java index 7db6bbd..06918d0 100644 --- a/src/test/java/org/sep3tools/SepExamplesTest.java +++ b/src/test/java/org/sep3tools/SepExamplesTest.java @@ -29,59 +29,52 @@ @Ignore("Class not ready for automatic tests, integrations tests depend on running database") public class SepExamplesTest { - static final String DB_URL = "jdbc:postgresql://localhost/petroparser"; - static final String USER = "petroparser"; - static final String PASS = "PetroParser"; - static final String WBTABLE = "woerterbuch.\"Woerterbuch\""; - static final String STTABLE = "woerterbuch.\"Schluesseltypen\""; + static final String DBPROPFILENAME = "db.properties"; @Test public void verifyPetroExamples() { - verifySepExamples("PETRO", "petrotest.properties"); + verifySepExamples("PETRO", "src/main/resources/petrotest.properties"); + } @Test public void verifyBeschbgExamples() { - verifySepExamples("BESCHBG", "beschbgtest.properties"); + verifySepExamples("BESCHBG", "src/main/resources/beschbgtest.properties"); } @Test public void verifyBeschbvExamples() { - verifySepExamples("BESCHBV", "beschbvtest.properties"); + verifySepExamples("BESCHBV", "src/main/resources/beschbvtest.properties"); } @Test public void verifyBgruppeExamples() { - verifySepExamples("BGRUPPE", "bgruppetest.properties"); + verifySepExamples("BGRUPPE", "src/main/resources/bgruppetest.properties"); } @Test public void verifyGeneseExamples() { - verifySepExamples("GENESE", "genesetest.properties"); + verifySepExamples("GENESE", "src/main/resources/genesetest.properties"); } @Test public void verifyKalkgehExamples() { - verifySepExamples("KALKGEH", "kalkgehtest.properties"); + verifySepExamples("KALKGEH", "src/main/resources/kalkgehtest.properties"); } @Test public void verifyZusatzExamples() { - verifySepExamples("ZUSATZ", "zusatztest.properties"); + verifySepExamples("ZUSATZ", "src/main/resources/zusatztest.properties"); } @Test public void verifyFarbeExamples() { - verifySepExamples("FARBE", "farbetest.properties"); + verifySepExamples("FARBE", "src/main/resources/farbetest.properties"); } public void verifySepExamples(String df, String propFile) { - JavaConnector.setUrl(DB_URL); - JavaConnector.setUser(USER); - JavaConnector.setPass(PASS); - JavaConnector.setWb(WBTABLE); - JavaConnector.setSt(STTABLE); + JavaConnector.setPropertiesFile(DBPROPFILENAME); JavaConnector.setDf(df); try { @@ -97,8 +90,6 @@ public void verifySepExamples(String df, String propFile) { String expectedTranslation = properties.getProperty(sep3String); String translation = Launch.S3_AsText(sep3String); assertThat(translation, CoreMatchers.is(expectedTranslation)); - // System.out.println(sep3String + " transation matched expected value: " - // + translation); } } catch (FileNotFoundException e) {