Examples of EODatabaseContext


Examples of com.webobjects.eoaccess.EODatabaseContext

      }
    }

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

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

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

Examples of com.webobjects.eoaccess.EODatabaseContext

    }
  }

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

    NSMutableArray beforeOpenChannels = new NSMutableArray();
    Enumeration beforeChannelsEnum = adaptorContext.channels().objectEnumerator();
    while (beforeChannelsEnum.hasMoreElements()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }
    try {
      EODatabaseChannel databaseChannel = databaseContext.availableChannel();
      EOAdaptorChannel adaptorChannel = databaseChannel.adaptorChannel();
      boolean channelOpen = adaptorChannel.isOpen();
      if (!channelOpen) {
        adaptorChannel.openChannel();
      }
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

      }
    }
  }

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

Examples of com.webobjects.eoaccess.EODatabaseContext

      if (aRelationship != null) {
        EOEditingContext anEditingContext = editingContext();
        EOGlobalID aGlobalID = anEditingContext.globalIDForObject(this);
        String aModelName = anEntity.model().name();
        EODatabaseContext aDatabaseContext = EOUtilities
            .databaseContextForModelNamed(anEditingContext,
                aModelName);
        aDatabaseContext.lock();
        NSDictionary aRow = aDatabaseContext
            .snapshotForGlobalID(aGlobalID);
        aDatabaseContext.unlock();
        EOQualifier aQualifier = aRelationship
            .qualifierWithSourceRow(aRow);

        return aQualifier;
      }
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

      }
    }

    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();
    while (beforeChannelsEnum.hasMoreElements()) {
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

    }
  }

  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()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }
    try {
      EODatabaseChannel databaseChannel = databaseContext.availableChannel();
      EOAdaptorChannel adaptorChannel = databaseChannel.adaptorChannel();
      boolean channelOpen = adaptorChannel.isOpen();
      if (!channelOpen) {
        adaptorChannel.openChannel();
      }
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

      }
    }
  }

  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

Examples of com.webobjects.eoaccess.EODatabaseContext

    if(false) {
      // AK: this should actually be the correct way...
      EOEditingContext ec = ERXEC.newEditingContext();
      ec.lock();
      try {
        EODatabaseContext dbc = ERXEOAccessUtilities.databaseContextForEntityNamed((EOObjectStoreCoordinator) ec.rootObjectStore(), entityName);
        dbc.lock();
        try {
          EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
          EOAdaptorChannel channel = (EOAdaptorChannel) dbc.adaptorContext().channels().lastObject();
          NSArray result = channel.primaryKeysForNewRowsWithEntity(increasePkBy, entity);
          return (Long) ((NSDictionary) result.lastObject()).allValues().lastObject();
        } finally {
          dbc.unlock();
        }
      } finally {
        ec.unlock();
      }
    } else {
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

  }

  private void createTables(boolean dropTables) {
    for (Enumeration e = EOModelGroup.defaultGroup().models().objectEnumerator(); e.hasMoreElements();) {
      final EOModel eomodel = (EOModel) e.nextElement();
      EODatabaseContext dbc = EOUtilities.databaseContextForModelNamed(ec, eomodel.name());
      dbc.lock();
      try {
        EOAdaptorChannel channel = dbc.availableChannel().adaptorChannel();
        if (eomodel.adaptorName().contains("JDBC")) {
          EOSynchronizationFactory syncFactory = (EOSynchronizationFactory) channel.adaptorContext().adaptor().synchronizationFactory();
          ERXSQLHelper helper = ERXSQLHelper.newSQLHelper(channel);
          NSDictionary options = helper.defaultOptionDictionary(true, dropTables);

          // Primary key support creation throws an unwanted exception
          // if
          // EO_PK_TABLE already
          // exists (e.g. in case of MySQL), so we add pk support in a
          // stand-alone step
          options = optionsWithPrimaryKeySupportDisabled(options);
          createPrimaryKeySupportForModel(eomodel, channel, syncFactory);

          String sqlScript = syncFactory.schemaCreationScriptForEntities(eomodel.entities(), options);
          log.info("Creating tables: " + eomodel.name());
          ERXJDBCUtilities.executeUpdateScript(channel, sqlScript, true);
        }
      } catch (SQLException ex) {
        log.error("Can't update: " + ex, ex);
      } finally {
        dbc.unlock();
      }
    }

  }
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

     *          The variable bindings, wrapped in {@link ERXSQLBinding} objects
     *
     * @return array of objects obtained by the query
     */
    public static NSArray selectObjectsOfEntityForSqlWithBindings( EOEditingContext ec, String entityName, String query, boolean refreshesCache, Integer fetchLimit, ERXSQLBinding... bindings ) {
        EODatabaseContext context = databaseContextForEntityName(ec,entityName);
        EOEntity entity = EOUtilities.entityNamed(ec, entityName);

        EOSQLExpression expression = context.adaptorContext().adaptor().expressionFactory().expressionForEntity( entity );

        String proceccedQuery = processedQueryString(query, expression, bindings);
        expression.setStatement(proceccedQuery);

        EOFetchSpecification spec = new EOFetchSpecification( entityName, null, null );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.