Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOAttribute


     * to determine the current attribute. Works even with inheirtance.
     * @param c current D2W context
     * @return attribute for the current propertyKey object combination.
     */
    public Object smartAttribute(D2WContext c) {
        EOAttribute result=null;
        String propertyKey=c.propertyKey();
        Object rawObject=c.valueForKey("object");
        if (rawObject!=null && rawObject instanceof EOEnterpriseObject && propertyKey!=null) {
            EOEnterpriseObject object=(EOEnterpriseObject)rawObject;
            EOEnterpriseObject lastEO=object;
View Full Code Here


    }

    for (String attributeName : classDescription.attributeKeys()) {
      ERXKey<Object> key = new ERXKey<Object>(attributeName);
      if (filter.matches(key, ERXKey.Type.Attribute)) {
        EOAttribute attribute = null;
        if (entity != null) {
          attribute = entity.attributeNamed(key.key());
        }
        NSMutableDictionary<String, Object> property = new NSMutableDictionary<String, Object>();

        boolean optional = attribute != null && attribute.allowsNull();
        property.setObjectForKey(optional, "optional");

        Class<?> attributeClass = classDescription.classForAttributeKey(key.key());
        if (String.class.isAssignableFrom(attributeClass)) {
          property.setObjectForKey("string", "type");
          if (attribute != null) {
            int width = attribute.width();
            if (width > 0) {
              if (!optional) {
                property.setObjectForKey(1, "minLength");
              }
              property.setObjectForKey(width, "maxLength");
View Full Code Here

  public NSDictionary _newPrimaryKey(EOEnterpriseObject object, EOEntity entity) {
    NSArray pkAttributes = entity.primaryKeyAttributes();
    if (pkAttributes.count() > 1) {
      throw new ERLuceneAdaptorException("Failed to generate primary key because " + entity.name() + " has a composite primary key.");
    }
    EOAttribute pkAttribute = (EOAttribute) pkAttributes.objectAtIndex(0);
    Object pkValue = null;
    String className = pkAttribute.className();
    String valueType = pkAttribute.valueType();
    if ("com.webobjects.foundation.NSData".equals(className)) {
//      if(true==false) {
//        ByteArrayBuffer buf = new ByteArrayBuffer();
//        try {
//          buf.write(entity.externalName().getBytes());
//          buf.write('.');
//          buf.write(new EOTemporaryGlobalID()._rawBytes());
//          pkValue = new NSData(buf.getRawData());
//        } catch (IOException e) {
//          throw NSForwardException._runtimeExceptionForThrowable(e);
//        }
//      } else {
        pkValue = new NSData(new EOTemporaryGlobalID()._rawBytes());
//      }
    } 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

      EORelationship rel = current.relationshipNamed(key);
     
      if (rel != null) {
        lastRetriever = (Retriever<? extends PropertyContainer, V>) RelationshipRetriever.create(rel);       
      } else {
        EOAttribute att = current.attributeNamed(key);
        NSArray<EOAttribute> pks = current.primaryKeyAttributes();
       
        if (pks.size() == 1 && pks.get(0).equals(att)) {
          lastRetriever = (Retriever<? extends PropertyContainer, V>) PrimaryKeyRetriever.create(current);
        } else {
View Full Code Here

    return Cost.PRIMARY_KEY;
  }
 
  public static PrimaryKeyRetriever<? extends PropertyContainer> create(EOEntity entity) {
    NSArray<EOAttribute> pks = entity.primaryKeyAttributes();
    EOAttribute pk = pks.get(0);
   
    if (RelationshipStore.shouldBeStoredAsRelationship(entity)) {
      return new PrimaryKeyRetriever<Relationship>(pk) {
        @Override
        protected long getId(Relationship t) {
View Full Code Here

    boolQuery.add(q, Occur.MUST);
   
    for (EORelationship r : relToNodes.keySet()) {
      NSArray<EOAttribute> srcAtts = r.sourceAttributes();
      BooleanQuery relationshipQuery = new BooleanQuery();
      EOAttribute att;
     
      if (srcAtts.count() != 1) {
        throw new IllegalArgumentException();
      } else {
        att = srcAtts.get(0);
      }

      for (Type n : relToNodes.get(r)) {
        Object ultimateId = Neo4JTranslator.instance.toNeutralValue(getObjectId(n), att);
        String luceneValue = LuceneTranslator.instance.fromNeutralValue(ultimateId, att);
        Term term = new Term(att.name(), luceneValue);
        TermQuery termQuery = new TermQuery(term);
       
        if (relationshipQuery.clauses().size() >= BooleanQuery.getMaxClauseCount()) {
          BooleanQuery.setMaxClauseCount(BooleanQuery.getMaxClauseCount() + 10);
        }
View Full Code Here

  protected Node getNode() {
    return (Node) getPropertyContainer();
  }
 
  private boolean isPrimaryKey(EOAttribute att) {
    EOAttribute pk = EOUtilities.primaryKeyAttribute(entity);
   
    return att.name().equals(pk.name());
  }
View Full Code Here

   
    if (r == null) {
      return null;
    } else {
      long id = r.getEndNode().getId();
      EOAttribute dstAtt = EOUtilities.primaryKeyAttribute(rel.destinationEntity());
     
      return EOUtilities.convertToAttributeType(dstAtt, id);
    }
  }
View Full Code Here

    for (EORelationship rel : entity.relationships()) {
      if (! rel.isCompound() && ! rel.isToMany()) {
        if (rel.sourceAttributes().size() != 1) {
          throw new IllegalArgumentException();
        } else {       
          EOAttribute att = rel.sourceAttributes().get(0);
         
          foreignKeys.put(att.name(), rel);
        }
      }
    }
  }
View Full Code Here

                                NSArray someKeys = aRow.allKeys();
                                int keyCount = someKeys.count();

                                for (int keyIndex = 0; keyIndex < keyCount; keyIndex++) {
                                    Object aKey = someKeys.objectAtIndex(keyIndex);
                                    EOAttribute anAttribute = anEntity.attributeNamed(aKey.toString());
                                    if (anAttribute != null) {
                                        Object aValue = aRow.objectForKey(aKey);

                                        NSKeyValueCoding.DefaultImplementation.takeValueForKey(aFile, aValue, anAttribute.columnName());
                                    }
                                }
                            }
                            return count;
                        }
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.