Package org.infinispan.demo.carmart.model

Examples of org.infinispan.demo.carmart.model.Car


    public void startup() {
      RemoteCache<String, Object> cars = provider.getCacheContainer().getCache(CarManager.CACHE_NAME);
        List<String> carNumbers = new ArrayList<String>();

        try {
            Car c = new Car("Ford Focus", 1.6, CarType.COMBI, "white", "FML 23-25", Country.CHN);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            c = new Car("BMW X3", 2.0, CarType.SEDAN, "gray", "1P3 2632", Country.CHN);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            c = new Car("Ford Mondeo", 2.2, CarType.COMBI, "blue", "1B2 1111", Country.USA);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            c = new Car("Mazda MX-5", 1.8, CarType.CABRIO, "red", "6T4 2526", Country.USA);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            c = new Car("VW Golf", 1.6, CarType.HATCHBACK, "yellow", "2B2 4946", Country.GERMANY);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            // insert a list of cars' number plates
            cars.put(CarManager.CAR_NUMBERS_KEY, carNumbers);
        } catch (Exception e) {
            log.warning("An exception occured while populating the database!");
        }
View Full Code Here


        utx = getUserTransactionFromJNDI();

        try {
            utx.begin();
            Car c = new Car("Ford Focus", 1.6, CarType.COMBI, "white", "FML 23-25", Country.CHN);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            c = new Car("BMW X3", 2.0, CarType.SEDAN, "gray", "1P3 2632", Country.CHN);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            c = new Car("Ford Mondeo", 2.2, CarType.COMBI, "blue", "1B2 1111", Country.USA);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            c = new Car("Mazda MX-5", 1.8, CarType.CABRIO, "red", "6T4 2526", Country.USA);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            c = new Car("VW Golf", 1.6, CarType.HATCHBACK, "yellow", "2B2 4946", Country.GERMANY);
            carNumbers.add(c.getNumberPlate());
            cars.put(CarManager.encode(c.getNumberPlate()), c);
            // insert a list of cars' number plates
            cars.put(CarManager.CAR_NUMBERS_KEY, carNumbers);
            utx.commit();
            log.info("Successfully imported data!");
        } catch (Exception e) {
View Full Code Here

    public void startup() {

    try {
      EntityManager em = provider.getEntityManagerFactory().createEntityManager();
            Car c = new Car("Ford Focus", 1.6, CarType.COMBI, "white", "FML 23-25", Country.CHN);
            em.persist(c);
            c = new Car("BMW X3", 2.0, CarType.SEDAN, "gray", "1P3 2632", Country.CHN);
            em.persist(c);
            c = new Car("Ford Mondeo", 2.2, CarType.COMBI, "blue", "1B2 1111", Country.USA);
            em.persist(c);
            c = new Car("Mazda MX-5", 1.8, CarType.CABRIO, "red", "6T4 2526", Country.USA);
            em.persist(c);
            c = new Car("VW Golf", 1.6, CarType.HATCHBACK, "yellow", "2B2 4946", Country.GERMANY);
            em.persist(c);
            em.close();
            log.info("Successfully imported data!");
        } catch (Exception e) {
            log.warning("An exception occured while populating the database " + e.getMessage());
View Full Code Here

    }

    public String removeCar(String numberPlate) {
        try {
          EntityManager em = provider.getEntityManagerFactory().createEntityManager();
          Car car = em.find(Car.class, numberPlate);
          em.remove(car);
          em.close();
            log.info("remote car " + numberPlate);
        } catch (Exception e) {
          log.warning("error whiling remote car " + numberPlate);
View Full Code Here

    removeCar("FML 23-25");
  }
 
  private void removeCar(String numberPlate) {
    EntityManager em = factory.createEntityManager();
    Car car = em.find(Car.class, numberPlate);
    em.remove(car);
    em.close();
    System.out.println("Remove Car " + numberPlate);
  }
View Full Code Here

        System.out.println("Get Car list " + result);
  }

  private void showCarDetails(String numberPlate) {
    EntityManager em = factory.createEntityManager();
    Car car = em.find(Car.class, numberPlate);
    em.close();
    System.out.println("Show Car Details " + car);
    }
View Full Code Here

    System.out.println("Show Car Details " + car);
    }

  private void addNewCar() {
    EntityManager em = factory.createEntityManager();
    Car c = new Car("Ford Focus", 1.6, CarType.COMBI, "white", "FML 23-25", Country.CHN);
        em.persist(c);
        em.close();
        System.out.println("Add a new car " + c);
  }
View Full Code Here

TOP

Related Classes of org.infinispan.demo.carmart.model.Car

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.