示例#1
0
  private List<StrasseDTO> findStreetsByPoint(
      Long startPunktId, boolean isMautAllowed, String query) throws SQLException {

    List<StrasseDTO> retVal = new ArrayList<StrasseDTO>();
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;

    Connection connection = daoFactory.getConnection();
    if (isMautAllowed) {
      preparedStatement =
          DaoUtil.prepareStatement(connection, query, false, new Object[] {startPunktId});
    } else {
      preparedStatement =
          DaoUtil.prepareStatement(
              connection, query + " AND Toll=?", false, new Object[] {startPunktId, 0});
    }
    resultSet = preparedStatement.executeQuery();

    while (resultSet.next()) {
      StrasseDTO s = new StrasseDTO();
      s.setStartPunktId(resultSet.getLong("StartPoint"));
      s.setEndPunktId(resultSet.getLong("EndPoint"));
      s.setDistanz(resultSet.getLong("Distance"));
      s.setSpeed(resultSet.getInt("Speed"));
      s.setMaut(resultSet.getBoolean("Toll"));

      retVal.add(s);
    }
    return retVal;
  }
示例#2
0
  @Override
  public void deletePoint(OrtDTO dto) throws SQLException {

    PreparedStatement preparedStatement = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement =
        DaoUtil.prepareStatement(
            connection, DELETEPOINTBYID, false, new Object[] {dto.getPointId()});
    preparedStatement.executeUpdate();
  }
示例#3
0
  @Override
  public void deleteStrasse(StrasseDTO dto) throws SQLException {

    PreparedStatement preparedStatement = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement =
        DaoUtil.prepareStatement(
            connection,
            DELETESTREET,
            false,
            new Object[] {dto.getStartPunktId(), dto.getEndPunktId()});
    preparedStatement.executeUpdate();
  }
示例#4
0
  @Override
  public OrtDTO createPoint(OrtDTO dto) throws SQLException {

    PreparedStatement preparedStatement = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement =
        DaoUtil.prepareStatement(
            connection,
            CREATEPOINT,
            false,
            new Object[] {dto.getPointX(), dto.getPointY(), dto.getDescription()});
    preparedStatement.executeUpdate();

    return findPointByAxis(dto.getPointX(), dto.getPointY());
  }
示例#5
0
  @Override
  public Map<Integer, StrasseComponentDTO> deleteStreetsByPointId(Long pointId)
      throws SQLException {

    Map<Integer, StrasseComponentDTO> deletedMap =
        findStreets(
            ALLSTREETSTODISPLAY + "WHERE Startpoint=? OR Endpoint=?",
            new Object[] {pointId, pointId});

    Connection connection = daoFactory.getConnection();
    PreparedStatement preparedStatement =
        DaoUtil.prepareStatement(
            connection, DELETESTREETBYPOINT, false, new Object[] {pointId, pointId});
    preparedStatement.executeUpdate();

    return deletedMap;
  }
示例#6
0
  @Override
  public Long findPointIdByName(String name) throws SQLException {

    PreparedStatement preparedStatement = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement =
        DaoUtil.prepareStatement(connection, FINDPOINTBYNAME, false, new Object[] {name});
    ResultSet rs = preparedStatement.executeQuery();
    Long retVal = null;

    while (rs.next()) {
      retVal = rs.getLong("id");
    }

    return retVal;
  }
示例#7
0
  @Override
  public OrtDTO findPointByAxis(int punktX, int punktY) throws SQLException {
    OrtDTO ort = new OrtDTO();
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement =
        DaoUtil.prepareStatement(connection, FINDPOINTBYAXIS, false, new Object[] {punktX, punktY});
    resultSet = preparedStatement.executeQuery();

    while (resultSet.next()) {
      ort.setPointId(resultSet.getLong("id"));
      ort.setPointX(resultSet.getInt("xAxis"));
      ort.setPointY(resultSet.getInt("yAxis"));
      ort.setDescription(resultSet.getString("name"));
    }
    return ort;
  }
示例#8
0
  @Override
  public List<OrtDTO> findAllPoints() throws SQLException {
    List<OrtDTO> retVal = new ArrayList<OrtDTO>();
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement = DaoUtil.prepareStatement(connection, FINDALLPOINTS, false, new Object[0]);
    resultSet = preparedStatement.executeQuery();

    while (resultSet.next()) {
      OrtDTO ort = new OrtDTO();
      ort.setPointId(resultSet.getLong("id"));
      ort.setPointX(resultSet.getInt("xAxis"));
      ort.setPointY(resultSet.getInt("yAxis"));
      ort.setDescription(resultSet.getString("name"));
      retVal.add(ort);
    }
    return retVal;
  }
示例#9
0
  private Map<Integer, StrasseComponentDTO> findStreets(String query, Object[] args)
      throws SQLException {

    Connection connection = daoFactory.getConnection();
    PreparedStatement preparedStatement = DaoUtil.prepareStatement(connection, query, false, args);

    ResultSet resultSet = preparedStatement.executeQuery();
    Map<Integer, StrasseComponentDTO> map = new HashMap<Integer, StrasseComponentDTO>();
    while (resultSet.next()) {
      StrasseComponentDTO s = new StrasseComponentDTO();
      s.setStartId(resultSet.getLong("StartId"));
      s.setEndId(resultSet.getLong("EndId"));
      s.setxStart(resultSet.getInt("startX"));
      s.setyStart(resultSet.getInt("startY"));
      s.setxEnd(resultSet.getInt("endX"));
      s.setyEnd(resultSet.getInt("endY"));
      s.setDistanz(resultSet.getDouble("Distance"));
      s.setSpeed(resultSet.getInt("Speed"));
      s.setMaut(resultSet.getBoolean("Toll"));
      map.put(s.hashCode(), s);
    }
    return map;
  }