Skip to content

Commit

Permalink
Merge pull request #63 from lat-lon/feature/prefixForDatenfeldSelection
Browse files Browse the repository at this point in the history
Added prefix for datafield selection
  • Loading branch information
tfr42 authored Oct 25, 2023
2 parents 5609118 + 534b14b commit 5ad7f34
Show file tree
Hide file tree
Showing 20 changed files with 233 additions and 120 deletions.
1 change: 0 additions & 1 deletion beschbgtest.properties

This file was deleted.

1 change: 0 additions & 1 deletion beschbvtest.properties

This file was deleted.

1 change: 0 additions & 1 deletion bgruppetest.properties

This file was deleted.

3 changes: 0 additions & 3 deletions bmltest.properties

This file was deleted.

24 changes: 0 additions & 24 deletions farbetest.properties

This file was deleted.

1 change: 0 additions & 1 deletion genesetest.properties

This file was deleted.

1 change: 0 additions & 1 deletion kalkgehtest.properties

This file was deleted.

16 changes: 0 additions & 16 deletions petrotest.properties

This file was deleted.

25 changes: 14 additions & 11 deletions src/main/antlr4/org/sep3tools/gen/PetroGrammar.g4
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ grammar PetroGrammar;
schichtbeschreibung: bestandteile;

bestandteile:
bestandteil # Teil
| bestandteile ',' bestandteile # Aufzaehlung_b
bestandteile ',' bestandteile # Aufzaehlung_b
| '(' bestandteile ',' bestandteile ')' ( '(' attribute ')' )? # Aufzaehlung_b_k
| bestandteil # Teil
| uebergang_bes # Uebergang_b
;

Expand All @@ -15,10 +15,11 @@ uebergang_bes:
;

bestandteil:
TEIL ( '(' attribute ')' )? # bestandteil_simple
| '(' bestandteil ')' # bestandteil_klammer
| bestandteil FRAGLICH # bestandteil_fraglich
| bestandteil SICHER # bestandteil_sicher
TEIL ( '(' attribute ')' )? # bestandteil_simple
| '(' bestandteil ')' ( '(' attribute ')' )? # bestandteil_klammer
| bestandteil FRAGLICH # bestandteil_fraglich
| bestandteil SICHER # bestandteil_sicher
| DATENFELDKUERZEL TEIL # bestandteil_fremddatenfeld
;

attribute:
Expand All @@ -32,15 +33,17 @@ attribute:
uebergang_att: attribut '-' attribut;

attribut:
TEIL # attr
| attribut FRAGLICH # attr_fraglich
| attribut SICHER # attr_sicher
| TIEFE # attr_tiefe
TEIL # attr
| attribut FRAGLICH # attr_fraglich
| attribut SICHER # attr_sicher
| TIEFE # attr_tiefe
| DATENFELDKUERZEL TEIL # attr_fremddatenfeld
;

TIEFE: ([0-9]|'.')+;
TEIL: ANY+;
UNBEKANNT: ANY+;
ANY: [a-z]|[A-Z]|[0-9]|'^'|'*'|'+'|'"'|'%';
FRAGLICH: '?';
SICHER: '!';
SICHER: '!';
DATENFELDKUERZEL: ('S'|'P'|'G'|'F'|'Z')':';
1 change: 0 additions & 1 deletion src/main/java/org/sep3tools/BmlVisitor.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.sep3tools;

import static java.util.Objects.isNull;
import static org.sep3tools.JavaConnector.getBodenQuant;

import java.sql.SQLException;
import java.util.logging.Logger;
Expand Down
52 changes: 49 additions & 3 deletions src/main/java/org/sep3tools/JavaConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,55 @@ private static void setConn(String url, String user, String pass) throws SQLExce
* @throws SQLException if DB error occurs
*/
public static String getS3Name(String sep3Code) throws SQLException {
String query = "select kuerzel, klartext from " + wb + " w join " + st + " s "
+ "on w.typ = s.nebentypbez where (s.datenfeld = '" + df + "' "
String query = getQueryString(wb, st, df);

if (credChanged)
setConn(m_url, user, pass);
PreparedStatement stmt = conn.prepareStatement(query);
stmt.setString(1, sep3Code);
LOG.fine("Executing statement: " + stmt);
try (ResultSet rs = stmt.executeQuery()) {
boolean validRS = rs.next();
String result = "";
if (validRS) {
result = rs.getString(2);
}
LOG.fine("Returning: " + result);

rs.close();
stmt.close();

return result;
}
}

private static String getQueryString(String woerterbuch, String schluesselypen, String datenfeld) {
return "select kuerzel, klartext from " + woerterbuch + " w join " + schluesselypen + " s "
+ "on w.typ = s.nebentypbez where (s.datenfeld = '" + datenfeld + "' "
+ "OR s.datenfeld = 'diverse') AND kuerzel= ?";
}

public static String getS3inDfName(String datefield, String sep3Code) throws SQLException {
String query;
switch (datefield) {
case "S:":
query = getQueryString(wb, st, "STRAT");
break;
case "P:":
query = getQueryString(wb, st, "PETRO");
break;
case "G:":
query = getQueryString(wb, st, "GENESE");
break;
case "F:":
query = getQueryString(wb, st, "FARBE");
break;
case "Z:":
query = getQueryString(wb, st, "ZUSATZ");
break;
default:
query = getQueryString(wb, st, df);
}

if (credChanged)
setConn(m_url, user, pass);
Expand Down Expand Up @@ -201,7 +247,7 @@ public static String getAllowedAttribs(String sep3Code) throws SQLException {
* @return quantifier based on sep3 code and quantifyer
* @throws SQLException in case of DB error
*/
public static String getBodenQuant(String sep3Code, String quant) throws SQLException {
public static String getItemQuant(String sep3Code, String quant) throws SQLException {
String allowedAttributes;
String quantBez;

Expand Down
Loading

0 comments on commit 5ad7f34

Please sign in to comment.