Search in sources :

Example 1 with ClassResourceLinks

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

the class ActivityResource method addActivity.

@POST
public Response addActivity(Activity activity) {
    try {
        ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (termId > 0)
            activity = activityService.addActivity(activity, classId, termId);
        else
            activity = activityService.addActivity(activity, classId);
        activity.addLink(resourceLinks.self(activity.getId()));
        if (activity.get_class() != null)
            activity.get_class().addLink(classResourceLinks.self(activity.get_class().getId()));
        return Response.status(Response.Status.CREATED).entity(activity).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) ActivityResourceLinks(com.remswork.project.alice.resource.links.ActivityResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 2 with ClassResourceLinks

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

the class ActivityResource method getActivityById.

@GET
@Path("{activityId}")
public Response getActivityById(@PathParam("activityId") long id) {
    try {
        ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Activity activity = activityService.getActivityById(id);
        activity.addLink(resourceLinks.self(id));
        if (activity.get_class() != null)
            activity.get_class().addLink(classResourceLinks.self(activity.get_class().getId()));
        return Response.status(Response.Status.OK).entity(activity).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) Message(com.remswork.project.alice.model.support.Message) ActivityResourceLinks(com.remswork.project.alice.resource.links.ActivityResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Activity(com.remswork.project.alice.model.Activity)

Example 3 with ClassResourceLinks

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

the class ActivityResource method updateActivityById.

@PUT
@Path("{activityId}")
public Response updateActivityById(@PathParam("activityId") long id, Activity newActivity) {
    try {
        ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Activity activity;
        if (termId > 0)
            activity = activityService.updateActivityById(id, newActivity, classId, termId);
        else
            activity = activityService.updateActivityById(id, newActivity, classId);
        activity.addLink(resourceLinks.self(activity.getId()));
        if (activity.get_class() != null)
            activity.get_class().addLink(classResourceLinks.self(activity.get_class().getId()));
        return Response.status(Response.Status.OK).entity(activity).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) ActivityResourceLinks(com.remswork.project.alice.resource.links.ActivityResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Activity(com.remswork.project.alice.model.Activity)

Example 4 with ClassResourceLinks

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

the class AssignmentResource method addAssignment.

@POST
public Response addAssignment(Assignment assignment) {
    try {
        AssignmentResourceLinks resourceLinks = new AssignmentResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (termId > 0)
            assignment = assignmentService.addAssignment(assignment, classId, termId);
        else
            assignment = assignmentService.addAssignment(assignment, classId);
        assignment.addLink(resourceLinks.self(assignment.getId()));
        if (assignment.get_class() != null)
            assignment.get_class().addLink(classResourceLinks.self(assignment.get_class().getId()));
        return Response.status(Response.Status.CREATED).entity(assignment).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) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) AssignmentResourceLinks(com.remswork.project.alice.resource.links.AssignmentResourceLinks)

Example 5 with ClassResourceLinks

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

the class AssignmentResource method getAssignmentById.

@GET
@Path("{assignmentId}")
public Response getAssignmentById(@PathParam("assignmentId") long id) {
    try {
        AssignmentResourceLinks resourceLinks = new AssignmentResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Assignment assignment = assignmentService.getAssignmentById(id);
        assignment.addLink(resourceLinks.self(id));
        if (assignment.get_class() != null)
            assignment.get_class().addLink(classResourceLinks.self(assignment.get_class().getId()));
        return Response.status(Response.Status.OK).entity(assignment).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 : Assignment(com.remswork.project.alice.model.Assignment) ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) AssignmentResourceLinks(com.remswork.project.alice.resource.links.AssignmentResourceLinks)

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