// Path: chapter04/src/main/java/com/packt/pfblueprints/dao/AdvisorDAO.java
// public class AdvisorDAO {
// 
// 	private  SessionFactory sessionFactory;
// 	private  String advisorNumber;
// 
// 	private  SessionFactory configureSessionFactory()
// 			throws HibernateException {
// 		Configuration configuration = new Configuration();
// 		configuration.configure();
// 		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder()
// 				.applySettings(configuration.getProperties());
// 		SessionFactory sessionfactory = configuration
// 				.buildSessionFactory(builder.build());
// 		return sessionfactory;
// 	}
//     
// 	public AdvisorDAO() {
// 		super();
// 		
// 		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
// 		Map<String, Object> sessionMap = externalContext.getSessionMap();
// 		advisorNumber=(String) sessionMap.get("advisornumber");
// 	}
// 
// 	public List<Representative> getAllRepresentatives() {
// 		sessionFactory = configureSessionFactory();
// 		Session session = sessionFactory.openSession();
// 		session.beginTransaction();
// 		Query queryResult=null;
// 		if(advisorNumber!=""){
// 			queryResult = session.createQuery("from Representative where advisornumber = :advisorNum");
// 			queryResult.setParameter("advisorNum", advisorNumber);
// 			}else{
// 		    queryResult = session.createQuery("from Representative");	
// 			}
// 		List<Representative> allAdvisors = queryResult.list();
// 		session.getTransaction().commit();
// 		return allAdvisors;
// 	}
// 
// }
// 
// Path: chapter04/src/main/java/com/packt/pfblueprints/model/Representative.java
// public class Representative implements Serializable{
// 
// 	private static final long serialVersionUID = 1L;
// 	private int id;
// 	private String repnumber;
// 	private String repname;
// 	private String advisornumber;
// 	private String dor;
// 	private String branch;
// 	private String status;
// 	
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	
// 	public String getRepnumber() {
// 		return repnumber;
// 	}
// 	public void setRepnumber(String repnumber) {
// 		this.repnumber = repnumber;
// 	}
// 	public String getRepname() {
// 		return repname;
// 	}
// 	public void setRepname(String repname) {
// 		this.repname = repname;
// 	}
// 	public String getAdvisornumber() {
// 		return advisornumber;
// 	}
// 	public void setAdvisornumber(String advisornumber) {
// 		this.advisornumber = advisornumber;
// 	}
// 	public String getDor() {
// 		return dor;
// 	}
// 	public void setDor(String dor) {
// 		this.dor = dor;
// 	}
// 	public String getBranch() {
// 		return branch;
// 	}
// 	public void setBranch(String branch) {
// 		this.branch = branch;
// 	}
// 	public String getStatus() {
// 		return status;
// 	}
// 	public void setStatus(String status) {
// 		this.status = status;
// 	}
// 
// }


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import com.packt.pfblueprints.dao.AdvisorDAO;
import com.packt.pfblueprints.model.Representative;

package com.packt.pfblueprints.controller;



@ManagedBean
@ViewScoped
public class AdvisorController implements Serializable{

	private static final long serialVersionUID = 1L;

// Path: chapter04/src/main/java/com/packt/pfblueprints/dao/AdvisorDAO.java
// public class AdvisorDAO {
// 
// 	private  SessionFactory sessionFactory;
// 	private  String advisorNumber;
// 
// 	private  SessionFactory configureSessionFactory()
// 			throws HibernateException {
// 		Configuration configuration = new Configuration();
// 		configuration.configure();
// 		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder()
// 				.applySettings(configuration.getProperties());
// 		SessionFactory sessionfactory = configuration
// 				.buildSessionFactory(builder.build());
// 		return sessionfactory;
// 	}
//     
// 	public AdvisorDAO() {
// 		super();
// 		
// 		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
// 		Map<String, Object> sessionMap = externalContext.getSessionMap();
// 		advisorNumber=(String) sessionMap.get("advisornumber");
// 	}
// 
// 	public List<Representative> getAllRepresentatives() {
// 		sessionFactory = configureSessionFactory();
// 		Session session = sessionFactory.openSession();
// 		session.beginTransaction();
// 		Query queryResult=null;
// 		if(advisorNumber!=""){
// 			queryResult = session.createQuery("from Representative where advisornumber = :advisorNum");
// 			queryResult.setParameter("advisorNum", advisorNumber);
// 			}else{
// 		    queryResult = session.createQuery("from Representative");	
// 			}
// 		List<Representative> allAdvisors = queryResult.list();
// 		session.getTransaction().commit();
// 		return allAdvisors;
// 	}
// 
// }
// 
// Path: chapter04/src/main/java/com/packt/pfblueprints/model/Representative.java
// public class Representative implements Serializable{
// 
// 	private static final long serialVersionUID = 1L;
// 	private int id;
// 	private String repnumber;
// 	private String repname;
// 	private String advisornumber;
// 	private String dor;
// 	private String branch;
// 	private String status;
// 	
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	
// 	public String getRepnumber() {
// 		return repnumber;
// 	}
// 	public void setRepnumber(String repnumber) {
// 		this.repnumber = repnumber;
// 	}
// 	public String getRepname() {
// 		return repname;
// 	}
// 	public void setRepname(String repname) {
// 		this.repname = repname;
// 	}
// 	public String getAdvisornumber() {
// 		return advisornumber;
// 	}
// 	public void setAdvisornumber(String advisornumber) {
// 		this.advisornumber = advisornumber;
// 	}
// 	public String getDor() {
// 		return dor;
// 	}
// 	public void setDor(String dor) {
// 		this.dor = dor;
// 	}
// 	public String getBranch() {
// 		return branch;
// 	}
// 	public void setBranch(String branch) {
// 		this.branch = branch;
// 	}
// 	public String getStatus() {
// 		return status;
// 	}
// 	public void setStatus(String status) {
// 		this.status = status;
// 	}
// 
// }


// Path: chapter04/src/main/java/com/packt/pfblueprints/controller/AdvisorController.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import com.packt.pfblueprints.dao.AdvisorDAO;
import com.packt.pfblueprints.model.Representative;

package com.packt.pfblueprints.controller;



@ManagedBean
@ViewScoped
public class AdvisorController implements Serializable{

	private static final long serialVersionUID = 1L;

	private List<Representative>  advisorInfo=new ArrayList<Representative>();
