use of com.remswork.project.alice.resource.links.ClassResourceLinks in project classify-system by anverliedoit.
the class AssignmentResource method getAssignmentList.
@GET
public Response getAssignmentList() {
try {
List<Assignment> assignmentList;
AssignmentResourceLinks resourceLinks = new AssignmentResourceLinks(uriInfo);
ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
if (classId != 0 && termId != 0)
assignmentList = assignmentService.getAssignmentListByClassId(classId, termId);
else if (classId != 0)
assignmentList = assignmentService.getAssignmentListByClassId(classId);
else if (studentId != 0 && termId != 0)
assignmentList = assignmentService.getAssignmentListByStudentId(studentId, termId);
else if (studentId != 0)
assignmentList = assignmentService.getAssignmentListByStudentId(studentId);
else
assignmentList = assignmentService.getAssignmentList();
for (Assignment assignment : assignmentList) {
assignment.addLink(resourceLinks.self(assignment.getId()));
if (assignment.get_class() != null)
assignment.get_class().addLink(classResourceLinks.self(assignment.get_class().getId()));
}
GenericEntity<List<Assignment>> entity = new GenericEntity<List<Assignment>>(assignmentList) {
};
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 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.resource.links.ClassResourceLinks 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();
}
}
use of com.remswork.project.alice.resource.links.ClassResourceLinks in project classify-system by anverliedoit.
the class AttendanceResource method getAttendanceById.
@GET
@Path("{attendanceId}")
public Response getAttendanceById(@PathParam("attendanceId") long id) {
try {
AttendanceResourceLinks resourceLinks = new AttendanceResourceLinks(uriInfo);
ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
Attendance attendance = attendanceService.getAttendanceById(id);
attendance.addLink(resourceLinks.self(id));
if (attendance.get_class() != null)
attendance.get_class().addLink(classResourceLinks.self(attendance.get_class().getId()));
return Response.status(Response.Status.OK).entity(attendance).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 ClassResource method deleteClassById.
@DELETE
@Path("{classId}")
public Response deleteClassById(@PathParam("classId") long id) {
try {
ClassResourceLinks resourceLinks = new ClassResourceLinks(uriInfo);
TeacherResourceLinks teacherResourceLinks = new TeacherResourceLinks(uriInfo);
SubjectResourceLinks subjectResourceLinks = new SubjectResourceLinks(uriInfo);
SectionResourceLinks sectionResourceLinks = new SectionResourceLinks(uriInfo);
Class _class = classService.deleteClassById(id);
_class.addLink(resourceLinks.self(id));
_class.addLink(resourceLinks.schedule(id));
_class.addLink(resourceLinks.student(id));
if (_class.getTeacher() != null)
_class.getTeacher().addLink(teacherResourceLinks.self(_class.getTeacher().getId()));
if (_class.getSubject() != null)
_class.getSubject().addLink(subjectResourceLinks.self(_class.getSubject().getId()));
if (_class.getSection() != null)
_class.getSection().addLink(sectionResourceLinks.self(_class.getSection().getId()));
return Response.status(Response.Status.OK).entity(_class).build();
} catch (ClassException e) {
e.printStackTrace();
Message message = new Message(400, "Bad Request", e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
}
}
Aggregations