// Path: chapter04/src/main/java/com/packt/pfblueprints/model/Advisor.java
// public class Advisor implements Serializable{
// 
// 	private static final long serialVersionUID = 1L;
// 	private int id;
// 	private String dealernumber;
// 	private String advisorname;
// 	private String advisornumber;
// 	private String managementcompany;
// 	private String branch;
// 	private int year;
// 	private boolean status;
// 	private int revenue;
// 	private List<ProgressStatus> progressStatus;
// 	
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	public String getDealernumber() {
// 		return dealernumber;
// 	}
// 	public void setDealernumber(String dealernumber) {
// 		this.dealernumber = dealernumber;
// 	}
// 	public String getAdvisorname() {
// 		return advisorname;
// 	}
// 	public void setAdvisorname(String advisorname) {
// 		this.advisorname = advisorname;
// 	}
// 	public String getAdvisornumber() {
// 		return advisornumber;
// 	}
// 	public void setAdvisornumber(String advisornumber) {
// 		this.advisornumber = advisornumber;
// 	}
// 	
// 	public String getManagementcompany() {
// 		return managementcompany;
// 	}
// 	public void setManagementcompany(String managementcompany) {
// 		this.managementcompany = managementcompany;
// 	}
// 	public int getYear() {
// 		return year;
// 	}
// 	public void setYear(int year) {
// 		this.year = year;
// 	}
// 	public int getRevenue() {
// 		return revenue;
// 	}
// 	public void setRevenue(int revenue) {
// 		this.revenue = revenue;
// 	}
// 	public String getBranch() {
// 		return branch;
// 	}
// 	public void setBranch(String branch) {
// 		this.branch = branch;
// 	}
// 	
// 	public boolean isStatus() {
// 		return status;
// 	}
// 	public void setStatus(boolean status) {
// 		this.status = status;
// 	}
// 	public List<ProgressStatus> getProgressStatus() {
// 		return progressStatus;
// 	}
// 	public void setProgressStatus(List<ProgressStatus> progressStatus) {
// 		this.progressStatus = progressStatus;
// 	}
// 
// }
// 
// Path: chapter04/src/main/java/com/packt/pfblueprints/model/ProgressStatus.java
// public class ProgressStatus{
// 	private String year;
// 	private String percentage;
// 	
// 	public ProgressStatus(String year, String percentage) {
// 		super();
// 		this.year = year;
// 		this.percentage = percentage;
// 	}
// 	
// 	public ProgressStatus() {
// 		super();
// 		// TODO Auto-generated constructor stub
// 	}
// 
// 	public String getYear() {
// 		return year;
// 	}
// 	public void setYear(String year) {
// 		this.year = year;
// 	}
// 	public String getPercentage() {
// 		return percentage;
// 	}
// 	public void setPercentage(String percentage) {
// 		this.percentage = percentage;
// 	}
// 	
// }


import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import com.packt.pfblueprints.model.Advisor;
import com.packt.pfblueprints.model.ProgressStatus;

package com.packt.pfblueprints.dao;





public class DealerDAO {

	private  SessionFactory sessionFactory;
	private  String dealerNumber;
	
	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 DealerDAO() {
		super();
		
		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
		Map<String, Object> sessionMap = externalContext.getSessionMap();
		dealerNumber=(String) sessionMap.get("dealertinnumber");
		// TODO Auto-generated constructor stub
	}


// Path: chapter04/src/main/java/com/packt/pfblueprints/model/Advisor.java
// public class Advisor implements Serializable{
// 
// 	private static final long serialVersionUID = 1L;
// 	private int id;
// 	private String dealernumber;
// 	private String advisorname;
// 	private String advisornumber;
// 	private String managementcompany;
// 	private String branch;
// 	private int year;
// 	private boolean status;
// 	private int revenue;
// 	private List<ProgressStatus> progressStatus;
// 	
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	public String getDealernumber() {
// 		return dealernumber;
// 	}
// 	public void setDealernumber(String dealernumber) {
// 		this.dealernumber = dealernumber;
// 	}
// 	public String getAdvisorname() {
// 		return advisorname;
// 	}
// 	public void setAdvisorname(String advisorname) {
// 		this.advisorname = advisorname;
// 	}
// 	public String getAdvisornumber() {
// 		return advisornumber;
// 	}
// 	public void setAdvisornumber(String advisornumber) {
// 		this.advisornumber = advisornumber;
// 	}
// 	
// 	public String getManagementcompany() {
// 		return managementcompany;
// 	}
// 	public void setManagementcompany(String managementcompany) {
// 		this.managementcompany = managementcompany;
// 	}
// 	public int getYear() {
// 		return year;
// 	}
// 	public void setYear(int year) {
// 		this.year = year;
// 	}
// 	public int getRevenue() {
// 		return revenue;
// 	}
// 	public void setRevenue(int revenue) {
// 		this.revenue = revenue;
// 	}
// 	public String getBranch() {
// 		return branch;
// 	}
// 	public void setBranch(String branch) {
// 		this.branch = branch;
// 	}
// 	
// 	public boolean isStatus() {
// 		return status;
// 	}
// 	public void setStatus(boolean status) {
// 		this.status = status;
// 	}
// 	public List<ProgressStatus> getProgressStatus() {
// 		return progressStatus;
// 	}
// 	public void setProgressStatus(List<ProgressStatus> progressStatus) {
// 		this.progressStatus = progressStatus;
// 	}
// 
// }
// 
// Path: chapter04/src/main/java/com/packt/pfblueprints/model/ProgressStatus.java
// public class ProgressStatus{
// 	private String year;
// 	private String percentage;
// 	
// 	public ProgressStatus(String year, String percentage) {
// 		super();
// 		this.year = year;
// 		this.percentage = percentage;
// 	}
// 	
// 	public ProgressStatus() {
// 		super();
// 		// TODO Auto-generated constructor stub
// 	}
// 
// 	public String getYear() {
// 		return year;
// 	}
// 	public void setYear(String year) {
// 		this.year = year;
// 	}
// 	public String getPercentage() {
// 		return percentage;
// 	}
// 	public void setPercentage(String percentage) {
// 		this.percentage = percentage;
// 	}
// 	
// }


// Path: chapter04/src/main/java/com/packt/pfblueprints/dao/DealerDAO.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import com.packt.pfblueprints.model.Advisor;
import com.packt.pfblueprints.model.ProgressStatus;

package com.packt.pfblueprints.dao;





public class DealerDAO {

	private  SessionFactory sessionFactory;
	private  String dealerNumber;
	
	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 DealerDAO() {
		super();
		
		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
		Map<String, Object> sessionMap = externalContext.getSessionMap();
		dealerNumber=(String) sessionMap.get("dealertinnumber");
		// TODO Auto-generated constructor stub
	}


	public List<Advisor> getAllAdvisors() {
