Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EODatabase


      }
    }

    callModelProcessorMethodIfExists("processModel", new Object[] { _model, _entities, flags });

    EODatabaseContext dbc = new EODatabaseContext(new EODatabase(_model));
    EOAdaptorContext ac = dbc.adaptorContext();
    EOSynchronizationFactory sf = ((JDBCAdaptor) ac.adaptor()).plugIn().synchronizationFactory();

    NSMutableArray beforeOpenChannels = new NSMutableArray();
    Enumeration beforeChannelsEnum = ac.channels().objectEnumerator();
View Full Code Here


    }
  }

  public void executeSQL(String sql) throws SQLException {
    fixClassPath();
    EODatabaseContext databaseContext = new EODatabaseContext(new EODatabase(_model));
    EOAdaptorContext adaptorContext = databaseContext.adaptorContext();

    NSMutableArray beforeOpenChannels = new NSMutableArray();
    Enumeration beforeChannelsEnum = adaptorContext.channels().objectEnumerator();
    while (beforeChannelsEnum.hasMoreElements()) {
View Full Code Here

      }
    }
  }

  public Map externalTypes() {
    EODatabaseContext dbc = new EODatabaseContext(new EODatabase(_model));
    EOAdaptorContext ac = dbc.adaptorContext();
    NSDictionary jdbc2Info = ((JDBCAdaptor) ac.adaptor()).plugIn().jdbcInfo();
    return (Map) EOFSQLUtils53.toJavaCollections(jdbc2Info);
  }
View Full Code Here

     */
    public static void clearSnapshotForRelationshipNamed(EOEnterpriseObject eo, String relationshipName) {
        EOEditingContext ec = eo.editingContext();
        EOModel model = EOUtilities.entityForObject(ec, eo).model();
        EODatabaseContext dbc = EODatabaseContext.registeredDatabaseContextForModel(model, ec);
        EODatabase database = dbc.database();
        ERXEOControlUtilities.clearSnapshotForRelationshipNamedInDatabase(eo, relationshipName, database);
    }
View Full Code Here

            String entityName = (String)entitiesEnumerator.nextElement();
            if (! ERCNSnapshot.shouldSynchronizeEntity(entityName))   continue;

            EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);
            EODatabaseContext dbContext = ERCNNotificationCoordinator.databaseContextForEntityNamed(entityName, ec);
            EODatabase database = dbContext.database();
            NSArray snapshots = (NSArray)ercnSnapshot.shapshotsForUpdateGroupedByEntity().objectForKey(entityName);
            Enumeration snapshotsEnumerator = snapshots.objectEnumerator();
            while (snapshotsEnumerator.hasMoreElements()) {
                NSDictionary snapshot = (NSDictionary)snapshotsEnumerator.nextElement();
                if (NSLog.debug.isEnabled())
                    NSLog.debug.appendln(ERCNNotificationCoordinator.LOG_HEADER + "Snapshot: " + snapshot);
                if (snapshot != null) {
                    EOGlobalID globalID = entity.globalIDForRow(snapshot);
                    dbContext.lock();
                    database.forgetSnapshotForGlobalID(globalID);
                    database.recordSnapshotForGlobalID(snapshot, globalID);
                    dbContext.unlock();
                }
            }
        }
        ec.unlock();
View Full Code Here

        EODatabaseContext dbc = (EODatabaseContext) dbcs.objectForKey(key);
        if (dbc == null) {
          dbc = ERXEOAccessUtilities.databaseContextForEntityNamed(osc, entityName);
          dbcs.setObjectForKey(dbc, key);
        }
        EODatabase database = dbc.database();
        NSMutableDictionary snapshotsByGlobalID = new NSMutableDictionary();
        for (Enumeration snapshotsEnumerator = snapshots.objectEnumerator(); snapshotsEnumerator.hasMoreElements();) {
          NSDictionary snapshot = (NSDictionary) snapshotsEnumerator.nextElement();
          EOGlobalID globalID = entity.globalIDForRow(snapshot);
          snapshotsByGlobalID.setObjectForKey(snapshot, globalID);
View Full Code Here

        Enumeration cacheChangeEnum = remoteChange.remoteCacheChanges().objectEnumerator();
        while (cacheChangeEnum.hasMoreElements()) {
          ERXDatabase.CacheChange cacheChange = (ERXDatabase.CacheChange) cacheChangeEnum.nextElement();
          EOKeyGlobalID gid = (EOKeyGlobalID) cacheChange.gid();
          EODatabaseContext dbc = ERXEOAccessUtilities.databaseContextForEntityNamed(osc, gid.entityName());
          EODatabase database = dbc.database();
          dbc.lock();
          try {
            if (cacheChange instanceof ERXDatabase.SnapshotInserted) {
              _insertCacheChangeProcessor.processCacheChange(dbc, database, cacheChange);
            }
View Full Code Here

         log.warn("Model " + model.name() + " failed: " + e.getMessage());
       }
       if (databaseContext != null) {
         databaseContext.lock();
         try {
           EODatabase database = databaseContext.database();
           if (!verifiedDatabases.containsObject(database)) {
             Enumeration gidEnum = database.snapshots().keyEnumerator();
             while (gidEnum.hasMoreElements()) {
               EOGlobalID gid = (EOGlobalID) gidEnum.nextElement();
               if (gid instanceof EOKeyGlobalID) {
                 EOEnterpriseObject eo = null;
                 EOKeyGlobalID keyGID = (EOKeyGlobalID) gid;
                 String entityName = keyGID.entityName();
                 EOEntity entity = modelGroup.entityNamed(entityName);
                 NSDictionary snapshot = database.snapshotForGlobalID(gid);
                 if (snapshot != null) {
                   EOQualifier gidQualifier = entity.qualifierForPrimaryKey(entity.primaryKeyForGlobalID(gid));
                   EOFetchSpecification gidFetchSpec = new EOFetchSpecification(entityName, gidQualifier, null);

                   NSMutableDictionary databaseSnapshotClone;
                   NSMutableDictionary memorySnapshotClone = snapshot.mutableClone();
                   EOAdaptorChannel channel = databaseContext.availableChannel().adaptorChannel();
                   channel.openChannel();
                   channel.selectAttributes(entity.attributesToFetch(), gidFetchSpec, false, entity);
                   try {
                     databaseSnapshotClone = channel.fetchRow().mutableClone();
                   }
                   finally {
                     channel.cancelFetch();
                   }
                   // gidFetchSpec.setRefreshesRefetchedObjects(true);
                   // NSArray databaseEOs = editingContext.objectsWithFetchSpecification(gidFetchSpec);
                   if (databaseSnapshotClone == null) {
                     mismatches.addObject(gid + " was deleted in the database, but the snapshot still exists: " + memorySnapshotClone);
                   }
                   else {
                     // NSMutableDictionary refreshedSnapshotClone =
                     // database.snapshotForGlobalID(gid).mutableClone();
                     ERXDictionaryUtilities.removeMatchingEntries(memorySnapshotClone, databaseSnapshotClone);
                     if (databaseSnapshotClone.count() > 0 || memorySnapshotClone.count() > 0) {
                       mismatches.addObject(gid + " doesn't match the database: original = " + memorySnapshotClone + "; database = " + databaseSnapshotClone);
                     }
                     eo = (EOEnterpriseObject) editingContext.objectsWithFetchSpecification(gidFetchSpec).objectAtIndex(0);
                   }
                 }

                 if (eo != null) {
                   Enumeration relationshipsEnum = entity.relationships().objectEnumerator();
                   while (relationshipsEnum.hasMoreElements()) {
                     EORelationship relationship = (EORelationship) relationshipsEnum.nextElement();
                     String relationshipName = relationship.name();
                     NSArray originalDestinationGIDs = database.snapshotForSourceGlobalID(keyGID, relationshipName);
                     if (originalDestinationGIDs != null) {
                       NSMutableArray newDestinationGIDs = new NSMutableArray();
                       EOQualifier qualifier = relationship.qualifierWithSourceRow(database.snapshotForGlobalID(keyGID));
                       EOFetchSpecification relationshipFetchSpec = new EOFetchSpecification(entityName, qualifier, null);
                       EOAdaptorChannel channel = databaseContext.availableChannel().adaptorChannel();
                       channel.openChannel();
                       try {
                         channel.selectAttributes(relationship.destinationEntity().attributesToFetch(), relationshipFetchSpec, false, relationship.destinationEntity());
View Full Code Here

        dbc = (EODatabaseContext) objectStore;
      }
    }

    if (dbc == null) {
      dbc = (EODatabaseContext) _NSUtilities.instantiateObject(EODatabaseContext.contextClassToRegister(), new Class[] { com.webobjects.eoaccess.EODatabase.class }, new Object[] { new EODatabase(model) }, true, false);
      coordinator.addCooperatingObjectStore(dbc);
    }
    return dbc;
  }
View Full Code Here

      NSArray<EOGlobalID> gids = cache.objectForKey(identifier);
      NSArray result = null;
     
      if(gids != null) {
        NSMutableArray<EOEnterpriseObject> eos = new NSMutableArray<EOEnterpriseObject>(gids.count());
        EODatabase database = dbc.database();
        for (EOGlobalID gid : gids) {
          NSDictionary snapshotForGlobalID = database.snapshotForGlobalID(gid);
          if(snapshotForGlobalID == null || dbc.snapshotForGlobalID(gid, ec.fetchTimestamp()) == null) {
            // not found with recent timestamp
            return null;
          }
          database.recordSnapshotForGlobalID(snapshotForGlobalID, gid);
                EOEnterpriseObject eo = ec.faultForGlobalID(gid, ec);
                eos.addObject(eo);
        }
        result = eos;
      }
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EODatabase

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.