public void addDatabase(Database database) { if (database1 == null) database1 = database; else if (database2 == null) database2 = database; else throw new DukeConfigException("Too many database objects configured"); }
public static void main(String[] argv) throws IOException { try { main_(argv); } catch (DukeConfigException e) { System.err.println("ERROR: " + e.getMessage()); } }
public double compute(int common, Set<String> q1, Set<String> q2) { throw new DukeConfigException("Unknown formula: " + this); } }
public static void main(String[] argv) throws IOException, CorruptIndexException { try { main_(argv); } catch (DukeConfigException e) { System.err.println("ERROR: " + e.getMessage()); } }
public Set<String> qgrams(String s, int q) { throw new DukeConfigException("Uknown tokenizer: " + this); } }
/** * Returns the data sources belonging to a particular group of data * sources. Data sources are grouped in record linkage mode, but not * in deduplication mode, so only use this method in record linkage * mode. */ public Collection<DataSource> getDataSources(int groupno) { if (groupno == 1) return group1; else if (groupno == 2) return group2; else throw new DukeConfigException("Invalid group number: " + groupno); }
public double compute(int removed, int shortlen, int longlen) { throw new DukeConfigException("Unknown formula: " + this); } }
/** * Used for getting required properties, will throw an exception if * the property is not specified. */ public static String get(Properties props, String name) { String value = props.getProperty(name); if (value == null) throw new DukeConfigException("Required property " + name + " not specified"); return value; }
private static Object instantiate(String classname) { try { Class klass = Class.forName(classname); return klass.newInstance(); } catch (Exception e) { throw new DukeConfigException("Couldn't instantiate class " + classname + ": " + e); } } }
private static DatabaseType getDatabaseType(String dbtype) { if (dbtype.equals("h2")) return DatabaseType.H2; else if (dbtype.equals("oracle")) return DatabaseType.ORACLE; else if (dbtype.equals("mysql")) return DatabaseType.MYSQL; else throw new DukeConfigException("Unknown database type: '" + dbtype + "'"); }
/** * Returns the enum constant from the given enum class representing * the constant with the given identifier/name. */ public static Object getEnumConstantByName(Class klass, String name) { name = name.toUpperCase(); Object c[] = klass.getEnumConstants(); for (int ix = 0; ix < c.length; ix++) if (c[ix].toString().equals(name)) return c[ix]; throw new DukeConfigException("No such " + klass + ": '" + name + "'"); }
protected void verifyProperty(String value, String name) { if (value == null) throw new DukeConfigException("Missing '" + name + "' property to " + getSourceName() + " data source"); }
public int getOptionInteger(String longname, int defaultvalue) { String val = ((StringOption) options.get(longname)).getValue(); if (val == null) return defaultvalue; try { return Integer.parseInt(val); } catch (NumberFormatException e) { throw new DukeConfigException("Option --" + longname + " must be an integer, not '" + val + "'"); } }
public double getOptionDouble(String longname, double defaultvalue) { String val = ((StringOption) options.get(longname)).getValue(); if (val == null) return defaultvalue; try { return Double.parseDouble(val); } catch (NumberFormatException e) { throw new DukeConfigException("Option --" + longname + " must be a double, not '" + val + "'"); } }
/** * Sets the file to write user's answers to in active learning mode. */ public void setLinkFile(String linkfile) throws IOException { if (scientific || !active || oracle instanceof LinkFileOracle) throw new DukeConfigException("Have no use for link file"); ((ConsoleOracle) oracle).setLinkFile(linkfile); }
private LinkDatabase makeLinkDatabase(Properties props) { String dbtype = get(props, "duke.linkdbtype"); if (dbtype.equals("jdbc")) return makeJDBCLinkDatabase(props); else if (dbtype.equals("jndi")) return makeJNDILinkDatabase(props); else throw new DukeConfigException("Unknown link database type '" + dbtype + "'"); }
/** * Validates the configuration to verify that it makes sense. * Rejects configurations that will fail during runtime. */ public void validate() { // verify that we do have properties if (properties == null || properties.isEmpty()) throw new DukeConfigException("Configuration has no properties at all"); // check if max prob is below threshold // this code duplicates code in findLookupProperties(), but prefer // that to creating an attribute double prob = 0.5; for (Property prop : properties.values()) { if (prop.getHighProbability() == 0.0) // if the probability is zero we ignore the property entirely continue; prob = Utils.computeBayes(prob, prop.getHighProbability()); } if (prob < threshold) throw new DukeConfigException("Maximum possible probability is " + prob + ", which is below threshold (" + threshold + "), which means no duplicates will ever " + "be found"); // check that we have at least one ID property if (getIdentityProperties().isEmpty()) throw new DukeConfigException("No ID properties."); // check that we only have one ID property if (getIdentityProperties().size() > 1) throw new DukeConfigException("Can only have one ID property."); }
throw new DukeConfigException("Couldn't find method '" + prop + "' in " + "class " + object.getClass()); } catch (IllegalArgumentException e) { throw new DukeConfigException("Couldn't set bean property " + prop + " on object of class " + object.getClass() + ": " + e); throw new DukeException(e); } catch (InvocationTargetException e) { throw new DukeConfigException("Couldn't set bean property " + prop + " on object of class " + object.getClass() + ": " + e);
public Record next() { String resource = page.get(pagerow)[0]; Collection<Column> cols = columns.get("?uri"); if (cols == null) throw new DukeConfigException("No '?uri' column. It's required in triple mode"); Column uricol = cols.iterator().next(); builder.newRecord(); builder.setValue(uricol, resource); while (pagerow < page.size() && resource.equals(page.get(pagerow)[0])) { while (pagerow < page.size() && resource.equals(page.get(pagerow)[0])) { cols = columns.get(page.get(pagerow)[1]); if (cols != null) { for (Column col : cols) addValue(2, col); } pagerow++; } // did we just step off this page? if (pagerow >= page.size()) fetchNextPage(); } return builder.getRecord(); } }
else if (type == Character.TYPE) { if (value.length() != 1) throw new DukeConfigException("String '" + value + "' is not a character"); return new Character(value.charAt(0)); } else if (type.isEnum())