Search in sources :

Example 36 with ClassResourceLinks

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

the class ProjectResource method getProjectList.

@GET
public Response getProjectList() {
    try {
        List<Project> projectList;
        ProjectResourceLinks resourceLinks = new ProjectResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (classId != 0 && termId != 0)
            projectList = projectService.getProjectListByClassId(classId, termId);
        else if (classId != 0)
            projectList = projectService.getProjectListByClassId(classId);
        else if (studentId != 0 && termId != 0)
            projectList = projectService.getProjectListByStudentId(studentId, termId);
        else if (studentId != 0)
            projectList = projectService.getProjectListByStudentId(studentId);
        else
            projectList = projectService.getProjectList();
        for (Project project : projectList) {
            project.addLink(resourceLinks.self(project.getId()));
            if (project.get_class() != null)
                project.get_class().addLink(classResourceLinks.self(project.get_class().getId()));
        }
        GenericEntity<List<Project>> entity = new GenericEntity<List<Project>>(projectList) {
        };
        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 : Project(com.remswork.project.alice.model.Project) ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) ProjectResourceLinks(com.remswork.project.alice.resource.links.ProjectResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) List(java.util.List)

Example 37 with ClassResourceLinks

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

the class QuizResource method getQuizList.

@GET
public Response getQuizList() {
    try {
        List<Quiz> quizList;
        QuizResourceLinks resourceLinks = new QuizResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (classId != 0 && termId != 0)
            quizList = quizService.getQuizListByClassId(classId, termId);
        else if (classId != 0)
            quizList = quizService.getQuizListByClassId(classId);
        else if (studentId != 0 && termId != 0)
            quizList = quizService.getQuizListByStudentId(studentId, termId);
        else if (studentId != 0)
            quizList = quizService.getQuizListByStudentId(studentId);
        else
            quizList = quizService.getQuizList();
        for (Quiz quiz : quizList) {
            quiz.addLink(resourceLinks.self(quiz.getId()));
            if (quiz.get_class() != null)
                quiz.get_class().addLink(classResourceLinks.self(quiz.get_class().getId()));
        }
        GenericEntity<List<Quiz>> entity = new GenericEntity<List<Quiz>>(quizList) {
        };
        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 : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Quiz(com.remswork.project.alice.model.Quiz) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) QuizResourceLinks(com.remswork.project.alice.resource.links.QuizResourceLinks) List(java.util.List)

Example 38 with ClassResourceLinks

use of com.remswork.project.alice.resource.links.ClassResourceLinks 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 39 with ClassResourceLinks

use of com.remswork.project.alice.resource.links.ClassResourceLinks 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 40 with ClassResourceLinks

use of com.remswork.project.alice.resource.links.ClassResourceLinks 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

Message (com.remswork.project.alice.model.support.Message)40 ClassResourceLinks (com.remswork.project.alice.resource.links.ClassResourceLinks)40 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)35 List (java.util.List)8 ClassException (com.remswork.project.alice.exception.ClassException)5 ActivityResourceLinks (com.remswork.project.alice.resource.links.ActivityResourceLinks)5 AssignmentResourceLinks (com.remswork.project.alice.resource.links.AssignmentResourceLinks)5 AttendanceResourceLinks (com.remswork.project.alice.resource.links.AttendanceResourceLinks)5 ExamResourceLinks (com.remswork.project.alice.resource.links.ExamResourceLinks)5 ProjectResourceLinks (com.remswork.project.alice.resource.links.ProjectResourceLinks)5 QuizResourceLinks (com.remswork.project.alice.resource.links.QuizResourceLinks)5 RecitationResourceLinks (com.remswork.project.alice.resource.links.RecitationResourceLinks)5 SectionResourceLinks (com.remswork.project.alice.resource.links.SectionResourceLinks)5 SubjectResourceLinks (com.remswork.project.alice.resource.links.SubjectResourceLinks)5 TeacherResourceLinks (com.remswork.project.alice.resource.links.TeacherResourceLinks)5 Activity (com.remswork.project.alice.model.Activity)4 Assignment (com.remswork.project.alice.model.Assignment)4 Attendance (com.remswork.project.alice.model.Attendance)4 Class (com.remswork.project.alice.model.Class)4 Exam (com.remswork.project.alice.model.Exam)4