Exemplo n.º 1
0
  private void deleteSensorTag() {
    String uri = null;
    String id = null;
    String tag = null;
    Map<String, String> sensorMetaMap = null;

    System.out.println("Delete Sensor Tags Mode");
    System.out.print("Sensor ID: ");
    id = sc.nextLine();

    System.out.print("Tag: ");
    tag = sc.nextLine();

    try {
      sensorMetaMap = sensorMetaDAO.getSensorMeta(id);
      uri = sensorMetaMap.get("uri");

      sensorMetaDAO.deleteTagInfo(uri, tag);

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  private void updateSensorMeta() {
    String ip = null;
    String id = null;
    String uri = null;

    System.out.println("Update Sensor Meta Mode");

    Map<String, String> sensorMetaMap = null;

    System.out.print("Input Sensor ID: ");
    id = sc.nextLine();

    try {
      sensorMetaMap = sensorMetaDAO.getSensorMeta(id);

      ip = sensorMetaMap.get("ip");
      System.out.println("Current Sensor IP: " + ip);

      String old_id = id;

      System.out.println("Input Updated Sensor Meta ");
      System.out.print("Sensor IP: ");
      ip = sc.nextLine();
      System.out.println(ip);
      System.out.print("Sensor ID: ");
      id = sc.nextLine();
      System.out.println(id);
      uri = "http://" + ip + "/" + id;
      System.out.println("Your New URI: " + uri);

      sensorMetaDAO.updateSensorMeta(uri, ip, id, old_id);
      System.out.println("Finish DB Update");

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 3
0
  private void deleteSensorMeta() {
    String sensor_id = null;
    System.out.println("Delete Sensor Meta Mode");

    System.out.print("Input Sensor ID: ");
    sensor_id = sc.nextLine();

    try {
      sensorMetaDAO.deleteSensorMeta(sensor_id);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    System.out.println("Finish Sensor Meta Delete");
  }
Exemplo n.º 4
0
  private void createSensorNetwork() {
    String sn_name = null;
    String create_date = null;
    int sn_id = 0;
    String input_sn_id = null;
    Set<String> sn_uris = new HashSet<String>();
    System.out.println("Create Sensor Network Mode");
    System.out.print("Sensor Network Name: ");
    sn_name = sc.nextLine();

    Calendar calendar = Calendar.getInstance();
    java.util.Date date = calendar.getTime();
    create_date = (new SimpleDateFormat("yyyyMMddHHmmss").format(date));

    try {
      sensorNetworkMetaDAO.addSensorNetwork(sn_name, create_date);
      System.out.println("Finish Insert Sensor Network in DB");
      System.out.println("Add Sensors");

      for (; ; ) {
        System.out.print("Input Sensor(for quit to type 'x'): ");
        input_sn_id = sc.nextLine();
        if (input_sn_id.compareTo("x") == 0) break;
        else {
          String sn_uri = sensorMetaDAO.getSensorURI(input_sn_id);
          sn_uris.add(sn_uri);
        }
      }
      sn_id = sensorNetworkMetaDAO.getSensorNetworkID(sn_name);
      sensorNetworkMetaDAO.addSensorNetworkMembers(sn_id, sn_uris);
      snConnector.setSensorNetworkData(sn_name, sn_id, sn_uris, false);
      snConnector.transferSensorNetworkMeta();

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 5
0
  private void createSensorMeta() {
    String ip = null;
    String id = null;
    String uri = null;

    System.out.println("Create Sensor Meta Mode");
    System.out.print("Sensor IP: ");
    ip = sc.nextLine();
    System.out.println(ip);
    System.out.print("Sensor ID: ");
    id = sc.nextLine();
    System.out.println(id);
    uri = "http://" + ip + "/" + id;
    System.out.println("Your URI: " + uri);

    try {
      sensorMetaDAO.addSensorMeta(uri, ip, id);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    System.out.println("Finish DB Input");
  }