Examples of newRepresentation()


Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

    Preconditions.checkNotNull(item, "item");
    Preconditions.checkNotNull(item.getId(), "id");

    RepresentationFactory factory = new DefaultRepresentationFactory();

    return factory.newRepresentation("/item/" + item.getId())
      // Must use individual property entries due to collections
      .withProperty("sku", item.getSKU())
      .withProperty("gtin", item.getGTIN());

  }
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

    Representation publicItemRepresentation = new PublicItemRepresentation().get(deliveryItem.getItem());

    // Create the wrapping DeliveryItem resource
    RepresentationFactory factory = new DefaultRepresentationFactory();

    return factory.newRepresentation("/delivery/item/" + deliveryItem.getItem().getSKU())
      .withProperty("supplier_sku", deliveryItem.getSupplierSKU())
      .withProperty("supplier_gtin", deliveryItem.getSupplierGTIN())
      .withProperty("batch_reference", deliveryItem.getBatchReference())
      .withProperty("quantity", deliveryItem.getQuantity())
      .withProperty("price_subtotal", deliveryItem.getPriceSubtotal().getAmount().toPlainString())
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

        .fromUri(self)
        .queryParam("pn", pagination.getCurrentPage())
        .queryParam("ps",pagination.getResultsPerPage())
        .build();

      representation = factory.newRepresentation(paginatedSelf);
      representation
        .withLink("first", UriBuilder
          .fromUri(self)
          .queryParam("pn", 1)
          .queryParam("ps", pagination.getResultsPerPage())
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

          .fromUri(self)
          .queryParam("pn", pagination.getTotalPages())
          .queryParam("ps", pagination.getResultsPerPage())
          .build());
    } else {
      representation = factory.newRepresentation(self);
    }

    // Add any links
    for (Map.Entry<String, String> entry : links.entrySet()) {
      representation.withLink(entry.getKey(), entry.getValue());
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

    String basePath = "/customer/" + customer.getId();

    // Create top-level resource
    RepresentationFactory factory = new DefaultRepresentationFactory();
    return factory
      .newRepresentation(basePath)
      .withLink("user", "/user/" + customer.getUser().getId())
      .withLink("cart", "/cart/" + customer.getCart().getId());
  }
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

      } else {
        throw new IllegalStateException("User does not have correct rights to be here ["+user.getId()+"]");
      }

      // The user will refer to their own profile implicitly
      representation = factory.newRepresentation(path)
        // The username and password digest are not required for any further authentication
        // If they are required it will be as part of a user profile update
        // The API and secret key are required for future user requests via HMAC
        .withProperty("api_key", user.getApiKey())
        .withProperty("secret_key", user.getSecretKey())
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

        .withProperty("secret_key", user.getSecretKey())
      // End of build
      ;
    } else {
      // The unauthenticated user will still refer to their own profile implicitly
      representation = factory.newRepresentation("/customer/user")
        // Provide empty credentials indicating a failure
        .withProperty("api_key", "")
        .withProperty("secret_key", "")
      // End of build
      ;
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

    Representation publicItemRepresentation = new PublicItemRepresentation().get(purchaseOrderItem.getItem());

    // Create the wrapping PurchaseOrderItem resource
    RepresentationFactory factory = new DefaultRepresentationFactory();

    return factory.newRepresentation("/purchase-order/item/" + purchaseOrderItem.getItem().getSKU())
      .withProperty("supplier_sku", purchaseOrderItem.getSupplierSKU())
      .withProperty("supplier_gtin", purchaseOrderItem.getSupplierGTIN())
      .withProperty("batch_reference", purchaseOrderItem.getBatchReference())
      .withProperty("quantity", purchaseOrderItem.getQuantity())
      .withProperty("price_subtotal", purchaseOrderItem.getPriceSubtotal().getAmount().toPlainString())
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

    // Calculate the price
    // TODO Consider currency choice from preferences
    String price = item.getLocalPrice().getAmount().toPlainString();
    String taxRate = String.valueOf(item.getTaxRate());

    Representation userRepresentation = factory
      .newRepresentation("/item/" + item.getSKU())
      .withProperty("sku", item.getSKU())
      .withProperty("gtin", item.getGTIN())
      .withProperty("price", price)
      .withProperty("tax_rate", taxRate)
View Full Code Here

Examples of com.theoryinpractise.halbuilder.DefaultRepresentationFactory.newRepresentation()

    Representation customerItemRepresentation = publicItemRepresentation.get(cartItem.getItem());

    // Create the wrapping CartItem resource
    RepresentationFactory factory = new DefaultRepresentationFactory();

    return factory.newRepresentation("/cart/item/" + cartItem.getIndex())
      .withProperty("index", cartItem.getIndex())
      .withProperty("quantity", cartItem.getQuantity())
      .withProperty("price_subtotal", cartItem.getPriceSubtotal().getAmount().toPlainString())
      .withProperty("tax_subtotal", cartItem.getTaxSubtotal().getAmount().toPlainString())
      .withProperty("cart_item_subtotal", cartItem.getCartItemSubtotal().getAmount().toPlainString())
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.