Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.DukeConfigException


    try {
      Class klass = Class.forName(classname);
      return klass.newInstance();
    }
    catch (Exception e) {
      throw new DukeConfigException("Couldn't instantiate class " + classname +
                                    ": " + e);
    }
  }
View Full Code Here


      } else if (localName.equals("data-source")) {
        datasource = (DataSource) instantiate(attributes.getValue("class"));
        currentobj = datasource;
      } else if (localName.equals("column")) {
        if (!(datasource instanceof ColumnarDataSource))
          throw new DukeConfigException("Column inside data source which " +
                                        "does not support it: " + datasource);

        String name = attributes.getValue("name");
        if (name == null)
          throw new DukeConfigException("Column with no name");
        String property = attributes.getValue("property");
        String prefix = attributes.getValue("prefix");
        String cleanername = attributes.getValue("cleaner");
        Cleaner cleaner = makeCleaner(cleanername);

        Column c = new Column(name, property, prefix, cleaner);
        String spliton = attributes.getValue("split-on");
        if (spliton != null)
          c.setSplitOn(spliton);

        ((ColumnarDataSource) datasource).addColumn(c);
      } else if (localName.equals("param")) {
        String param = attributes.getValue("name");
        String value = attributes.getValue("value");

        if (currentobj == null)
          throw new DukeConfigException("Trying to set parameter " +
                                        param + " but no current object");

        // we resolve file references relative to the config file location
        if (param.equals("input-file") && path != null &&
            !value.startsWith("/"))
          value = new File(path, value).getAbsolutePath();

        ObjectUtils.setBeanProperty(currentobj, param, value, objects);
      } else if (localName.equals("group")) {
        groupno++;
        // FIXME: now possible to have data sources between the two
        // groups.  need to check for that, too. ideally XML
        // validation should take care of all this for us.
        if (groupno == 1 && !config.getDataSources().isEmpty())
          throw new DukeConfigException("Cannot have groups in deduplication mode");
        else if (groupno == 3)
          throw new DukeConfigException("Record linkage mode only supports " +
                                        "two groups");

      } else if (localName.equals("object")) {
        String klass = attributes.getValue("class");
        String name = attributes.getValue("name");
View Full Code Here

      if (keepers.contains(localName))
        keep = false;

      else if (localName.equals("duke")) {
        if (groupno > 0 && groupno != 2)
          throw new DukeConfigException("Record linkage mode requires exactly 2 groups; should you be using deduplication mode?");
      }
    }
View Full Code Here

    if (val == null)
      return defaultvalue;
    try {
      return Integer.parseInt(val);
    } catch (NumberFormatException e) {
      throw new DukeConfigException("Option --" + longname + " must be an integer, not '" + val + "'");
    }
  }
View Full Code Here

    if (val == null)
      return defaultvalue;
    try {
      return Double.parseDouble(val);
    } catch (NumberFormatException e) {
      throw new DukeConfigException("Option --" + longname + " must be a double, not '" + val + "'");
    }
  }
View Full Code Here

   * 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;
  }
View Full Code Here

  /**
   * 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);
  }
View Full Code Here

  private String getid(Record r) {
    for (String propname : r.getProperties()) {
      Property prop = config.getPropertyByName(propname);
      if (prop == null)
        throw new DukeConfigException("Record has property " + propname +
                                      " which is not in configuration");

      if (prop.isIdProperty())
        return r.getValue(propname);
    }
View Full Code Here

      CSVReader csv = new CSVReader(in);
      if (separator != 0)
        csv.setSeparator(separator);
      return new CSVRecordIterator(csv);
    } catch (FileNotFoundException e) {
      throw new DukeConfigException("Couldn't find CSV file '" + file + "'");
    } catch (IOException e) {
      throw new DukeException(e);
    }
  }
View Full Code Here

            found = true;
            break;
          }
        }
        if (!found)
          throw new DukeConfigException("Column " + c.getName() + " not found "+
                                        "in CSV file");
      }

      findNextRecord();
    }
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.DukeConfigException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.