Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOAttribute


    while (entitiesEnum.hasMoreElements()) {
      EOEntity entity = (EOEntity) entitiesEnum.nextElement();
      if (isSingleTableInheritance(entity)) {
        Enumeration attributeEnum = entity.attributes().objectEnumerator();
        while (attributeEnum.hasMoreElements()) {
          EOAttribute attribute = (EOAttribute) attributeEnum.nextElement();
          if (!isInherited(attribute)) {
            attribute.setAllowsNull(true);
          }
        }
      }
    }
  }
View Full Code Here


      attributesUsedForLocking = NSArray.EmptyArray;
    }
    NSMutableArray mutableClassProperties = classProperties.mutableClone();
    NSMutableArray mutableAttributesUsedForLocking = attributesUsedForLocking.mutableClone();
    for (Enumeration e = attributes.objectEnumerator(); e.hasMoreElements();) {
      EOAttribute attribute = (EOAttribute) e.nextElement();
      NSDictionary userInfo = attribute.userInfo();
      String name = attribute.name();
      if (userInfo != null) {
        Object l = userInfo.valueForKey("ERXLanguages");
        if (l != null && !(l instanceof NSArray)) {
          l = (entity.model().userInfo() != null ? entity.model().userInfo().valueForKey("ERXLanguages") : null);
        }

        NSArray languages = (NSArray) l;
        if (languages != null && languages.count() > 0) {
          String columnName = attribute.columnName();
          for (int i = 0; i < languages.count(); i++) {
            String language = (String) languages.objectAtIndex(i);
            String newName = name + "_" + language;
            String newColumnName = columnName + "_" + language;

            EOAttribute newAttribute = new EOAttribute();
            newAttribute.setName(newName);
            entity.addAttribute(newAttribute);

            newAttribute.setPrototype(attribute.prototype());
            newAttribute.setColumnName(newColumnName);
            newAttribute.setAllowsNull(attribute.allowsNull());
            newAttribute.setClassName(attribute.className());
            newAttribute.setExternalType(attribute.externalType());
            newAttribute.setWidth(attribute.width());
            newAttribute.setUserInfo(attribute.userInfo());

            if (classProperties.containsObject(attribute)) {
              mutableClassProperties.addObject(newAttribute);
            }
            if (attributesUsedForLocking.containsObject(attribute)) {
View Full Code Here

    while (entitiesEnum.hasMoreElements()) {
      EOEntity entity = (EOEntity) entitiesEnum.nextElement();
      if (isSingleTableInheritance(entity)) {
        Enumeration attributeEnum = entity.attributes().objectEnumerator();
        while (attributeEnum.hasMoreElements()) {
          EOAttribute attribute = (EOAttribute) attributeEnum.nextElement();
          if (!isInherited(attribute)) {
            attribute.setAllowsNull(true);
          }
        }
      }
    }
  }
View Full Code Here

      attributesUsedForLocking = NSArray.EmptyArray;
    }
    NSMutableArray mutableClassProperties = classProperties.mutableClone();
    NSMutableArray mutableAttributesUsedForLocking = attributesUsedForLocking.mutableClone();
    for (Enumeration e = attributes.objectEnumerator(); e.hasMoreElements();) {
      EOAttribute attribute = (EOAttribute) e.nextElement();
      NSDictionary userInfo = attribute.userInfo();
      String name = attribute.name();
      if (userInfo != null) {
        Object l = userInfo.valueForKey("ERXLanguages");
        if (l != null && !(l instanceof NSArray)) {
          l = (entity.model().userInfo() != null ? entity.model().userInfo().valueForKey("ERXLanguages") : null);
        }

        NSArray languages = (NSArray) l;
        if (languages != null && languages.count() > 0) {
          String columnName = attribute.columnName();
          for (int i = 0; i < languages.count(); i++) {
            String language = (String) languages.objectAtIndex(i);
            String newName = name + "_" + language;
            String newColumnName = columnName + "_" + language;

            EOAttribute newAttribute = new EOAttribute();
            newAttribute.setName(newName);
            entity.addAttribute(newAttribute);

            newAttribute.setPrototype(attribute.prototype());
            newAttribute.setColumnName(newColumnName);
            newAttribute.setAllowsNull(attribute.allowsNull());
            newAttribute.setClassName(attribute.className());
            newAttribute.setExternalType(attribute.externalType());
            newAttribute.setWidth(attribute.width());
            newAttribute.setUserInfo(attribute.userInfo());

            if (classProperties.containsObject(attribute)) {
              mutableClassProperties.addObject(newAttribute);
            }
            if (attributesUsedForLocking.containsObject(attribute)) {
View Full Code Here

  public NSArray<String> localesForKey(String key) {
    NSArray<String> result = NSArray.EmptyArray;
    EOClassDescription cd = classDescription();
    if (cd instanceof ERXEntityClassDescription) {
      ERXEntityClassDescription ecd = (ERXEntityClassDescription) cd;
      EOAttribute attribute = ecd.entity().attributeNamed(key);
      if (attribute == null) {
        attribute = ecd.entity().attributeNamed(localizedKey(key));
      }
      return (NSArray<String>) attribute.userInfo().objectForKey("ERXLanguages");
    }
    return result;
  }
View Full Code Here

        String s1 = eoentity.name() + "." + s;
        Object o = customAttributes.get(s1);
        if(o == NOT_FOUND) {
            return null;
        }
        EOAttribute eoattribute = (EOAttribute)o;
        if (eoattribute == null && s != null) {
            Class class1 = D2WUtils.dataTypeForCustomKeyAndEntity(s, eoentity);
            if (class1 != null) {
                eoattribute = new EOAttribute();
                eoattribute.setName(s);
                eoattribute.setClassName(class1.getName());
                customAttributes.put(s1, eoattribute);
            } else {
                // this should be cached, too
                // can save up to 100 millis and more for complex pages
                customAttributes.put(s1, NOT_FOUND);
View Full Code Here

            EOEntity entity = entity();
            NSDictionary entityInfo = (NSDictionary)entity.userInfo().objectForKey("ERXDefaultValues");

            for( Enumeration e = entity.attributes().objectEnumerator(); e.hasMoreElements();) {
                EOAttribute attr = (EOAttribute)e.nextElement();
                String defaultValue = null;

                if(attr.userInfo() != null)
                    defaultValue = (String)attr.userInfo().objectForKey(defaultKey);

                if(defaultValue == null && entityInfo != null) {
                    defaultValue = (String)entityInfo.objectForKey(attr.name());
                }
                if(defaultValue != null)
                    setDefaultAttributeValue(attr, defaultValue);
            }
View Full Code Here

    public void setDefaultRelationshipValue(EORelationship rel, String defaultValue) {
        String name = rel.name();
        defaultLog.debug("Adding: " + name + "-" + defaultValue);
        NSArray attrs = rel.destinationAttributes();
        if(!rel.isFlattened() && attrs !=  null && attrs.count() == 1) {
            EOAttribute relAttr = (EOAttribute)attrs.objectAtIndex(0);
            if(defaultValue != null) {
                RelationshipDefault d = new RelationshipDefault(name, defaultValue, relAttr.adaptorValueType(), rel.destinationEntity().name());
                _initialDefaultValues.setObjectForKey(d, name);
            }
        }
    }
View Full Code Here

        return sharedGSVEngineInstance;
    }

  @Override
  public Class _enforcedKVCNumberClassForKey(String key) {
    EOAttribute attribute = entity().attributeNamed(key);
    if(attribute != null && attribute.userInfo() != null) {
      String className = (String) attribute.userInfo().objectForKey("ERXConstantClassName");
      if(className != null) {
                Class c = ERXPatcher.classForName(className);
        return c;
      }
    }
View Full Code Here

    public String valueClassNameForKey(String key) {
        String entityName = (String) _WOJExtensionsUtil.valueForBindingOrNull("sourceEntityName", this);
        EOModelGroup modelGroup = EOModelGroup.defaultGroup();
        EOEntity entity = modelGroup.entityNamed(entityName);
        EOAttribute selectedAttribute = null;
        if (relationshipKey() != null && entity.relationshipNamed(relationshipKey()) != null) {
            EORelationship relationship = entity.relationshipNamed(relationshipKey());
            EOEntity destinationEntity = relationship.destinationEntity();
            selectedAttribute = destinationEntity.attributeNamed(key);
        } else {
            selectedAttribute = entity.attributeNamed(key);
        }
        return selectedAttribute.className();
    }
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.