Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOEntity


    @Override
    public boolean evaluateWithObject(Object o) {
        // FIXME here -- this could be sth else..
        D2WContext c=(D2WContext)o;
        EOEntity e=(EOEntity)c.valueForKeyPath(_keyPath);
        return isKindOfEntity(e);
    }
View Full Code Here


  }

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

        if (!hasNext()) {
          throw new NoSuchElementException("No more rows are available");
        }
        _hasNext = null;
        NSMutableDictionary<String, Object> row = new NSMutableDictionary<String, Object>(src);
        EOEntity entity = relationship.entity();
        for (EOAttribute attrib : (NSArray<EOAttribute>) entity.attributesToFetch()) {
          EORelationship rel = entity._relationshipForPath(attrib.relationshipPath());
          if (attrib.isFlattened() && relationship.equals(rel)) {
            String dstKey = entity._attributeForPath(attrib.definition()).columnName();
            Object value = dst.objectForKey(dstKey);
            row.setObjectForKey(value != null ? value : NSKeyValueCoding.NullValue, attrib.definition());
          }
        }
        //row.takeValueForKeyPath(rowFromStoredValues(dst, relationship.entity()), relationship.name());
View Full Code Here

      NSDictionary<String, Object> row, EORelationship relationship, ERMemoryAdaptorContext context) {
    String relationshipPath = relationship.relationshipPath();
    String toJoinKey = ERXStringUtilities.firstPropertyKeyInKeyPath(relationshipPath);
    String toDestKey = ERXStringUtilities.keyPathWithoutFirstProperty(relationshipPath);
    EORelationship toJoinRelationship = entity.anyRelationshipNamed(toJoinKey);
    EOEntity joinEntity = toJoinRelationship.destinationEntity();
    EREntityStore joinStore = context._entityStoreForEntity(joinEntity);
    String sourceAttribute = toJoinRelationship.sourceAttributes().get(0).name();
    String destinationAttribute = toJoinRelationship.destinationAttributes().get(0).name();

    ERXFetchSpecification fs = new ERXFetchSpecification(joinEntity.name(), ERXQ.equals(destinationAttribute,
        row.valueForKey(sourceAttribute)), null);
    NSArray<NSMutableDictionary<String, Object>> fetchedObjects = joinStore.fetch(joinEntity.attributesToFetch(),
        fs, false, joinEntity, context);

    if (fetchedObjects.isEmpty()) {
      return NSArray.EmptyArray;
    }

    EORelationship destRelationship = joinEntity.anyRelationshipNamed(toDestKey);
    sourceAttribute = destRelationship.sourceAttributes().get(0).name();
    destinationAttribute = destRelationship.destinationAttributes().get(0).name();
    NSArray<Object> destValues = (NSArray<Object>) fetchedObjects.valueForKey(sourceAttribute);
    EOEntity destEntity = relationship.destinationEntity();

    fs = new ERXFetchSpecification(destEntity.name(), ERXQ.in(destinationAttribute, destValues), null);
    EREntityStore destinationStore = context._entityStoreForEntity(destEntity);
    fetchedObjects = destinationStore.fetch(destEntity.attributesToFetch(), fs, false, destEntity, context);

    return fetchedObjects;
  }
View Full Code Here

   *            the memory adaptor context
   * @return array of rows from related entity store
   */
  protected NSArray<NSMutableDictionary<String, Object>> fetchRelatedRows(EOEntity entity,
      NSDictionary<String, Object> row, EORelationship relationship, ERMemoryAdaptorContext context) {
    EOEntity destEntity = relationship.destinationEntity();
    EREntityStore destStore = context._entityStoreForEntity(destEntity);
    String sourceAttribute = relationship.sourceAttributes().get(0).name();
    String destinationAttribute = relationship.destinationAttributes().get(0).name();

    ERXFetchSpecification fs = new ERXFetchSpecification(destEntity.name(), ERXQ.equals(destinationAttribute,
        row.valueForKey(sourceAttribute)), null);
    return destStore.fetch(destEntity.attributesToFetch(), fs, false, destEntity, context);
  }
View Full Code Here

            " works only with single pk long values, expected a java.lang.Number but got a "+values.objectAtIndex(0));
      }
      long entityCode = pkValueWithCode & ((1 << ERXLongPrimaryKeyFactory.CODE_LENGTH) - 1);
      if (entityCode == 0) return null;
      for (Enumeration subEntities = entity.subEntities().objectEnumerator(); subEntities.hasMoreElements();) {
        EOEntity subEntity = (EOEntity) subEntities.nextElement();
        if (((ERXModelGroup) EOModelGroup.defaultGroup()).entityCode(subEntity) == entityCode) {
          return subEntity;
        }
      }
    }
View Full Code Here

    }
    return _factory;
  }

  private NSDictionary primaryKeyDictionary(String entityName) {
    EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);
    while (entity.parentEntity() != null) {
      entity = entity.parentEntity();
    }
    entityName = entity.name();
    if(entity.primaryKeyAttributeNames().count() != 1) {
      throw new IllegalArgumentException("Can handle only entities with one PK: " + entityName + " has " + entity.primaryKeyAttributeNames());
    }

    Long pk = getNextPkValueForEntity(entityName);
    String pkName = entity.primaryKeyAttributeNames().objectAtIndex(0);
    return new NSDictionary(new Object[] { pk}, new Object[] { pkName});
  }
View Full Code Here

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

      ec.lock();
      try {
        EODatabaseContext dbc = ERXEOAccessUtilities.databaseContextForEntityNamed((EOObjectStoreCoordinator) ec.rootObjectStore(), entityName);
        dbc.lock();
        try {
          EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
          EOAdaptorChannel channel = (EOAdaptorChannel) dbc.adaptorContext().channels().lastObject();
          NSArray result = channel.primaryKeysForNewRowsWithEntity(increasePkBy, entity);
          return (Long) ((NSDictionary) result.lastObject()).allValues().lastObject();
        } finally {
          dbc.unlock();
View Full Code Here

   * first
   *
   * @param ename
   */
  private long maxIdFromTable(String ename) {
    EOEntity entity = EOModelGroup.defaultGroup().entityNamed(ename);
    if (entity == null) throw new NullPointerException("could not find an entity named " + ename);
    String tableName = entity.externalName();
    String colName = entity.primaryKeyAttributes().lastObject().columnName();
    String sql = "select max(" + colName + ") from " + tableName;

    ERXJDBCConnectionBroker broker = ERXJDBCConnectionBroker.connectionBrokerForEntityNamed(ename);
    Connection con = broker.getConnection();
    ResultSet resultSet;
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.