Search in sources :

Example 1 with ScheduleResourceLinks

use of com.remswork.project.alice.resource.links.ScheduleResourceLinks in project classify-system by anverliedoit.

the class ScheduleResource method getScheduleById.

@GET
@Path("{scheduleId}")
public Response getScheduleById(@PathParam("scheduleId") long id) {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        Schedule schedule = scheduleService.getScheduleById(id);
        schedule.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(schedule).build();
    } catch (ScheduleException e) {
        e.printStackTrace();
        Message message = new Message(404, "Not Found", e.getMessage());
        return Response.status(Response.Status.NOT_FOUND).entity(message).build();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) Schedule(com.remswork.project.alice.model.Schedule) ScheduleResourceLinks(com.remswork.project.alice.resource.links.ScheduleResourceLinks) ScheduleException(com.remswork.project.alice.exception.ScheduleException)

Example 2 with ScheduleResourceLinks

use of com.remswork.project.alice.resource.links.ScheduleResourceLinks in project classify-system by anverliedoit.

the class ScheduleResource method getScheduleList.

@GET
public Response getScheduleList() {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        List<Schedule> scheduleList = scheduleService.getScheduleList();
        for (Schedule schedule : scheduleList) schedule.addLink(resourceLinks.self(schedule.getId()));
        GenericEntity<List<Schedule>> entity = new GenericEntity<List<Schedule>>(scheduleList) {
        };
        return Response.status(Response.Status.OK).entity(entity).build();
    } catch (ScheduleException e) {
        e.printStackTrace();
        Message message = new Message(404, "Not Found", e.getMessage());
        return Response.status(Response.Status.NOT_FOUND).entity(message).build();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) Schedule(com.remswork.project.alice.model.Schedule) ScheduleResourceLinks(com.remswork.project.alice.resource.links.ScheduleResourceLinks) List(java.util.List) ScheduleException(com.remswork.project.alice.exception.ScheduleException)

Example 3 with ScheduleResourceLinks

use of com.remswork.project.alice.resource.links.ScheduleResourceLinks in project classify-system by anverliedoit.

the class ScheduleResource method updateScheduleById.

@PUT
@Path("{scheduleId}")
public Response updateScheduleById(@PathParam("scheduleId") long id, Schedule newSchedule) {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        Schedule schedule = scheduleService.updateScheduleById(id, newSchedule);
        schedule.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(schedule).build();
    } catch (ScheduleException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) Schedule(com.remswork.project.alice.model.Schedule) ScheduleResourceLinks(com.remswork.project.alice.resource.links.ScheduleResourceLinks) ScheduleException(com.remswork.project.alice.exception.ScheduleException)

Example 4 with ScheduleResourceLinks

use of com.remswork.project.alice.resource.links.ScheduleResourceLinks in project classify-system by anverliedoit.

the class ScheduleResource method addSchedule.

@POST
public Response addSchedule(Schedule schedule) {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        schedule = scheduleService.addSchedule(schedule);
        schedule.addLink(resourceLinks.self(schedule.getId()));
        return Response.status(Response.Status.CREATED).entity(schedule).build();
    } catch (ScheduleException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) ScheduleResourceLinks(com.remswork.project.alice.resource.links.ScheduleResourceLinks) ScheduleException(com.remswork.project.alice.exception.ScheduleException)

Example 5 with ScheduleResourceLinks

use of com.remswork.project.alice.resource.links.ScheduleResourceLinks in project classify-system by anverliedoit.

the class ScheduleResource method deleteScheduleById.

@DELETE
@Path("{scheduleId}")
public Response deleteScheduleById(@PathParam("scheduleId") long id) {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        Schedule schedule = scheduleService.deleteScheduleById(id);
        schedule.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(schedule).build();
    } catch (ScheduleException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) Schedule(com.remswork.project.alice.model.Schedule) ScheduleResourceLinks(com.remswork.project.alice.resource.links.ScheduleResourceLinks) ScheduleException(com.remswork.project.alice.exception.ScheduleException)

Aggregations

ScheduleException (com.remswork.project.alice.exception.ScheduleException)6 Message (com.remswork.project.alice.model.support.Message)6 ScheduleResourceLinks (com.remswork.project.alice.resource.links.ScheduleResourceLinks)6 Schedule (com.remswork.project.alice.model.Schedule)5 List (java.util.List)1 Set (java.util.Set)1