Package org.snippr.business.entities

Examples of org.snippr.business.entities.User


     * @throws DuplicateName
     */
    @Override
    @Transactional
    public void addNewSnippet(Label label) throws DuplicateName {
        User user = userDAO.getCurrentUser();
        snippet = new Snippet();
        snippet.setTitle("New Snippet, please fill it.");
        snippet.setDescription("Add a description here.");
        snippet.setUser(user);
        snippet.setLabel(label);
View Full Code Here


    }

    @Override
    @Transactional
    public void addNewLabel() throws DuplicateName {
        User user = userDAO.getCurrentUser();
        Label label = new Label();
        label.setName("<No name>");
        label.setUser(user);
        if (labelDAO.exists(label)) {
            throw new DuplicateName();
View Full Code Here

    }

    @Override
    @Transactional(readOnly = true)
    public List<Snippet> getSnippetsByLabel(Label label) {
        User user = userDAO.getCurrentUser();

        if (label == null) {
            labels = getLabels();
            if (!labels.isEmpty()) {
                label = labels.get(0);
View Full Code Here

        }
        return snippets;
    }

    private List<Label> getLabels() {
        User user = userDAO.getCurrentUser();
        if (labels == null) {
            labels = labelDAO.getAllByUser(user);
        }
        return labels;
    }
View Full Code Here

    }

    @Override
    @Transactional
    public List<Label> getLabelsByUser() {
        User user = userDAO.getCurrentUser();
        if (labels == null) {
            labels = labelDAO.getAllByUser(user);
        }
        return labels;
    }
View Full Code Here

    @Transactional
    public void save(Snippet snippet) throws DuplicateName {
        if (comment.getId() == null && commentDAO.exists(comment)) {
            throw new DuplicateName();
        }
        User user = userDAO.getCurrentUser();
        comment.setSnippet(snippet);
        comment.setUser(user);
        commentDAO.save(comment);
    }
View Full Code Here

    public User getByUsername(String username) {
        Criteria criteria = getSession().createCriteria(User.class);
        criteria.add(Restrictions.eq("username", username));
        criteria.createCriteria("roles");
        criteria.setMaxResults(1);
        User user = null;
        if (!criteria.list().isEmpty()) {
            user = (User) criteria.list().get(0);
        } else {
            user = new User().invalidate();
        }

        return user;
    }
View Full Code Here

TOP

Related Classes of org.snippr.business.entities.User

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.