Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOEntity


        return result;
    }
   
    public NSArray<String> toOneRelationships() {
        NSMutableArray<String> result = new NSMutableArray<String>();
        EOEntity entity = entity();
        for (String key : (NSArray<String>)displayPropertyKeys()) {
            if(entity.classDescriptionForInstances().toOneRelationshipKeys().containsObject(key) && entity.classPropertyNames().containsObject(key)) {
                result.addObject(key);
            }
        }
        return result;
    }
View Full Code Here


        return "->";
    }
   
    public NSArray<String> toManyRelationships() {
        NSMutableArray<String> result = new NSMutableArray<String>();
        EOEntity entity = entity();
        for (String key : (NSArray<String>)displayPropertyKeys()) {
            if(entity.classDescriptionForInstances().toManyRelationshipKeys().containsObject(key) && entity.classPropertyNames().containsObject(key)) {
                result.addObject(key);
            }
        }
        return result;
    }
View Full Code Here

  }
 
  private static final Pattern DOT_PATTERN = Pattern.compile("\\.");

  public static String unflattenedKey(EOEntity entity, String keypath) {
    EOEntity currentEntity = entity;
    List<String> splits = new ArrayList<String>();
    StringBuilder b = new StringBuilder();
   
    Collections.addAll(splits, DOT_PATTERN.split(keypath));
   
    for (int i=0; i<splits.size(); i++) {
      String key = splits.get(i);
      EORelationship rel = currentEntity.relationshipNamed(key);
     
      if (rel != null) {       
        if (rel.isFlattened()) {
          String [] newDefinition = DOT_PATTERN.split(rel.definition());
         
View Full Code Here

      pojoModel.setAdaptorName("JDBCAdaptor");
      //ak: fake dict for possible NPE
      pojoModel.setConnectionDictionary(new NSMutableDictionary());
      EOModelGroup.defaultGroup().addModel(pojoModel);
    }
    EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);
    /*if (entity != null) {
      pojoModel.removeEntity(entity);
      entity = null;
    }*/
    EOClassDescription classDescription;
    if (entity == null) {
      entity = new EOEntity();
      entity.setName(entityName);
      keys = (keys == null ? fieldNamesFromClass(clazz) : keys);
      for (Enumeration iter = keys.objectEnumerator(); iter.hasMoreElements();) {
        String name = (String) iter.nextElement();
        EOAttribute attribute = new EOAttribute();
        attribute.setName(name);
        Method m = methodForName(clazz, name);
        if(m != null) {
          attribute.setClassName(m.getReturnType().getName());
        } else {
          Field f = fieldForName(clazz, name);
          if(f != null) {
            String type = f.getType().getName();
            if("boolean".equals(type)) {
              type = "java.lang.Boolean";
            } else if("int".equals(type)) {
              type = "java.lang.Number";
            } else if("long".equals(type)) {
              type = "java.lang.Number";
            } else if("short".equals(type)) {
              type = "java.lang.Number";
            }

            attribute.setClassName(type);
          }
        }
        entity.addAttribute(attribute);
      }
      classDescription = new EOEntityClassDescription(entity);
      NSKeyValueCoding.Utility.takeValueForKey(entity, classDescription, "classDescription");
      EOClassDescription.registerClassDescription(classDescription, clazz);
      pojoModel.addEntity(entity);
View Full Code Here

                o = EOModelGroup.defaultGroup().entityNamed(entityName);
            } else if(s.indexOf(RELATIONSHIP_PREFIX) == 0) {
                int entityOffset = s.indexOf(ENTITY_PREFIX);
                String entityName = s.substring(entityOffset + ENTITY_PREFIX.length());
                String relationshipName = s.substring(RELATIONSHIP_PREFIX.length(), entityOffset);
                EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);
                o = entity.relationshipNamed(relationshipName);
            } else if(s.indexOf(ATTRIBUTE_PREFIX) == 0) {
                int entityOffset = s.indexOf(ENTITY_PREFIX);
                String entityName = s.substring(entityOffset + ENTITY_PREFIX.length());
                String attributeName = s.substring(ATTRIBUTE_PREFIX.length(), entityOffset);
                EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);
                o = entity.attributeNamed(attributeName);
            }
        }
        return o;
    }
View Full Code Here

  public NSArray<EOSortOrdering> sortOrderings(EOEditingContext editingContext, NSKeyValueCoding options) {
    String sortKeysStr = (String) options.valueForKey("sort");
    if (sortKeysStr == null || sortKeysStr.length() == 0) {
      return _defaultSortOrderings;
    }
    EOEntity entity = EOUtilities.entityNamed(editingContext, _entityName);
    NSMutableArray<EOSortOrdering> sortOrderings = new NSMutableArray<EOSortOrdering>();
    for (String sortKeyStr : sortKeysStr.split(",")) {
      String[] sortAttributes = sortKeyStr.split("\\|");
      String sortKey = sortAttributes[0];
View Full Code Here

        qualifier = EOQualifier.qualifierWithQualifierFormat(qualifierStr, null);
        if (qualifier == null) {
          qualifier = _baseQualifier;
        }
        else {
          EOEntity entity = EOUtilities.entityNamed(editingContext, _entityName);
          ERXFilteredQualifierTraversal.checkQualifierForEntityWithFilter(qualifier, entity, _qualifierFilter);
          if (_baseQualifier != null) {
            qualifier = ERXQ.and(_baseQualifier, qualifier);
          }
        }
View Full Code Here

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

     *
     * @return batch iterator for the passed in query
     */
    public static ERXFetchSpecificationBatchIterator batchIteratorForObjectsWithSqlWithBindings( EOEditingContext ec, String entityName, String query, boolean refreshesCache, int batchSize, NSArray sortOrderings, ERXSQLBinding... bindings ) {
        EODatabaseContext databaseContext = databaseContextForEntityName(ec,entityName);
        EOEntity entity = EOUtilities.entityNamed(ec, entityName);

        if( entity.primaryKeyAttributes().count() > 1 ) {
            throw new RuntimeException("Multiple primary keys not supported.");
        }

        EOSQLExpression expression = databaseContext.adaptorContext().adaptor().expressionFactory().expressionForEntity( entity );
        expression.setStatement(processedQueryString(query, expression, bindings));

        EOFetchSpecification pkSpec = new EOFetchSpecification( entityName, null, null );
        pkSpec.setRefreshesRefetchedObjects(refreshesCache);
        pkSpec.setFetchesRawRows(true);
        pkSpec.setRawRowKeyPaths(entity.primaryKeyAttributeNames());
        pkSpec.setHints( new NSDictionary( expression, EODatabaseContext.CustomQueryExpressionHintKey ) );

        NSArray pkDicts = ec.objectsWithFetchSpecification(pkSpec);
        NSMutableArray pks = new NSMutableArray();
        String pkAtttributeName = entity.primaryKeyAttributes().lastObject().name();

        for ( Enumeration rowEnumerator = pkDicts.objectEnumerator(); rowEnumerator.hasMoreElements(); ) {
            NSDictionary row = (NSDictionary) rowEnumerator.nextElement();
            pks.addObject( row.objectForKey( pkAtttributeName ));
        }
View Full Code Here

     * @return The requested raw rows
     */
    public static NSArray rawRowsForSqlWithBindings( EOEditingContext ec, String entityName, String query, ERXSQLBinding... bindings ) {
        EODatabaseChannel databaseChannel = databaseContextForEntityName(ec,entityName).availableChannel();
        EOAdaptorChannel adaptorChannel = databaseChannel.adaptorChannel();
        EOEntity entity = EOUtilities.entityNamed(ec, entityName);

        EOSQLExpression expression = adaptorChannel.adaptorContext().adaptor().expressionFactory().expressionForEntity( entity );
        expression.setStatement( processedQueryString( query, expression, bindings ) );

        EOFetchSpecification spec = new EOFetchSpecification( entityName, null, null );
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOEntity

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.