All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evasion.plugin.donation.DonationManager Maven / Gradle / Ivy

There is a newer version: 2.0.0.2
Show newest version
/*
 * 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.");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy