Search in sources :

Example 1 with RecitationResourceLinks

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

the class RecitationResource method updateRecitationById.

@PUT
@Path("{recitationId}")
public Response updateRecitationById(@PathParam("recitationId") long id, Recitation newRecitation) {
    try {
        RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Recitation recitation;
        if (termId > 0)
            recitation = recitationService.updateRecitationById(id, newRecitation, classId, termId);
        else
            recitation = recitationService.updateRecitationById(id, newRecitation, classId);
        recitation.addLink(resourceLinks.self(recitation.getId()));
        if (recitation.get_class() != null)
            recitation.get_class().addLink(classResourceLinks.self(recitation.get_class().getId()));
        return Response.status(Response.Status.OK).entity(recitation).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Recitation(com.remswork.project.alice.model.Recitation) Message(com.remswork.project.alice.model.support.Message) RecitationResourceLinks(com.remswork.project.alice.resource.links.RecitationResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 2 with RecitationResourceLinks

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

the class RecitationResource method addRecitation.

@POST
public Response addRecitation(Recitation recitation) {
    try {
        RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (termId > 0)
            recitation = recitationService.addRecitation(recitation, classId, termId);
        else
            recitation = recitationService.addRecitation(recitation, classId);
        recitation.addLink(resourceLinks.self(recitation.getId()));
        if (recitation.get_class() != null)
            recitation.get_class().addLink(classResourceLinks.self(recitation.get_class().getId()));
        return Response.status(Response.Status.CREATED).entity(recitation).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Message(com.remswork.project.alice.model.support.Message) RecitationResourceLinks(com.remswork.project.alice.resource.links.RecitationResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 3 with RecitationResourceLinks

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

the class RecitationResource method deleteRecitationById.

@DELETE
@Path("{recitationId}")
public Response deleteRecitationById(@PathParam("recitationId") long id) {
    try {
        RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Recitation recitation = recitationService.deleteRecitationById(id);
        recitation.addLink(resourceLinks.self(recitation.getId()));
        if (recitation.get_class() != null)
            recitation.get_class().addLink(classResourceLinks.self(recitation.get_class().getId()));
        return Response.status(Response.Status.OK).entity(recitation).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Recitation(com.remswork.project.alice.model.Recitation) Message(com.remswork.project.alice.model.support.Message) RecitationResourceLinks(com.remswork.project.alice.resource.links.RecitationResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 4 with RecitationResourceLinks

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

the class RecitationResource method getRecitationList.

@GET
public Response getRecitationList() {
    try {
        List<Recitation> recitationList;
        RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (classId != 0 && termId != 0)
            recitationList = recitationService.getRecitationListByClassId(classId, termId);
        else if (classId != 0)
            recitationList = recitationService.getRecitationListByClassId(classId);
        else if (studentId != 0 && termId != 0)
            recitationList = recitationService.getRecitationListByStudentId(studentId, termId);
        else if (studentId != 0)
            recitationList = recitationService.getRecitationListByStudentId(studentId);
        else
            recitationList = recitationService.getRecitationList();
        for (Recitation recitation : recitationList) {
            recitation.addLink(resourceLinks.self(recitation.getId()));
            if (recitation.get_class() != null)
                recitation.get_class().addLink(classResourceLinks.self(recitation.get_class().getId()));
        }
        GenericEntity<List<Recitation>> entity = new GenericEntity<List<Recitation>>(recitationList) {
        };
        return Response.status(Response.Status.OK).entity(entity).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(404, "Not Found", e.getMessage());
        return Response.status(Response.Status.NOT_FOUND).entity(message).build();
    }
}
Also used : Recitation(com.remswork.project.alice.model.Recitation) ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Message(com.remswork.project.alice.model.support.Message) RecitationResourceLinks(com.remswork.project.alice.resource.links.RecitationResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) List(java.util.List)

Example 5 with RecitationResourceLinks

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

the class RecitationResource method getRecitationById.

@GET
@Path("{recitationId}")
public Response getRecitationById(@PathParam("recitationId") long id) {
    try {
        RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Recitation recitation = recitationService.getRecitationById(id);
        recitation.addLink(resourceLinks.self(id));
        if (recitation.get_class() != null)
            recitation.get_class().addLink(classResourceLinks.self(recitation.get_class().getId()));
        return Response.status(Response.Status.OK).entity(recitation).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(404, "Not Found", e.getMessage());
        return Response.status(Response.Status.NOT_FOUND).entity(message).build();
    }
}
Also used : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Recitation(com.remswork.project.alice.model.Recitation) Message(com.remswork.project.alice.model.support.Message) RecitationResourceLinks(com.remswork.project.alice.resource.links.RecitationResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Aggregations

GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)5 Message (com.remswork.project.alice.model.support.Message)5 ClassResourceLinks (com.remswork.project.alice.resource.links.ClassResourceLinks)5 RecitationResourceLinks (com.remswork.project.alice.resource.links.RecitationResourceLinks)5 Recitation (com.remswork.project.alice.model.Recitation)4 List (java.util.List)1