Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOAttribute


        }
        if (entity!=null && lastKey!=null) {
            Object property=entity.attributeNamed(lastKey);
            property=property==null ? entity.relationshipNamed(lastKey) : property;
            //BOOGIE
            EOAttribute a=entity.attributeNamed(lastKey);
            NSDictionary userInfo=null;
            if (a!=null) userInfo=a.userInfo();
            else {
                EORelationship r=entity.relationshipNamed(lastKey);
                if (r!=null) userInfo=r.userInfo();
            }
            //
View Full Code Here


            for(Enumeration relationships = eoentity.relationships().objectEnumerator(); relationships.hasMoreElements(); ) {
                EORelationship relationship = (EORelationship)relationships.nextElement();
                if(!relationship.isToMany()) {
                    if(relationship.isMandatory()) {
                        for(Enumeration attributes = relationship.sourceAttributes().objectEnumerator(); attributes.hasMoreElements(); ) {
                            EOAttribute attribute = (EOAttribute)attributes.nextElement();
                            if(attribute.allowsNull()) {
                                handleMandatoryRelationshipError(eoentity, relationship, attribute);
                            }
                        }
                    } else {
                        for(Enumeration attributes = relationship.sourceAttributes().objectEnumerator(); attributes.hasMoreElements(); ) {
                            EOAttribute attribute = (EOAttribute)attributes.nextElement();
                            if(!attribute.allowsNull() && !primaryKeys.containsObject(attribute)) {
                                handleOptionalRelationshipError(eoentity, relationship, attribute);
                            }
                        }
                    }
                }
View Full Code Here

         
          NSMutableArray qualifiers = new NSMutableArray();
          for(Enumeration e = context().request().formValueKeys().objectEnumerator(); e.hasMoreElements(); ) {
            String key = (String)e.nextElement();
            EOEntity entity = rootEntity;
            EOAttribute attribute = null;
            String attributeName = key;
            if(key.indexOf(".") > 0) {
              String path = ERXStringUtilities.keyPathWithoutLastProperty(key);
              attributeName = ERXStringUtilities.lastPropertyKeyInKeyPath(key);
              entity = ERXEOAccessUtilities.destinationEntityForKeyPath(rootEntity, path);
View Full Code Here

  private EREntityStore joinedStore(NSArray<EOAttribute> attributesToFetch, EOFetchSpecification fetchSpecification, EOEntity entity) {
    EREntityStore store = _stores.objectForKey(entity);
    for (EOAttribute attrib : attributesToFetch) {
      if (attrib.isFlattened()) {
        EOAttribute _attrib = entity._attributeForPath(attrib.definition());
        EORelationship _rel = entity._relationshipForPath(attrib.relationshipPath());
        store = join(_rel, store, _stores.objectForKey(_attrib.entity()));
      }
    }
    // We need to check the qualifier for _hiddenRelationships and include them if referenced
//    for (EORelationship rel : (NSArray<EORelationship>) entity._hiddenRelationships()) {
//      if (rel.isFlattened()) {
View Full Code Here

  public void insertRow(NSDictionary<String, Object> row, EOEntity entity) {
    NSMutableDictionary<String, Object> newRow = new NSMutableDictionary<String, Object>();
    EOEntity target = entity;
    /* XXX: This assumes that EOF isn't going to try to insert into two different tables at once */
    for (Entry<String, Object> entry : row.entrySet()) {
      EOAttribute attrib = entity.anyAttributeNamed(entry.getKey());
      if (attrib.isFlattened()) {
        EOAttribute _attrib = entity._attributeForPath(attrib.definition());
        target = _attrib.entity();
        newRow.setObjectForKey(entry.getValue(), _attrib.name());
      } else {
        newRow.setObjectForKey(entry.getValue(), attrib.name());
      }
    }
    _stores.objectForKey(target).insertRow(newRow, target);
View Full Code Here

    private void initForValue(Object originalValue) {
        Object value = originalValue;
        if( originalValue instanceof Boolean ) {
            value = originalValue.toString();
        }
        EOAttribute attribute = new EOAttribute();
        attribute.setName(""); // Must have a name, or EOSQLExpression will scream
        if( value instanceof String ) {
            attribute.setClassName( String.class.getName() );
        } else if( value instanceof BigDecimal ) {
            attribute.setClassName( BigDecimal.class.getName() );
        } else if( value instanceof Number ) {
            attribute.setClassName( Number.class.getName() );
        } else if( value instanceof NSData ) {
            attribute.setClassName( NSData.class.getName() );
        } else if( value instanceof NSTimestamp ) {
            attribute.setClassName( NSTimestamp.class.getName() );
        } else {
            throw new RuntimeException("Unsupported object class: " + value.getClass().getName() );
        }
        _value = value;
        _attribute = attribute;
View Full Code Here

 
  public void insertRow(NSDictionary<String, Object> row, EOEntity entity) {
    try {
      NSMutableDictionary<String, Object> mutableRow = new NSMutableDictionary<String, Object>(row.size());
      for (Enumeration e = entity.attributes().objectEnumerator(); e.hasMoreElements();) {
        EOAttribute attribute = (EOAttribute) e.nextElement();
        Object value = row.objectForKey(attribute.name());
        if (!attribute.isDerived())
          mutableRow.setObjectForKey(value != null ? value : NSKeyValueCoding.NullValue, attribute.columnName());
      }
      _insertRow(mutableRow, entity);
    }
    catch (EOGeneralAdaptorException e) {
      throw e;
View Full Code Here

        NSMutableDictionary<String, Object> rawRow = i.next();
        NSMutableDictionary<String, Object> row = rowFromStoredValues(rawRow, entity);
       
        if (qualifier == null || qualifier.evaluateWithObject(row)) {
          for (Map.Entry<String, Object> entry : updatedRow.entrySet()) {
            EOAttribute attribute = entity.attributeNamed(entry.getKey());
            rawRow.setObjectForKey(entry.getValue(), attribute.columnName());
          }
          count++;
        }
      }
View Full Code Here

    EREntityStore store = _entityStoreForEntity(entity, false);
    NSArray pkAttributes = entity.primaryKeyAttributes();
    if (pkAttributes.count() > 1) {
      throw new EOGeneralAdaptorException("Failed to generate primary key because " + entity.name() + " has a composite primary key.");
    }
    EOAttribute pkAttribute = (EOAttribute) pkAttributes.objectAtIndex(0);
    int nextSequence = store.nextSequence();
    Object pkValue;
    String className = pkAttribute.className();
    String valueType = pkAttribute.valueType();
    if ("NSData".equals(className)) {
      pkValue = new NSData(String.valueOf(nextSequence).getBytes());
    }
    else {
      if (valueType == null || "i".equals(valueType)) {
        pkValue = Integer.valueOf(nextSequence);
      }
      else if ("l".equals(valueType)) {
        pkValue = Long.valueOf(nextSequence);
      }
      else if ("f".equals(valueType)) {
        pkValue = Float.valueOf(nextSequence);
      }
      else if ("d".equals(valueType)) {
        pkValue = Double.valueOf(nextSequence);
      }
      else if ("s".equals(valueType)) {
        pkValue = Short.valueOf((short) nextSequence);
      }
      else if ("c".equals(valueType) && "NSString".equals(pkAttribute.valueClassName())) { // hack for bugtracker test cases
        pkValue = String.valueOf(nextSequence);
      }
      else {
        throw new IllegalArgumentException("Unknown value type '" + valueType + "' for '" + object + "' of entity '" + entity.name() + "'.");
      }
    }
    NSDictionary pk = new NSDictionary<String, Object>(pkValue, pkAttribute.name());
    return pk;
  }
View Full Code Here

    try {
      Object parsedValue;
      if (value == null || ERXValueUtilities.isNull(value) || (value instanceof String && ((String) value).length() == 0)) {
        if (parentEntity != null) {
          if (parentEntity instanceof EOEntityClassDescription) {
            EOAttribute attribute = ((EOEntityClassDescription)parentEntity).entity().attributeNamed(attributeName);
            if (attribute != null && !attribute.allowsNull() && String.class.isAssignableFrom(valueType)) {
              parsedValue = "";
            }
            else {
              parsedValue = EOKeyValueCoding.NullValue;
            }
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOAttribute

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.