src/com/vehiclerental/dataLayer/sqliteImplementation/OrmLiteHelper.java
/**
     * Creates the Vehicle table and generates default values
     *
     * @param dao ORMLite vehicle data access object
     */
Creates the Vehicle table and generates default values
@param dao ORMLite vehicle data access object
Creates the Vehicle table and generates default values @param dao ORMLite vehicle data access object
private void initializeVehicleTable(Dao<Vehicle, Integer> dao) {
        try {
            TableUtils.createTable(OrmLiteConnectionSingleton.getInstance(), Vehicle.class);
            Dao<Branch, Integer> branchDao = getOrmLiteBranchDao();
            List<Branch> branches = branchDao.queryForAll();
            List<String> cars = new ArrayList<>();
            cars.add("Acura Integra");
            cars.add("Acura SLX");
            cars.add("Alfa Romeo GTV-6");
            cars.add("Alfa Romeo Milano");
            cars.add("Peugeot 206");
            cars.add("Renault Clio");
            cars.add("Chrysler Aspen");
            cars.add("Chrysler Voyager");
            cars.add("Dodge Viper");
            cars.add("Dodge Lancer");
            cars.add("Ford Fiesta");
            cars.add("Ford Mustang");
            cars.add("Suzuki Forenza");
            cars.add("Volvo S60");
            Random random = new Random();
            int i = 0;
            int randomNumber;
            for (Branch branch : branches) {
                randomNumber = random.nextInt(cars.size());
                i++;
                dao.create(new Vehicle(branch, Vehicle.Status.AVAILABLE.getCode(), Vehicle.Type.SMALL_CAR.getCode(), branch.getName().toUpperCase() + "-" + Integer.toString(i), 2, 4, false, (5 + Math.floor((random.nextDouble() * 10) * 100) / 100), cars.get(randomNumber)));
                randomNumber = random.nextInt(cars.size());
                i++;
                dao.create(new Vehicle(branch, Vehicle.Status.AVAILABLE.getCode(), Vehicle.Type.FAMILY_CAR.getCode(), branch.getName().toUpperCase() + "-" + Integer.toString(i), 2, 4, false, (5 + Math.floor((random.nextDouble() * 10) * 100) / 100), cars.get(randomNumber)));
                randomNumber = random.nextInt(cars.size());
                i++;
                dao.create(new Vehicle(branch, Vehicle.Status.AVAILABLE.getCode(), Vehicle.Type.SMALL_VAN.getCode(), branch.getName().toUpperCase() + "-" + Integer.toString(i), 2, 4, false, (5 + Math.floor((random.nextDouble() * 10) * 100) / 100), cars.get(randomNumber)));
                randomNumber = random.nextInt(cars.size());
                i++;
                dao.create(new Vehicle(branch, Vehicle.Status.AVAILABLE.getCode(), Vehicle.Type.LARGE_VAN.getCode(), branch.getName().toUpperCase() + "-" + Integer.toString(i), 2, 4, false, (5 + Math.floor((random.nextDouble() * 10) * 100) / 100), cars.get(randomNumber)));
            }
        } catch (SQLException e) {
            System.out.println("Error initializing vehicle table");
            e.printStackTrace();
        } catch (DatabaseAccessFailedException e) {
            System.out.println("Error initializing vehicle table");
            e.printStackTrace();
        }
    }
private void initializeVehicleTable ( Dao < Vehicle , Integer > dao ) { try { TableUtils . createTable ( OrmLiteConnectionSingleton . getInstance ( ) , Vehicle . class ) ; Dao < Branch , Integer > branchDao = getOrmLiteBranchDao ( ) ; List < Branch > branches = branchDao . queryForAll ( ) ; List < String > cars = new ArrayList < > ( ) ; cars . add ( "Acura Integra" ) ; cars . add ( "Acura SLX" ) ; cars . add ( "Alfa Romeo GTV-6" ) ; cars . add ( "Alfa Romeo Milano" ) ; cars . add ( "Peugeot 206" ) ; cars . add ( "Renault Clio" ) ; cars . add ( "Chrysler Aspen" ) ; cars . add ( "Chrysler Voyager" ) ; cars . add ( "Dodge Viper" ) ; cars . add ( "Dodge Lancer" ) ; cars . add ( "Ford Fiesta" ) ; cars . add ( "Ford Mustang" ) ; cars . add ( "Suzuki Forenza" ) ; cars . add ( "Volvo S60" ) ; Random random = new Random ( ) ; int i = 0 ; int randomNumber ; for ( Branch branch : branches ) { randomNumber = random . nextInt ( cars . size ( ) ) ; i ++ ; dao . create ( new Vehicle ( branch , Vehicle . Status . AVAILABLE . getCode ( ) , Vehicle . Type . SMALL_CAR . getCode ( ) , branch . getName ( ) . toUpperCase ( ) + "-" + Integer . toString ( i ) , 2 , 4 , false , ( 5 + Math . floor ( ( random . nextDouble ( ) * 10 ) * 100 ) / 100 ) , cars . get ( randomNumber ) ) ) ; randomNumber = random . nextInt ( cars . size ( ) ) ; i ++ ; dao . create ( new Vehicle ( branch , Vehicle . Status . AVAILABLE . getCode ( ) , Vehicle . Type . FAMILY_CAR . getCode ( ) , branch . getName ( ) . toUpperCase ( ) + "-" + Integer . toString ( i ) , 2 , 4 , false , ( 5 + Math . floor ( ( random . nextDouble ( ) * 10 ) * 100 ) / 100 ) , cars . get ( randomNumber ) ) ) ; randomNumber = random . nextInt ( cars . size ( ) ) ; i ++ ; dao . create ( new Vehicle ( branch , Vehicle . Status . AVAILABLE . getCode ( ) , Vehicle . Type . SMALL_VAN . getCode ( ) , branch . getName ( ) . toUpperCase ( ) + "-" + Integer . toString ( i ) , 2 , 4 , false , ( 5 + Math . floor ( ( random . nextDouble ( ) * 10 ) * 100 ) / 100 ) , cars . get ( randomNumber ) ) ) ; randomNumber = random . nextInt ( cars . size ( ) ) ; i ++ ; dao . create ( new Vehicle ( branch , Vehicle . Status . AVAILABLE . getCode ( ) , Vehicle . Type . LARGE_VAN . getCode ( ) , branch . getName ( ) . toUpperCase ( ) + "-" + Integer . toString ( i ) , 2 , 4 , false , ( 5 + Math . floor ( ( random . nextDouble ( ) * 10 ) * 100 ) / 100 ) , cars . get ( randomNumber ) ) ) ; } } catch ( SQLException e ) { System . out . println ( "Error initializing vehicle table" ) ; e . printStackTrace ( ) ; } catch ( DatabaseAccessFailedException e ) { System . out . println ( "Error initializing vehicle table" ) ; e . printStackTrace ( ) ; } }
Creates the Vehicle table and generates default values
 @param dao ORMLite vehicle data access object
Creates the Vehicle table and generates default values @param dao ORMLite vehicle data access object