Examples of EOClassDescription


Examples of com.webobjects.eocontrol.EOClassDescription

  public WOActionResults destroyAction() throws Throwable {
    if (!allowUpdates()) {
      throw new SecurityException("You are not allowed to delete this type of object.");
    }
    T obj = object();
        EOClassDescription classDescription = ERXRestClassDescriptionFactory.classDescriptionForObject(obj, false);
    Object primaryKey = IERXRestDelegate.Factory.delegateForClassDescription(classDescription).primaryKeyForObject(obj, restContext());
    editingContext().deleteObject(obj);
    editingContext().saveChanges();
    return response(primaryKey, null);
  }
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

  @Override
  public WOActionResults newAction() throws Throwable {
    if (!allowUpdates()) {
      throw new SecurityException("You are not allowed to create this type of object.");
    }
    EOClassDescription classDescription = ERXRestClassDescriptionFactory.classDescriptionForEntityName(entityName());
    T obj = (T) IERXRestDelegate.Factory.delegateForClassDescription(classDescription).createObjectOfEntityWithID(classDescription, null, restContext());
    return response(obj, showFilter());
  }
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

    }
    entities.add(entityName);
   
    NSMutableDictionary<String, Object> properties = new NSMutableDictionary<String, Object>();

    EOClassDescription classDescription = ERXRestClassDescriptionFactory.classDescriptionForEntityName(entityName);
   
    EOEntity entity = null;
    if (classDescription instanceof EOEntityClassDescription) {
      entity = ((EOEntityClassDescription) classDescription).entity();
    }

    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");
            }
          }
        }
        else if (Date.class.isAssignableFrom(attributeClass)) {
          property.setObjectForKey("string", "type");
          property.setObjectForKey("date-time", "format");
        }
        else if (Integer.class.isAssignableFrom(attributeClass)) {
          property.setObjectForKey("integer", "type");
        }
        else if (BigDecimal.class.isAssignableFrom(attributeClass)) {
          property.setObjectForKey("number", "type");
        }
        else if (Number.class.isAssignableFrom(attributeClass)) {
          property.setObjectForKey("number", "type");
        }
        else if (Boolean.class.isAssignableFrom(attributeClass)) {
          property.setObjectForKey("boolean", "type");
        }
        else {
          NSLog.out.appendln("Unknown schema type '" + attributeClass.getName() + "' for entity '" + entityName + "'");
          property.setObjectForKey("any", "type");
        }

        properties.setObjectForKey(property, key.key());
      }
    }

    for (String toOneRelationshipName : classDescription.toOneRelationshipKeys()) {
      ERXKey<Object> key = new ERXKey<Object>(toOneRelationshipName);
      if (filter.matches(key, ERXKey.Type.ToOneRelationship)) {
        EOClassDescription destinationClassDescription = classDescription.classDescriptionForDestinationKey(key.key());
        ERXKeyFilter destinationFilter = filter._filterForKey(key);
        NSDictionary<String, Object> destinationSchema = ERXRestSchema.schemaPropertiesForEntityNamed(destinationClassDescription.entityName(), destinationFilter, entities);
        if (destinationSchema != null) {
          properties.setObjectForKey(destinationSchema, key.key());
        }
        else {
          // MS: Recursive reference to an entity .... wtf do we do.
        }
        /*
         * HashMap property = new HashMap(); property.put("$ref", relationship.destinationEntity().name());
         * properties.put(relationship.name(), property);
         */
      }
    }

    for (String toManyRelationshipName : classDescription.toManyRelationshipKeys()) {
      ERXKey<Object> key = new ERXKey<Object>(toManyRelationshipName);
      if (filter.matches(key, ERXKey.Type.ToManyRelationship)) {
        EOClassDescription destinationClassDescription = classDescription.classDescriptionForDestinationKey(key.key());
        ERXKeyFilter destinationFilter = filter._filterForKey(key);
        NSDictionary<String, Object> destinationSchema = ERXRestSchema.schemaPropertiesForEntityNamed(destinationClassDescription.entityName(), destinationFilter, entities);
        if (destinationSchema != null) {
          properties.setObjectForKey(destinationSchema, key.key());
        }
        else {
          // MS: Recursive reference to an entity .... wtf do we do.
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

    return responseNode;
  }

  protected Object _objectWithRequestNode(ERXRestRequestNode node, String entityName) {
    Object obj;
    EOClassDescription classDescription = ERXRestClassDescriptionFactory.classDescriptionForEntityName(entityName);
    if (entityName != null && classDescription == null && !_classDescriptionRequired) {
      obj = node;
    }
    else {
      obj = node.objectWithFilter(entityName, ERXKeyFilter.filterWithAllRecursive(), _context);
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

    public static EOEnterpriseObject createAndInsertObject(EOEditingContext editingContext,
                                                           String entityName,
                                                           NSDictionary objectInfo) {
        if (log.isDebugEnabled())
            log.debug("Creating object of type: " + entityName);
        EOClassDescription cd=EOClassDescription.classDescriptionForEntityName(entityName);
        if (cd==null)
            throw new RuntimeException("Could not find class description for entity named "+entityName);
        EOEnterpriseObject newEO=cd.createInstanceWithEditingContext(editingContext,null);
        editingContext.insertObject(newEO);
        if (objectInfo != null)
            newEO.takeValuesFromDictionary(objectInfo);
        return newEO;
    }
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

    return ERXRestClassDescriptionFactory.classDescriptionForObject(obj, false);
  }

  @SuppressWarnings("unchecked")
  public static EOClassDescription classDescriptionForObject(Object obj, boolean forceNonEntity) {
    EOClassDescription classDescription;
    if (obj == null) {
      classDescription = null;
    }
    else if (obj instanceof EOEnterpriseObject && !forceNonEntity) {
      classDescription = ERXRestClassDescriptionFactory.classDescriptionForEntityName(((EOEnterpriseObject) obj).entityName());
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

  public static EOClassDescription classDescriptionForEntityName(String entityName) {
    if (entityName == null) {
      throw new NullPointerException("You did not specify an entityName.");
    }
    EOClassDescription classDescription = EOClassDescription.classDescriptionForEntityName(entityName);
    if (classDescription == null) {
      Class clazz = _classByName.get(entityName);
      if (clazz == null) {
        clazz = _NSUtilities.classWithName(entityName);
        if (clazz == null) {
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

    }
    return classDescription;
  }

  public static EOClassDescription classDescriptionForClass(Class clazz, boolean forceNonEntity) {
    EOClassDescription classDescription = _classDescriptionByClass.get(clazz);
    if (classDescription == null && !forceNonEntity && EOEnterpriseObject.class.isAssignableFrom(clazz)) {
      classDescription = ERXRestClassDescriptionFactory.classDescriptionForEntityName(clazz.getSimpleName());
    }
    if (classDescription == null) {
      if (NSDictionary.class.isAssignableFrom(clazz)) {
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

  public static EOClassDescription registerClass(Class clazz) {
    return ERXRestClassDescriptionFactory.registerClassForEntityNamed(clazz, clazz.getSimpleName());
  }

  public static EOClassDescription registerClassForEntityNamed(Class clazz, String entityName) {
    EOClassDescription classDescription = classDescriptionForClass(clazz, false);
    ERXRestClassDescriptionFactory.registerClassDescription(classDescription, clazz);
    _classByName.put(entityName, clazz);
    return classDescription;
  }
View Full Code Here

Examples of com.webobjects.eocontrol.EOClassDescription

            System.out.println("someFiles.name: " + someFiles.valueForKey("name"));
            System.out.println("someFiles.content.length: " + someFiles.valueForKeyPath("content.length"));
            System.out.println("someDirectories.count: " + someDirectories.count());
            System.out.println("someDirectories.name: " + someDirectories.valueForKey("name"));
        }
        EOClassDescription aClassDescription = EOClassDescription.classDescriptionForEntityName("FSDirectory");
        EOEnterpriseObject anObject = aClassDescription.createInstanceWithEditingContext(anEditingContext, null);
        anObject.takeValueForKey((System.getProperty("user.home") + File.separator + "FSItemInsertTest"), "absolutePath");

        anEditingContext.insertObject(anObject);
        anEditingContext.saveChanges();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.