/**
   * Gives Project object from given identifier
   *
   * @param projectId
   * @return
   * @throws DatabaseException
   * @throws SQLException
   * @throws DatabaseValueNotFoundException
   */
  public Project getProject(int projectId)
      throws DatabaseException, SQLException, DatabaseValueNotFoundException {
    PreparedStatement statement =
        this.conApex.prepareStatement(
            "SELECT * FROM BRG_PROJECT WHERE ID=?",
            ResultSet.TYPE_SCROLL_INSENSITIVE,
            ResultSet.CONCUR_READ_ONLY);

    statement.setInt(1, projectId);
    ResultSet result = statement.executeQuery();
    ArrayList<Rule> rules = getRules(projectId);

    while (result.next()) {
      Project tmpProject =
          new Project(
              result.getInt("ID"),
              result.getString("NAME"),
              result.getString("TARGET_DATABASE_DESC"),
              new DbConfiguration(
                  result.getString("TARGET_DATABASE_IP"),
                  result.getString("TARGET_DATABASE_USERNAME"),
                  result.getString("TARGET_DATABASE_PASSWORD"),
                  result.getString("TARGET_DATABASE_DATABASE"),
                  result.getString("TARGET_DATABASE_PORT")));

      if (rules != null) {
        for (Rule rule : rules) {
          ArrayList<Column> collumns = getColumns(rule.getId());
          if (collumns != null) {
            for (Column column : collumns) {
              rule.addColumns(column);
            }
          }
          ArrayList<Value> values = getValues(rule.getId());
          if (values != null) {
            for (Value value : values) {
              rule.addValues(value);
            }
          }
          ArrayList<Table> tables = getTables(rule.getId());
          if (tables != null) {
            for (Table table : tables) {
              rule.addTables(table);
            }
          }
          tmpProject.addRule(rule);
        }
      }
      statement.close();
      return tmpProject;
    }
    statement.close();
    throw new DatabaseValueNotFoundException("Project " + projectId + " not found");
  }