protected ResourceResponse newResourceResponse(final IResource.Attributes attributes) {
   final ResourceResponse response = new ResourceResponse();
   if (this.lastModifiedTime != null) {
     response.setLastModified(this.lastModifiedTime);
   } else {
     response.setLastModified(Time.now());
   }
   if (response.dataNeedsToBeWritten(attributes)) {
     response.setContentType("image/" + this.getFormat());
     response.setContentDisposition(ContentDisposition.INLINE);
     final byte[] imageData = this.getImageData(attributes);
     if (imageData == null) {
       response.setError(404);
     } else {
       response.setWriteCallback(
           new WriteCallback() {
             public void writeData(final IResource.Attributes attributes) {
               attributes.getResponse().write(imageData);
             }
           });
       this.configureResponse(response, attributes);
     }
   }
   return response;
 }
Exemple #2
0
 public void timeEvent(Time arg0) {
   // System.out.println("time " + arg0.getTime());
   time = arg0.getTime();
 }
  /**
   * Insert all service in services table
   *
   * @param noms
   * @throws SQLException
   */
  public static void insertStations(List<String[]> pdvs) throws SQLException {

    int idPdv;
    String nom = "";
    String adresse = "";
    String ville = "";
    String cp = "";
    String type_route;
    String[] ouvert = new String[3];
    String[] fermer = new String[3];
    Time hor_Ouv = null;
    hor_Ouv.valueOf("00:00:00");
    Time hor_Ferm = null;
    hor_Ferm.valueOf("00:00:00");
    double latitudePdv;
    double longitudePdv;

    String path = "src\\DAL\\StationsNOM.csv";
    List<String> nomStations = LectureFichier.readTXT(path);

    Random rand = new Random();
    int nbrand = 2;

    String requete =
        "INSERT INTO stations "
            + "(id_Station,Nom,Adresse,Ville,CP,Type_route,Horaire_ouverture,Horaire_fermeture,latitude,longitude) "
            + "VALUES(?,?,?,?,?,?,?,?,?,?)";
    // int[] count= new int[0];

    Connection connection = ConnexionManager.GetInstance().GetConnection();
    for (String[] pdv : pdvs) {

      if (!pdv[0].equals("id")) {
        idPdv = Integer.parseInt(pdv[0]);
        // integration des noms g�n�r� al�atoirement
        nbrand = rand.nextInt(nomStations.size() - 2) + 1;
        nom = nomStations.get(nbrand);
        adresse = pdv[1];
        ville = pdv[2];
        cp = pdv[3];
        type_route = pdv[4];
        ouvert = pdv[5].split(":");
        fermer = pdv[6].split(":");
        // fermer = pdv[6].replace(':', '-');
        hor_Ouv =
            new Time(
                Integer.parseInt(ouvert[0]),
                Integer.parseInt(ouvert[1]),
                Integer.parseInt(ouvert[2]));
        hor_Ferm =
            new Time(
                Integer.parseInt(fermer[0]),
                Integer.parseInt(fermer[1]),
                Integer.parseInt(fermer[2]));
        latitudePdv = Double.parseDouble(pdv[7]);
        longitudePdv = Double.parseDouble(pdv[8]);

        try {
          PreparedStatement requeteSql = connection.prepareStatement(requete);
          requeteSql.setInt(1, idPdv);
          requeteSql.setString(2, nom);
          requeteSql.setString(3, adresse);
          requeteSql.setString(4, ville);
          requeteSql.setString(5, cp);
          requeteSql.setString(6, type_route);
          requeteSql.setTime(7, hor_Ouv);
          requeteSql.setTime(8, hor_Ferm);
          requeteSql.setDouble(9, latitudePdv);
          requeteSql.setDouble(10, longitudePdv);
          requeteSql.addBatch();
          int[] count = requeteSql.executeBatch();
          // requeteSql.executeBatch();
          // System.out.println(count.length);
        } catch (SQLException sqle) {
          // TODO Auto-generated catch block

          ConnexionManager.GetInstance().GetConnection().rollback();

          sqle.printStackTrace();
        }
      }
    }
  }