package oracle.byop.maf.data.collections.readonly;

import java.util.ArrayList;

import oracle.byop.maf.data.entities.Employee;
import oracle.byop.maf.data.entities.Product;

/**
 *
 * Title:   Bring Your Own Project (BYOP): Hackathon
 * Schema:  ADF Summit
 *
 * Type:    Service Object with hard-coded sample data
 *
 *
 * @author Frank Nimphius - August, 2014
 *  */

public class EmployeesRO {
    
    private Employee[] employees = new Employee[25];
    
    public EmployeesRO() {
        super();
        employees[0] = (createEmployee(new Integer(1),"Velasquez","Carmen","cvelasqu@summit.com",new Integer(50),new Long(2500),new Double(0)));                                                                                                                                                                                                                                                                             
        employees[1] =(createEmployee(new Integer(2),"Ngao","LaDoris","lngao@summit.com",new Integer(41),new Long(1450),new Double(0)));                                                                                                                                                                                                                                                                                    
        employees[2] =(createEmployee(new Integer(3),"Nagayama","Midori","mnagayam@summit.com",new Integer(31),new Long(1400),new Double(0)));                                                                                                                                                                                                                                                                              
        employees[3] =(createEmployee(new Integer(4),"Quick-To-See","Mark","mquickto@summit.com",new Integer(10),new Long(1450),new Double(0)));                                                                                                                                                                                                                                                                            
        employees[4] =(createEmployee(new Integer(5),"Ropeburn","Audry","aropebur@summit.com",new Integer(50),new Long(1550),new Double(0)));                                                                                                                                                                                                                                                                               
        employees[5] =(createEmployee(new Integer(6),"Urguhart","Molly","murguhar@summit.com",new Integer(41),new Long(1200),new Double(0)));                                                                                                                                                                                                                                                                               
        employees[6] =(createEmployee(new Integer(7),"Menchu","Roberta","rmenchu@summit.com",new Integer(42),new Long(1250),new Double(0)));                                                                                                                                                                                                                                                                                
        employees[7] =(createEmployee(new Integer(8),"Biri","Ben","bbiri@summit.com",new Integer(43),new Long(1100),new Double(0)));                                                                                                                                                                                                                                                                                        
        employees[8] =(createEmployee(new Integer(9),"Catchpole","Antoinette","acatchpo@summit.com",new Integer(44),new Long(1300),new Double(0)));                                                                                                                                                                                                                                                                         
        employees[9] =(createEmployee(new Integer(10),"Havel","Marta","mhavel@summit.com",new Integer(45),new Long(1307),new Double(0)));                                                                                                                                                                                                                                                                                   
        employees[10] =(createEmployee(new Integer(11),"Magee","Colin","cmagee@summit.com",new Integer(31),new Long(1400),new Double(10)));                                                                                                                                                                                                                                                                                  
        employees[11] =(createEmployee(new Integer(12),"Giljum","Henry","hgiljum@summit.com",new Integer(41),new Long(1490),new Double(12.5)));                                                                                                                                                                                                                                                                              
        employees[12] =(createEmployee(new Integer(13),"Sedeghi","Yasmin","ysedeghi@summit.com",new Integer(33),new Long(1515),new Double(10)));                                                                                                                                                                                                                                                                             
        employees[13] =(createEmployee(new Integer(14),"Nguyen","Mai","mnguyen@summit.com",new Integer(34),new Long(1525),new Double(15)));                                                                                                                                                                                                                                                                                  
        employees[14] =(createEmployee(new Integer(15),"Dumas","Andre","adumas@summit.com",new Integer(35),new Long(1450),new Double(17.5)));                                                                                                                                                                                                                                                                                
        employees[15] =(createEmployee(new Integer(16),"Maduro","Elena","emaduro@summit.com",new Integer(41),new Long(1400),new Double(0)));                                                                                                                                                                                                                                                                                 
        employees[16] =(createEmployee(new Integer(17),"Smith","George","gsmith@summit.com",new Integer(41),new Long(940),new Double(0)));                                                                                                                                                                                                                                                                                   
        employees[17] =(createEmployee(new Integer(18),"Nozaki","Akira","anozaki@summit.com",new Integer(42),new Long(1200),new Double(0)));                                                                                                                                                                                                                                                                                 
        employees[18] =(createEmployee(new Integer(19),"Patel","Vikram","vpatel@summit.com",new Integer(42),new Long(795),new Double(0)));                                                                                                                                                                                                                                                                                   
        employees[19] =(createEmployee(new Integer(20),"Newman","Chad","cnewman@summit.com",new Integer(43),new Long(750),new Double(0)));                                                                                                                                                                                                                                                                                   
        employees[20] =(createEmployee(new Integer(21),"Markarian","Alexander","amarkari@summit.com",new Integer(43),new Long(850),new Double(0)));                                                                                                                                                                                                                                                                          
        employees[21] =(createEmployee(new Integer(22),"Chang","Eddie","echang@summit.com",new Integer(44),new Long(800),new Double(0)));                                                                                                                                                                                                                                                                                    
        employees[22] =(createEmployee(new Integer(23),"Patel","Radha","rpatel@summit.com",new Integer(34),new Long(795),new Double(0)));                                                                                                                                                                                                                                                                                    
        employees[23] =(createEmployee(new Integer(24),"Dancs","Bela","bdancs@summit.com",new Integer(45),new Long(860),new Double(0)));                                                                                                                                                                                                                                                                                     
        employees[24] =(createEmployee(new Integer(25),"Schwartz","Sylvie","sschwart@summit.com",new Integer(45),new Long(1100),new Double(0)));                                                                                                                                                                                                                                                                             

        
    }

    
    //create credit rating
    private Employee createEmployee(Integer id, String lastname, String firstname, String email, Integer deptId, Long salary, Double commssionPct) {
        return new Employee(id,lastname,firstname,email,deptId,salary,commssionPct);
    }


    public void setEmployees(Employee[] employees) { }

    public Employee[] getEmployees() {
        return employees;
    }
    
    public Employee getEmployeeId(Integer empId) {
        
        for (int i = 0; i < employees.length; i++) {
            if(((Employee)employees[i]).getId() == empId){
               return (Employee)employees[i];
            }
        }
      return null;
    }
    
    public Employee[] getEmployeesByDepartmentId(Integer deptId) {
        
        ArrayList emps = new ArrayList();
        for (int i = 0; i < employees.length; i++) {
            if(employees[i].getDeptId().compareTo(deptId) == 0){
               emps.add(employees[i]);
            }
       }

        return (Employee[]) emps.toArray(new Employee[emps.size()]);
    }
}
