Search in sources :

Example 26 with ScheduleException

use of com.remswork.project.alice.exception.ScheduleException 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 27 with ScheduleException

use of com.remswork.project.alice.exception.ScheduleException 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)

Example 28 with ScheduleException

use of com.remswork.project.alice.exception.ScheduleException in project classify-system by anverliedoit.

the class ScheduleResource method getScheduleListByTeacherId.

@GET
@Path("1")
public Response getScheduleListByTeacherId(@QueryParam("teacherId") long teacherId) {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        Set<Schedule> scheduleSet = scheduleService.getScheduleListByTeacherId(teacherId);
        for (Schedule schedule : scheduleSet) schedule.addLink(resourceLinks.self(schedule.getId()));
        GenericEntity<Set<Schedule>> entity = new GenericEntity<Set<Schedule>>(scheduleSet) {
        };
        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 : Set(java.util.Set) 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)28 Schedule (com.remswork.project.alice.model.Schedule)22 Message (com.remswork.project.alice.model.support.Message)18 AsyncTask (android.os.AsyncTask)6 Gson (com.google.gson.Gson)6 ScheduleResourceLinks (com.remswork.project.alice.resource.links.ScheduleResourceLinks)6 ScheduleServiceException (com.remswork.project.alice.web.service.exception.ScheduleServiceException)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 HttpURLConnection (java.net.HttpURLConnection)6 URL (java.net.URL)6 ExecutionException (java.util.concurrent.ExecutionException)6 Client (javax.ws.rs.client.Client)6 WebTarget (javax.ws.rs.client.WebTarget)6 Response (javax.ws.rs.core.Response)6 Session (org.hibernate.Session)6 ScheduleDaoException (com.remswork.project.alice.dao.exception.ScheduleDaoException)5 ArrayList (java.util.ArrayList)3 ClientBuilder (javax.ws.rs.client.ClientBuilder)3 Builder (javax.ws.rs.client.Invocation.Builder)3