Search in sources :

Example 1 with DepartmentResourceLinks

use of com.remswork.project.alice.resource.links.DepartmentResourceLinks in project classify-system by anverliedoit.

the class DepartmentResource method deleteDepartmentById.

@DELETE
@Path("{departmentId}")
public Response deleteDepartmentById(@PathParam("departmentId") long id) {
    try {
        DepartmentResourceLinks resourceLinks = new DepartmentResourceLinks(uriInfo);
        Department department = departmentService.deleteDepartmentById(id);
        department.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(department).build();
    } catch (DepartmentException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : Department(com.remswork.project.alice.model.Department) DepartmentException(com.remswork.project.alice.exception.DepartmentException) Message(com.remswork.project.alice.model.support.Message) DepartmentResourceLinks(com.remswork.project.alice.resource.links.DepartmentResourceLinks)

Example 2 with DepartmentResourceLinks

use of com.remswork.project.alice.resource.links.DepartmentResourceLinks in project classify-system by anverliedoit.

the class DepartmentResource method getDepartmentById.

@GET
@Path("{departmentId}")
public Response getDepartmentById(@PathParam("departmentId") long id) {
    try {
        DepartmentResourceLinks resourceLinks = new DepartmentResourceLinks(uriInfo);
        Department department = departmentService.getDepartmentById(id);
        department.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(department).build();
    } catch (DepartmentException e) {
        e.printStackTrace();
        Message message = new Message(404, "Not Found", e.getMessage());
        return Response.status(Response.Status.NOT_FOUND).entity(message).build();
    }
}
Also used : Department(com.remswork.project.alice.model.Department) DepartmentException(com.remswork.project.alice.exception.DepartmentException) Message(com.remswork.project.alice.model.support.Message) DepartmentResourceLinks(com.remswork.project.alice.resource.links.DepartmentResourceLinks)

Example 3 with DepartmentResourceLinks

use of com.remswork.project.alice.resource.links.DepartmentResourceLinks in project classify-system by anverliedoit.

the class DepartmentResource method updateDepartmentById.

@PUT
@Path("{departmentId}")
public Response updateDepartmentById(@PathParam("departmentId") long id, Department newDepartment) {
    try {
        DepartmentResourceLinks resourceLinks = new DepartmentResourceLinks(uriInfo);
        Department department = departmentService.updateDepartmentById(id, newDepartment);
        department.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(department).build();
    } catch (DepartmentException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : Department(com.remswork.project.alice.model.Department) DepartmentException(com.remswork.project.alice.exception.DepartmentException) Message(com.remswork.project.alice.model.support.Message) DepartmentResourceLinks(com.remswork.project.alice.resource.links.DepartmentResourceLinks)

Example 4 with DepartmentResourceLinks

use of com.remswork.project.alice.resource.links.DepartmentResourceLinks 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();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) DepartmentResourceLinks(com.remswork.project.alice.resource.links.DepartmentResourceLinks) SectionException(com.remswork.project.alice.exception.SectionException) Section(com.remswork.project.alice.model.Section) SectionResourceLinks(com.remswork.project.alice.resource.links.SectionResourceLinks)

Example 5 with DepartmentResourceLinks

use of com.remswork.project.alice.resource.links.DepartmentResourceLinks 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();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) DepartmentResourceLinks(com.remswork.project.alice.resource.links.DepartmentResourceLinks) SectionException(com.remswork.project.alice.exception.SectionException) Section(com.remswork.project.alice.model.Section) SectionResourceLinks(com.remswork.project.alice.resource.links.SectionResourceLinks)

Aggregations

Message (com.remswork.project.alice.model.support.Message)20 DepartmentResourceLinks (com.remswork.project.alice.resource.links.DepartmentResourceLinks)20 SectionResourceLinks (com.remswork.project.alice.resource.links.SectionResourceLinks)10 Section (com.remswork.project.alice.model.Section)9 DepartmentException (com.remswork.project.alice.exception.DepartmentException)5 SectionException (com.remswork.project.alice.exception.SectionException)5 StudentException (com.remswork.project.alice.exception.StudentException)5 TeacherException (com.remswork.project.alice.exception.TeacherException)5 StudentResourceLinks (com.remswork.project.alice.resource.links.StudentResourceLinks)5 TeacherResourceLinks (com.remswork.project.alice.resource.links.TeacherResourceLinks)5 Department (com.remswork.project.alice.model.Department)4 Student (com.remswork.project.alice.model.Student)4 Teacher (com.remswork.project.alice.model.Teacher)4 List (java.util.List)4