Package com.theoryinpractise.halbuilder.api

Examples of com.theoryinpractise.halbuilder.api.Representation


    int pageNumber = Integer.valueOf(rawPageNumber.get());

    PaginatedList<Delivery> deliveries = deliveryReadService.getPaginatedList(pageSize, pageNumber);

    // Provide a representation to the client
    Representation representation = new AdminDeliveryCollectionRepresentation().get(deliveries);

    return ok(representation);

  }
View Full Code Here


  public Representation get(PaginatedList<Role> roles) {

    Preconditions.checkNotNull(roles, "roles");

    URI self = UriBuilder.fromPath("/admin/role").build();
    Representation roleList = Representations.newPaginatedList(self, roles);

    for (Role role : roles.list()) {
      Representation roleRepresentation = new AdminRoleRepresentation().get(role);

      roleList.withRepresentation("/role/" + role.getId(), roleRepresentation);
    }

    return roleList;
View Full Code Here

    Preconditions.checkNotNull(purchaseOrderItem, "purchaseOrderItem");
    Preconditions.checkNotNull(purchaseOrderItem.getItem().getId(), "id");

    // Create the Customer Item resource
    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())
View Full Code Here

    // Persist the updated delivery
    persistentDelivery = deliveryReadService.saveOrUpdate(persistentDelivery);

    // Provide a representation to the client
    Representation representation = new AdminDeliveryRepresentation().get(persistentDelivery);

    return ok(representation);

  }
View Full Code Here

    PaginatedList<Cart> carts = cartDao.getPaginatedList(pageSize, pageNumber);

    // Provide a representation to the client

    Representation representation = new AdminCartCollectionRepresentation().get(carts);

    return ok(representation);

  }
View Full Code Here

    // Persist the updated cart
    cart = cartDao.saveOrUpdate(cart);

    // Provide a representation to the client
    Representation representation = new AdminCartRepresentation().get(cart);

    return ok(representation);

  }
View Full Code Here

public class SupplierUserRepresentation {

  public Representation get(User user) {

    // Build on the minimal representation
    Representation userRepresentation = new ClientUserRepresentation().get(user);

    // Apply restrictions against the more detailed representation
    Preconditions.checkNotNull(user, "user");
    Preconditions.checkNotNull(user.getId(), "id");

    // Add properties
    userRepresentation.withProperty("username", user.getUsername());

    // Convert the ContactMethodDetails map into primary and secondary property entries
    for (Map.Entry<ContactMethod, ContactMethodDetail> entry : user.getContactMethodMap().entrySet()) {
      String propertyName = entry.getKey().getPropertyNameSingular();
      ContactMethodDetail contactMethodDetail = entry.getValue();
      String primaryDetail = contactMethodDetail.getPrimaryDetail();

      userRepresentation.withProperty(propertyName, primaryDetail);

      // Determine if secondary details should be included
      if (entry.getKey().isSecondaryDetailSupported()) {
        Set<String> secondaryDetails = contactMethodDetail.getSecondaryDetails();
        // TODO Consider if a 1-based field index is the best representation here: array? sub-resource?
        int index = 1;
        for (String secondaryDetail : secondaryDetails) {
          userRepresentation.withProperty(propertyName + index, secondaryDetail);
          index++;
        }
      }
    }
View Full Code Here

    int pageNumber = Integer.valueOf(rawPageNumber.get());

    PaginatedList<PurchaseOrder> purchaseOrders = purchaseOrderReadService.getPaginatedList(pageSize, pageNumber);

    // Provide a representation to the client
    Representation representation = new AdminPurchaseOrderCollectionRepresentation().get(purchaseOrders);

    return ok(representation);

  }
View Full Code Here

    // Persist the updated purchaseOrder
    persistentPurchaseOrder = purchaseOrderReadService.saveOrUpdate(persistentPurchaseOrder);

    // Provide a representation to the client
    Representation representation = new AdminPurchaseOrderRepresentation().get(persistentPurchaseOrder);

    return ok(representation);

  }
View Full Code Here

  public Representation get(PaginatedList<Cart> carts) {
    RepresentationFactory factory = new DefaultRepresentationFactory();

    URI self = UriBuilder.fromPath("/admin/cart").build();
    Representation cartList = Representations.newPaginatedList(self, carts);

    for (Cart cart : carts.list()) {
      Representation cartRepresentation= publicCartRepresentation.get(cart);

      cartRepresentation.withProperty("id", cart.getId())
      // End of build
      ;

      cartList.withRepresentation("/cart/" + cart.getId(), cartRepresentation);
    }
View Full Code Here

TOP

Related Classes of com.theoryinpractise.halbuilder.api.Representation

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.