Examples of GeolocCity


Examples of org.hoteia.qalingo.core.domain.GeolocCity

            addressGeolocMessageJms.setServerIp(InetAddress.getLocalHost().getHostAddress());
            if(result != null && result instanceof GeolocAddress){
                GeolocAddress geolocAddress = (GeolocAddress) result;
                addressGeolocMessageJms.setGeolocType("GeolocAddress");
            } else if(result != null && result instanceof GeolocCity){
                GeolocCity geolocCity = (GeolocCity) result;
                addressGeolocMessageJms.setGeolocType("GeolocCity");
            }
           
            // Generate and send the JMS message
            addressGeolocMessageProducer.generateMessages(addressGeolocMessageJms);
View Full Code Here

Examples of org.hoteia.qalingo.core.domain.GeolocCity

    protected GeolocDao geolocDao;
   
    // GEOLOC CITY
   
    public GeolocCity geolocByCityAndCountry(final String city, final String country){
        GeolocCity geolocCity = null;
        String address = city.replace(" ", "+") + "," + country.replace(" ", "+");
        String key = null;
        try {
            key = engineSettingService.getGoogleGeolocationApiKey();
        } catch (Exception e) {
            logger.error("Google Geolocation API Key is mandatory!", e);
        }
        if(key != null && StringUtils.isNotEmpty(key)){
            HttpPost request = new HttpPost("https://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&key=" + key);
            HttpResponse response = null;
            HttpClient httpClient = new DefaultHttpClient();
            try {
                response = httpClient.execute(request);
               
            } catch (ClientProtocolException e) {
                logger.error("", e);
            } catch (IOException e) {
                logger.error("", e);
            }

            try {
                BufferedReader streamReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                StringBuilder responseStrBuilder = new StringBuilder();

                String inputStr;
                while ((inputStr = streamReader.readLine()) != null){
                    responseStrBuilder.append(inputStr);
                }
                String json = responseStrBuilder.toString();
               
                ObjectMapper mapper = new ObjectMapper();
                GoogleGeoCode geoCode = mapper.readValue(json, GoogleGeoCode.class);
               
                geolocCity = new GeolocCity();
                geolocCity.setCity(city);
                geolocCity.setCountry(country);
                geolocCity.setJson(json);
                geolocCity.setLatitude(geoCode.getLatitude());
                geolocCity.setLongitude(geoCode.getLongitude());
                geolocCity = geolocDao.saveOrUpdateGeolocCity(geolocCity);
               
            } catch (IllegalStateException e) {
                logger.error("", e);
            } catch (IOException e) {
View Full Code Here

Examples of org.hoteia.qalingo.core.domain.GeolocCity

        FetchPlan fetchPlan = handleSpecificFetchMode(criteria);

        criteria.add(Restrictions.eq("city", city));
        criteria.add(Restrictions.eq("country", country));
        GeolocCity geolocCity = (GeolocCity) criteria.uniqueResult();
        if (geolocCity != null) {
            geolocCity.setFetchPlan(fetchPlan);
        }
        return geolocCity;
    }
View Full Code Here

Examples of org.hoteia.qalingo.core.domain.GeolocCity

        geolocCity.setDateUpdate(new Date());
        if (geolocCity.getId() != null) {
            if (em.contains(geolocCity)) {
                em.refresh(geolocCity);
            }
            GeolocCity mergedGeolocCity = em.merge(geolocCity);
            em.flush();
            return mergedGeolocCity;
        } else {
            em.persist(geolocCity);
            return geolocCity;
View Full Code Here

Examples of org.hoteia.qalingo.core.domain.GeolocCity

    protected EngineEcoSession handleGeolocData(final HttpServletRequest request, EngineEcoSession engineEcoSession, final GeolocData geolocData) throws Exception {
        if (geolocData != null) {
            // FIND LATITUDE/LONGITUDE BY CITY/COUNTRY
            City city = geolocData.getCity();
            Country country = geolocData.getCountry();
            GeolocCity geolocCity = geolocService.getGeolocCityByCityAndCountry(city.getName(), country.getName());
            if (geolocCity != null) {
                geolocData.setLatitude(geolocCity.getLatitude());
                geolocData.setLongitude(geolocCity.getLongitude());
            } else {
                // LATITUDE/LONGITUDE DOESN'T EXIST - WE USE GOOGLE GEOLOC TO FOUND IT
                geolocCity = geolocService.geolocByCityAndCountry(city.getName(), country.getName());
                if (geolocCity != null) {
                    geolocData.setLatitude(geolocCity.getLatitude());
                    geolocData.setLongitude(geolocCity.getLongitude());
                }
            }
            engineEcoSession.setGeolocData(geolocData);
            engineEcoSession = updateCurrentEcoSession(request, engineEcoSession);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.