public static LinkKind getbyid(int id) { if (id == 1) return SAME; else if (id == 2) return MAYBESAME; else if (id == 3) return DIFFERENT; throw new DukeException("No kind with id " + id); } }
private Database getDB(int no) { if (no == 1) return database1; else if (no == 2) return database2; else throw new DukeException("Unknown database " + no); }
public static LinkStatus getbyid(int id) { if (id == 2) return ASSERTED; else if (id == 1) return INFERRED; else if (id == 0) return RETRACTED; throw new DukeException("No status with id " + id); } }
private void addToClass(String id, int clid) { try { stmt.executeUpdate("insert into classes values ('" + id + "', " + clid + ")"); } catch (SQLException e) { throw new DukeException(e); } }
private void merge(int clid1, int clid2) { try { stmt.executeUpdate("update classes set clid = " + clid1 + " where clid = " + clid2); } catch (SQLException e) { throw new DukeException(e); } }
public void spawnThread(DukeController controller, int check_interval) { if (this.controller != null) throw new DukeException("Timer thread already running!"); this.controller = controller; this.check_interval = check_interval * 1000; // convert to ms keep_running = true; // spawn away Thread thread = new Thread(this); thread.setDaemon(true); thread.start(); }
private void parsedatatype() { pos++; // skip first ^ if (line.charAt(pos++) != '^') throw new DukeException("Incorrect start of datatype"); if (line.charAt(pos) != '<') throw new DukeException("Datatype URI does not start with '<'"); parseuri(); }
/** * Empties the link database. Used only for testing at the moment. */ public void clear() { try { stmt.executeUpdate("delete from " + tblprefix + "links"); } catch (SQLException e) { close(); // releasing connection throw new DukeException(e); } }
public RecordIterator getRecordsFromString(String s) { try { JsonFactory jsonFactory = new JsonFactory(); return new JsonIterator(jsonFactory.createParser(new StringReader(s))); } catch (IOException e) { throw new DukeException(e); } }
public RecordIterator getRecords() { try { return getRecordsFromStream(new FileInputStream(file)); } catch (IOException e) { throw new DukeException("Error reading JSON from " + file, e); } }
@Override // is this "Override" necessary? public void close(){ try { mongoClient.close(); } catch (Exception e) { throw new DukeException(e); } }
public RecordIterator getRecordsFromStream(InputStream is) { JsonFactory jsonFactory = new JsonFactory(); try { JsonParser jp = jsonFactory.createParser(is); return new JsonIterator(jp); } catch (IOException e) { throw new DukeException(e); } }
public void commit() { try { Connection conn = stmt.getConnection(); if (!conn.getAutoCommit()) // we only call commit if the connection is not auto-committing, as // mysql throws an exception otherwise (issue 105) conn.commit(); } catch (SQLException e) { close(); // releasing connection throw new DukeException(e); } }
public LinkKind getLinkKind(String id1, String id2) { boolean match = console.yesorno(); if (writer != null) try { writer.write(id1, id2, match, 1.0); out.flush(); // make sure everything's saved } catch (IOException e) { throw new DukeException(e); } return match ? LinkKind.SAME : LinkKind.DIFFERENT; }
private String getid(Record r) { for (Property p : idprops) { String v = r.getValue(p.getName()); if (v == null) continue; return v; } throw new DukeException("No identity for record " + r); } }
private String getid(Record r) { for (Property p : idprops) { String v = r.getValue(p.getName()); if (v == null) continue; return v; } throw new DukeException("No identity for record " + r); } }
private void flushIndex(boolean force) { if ((force && this.bulkRequestCounter > 0) || this.bulkRequestCounter >= this.bulkSize) { BulkResponse bulkResponse = this.bulkRequest.execute().actionGet(); if (bulkResponse.hasFailures()) { throw new DukeException(bulkResponse.buildFailureMessage()); } // reset bulk this.bulkRequestCounter = 0; this.bulkRequest = this.client.prepareBulk(); } }
private void init() { try { openIndexes(overwrite); openSearchers(); initSpatial(); } catch (Exception e) { // initialization failed, so clean up to prevent leaving us in an // inconsistent state https://github.com/larsga/Duke/issues/226 directory = null; throw new DukeException(e); } }
private String getIdentity(Record r) { for (Property p : config.getIdentityProperties()) { Collection<String> vs = r.getValues(p.getName()); if (vs == null) continue; for (String v : vs) return v; } throw new DukeException("No identity found in record [" + PrintMatchListener.toString(r) + "]"); }
public void matches(Record r1, Record r2, double confidence) { try { for (Property p : idprops) for (String id1 : r1.getValues(p.getName())) for (String id2 : r2.getValues(p.getName())) link(id1, id2, confidence); } catch (IOException e) { throw new DukeException(e); } } }