com.evasion.plugin.donation.DonationManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Plugin-Donation Show documentation
Show all versions of Plugin-Donation Show documentation
Gestion des donnations au profit d'une association
/*
* 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.");
}
}