Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOSynchronizationFactory


    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()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }

    StringBuffer sqlBuffer = new StringBuffer();
    fixDuplicateSingleTableInheritanceDropStatements(sf, flags, sqlBuffer);

    try {
      String sql = sf.schemaCreationScriptForEntities(_entities, flags);
      sql = sql.replaceAll("CREATE TABLE ([^\\s(]+)\\(", "CREATE TABLE $1 (");
      sqlBuffer.append(sql);

      callModelProcessorMethodIfExists("processSQL", new Object[] { sqlBuffer, _model, _entities, flags });
    } finally {
View Full Code Here


    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()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }

    StringBuffer sqlBuffer = new StringBuffer();
    fixDuplicateSingleTableInheritanceDropStatements(sf, flags, sqlBuffer);

    try {
      String sql = sf.schemaCreationScriptForEntities(_entities, flags);
      sql = sql.replaceAll("CREATE TABLE ([^\\s(]+)\\(", "CREATE TABLE $1 (");
      sqlBuffer.append(sql);

      callModelProcessorMethodIfExists("processSQL", new Object[] { sqlBuffer, _model, _entities, flags });
    } finally {
View Full Code Here

      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);
View Full Code Here

          }
          // timc 2006-11-06 row.objectForKey("COUNT") returns BigDecimal not Long
          //if( Long.valueOf( 0 ).equals( row.objectForKey( "COUNT" ) ) ) {
          Number numCount = (Number) row.objectForKey("COUNT");
          if (numCount != null && numCount.longValue() == 0L) {
            EOSynchronizationFactory f = createSynchronizationFactory();
            NSArray<EOSQLExpression> statements = f.primaryKeySupportStatementsForEntityGroup(new NSArray<EOEntity>(entity));
            int stmCount = statements.count();
            for (int i = 0; i < stmCount; i++) {
              channel.evaluateExpression(statements.objectAtIndex(i));
            }
          }
View Full Code Here

    optionsCreateTables.setObjectForKey("YES", EOSchemaGeneration.PrimaryKeyConstraintsKey);
    optionsCreateTables.setObjectForKey("NO", EOSchemaGeneration.ForeignKeyConstraintsKey);
    optionsCreateTables.setObjectForKey("NO", EOSchemaGeneration.CreateDatabaseKey);
    optionsCreateTables.setObjectForKey("NO", EOSchemaGeneration.DropDatabaseKey);
    StringBuilder sqlBuffer = new StringBuilder();
    EOSynchronizationFactory sf = ((JDBCAdaptor) adaptor).plugIn().synchronizationFactory();
    String creationScript = sf.schemaCreationScriptForEntities(entities, optionsCreateTables);
    sqlBuffer.append(creationScript);
   
    NSMutableArray<EOEntity> foreignKeyEntities = entities.mutableClone();
    for (EOEntity entity : entities) {
      for (EORelationship relationship : entity.relationships()) {
        if (!relationship.isToMany()) {
          EOEntity destinationEntity = relationship.destinationEntity();
          if (destinationEntity.model() != entity.model()) {
            foreignKeyEntities.addObject(destinationEntity);
          }
        }
      }
    }
   
    NSMutableDictionary<String, String> optionsCreateForeignKeys = new NSMutableDictionary<String, String>();
    optionsCreateForeignKeys.setObjectForKey("NO", EOSchemaGeneration.DropTablesKey);
    optionsCreateForeignKeys.setObjectForKey("NO", EOSchemaGeneration.DropPrimaryKeySupportKey);
    optionsCreateForeignKeys.setObjectForKey("NO", EOSchemaGeneration.CreateTablesKey);
    optionsCreateForeignKeys.setObjectForKey("NO", EOSchemaGeneration.CreatePrimaryKeySupportKey);
    optionsCreateForeignKeys.setObjectForKey("NO", EOSchemaGeneration.PrimaryKeyConstraintsKey);
    optionsCreateForeignKeys.setObjectForKey("YES", EOSchemaGeneration.ForeignKeyConstraintsKey);
    optionsCreateForeignKeys.setObjectForKey("NO", EOSchemaGeneration.CreateDatabaseKey);
    optionsCreateForeignKeys.setObjectForKey("NO", EOSchemaGeneration.DropDatabaseKey);
    String foreignKeyScript = sf.schemaCreationScriptForEntities(foreignKeyEntities, optionsCreateForeignKeys);
    sqlBuffer.append(foreignKeyScript);
   
    return sqlBuffer.toString();
  }
View Full Code Here

   *            the options (@see
   *            createSchemaSQLForEntitiesInModelWithNameAndOptions)
   * @return a sql script
   */
  public String createSchemaSQLForEntitiesWithOptions(NSArray<EOEntity> entities, EOAdaptor adaptor, NSDictionary<String, String> optionsDictionary) {
    EOSynchronizationFactory sf = ((JDBCAdaptor) adaptor).plugIn().synchronizationFactory();
    String creationScript = sf.schemaCreationScriptForEntities(entities, optionsDictionary)
    return creationScript;
  }
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOSynchronizationFactory

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.