use of com.remswork.project.alice.resource.links.DepartmentResourceLinks in project classify-system by anverliedoit.
the class TeacherResource method deleteTeacherById.
@DELETE
@Path("{teacherId}")
public Response deleteTeacherById(@PathParam("teacherId") long id) {
try {
TeacherResourceLinks resourceLink = new TeacherResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
Teacher teacher = teacherService.deleteTeacherById(id);
teacher.addLink(resourceLink.self(id));
if (teacher.getDepartment() != null)
teacher.getDepartment().addLink(departmentResourceLinks.self(teacher.getDepartment().getId()));
return Response.status(Response.Status.OK).entity(teacher).build();
} catch (TeacherException 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.DepartmentResourceLinks in project classify-system by anverliedoit.
the class StudentResource method addStudent.
@POST
public Response addStudent(Student student) {
try {
StudentResourceLinks resourceLinks = new StudentResourceLinks(uriInfo);
SectionResourceLinks sectionResourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
student = studentService.addStudent(student, sectionId);
student.addLink(resourceLinks.self(student.getId()));
if (student.getSection() != null) {
Section section = student.getSection();
section.addLink(sectionResourceLinks.self(section.getId()));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
}
return Response.status(Response.Status.CREATED).entity(student).build();
} catch (StudentException 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.DepartmentResourceLinks in project classify-system by anverliedoit.
the class StudentResource method updateStudentById.
@PUT
@Path("{studentId}")
public Response updateStudentById(@PathParam("studentId") long id, Student newStudent) {
try {
StudentResourceLinks resourceLinks = new StudentResourceLinks(uriInfo);
SectionResourceLinks sectionResourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
Student student = studentService.updateStudentById(id, newStudent, sectionId);
student.addLink(resourceLinks.self(id));
if (student.getSection() != null) {
Section section = student.getSection();
section.addLink(sectionResourceLinks.self(section.getId()));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
}
return Response.status(Response.Status.OK).entity(student).build();
} catch (StudentException 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.DepartmentResourceLinks in project classify-system by anverliedoit.
the class StudentResource method getStudentById.
@GET
@Path("{studentId}")
public Response getStudentById(@PathParam("studentId") long id) {
try {
StudentResourceLinks resourceLinks = new StudentResourceLinks(uriInfo);
SectionResourceLinks sectionResourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
Student student = studentService.getStudentById(id);
student.addLink(resourceLinks.self(id));
if (student.getSection() != null) {
Section section = student.getSection();
section.addLink(sectionResourceLinks.self(section.getId()));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
}
return Response.status(Response.Status.OK).entity(student).build();
} catch (StudentException 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.DepartmentResourceLinks in project classify-system by anverliedoit.
the class StudentResource method deleteStudentById.
@DELETE
@Path("{studentId}")
public Response deleteStudentById(@PathParam("studentId") long id) {
try {
StudentResourceLinks resourceLinks = new StudentResourceLinks(uriInfo);
SectionResourceLinks sectionResourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
Student student = studentService.deleteStudentById(id);
student.addLink(resourceLinks.self(id));
if (student.getSection() != null) {
Section section = student.getSection();
section.addLink(sectionResourceLinks.self(section.getId()));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
}
return Response.status(Response.Status.OK).entity(student).build();
} catch (StudentException e) {
e.printStackTrace();
Message message = new Message(400, "Bad Request", e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
}
}
Aggregations