Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOAttribute


    @Override
    public String sqlStringForValue(Object v, String kp) {
        if(disableTypeCasting()) {
            return super.sqlStringForValue(v,kp);
        }
        EOAttribute attribute;
        int lastDotIdx = kp.lastIndexOf(".");
        if (lastDotIdx == -1) {
          attribute = entity().attributeNamed(kp);
        } else {
          EOEntity kpEntity = entityForKeyPath(kp);
          attribute = kpEntity.attributeNamed(kp.substring(lastDotIdx+1));
        }
        // AK: inet6 addresses get handed down as "xxx:xxx:...:xxx%y", not "xxx:xxx:...:xxx/y"
        // note that this might break if you hand over a host name that contains percent chars (not sure if possible)
      if(attribute != null && "inet".equals(attribute.externalType()) && v != null && v.toString().indexOf('%') > 0) {
        v = v.toString().replace('%', '/');
      }
        if(attribute != null && v != null && v != NSKeyValueCoding.NullValue) {
          String s = columnTypeStringForAttribute(attribute);
          return super.sqlStringForValue(v, kp) + "::" + s;
View Full Code Here


                    // produces very yucky output
                    obj = obj.toString();
                }
            } else {
                if (expression.entity() != null) {
                    EOAttribute attribute = expression.entity().anyAttributeNamed(attributeName);
                    if (attribute != null) {
                        obj = expression.formatValueForAttribute(obj, attribute);
                    }
                }
            }
View Full Code Here

        NSArray keys = changedValues.allKeys();
        NSMutableSet relationships = new NSMutableSet();
       
        for (int i=0; i<keys.count(); i++) {
            String key = (String)keys.objectAtIndex(i);
            EOAttribute attrib = entity.attributeNamed(key);
            if (attrib != null) {
                Object val = changedValues.objectForKey(key);
                if(ERXValueUtilities.isNull(val)) {
                  val = null;
                }
View Full Code Here

  public static EORelationship createRelationship(String relationshipName, String sourceEntityName, String sourceAttributeName, String destinationEntityName, String destinationAttributeName, boolean toMany, int deleteRule, boolean isMandatory, boolean isClassProperty, boolean shouldPropagatePrimaryKey) {
    EOEntity sourceEntity = EOModelGroup.defaultGroup().entityNamed(sourceEntityName);
    if(sourceEntity.isAbstractEntity())
      log.warn("If you programatically add relationships to an abstract entity, make sure you also add it to child entities");
    EOEntity destinationEntity = EOModelGroup.defaultGroup().entityNamed(destinationEntityName);
    EOAttribute sourceAttribute = sourceEntity.attributeNamed(sourceAttributeName);
    EOAttribute destinationAttribute = destinationEntity.attributeNamed(destinationAttributeName);
    EOJoin join = new EOJoin(sourceAttribute, destinationAttribute);
    EORelationship relationship = new EORelationship();

    relationship.setName(relationshipName);
    sourceEntity.addRelationship(relationship);
View Full Code Here

            addAttributeNamed(selectedEntity, "attributeName", null);
            return null;
        }

        public EOAttribute addAttributeNamed(EOEntity entity, String name, EOAttribute prototype) {
            EOAttribute a = new EOAttribute();
            a.setName(name);
            entity.addAttribute(a);
            if(prototype != null)
                a.setPrototype(prototype);
            a.setColumnName(name.toLowerCase());
            updateClassProperties(entity,a,false);
            return a;
        }
View Full Code Here

  public NSArray<NSDictionary<String, Object>> newPrimaryKeys(int count, EOEntity entity, JDBCChannel channel) {
    if (isPrimaryKeyGenerationNotSupported(entity)) {
      return null;
    }
   
    EOAttribute attribute = entity.primaryKeyAttributes().lastObject();
    String attrName = attribute.name();
    boolean isIntType = "i".equals(attribute.valueType());

    NSMutableArray<NSDictionary<String, Object>> results = new NSMutableArray<NSDictionary<String, Object>>(count);
    String sequenceName = _sequenceNameForEntity(entity);
    PostgresqlExpression expression = new PostgresqlExpression(entity);
   
View Full Code Here

        }
       
        public void addRelationship(EOEntity selectedEntity, EOEntity targetEntity, EOAttribute foreignAttribute, boolean isToMany, boolean addBack) {
            String targetName = targetEntity.name().toLowerCase();
            String selectedName = selectedEntity.name().toLowerCase();
            EOAttribute selectedPK = (EOAttribute)selectedEntity.primaryKeyAttributes().objectAtIndex(0);
           
            if(foreignAttribute == null) {
                foreignAttribute = addAttributeNamed(targetEntity, selectedName+"id", selectedPK.prototype());
            }
           
            EORelationship relationship = new EORelationship();
            relationship.setName(targetName+(isToMany ? "s" : ""));
            selectedEntity.addRelationship(relationship);
View Full Code Here

        }
        public void addBackRelationship(EOEntity selectedEntity, EOEntity targetEntity, EOAttribute foreignAttribute, boolean isToMany, boolean addBack) {
            EORelationship relationship = new EORelationship();
            String targetName = targetEntity.name().toLowerCase();
            String selectedName = selectedEntity.name().toLowerCase();
            EOAttribute selectedPK = (EOAttribute)targetEntity.primaryKeyAttributes().objectAtIndex(0);

            if(foreignAttribute == null) {
                foreignAttribute = addAttributeNamed(selectedEntity, targetName+"id", selectedPK.prototype());
            }
            relationship.setName(targetName+(isToMany ? "s" : ""));
            selectedEntity.addRelationship(relationship);

            EOJoin join = new EOJoin(foreignAttribute,selectedPK);
View Full Code Here

    return new TermRangeQuery(key, min, max, minInclusive, maxInclusive);
  }
 
  @Override
  protected Query comparison(EOEntity entity, String key, ComparisonOperator operator, Object value) {
    EOAttribute att = entity.attributeNamed(key);
    String luceneValue = LuceneTranslator.instance.fromNeutralValue(value, att);
   
    switch (operator) {
    case EQUAL:
      return new TermQuery(new Term(key, luceneValue));
View Full Code Here

        public EOEntity addEntityWithName(EOModel model, String entityName) {
            entity = new EOEntity();
            entity.setName(entityName);
            entity.setExternalName(entityName.toLowerCase());
            model.addEntity(entity);
            EOAttribute oid = new EOAttribute();
            NSArray pks = new NSArray(oid);
            entity.setPrimaryKeyAttributes(pks);
            oid.setPrototype(prototypes.attributeNamed("id"));
            oid.setColumnName("oid");
            oid.setName("oid");
            entity.addAttribute(oid);
            return entity;
        }
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.