Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSMutableArray$ListItr


    String prototypeEntityName = (String) databaseConfig.get("prototypeEntityName");
    if (prototypeEntityName != null) {
      replacePrototypes(_modelGroup, prototypeEntityName);
    }

    _entities = new NSMutableArray();
    _model = _modelGroup.modelNamed(modelName);

    NSDictionary defaultConnectionDictionary;
    Map overrideConnectionDictionary = (Map) databaseConfig.get("connectionDictionary");
    if (overrideConnectionDictionary != null) {
View Full Code Here


      classProperties = NSArray.EmptyArray;
    }
    if (attributesUsedForLocking == null) {
      attributesUsedForLocking = NSArray.EmptyArray;
    }
    NSMutableArray mutableClassProperties = classProperties.mutableClone();
    NSMutableArray mutableAttributesUsedForLocking = attributesUsedForLocking.mutableClone();
    for (Enumeration e = attributes.objectEnumerator(); e.hasMoreElements();) {
      EOAttribute attribute = (EOAttribute) e.nextElement();
      NSDictionary userInfo = attribute.userInfo();
      String name = attribute.name();
      if (userInfo != null) {
        Object l = userInfo.valueForKey("ERXLanguages");
        if (l != null && !(l instanceof NSArray)) {
          l = (entity.model().userInfo() != null ? entity.model().userInfo().valueForKey("ERXLanguages") : null);
        }

        NSArray languages = (NSArray) l;
        if (languages != null && languages.count() > 0) {
          String columnName = attribute.columnName();
          for (int i = 0; i < languages.count(); i++) {
            String language = (String) languages.objectAtIndex(i);
            String newName = name + "_" + language;
            String newColumnName = columnName + "_" + language;

            EOAttribute newAttribute = new EOAttribute();
            newAttribute.setName(newName);
            entity.addAttribute(newAttribute);

            newAttribute.setPrototype(attribute.prototype());
            newAttribute.setColumnName(newColumnName);
            newAttribute.setAllowsNull(attribute.allowsNull());
            newAttribute.setClassName(attribute.className());
            newAttribute.setExternalType(attribute.externalType());
            newAttribute.setWidth(attribute.width());
            newAttribute.setUserInfo(attribute.userInfo());

            if (classProperties.containsObject(attribute)) {
              mutableClassProperties.addObject(newAttribute);
            }
            if (attributesUsedForLocking.containsObject(attribute)) {
              mutableAttributesUsedForLocking.addObject(newAttribute);
            }
          }
          entity.removeAttribute(attribute);
          mutableClassProperties.removeObject(attribute);
          mutableAttributesUsedForLocking.removeObject(attribute);
        }
      }
      entity.setClassProperties(mutableClassProperties);
      entity.setAttributesUsedForLocking(mutableAttributesUsedForLocking);
    }
View Full Code Here

    return inherited;
  }

  protected void fixDuplicateSingleTableInheritanceDropStatements(EOSynchronizationFactory syncFactory, NSMutableDictionary flags, StringBuffer sqlBuffer) {
    if ("YES".equals(flags.valueForKey(EOSchemaGeneration.DropTablesKey))) {
      NSMutableArray dropEntities = new NSMutableArray(_entities);
      for (int entityNum = dropEntities.count() - 1; entityNum >= 0; entityNum--) {
        EOEntity entity = (EOEntity) dropEntities.objectAtIndex(entityNum);
        if (isSingleTableInheritance(entity)) {
          dropEntities.removeObjectAtIndex(entityNum);
        }
      }
      if (dropEntities.count() != _entities.count()) {
        NSMutableDictionary dropFlags = new NSMutableDictionary();
        dropFlags.takeValueForKey("YES", EOSchemaGeneration.DropTablesKey);
        dropFlags.takeValueForKey("NO", EOSchemaGeneration.DropPrimaryKeySupportKey);
        dropFlags.takeValueForKey("NO", EOSchemaGeneration.CreateTablesKey);
        dropFlags.takeValueForKey("NO", EOSchemaGeneration.CreatePrimaryKeySupportKey);
View Full Code Here

    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 {
      Enumeration afterChannelsEnum = ac.channels().objectEnumerator();
      while (afterChannelsEnum.hasMoreElements()) {
        EOAdaptorChannel channel = (EOAdaptorChannel) afterChannelsEnum.nextElement();
        if (channel.isOpen() && !beforeOpenChannels.containsObject(channel)) {
          channel.closeChannel();
        }
      }
    }
View Full Code Here

  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();
      }
      try {
        JDBCContext jdbccontext = (JDBCContext) adaptorChannel.adaptorContext();
        try {
          jdbccontext.beginTransaction();
          Connection conn = jdbccontext.connection();
          Statement stmt = conn.createStatement();
          stmt.executeUpdate(sql);
          conn.commit();
        } catch (SQLException sqlexception) {
          sqlexception.printStackTrace(System.out);
          jdbccontext.rollbackTransaction();
          throw sqlexception;
        }
      } finally {
        if (!channelOpen) {
          adaptorChannel.closeChannel();
        }
      }
    } finally {
      Enumeration afterChannelsEnum = adaptorContext.channels().objectEnumerator();
      while (afterChannelsEnum.hasMoreElements()) {
        EOAdaptorChannel channel = (EOAdaptorChannel) afterChannelsEnum.nextElement();
        if (channel.isOpen() && !beforeOpenChannels.containsObject(channel)) {
          channel.closeChannel();
        }
      }
    }
  }
View Full Code Here

          nsDict.setObjectForKey(value, key);
        }
      }
      result = nsDict;
    } else if (obj instanceof List) {
      NSMutableArray nsArray = new NSMutableArray();
      List list = (List) obj;
      Iterator valuesEnum = list.iterator();
      while (valuesEnum.hasNext()) {
        Object value = valuesEnum.next();
        if (value != null) {
          value = toWOCollections(value);
          nsArray.addObject(value);
        }
      }
      result = nsArray;
    } else if (obj instanceof Set) {
      Set set = (Set) obj;
View Full Code Here

    String prototypeEntityName = (String) databaseConfig.get("prototypeEntityName");
    if (prototypeEntityName != null) {
      replacePrototypes(_modelGroup, prototypeEntityName);
    }

    _entities = new NSMutableArray();
    _model = _modelGroup.modelNamed(modelName);

    NSDictionary defaultConnectionDictionary;
    Map overrideConnectionDictionary = (Map) databaseConfig.get("connectionDictionary");
    if (overrideConnectionDictionary != null) {
View Full Code Here

      classProperties = NSArray.EmptyArray;
    }
    if (attributesUsedForLocking == null) {
      attributesUsedForLocking = NSArray.EmptyArray;
    }
    NSMutableArray mutableClassProperties = classProperties.mutableClone();
    NSMutableArray mutableAttributesUsedForLocking = attributesUsedForLocking.mutableClone();
    for (Enumeration e = attributes.objectEnumerator(); e.hasMoreElements();) {
      EOAttribute attribute = (EOAttribute) e.nextElement();
      NSDictionary userInfo = attribute.userInfo();
      String name = attribute.name();
      if (userInfo != null) {
        Object l = userInfo.valueForKey("ERXLanguages");
        if (l != null && !(l instanceof NSArray)) {
          l = (entity.model().userInfo() != null ? entity.model().userInfo().valueForKey("ERXLanguages") : null);
        }

        NSArray languages = (NSArray) l;
        if (languages != null && languages.count() > 0) {
          String columnName = attribute.columnName();
          for (int i = 0; i < languages.count(); i++) {
            String language = (String) languages.objectAtIndex(i);
            String newName = name + "_" + language;
            String newColumnName = columnName + "_" + language;

            EOAttribute newAttribute = new EOAttribute();
            newAttribute.setName(newName);
            entity.addAttribute(newAttribute);

            newAttribute.setPrototype(attribute.prototype());
            newAttribute.setColumnName(newColumnName);
            newAttribute.setAllowsNull(attribute.allowsNull());
            newAttribute.setClassName(attribute.className());
            newAttribute.setExternalType(attribute.externalType());
            newAttribute.setWidth(attribute.width());
            newAttribute.setUserInfo(attribute.userInfo());

            if (classProperties.containsObject(attribute)) {
              mutableClassProperties.addObject(newAttribute);
            }
            if (attributesUsedForLocking.containsObject(attribute)) {
              mutableAttributesUsedForLocking.addObject(newAttribute);
            }
          }
          entity.removeAttribute(attribute);
          mutableClassProperties.removeObject(attribute);
          mutableAttributesUsedForLocking.removeObject(attribute);
        }
      }
      entity.setClassProperties(mutableClassProperties);
      entity.setAttributesUsedForLocking(mutableAttributesUsedForLocking);
    }
View Full Code Here

    return inherited;
  }

  protected void fixDuplicateSingleTableInheritanceDropStatements(EOSynchronizationFactory syncFactory, NSMutableDictionary flags, StringBuffer sqlBuffer) {
    if ("YES".equals(flags.valueForKey(EOSchemaGeneration.DropTablesKey))) {
      NSMutableArray dropEntities = new NSMutableArray(_entities);
      for (int entityNum = dropEntities.count() - 1; entityNum >= 0; entityNum--) {
        EOEntity entity = (EOEntity) dropEntities.objectAtIndex(entityNum);
        if (isSingleTableInheritance(entity)) {
          dropEntities.removeObjectAtIndex(entityNum);
        }
      }
      if (dropEntities.count() != _entities.count()) {
        NSMutableDictionary dropFlags = new NSMutableDictionary();
        dropFlags.takeValueForKey("YES", EOSchemaGeneration.DropTablesKey);
        dropFlags.takeValueForKey("NO", EOSchemaGeneration.DropPrimaryKeySupportKey);
        dropFlags.takeValueForKey("NO", EOSchemaGeneration.CreateTablesKey);
        dropFlags.takeValueForKey("NO", EOSchemaGeneration.CreatePrimaryKeySupportKey);
View Full Code Here

    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 {
      Enumeration afterChannelsEnum = ac.channels().objectEnumerator();
      while (afterChannelsEnum.hasMoreElements()) {
        EOAdaptorChannel channel = (EOAdaptorChannel) afterChannelsEnum.nextElement();
        if (channel.isOpen() && !beforeOpenChannels.containsObject(channel)) {
          channel.closeChannel();
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSMutableArray$ListItr

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.