Updated importer to include everything needed, and not to depend on external sql statements.
This commit is contained in:
parent
7379440520
commit
a921ac7536
1 changed files with 265 additions and 119 deletions
|
@ -1,28 +1,14 @@
|
||||||
package org.thdl.lex.util;
|
package org.thdl.lex.util;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.*;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
import org.thdl.lex.LexComponentRepository;
|
|
||||||
import org.thdl.lex.component.ITerm;
|
|
||||||
import org.thdl.lex.component.Meta;
|
|
||||||
import org.thdl.lex.component.Term;
|
|
||||||
import org.thdl.lex.component.TransitionalData;
|
|
||||||
import org.thdl.tib.scanner.Manipulate;
|
import org.thdl.tib.scanner.Manipulate;
|
||||||
|
|
||||||
public class DictionaryImporter {
|
public class DictionaryImporter {
|
||||||
|
@ -46,37 +32,19 @@ public class DictionaryImporter {
|
||||||
|
|
||||||
private static int delimiterType;
|
private static int delimiterType;
|
||||||
|
|
||||||
private static Integer creator;
|
|
||||||
|
|
||||||
private static String note;
|
private static String note;
|
||||||
|
|
||||||
private static Integer proj;
|
private static int proj;
|
||||||
|
|
||||||
private static String publicCons;
|
private static String publicCons;
|
||||||
|
|
||||||
private static Integer label;
|
private static int label;
|
||||||
|
|
||||||
private static Statement sqlStatement;
|
private static Statement sqlStatement;
|
||||||
|
|
||||||
private static Connection conn;
|
private static Connection connLex, connUsers;
|
||||||
|
|
||||||
private static Connection conn2;
|
private static PreparedStatement insertMetaStmt, selectMetaStmt, insertTermStmt, updateTransStmt, insertTransStmt;
|
||||||
|
|
||||||
private static Connection conn3;
|
|
||||||
|
|
||||||
private static Connection conn4;
|
|
||||||
|
|
||||||
private static Connection conn5;
|
|
||||||
|
|
||||||
private static PreparedStatement insertMetaStmt;
|
|
||||||
|
|
||||||
private static PreparedStatement selectMetaStmt;
|
|
||||||
|
|
||||||
private static PreparedStatement insertTermStmt;
|
|
||||||
|
|
||||||
private static PreparedStatement updateTransStmt;
|
|
||||||
|
|
||||||
private static PreparedStatement insertTransStmt;
|
|
||||||
|
|
||||||
public final static int delimiterGeneric = 0;
|
public final static int delimiterGeneric = 0;
|
||||||
|
|
||||||
|
@ -147,8 +115,10 @@ public class DictionaryImporter {
|
||||||
out.flush();
|
out.flush();
|
||||||
if (sqlStatement != null)
|
if (sqlStatement != null)
|
||||||
sqlStatement.close();
|
sqlStatement.close();
|
||||||
if (conn != null)
|
if (connLex != null)
|
||||||
conn.close();
|
connLex.close();
|
||||||
|
if (connUsers != null)
|
||||||
|
connUsers.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRecordManually(String term, String definition)
|
public void addRecordManually(String term, String definition)
|
||||||
|
@ -192,7 +162,7 @@ public class DictionaryImporter {
|
||||||
.executeQuery("SELECT TransitionalDataText, TransitionalData.metaid FROM TransitionalData, Meta where TransitionalData.parentid = "
|
.executeQuery("SELECT TransitionalDataText, TransitionalData.metaid FROM TransitionalData, Meta where TransitionalData.parentid = "
|
||||||
+ metaID
|
+ metaID
|
||||||
+ " and TransitionalData.metaid = Meta.metaid and createdbyprojsub = "
|
+ " and TransitionalData.metaid = Meta.metaid and createdbyprojsub = "
|
||||||
+ proj.toString());
|
+ proj);
|
||||||
|
|
||||||
// if there is, append the definition if it is different. If not add it.
|
// if there is, append the definition if it is different. If not add it.
|
||||||
if (set.first()) {
|
if (set.first()) {
|
||||||
|
@ -231,7 +201,7 @@ public class DictionaryImporter {
|
||||||
insertTransStmt.setInt(1, metaIDTrans);
|
insertTransStmt.setInt(1, metaIDTrans);
|
||||||
insertTransStmt.setInt(2, metaID);
|
insertTransStmt.setInt(2, metaID);
|
||||||
insertTransStmt.setInt(3, prec);
|
insertTransStmt.setInt(3, prec);
|
||||||
insertTransStmt.setInt(4, label.intValue());
|
insertTransStmt.setInt(4, label);
|
||||||
insertTransStmt.setString(5, publicCons);
|
insertTransStmt.setString(5, publicCons);
|
||||||
insertTransStmt.setString(6, definition);
|
insertTransStmt.setString(6, definition);
|
||||||
insertTransStmt.executeUpdate();
|
insertTransStmt.executeUpdate();
|
||||||
|
@ -250,23 +220,6 @@ public class DictionaryImporter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Meta defaultMeta() {
|
|
||||||
//use the file src/sql/import-updates.sql to add new metadata for use
|
|
||||||
// in this method.
|
|
||||||
Meta meta = new Meta();
|
|
||||||
meta.setCreatedBy(creator);
|
|
||||||
meta.setModifiedBy(creator);
|
|
||||||
meta.setCreatedByProjSub(proj);
|
|
||||||
meta.setModifiedByProjSub(proj);
|
|
||||||
meta.setSource(new Integer(0));
|
|
||||||
// meta.setTranslationOf( new Integer( 0 ) );
|
|
||||||
meta.setLanguage(new Integer("0"));
|
|
||||||
meta.setDialect(new Integer("0"));
|
|
||||||
meta.setScript(new Integer("1"));
|
|
||||||
meta.setNote(note);
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used only if the database is being accessed manually instead of through
|
* Used only if the database is being accessed manually instead of through
|
||||||
* Hibernate
|
* Hibernate
|
||||||
|
@ -285,16 +238,10 @@ public class DictionaryImporter {
|
||||||
|
|
||||||
// Connecting to database
|
// Connecting to database
|
||||||
try {
|
try {
|
||||||
conn = DriverManager.getConnection(rb
|
connLex = DriverManager.getConnection(rb
|
||||||
.getString("dictionaryimporter.url"));
|
.getString("dictionaryimporter.lex.url"));
|
||||||
conn2 = DriverManager.getConnection(rb
|
connUsers = DriverManager.getConnection(rb
|
||||||
.getString("dictionaryimporter.url"));
|
.getString("dictionaryimporter.thdlusers.url"));
|
||||||
conn3 = DriverManager.getConnection(rb
|
|
||||||
.getString("dictionaryimporter.url"));
|
|
||||||
conn4 = DriverManager.getConnection(rb
|
|
||||||
.getString("dictionaryimporter.url"));
|
|
||||||
conn5 = DriverManager.getConnection(rb
|
|
||||||
.getString("dictionaryimporter.url"));
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// handle any errors
|
// handle any errors
|
||||||
System.out.println("Could not connect to database!");
|
System.out.println("Could not connect to database!");
|
||||||
|
@ -305,12 +252,12 @@ public class DictionaryImporter {
|
||||||
|
|
||||||
private static void initStatements() {
|
private static void initStatements() {
|
||||||
try {
|
try {
|
||||||
sqlStatement = conn.createStatement();
|
sqlStatement = connLex.createStatement();
|
||||||
insertMetaStmt = conn.prepareStatement(INSERT_META);
|
insertMetaStmt = connLex.prepareStatement(INSERT_META);
|
||||||
selectMetaStmt = conn.prepareStatement(SELECT_META);
|
selectMetaStmt = connLex.prepareStatement(SELECT_META);
|
||||||
insertTermStmt = conn.prepareStatement(INSERT_TERM);
|
insertTermStmt = connLex.prepareStatement(INSERT_TERM);
|
||||||
updateTransStmt = conn.prepareStatement(UPDATE_TRANS);
|
updateTransStmt = connLex.prepareStatement(UPDATE_TRANS);
|
||||||
insertTransStmt = conn.prepareStatement(INSERT_TRANS);
|
insertTransStmt = connLex.prepareStatement(INSERT_TRANS);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// handle any errors
|
// handle any errors
|
||||||
System.out.println("Could not create statement!");
|
System.out.println("Could not create statement!");
|
||||||
|
@ -322,30 +269,180 @@ public class DictionaryImporter {
|
||||||
public DictionaryImporter() {
|
public DictionaryImporter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static int getCreator(String firstName, String lastName) throws Exception
|
||||||
String format = null;
|
{
|
||||||
|
PreparedStatement stmt, stmt2;
|
||||||
|
ResultSet set;
|
||||||
|
int creator = -1;
|
||||||
|
|
||||||
|
stmt = connUsers.prepareStatement("SELECT id FROM thdlusers WHERE firstname LIKE ? AND lastname LIKE ?");
|
||||||
|
stmt.setString(1, "%" + firstName + "%");
|
||||||
|
stmt.setString(2, "%" + lastName + "%");
|
||||||
|
set = stmt.executeQuery();
|
||||||
|
|
||||||
|
// check if there is at least one
|
||||||
|
if (set.next())
|
||||||
|
{
|
||||||
|
creator = set.getInt(1);
|
||||||
|
|
||||||
|
// if there are more instances of the same user delete them
|
||||||
|
if (set.next())
|
||||||
|
{
|
||||||
|
stmt = connUsers.prepareStatement("DELETE FROM thdlusers WHERE firstname LIKE ? AND lastname LIKE ? AND id != ?");
|
||||||
|
stmt.setString(1, "%" + firstName + "%");
|
||||||
|
stmt.setString(2, "%" + lastName + "%");
|
||||||
|
stmt.setInt(3, creator);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stmt2 = connUsers.prepareStatement("INSERT INTO thdlusers(firstname, lastname) VALUES (?, ?)");
|
||||||
|
stmt2.setString(1, firstName);
|
||||||
|
stmt2.setString(2, lastName);
|
||||||
|
stmt2.executeUpdate();
|
||||||
|
set = stmt.executeQuery();
|
||||||
|
|
||||||
|
if (set.next())
|
||||||
|
{
|
||||||
|
creator = set.getInt(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return creator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getProject(String projectName, String shortName, int creator) throws Exception
|
||||||
|
{
|
||||||
|
PreparedStatement stmt, stmt2;
|
||||||
|
ResultSet set;
|
||||||
|
int projectFirst = -1, project = -1;
|
||||||
|
|
||||||
|
stmt = connLex.prepareStatement("SELECT id FROM projectsubjects WHERE projectSubject like ? OR projectSubject like ?");
|
||||||
|
stmt.setString(1, "%" + projectName + "%");
|
||||||
|
stmt.setString(2, "%" + shortName + "%");
|
||||||
|
set = stmt.executeQuery();
|
||||||
|
stmt2 = connLex.prepareStatement("DELETE FROM transitionaldata, meta USING transitionaldata, meta WHERE transitionaldata.metaid=meta.metaid AND createdbyprojsub = ?");
|
||||||
|
|
||||||
|
while (set.next())
|
||||||
|
{
|
||||||
|
project = set.getInt(1);
|
||||||
|
if (projectFirst==-1) projectFirst = project;
|
||||||
|
stmt2.setInt(1, project);
|
||||||
|
stmt2.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (projectFirst==-1)
|
||||||
|
{
|
||||||
|
stmt2 = connLex.prepareStatement("INSERT INTO ProjectSubjects(projectSubject, leader, participantList) VALUES (?, ?, ?)");
|
||||||
|
stmt2.setString(1, projectName);
|
||||||
|
stmt2.setInt(2, creator);
|
||||||
|
stmt2.setString(3, "");
|
||||||
|
stmt2.executeUpdate();
|
||||||
|
|
||||||
|
set = stmt.executeQuery();
|
||||||
|
if (set.next())
|
||||||
|
{
|
||||||
|
projectFirst = set.getInt(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* if there is more than one project under that name
|
||||||
|
* delete the others
|
||||||
|
* */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stmt2 = connLex.prepareStatement("UPDATE projectsubjects SET projectSubject = ?, leader = ?, participantList = ? WHERE id = ?");
|
||||||
|
stmt2.setString(1, projectName);
|
||||||
|
stmt2.setInt(2, creator);
|
||||||
|
stmt2.setString(3, "");
|
||||||
|
stmt2.setInt(4, projectFirst);
|
||||||
|
stmt2.executeUpdate();
|
||||||
|
|
||||||
|
if (projectFirst!=project)
|
||||||
|
{
|
||||||
|
stmt2 = connLex.prepareStatement("DELETE FROM projectsubjects WHERE id != ? AND (projectSubject like ? OR projectSubject like ?)");
|
||||||
|
stmt2.setInt(1, projectFirst);
|
||||||
|
stmt2.setString(2, "%" + projectName + "%");
|
||||||
|
stmt2.setString(3, "%" + shortName + "%");
|
||||||
|
stmt2.executeUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return projectFirst;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getLabel(String longName, String shortName, int priority) throws Exception
|
||||||
|
{
|
||||||
|
PreparedStatement stmt, stmt2;
|
||||||
|
ResultSet set;
|
||||||
|
int label=-1;
|
||||||
|
|
||||||
|
stmt = connLex.prepareStatement("SELECT id FROM transitionaldatalabels WHERE transitionaldatalabel like ? OR transitionaldatalabel like ?");
|
||||||
|
stmt.setString(1, "%" + shortName + "%");
|
||||||
|
stmt.setString(2, "%" + longName + "%");
|
||||||
|
set = stmt.executeQuery();
|
||||||
|
|
||||||
|
if (set.next())
|
||||||
|
{
|
||||||
|
label = set.getInt(1);
|
||||||
|
if (set.next())
|
||||||
|
{
|
||||||
|
stmt2 = connLex.prepareStatement("DELETE FROM transitionaldatalabels WHERE id != ? AND (transitionaldatalabel like ? OR transitionaldatalabel like ?)");
|
||||||
|
stmt2.setInt(1, label);
|
||||||
|
stmt2.setString(2, "%" + shortName + "%");
|
||||||
|
stmt2.setString(3, "%" + longName + "%");
|
||||||
|
stmt2.executeUpdate();
|
||||||
|
}
|
||||||
|
stmt2 = connLex.prepareStatement("UPDATE transitionaldatalabels SET priority = ?, transitionaldatalabelshort = ?, transitionaldatalabel = ? WHERE id = ?");
|
||||||
|
stmt2.setInt(1, priority);
|
||||||
|
stmt2.setString(2, shortName);
|
||||||
|
stmt2.setString(3, longName);
|
||||||
|
stmt2.setInt(4, label);
|
||||||
|
stmt2.executeUpdate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stmt2 = connLex.prepareStatement("INSERT INTO transitionaldatalabels(priority, transitionaldatalabel, transitionaldatalabelshort) VALUES (?, ?, ?)");
|
||||||
|
stmt2.setInt(1, priority);
|
||||||
|
stmt2.setString(2, longName);
|
||||||
|
stmt2.setString(3, shortName);
|
||||||
|
stmt2.executeUpdate();
|
||||||
|
|
||||||
|
set = stmt.executeQuery();
|
||||||
|
|
||||||
|
if (set.next())
|
||||||
|
{
|
||||||
|
label = set.getInt(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
String format = null, firstName = "", lastName = "", longName = "", shortName = "";
|
||||||
InputStream is;
|
InputStream is;
|
||||||
|
|
||||||
int argNum = args.length, currentArg = 0;
|
int argNum = args.length, currentArg = 0, creator, priority = -1;
|
||||||
String option;
|
String option;
|
||||||
boolean file = false;
|
boolean file = false;
|
||||||
boolean manual = false;
|
|
||||||
out = null;
|
out = null;
|
||||||
|
|
||||||
delimiterType = delimiterDash;
|
delimiterType = delimiterDash;
|
||||||
delimiter = "-";
|
delimiter = "-";
|
||||||
creator = new Integer(80);
|
proj = -1;
|
||||||
proj = new Integer(18);
|
note = "";
|
||||||
note = "This entry comes from The Rangjung Yeshe Tibetan-English Dictionary of Buddhist Culture (www.rangjung.com).";
|
|
||||||
publicCons = "true";
|
publicCons = "true";
|
||||||
label = new Integer(6);
|
label = -1;
|
||||||
sqlStatement = null;
|
sqlStatement = null;
|
||||||
conn = null;
|
connLex = null;
|
||||||
|
|
||||||
if (argNum <= currentArg) {
|
if (argNum <= currentArg) {
|
||||||
System.out
|
System.out
|
||||||
.println("Syntax: DictionaryImporter [-manual] [-format format] [-tab | -delim delimiter] "
|
.println("Syntax: DictionaryImporter [-format format] [-tab | -delim delimiter] "
|
||||||
+ "[-creator creator-id] [-proj project-id] [-label label] [-note note] "
|
+ "-creatorFirstName first-name -creatorLastName last-name [-proj project-name] [-note note] "
|
||||||
+ "[-pub-cons public-consumption-marker] [input-file] [output-error-file]");
|
+ "[-pub-cons public-consumption-marker] [input-file] [output-error-file]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -353,11 +450,7 @@ public class DictionaryImporter {
|
||||||
while (args[currentArg].charAt(0) == '-') {
|
while (args[currentArg].charAt(0) == '-') {
|
||||||
option = args[currentArg].substring(1);
|
option = args[currentArg].substring(1);
|
||||||
currentArg++;
|
currentArg++;
|
||||||
if (option.equals("manual")) {
|
if (option.equals("format")) {
|
||||||
initConnections();
|
|
||||||
initStatements();
|
|
||||||
manual = true;
|
|
||||||
} else if (option.equals("format")) {
|
|
||||||
if (argNum <= currentArg) {
|
if (argNum <= currentArg) {
|
||||||
System.out.println("Syntax error: format expected.");
|
System.out.println("Syntax error: format expected.");
|
||||||
return;
|
return;
|
||||||
|
@ -374,26 +467,40 @@ public class DictionaryImporter {
|
||||||
}
|
}
|
||||||
delimiter = args[currentArg];
|
delimiter = args[currentArg];
|
||||||
currentArg++;
|
currentArg++;
|
||||||
} else if (option.equals("creator")) {
|
} else if (option.equals("creatorFirstName")) {
|
||||||
if (argNum <= currentArg) {
|
if (argNum <= currentArg) {
|
||||||
System.out.println("Syntax error: creator expected.");
|
System.out.println("Syntax error: creator\'s first name expected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
creator = new Integer(args[currentArg]);
|
firstName = args[currentArg];
|
||||||
currentArg++;
|
currentArg++;
|
||||||
} else if (option.equals("proj")) {
|
} else if (option.equals("creatorLastName")) {
|
||||||
if (argNum <= currentArg) {
|
if (argNum <= currentArg) {
|
||||||
System.out.println("Syntax error: project expected.");
|
System.out.println("Syntax error: creator\'s last name expected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
proj = new Integer(args[currentArg]);
|
lastName = args[currentArg];
|
||||||
currentArg++;
|
currentArg++;
|
||||||
} else if (option.equals("label")) {
|
} else if (option.equals("longName")) {
|
||||||
if (argNum <= currentArg) {
|
if (argNum <= currentArg) {
|
||||||
System.out.println("Syntax error: label expected.");
|
System.out.println("Syntax error: project\'s full name expected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
label = new Integer(args[currentArg]);
|
longName = args[currentArg];
|
||||||
|
currentArg++;
|
||||||
|
} else if (option.equals("shortName")) {
|
||||||
|
if (argNum <= currentArg) {
|
||||||
|
System.out.println("Syntax error: project\'s abbreviated name expected.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
shortName = args[currentArg];
|
||||||
|
currentArg++;
|
||||||
|
} else if (option.equals("priority")) {
|
||||||
|
if (argNum <= currentArg) {
|
||||||
|
System.out.println("Syntax error: project\'s priority expected.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
priority = Integer.parseInt(args[currentArg]);
|
||||||
currentArg++;
|
currentArg++;
|
||||||
} else if (option.equals("note")) {
|
} else if (option.equals("note")) {
|
||||||
if (argNum <= currentArg) {
|
if (argNum <= currentArg) {
|
||||||
|
@ -426,35 +533,74 @@ public class DictionaryImporter {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (format != null)
|
if (format != null)
|
||||||
out = new PrintWriter(new OutputStreamWriter(
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
out = new PrintWriter(new OutputStreamWriter(
|
||||||
new FileOutputStream(args[currentArg + 1]), format));
|
new FileOutputStream(args[currentArg + 1]), format));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
out = new PrintWriter(
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
out = new PrintWriter(
|
||||||
new FileOutputStream(args[currentArg + 1]));
|
new FileOutputStream(args[currentArg + 1]));
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
file = true;
|
file = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file) {
|
if (file)
|
||||||
if (args[currentArg].indexOf("http://") >= 0)
|
{
|
||||||
is = new BufferedInputStream((new URL(args[currentArg]))
|
try
|
||||||
.openStream());
|
{
|
||||||
else
|
if (args[currentArg].indexOf("http://") >= 0)
|
||||||
is = new FileInputStream(args[currentArg]);
|
is = new BufferedInputStream((new URL(args[currentArg]))
|
||||||
|
.openStream());
|
||||||
|
else
|
||||||
|
is = new FileInputStream(args[currentArg]);
|
||||||
|
|
||||||
if (format == null)
|
if (format == null)
|
||||||
in = new BufferedReader(new InputStreamReader(is));
|
in = new BufferedReader(new InputStreamReader(is));
|
||||||
else
|
else
|
||||||
in = new BufferedReader(new InputStreamReader(is, format));
|
in = new BufferedReader(new InputStreamReader(is, format));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("File " + args[currentArg] + " not found.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manual) {
|
initConnections();
|
||||||
insertMetaStmt.setString(1, creator.toString());
|
initStatements();
|
||||||
insertMetaStmt.setString(2, creator.toString());
|
|
||||||
insertMetaStmt.setString(3, proj.toString());
|
try
|
||||||
insertMetaStmt.setString(4, proj.toString());
|
{
|
||||||
|
creator = getCreator(firstName, lastName);
|
||||||
|
proj = getProject(longName, shortName, creator);
|
||||||
|
label = getLabel (longName, shortName, priority);
|
||||||
|
|
||||||
|
insertMetaStmt.setInt(1, creator);
|
||||||
|
insertMetaStmt.setInt(2, creator);
|
||||||
|
insertMetaStmt.setInt(3, proj);
|
||||||
|
insertMetaStmt.setInt(4, proj);
|
||||||
insertMetaStmt.setString(5, note);
|
insertMetaStmt.setString(5, note);
|
||||||
}
|
|
||||||
|
|
||||||
new DictionaryImporter().doImport();
|
new DictionaryImporter().doImport();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue