Search in sources :

Example 1 with GradingFactorException

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

the class ActivityResource method addActivity.

@POST
public Response addActivity(Activity activity) {
    try {
        ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (termId > 0)
            activity = activityService.addActivity(activity, classId, termId);
        else
            activity = activityService.addActivity(activity, classId);
        activity.addLink(resourceLinks.self(activity.getId()));
        if (activity.get_class() != null)
            activity.get_class().addLink(classResourceLinks.self(activity.get_class().getId()));
        return Response.status(Response.Status.CREATED).entity(activity).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) ActivityResourceLinks(com.remswork.project.alice.resource.links.ActivityResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 2 with GradingFactorException

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

the class ActivityResource method getActivityById.

@GET
@Path("{activityId}")
public Response getActivityById(@PathParam("activityId") long id) {
    try {
        ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Activity activity = activityService.getActivityById(id);
        activity.addLink(resourceLinks.self(id));
        if (activity.get_class() != null)
            activity.get_class().addLink(classResourceLinks.self(activity.get_class().getId()));
        return Response.status(Response.Status.OK).entity(activity).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 : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Message(com.remswork.project.alice.model.support.Message) ActivityResourceLinks(com.remswork.project.alice.resource.links.ActivityResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Activity(com.remswork.project.alice.model.Activity)

Example 3 with GradingFactorException

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

the class ActivityResource method updateActivityById.

@PUT
@Path("{activityId}")
public Response updateActivityById(@PathParam("activityId") long id, Activity newActivity) {
    try {
        ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Activity activity;
        if (termId > 0)
            activity = activityService.updateActivityById(id, newActivity, classId, termId);
        else
            activity = activityService.updateActivityById(id, newActivity, classId);
        activity.addLink(resourceLinks.self(activity.getId()));
        if (activity.get_class() != null)
            activity.get_class().addLink(classResourceLinks.self(activity.get_class().getId()));
        return Response.status(Response.Status.OK).entity(activity).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) ActivityResourceLinks(com.remswork.project.alice.resource.links.ActivityResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Activity(com.remswork.project.alice.model.Activity)

Example 4 with GradingFactorException

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

the class ActivityResultResource method updateActivityResult.

@PUT
public Response updateActivityResult(@PathParam("activityId") long activityId, @QueryParam("score") int score) {
    try {
        ActivityResultResourceLinks resultResourceLinks = new ActivityResultResourceLinks(uriInfo);
        ActivityResult result = activityService.updateActivityResultByActivityAndStudentId(score, activityId, 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.NOT_FOUND).entity(message).build();
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) ActivityResultResourceLinks(com.remswork.project.alice.resource.links.ActivityResultResourceLinks) ActivityResult(com.remswork.project.alice.model.ActivityResult)

Example 5 with GradingFactorException

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

the class AssignmentResource method addAssignment.

@POST
public Response addAssignment(Assignment assignment) {
    try {
        AssignmentResourceLinks resourceLinks = new AssignmentResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (termId > 0)
            assignment = assignmentService.addAssignment(assignment, classId, termId);
        else
            assignment = assignmentService.addAssignment(assignment, classId);
        assignment.addLink(resourceLinks.self(assignment.getId()));
        if (assignment.get_class() != null)
            assignment.get_class().addLink(classResourceLinks.self(assignment.get_class().getId()));
        return Response.status(Response.Status.CREATED).entity(assignment).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) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) AssignmentResourceLinks(com.remswork.project.alice.resource.links.AssignmentResourceLinks)

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