*/
private ContactModel findCreateContact (EntityManager em, String newContact)
{
Query contactQuery = em.createNamedQuery ("conByContact");
contactQuery.setParameter ("contact", newContact);
ContactModel con = null;
try {
con = (ContactModel)(contactQuery.getSingleResult ());
myLog.debug ("edit - retrieved {}", con);
}
catch (NoResultException exc) {
myLog.debug ("edit - existing contact {} not found.", newContact);
con = null;
}
if (con == null) {
Query contactTypeQuery = em.createNamedQuery ("cotByCode");
contactTypeQuery.setParameter ("code", ContactType.eEmail.getCode ());
ContactTypeModel cot = (ContactTypeModel)(contactTypeQuery.getSingleResult ());
myLog.debug ("edit - retrieved contact type {}, {}", cot.getKey (), cot);
con = new ContactModel (cot, newContact, "cahaya");
{
Object [] t = {con, con.getType ().getKey (), con.getType ()};
myLog.debug ("edit - retrieved contact {}, {}, {}", t);
}
em.persist (con);
}