Package com.evasion.plugin.donation

Source Code of com.evasion.plugin.donation.DonationManager

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

import com.evasion.entity.Don;
import com.evasion.entity.Person;
import com.evasion.exception.PersistenceViolationException;
import com.evasion.ejb.local.DonationManagerLocal;
import com.evasion.ejb.remote.DonationManagerRemote;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionManagement;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
*
* @author sebastien.glon
*/
@Stateless
@Local(value = DonationManagerLocal.class)
@Remote(value = DonationManagerRemote.class)
public class DonationManager implements DonationManagerLocal, DonationManagerRemote {

    @PersistenceContext(unitName = "EvasionPU")
    private EntityManager em;

    protected DonationManager(EntityManager em) {
        this.em = em;
    }

    public DonationManager() {
    }
   
    @Override
    public Long savePromesse(Person p, Long l, String d) throws PersistenceViolationException {
        if (l == null || l <= 0L) {
            throw new PersistenceViolationException("le montant ne peut etre null ou <=0");
        }
        Don don = new Don(p, l, d);
        try {
            em.persist(don);
            em.flush();
            return don.getId();
        } catch (Exception e) {
            throw new PersistenceViolationException("Save promesse en Echec", e);
        }
    }

    @Override
    public void validDon(Long l) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
TOP

Related Classes of com.evasion.plugin.donation.DonationManager

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.