Package er.extensions.eof

Examples of er.extensions.eof.ERXEC$DefaultFactory


        // as we only need a bit of reference data anyway, we just fake we fetched...
        ERXEC.setFactory(new ERXEC.DefaultFactory() {

      @Override
      protected EOEditingContext _createEditingContext(EOObjectStore parent) {
        return new ERXEC(parent) {

          @Override
          public NSArray objectsWithFetchSpecification(EOFetchSpecification eofetchspecification, EOEditingContext eoeditingcontext) {
            NSMutableArray result = new NSMutableArray();
            for (int i = 0; i < 5; i++) {
View Full Code Here


  public void testDB2CreateSchema() {
    //    ERXTestUtilities.fixModelsForAdaptorNamed(adaptorName);


    ERXEC ec = (ERXEC) ERXEC.newEditingContext();
    ec.lock();
    try {
      ERXEOAccessUtilities.ChannelAction action = new ERXEOAccessUtilities.ChannelAction() {
        @Override
        protected int doPerform(EOAdaptorChannel channel) {
          try {
            ERXSQLHelper helper = ERXSQLHelper.newSQLHelper(adaptorName);
            String sql = helper.createSchemaSQLForEntitiesInModelAndOptions(model.entities(), model, helper.defaultOptionDictionary(false, true)) ;
            log.debug(sql);
            try {
              ERXJDBCUtilities.executeUpdateScript(channel, sql);
            } catch (Throwable e) {
              log.info("drop failure");
            }
            sql = helper.createSchemaSQLForEntitiesInModelAndOptions(model.entities(), model, helper.defaultOptionDictionary(true, false)) ;
            log.debug(sql);
            ERXJDBCUtilities.executeUpdateScript(channel, sql);
          }
          catch (SQLException e) {
            throw new NSForwardException(e);
          }
          return 0;
        }
      };
      action.perform(ec, model.name());
    } finally {
      ec.unlock();
    }
  }
View Full Code Here

   
  }


  protected void resetData() {
    ERXEC ec = (ERXEC) ERXEC.newEditingContext();
    ERXEOAccessUtilities.ChannelAction action = new ERXEOAccessUtilities.ChannelAction() {
      @Override
      protected int doPerform(EOAdaptorChannel channel) {
        try {
          ERXJDBCUtilities.executeUpdateScript(channel, "update city set countryID = null;\n" +
View Full Code Here

    private boolean run = true;
    @Override
    public void run() {
     
      while (getRun()) {
        ERXEC ec = (ERXEC) ERXEC.newEditingContext();
        ec.lock();
        try {
         
          NSArray<City> cities = City.fetchCities(ec, City.NAME.likeInsensitive(RandomStringUtils.randomAlphabetic(1) + "*"), City.NAME.ascs());
         
        } finally {
          ec.unlock();
        }
      }
    }
View Full Code Here

  public static class InsertTask implements Runnable {

    @Override
    public void run() {
      for (int i = 0; i < 25; i++) {
        ERXEC ec = (ERXEC) ERXEC.newEditingContext();
        ec.lock();
        try {
          Country country = Country.fetchAllCountries(ec).lastObject();
          City city = City.createCity(ec, RandomStringUtils.randomAlphabetic(15));
          city.setCountryRelationship(country);
         
          ec.saveChanges();
        } finally {
          ec.unlock();
        }
       
      }
    }
View Full Code Here

  public static class UpdateTask implements Runnable {

    @Override
    public void run() {
      for (int i = 0; i < 25; i++) {
        ERXEC ec = (ERXEC) ERXEC.newEditingContext();
        ec.lock();
        try {
          City city = City.fetchCity(ec, City.NAME.eq("Amsterdam"));
         
          if (city != null) {
            city.setPopulation(RandomUtils.nextInt(3));
          }
         
          ec.saveChanges();
        } finally {
          ec.unlock();
        }
       
      }
     
    }
View Full Code Here

    resetData();
  }


  public void testInsert() {
    ERXEC ec = (ERXEC) ERXEC.newEditingContext();
    ec.lock();
    try {
      City city = City.createCity(ec, "Washington");
      city.setDistict("DC");
      city.setPopulation(650000);
      city.setDescription("This is some text to make sure long strings work");


      log.debug(ERXModelGroup.prototypeEntityNameForModel(model));
      //Employee emp = Employee.createEmployee(ec, "Bugs", "Bunny", false, Company.createCompany(ec, "Boston Opera"));

      ec.saveChanges();

      Integer cnt = ERXEOControlUtilities.objectCountWithQualifier(ec, City.ENTITY_NAME, City.DISTICT.eq("DC"));

      assertNotNull(cnt);
      assertEquals(Integer.valueOf(1), cnt);

      Country country = Country.createCountry(ec, "USA", "United States of America");
      country.setCapital(city);
      try {
        // make sure blobs work
        NSData flag = new NSData(ERXFileUtilities.inputStreamForResourceNamed("us.png", null, null), 1024);
        country.setFlag(flag);
      } catch (IOException e) {
        log.error(org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e), e);
        throw new RuntimeException(e.getMessage(), e);
      }
      ec.saveChanges();
      cnt = ERXEOControlUtilities.objectCountWithQualifier(ec, Country.ENTITY_NAME, Country.CODE.eq("USA"));

      assertNotNull(cnt);
      assertEquals(Integer.valueOf(1), cnt);
    } finally {
      ec.unlock();
    }
  }
View Full Code Here

    }
  }


  public void testUpdate() {
    ERXEC ec = (ERXEC) ERXEC.newEditingContext();
    ec.lock();
    try {
      Country country = Country.fetchCountry(ec, Country.CODE.eq("NLD"));
      final String headOfState = "Queen " + country.headOfState();
      country.setHeadOfState(headOfState);
      ec.saveChanges();

      Integer cnt = ERXEOControlUtilities.objectCountWithQualifier(ec, Country.ENTITY_NAME, Country.HEAD_OF_STATE.eq(headOfState));

      assertNotNull(cnt);
      assertEquals(Integer.valueOf(1), cnt);
    } finally {
      ec.unlock();
    }

  }
View Full Code Here

    }

  }

  public void testDelete() {
    ERXEC ec = (ERXEC) ERXEC.newEditingContext();
    ec.lock();
    try {
      Country country = Country.fetchCountry(ec, Country.CODE.eq("NOR"));
      country.delete();
      ec.saveChanges();

      Integer cnt = ERXEOControlUtilities.objectCountWithQualifier(ec, Country.ENTITY_NAME, Country.CODE.eq("NOR"));

      assertNotNull(cnt);
      assertEquals(Integer.valueOf(0), cnt);
    } finally {
      ec.unlock();
    }

  }
View Full Code Here

    super.setUp();
    resetData();
  }

  public void testFetchAll() {
    ERXEC ec = (ERXEC) ERXEC.newEditingContext();
    ec.lock();
    try {
     
      NSArray<City> cities = City.fetchAllCities(ec);
     
      assertNotNull(cities);
      assertEquals(28, cities.count());
    } finally {
      ec.unlock();
    }
  }
View Full Code Here

TOP

Related Classes of er.extensions.eof.ERXEC$DefaultFactory

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.