コード例 #1
0
  protected List<Category> exportCategories() {
    if (!this.running) return null;

    // get user configured column names and sql
    String colId = (String) this.properties.get(PROPKEY_CAT_ID);
    String colName = (String) this.properties.get(PROPKEY_CAT_NAME);
    String table = (String) this.properties.get(PROPKEY_CAT_TABLE);
    String rawSql = (String) this.properties.get(PROPKEY_CAT_SQL);
    // update sql to reflect user configured column names
    String sql = rawSql.replaceAll("\\Q{" + PROPKEY_CAT_ID + "}\\E", colId);
    sql = sql.replaceAll("\\Q{" + PROPKEY_CAT_NAME + "}\\E", colName);
    sql = sql.replaceAll("\\Q{" + PROPKEY_CAT_TABLE + "}\\E", table);

    Vector<Category> categories = new Vector<Category>();

    ResultSet data = null;
    try {
      data = sql(sql);
      while (data.next()) { // get each category
        Category cat = new Category();
        cat.id = data.getString(colId);
        cat.name = encode(data.getBytes(colName));
        categories.add(cat);
      }
    } catch (SQLException e) {
      log.error("Could not export Categories with sql: " + sql);
      e.printStackTrace();
      return null;
    }
    return categories;
  }
コード例 #2
0
 public Category createCategory() {
   Category category = new Category();
   category.name = "Test category";
   category.operationType = OperationType.expense;
   return category;
 }