Package org.jboss.seam.rest.example.tasks.entity

Examples of org.jboss.seam.rest.example.tasks.entity.Task


    @Path("/task")
    public Response createTask(JaxbTaskWrapper incommingTask, @PathParam("category") String categoryName,
            @Context UriInfo uriInfo) {
        Category category = loadCategory(categoryName);

        Task task = new Task();
        task.setCategory(category);
        task.setCreated(new Date());
        task.setUpdated(task.getCreated()); // set update date to creation date
        task.setName(incommingTask.getName());
        task.setResolved(false); // not resolved by default
        em.persist(task);
        long id = task.getId();

        URI uri = uriInfo.getBaseUriBuilder().path(TaskCollectionResource.class)
                .path(TaskCollectionResource.class, "getTaskSubresource").build(String.valueOf(id));
        return Response.created(uri).build();
    }
View Full Code Here


    }

    @POST
    @Path("/move")
    public void move(@PathParam("taskId") long taskId, @QueryParam("category") String newCategoryName, @Context UriInfo uriInfo) {
        Task task = loadTask(taskId, uriInfo);
        Category newCategory = (Category) em.createNamedQuery("categoryByName").setParameter("category", newCategoryName)
                .getSingleResult();
        Category oldCategory = task.getCategory();

        oldCategory.getTasks().remove(task);
        newCategory.getTasks().add(task);
        task.setCategory(newCategory);
        task.setUpdated(new Date());
    }
View Full Code Here

        task.setUpdated(new Date());
    }

    @PUT
    public void updateTask(@PathParam("taskId") long taskId, @Context UriInfo uriInfo, JaxbTaskWrapper incommingTask) {
        Task task = loadTask(taskId, uriInfo);
        if (incommingTask.getName() != null) {
            task.setName(incommingTask.getName());
        }
        if (incommingTask.isResolved() != null) {
            task.setResolved(incommingTask.isResolved());
        }
        task.setUpdated(new Date());
    }
View Full Code Here

        task.setUpdated(new Date());
    }

    @DELETE
    public void deleteTask(@PathParam("taskId") long taskId, @Context UriInfo uriInfo) {
        Task task = loadTask(taskId, uriInfo);
        task.getCategory().getTasks().remove(task);
        em.remove(task);
    }
View Full Code Here

    private void addTask(Category category, String name) {
        addTask(category, name, false);
    }

    private void addTask(Category category, String name, boolean resolved) {
        Task task = new Task(name, resolved, new Date(), new Date(), category);
        category.getTasks().add(task);
    }
View Full Code Here

TOP

Related Classes of org.jboss.seam.rest.example.tasks.entity.Task

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.