Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOModel


         * @param entity to create the class description for
         * @return new class description for the given entity
         */
        protected ERXEntityClassDescription newClassDescriptionForEntity(EOEntity entity) {
          String key = entity.name();
          EOModel model = entity.model();
          if (model != null) {
            key = model.name() + " " + key;
          }
          ERXEntityClassDescription classDescription = (ERXEntityClassDescription)_classDescriptionForEntity.objectForKey(key);
          if (classDescription == null) {
            classDescription = new ERXEntityClassDescription(entity);
            _classDescriptionForEntity.setObjectForKey(classDescription, key);
View Full Code Here


     *          The entity name
     * @return The database context for the given editing context and entity name
     */
    private static EODatabaseContext databaseContextForEntityName( EOEditingContext ec, String entityName ) {
        EOModelGroup group = EOUtilities.modelGroup( ec );
        EOModel model = group.entityNamed(entityName).model();
        if (model == null) {
            throw new RuntimeException("Entity named " + entityName + " not found in the model group.");
        }
        return EODatabaseContext.registeredDatabaseContextForModel(model, ec);
    }
View Full Code Here

     *          The model name
     * @return The database context for the given editing context and model name
     */
    private static EODatabaseContext databaseContextForModelName(EOEditingContext ec, String modelName) {
        EOModelGroup group = EOUtilities.modelGroup( ec );
        EOModel model = group.modelNamed(modelName);
        if (model == null) {
            throw new RuntimeException("Model " + modelName + " not found in the model group.");
        }
        return EODatabaseContext.registeredDatabaseContextForModel(model, ec);
    }
View Full Code Here

        }
    }

    public void indexAllObjects(EOModelGroup group) {
        for (Enumeration models = group.models().objectEnumerator(); models.hasMoreElements();) {
            EOModel model = (EOModel) models.nextElement();
            indexAllObjects(model);
        }
    }
View Full Code Here

     * @param eo enterprise object
     * @param relationshipName relationship name
     */
    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

      result = objects.immutableClone();
    }
    else {
      // we have hints, use them
     
      EOModel model = EOModelGroup.defaultGroup().entityNamed(spec.entityName()).model();
      ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(ec, model.name());
      Object hint = spec.hints().valueForKey(EODatabaseContext.CustomQueryExpressionHintKey);
      String sql = sqlHelper.customQueryExpressionHintAsString(hint);
      sql = sqlHelper.limitExpressionForSQL(null, spec, sql, start, end);
     
      if (rawRowsForCustomQueries) {
        result = EOUtilities.rawRowsForSQL(ec, model.name(), sql, null);
      }
      else {
        EOFetchSpecification fs = new EOFetchSpecification(spec.entityName(), null, null);
        fs.setHints(new NSDictionary(sql, EODatabaseContext.CustomQueryExpressionHintKey));
        result = ec.objectsWithFetchSpecification(fs);
View Full Code Here

     * @param aggregateAttribute the attribute that contains the "count(*)" definition
     * @return the number of objects
     */
    public static Object _aggregateFunctionWithQualifierAndAggregateAttribute(EOEditingContext ec, String entityName, EOQualifier qualifier, EOAttribute aggregateAttribute) {
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        EOModel model = entity.model();
        EODatabaseContext dbc = EODatabaseContext.registeredDatabaseContextForModel(model, ec);
        Object aggregateValue = null;
       
        dbc.lock();
        try {
View Full Code Here

        return new NSArray(TableNames);
    }

    @Override
    public EOModel describeModelWithTableNames(NSArray tableNames) {
        return new EOModel(defaultModelUrl());
    }
View Full Code Here

          log.info("Not adding model, it's only a temp file: " + indexPath);
          continue;
        }
        String modelPath = NSPathUtilities.stringByDeletingLastPathComponent(indexPath);
        String modelName = (NSPathUtilities.stringByDeletingPathExtension(NSPathUtilities.lastPathComponent(modelPath)));
        EOModel eomodel = modelNamed(modelName);
        if (eomodel == null) {
          URL url = nsbundle.pathURLForResourcePath(modelPath);
          modelNameURLDictionary.setObjectForKey(url, modelName);
          modelNames.addObject(modelName);
        }
        else if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 32768L)) {
          NSLog.debug.appendln("Ignoring model at path \"" + modelPath + "\" because the model group " + this + " already contains the model from the path \"" + eomodel.pathURL() + "\"");
        }
      }
    }

    NSMutableArray<URL> modelURLs = new NSMutableArray<URL>();
    // First, add prototyes if specified
    for(Enumeration prototypeModelNamesEnum = _prototypeModelNames.objectEnumerator(); prototypeModelNamesEnum.hasMoreElements(); ) {
      String prototypeModelName = (String) prototypeModelNamesEnum.nextElement();
      URL prototypeModelURL = (URL) modelNameURLDictionary.removeObjectForKey(prototypeModelName); // WO53
      modelNames.removeObject(prototypeModelName);
      if (prototypeModelURL != null) {
        modelURLs.addObject(prototypeModelURL);
      } else {
        // AK: we throw for everything except erprototypes, as it is set by default
        if(!"erprototypes".equals(prototypeModelName)) {
          throw new IllegalArgumentException("You specified the prototype model '" + prototypeModelName + "' in your prototypeModelNames array, but it can not be found.");
        }
      }
    }
    // Next, add all models that are stated explicitely
    for(Enumeration<String> modelLoadOrderEnum = _modelLoadOrder.objectEnumerator(); modelLoadOrderEnum.hasMoreElements(); ) {
      String modelName = modelLoadOrderEnum.nextElement();
      URL modelURL = modelNameURLDictionary.removeObjectForKey(modelName);
      modelNames.removeObject(modelName);
      if (modelURL == null) {
        throw new IllegalArgumentException("You specified the model '" + modelName + "' in your modelLoadOrder array, but it can not be found.");
      }
      modelURLs.addObject(modelURL);
    }
    // Finally add all the rest
    for (Enumeration<String> e = modelNames.objectEnumerator(); e.hasMoreElements();) {
      String name = e.nextElement();
      modelURLs.addObject(modelNameURLDictionary.objectForKey(name));
    }

    Enumeration<URL> modelURLEnum = modelURLs.objectEnumerator();
    while (modelURLEnum.hasMoreElements()) {
      URL url = modelURLEnum.nextElement();
      addModelWithPathURL(url);
    }
   
    // correcting an EOF Inheritance bug
    checkInheritanceRelationships();
   
    if (!patchModelsOnLoad) {
      modifyModelsFromProperties();
      flattenPrototypes();
      Enumeration<EOModel> modelsEnum = models().objectEnumerator();
      while (modelsEnum.hasMoreElements()) {
        EOModel model = modelsEnum.nextElement();
        preloadERXConstantClassesForModel(model);
      }
    }
   
    NSNotificationCenter.defaultCenter().postNotification(ModelGroupAddedNotification, this);
View Full Code Here

      return;
    }
    NSMutableSet nsmutableset = new NSMutableSet(128);
    NSSet<String> nsset = new NSSet<String>(eomodel.entityNames());
    while (enumeration.hasMoreElements()) {
      EOModel eomodel1 = (EOModel) enumeration.nextElement();
      nsmutableset.addObjectsFromArray(eomodel1.entityNames());
    }
    NSSet intersection = nsmutableset.setByIntersectingSet(nsset);
    if (intersection.count() != 0) {
      log.warn("The model '" + name + "' (path: " + eomodel.pathURL() + ") has an entity name conflict with the entities " + intersection + " already in the model group " + this);
      Enumeration e = intersection.objectEnumerator();
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOModel

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.