コード例 #1
0
    public void prepareUpdateExpressionWithRow(NSDictionary row, EOQualifier qualifier) {
      EOAttribute attribute;
      Object value;
      for (Enumeration enumeration = row.keyEnumerator();
          enumeration.hasMoreElements();
          addUpdateListAttribute(attribute, value)) {
        String attributeName = (String) enumeration.nextElement();
        attribute = this.entity().anyAttributeNamed(attributeName);
        if (attribute == null)
          throw new IllegalStateException(
              "prepareUpdateExpressionWithRow: row argument contains key '"
                  + attributeName
                  + "' which does not have corresponding attribute on entity '"
                  + this.entity().name()
                  + "'");
        value = row.objectForKey(attributeName);
      }

      _whereClauseString =
          EOQualifierSQLGeneration.Support._sqlStringForSQLExpression(qualifier, this);
      String tableList = tableListWithRootEntity(_rootEntityForExpression());
      _statement =
          assembleUpdateStatementWithRow(
              row, qualifier, tableList, new String(_listString), _whereClauseString);
    }
コード例 #2
0
  @Override
  public D2WContext subContext() {
    if (_context == null) {
      String s = hasBinding("_dynamicPage") ? (String) valueForBinding("_dynamicPage") : null;
      if (s != null) {
        _context = makeSubContextForDynamicPageNamed(s, session());
      } else {
        _context =
            makeSubContextForTaskAndEntity(
                task(), EOModelGroup.defaultGroup().entityNamed(entityName()), session());
      }
      String s1 = lookFromSettings();
      if (s1 != null) {
        _context.takeValueForInferrableKey(lookFromSettings(), D2WModel.LookKey);
      }
      _context.takeValueForKey(
          _context.task() + "CurrentObject",
          D2WComponent.keyForGenerationReplacementForVariableNamed("currentObject"));
    }
    NSDictionary nsdictionary = settings();
    if (nsdictionary != null) {
      String s2;
      for (Enumeration enumeration = nsdictionary.keyEnumerator();
          enumeration.hasMoreElements();
          _context.takeValueForInferrableKey(nsdictionary.valueForKey(s2), s2)) {
        s2 = (String) enumeration.nextElement();
      }
    }

    if (log.isDebugEnabled()) log.debug(hashCode() + ": context: " + _context);
    return _context;
  }
コード例 #3
0
  protected static NSDictionary expansionLookup() {
    if (RuleModelUtilities.expansionLookup == null) {
      NSDictionary lookupDictionary = RuleModelUtilities.compressionLookup();
      Enumeration keys = lookupDictionary.keyEnumerator();
      NSMutableDictionary lookup = new NSMutableDictionary(lookupDictionary.count());

      while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = lookupDictionary.objectForKey(key);

        lookup.setObjectForKey(key, value);
      }

      // Direct To Web rule editor compatibility
      lookup.setObjectForKey(
          BooleanAssignment.class.getName(), "com.webobjects.directtoweb.BooleanAssignment");
      lookup.setObjectForKey(Rule.class.getName(), "com.webobjects.directtoweb.Rule");
      lookup.setObjectForKey(
          SimpleAssignment.class.getName(), "com.webobjects.directtoweb.Assignment");
      lookup.setObjectForKey(
          KeyValueAssignment.class.getName(), "com.webobjects.directtoweb.KeyValueAssignment");

      RuleModelUtilities.expansionLookup = lookup;
    }

    return RuleModelUtilities.expansionLookup;
  }
コード例 #4
0
 public static <K, V> NSDictionary<K, V> removeNullValues(NSDictionary<K, V> dict) {
   NSMutableDictionary<K, V> d = new NSMutableDictionary<K, V>();
   for (Enumeration<K> e = dict.keyEnumerator(); e.hasMoreElements(); ) {
     K key = e.nextElement();
     V o = dict.objectForKey(key);
     if (!(o instanceof NSKeyValueCoding.Null)) {
       d.setObjectForKey(o, key);
     }
   }
   return d;
 }
コード例 #5
0
 @Override
 public NSDictionary statistics() {
   NSDictionary stats = super.statistics();
   NSMutableDictionary fixed = stats.mutableClone();
   for (Enumeration enumerator = stats.keyEnumerator(); enumerator.hasMoreElements(); ) {
     Object key = enumerator.nextElement();
     Object value = stats.objectForKey(key);
     fixed.setObjectForKey(fix(value), key);
   }
   stats = fixed;
   return stats;
 }
コード例 #6
0
  protected static NSDictionary transformDictionary(NSDictionary dictionary, NSDictionary lookup) {
    NSMutableDictionary transformedDictionary = new NSMutableDictionary(dictionary.count());
    Enumeration keys = dictionary.keyEnumerator();

    while (keys.hasMoreElements()) {
      Object key = keys.nextElement();
      Object value = dictionary.objectForKey(key);

      transformedDictionary.setObjectForKey(RuleModelUtilities.transform(value, lookup), key);
    }

    return transformedDictionary;
  }
コード例 #7
0
    public void prepareInsertExpressionWithRow(NSDictionary row) {
      EOAttribute attribute;
      Object value;
      for (Enumeration enumeration = row.keyEnumerator();
          enumeration.hasMoreElements();
          this.addInsertListAttribute(attribute, value)) {
        String attributeName = (String) enumeration.nextElement();
        attribute = this.entity().anyAttributeNamed(attributeName);
        if (attribute == null)
          throw new IllegalStateException(
              "prepareInsertExpressionWithRow: row argument contains key '"
                  + attributeName
                  + "' which does not have corresponding attribute on entity '"
                  + this.entity().name()
                  + "'");
        value = row.objectForKey(attributeName);
      }

      String tableList = tableListWithRootEntity(_rootEntityForExpression());
      _statement =
          this.assembleInsertStatementWithRow(
              row, tableList, new String(_listString), new String(_valueListString));
    }
コード例 #8
0
  /**
   * Decodes all of the objects for a given set of form values in the given editing context. The
   * object encoding is very simple, just a generic entity name primary key pair where the key is
   * potentially encrypted using blowfish. The specific encoding is specified in the method: <code>
   * encodeEnterpriseObjectsPrimaryKeyForUrl
   * </code>.
   *
   * @param ec editingcontext to fetch the objects from
   * @param values form value dictionary where the values are an encoded representation of the
   *     primary key values in either cleartext or encrypted format.
   * @return array of enterprise objects corresponding to the passed in form values.
   */
  public static NSArray decodeEnterpriseObjectsFromFormValues(
      EOEditingContext ec, NSDictionary values) {
    if (ec == null)
      throw new IllegalArgumentException(
          "Attempting to decode enterprise objects with null editing context.");
    if (values == null)
      throw new IllegalArgumentException(
          "Attempting to decode enterprise objects with null form values.");
    if (log.isDebugEnabled()) log.debug("values = " + values);
    NSMutableArray result = new NSMutableArray();

    String separator =
        values.objectForKey("sep") != null
            ? (String) values.objectForKey("sep")
            : entityNameSeparator();

    for (Enumeration e = values.keyEnumerator(); e.hasMoreElements(); ) {
      Object o = e.nextElement();
      String key = (String) o;
      if (key.indexOf(separator) != -1) {
        boolean isEncrypted = key.indexOf(separator + "E") != -1;
        String encodedEntityName = key.substring(0, key.indexOf(separator));
        String entityName = entityNameDecode(encodedEntityName);
        entityName = entityName == null ? encodedEntityName : entityName;
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        if (entity != null) {
          NSDictionary pk =
              processPrimaryKeyValue((String) values.objectForKey(key), entity, isEncrypted);
          result.addObject(EOUtilities.objectWithPrimaryKey(ec, entity.name(), pk));
        } else {
          log.warn("Unable to find entity for name: " + entityName);
        }
      }
    }
    return result;
  }