use of com.remswork.project.alice.resource.links.ClassResourceLinks in project classify-system by anverliedoit.
the class QuizResource method updateQuizById.
@PUT
@Path("{quizId}")
public Response updateQuizById(@PathParam("quizId") long id, Quiz newQuiz) {
try {
QuizResourceLinks resourceLinks = new QuizResourceLinks(uriInfo);
ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
Quiz quiz;
if (termId > 0)
quiz = quizService.updateQuizById(id, newQuiz, classId, termId);
else
quiz = quizService.updateQuizById(id, newQuiz, classId);
quiz.addLink(resourceLinks.self(quiz.getId()));
if (quiz.get_class() != null)
quiz.get_class().addLink(classResourceLinks.self(quiz.get_class().getId()));
return Response.status(Response.Status.OK).entity(quiz).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.resource.links.ClassResourceLinks in project classify-system by anverliedoit.
the class RecitationResource method updateRecitationById.
@PUT
@Path("{recitationId}")
public Response updateRecitationById(@PathParam("recitationId") long id, Recitation newRecitation) {
try {
RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
Recitation recitation;
if (termId > 0)
recitation = recitationService.updateRecitationById(id, newRecitation, classId, termId);
else
recitation = recitationService.updateRecitationById(id, newRecitation, classId);
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();
}
}
use of com.remswork.project.alice.resource.links.ClassResourceLinks in project classify-system by anverliedoit.
the class RecitationResource method addRecitation.
@POST
public Response addRecitation(Recitation recitation) {
try {
RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
if (termId > 0)
recitation = recitationService.addRecitation(recitation, classId, termId);
else
recitation = recitationService.addRecitation(recitation, classId);
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.CREATED).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();
}
}
use of com.remswork.project.alice.resource.links.ClassResourceLinks in project classify-system by anverliedoit.
the class ActivityResource method getActivityList.
@GET
public Response getActivityList() {
try {
List<Activity> activityList;
ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
if (classId != 0 && termId != 0)
activityList = activityService.getActivityListByClassId(classId, termId);
else if (classId != 0)
activityList = activityService.getActivityListByClassId(classId);
else if (studentId != 0 && termId != 0)
activityList = activityService.getActivityListByStudentId(studentId, termId);
else if (studentId != 0)
activityList = activityService.getActivityListByStudentId(studentId);
else
activityList = activityService.getActivityList();
for (Activity activity : activityList) {
activity.addLink(resourceLinks.self(activity.getId()));
if (activity.get_class() != null)
activity.get_class().addLink(classResourceLinks.self(activity.get_class().getId()));
}
GenericEntity<List<Activity>> entity = new GenericEntity<List<Activity>>(activityList) {
};
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();
}
}
use of com.remswork.project.alice.resource.links.ClassResourceLinks in project classify-system by anverliedoit.
the class ActivityResource method deleteActivityById.
@DELETE
@Path("{activityId}")
public Response deleteActivityById(@PathParam("activityId") long id) {
try {
ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
Activity activity = activityService.deleteActivityById(id);
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();
}
}
Aggregations