Package name.pehl.karaka.shared.model

Examples of name.pehl.karaka.shared.model.Activities


{
    @Inject ActivityConverter activityConverter;

    public Activities toModel(DateMidnight date, TimeUnit timeunit, List<Activity> activities)
    {
        Activities result = new Activities(date.getYear(), date.getMonthOfYear(), date.getWeekOfWeekyear(),
                date.getDayOfMonth(), timeunit);
        switch (timeunit)
        {
            case MONTH:
                result.getWeeks().addAll(groupByWeeks(date, activities));
                break;
            case WEEK:
                result.getDays().addAll(groupByDays(date, activities));
                break;
            case DAY:
                for (Activity activity : activities)
                {
                    result.add(activityConverter.toModel(activity));
                }
                break;
            default:
                break;
        }
View Full Code Here


    @GET
    @Path("/{year:\\d{4}}/{month:\\d{1,2}}")
    public Response activitiesForYearMonth(@PathParam("year") int year, @PathParam("month") int month)
    {
        DateMidnight yearMonth = new DateMidnight(year, month, 1, settings.get().getTimeZone());
        Activities activities = activitiesConverter.toModel(yearMonth, MONTH,
                repository.findByYearMonth(yearMonth.year().get(), yearMonth.monthOfYear().get()));
        return addLinksForYearMonth(activities, yearMonth);
    }
View Full Code Here

    @GET
    @Path("/relative/{month:[+-]?\\d+}")
    public Response activitiesForRelativeMonth(@PathParam("month") int month)
    {
        DateMidnight absolute = absoluteMonth(month);
        Activities activities = activitiesConverter.toModel(absolute, MONTH,
                repository.findByYearMonth(absolute.year().get(), absolute.monthOfYear().get()));
        return addLinksForYearMonth(activities, absolute);
    }
View Full Code Here

    @GET
    @Path("/currentMonth")
    public Response activitiesForCurrentMonth()
    {
        DateMidnight now = now(settings.get().getTimeZone());
        Activities activities = activitiesConverter.toModel(now, MONTH,
                repository.findByYearMonth(now.year().get(), now.monthOfYear().get()));
        return addLinksForYearMonth(activities, now);
    }
View Full Code Here

    public Response activitiesForYearWeek(@PathParam("year") int year, @PathParam("week") int week)
    {
        DateMidnight yearWeek = new MutableDateTime(settings.get().getTimeZone()).year().set(year).weekOfWeekyear()
                .set(week)
                .toDateTime().toDateMidnight();
        Activities activities = activitiesConverter.toModel(yearWeek, WEEK,
                repository.findByYearWeek(yearWeek.year().get(), yearWeek.weekOfWeekyear().get()));
        return addLinksForYearWeek(activities, yearWeek);
    }
View Full Code Here

    @GET
    @Path("/relative/cw{week:[+-]?\\d+}")
    public Response activitiesForRelativeWeek(@PathParam("week") int week)
    {
        DateMidnight absolute = absoluteWeek(week);
        Activities activities = activitiesConverter.toModel(absolute, WEEK,
                repository.findByYearWeek(absolute.year().get(), absolute.weekOfWeekyear().get()));
        return addLinksForYearWeek(activities, absolute);
    }
View Full Code Here

    @GET
    @Path("/currentWeek")
    public Response activitiesForCurrentWeek()
    {
        DateMidnight now = now(settings.get().getTimeZone());
        Activities activities = activitiesConverter.toModel(now, WEEK,
                repository.findByYearWeek(now.year().get(), now.weekOfWeekyear().get()));
        return addLinksForYearWeek(activities, now);
    }
View Full Code Here

    @Path("/{year:\\d{4}}/{month:\\d{1,2}}/{day:\\d{1,2}}")
    public Response activitiesForYearMonthDay(@PathParam("year") int year, @PathParam("month") int month,
            @PathParam("day") int day)
    {
        DateMidnight yearMonthDay = new DateMidnight(year, month, day, settings.get().getTimeZone());
        Activities activities = activitiesConverter.toModel(yearMonthDay, DAY,
                repository.findByYearMonthDay(yearMonthDay.year().get(), yearMonthDay.monthOfYear().get(), yearMonthDay
                        .dayOfMonth().get()));
        return addLinksForYearMonthDay(activities, yearMonthDay);
    }
View Full Code Here

    @GET
    @Path("/today")
    public Response activitiesForToday()
    {
        DateMidnight now = now(settings.get().getTimeZone());
        Activities activities = activitiesConverter.toModel(now, DAY,
                repository.findByYearMonthDay(now.year().get(), now.monthOfYear().get(), now
                        .dayOfMonth().get()));
        return addLinksForYearMonthDay(activities, now);
    }
View Full Code Here

        }
        List<Activity> range = repository.findByRange(start, end);
        if (!range.isEmpty())
        {
            // TODO Custom TimeUnit 'RANGE'?
            Activities activities = activitiesConverter.toModel(start.toDateMidnight(), DAY, range);
            return Response.ok(activities).build();
        }
        return Response.status(NOT_FOUND).entity(String.format("No activities found in range [%s,%s]", from, to)).build();
    }
View Full Code Here

TOP

Related Classes of name.pehl.karaka.shared.model.Activities

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.