Examples of ERXRestContext


Examples of er.rest.ERXRestContext

      String entityName = (String) valueForBinding("entityName");
      if (entityName == null) {
        entityName = ERXRestClassDescriptionFactory.entityNameForObject(record);
      }
      EOEditingContext editingContext = ERXEC.newEditingContext();
      Object entityID = IERXRestDelegate.Factory.delegateForEntityNamed(entityName).primaryKeyForObject(record, new ERXRestContext(editingContext));
      editingContext.dispose();
      linkUrl = ERXRouteUrlUtils.actionUrlForEntity(context(), entityName, entityID, action, format, queryParameters, secure, includeSessionID);
    }
    else {
      String entityName = (String) valueForBinding("entityName");
View Full Code Here

Examples of er.rest.ERXRestContext

    * Creates a new rest context for the controller.
   *
   * @return a new rest context for the controller
  */
  protected ERXRestContext createRestContext() {
    return new ERXRestContext(editingContext());
  }
View Full Code Here

Examples of er.rest.ERXRestContext

   
    ERXRestNameRegistry.registry().setExternalNameForInternalName("Company", "ClientCompany");
    IERXRestDelegate.Factory.setDefaultDelegate(new ERXNoOpRestDelegate());
    IERXRestDelegate.Factory.setDelegateForEntityNamed(new ClientCompanyRestDelegate(), "ClientCompany", ClientCompany.class);

    ERXRestClient client = new ERXRestClient(baseURL, new ERXRestContext());
    ClientCompany c = client.objectWithPath("Company/1.json");
    System.out.println("Client.main: single company = " + c);

    Object obj = new ERXRestClient(client.baseURL(), new ERXRestContext(), false).objectWithPath("Pet/1.json");
    System.out.println("Client.main: unknown class = " + obj);

    NSArray<ClientCompany> comps = client.objectWithPath("Company.json", "ClientCompany");
    System.out.println("Client.main: array of companies = " + comps);

    c.setName("New Name");
    client.updateObjectWithPath(c, ERXKeyFilter.filterWithAllRecursive(), "Company/1.json", ERXRestFormat.json());

    ClientCompany updatedCompany = client.objectWithPath("Company/1.json");
    System.out.println("Client.main: updated company = " + updatedCompany);
   
    NSMutableDictionary<String, Object> dict = new NSMutableDictionary<String, Object>();
    dict.setObjectForKey("Schrag", "lastName");
    dict.setObjectForKey("Mike", "firstName");
    dict.setObjectForKey(new NSDictionary<String, Object>("true", "nested"), "child");
    dict.setObjectForKey(new NSArray<String>("a", "b"), "array");
    String dictJSON = ERXRestFormat.json().toString(dict);
    System.out.println("Client.main: dictionary as JSON " + dictJSON);

    NSArray<?> list = new NSArray<String>("a", "b");
    String arrayJSON = ERXRestFormat.json().toString(list);
    System.out.println("Client.main: array as JSON " + arrayJSON);

    ClientCompany newCompany = new ClientCompany();
    newCompany.setName("Peters Pickles");
    ERXRestRequestNode node = client.createObjectWithPath(newCompany, ERXKeyFilter.filterWithAllRecursive(), "Company.json", ERXRestFormat.json());
    System.out.println("Client.main: The newly created company is: " + node.toString(ERXRestFormat.json(), new ERXRestContext()));
  }
View Full Code Here

Examples of er.rest.ERXRestContext

    String newUrl = url.replaceFirst("/" + WOApplication.application().directActionRequestHandlerKey() + "(/|$)", "/" + newRequestHandler + "$1");
    return newUrl;
  }

  public static String actionUrlForRecord(WOContext context, ERXGenericRecord record, String action, String format, NSDictionary<String, Object> queryParameters, boolean secure, boolean includeSessionID) {
    Object entityID = IERXRestDelegate.Factory.delegateForEntityNamed(record.entityName()).primaryKeyForObject(record, new ERXRestContext(record.editingContext()));
    String url = ERXWOContext.directActionUrl(context, ERXRouteUrlUtils.actionUrlPathForEntity(record.entityName(), entityID, action, format), queryParameters, Boolean.valueOf(secure), includeSessionID);
    url = ERXRouteUrlUtils.changeDirectActionRequestHandlerTo(url, ERXRouteRequestHandler.Key);
    return url;
  }
View Full Code Here

Examples of er.rest.ERXRestContext

  public static void main(String[] args) {
    String str = "<Company><id>100</id><type>Company</type><name>mDT</name><firstName nil=\"true\"/><employees><Employee id=\"101\" type=\"Employee\"/><Employee id=\"102\"><name>Mike</name></Employee></employees></Company>";
    //String str = "<Employees><Employee id=\"101\" type=\"Employee\"/><Employee id=\"102\"><name>Mike</name></Employee></Employees>";
    ERXRestNameRegistry.registry().setExternalNameForInternalName("Super", "Company");
    ERXRestNameRegistry.registry().setExternalNameForInternalName("Super2", "Employee");
    ERXRestContext context = new ERXRestContext();
    ERXRestRequestNode n = new ERXXmlRestParser().parseRestRequest(new ERXStringRestRequest(str), new ERXRestFormatDelegate(), context);
    ERXStringBufferRestResponse response = new ERXStringBufferRestResponse();
    new ERXXmlRestWriter().appendToResponse(n, response, new ERXRestFormatDelegate(), context);
    System.out.println("ERXXmlRestParser.main: " + response);
  }
View Full Code Here

Examples of er.rest.ERXRestContext

   * @return the parsed request node
   */
  public ERXRestRequestNode parse(String str) {
    EOEditingContext editingContext = ERXEC.newEditingContext();
    try {
      ERXRestRequestNode node = parse(str, new ERXRestContext(editingContext));
      return node;
    }
    finally {
      editingContext.dispose();
    }
View Full Code Here

Examples of er.rest.ERXRestContext

   * @param obj the object to render
   * @return obj rendered using this format
   */
  public String toString(Object obj) {
    EOEditingContext editingContext = (obj instanceof EOEnterpriseObject) ? ((EOEnterpriseObject)obj).editingContext() : null;
    return toString(obj, new ERXRestContext(editingContext));
  }
View Full Code Here

Examples of er.rest.ERXRestContext

   * @param obj the object to render
   * @return obj rendered using this format
   */
  public String toString(Object obj, ERXKeyFilter filter) {
    EOEditingContext editingContext = (obj instanceof EOEnterpriseObject) ? ((EOEnterpriseObject)obj).editingContext() : null;
    return toString(obj, filter, new ERXRestContext(editingContext));
  }
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.