@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;
  }
 public static D2WContext makeSubContextForTaskAndEntity(
     String s, EOEntity eoentity, WOSession wosession) {
   D2WContext d2wcontext = ERD2WContext.newContext(wosession);
   d2wcontext.setTask(s);
   d2wcontext.setEntity(eoentity);
   d2wcontext.takeValueForKey(D2WModel.One, D2WModel.FrameKey);
   return d2wcontext;
 }
Пример #3
0
 public String idForParentPageConfiguration(D2WContext c) {
   String parentConfig = (String) c.valueForKey("parentPageConfiguration");
   if (parentConfig == null) {
     parentConfig = "NO_PARENT_CONFIGURATION_" + idForPageConfiguration(c);
   }
   return parentConfig;
 }
 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;
 }
 public static D2WContext makeSubContextForDynamicPageNamed(String s, WOSession wosession) {
   D2WContext d2wcontext = ERD2WContext.newContext(wosession);
   d2wcontext.setDynamicPage(s);
   // NOTE AK: for whatever reason, when you set a page config
   d2wcontext.setEntity(d2wcontext.entity());
   d2wcontext.setTask(d2wcontext.task());
   d2wcontext.takeValueForKey(D2WModel.One, D2WModel.FrameKey);
   return d2wcontext;
 }
 // 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;
 }
  // FIXME resetting the caches breaks the context in the embedded component
  public void resetCaches() {
    // log.debug("Resetting caches");
    // takeValueForKey(null,"_task"); // this will break in 5.0 :-)
    // takeValueForKey(null,"_entityName");
    // Finalizing a context is a protected method, hence the utility.
    // ERD2WUtilities.finalizeContext((D2WContext)valueForKey("subContext"));
    // takeValueForKey(null,"_context");

    // HACK HACK HACK ak: When you have several embedded list components in
    // a tab page
    // D2W gets very confused about the keys. It will assume that the
    // objects on the second tab somehow belong to the first
    // resetting the cache when setting a new page configuration prevents
    // this
    D2WContext subContext = (D2WContext) valueForKey("subContext");
    ERD2WUtilities.resetContextCache(subContext);
    subContext.setDynamicPage((String) valueForBinding("_dynamicPage"));
    subContext.takeValueForKey(D2WModel.One, D2WModel.FrameKey);
    subContext.takeValueForKey(session(), D2WModel.SessionKey);
  }
Пример #9
0
 public String idForPageConfiguration(D2WContext c) {
   String result = c.task() + "_NoEntity";
   if (c.dynamicPage() != null) {
     result = c.dynamicPage();
   } else if (c.entity() != null) {
     result = c.task() + "_" + c.entity().name();
   }
   return result;
 }
Пример #10
0
 public String idForPropertyContainer(D2WContext c) {
   return "PCUC_" + idForPageConfiguration(c) + "_" + cssClassForPropertyKey(c.propertyKey());
 }
Пример #11
0
 /**
  * Gives each property its own d2wContext rather than sharing one Necessary for ajax or dyanmic
  * D2W
  */
 @Override
 public void setPropertyKey(String propertyKey) {
   _subContext = new D2WContext(d2wContext());
   _subContext.takeValueForKey(propertyKey, "propertyKey");
 }