Subversion Repositories SmartDukaan

Rev

Rev 4142 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * 
 */
package in.shop2020.utils;

import in.shop2020.model.v1.catalog.Item;
import in.shop2020.model.v1.order.LineItem;
import in.shop2020.model.v1.order.Order;

/**
 * @author mandeep
 *
 */
public class ModelUtils {
    public static String extractAddressFromOrder(Order order) {
        StringBuilder address = new StringBuilder();
        if (order.getCustomer_address1() != null) {
            address.append(order.getCustomer_address1() + ", ");
        }
        if (order.getCustomer_address2() != null) {
            address.append(order.getCustomer_address2() + ", ");
        }
        if (order.getCustomer_city() != null) {
            address.append(order.getCustomer_city() + ", ");
        }
        if (order.getCustomer_state() != null) {
            address.append(order.getCustomer_state() + "-");
        }
        if (order.getCustomer_pincode() != null) {
            address.append(order.getCustomer_pincode());
        }

        return address.toString();
    }
    
    public static String extractProductNameFromLineItem(LineItem lineItem) {
        StringBuilder productName = new StringBuilder();

        if (lineItem.getBrand() != null && !lineItem.getBrand().isEmpty()) {
            productName.append(lineItem.getBrand() + " ");
        }

        if (lineItem.getModel_name() != null && !lineItem.getModel_name().isEmpty()) {
            productName.append(lineItem.getModel_name()  + " ");
        }

        if (lineItem.getModel_number() != null && !lineItem.getModel_number().isEmpty()) {
            productName.append(lineItem.getModel_number()  + " ");
        }

        return productName.toString();
    }

    public static String extractProductNameFromItem(Item item) {
        StringBuilder productName = new StringBuilder();

        if (item.getBrand() != null && !item.getBrand().isEmpty()) {
            productName.append(item.getBrand() + " ");
        }

        if (item.getModelName() != null && !item.getModelName().isEmpty()) {
            productName.append(item.getModelName() + " ");
        }

        if (item.getModelNumber() != null && !item.getModelNumber().isEmpty()) {
            productName.append(item.getModelNumber() + " ");
        }
        
        if (item.getColor() != null && !item.getColor().isEmpty())      {
                productName.append(item.getColor());
        }
        return productName.toString();
    }
}