public static List <string> GetRecordsByBase(object conn, XMLRealiser.LexiconType lexiconType, string @base) { switch (lexiconType) { case XMLRealiser.LexiconType.NIHDB_HSQL: throw new NotImplementedException("HSQLdb disabled"); string query = "SELECT lexRecord FROM LEX_RECORD where (base = '" + DbBase.FormatSqlStr(@base) + "' and lastAction <> 3)"; //Statement statement = ((Connection) conn).createStatement(); //ResultSet rs = statement.executeQuery(query); //List<string> outs = new List<string>(); //while (rs.next()) //{ // string lexRecord = rs.getString("lexRecord"); // outs.Add(lexRecord); //} //rs.close(); //statement.close(); //return outs; case XMLRealiser.LexiconType.NIHDB_SQLITE: List <string> recordStringList = new List <string>(); SQLiteCommand command = new SQLiteCommand("SELECT lexRecord FROM LEX_RECORD where (base = @BaseForm and lastAction <> 3)", (SQLiteConnection)conn); command.Parameters.Add("@BaseForm", DbType.String).Value = @base; SqliteAccess.ProcessDataReader((SQLiteConnection)conn, command, reader => recordStringList.Add(reader["lexRecord"] as string)); return(recordStringList); } return(null); }
public static List <string> GetRecordsByCat(object conn, XMLRealiser.LexiconType lexiconType, long category) { string catCondition = GetCategoryCondition(category); string query = "SELECT lexRecord FROM LEX_RECORD where ((lastAction <> 3)" + catCondition + ")"; switch (lexiconType) { case XMLRealiser.LexiconType.NIHDB_HSQL: throw new NotImplementedException("HSQLdb disabled"); //Statement statement = ((Connection)conn).createStatement(); //ResultSet rs = statement.executeQuery(query); //List<string> outs = new List<string>(); //while (rs.next()) //{ // string lexRecord = rs.getString("lexRecord"); // outs.Add(lexRecord); //} //rs.close(); //statement.close(); //return outs; case XMLRealiser.LexiconType.NIHDB_SQLITE: List <string> recordStringList = new List <string>(); SQLiteCommand command = new SQLiteCommand(query); SqliteAccess.ProcessDataReader((SQLiteConnection)conn, command, reader => recordStringList.Add(reader["lexRecord"] as string)); return(recordStringList); } return(null); }
public static string GetRecordByEui(object conn, XMLRealiser.LexiconType lexiconType, string eui) { switch (lexiconType) { case XMLRealiser.LexiconType.NIHDB_HSQL: throw new NotImplementedException("HSQLdb disabled"); string query = "SELECT lexRecord FROM LEX_RECORD WHERE (eui = '" + eui + "' AND lastAction <> 3)"; //Statement statement = ((Connection)conn).createStatement(); //ResultSet rs = statement.executeQuery(query); //string lexRecord = ""; //while (rs.next()) //{ // lexRecord = rs.getString("lexRecord"); //} //rs.close(); //statement.close(); //return lexRecord; case XMLRealiser.LexiconType.NIHDB_SQLITE: List <string> recordStringList = new List <string>(); SQLiteCommand command = new SQLiteCommand("SELECT lexRecord FROM LEX_RECORD WHERE (eui = @ID AND lastAction <> 3)", (SQLiteConnection)conn); command.Parameters.AddWithValue("@ID", eui); SqliteAccess.ProcessDataReader((SQLiteConnection)conn, command, reader => recordStringList.Add(reader["lexRecord"] as string)); return(recordStringList[0]); } return(null); }
public virtual void setUp() { try { Properties prop = new Properties(); prop.load("Resources/lexicon.properties"); string xmlFile = prop.getProperty("XML_FILENAME"); string dbFile = prop.getProperty("DB_FILENAME"); string lexiconTypeStr = prop.getProperty("LexiconType"); XMLRealiser.LexiconType lexiconType = XMLRealiser.LexiconType.NIHDB_HSQL; if (lexiconTypeStr == "NIH_SQLITE") { lexiconType = XMLRealiser.LexiconType.NIHDB_SQLITE; } lexicon = new MultipleLexicon(new XMLLexicon(xmlFile), new NIHDBLexicon(dbFile, lexiconType)); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); lexicon = new MultipleLexicon(new XMLLexicon(XML_FILENAME), new NIHDBLexicon(DB_FILENAME, LEXICON_TYPE)); } }
/****************************************************************************/ // constructors /****************************************************************************/ /** * set up lexicon using file which contains downloaded lexAccess HSQL DB and * default passwords * * @param filename * of HSQL DB */ public NIHDBLexicon(string filename, XMLRealiser.LexiconType lexiconType) : base() { _lexiconType = lexiconType; string url; switch (lexiconType) { case XMLRealiser.LexiconType.NIHDB_HSQL: throw new NotImplementedException("HSQLdb disabled"); //// get rid of .data at end of filename if necessary //string dbfilename = filename; //if (dbfilename.EndsWith(DB_HSQL_EXTENSION, StringComparison.Ordinal)) //{ // dbfilename = dbfilename.Substring(0, dbfilename.Length - DB_HSQL_EXTENSION.Length); //} //url = DB_HQSL_JDBC + dbfilename + ";default_schema=true"; //SetUpConnection(new org.hsqldb.jdbcDriver(), url, DB_DEFAULT_USERNAME, DB_DEFAULT_PASSWORD); //break; case XMLRealiser.LexiconType.NIHDB_SQLITE: url = "Data Source=" + filename; SetUpConnection(url); break; default: throw new Exception("Not implemented for lexiconType: " + lexiconType); } }
public static List <string> GetBasesByEui(object conn, XMLRealiser.LexiconType lexiconType, string eui) { switch (lexiconType) { case XMLRealiser.LexiconType.NIHDB_HSQL: throw new NotImplementedException("HSQLdb disabled"); //string query = "SELECT inflVar FROM INFL_VARS where (eui = '" + eui + "' and inflection = 1)"; //Statement statement = ((Connection) conn).createStatement(); //ResultSet rs = statement.executeQuery(query); //List<string> outs = new List<string>(); //while (rs.next()) //{ // string @base = rs.getString("inflVar"); // outs.Add(@base); //} //rs.close(); //statement.close(); //return outs; case XMLRealiser.LexiconType.NIHDB_SQLITE: List <string> recordStringList = new List <string>(); SQLiteCommand command = new SQLiteCommand("SELECT inflVar FROM INFL_VARS where (eui = @EUI and inflection = 1)", (SQLiteConnection)conn); command.Parameters.AddWithValue("@EUI", eui); SqliteAccess.ProcessDataReader((SQLiteConnection)conn, command, reader => recordStringList.Add(reader["inflVar"] as string)); return(recordStringList); } return(null); }
public static List <string> GetEuis(object conn, XMLRealiser.LexiconType lexiconType, string inflVar) { switch (lexiconType) { case XMLRealiser.LexiconType.NIHDB_HSQL: throw new NotImplementedException("HSQLdb disabled"); string query = "SELECT eui FROM INFL_VARS where (inflVarLc = '" + DbBase.FormatSqlStr(inflVar.ToLower()) + "')"; //Statement statement = ((Connection) conn).createStatement(); //ResultSet rs = statement.executeQuery(query); //List<string> outs = new List<string>(); //while (rs.next()) //{ // string eui = rs.getString("eui"); // outs.Add(eui); //} //rs.close(); //statement.close(); //return outs; case XMLRealiser.LexiconType.NIHDB_SQLITE: List <string> euis = new List <string>(); SQLiteCommand command = new SQLiteCommand("SELECT eui FROM INFL_VARS where (inflVarLc = @INFLVAR)", (SQLiteConnection)conn); command.Parameters.AddWithValue("@INFLVAR", DbBase.FormatSqlStr(inflVar.ToLower())); SqliteAccess.ProcessDataReader((SQLiteConnection)conn, command, reader => euis.Add(reader["eui"] as string)); return(euis); } return(null); }
public virtual void setUp() { // use property file for the lexicon try { Properties prop = new Properties(); prop.load("Resources/lexicon.properties"); string lexiconPath = prop.getProperty("DB_FILENAME"); string lexiconTypeStr = prop.getProperty("LexiconType"); XMLRealiser.LexiconType lexiconType = XMLRealiser.LexiconType.NIHDB_HSQL; if (lexiconTypeStr == "NIH_SQLITE") { lexiconType = XMLRealiser.LexiconType.NIHDB_SQLITE; } if (null != lexiconPath) { lexicon = new NIHDBLexicon(lexiconPath, lexiconType); } } catch (Exception e) { lexicon = new NIHDBLexicon(DB_FILENAME, LEXICON_TYPE); } }
//public LexAccessApi(Connection conn) //{ // conn_ = conn; // lexiconType = XMLRealiser.LexiconType.NIHDB_HSQL; //} public LexAccessApi(SQLiteConnection conn) { conn_ = conn; lexiconType = XMLRealiser.LexiconType.NIHDB_SQLITE; }