private String documentRoot() {
   if (_documentRoot == null) {
     _documentRoot = ERXProperties.stringForKey("WODocumentRoot");
     if (_documentRoot == null) {
       NSBundle bundle = NSBundle.bundleForName("JavaWebObjects");
       NSDictionary dict =
           ERXDictionaryUtilities.dictionaryFromPropertyList("WebServerConfig", bundle);
       _documentRoot = (String) dict.objectForKey("DocumentRoot");
     }
   }
   return _documentRoot;
 }
Ejemplo n.º 2
0
public class ERBAssignment extends ERDAssignment {

  /** */
  private static final long serialVersionUID = 1L;

  public ERBAssignment(EOKeyValueUnarchiver u) {
    super(u);
  }

  public ERBAssignment(String key, Object value) {
    super(key, value);
    // TODO Auto-generated constructor stub
  }

  /** holds the array of keys this assignment depends upon */
  @SuppressWarnings({"unchecked", "rawtypes"})
  protected static final NSDictionary keys =
      ERXDictionaryUtilities.dictionaryWithObjectsAndKeys(
          new Object[] {
            new NSArray(new Object[] {"task", "entity.name", "pageConfiguration"}),
                "idForUpdateContainer",
            new NSArray(new Object[] {"task", "entity.name", "pageConfiguration"}),
                "idForRepetitionContainer",
            new NSArray(new Object[] {"task", "entity.name", "pageConfiguration"}),
                "idForMainContainer",
            new NSArray(new Object[] {"task", "entity.name", "pageConfiguration"}),
                "idForPageTabContainer",
            new NSArray(new Object[] {"task", "entity.name", "pageConfiguration", "propertyKey"}),
                "idForPropertyContainer",
            new NSArray(
                    new Object[] {
                      "task", "entity.name", "pageConfiguration", "parentPageConfiguration"
                    }),
                "idForParentPageConfiguration",
            new NSArray(
                    new Object[] {
                      "task", "entity.name", "pageConfiguration", "parentPageConfiguration"
                    }),
                "idForParentMainContainer"
          });

  /**
   * Static constructor required by the EOKeyValueUnarchiver interface. If this isn't implemented
   * then the default behavior is to construct the first super class that does implement this
   * method. Very lame.
   *
   * @param eokeyvalueunarchiver to be unarchived
   * @return decoded assignment of this class
   */
  public static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver eokeyvalueunarchiver) {
    return new ERBAssignment(eokeyvalueunarchiver);
  }

  @Override
  public NSArray dependentKeys(String keyPath) {
    return (NSArray) keys.valueForKey(keyPath);
  }

  public String idForUpdateContainer(D2WContext c) {
    return "JQAUC_" + idForPageConfiguration(c);
  }

  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;
  }

  public String idForParentPageConfiguration(D2WContext c) {
    String parentConfig = (String) c.valueForKey("parentPageConfiguration");
    if (parentConfig == null) {
      parentConfig = "NO_PARENT_CONFIGURATION_" + idForPageConfiguration(c);
    }
    return parentConfig;
  }

  // IDs

  public String idForMainContainer(D2WContext c) {
    return "MUC_" + idForPageConfiguration(c);
  }

  public String idForParentMainContainer(D2WContext c) {
    return "MUC_" + idForParentPageConfiguration(c);
  }

  public String idForRepetitionContainer(D2WContext c) {
    return "RUC_" + idForPageConfiguration(c);
  }

  public String idForPageTabContainer(D2WContext c) {
    return "PTUC_" + idForPageConfiguration(c);
  }

  public String idForPropertyContainer(D2WContext c) {
    return "PCUC_" + idForPageConfiguration(c) + "_" + cssClassForPropertyKey(c.propertyKey());
  }

  /**
   * Cleans the propertyKey, removing "." and capitalizing key path components
   *
   * @param key
   */
  public String cssClassForPropertyKey(String key) {
    if (key != null) {
      String temp = "";
      if (key.indexOf(".") != -1) {
        NSArray<String> components = NSArray.componentsSeparatedByString(key, ".");
        for (String string : components) {
          string = ERXStringUtilities.capitalize(string);
          temp = temp + string;
        }
      } else {
        temp = ERXStringUtilities.capitalize(key);
      }
      key = temp;
    }
    return key;
  }
}
Ejemplo n.º 3
0
 /**
  * Creates a dictionary from an object and a list of key paths
  *
  * @param object object to pull the values from
  * @param keys list of keys
  * @return Returns a {@code NSDictionary} containing all of the object-key pairs.
  */
 public static NSDictionary<String, Object> dictionaryFromObjectWithKeys(
     Object object, String... keys) {
   return ERXDictionaryUtilities.dictionaryFromObjectWithKeys(object, new NSArray<>(keys));
 }