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

com.evasion.plugin.person.PersonEJB Maven / Gradle / Ivy

There is a newer version: 1.0.0.5
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.evasion.plugin.person;

import com.evasion.entity.Civilite;
import com.evasion.entity.Individual;
import com.evasion.entity.Person;
import java.util.Date;
import javax.persistence.EntityManager;

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

    private EntityManager em;

    public PersonEJB(EntityManager em) {
        this.em = em;
    }

    public Long saveIndividual(Long id, Civilite civ, String nom, String prenom, Date naissance, String email) {
        Individual indiv;
        if (id == null) {
            indiv = new Individual(email, civ, nom, prenom, naissance);
            createPerson(indiv);
        } else {
            indiv = em.find(Individual.class, id);
            indiv.setTitre(civ);
            indiv.setNom(nom);
            indiv.setPrenom(prenom);
            indiv.setAnniversaire(naissance);
            indiv.setEmail(email);
            indiv = em.merge(indiv);
        }
        return indiv.getId();
    }

    public void saveCorporation(String nom, Byte logo, String email) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

        public Person createPerson(Person p) {
        em.persist(p);
        return p;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy