use of com.remswork.project.alice.model.Section in project classify-system by anverliedoit.
the class SectionResource method getSectionById.
@GET
@Path("{sectionId}")
public Response getSectionById(@PathParam("sectionId") long id) {
try {
SectionResourceLinks resourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
Section section = sectionService.getSectionById(id);
section.addLink(resourceLinks.self(id));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
return Response.status(Response.Status.OK).entity(section).build();
} catch (SectionException 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.model.Section in project classify-system by anverliedoit.
the class SectionResource method deleteSectionById.
@DELETE
@Path("{sectionId}")
public Response deleteSectionById(@PathParam("sectionId") long id) {
try {
SectionResourceLinks resourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
Section section = sectionService.deleteSectionById(id);
section.addLink(resourceLinks.self(id));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
return Response.status(Response.Status.OK).entity(section).build();
} catch (SectionException 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.Section in project classify-system by anverliedoit.
the class SectionResource method updateSectionById.
@PUT
@Path("{sectionId}")
public Response updateSectionById(@PathParam("sectionId") long id, Section newSection) {
try {
SectionResourceLinks resourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
Section section = sectionService.updateSectionById(id, newSection, departmentId);
section.addLink(resourceLinks.self(id));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
return Response.status(Response.Status.OK).entity(section).build();
} catch (SectionException 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.Section in project classify-system by anverliedoit.
the class SectionResource method getSectionList.
@GET
public Response getSectionList() {
try {
SectionResourceLinks resourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
List<Section> sectionList = sectionService.getSectionList();
for (Section section : sectionList) {
section.addLink(resourceLinks.self(section.getId()));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
}
GenericEntity<List<Section>> entity = new GenericEntity<List<Section>>(sectionList) {
};
return Response.status(Response.Status.OK).entity(entity).build();
} catch (SectionException 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.model.Section in project classify-system by anverliedoit.
the class StudentResource method getStudentList.
@GET
public Response getStudentList() {
try {
StudentResourceLinks resourceLinks = new StudentResourceLinks(uriInfo);
SectionResourceLinks sectionResourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
List<Student> studentList = studentService.getStudentList();
if (sn == null) {
for (Student student : studentList) {
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()));
}
}
GenericEntity<List<Student>> entity = new GenericEntity<List<Student>>(studentList) {
};
return Response.status(Response.Status.OK).entity(entity).build();
} else {
Student student = studentService.getStudentBySN(sn);
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();
}
}
Aggregations