Package org.fluxtream.core.domain.metadata

Examples of org.fluxtream.core.domain.metadata.VisitedCity


        setDayMainCity(guestId, date, closestCity);
    }

    @Override
    public void setDayMainCity(final long guestId, final long visitedCityId, final String date) {
        final VisitedCity visitedCity = em.find(VisitedCity.class, visitedCityId);
        setDayMainCity(guestId, date, visitedCity.city);
    }
View Full Code Here


    @Transactional(readOnly=false)
    private void setMainCity(final long guestId, final City city, final long start, final long end, final String timePeriod) {

        resetDayMainCity(guestId, timePeriod);

        VisitedCity visitedCity = new VisitedCity();
        visitedCity.guestId = guestId;
        visitedCity.date = timePeriod;
        visitedCity.locationSource = LocationFacet.Source.USER;
        visitedCity.city = city;
        visitedCity.start = start;
View Full Code Here

    @Override
    public ArbitraryTimespanMetadata getArbitraryTimespanMetadata(final long guestId, final long start, final long end) {
        final TreeSet<String> dates = getDatesBetween(start, end);
        List<VisitedCity> cities = getVisitedCitiesForDates(guestId, dates);
        VisitedCity previousInferredCity = null, nextInferredCity = null;
        if (cities.size()==0) {
            previousInferredCity = searchCityBeforeDate(guestId, dates.first());
            nextInferredCity = searchCityAfterDate(guestId, dates.last());
            if (previousInferredCity==null&&nextInferredCity==null) {
                ArbitraryTimespanMetadata info = new ArbitraryTimespanMetadata(start, end);
                return info;
            }
        }
        final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
        final List<DayMetadata> dayMetadataForDates = getDayMetadataForDates(guestId, dates);
        final TreeMap<String, TimeZone> consensusTimezoneMap = getConsensusTimezoneMap(dayMetadataForDates);
        final List<VisitedCity> consensusCities = extractConsensusCities(dayMetadataForDates);
        TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
        ArbitraryTimespanMetadata info = new ArbitraryTimespanMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, start, end);
View Full Code Here

    @Override
  public DayMetadata getDayMetadata(long guestId, String date) {
        // get visited cities for a specific date . If we don't have any data for that date,
        // retrieve cities for the first date for which we do have data
        List<VisitedCity> cities = getVisitedCitiesForDate(guestId, date);
        VisitedCity previousInferredCity = null, nextInferredCity = null;
        if (cities.size()==0) {
            previousInferredCity = searchCityBeforeDate(guestId, date);
            nextInferredCity = searchCityAfterDate(guestId, date);
            if (previousInferredCity==null&&nextInferredCity==null) {
                DayMetadata info = new DayMetadata(date);
                return info;
            }
        }
        final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
        TreeMap<String, TimeZone> consensusTimezoneMap = new TreeMap<String, TimeZone>();
        consensusTimezoneMap.put(date, TimeZone.getTimeZone(consensusVisitedCity.city.geo_timezone));
        TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
        List<VisitedCity> consensusVisitedCities = Arrays.asList(consensusVisitedCity);
        DayMetadata info = new DayMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusVisitedCities, date);
View Full Code Here

    @Override
    public WeekMetadata getWeekMetadata(final long guestId, final int year, final int week) {
        TreeSet<String> dates = getDatesForWeek(year, week);
        List<VisitedCity> cities = getVisitedCitiesForDates(guestId, dates);
        VisitedCity previousInferredCity = null, nextInferredCity = null;
        if (cities.size()==0) {
            previousInferredCity = searchCityBeforeDate(guestId, dates.first());
            nextInferredCity = searchCityAfterDate(guestId, dates.last());
            if (previousInferredCity==null&&nextInferredCity==null) {
                WeekMetadata info = new WeekMetadata(year, week);
                return info;
            }
        }
        final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
        final List<DayMetadata> dayMetadataForDates = getDayMetadataForDates(guestId, dates);
        final TreeMap<String, TimeZone> consensusTimezoneMap = getConsensusTimezoneMap(dayMetadataForDates);
        final List<VisitedCity> consensusCities = extractConsensusCities(dayMetadataForDates);
        TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
        WeekMetadata info = new WeekMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, year, week);
View Full Code Here

                    return o1.date.compareTo(o2.date);
                }
            });
        for (String date : dates) {
            final DayMetadata dayMetadata = getDayMetadata(guestId, date);
            final VisitedCity consensusVisitedCity = dayMetadata.consensusVisitedCity;
            // Explicitely set the date on this visitedCity to enable time boundaries checking
            VisitedCity copy = new VisitedCity(consensusVisitedCity);
            copy.setDate(date);
            copy.start = copy.getDayStart();
            copy.end = copy.getDayEnd();
            consensusCities.add(copy);
        }
        return consensusCities;
    }
View Full Code Here

    @Override
    public MonthMetadata getMonthMetadata(final long guestId, final int year, final int month) {
        TreeSet<String> dates = getDatesForMonth(year, month);
        List<VisitedCity> cities = getVisitedCitiesForDates(guestId, dates);
        VisitedCity previousInferredCity = null, nextInferredCity = null;
        if (cities.size()==0) {
            previousInferredCity = searchCityBeforeDate(guestId, dates.first());
            nextInferredCity = searchCityAfterDate(guestId, dates.last());
            if (previousInferredCity==null && nextInferredCity==null) {
                MonthMetadata info = new MonthMetadata(year, month);
                return info;
            }
        }
        final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
        final List<DayMetadata> dayMetadataForDates = getDayMetadataForDates(guestId, dates);
        final TreeMap<String, TimeZone> consensusTimezoneMap = getConsensusTimezoneMap(dayMetadataForDates);
        final List<VisitedCity> consensusCities = extractConsensusCities(dayMetadataForDates);
        TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
        MonthMetadata info = new MonthMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, year, month);
View Full Code Here

            return cityList.get(0);
        return null;
    }

    private String findClosestKnownDateForTime(final long guestId, final long time) {
        VisitedCity existingCity = searchCityBefore(guestId, time);
        if (existingCity==null)
            existingCity = searchCityAfter(guestId, time);
        if (existingCity!=null) {
            return existingCity.date;
        }
View Full Code Here

            return cities.get(0);
        return null;
    }

    private VisitedCity searchCityBeforeDate(final long guestId, final String date) {
        VisitedCity visitedCity = searchCity("SELECT facet FROM " + JPAUtils.getEntityName(VisitedCity.class) + " facet WHERE facet.guestId=? AND facet.date<? ORDER BY facet.start DESC", guestId, date);
        if (visitedCity!=null) {
            final List<VisitedCity> visitedCitiesForDate = getVisitedCitiesForDate(guestId, visitedCity.date);
            visitedCity = getConsensusVisitedCity(visitedCitiesForDate, null, null);
            visitedCity.daysInferred = daysBetween(date, visitedCity);
        }
View Full Code Here

        }
        return visitedCity;
    }

    private VisitedCity searchCityAfterDate(final long guestId, final String date) {
        VisitedCity visitedCity = searchCity("SELECT facet FROM " + JPAUtils.getEntityName(VisitedCity.class) + " facet WHERE facet.guestId=? AND facet.date>? ORDER BY facet.start", guestId, date);
        if (visitedCity!=null) {
            final List<VisitedCity> visitedCitiesForDate = getVisitedCitiesForDate(guestId, visitedCity.date);
            visitedCity = getConsensusVisitedCity(visitedCitiesForDate, null, null);
            visitedCity.daysInferred = daysBetween(date, visitedCity);
        }
View Full Code Here

TOP

Related Classes of org.fluxtream.core.domain.metadata.VisitedCity

Copyright © 2018 www.massapicom. 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.