Example #1
0
  /**
   * Save Product into the application for the merchant.
   *
   * @param request product details
   * @param productId product Id of the product to delete.
   * @return Status of the operation.
   */
  @SuppressWarnings("unchecked")
  public ProductDetailsResponseDTO deleteProduct(
      String merchantId, String productId, String businessCategory) {
    ProductDetailsResponseDTO response = new ProductDetailsResponseDTO();
    boolean result = true;

    result = deleteProduct(productId);
    if (result == true) {
      logger.info("Product Deleted with ID: " + productId);
    }
    response.setMerchantId(merchantId);
    return response;
  }
Example #2
0
  @SuppressWarnings("unchecked")
  private Product registerProduct(String merchantID, String businessCategory) {
    IIdGenerator<String> generator =
        AbstractIdGeneratorFactory.getIdGenerator(GeneratorType.PRODUCT_ID);
    productRegistrationId = generator.nextId();

    Product product =
        new ProductAssembler()
            .productEntity(productRegistrationId, merchantID, businessCategory, true);

    logger.info("Product persisted with ID : " + product.getProductId());

    return product;
  }
Example #3
0
  @SuppressWarnings("unchecked")
  private void persistFashionProduct(Product product, ProductDetailsRequestDTO request) {

    ProductFashion productFashion =
        new ProductAssembler().productFashionEntity(product.getProductId(), request);
    IRepositoryAdapter<Product, ?> adapter =
        RepositoryAdapterFactory.getRepositoryAdapter(
            super.getORMProvider(
                "com.yoku.server.core.services.product.ProductService.createAndregister"));
    product.setProductFashion(productFashion);
    productFashion.setProduct(product);
    adapter.save(product);
    logger.info("Fashion Product with product ID: " + product.getProductId() + " persisted");
  }
Example #4
0
 /**
  * Update Current Order status. Make it available to Ninja for pickup.
  *
  * @return order list
  */
 @RequestMapping(
     value = "/{orderId}",
     method = RequestMethod.PUT,
     produces = Constants.APPLICATION_JSON)
 public ResponseEntity<BaseDTO> updateStatus(
     @PathVariable String merchantId, @PathVariable String orderId, @RequestParam String status) {
   try {
     String merId = super.beginMerchantSession(merchantId);
     com.yoku.server.core.services.order.Order service =
         new com.yoku.server.core.services.order.Order();
     service.updateStatusByMerchant(merId, orderId, status);
   } catch (LoginSessionException e) {
     logger.error(e.getMessage(), e);
   }
   return null;
 }
Example #5
0
 /**
  * Read all orders for current merchant.
  *
  * @return order list
  */
 @RequestMapping(value = "/all", method = RequestMethod.GET, produces = Constants.APPLICATION_JSON)
 public ResponseEntity<BaseDTO> readAll(
     @PathVariable String merchantId, @RequestParam String status) {
   OrderDetailsResponseDTO response = null;
   HttpStatus httpStatus = null;
   try {
     String merId = super.beginMerchantSession(merchantId);
     com.yoku.server.core.services.order.Order service =
         new com.yoku.server.core.services.order.Order();
     response = service.readAll(merId, status);
     httpStatus = HttpStatus.OK;
   } catch (LoginSessionException e) {
     httpStatus = HttpStatus.BAD_REQUEST;
     logger.error(e.getMessage(), e);
   }
   return super.buildResponse(httpStatus, response);
 }
Example #6
0
 @SuppressWarnings("unchecked")
 public MerchantBusinessViewEntity getMerchantBusinessDetails(String merchantId) {
   String query;
   List<MerchantBusinessViewEntity> merchantBusinessViewEntity =
       new ArrayList<MerchantBusinessViewEntity>();
   IRepositoryAdapter<MerchantBusinessViewEntity, ?> adapter =
       RepositoryAdapterFactory.getRepositoryAdapter(
           super.getORMProvider(
               "com.yoku.server.core.services.product.ProductService.createAndregister"));
   logger.info(
       "New Product Registration initiated. Product Registration ID : "
           + productRegistrationId
           + " For the Merchant ID : "
           + merchantId);
   query =
       "from MerchantBusinessViewEntity merchantBusinessViewEntity where merchantBusinessViewEntity.merchantID='"
           + merchantId
           + "'";
   merchantBusinessViewEntity = adapter.executeReadQuery(query);
   return (MerchantBusinessViewEntity) merchantBusinessViewEntity.get(0);
 }
Example #7
0
  @SuppressWarnings("unchecked")
  private MerchantProductListingResponseDTO getAllFashionProduct(
      String merchantID, String businessCategory, MerchantProductListingResponseDTO response) {

    String query;
    List<ProductFashion> products = new ArrayList<ProductFashion>();
    IRepositoryAdapter<ProductFashion, ?> adapter =
        RepositoryAdapterFactory.getRepositoryAdapter(
            super.getORMProvider(
                "com.yoku.server.core.services.product.ProductService..readAllProductsForMerchant"));

    query =
        "select productFashion from  ProductFashion productFashion, Product product where product.merchantId = '"
            + merchantID
            + "' and product.productId=productFashion.productId";
    products = (List<ProductFashion>) adapter.executeReadQuery(query);
    logger.info("Total product found------" + products.size());
    response =
        new ProductAssembler()
            .createResponseForMerchantProductFashionListingResponseDTO(
                (List<ProductFashion>) products, businessCategory, response);
    return response;
  }