Package com.evasion.plugin.account

Source Code of com.evasion.plugin.account.AccountManager

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.evasion.plugin.account;

import com.evasion.entity.Account;
import com.evasion.exception.PersistenceViolationException;
import com.evasion.plugin.account.dao.AccountDAOImpl;
import com.evasion.plugin.person.PersonEJB;
import com.evasion.plugin.security.UserAuthService;
import java.util.List;
import javax.persistence.EntityManager;

/**
*
* @author sebastien.glon
*/
public class AccountManager {

    private EntityManager em;
    private final AccountDAOImpl accountDAO;

    public AccountManager(EntityManager em) {
        accountDAO = new AccountDAOImpl();
        accountDAO.setEntityManager(em);
        this.em = em;
    }

    public Account createAccount(Account account) throws PersistenceViolationException {
        (new UserAuthService(em)).createUser(account.getUser());
        (new PersonEJB(em)).createPerson(account.getPerson());
        try {
            em.persist(account);
            em.flush();
        } catch (Exception e) {
            throw new PersistenceViolationException("Erreur dans la validation du compte utilisateur", e.fillInStackTrace());
        }
        return account;
    }

    public void deleteAccount(Account u) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Account updateAccount(Account u) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public List<Account> listAllAccount() {
        return accountDAO.findAll();
    }
}
TOP

Related Classes of com.evasion.plugin.account.AccountManager

TOP
Copyright © 2018 www.massapi.com. 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.