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

import java.util.ArrayList;

import oracle.byop.maf.data.entities.Country;
import oracle.byop.maf.data.entities.CreditRating;
import oracle.byop.maf.data.entities.Customer;

/**
 *
 * 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 CountriesRO {
    
    private Country[] countries = new Country[14];
    
    public CountriesRO() {
        super();
        
        countries[0]= (createCountry(new Integer(1),"Brazil",new Integer(2), "BR"));
        countries[1]= (createCountry(new Integer(2),"Japan",new Integer(4), "JP"));
        countries[2]= (createCountry(new Integer(3),"India",new Integer(4), "IN"));
        countries[3]= (createCountry(new Integer(4),"USA",new Integer(1), "US"));
        countries[4]= (createCountry(new Integer(5),"Hong Kong",new Integer(4), "HK"));
        countries[5]= (createCountry(new Integer(6),"France",new Integer(5), "FR"));
        countries[6]= (createCountry(new Integer(7),"Nigeria",new Integer(3), "NG"));
        countries[7]= (createCountry(new Integer(8),"Germany",new Integer(5), "DE"));
        countries[8]= (createCountry(new Integer(9),"Dominican Republic",new Integer(1), "DO"));
        countries[9]= (createCountry(new Integer(10),"Columbia",new Integer(2), "CO"));
        countries[10]= (createCountry(new Integer(11),"Czech Republic",new Integer(5), "CZ"));
        countries[11]= (createCountry(new Integer(12),"Egypt",new Integer(3), "EG"));
        countries[12]= (createCountry(new Integer(13),"Russian Federation",new Integer(5), "RU"));
        countries[13]= (createCountry(new Integer(14),"Canada",new Integer(1), "CA"));

    }

    
    //create credit rating
    private Country createCountry(Integer id, String country, Integer regionId, String countryCode){
        return new Country(id, country,regionId,countryCode);
    }


    public void setCountries(Country[] countries) { }

    public Country[] getCountries() {
        return countries;
    }
    
    public Country getCountryById(Integer countryId) {
        
        for (int i = 0; i < this.countries.length; i++) {
            if(((Country)countries[i]).getId().compareTo(countryId) == 0){
                return (Country)countries[i];
            }
       }

        return null;
    }
}
