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();
}
}
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();
}
}
Aggregations