Search in sources :

Example 11 with Assignment

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

the class AssignmentResource method deleteAssignmentById.

@DELETE
@Path("{assignmentId}")
public Response deleteAssignmentById(@PathParam("assignmentId") long id) {
    try {
        AssignmentResourceLinks resourceLinks = new AssignmentResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Assignment assignment = assignmentService.deleteAssignmentById(id);
        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.OK).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 : 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)

Example 12 with Assignment

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

the class AssignmentResource method updateAssignmentById.

@PUT
@Path("{assignmentId}")
public Response updateAssignmentById(@PathParam("assignmentId") long id, Assignment newAssignment) {
    try {
        AssignmentResourceLinks resourceLinks = new AssignmentResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Assignment assignment;
        if (termId > 0)
            assignment = assignmentService.updateAssignmentById(id, newAssignment, classId, termId);
        else
            assignment = assignmentService.updateAssignmentById(id, newAssignment, 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.OK).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 : 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

Assignment (com.remswork.project.alice.model.Assignment)12 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)10 Message (com.remswork.project.alice.model.support.Message)7 ArrayList (java.util.ArrayList)5 AssignmentResourceLinks (com.remswork.project.alice.resource.links.AssignmentResourceLinks)4 ClassResourceLinks (com.remswork.project.alice.resource.links.ClassResourceLinks)4 AsyncTask (android.os.AsyncTask)3 Gson (com.google.gson.Gson)3 Student (com.remswork.project.alice.model.Student)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 HttpURLConnection (java.net.HttpURLConnection)3 URL (java.net.URL)3 List (java.util.List)3 ExecutionException (java.util.concurrent.ExecutionException)3 JSONArray (org.json.JSONArray)3 JSONException (org.json.JSONException)3 CardView (android.support.v7.widget.CardView)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2