Package name.pehl.karaka.server.activity.entity

Examples of name.pehl.karaka.server.activity.entity.Activity


            mdt.hourOfDay().set(9);
            int activitiesCount = 1 + random.nextInt(ACTIVITIES_PER_DAY);
            int hours = 2 + random.nextInt(6) / activitiesCount;
            for (int j = 0; j < activitiesCount; j++)
            {
                Activity activity = new Activity(loremIpsum.randomWords(2), loremIpsum.randomWords(4), timeZone);
                activity.setStart(new Time(mdt));
                int hour = mdt.hourOfDay().get() + hours;
                activity.setEnd(new Time(mdt.copy().hourOfDay().set(hour)));
                activity.setProject(Ref.create(projects.get(random.nextInt(projects.size()))));
                for (int i = 0; i < TAGS_PER_ACTIVITY; i++)
                {
                    Tag tag = tagKeys.get(random.nextInt(tagKeys.size()));
                    activity.addTag(Key.create(tag));
                }
                activities.add(activity);
                mdt.hourOfDay().add(hours);
            }
            mdt.addDays(1);
View Full Code Here


        Map<SameActivity, name.pehl.karaka.shared.model.Activity> activities = new HashMap<SameActivity, name.pehl.karaka.shared.model.Activity>();
        Results<ScoredDocument> results = indexSearch.search(query);
        for (ScoredDocument scoredDocument : results)
        {
            Long id = Long.valueOf(scoredDocument.getId());
            Activity activity = repository.get(id);
            if (activity != null)
            {
                activities.put(new SameActivity(activity), activityConverter.toModel(activity));
            }
        }
View Full Code Here

    @GET
    @Path("/running")
    public name.pehl.karaka.shared.model.Activity runningActivity()
    {
        Activity activity = repository.findRunningActivity();
        if (activity == null)
        {
            throw new NotFoundException("No running activity");
        }
        return activityConverter.toModel(activity);
View Full Code Here

    @GET
    @Path("/latest")
    public name.pehl.karaka.shared.model.Activity latestActivity()
    {
        Activity activity = repository.findLatestActivity();
        if (activity == null)
        {
            throw new NotFoundException("No latest activity");
        }
        return activityConverter.toModel(activity);
View Full Code Here

    // ------------------------------------------------------------ CUD methods

    @POST
    public Response createNewActivity(name.pehl.karaka.shared.model.Activity clientActivity)
    {
        Activity serverActivity = activityConverter.fromModel(clientActivity);
        Activity savedActivity = repository.save(serverActivity);
        name.pehl.karaka.shared.model.Activity newClientActivity = activityConverter.toModel(savedActivity);
        return Response.status(CREATED).entity(newClientActivity).build();
    }
View Full Code Here

    public Response updateActivity(@PathParam("id") String id,
            name.pehl.karaka.shared.model.Activity clientActivity)
    {
        try
        {
            Activity serverActivity = repository.get(id);
            activityConverter.merge(clientActivity, serverActivity);
            Activity savedActivity = repository.save(serverActivity);
            name.pehl.karaka.shared.model.Activity updatedClientActivity = activityConverter.toModel(savedActivity);
            return Response.ok(updatedClientActivity).build();
        }
        catch (com.googlecode.objectify.NotFoundException e)
        {
View Full Code Here

    @Path("/{id}/copy/{period}")
    public Response copyActivity(@PathParam("id") String id, @PathParam("period") String period)
    {
        try
        {
            Activity activity = repository.get(id);
            Activity copy = activity.copy(period);
            Activity savedActivity = repository.save(copy);
            name.pehl.karaka.shared.model.Activity clientCopy = activityConverter.toModel(savedActivity);
            return Response.status(CREATED).entity(clientCopy).build();
        }
        catch (com.googlecode.objectify.NotFoundException e)
        {
View Full Code Here

    @PUT
    @Path("/start")
    public Response startNewActivity(name.pehl.karaka.shared.model.Activity clientActivity)
    {
        // TODO Is it an error if the client activity already exists on the server?
        Activity newServerActivity = activityConverter.fromModel(clientActivity);
        Activity savedActivity = repository.save(newServerActivity);
        Iterable<Activity> modifiedActivities = repository.start(savedActivity);
        Set<name.pehl.karaka.shared.model.Activity> clientActivities = new HashSet<name.pehl.karaka.shared.model.Activity>();
        for (Activity modifiedActivity : modifiedActivities)
        {
            clientActivities.add(activityConverter.toModel(modifiedActivity));
View Full Code Here

    @Path("/{id}/start")
    public Response startActivity(@PathParam("id") String id)
    {
        try
        {
            Activity activity = repository.get(id);
            Iterable<Activity> modifiedActivities = repository.start(activity);
            Set<name.pehl.karaka.shared.model.Activity> clientActivities = new HashSet<name.pehl.karaka.shared.model.Activity>();
            for (Activity modifiedActivity : modifiedActivities)
            {
                clientActivities.add(activityConverter.toModel(modifiedActivity));
View Full Code Here

    @Path("/{id}/tick")
    public Response tickActivity(@PathParam("id") String id)
    {
        try
        {
            Activity activity = repository.get(id);
            Iterable<Activity> modifiedActivities = repository.tick(activity);
            Set<name.pehl.karaka.shared.model.Activity> clientActivities = new HashSet<name.pehl.karaka.shared.model.Activity>();
            for (Activity modifiedActivity : modifiedActivities)
            {
                clientActivities.add(activityConverter.toModel(modifiedActivity));
View Full Code Here

TOP

Related Classes of name.pehl.karaka.server.activity.entity.Activity

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.