Exemple #1
0
    /**
     * Overriden to contruct a valid SQL92 JOIN clause as opposed to the Oracle-like SQL the
     * superclass produces.
     *
     * <p>kieran copied from PostgresqlExpression
     */
    @Override
    public String joinClauseString() {
      NSMutableDictionary<String, Boolean> seenIt = new NSMutableDictionary<String, Boolean>();
      StringBuilder sb = new StringBuilder();
      JoinClauseDefinition jc;
      EOSortOrdering.sortArrayUsingKeyOrderArray(
          _alreadyJoined,
          new NSArray<EOSortOrdering>(
              EOSortOrdering.sortOrderingWithKey("sortKey", EOSortOrdering.CompareAscending)));
      if (_alreadyJoined.count() > 0) {
        jc = _alreadyJoined.objectAtIndex(0);

        sb.append(jc);
        seenIt.setObjectForKey(Boolean.TRUE, jc._table1);
        seenIt.setObjectForKey(Boolean.TRUE, jc._table2);
      }

      for (int i = 1; i < _alreadyJoined.count(); i++) {
        jc = _alreadyJoined.objectAtIndex(i);

        sb.append(jc._op);
        if (seenIt.objectForKey(jc._table1) == null) {
          sb.append(jc._table1);
          seenIt.setObjectForKey(Boolean.TRUE, jc._table1);
        } else if (seenIt.objectForKey(jc._table2) == null) {
          sb.append(jc._table2);
          seenIt.setObjectForKey(Boolean.TRUE, jc._table2);
        }
        sb.append(jc._joinCondition);
      }
      return sb.toString();
    }
Exemple #2
0
 public WOActionResults delete() {
   NSMutableArray personList = (NSMutableArray) session().valueForKey("personList");
   if (personList != null && personList.count() > 0) {
     for (int i = 0; i < personList.count(); i++) {
       PersonLink pers = (PersonLink) personList.objectAtIndex(i);
       if (item == EOUtilities.localInstanceOfObject(ec, pers.person())) {
         personList.removeObjectAtIndex(i);
         break;
       }
     }
   }
   return context().page();
   //		onEdit = null;
 }
  /*
   * (non-Javadoc)
   *
   * @see com.webobjects.eocontrol.EOCustomObject#validateForSave()
   */
  public void validateForSave() throws ValidationException {
    NSMutableArray validationExceptions = new NSMutableArray();
    RuleContext validationContext = validatingEditingContext().validationContext();
    boolean didSetTask = false;

    if (validationContext.valueForKey(ValidatingRecord.TASK_KEY) == null) {
      didSetTask = true;

      validationContext.takeValueForKey(ValidatingRecord.SAVE_VALUE, ValidatingRecord.TASK_KEY);
    }

    validationContext.takeValueForKey(entityName(), ValidatingRecord.ENTITY_NAME_KEY);

    try {
      super.validateForSave();
    } catch (NSValidation.ValidationException ve) {
      validationExceptions.addObject(ve);
    }

    EOClassDescription classDescription = classDescription();

    if (classDescription instanceof ValidatingClassDescription) {
      try {
        ValidatingClassDescription vClassDescription =
            (ValidatingClassDescription) classDescription;

        vClassDescription.validateAdditionalKeys(this);
      } catch (NSValidation.ValidationException ve) {
        validationExceptions.addObject(ve);
      }
    }
    if (didSetTask) {
      validationContext.takeValueForKey(null, ValidatingRecord.TASK_KEY);
    }

    validationContext.takeValueForKey(null, ValidatingRecord.ENTITY_NAME_KEY);

    int vCount = validationExceptions.count();

    if (vCount == 1) {
      throw (NSValidation.ValidationException) validationExceptions.objectAtIndex(0);
    } else if (vCount > 1) {
      throw NSValidation.ValidationException.aggregateExceptionWithExceptions(validationExceptions);
    }
  }
  private String _generateModProxyConfig() {
    StringBuilder result = new StringBuilder();

    result.append("#\n");
    result.append("# Common configuration (if not already set)\n");
    result.append("#\n");
    result.append("ProxyRequests Off\nProxyVia Full\n");
    result.append("#\n");
    result.append("# Give us a name\n");
    result.append("#\n");
    result.append("RequestHeader append x-webobjects-adaptor-version \"mod_proxy\"\n\n\n");

    result.append("#\n");
    result.append("# Balancer routes\n");
    result.append("#\n");

    for (Enumeration<MApplication> e = siteConfig().applicationArray().objectEnumerator();
        e.hasMoreElements(); ) {
      MApplication anApp = e.nextElement();
      anApp.extractAdaptorValuesFromSiteConfig();

      String tmpAdaptor = siteConfig().woAdaptor();
      tmpAdaptor = StringUtils.removeEnd(tmpAdaptor, "/");

      NSArray<String> tmpPath = NSArray.componentsSeparatedByString(tmpAdaptor, "/");

      int count = tmpPath.count();
      String adaptorPath = "/" + tmpPath.get(count - 2) + "/" + tmpPath.get(count - 1) + "/";

      result.append("<Proxy balancer://" + anApp.name() + ".woa>\n");

      NSMutableArray<String> reversePathes = new NSMutableArray<String>();

      for (Enumeration<MInstance> e2 = anApp.instanceArray().objectEnumerator();
          e2.hasMoreElements(); ) {
        MInstance anInst = e2.nextElement();

        anInst.extractAdaptorValuesFromApplication();

        String host = anInst.values().valueForKey("hostName").toString();
        String port = anInst.values().valueForKey("port").toString();

        String url = "http://" + host + ":" + port + adaptorPath + anApp.name() + ".woa";

        result.append("\tBalancerMember ");
        result.append(url);
        result.append(" route=");
        result.append(_proxyBalancerRoute(anApp.name(), host, port));
        result.append('\n');

        reversePathes.add(url);
      }

      result.append("</Proxy>\n");
      result.append("ProxyPass ");
      result.append(adaptorPath);
      result.append(anApp.name());
      result.append(".woa balancer://");
      result.append(anApp.name());
      result.append(".woa stickysession=");
      result.append(_proxyBalancerCookieName(anApp.name()));
      result.append(" nofailover=On\n");

      for (int i = 0; i < reversePathes.count(); i++) {
        String url = reversePathes.objectAtIndex(i);
        result.append("ProxyPassReverse / ");
        result.append(url);
        result.append('\n');
      }
      result.append('\n');
    }

    result.append("#\n");
    result.append("# Balancer configuration\n");
    result.append("#\n");
    for (Enumeration<MApplication> e = siteConfig().applicationArray().objectEnumerator();
        e.hasMoreElements(); ) {
      MApplication anApp = e.nextElement();
      anApp.extractAdaptorValuesFromSiteConfig();
      String name = anApp.name();
      result.append("ProxySet balancer://" + name + ".woa");
      if (timeout != null && timeout.intValue() > 0) {
        result.append(" timeout=");
        result.append(timeout);
      }
      if (loadBalancer != null) {
        result.append(" lbmethod=");
        result.append(loadBalancer);
      } else {
        result.append(" lbmethod=byrequests");
      }
      result.append('\n');
    }

    result.append("#\n");
    result.append("#\n");
    result.append("#\n");

    result.append('\n');
    return result.toString();
  }
Exemple #5
0
 public static NSArray getNextColor() {
   initColors();
   NSArray theColor = (NSArray) theColors.objectAtIndex(0);
   theColors.removeObjectAtIndex(0);
   return theColor;
 }