Search in sources :

Example 26 with Message

use of com.remswork.project.alice.model.support.Message in project classify-system by anverliedoit.

the class ClassStudentListResource method deleteStudentById.

@DELETE
@Path("{studentId}")
public Response deleteStudentById(@PathParam("classId") long classId, @PathParam("studentId") long id) {
    try {
        ClassStudentListResourceLinks resourceLinks = new ClassStudentListResourceLinks(uriInfo);
        Student student = classService.deleteStudentById(classId, id);
        student.addLink(resourceLinks.self(classId, id));
        return Response.status(Response.Status.OK).entity(student).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();
    }
}
Also used : ClassStudentListResourceLinks(com.remswork.project.alice.resource.links.ClassStudentListResourceLinks) Message(com.remswork.project.alice.model.support.Message) ClassException(com.remswork.project.alice.exception.ClassException) Student(com.remswork.project.alice.model.Student)

Example 27 with Message

use of com.remswork.project.alice.model.support.Message 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 28 with Message

use of com.remswork.project.alice.model.support.Message 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 29 with Message

use of com.remswork.project.alice.model.support.Message 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 30 with Message

use of com.remswork.project.alice.model.support.Message in project classify-system by anverliedoit.

the class ExamResource method deleteExamById.

@DELETE
@Path("{examId}")
public Response deleteExamById(@PathParam("examId") long id) {
    try {
        ExamResourceLinks resourceLinks = new ExamResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Exam exam = examService.deleteExamById(id);
        exam.addLink(resourceLinks.self(exam.getId()));
        if (exam.get_class() != null)
            exam.get_class().addLink(classResourceLinks.self(exam.get_class().getId()));
        return Response.status(Response.Status.OK).entity(exam).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();
    }
}
Also used : ExamResourceLinks(com.remswork.project.alice.resource.links.ExamResourceLinks) ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Exam(com.remswork.project.alice.model.Exam)

Aggregations

Message (com.remswork.project.alice.model.support.Message)336 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)178 Gson (com.google.gson.Gson)155 IOException (java.io.IOException)155 InputStream (java.io.InputStream)155 HttpURLConnection (java.net.HttpURLConnection)155 URL (java.net.URL)155 ExecutionException (java.util.concurrent.ExecutionException)155 AsyncTask (android.os.AsyncTask)153 Client (javax.ws.rs.client.Client)58 WebTarget (javax.ws.rs.client.WebTarget)58 Response (javax.ws.rs.core.Response)58 JSONArray (org.json.JSONArray)49 JSONException (org.json.JSONException)49 ClassException (com.remswork.project.alice.exception.ClassException)46 ArrayList (java.util.ArrayList)46 ClassResourceLinks (com.remswork.project.alice.resource.links.ClassResourceLinks)40 OutputStreamWriter (java.io.OutputStreamWriter)36 BufferedWriter (java.io.BufferedWriter)34 OutputStream (java.io.OutputStream)34