public Object fire(D2WContext c) { NSMutableArray<Object> results = new NSMutableArray<Object>(); NSArray<String> keyPaths = (NSArray<String>) value(); for (String path : keyPaths) { results.addObject(c.valueForKeyPath(path)); } return results; }
protected EOQualifier extraQualifier(D2WContext c, NSDictionary<String, Object> dict) { NSMutableArray<EOQualifier> qualifiers = new NSMutableArray<>(); EOQualifier result = null; for (String key : dict.allKeys()) { Object value = null; if (dict.objectForKey(key) instanceof NSDictionary) { // qualifier definition with operator NSDictionary qDict = (NSDictionary) dict.objectForKey(key); if (qDict.size() == 1) { String operatorKey = (String) qDict.allKeys().lastObject(); String contextKeyPath = (String) qDict.objectForKey(operatorKey); if ("NSKeyValueCoding.NullValue".equals(contextKeyPath)) { value = NSKeyValueCoding.NullValue; } else { value = c.valueForKeyPath(contextKeyPath); } if (value != null) { EOQualifier q = qualifierForOperatorAndObject(key, operatorKey, value); qualifiers.addObject(q); } } } else { value = c.valueForKeyPath((String) dict.objectForKey(key)); if (value != null) { EOQualifier q; if (value instanceof NSArray) { q = qualifierForArray(key, (NSArray) value); } else { if (value == NSKeyValueCoding.NullValue) { value = null; } q = qualifierForObject(key, value); } if (q != null) { qualifiers.addObject(q); } } } } if (qualifiers.count() > 0) result = new EOAndQualifier(qualifiers); if (log.isDebugEnabled()) { log.debug("Computed qualifier: " + result); } return result; }
// FIXME: Should check for NSKeyValueCoding.NullValue public Object fireNow(D2WContext c) { Object result = null; String keyPath; String resultKey; NSDictionary conditionAssignment = (NSDictionary) this.value(); keyPath = (String) conditionAssignment.valueForKey("nonNullKeyPath"); resultKey = c.valueForKeyPath(keyPath) == null ? "falseValue" : "trueValue"; result = conditionAssignment.objectForKey(resultKey); if (log.isDebugEnabled()) log.debug("ResultKey: " + resultKey + " = " + result); return result; }