Rev 3929 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.util;import in.shop2020.metamodel.util.ExpandedEntity;public class EntityUtils {/*** Get the name of the product from entity. It considers null values also* @param expEntity* @return*/public static String getProductName(ExpandedEntity expEntity){//FIXME Use stringbuilderString productName = ((expEntity.getBrand() != null) ? expEntity.getBrand().trim() + " " : "")+ ((expEntity.getModelName() != null) ? expEntity.getModelName().trim() + " " : "")+ (( expEntity.getModelNumber() != null ) ? expEntity.getModelNumber().trim() : "" );return productName;}/*** Get url of the entity.* @param expEntity* @return*/public static String getEntityURL(ExpandedEntity expEntity){String url = "/" + expEntity.getCategory().getParentCategory().getLabel().toLowerCase().replace(' ', '-') + "/";if(expEntity.getCategory().getParentCategory().getID() == Utils.ROOT_CATAGOEY){url = "/" + expEntity.getCategory().getLabel().toLowerCase().replace(' ', '-') + "/";}String productName = getProductName(expEntity);String productUrl = productName.toLowerCase().replace(' ', '-') + "-" + expEntity.getID();productUrl = productUrl.replaceAll("/", "-");url = url + productUrl;url = url.replaceAll("-+", "-");return url;}/*** get image prefix* @param expEntity* @return*/public static String getImagePrefix(ExpandedEntity expEntity){String productName = getProductName(expEntity);String imagePrefix = productName.toLowerCase().replace(' ', '-');imagePrefix = imagePrefix.replaceAll("/", "-");imagePrefix = imagePrefix.replaceAll("-+", "-");return imagePrefix;}}