Package org.springframework.hateoas.client

Examples of org.springframework.hateoas.client.Agent


    return browser;
  }

  private static void getProductsOfPerson(Browser browser, int personId) throws GoalNotFoundException {

    Agent agent = new Agent(browser);

    // order of follow rel actions is significant
    agent.addFollowRelAction(new FollowRelAction("search"));
    agent.addFollowRelAction(new FollowRelAction("products"));

    // enable client to submit form when encountered
    agent.addSubmitFormAction(new SubmitFormAction("searchPerson", Args.of("personId", personId)));

    agent.setGoal(describedBy("http://example.com/doc#product").within(describedBy("http://example.com/doc#customer")));
    Browsable result = agent.browseForGoal();

    System.out.println("\n--- result ---");
    System.out.println(result.toString());
    System.out.println("--------------\n");
  }
View Full Code Here


   * @param toAccount
   * @param amount
   * @throws GoalNotFoundException
   */
  private static void transferMoney(Browser browser, String fromAccount, String toAccount, BigInteger amount) throws GoalNotFoundException {
    Agent agent = new Agent(browser);
    // collect follow rel actions from describedBy URL
    // for json-ld, would that be the context?
    // could we construct schema.org actions for this?
    agent.identifyGoal("http://localhost:8080/banking/ns/transfer", browser.getCurrentContext());

    // enable client to submit forms
    // TODO: look into schema.org actions to see if they say something about required data for an action.
    agent.addSubmitFormAction(new SubmitFormAction("bankAccountForm", Args.of("accountNumber", fromAccount)));
    agent.addSubmitFormAction(new SubmitFormAction("moneyTransferForm", Args.of("amount", amount, "to", toAccount)));

    Browsable result = agent.browseForGoal();
    System.out.println("\n--- result ---");
    System.out.println(result.toString());
    System.out.println("--------------\n");
  }
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.client.Agent

Copyright © 2018 www.massapicom. 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.