Package org.pathways.openciss.shared

Source Code of org.pathways.openciss.shared.ProgramProfileInfoService

/*CRUD operations on the _program_profile_info_table
*/
package org.pathways.openciss.shared;

//for JPA
import javax.persistence.EntityManager;

import org.pathways.openciss.model.ProgramProfileInfo;

public class ProgramProfileInfoService {
  public EntityManager em;
 
  public ProgramProfileInfo getProgramProfileInfo(int program_key) {
    ProgramProfileInfo result = null;
    em =EMF.get().createEntityManager();
    try {
      result = em.find(ProgramProfileInfo.class, program_key);
    }
    finally {em.close();}
    return result;
  }
 
  @SuppressWarnings("finally")
  public boolean updateProgramProfileInfo_Occupany(ProgramProfileInfo ppi) {
    em =EMF.get().createEntityManager();
    try{
       em.getTransaction().begin();
       ProgramProfileInfo ppix = em.find(ProgramProfileInfo.class, ppi.getAgencyKey());
       ppix.setUnitsAvailable(ppi.getUnitsAvailable());
       ppix.setUnitsOccupied(ppi.getUnitsOccupied());
       ppix.setUnitsTotal(ppi.getUnitsTotal());
       em.getTransaction().commit();
     } catch (Exception e){System.out.println("couldn't persist");}
     finally {
       em.close();
       return false;
     }
  }
 
  @SuppressWarnings("finally")
  public boolean updateProgramProfileInfo_Shelter(ProgramProfileInfo ppi) {
    em =EMF.get().createEntityManager();
    try{
       em.getTransaction().begin();
       //ProgramProfileInfo ppix = em.find(ProgramProfileInfo.class, ppi.getAgencyKey());
//       ppix.setAgencyName(ppi.getAgencyName());
//       ppix.setContactPhone(ppi.getContactPhone());
//       ppix.setProgramAddress(ppi.getProgramAddress());
//       ppix.setProgramCity(ppi.getProgramCity());
//       ppix.setProgramZip(ppi.getProgramZip());
//       ppix.setFeedSource(ppi.getFeedSource());
//       System.out.println("ppix is: " +ppix.toString());
       em.persist(ppi);
       em.getTransaction().commit();
     } catch (Exception e){System.out.println("couldn't persist");}
     finally {
       em.close();
       return false;
     }
  }
 
//  public ProgramProfileInfo createProgramProfileInfo(int program_key) {
   
//    public void createContact(Contact c) {
//          logger.info("Entering createContact: ["
//                      + c.getFirstName() + ","
//                      + c.getLastName() + "]");          
//          EntityManager mgr = EMF.get().createEntityManager();
//          try {
//              mgr.getTransaction().begin();
//              mgr.persist(c);
//              mgr.getTransaction().commit();
//          } finally {
//              mgr.close();
//          }
//          logger.info("Exiting createContact");

   
//    ProgramProfileInfo result = null;
//    EntityManager em =EMF.get().createEntityManager();
//    try {
//      result = em. (ProgramProfileInfo.class, program_key);
//    }
//    finally {em.close();}
//    return result;
//  }
}
TOP

Related Classes of org.pathways.openciss.shared.ProgramProfileInfoService

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.