Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOAttribute


     * @param entityName name of the entity to fetch
     * @param qualifier to find the matching objects
     * @return number of matching objects
     */
    public static Integer objectCountWithQualifier(EOEditingContext ec, String entityName, EOQualifier qualifier) {
        EOAttribute attribute = EOEnterpriseObjectClazz.objectCountAttribute();
        return (Integer)_aggregateFunctionWithQualifierAndAggregateAttribute(ec, entityName, qualifier, attribute);
    }
View Full Code Here


     * @param attributeName name of attribute in same entity to consider in order to determine uniqueness
     * @return number of matching objects
     */
    public static Integer objectCountUniqueWithQualifierAndAttribute(EOEditingContext ec, String entityName, EOQualifier qualifier, String attributeName) {
        EOEntity entity = EOUtilities.entityNamed(ec, entityName);
        EOAttribute attribute = entity.attributeNamed(attributeName);
        EOAttribute aggregateAttribute = EOEnterpriseObjectClazz.objectCountUniqueAttribute(attribute);
        return (Integer)_aggregateFunctionWithQualifierAndAggregateAttribute(ec, entityName, qualifier, aggregateAttribute);
    }
View Full Code Here

                                                        String attributeName,
                                                        String function,
                                                        Class valueClass,
                                                        String valueType,
                                                        EOQualifier qualifier) {
        EOAttribute attribute = ERXEOAccessUtilities.createAggregateAttribute(ec,
                                                                              function,
                                                                              attributeName,
                                                                              entityName, valueClass, valueType);

        return ERXEOControlUtilities._aggregateFunctionWithQualifierAndAggregateAttribute(ec, entityName, qualifier, attribute);
View Full Code Here

        try {
            Object rawValue = NSPropertyListSerialization.propertyListFromString(string);
            if(rawValue instanceof NSArray) {
                int index = 0;
                for(Enumeration e = ((NSArray)rawValue).objectEnumerator(); e.hasMoreElements();) {
                    EOAttribute attribute = pks.objectAtIndex(index++);
                    Object value = e.nextElement();
                    if(attribute.adaptorValueType() == EOAttribute.AdaptorDateType && !(value instanceof NSTimestamp)) {
                        value = new NSTimestampFormatter("%Y-%m-%d %H:%M:%S %Z").parseObject((String)value);
                    }
                    value = attribute.validateValue(value);
                    pk.setObjectForKey(value, attribute.name());
                    if(pks.count() == 1) {
                        break;
                    }
                }
            } else {
              if(rawValue instanceof NSMutableData) {
                  // AK: wtf!! I got an exception
                  // java.lang.IllegalArgumentException: Attempt to create an EOGlobalID for the entity "Asset" with a primary key component of type com.webobjects.foundation.NSMutableData instead of type com.webobjects.foundation.NSData!
                  // so this is a lame attempt to fix it.
                 
                rawValue = new NSData((NSMutableData)rawValue);
              }
                EOAttribute attribute = pks.objectAtIndex(0);
                Object value = rawValue;
                value = attribute.validateValue(value);
                pk.setObjectForKey(value, attribute.name());
            }
            return pk;
        } catch (Exception ex) {
            throw new NSForwardException(ex, "Error while parsing primary key: " + string);
        }
View Full Code Here

            _attributeKeysPerEntityName.setObjectForKey(attList,entityName);
            result=attList;
            for (Enumeration e=entity.classProperties().objectEnumerator();e.hasMoreElements();) {
                Object property=e.nextElement();
                if (property instanceof EOAttribute) {
                    EOAttribute a=(EOAttribute)property;
                    if (a.className().equals("java.lang.String"))
                        attList.addObject(a.name());
                }
            }
        }
        return result;
    }
View Full Code Here

  public Results<T> doFilter(GraphDatabaseService db, EOEntity entity, EOQualifier qualifier) {
    // check if there are any node ids specified, if yes then go to those nodes directly
    ValueMap map = new ValueMap(entity, qualifier);
   
    if (map.getAttributes().size() == 1) {
      EOAttribute att = map.getMostFrequentAttribute();
      EORelationship rel = EOUtilities.getRelationshipForSourceAttribute(entity, att);
      Collection<?> values = map.getValuesForAttribute(att);
      boolean containsNulls = values.contains(null);
     
      if (! containsNulls) {
        if (entity.primaryKeyAttributes().size() == 1 && att.equals(EOUtilities.primaryKeyAttribute(entity))) {
          // it's primary key
          Results<T> filter = (Results<T>) primaryKeyReference(db, (Collection<? extends Number>) values);
         
          return new EvaluatingFilter<T>(filter, entity, qualifier);
        }
View Full Code Here

    if (q instanceof EOKeyValueQualifier) {
      EOKeyValueQualifier kvQualifier = (EOKeyValueQualifier) q;
     
      if (kvQualifier.selector().equals(EOKeyValueQualifier.QualifierOperatorEqual)) {
        String key = kvQualifier.key();
        EOAttribute att = entity.attributeNamed(key);
       
        if (att != null) {
          if (q instanceof ERXInQualifier) {
            for (Object v : ((ERXInQualifier) q).values()) {
              Object value = NSTranslator.instance.toNeutralValue(v, att);
View Full Code Here

     * @param value of the assignment
     */
    public ERDDefaultModelAssignment (String key, Object value) { super(key,value); }
       
    protected int attributeWidthAsInt(D2WContext c) {
        EOAttribute a = (EOAttribute)c.valueForKey("smartAttribute");
        return a!=null ? a.width() : 0;
    }
View Full Code Here

     * @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

     * Returns the default value for the entity based on the controllerName.
     * @param c current D2W context
     * @return the entity.
     */
    public Object attributeConstants(D2WContext c) {
      EOAttribute attr = (EOAttribute)c.valueForKey("smartAttribute");
      if(attr != null && attr.userInfo() != null) {
        String clazzName = (String)attr.userInfo().objectForKey("ERXConstantClassName");
        if(clazzName != null) {
          return ERXConstant.constantsForClassName(clazzName);
        }
      }
        return null;
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.