Search in sources :

Example 36 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException in project classify-system by anverliedoit.

the class RecitationResource method addRecitation.

@POST
public Response addRecitation(Recitation recitation) {
    try {
        RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (termId > 0)
            recitation = recitationService.addRecitation(recitation, classId, termId);
        else
            recitation = recitationService.addRecitation(recitation, classId);
        recitation.addLink(resourceLinks.self(recitation.getId()));
        if (recitation.get_class() != null)
            recitation.get_class().addLink(classResourceLinks.self(recitation.get_class().getId()));
        return Response.status(Response.Status.CREATED).entity(recitation).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 : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Message(com.remswork.project.alice.model.support.Message) RecitationResourceLinks(com.remswork.project.alice.resource.links.RecitationResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 37 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException 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 38 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException 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 39 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException in project classify-system by anverliedoit.

the class TermResource method addTerm.

@POST
public Response addTerm(Term term) {
    try {
        TermResourceLinks resourceLinks = new TermResourceLinks(uriInfo);
        term = termService.addTerm(term);
        term.addLink(resourceLinks.self(term.getId()));
        return Response.status(Response.Status.CREATED).entity(term).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 : TermResourceLinks(com.remswork.project.alice.resource.links.TermResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 40 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException in project classify-system by anverliedoit.

the class TermResource method getTermList.

@GET
public Response getTermList() {
    try {
        TermResourceLinks resourceLinks = new TermResourceLinks(uriInfo);
        List<Term> termList = termService.getTermList();
        for (Term term : termList) term.addLink(resourceLinks.self(term.getId()));
        GenericEntity<List<Term>> entity = new GenericEntity<List<Term>>(termList) {
        };
        return Response.status(Response.Status.OK).entity(entity).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 : TermResourceLinks(com.remswork.project.alice.resource.links.TermResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) List(java.util.List) Term(com.remswork.project.alice.model.Term)

Aggregations

GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)302 Message (com.remswork.project.alice.model.support.Message)178 GradingFactorDaoException (com.remswork.project.alice.dao.exception.GradingFactorDaoException)104 Session (org.hibernate.Session)104 AsyncTask (android.os.AsyncTask)102 Gson (com.google.gson.Gson)102 IOException (java.io.IOException)102 InputStream (java.io.InputStream)102 HttpURLConnection (java.net.HttpURLConnection)102 URL (java.net.URL)102 ExecutionException (java.util.concurrent.ExecutionException)102 ArrayList (java.util.ArrayList)71 Query (org.hibernate.Query)64 ClassResourceLinks (com.remswork.project.alice.resource.links.ClassResourceLinks)35 JSONArray (org.json.JSONArray)32 JSONException (org.json.JSONException)32 Grade (com.remswork.project.alice.model.Grade)25 BufferedWriter (java.io.BufferedWriter)21 OutputStream (java.io.OutputStream)21 OutputStreamWriter (java.io.OutputStreamWriter)21