Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOEditingContext


  public ModalDialogExample(WOContext context) {
        super(context);
       
        // Fetch/create some sample data to edit
        EOEditingContext ec = session().defaultEditingContext();
       
        for (int i = 0; i < companyNames.count(); i++) {
      String name = companyNames.objectAtIndex(i);
          Company company = Company.fetchCompany(ec, Company.NAME_KEY, name);
          if (company == null) {
            company = Company.createCompany(ec, name);
          }
          companies.addObject(company);
    }
        ec.saveChanges();
       
        employee = Employee.fetchEmployee(ec, ERXQ.and(ERXQ.equals(Employee.FIRST_NAME_KEY, "Bill"),
                                   ERXQ.equals(Employee.LAST_NAME_KEY, "Wratchit")));
        if (employee == null) {
            Company company = Company.fetchCompany(ec, Company.NAME_KEY, companyNames.objectAtIndex(2));
            employee = Employee.createEmployee(ec, "Bill", "Wratchit", company);
        }
        ec.saveChanges();
  }
View Full Code Here


    _deep = deep;
    registerForNotifications();
  }

  private static String entityNameForClass(Class c) {
    EOEditingContext ec = ERXEC.newEditingContext();
    ec.lock();
    try {
      EOEntity entity = EOUtilities.entityForClass(ec, c);
      if (entity != null) {
        return entity.name();
      }
      throw new IllegalArgumentException("There is no entity for the class " + c + ".");
    }
    finally {
      ec.unlock();
    }
  }
View Full Code Here

        return result;
    }
   
    @Override
    public void setMasterObjectAndRelationshipKey(EOEnterpriseObject eo, String relationshipKey) {
        EOEditingContext ec = ERXEC.newEditingContext(eo.editingContext(), false); // no validation;
        setEditingContext(ec);
        EOEnterpriseObject localEO = EOUtilities.localInstanceOfObject(ec, eo);
        setObject(localEO);
        _relationshipKey = relationshipKey;
        if (object().isToManyKey(relationshipKey))
View Full Code Here

   * were changed.
   *
   * @param n
   */
  public void editingContextDidSaveChanges(NSNotification n) {
    EOEditingContext ec = (EOEditingContext) n.object();
    if (ec.parentObjectStore() instanceof EOObjectStoreCoordinator) {
      NSArray<T> entitiesInserted = relevantChanges(ec, n.userInfo(), EOEditingContext.InsertedKey);
      NSArray<T> entitiesUpdated = null;
      NSArray<T> entitiesDeleted = null;
      if (entitiesInserted.count() == 0 || _trackAllChanges) {
        entitiesUpdated = relevantChanges(ec, n.userInfo(), EOEditingContext.UpdatedKey);
View Full Code Here

    }
  }

  public static class SadEditingContextFactory implements EOEnterpriseObjectSerializer.EOEditingContextFactory {
    public EOEditingContext newEditingContext() {
      return new EOEditingContext();
    }
View Full Code Here

    if ( _dg == null ) {
      // Show most recent first.
      EOSortOrdering pkOrder = new EOSortOrdering("id", EOSortOrdering.CompareDescending);
      ERXFetchSpecification<TaskInfo> fs = new ERXFetchSpecification<TaskInfo>(TaskInfo.ENTITY_NAME, null, new ERXSortOrderings(pkOrder));
     
      EOEditingContext ec = ERXEC.newEditingContext();
      EODatabaseDataSource ds = new EODatabaseDataSource(ec, TaskInfo.ENTITY_NAME);
      ds.setFetchSpecification(fs);
     
      _dg = new ERXDisplayGroup<TaskInfo>();
      _dg.setDataSource(ds);
View Full Code Here

    public boolean verifySimpleData(NSArray data) {
      return simpleData.equals(data);
    }
   
    public NSArray eoData() {
      EOEditingContext editingContext = ERXEC.newEditingContext();
      NSArray<Company> originalCompanies = ExampleDataFactory.companies(editingContext);
      NSMutableArray<Company> companiesWithDupes = new NSMutableArray<Company>();
      companiesWithDupes.addObjectsFromArray(originalCompanies);
      companiesWithDupes.addObjectsFromArray(originalCompanies);
      return companiesWithDupes;
View Full Code Here

                    throw new IllegalStateException("<" + getClass().getName() + " could not find entity named " + anEntityName + ">");
                }
               
                EOEntity destinationEntity = entityWithEntityAndKeyPath(anEntity, _localRelationshipKey());
                Object _source = _localSourceObject();
                EOEditingContext anEditingContext = null;

                if (_source instanceof EOEnterpriseObject) {
                    anEditingContext = ((EOEnterpriseObject) _source).editingContext();
                }
View Full Code Here

//      return super.pageForConfigurationNamed(name, s);
      
    }

    private EOEntity _entityNamed(String entityName, WOSession session) {
        EOEditingContext ec = (session != null ? session.defaultEditingContext() : null);
        EOModelGroup group = (ec == null) ? EOModelGroup.defaultGroup() : EOUtilities.modelGroup(ec);
        return entityName != null ? group.entityNamed(entityName) : null;
    }
View Full Code Here

    }

  @Override
    public EditPageInterface editPageForNewObjectWithEntityNamed(String entityName, WOSession session) {
        EditPageInterface epi = (EditPageInterface) pageForConfigurationNamed("Create" + entityName, session);
        EOEditingContext peerContext = ERXEC.newEditingContext(session.defaultEditingContext().parentObjectStore());
        EOEnterpriseObject newObject = _newObjectWithEntity(_entityNamed(entityName, session), peerContext);
        epi.setObject(newObject);
        peerContext.hasChanges();
        return epi;
    }
View Full Code Here

TOP

Related Classes of com.webobjects.eocontrol.EOEditingContext

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.