Package jug.domain

Examples of jug.domain.Subject


    @POST
    @Path("vote")
    public Vote vote(final String input, @QueryParam("subject") final String subjectName) {
        final Vote vote = voteDao.create(Value.valueOf(input));
        final Subject subject = dao.findByName(subjectName);
        dao.addVote(subject, vote);

        counter.putSubject(subject); // update

        return vote;
View Full Code Here


    public Subject create(final String question, @QueryParam("name") final String name) {
        if (blackList.contains(name)) {
            throw new IllegalArgumentException("name blacklisted");
        }

        final Subject subject = dao.create(name, question);

        counter.putSubject(subject);

        return subject;
    }
View Full Code Here

    @POST
    @Path("vote")
    public Vote vote(final String input, @QueryParam("subject") final String subjectName) {
        final Vote vote = voteDao.create(Value.valueOf(input));
        final Subject subject = dao.findByName(subjectName);
        dao.addVote(subject, vote);

        counter.putSubject(subject); // update

        return vote;
View Full Code Here

    @Inject
    private ReadSubjectDao readDao;

    public Subject create(final String name, final String question) {
        final Subject subject = new Subject();
        subject.setName(name);
        subject.setQuestion(question);

        em.persist(subject);
        return subject;
    }
View Full Code Here

        return subject;
    }

    public Subject addVote(final Subject subject, final Vote vote) {
        final Vote foundVote = retrieve(vote, Vote.class, vote.getId());
        final Subject subjectToUpdate = retrieve(subject, Subject.class, subject.getId());

        subjectToUpdate.getVotes().add(foundVote);
        return subjectToUpdate;
    }
View Full Code Here

        return t;
    }

    public Subject bestSubject() {
        int bestScore = 0;
        Subject best = null;
        for (Subject subject : findAll()) {
            int currentScore = subject.score();
            if (best == null || bestScore < currentScore) {
                bestScore = currentScore;
                best = subject;
View Full Code Here

TOP

Related Classes of jug.domain.Subject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.