1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import com.yourcompany.struts.form.AcceuilsFB;
/**
* MyEclipse Struts
* Creation date: 12-31-2008
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class AcceuilsACTAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward HOTEL(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
AcceuilsFB fb= (AcceuilsFB) form;
//ActionForward forward = new ActionForward();
//ajouter Simplelbs
//ajouter veiwlbs
//ajouter cordx cordy
String coordx;
String coordy ;
SimpleLBS myLbs = new SimpleLBS();
Positione p=new Positione();
myLbs.viewLocation("22528837");
coordx=myLbs.getX();
coordy=myLbs.getY();
p.setx(""+coordx);
p.sety(""+coordy);
double x =p.Convertx();
double y =p.Converty();
double xmin=x-0.005;
double ymin=y-0.005;
double xmax=x+0.005;
double ymax=y+0.005;
fb.setCordx(""+x); // Mettre le résulat sur l'un des ces faviable
fb.setCordy(""+y);
fb.setAdress("adresse hotel");
// CONNEXION BASE DONN2E
Transaction tx = null;
Session session = null;
try {
SessionFactory sessionFactory = null;
try {
Context ctx = new InitialContext();
Object obj = ctx.lookup("HibernateSessionFactory");
sessionFactory =(SessionFactory) obj;
} catch (NamingException e1) {
e1.printStackTrace();
}
session = sessionFactory.openSession();
String Hql=" select adresse,télephone from Hôtels " ;
//" where x between " +xmin+" AND"+xmax+
//" AND y between" +ymin+"AND"+ymax ;
Query q= session.createQuery(Hql);
List list = q.list();
Iterator it = list.iterator();
while (it.hasNext()){
AcceuilsFB tempfb = new AcceuilsFB();
if(it.hasNext())
{
Object[] tempobj=(Object[]) it.next();
tempfb = new AcceuilsFB() ;
String adress=(tempobj[0]!= null ? tempobj[0].toString(): "");
String num=(tempobj[1]!= null ? tempobj[1].toString(): "");
tempfb.setAdress("adresse"+adress+"num"+num);
}
}}
catch (HibernateException e1) {
e1.printStackTrace();
if (tx != null && tx.isActive())
tx.rollback();
System.out.println("Echec " + e1.getMessage());
} catch (Exception e) {
} finally
{
return mapping.findForward("acceuilsFB");
}
} |
Partager