Search in sources :

Example 1 with Schedule

use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.

the class ClassScheduleListResource method getScheduleList.

@GET
public Response getScheduleList(@PathParam("classId") long classId) {
    try {
        ClassScheduleListResourceLinks resourceLinks = new ClassScheduleListResourceLinks(uriInfo);
        Set<Schedule> scheduleSet = classService.getScheduleList(classId);
        for (Schedule schedule : scheduleSet) schedule.addLink(resourceLinks.self(classId, schedule.getId()));
        GenericEntity<Set<Schedule>> entity = new GenericEntity<Set<Schedule>>(scheduleSet) {
        };
        return Response.status(Response.Status.OK).entity(entity).build();
    } catch (ClassException 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) ClassScheduleListResourceLinks(com.remswork.project.alice.resource.links.ClassScheduleListResourceLinks) Message(com.remswork.project.alice.model.support.Message) GenericEntity(javax.ws.rs.core.GenericEntity) Schedule(com.remswork.project.alice.model.Schedule) ClassException(com.remswork.project.alice.exception.ClassException)

Example 2 with Schedule

use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.

the class ClassScheduleListResource method getScheduleById.

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

Example 3 with Schedule

use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.

the class ClassScheduleListResource method addScheduleById.

@POST
public Response addScheduleById(@PathParam("classId") long classId) {
    try {
        ClassScheduleListResourceLinks resourceLinks = new ClassScheduleListResourceLinks(uriInfo);
        if (scheduleId == 0)
            throw new ClassDaoException("Query param : scheduleId is required");
        Schedule schedule = classService.addScheduleById(classId, scheduleId);
        schedule.addLink(resourceLinks.self(classId, scheduleId));
        return Response.status(Response.Status.OK).entity(schedule).build();
    } catch (ClassException | ClassDaoException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : ClassScheduleListResourceLinks(com.remswork.project.alice.resource.links.ClassScheduleListResourceLinks) ClassDaoException(com.remswork.project.alice.dao.exception.ClassDaoException) Message(com.remswork.project.alice.model.support.Message) Schedule(com.remswork.project.alice.model.Schedule) ClassException(com.remswork.project.alice.exception.ClassException)

Example 4 with Schedule

use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.

the class ClassScheduleListResource method deleteScheduleById.

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

Example 5 with Schedule

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

Aggregations

Schedule (com.remswork.project.alice.model.Schedule)36 ScheduleException (com.remswork.project.alice.exception.ScheduleException)22 Message (com.remswork.project.alice.model.support.Message)22 ClassException (com.remswork.project.alice.exception.ClassException)13 Client (javax.ws.rs.client.Client)10 WebTarget (javax.ws.rs.client.WebTarget)10 Response (javax.ws.rs.core.Response)10 ScheduleServiceException (com.remswork.project.alice.web.service.exception.ScheduleServiceException)6 ScheduleResourceLinks (com.remswork.project.alice.resource.links.ScheduleResourceLinks)5 ArrayList (java.util.ArrayList)5 ClientBuilder (javax.ws.rs.client.ClientBuilder)5 Builder (javax.ws.rs.client.Invocation.Builder)5 Session (org.hibernate.Session)5 ScheduleDaoException (com.remswork.project.alice.dao.exception.ScheduleDaoException)4 ClassScheduleListResourceLinks (com.remswork.project.alice.resource.links.ClassScheduleListResourceLinks)4 ClassServiceException (com.remswork.project.alice.web.service.exception.ClassServiceException)4 Set (java.util.Set)4 AsyncTask (android.os.AsyncTask)3 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3