Search in sources :

Example 51 with Message

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

the class RecitationResultResource method addRecitationResult.

@POST
public Response addRecitationResult(@QueryParam("score") int score, @PathParam("recitationId") long recitationId) {
    try {
        RecitationResultResourceLinks resultResourceLinks = new RecitationResultResourceLinks(uriInfo);
        RecitationResult result = recitationService.addRecitationResult(score, recitationId, studentId);
        result.addLink(resultResourceLinks.self(result.getId()));
        return Response.status(Response.Status.OK).entity(result).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();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) RecitationResultResourceLinks(com.remswork.project.alice.resource.links.RecitationResultResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) RecitationResult(com.remswork.project.alice.model.RecitationResult)

Example 52 with Message

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

the class RecitationResultResource method deleteRecitationResult.

@DELETE
public Response deleteRecitationResult(@PathParam("recitationId") long recitationId) {
    try {
        RecitationResultResourceLinks resultResourceLinks = new RecitationResultResourceLinks(uriInfo);
        RecitationResult result = recitationService.deleteRecitationResultByRecitationAndStudentId(recitationId, studentId);
        result.addLink(resultResourceLinks.self(result.getId()));
        return Response.status(Response.Status.OK).entity(result).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 : Message(com.remswork.project.alice.model.support.Message) RecitationResultResourceLinks(com.remswork.project.alice.resource.links.RecitationResultResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) RecitationResult(com.remswork.project.alice.model.RecitationResult)

Example 53 with Message

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

the class ScheduleResource method getScheduleById.

@GET
@Path("{scheduleId}")
public Response getScheduleById(@PathParam("scheduleId") long id) {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        Schedule schedule = scheduleService.getScheduleById(id);
        schedule.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(schedule).build();
    } catch (ScheduleException 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) Schedule(com.remswork.project.alice.model.Schedule) ScheduleResourceLinks(com.remswork.project.alice.resource.links.ScheduleResourceLinks) ScheduleException(com.remswork.project.alice.exception.ScheduleException)

Example 54 with Message

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

the class ScheduleResource method getScheduleList.

@GET
public Response getScheduleList() {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        List<Schedule> scheduleList = scheduleService.getScheduleList();
        for (Schedule schedule : scheduleList) schedule.addLink(resourceLinks.self(schedule.getId()));
        GenericEntity<List<Schedule>> entity = new GenericEntity<List<Schedule>>(scheduleList) {
        };
        return Response.status(Response.Status.OK).entity(entity).build();
    } catch (ScheduleException 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) Schedule(com.remswork.project.alice.model.Schedule) ScheduleResourceLinks(com.remswork.project.alice.resource.links.ScheduleResourceLinks) List(java.util.List) ScheduleException(com.remswork.project.alice.exception.ScheduleException)

Example 55 with Message

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

the class ScheduleResource method updateScheduleById.

@PUT
@Path("{scheduleId}")
public Response updateScheduleById(@PathParam("scheduleId") long id, Schedule newSchedule) {
    try {
        ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
        Schedule schedule = scheduleService.updateScheduleById(id, newSchedule);
        schedule.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(schedule).build();
    } catch (ScheduleException 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) Schedule(com.remswork.project.alice.model.Schedule) ScheduleResourceLinks(com.remswork.project.alice.resource.links.ScheduleResourceLinks) ScheduleException(com.remswork.project.alice.exception.ScheduleException)

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