Search in sources :

Example 1 with TermResourceLinks

use of com.remswork.project.alice.resource.links.TermResourceLinks 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 2 with TermResourceLinks

use of com.remswork.project.alice.resource.links.TermResourceLinks 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)

Example 3 with TermResourceLinks

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

the class TermResource method updateTermById.

@PUT
@Path("{termId}")
public Response updateTermById(@PathParam("termId") long id, Term newTerm) {
    try {
        TermResourceLinks resourceLinks = new TermResourceLinks(uriInfo);
        Term term = termService.updateTermById(id, newTerm);
        term.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).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) Term(com.remswork.project.alice.model.Term)

Example 4 with TermResourceLinks

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

the class TermResource method deleteTermById.

@DELETE
@Path("{termId}")
public Response deleteTermById(@PathParam("termId") long id) {
    try {
        TermResourceLinks resourceLinks = new TermResourceLinks(uriInfo);
        Term term = termService.deleteTermById(id);
        term.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).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) Term(com.remswork.project.alice.model.Term)

Example 5 with TermResourceLinks

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

the class TermResource method getTermById.

@GET
@Path("{termId}")
public Response getTermById(@PathParam("termId") long id) {
    try {
        TermResourceLinks resourceLinks = new TermResourceLinks(uriInfo);
        Term term = termService.getTermById(id);
        term.addLink(resourceLinks.self(id));
        return Response.status(Response.Status.OK).entity(term).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) Term(com.remswork.project.alice.model.Term)

Aggregations

GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)5 Message (com.remswork.project.alice.model.support.Message)5 TermResourceLinks (com.remswork.project.alice.resource.links.TermResourceLinks)5 Term (com.remswork.project.alice.model.Term)4 List (java.util.List)1