Examples of ERXMutableURL


Examples of er.extensions.foundation.ERXMutableURL

    return styleKey;
  }

  @Override
  public void appendToResponse(WOResponse response, WOContext context) {
    ERXMutableURL chartUrl = new ERXMutableURL();
    chartUrl.setProtocol("http");
    chartUrl.setHost("chart.apis.google.com");
    chartUrl.setPath("/chart");

    WOComponent component = context.component();

    int width = 300;
    int height = 200;
    if (_size != null) {
      String sizeStr = (String) _size.valueInComponent(component);
      if (sizeStr != null) {
        String[] sizeStrs = sizeStr.split("x");
        width = Integer.parseInt(sizeStrs[0]);
        height = Integer.parseInt(sizeStrs[1]);
      }
    }
    else {
      if (_width != null) {
        width = ERXValueUtilities.intValueWithDefault(_width.valueInComponent(component), width);
      }
      if (_height != null) {
        height = ERXValueUtilities.intValueWithDefault(_height.valueInComponent(component), height);
      }
    }
    chartUrl.setQueryParameter("chs", width + "x" + height);

    NSArray<String> colors = AjaxUtils.arrayValueForAssociation(component, _colors);
    if (colors != null) {
      chartUrl.setQueryParameter("chco", colors.componentsJoinedByString(","));
    }

    List<List<Number>> data = null;
    if (_data != null) {
      Object dataValue = _data.valueInComponent(component);
      if (dataValue instanceof String && ((String) dataValue).length() >= 2 && ((String) dataValue).charAt(1) == ':') {
        chartUrl.setQueryParameter("chd", (String) dataValue);
      }
      else {
        data = GCEncoding.convertToNumberLists(AjaxUtils.arrayValueForAssociation(component, _data));
        chartUrl.setQueryParameter("chd", encode(data, response, context));
      }
    }

    Object scaling = scaling(response, context);
    if (scaling instanceof Boolean && ((Boolean) scaling).booleanValue()) {
      if (data != null) {
        NSMutableArray<String> scaleNumbers = new NSMutableArray<String>();
        for (List<Number> innerList : data) {
          Float minValue = Float.valueOf(GCEncoding.minValueInList(innerList));
          scaleNumbers.addObject(String.format("%1$.1f", minValue));

          Number maxValue = maxValue(response, context);
          if (maxValue == null) {
            maxValue = Float.valueOf(GCEncoding.minValueInList(innerList));
          }
          scaleNumbers.addObject(String.format("%1$.1f", maxValue));
        }

        chartUrl.setQueryParameter("chds", scaleNumbers.componentsJoinedByString(","));
      }
    }
    else {
      chartUrl.setQueryParameter("chds", (String) scaling);
    }

    if (_title != null) {
      String title = (String) _title.valueInComponent(component);
      if (title != null) {
        chartUrl.setQueryParameter("chtt", title);
      }
    }

    if (_titleColor != null || _titleSize != null) {
      String titleColor = "454545";
      if (_titleColor != null) {
        titleColor = (String) _titleColor.valueInComponent(component);
      }
      if (_titleSize != null) {
        Object titleSize = _titleSize.valueInComponent(component);
        chartUrl.setQueryParameter("chts", titleColor + "," + titleSize);
      }
      else {
        chartUrl.setQueryParameter("chts", titleColor);
      }
    }

    if (_lineStyles != null) {
      chartUrl.setQueryParameter("chls", (String) _lineStyles.valueInComponent(component));
    }

    if (_fillArea != null) {
      chartUrl.setQueryParameter("chm", (String) _fillArea.valueInComponent(component));
    }

    if (_rangeMarkers != null) {
      chartUrl.setQueryParameter("chm", (String) _rangeMarkers.valueInComponent(component));
    }

    if (_shapeMarkers != null) {
      chartUrl.setQueryParameter("chm", (String) _shapeMarkers.valueInComponent(component));
    }

    if (_gridLines != null) {
      chartUrl.setQueryParameter("chg", (String) _gridLines.valueInComponent(component));
    }
    else if (_gridXStep != null || _gridYStep != null || _gridLineSize != null || _gridBlankSize != null) {
      StringBuilder chg = new StringBuilder();
      if (_gridXStep != null && _gridYStep != null) {
        chg.append(_gridXStep.valueInComponent(component));
        chg.append(',');
        chg.append(_gridYStep.valueInComponent(component));
      }

      if (_gridLineSize != null || _gridBlankSize != null) {
        if (chg.length() == 0) {
          chg.append("20,50");
        }

        if (_gridLineSize != null) {
          chg.append(',');
          chg.append(_gridLineSize.valueInComponent(component));
        }

        if (_gridBlankSize != null) {
          if (_gridLineSize == null) {
            chg.append(",5");
          }
          chg.append(',');
          chg.append(_gridBlankSize.valueInComponent(component));
        }
      }
      chartUrl.setQueryParameter("chg", chg.toString());
    }

    StringBuilder fill = new StringBuilder();

    String backgroundStyle = "solid";
    if (_backgroundStyle != null) {
      backgroundStyle = (String) _backgroundStyle.valueInComponent(component);
    }
    if (_background != null) {
      fill.append("bg,");
      fill.append(styleKey(backgroundStyle));
      fill.append(',');
      fill.append(_background.valueInComponent(component));
    }

    String chartBackgroundStyle = "solid";
    if (_chartBackgroundStyle != null) {
      chartBackgroundStyle = (String) _chartBackgroundStyle.valueInComponent(component);
    }
    if (_chartBackground != null) {
      if (fill.length() > 0) {
        fill.append('|');
      }
      fill.append("c,");
      fill.append(styleKey(chartBackgroundStyle));
      fill.append(',');
      fill.append(_chartBackground.valueInComponent(component));
    }

    if (_chartBackground != null || _transparency != null) {
      if (_transparency != null) {
        if (fill.length() > 0) {
          fill.append('|');
        }
        fill.append("a,s,");
        fill.append(_transparency.valueInComponent(component));
      }
    }

    if (fill.length() > 0) {
      chartUrl.setQueryParameter("chf", fill.toString());
    }

    NSArray<String> legend = AjaxUtils.arrayValueForAssociation(component, _legend);
    if (legend != null) {
      chartUrl.setQueryParameter("chdl", legend.componentsJoinedByString("|"));
    }

    NSArray<String> labeledAxes = AjaxUtils.arrayValueForAssociation(component, _labeledAxes);
    if (labeledAxes != null) {
      chartUrl.setQueryParameter("chxt", labeledAxes.componentsJoinedByString(","));
    }

    NSArray<Object> axisLabels = AjaxUtils.arrayValueForAssociation(component, _axisLabels);
    if (axisLabels != null) {
      StringBuilder axisLabelsStr = new StringBuilder();
      for (int i = 0; i < axisLabels.count(); i++) {
        Object singleAxisLabels = axisLabels.objectAtIndex(i);
        if (i > 0) {
          axisLabelsStr.append('|');
        }
        axisLabelsStr.append(i + ":|");
        if (singleAxisLabels instanceof Object[]) {
          axisLabelsStr.append(new NSArray<Object>((Object[]) singleAxisLabels).componentsJoinedByString("|"));
        }
        else {
          axisLabelsStr.append(singleAxisLabels);
        }
      }
      chartUrl.setQueryParameter("chxl", axisLabelsStr.toString());
    }

    if (_custom != null) {
      String custom = (String) _custom.valueInComponent(component);
      if (custom != null) {
        try {
          chartUrl.addQueryParameters(custom);
        }
        catch (MalformedURLException e) {
          throw new IllegalArgumentException("Failed to add the query parameters '" + custom + "'.", e);
        }
      }
    }
    addQueryParameters(chartUrl, response, context);

    response.appendContentString("<img");
    if (_id != null) {
      response._appendTagAttributeAndValue("id", (String) _id.valueInComponent(component), true);
    }
    if (_class != null) {
      response._appendTagAttributeAndValue("class", (String) _class.valueInComponent(component), true);
    }
    if (_alt != null) {
      response._appendTagAttributeAndValue("alt", (String) _alt.valueInComponent(component), true);
    }
    String chartSrc = WOMessage.stringByEscapingHTMLAttributeValue(chartUrl.toExternalForm());
    response._appendTagAttributeAndValue("src", chartSrc, false);
    response._appendTagAttributeAndValue("width", String.valueOf(width), false);
    response._appendTagAttributeAndValue("height", String.valueOf(height), false);
    response.appendContentString("/>");
  }
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

    AjaxSocialNetwork._socialNetworks.setObjectForKey(socialNetwork, name);
  }
 
  protected String _submissionUrl(String baseUrl, String urlKey, String targetUrl, String titleKey, String title, NSDictionary<String, String> additionalParams) {
    try {
      ERXMutableURL url = new ERXMutableURL(baseUrl);
      url.setQueryParameter(urlKey, targetUrl);
      if (titleKey != null && title != null) {
        url.setQueryParameter(titleKey, title);
      }
      if (additionalParams != null) {
        url.addQueryParameters(additionalParams);
      }
      return url.toString();
    }
    catch (Throwable t) {
      throw new RuntimeException("Failed to create a URL for '" + baseUrl + "' with the targetUrl '" + targetUrl + "'");
    }
  }
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

          if(!generatingCompleteURLs) {
            context.generateCompleteURLs();
          }
          try {
            _url = context._directActionURL(directActionName, queryDictionary, secure, 0, false);
            ERXMutableURL u = new ERXMutableURL(_url);
            u.addQueryParameter(String.valueOf(System.currentTimeMillis()), null);
            _url = u.toExternalForm();
          } catch (MalformedURLException e) {
            throw new NSForwardException(e);
          } finally {
            if(!generatingCompleteURLs) {
              context.generateRelativeURLs();
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

  }

  @SuppressWarnings("unchecked")
  public <T> T objectWithPath(String path, String entityName) throws HttpException, IOException {
    HttpClient client = httpClient();
    GetMethod fetchObjectMethod = new GetMethod(new ERXMutableURL(_baseURL).appendPath(path).toExternalForm());
    client.executeMethod(fetchObjectMethod);
    ERXRestRequestNode node = requestNodeWithMethod(fetchObjectMethod);
    return (T) _objectWithRequestNode(node, entityName);
  }
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

  }

  @SuppressWarnings("unchecked")
  public <T> T objectWithPath(String path) throws HttpException, IOException {
    HttpClient client = httpClient();
    GetMethod fetchObjectMethod = new GetMethod(new ERXMutableURL(_baseURL).appendPath(path).toExternalForm());
    client.executeMethod(fetchObjectMethod);
    ERXRestRequestNode node = requestNodeWithMethod(fetchObjectMethod);
    String type = node.type();
    return (T) _objectWithRequestNode(node, type);
  }
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

    ERXRestRequestNode node = ERXRestRequestNode.requestNodeWithObjectAndFilter(obj, filter, _context);
    ERXStringBufferRestResponse response = new ERXStringBufferRestResponse();
    format.writer().appendToResponse(node, response, format.delegate(), _context);

    HttpClient client = httpClient();
    PutMethod updateObjectMethod = new PutMethod(new ERXMutableURL(_baseURL).appendPath(path).toExternalForm());
    updateObjectMethod.setRequestEntity(new StringRequestEntity(response.toString()));
    client.executeMethod(updateObjectMethod);
    return requestNodeWithMethod(updateObjectMethod);
  }
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

    ERXRestRequestNode node = ERXRestRequestNode.requestNodeWithObjectAndFilter(obj, filter, _context);
    ERXStringBufferRestResponse response = new ERXStringBufferRestResponse();
    format.writer().appendToResponse(node, response, format.delegate(), _context);

    HttpClient client = httpClient();
    PostMethod updateObjectMethod = new PostMethod(new ERXMutableURL(_baseURL).appendPath(path).toExternalForm());
    updateObjectMethod.setRequestEntity(new StringRequestEntity(response.toString()));
    client.executeMethod(updateObjectMethod);
    return requestNodeWithMethod(updateObjectMethod, format);
  }
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

  public ERXRestRequestNode deleteObjectWithPath(Object obj, String path, ERXRestFormat format) throws HttpException, IOException {
    ERXRestRequestNode node = ERXRestRequestNode.requestNodeWithObjectAndFilter(obj, ERXKeyFilter.filterWithNone(), _context);

    HttpClient client = httpClient();
    DeleteMethod deleteObjectMethod = new DeleteMethod(new ERXMutableURL(_baseURL).appendPath(path).toExternalForm());
    client.executeMethod(deleteObjectMethod);
    return requestNodeWithMethod(deleteObjectMethod);
  }
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

    try {
      _fetchIndex = 0;

      NSMutableDictionary<String, Object> attributesFromQualifier = new NSMutableDictionary<String, Object>();
      ERXMutableURL url = new ERXMutableURL(urlForQualifier(entity, fetchSpecification.qualifier(), attributesFromQualifier));
      InputStream urlStream = new BufferedInputStream(url.toURL().openStream());
      Document document;
      try {
        document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(urlStream);
      }
      finally {
View Full Code Here

Examples of er.extensions.foundation.ERXMutableURL

      }
      else {
        response.appendContentString("<a href = \"");
        if (_download != null && _download.booleanValueInComponent(component)) {
          try {
            ERXMutableURL attachmentMutableUrl = new ERXMutableURL(attachmentUrl);
            attachmentMutableUrl.addQueryParameter("attachment", "true");
            attachmentUrl = attachmentMutableUrl.toExternalForm();
          }
          catch (MalformedURLException e) {
            throw new RuntimeException("Failed to create attachment URL.", e);
          }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.