use of com.remswork.project.alice.exception.GradingFactorException 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();
}
}
use of com.remswork.project.alice.exception.GradingFactorException 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();
}
}
use of com.remswork.project.alice.exception.GradingFactorException 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();
}
}
use of com.remswork.project.alice.exception.GradingFactorException in project classify-system by anverliedoit.
the class ActivityResultResource method updateActivityResult.
@PUT
public Response updateActivityResult(@PathParam("activityId") long activityId, @QueryParam("score") int score) {
try {
ActivityResultResourceLinks resultResourceLinks = new ActivityResultResourceLinks(uriInfo);
ActivityResult result = activityService.updateActivityResultByActivityAndStudentId(score, activityId, studentId);
result.addLink(resultResourceLinks.self(result.getId()));
return Response.status(Response.Status.OK).entity(result).build();
} catch (GradingFactorException e) {
e.printStackTrace();
Message message = new Message(400, "Bad Request", e.getMessage());
return Response.status(Response.Status.NOT_FOUND).entity(message).build();
}
}
use of com.remswork.project.alice.exception.GradingFactorException 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();
}
}
Aggregations