Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOModelGroup


   * @throws IllegalAccessException
   * @throws InstantiationException
   */
  @SuppressWarnings("unchecked")
  public void migrateToLatest() {
    EOModelGroup modelGroup = EOModelGroup.defaultGroup();
    NSArray<String> modelNames;
    String modelNamesStr = ERXProperties.stringForKey("er.migration.modelNames");
    if (modelNamesStr == null) {
      ERXMigrator.log.warn("er.migration.modelNames is not set, defaulting to modelGroup.models() order instead.");
      modelNames = modelGroup.modelNames();
    }
    else {
      modelNames = NSArray.componentsSeparatedByString(modelNamesStr, ",");
    }
    String skipModelNamesStr = ERXProperties.stringForKey("er.migration.skipModelNames");
View Full Code Here


  protected Map<IERXMigration, ERXModelVersion> _buildDependenciesForModelsNamed(NSArray<String> modelNames, NSArray<String> skipModelNames) {
    Map<IERXMigration, ERXModelVersion> migrations = new LinkedHashMap<IERXMigration, ERXModelVersion>();
    try {
      Map<String, Integer> versions = new HashMap<String, Integer>();

      EOModelGroup modelGroup = EOModelGroup.defaultGroup();
      Enumeration modelNamesEnum = modelNames.objectEnumerator();
      while (modelNamesEnum.hasMoreElements()) {
        String modelName = (String) modelNamesEnum.nextElement();
        if (!skipModelNames.containsObject(modelName)) {
          EOModel model = modelGroup.modelNamed(modelName);
          if (model == null) {
            throw new IllegalArgumentException("There is no model named '" + modelName + "' in this model group.");
          }
          _buildDependenciesForModel(model, ERXMigrator.LATEST_VERSION, versions, migrations);
        }
      }

      Set<String> processedModelNames = new HashSet<String>();
      Set<String> pendingModelNames = new HashSet<String>(versions.keySet());
      while (!pendingModelNames.isEmpty()) {
        Iterator<String> modelNamesIter = pendingModelNames.iterator();
        while (modelNamesIter.hasNext()) {
          String modelName = modelNamesIter.next();
          EOModel model = modelGroup.modelNamed(modelName);
          Enumeration entitiesEnum = model.entities().objectEnumerator();
          while (entitiesEnum.hasMoreElements()) {
            EOEntity entity = (EOEntity) entitiesEnum.nextElement();
            EOEntity parentEntity = entity.parentEntity();
            if (parentEntity != null && !parentEntity.model().equals(model)) {
View Full Code Here

    EOModel dbUpdaterModel;
    if (_lastUpdatedModel == model) {
      dbUpdaterModel = _dbUpdaterModelCache;
    }
    else {
      EOModelGroup modelGroup = model.modelGroup();
      EOEntity prototypeEntity = modelGroup.entityNamed(ERXModelGroup.prototypeEntityNameForModel(model));
      boolean isWonderPrototype = (prototypeEntity != null && prototypeEntity.model().name().equals("erprototypes"));

      dbUpdaterModel = new EOModel();
      dbUpdaterModel.setConnectionDictionary(model.connectionDictionary());
      dbUpdaterModel.setAdaptorName(model.adaptorName());
View Full Code Here

  }

  private void reloadModel(EOModel model) {
    log.echo("JRebel: reloading EOModel " + model.name() + " (" + model.hashCode() + ")");
    EOModel newModel = new EOModel(model.pathURL());
    EOModelGroup modelGroup = model.modelGroup();
    modelGroup.removeModel(model);
    modelGroup.addModel(newModel);
    for (Map.Entry<EOObjectStoreCoordinator, EOModelGroup> entry : oscCache.entrySet()) {
      if (modelGroup == entry.getValue()) {
        EOObjectStoreCoordinator osc = entry.getKey();
        for (Object obj : osc.cooperatingObjectStores()) {
          EOCooperatingObjectStore store = (EOCooperatingObjectStore) obj;
View Full Code Here

    // over all the models that heard about via EOModelAddedNotification's
    // and loads all their shared EOs at once.
    public void objectStoreWasAdded(NSNotification aNotification) {
        if (!_loadingComplete) {
            if (_modelList.count() == 0) {
                EOModelGroup group = EOModelGroup.modelGroupForObjectStoreCoordinator((EOObjectStoreCoordinator)aNotification.object());
                if (group != null && group.models().count() == 0) {
                    throw new RuntimeException("No models found in default group");
                }
                // internal list empty; drop it and use modelgroup's.
                _modelList = new NSMutableArray(group.models());
            }
            _loadingComplete = true; // make sure we only do this once.
            EOModel currentModel = null;
            try {
                NSNotificationCenter.defaultCenter().addObserver(this,
View Full Code Here

    public boolean supportsDirectColumnRenaming() {
        return true;
    }
   
    private EOEntity entityForTableName(String tableName) {
        EOModelGroup modelGroup = EOModelGroup.globalModelGroup();
            for (EOModel model : modelGroup.models()) {
                for (EOEntity entity : model.entities()) {
                    if (entity.externalName() != null && entity.externalName().equalsIgnoreCase(tableName)) {
                        return entity;
                    }
                }
View Full Code Here

        if (null==dataSource()) {
            setDataSource((EODatabaseDataSource) _WOJExtensionsUtil.valueForBindingOrNull("dataSource",this));
            if (null==dataSource()) {
                String anEntityName = _localSourceEntityName();
                EOModelGroup aModelGroup = EOModelGroup.defaultGroup();
                EOEntity anEntity = aModelGroup.entityNamed(anEntityName);

                if (anEntity == null) {
                    throw new IllegalStateException("<" + getClass().getName() + " could not find entity named " + anEntityName + ">");
                }
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOModelGroup

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.