Subversion Repositories SmartDukaan

Rev

Rev 3929 | Rev 9280 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3929 Rev 9218
Line 1... Line 1...
1
package in.shop2020.util;
1
package in.shop2020.util;
2
 
2
 
3
import java.util.Map;
3
import in.shop2020.metamodel.core.Entity;
4
 
-
 
5
import in.shop2020.metamodel.core.FreeformContent;
4
import in.shop2020.metamodel.core.FreeformContent;
6
import in.shop2020.metamodel.core.Media;
5
import in.shop2020.metamodel.core.Media;
7
import in.shop2020.metamodel.util.ExpandedEntity;
6
import in.shop2020.metamodel.util.ExpandedEntity;
8
 
7
 
-
 
8
import java.util.Map;
-
 
9
 
9
public class EntityUtils {
10
public class EntityUtils {
10
    /**
11
    /**
11
     * Get the name of the product from entity. It considers null values also
12
     * Get the name of the product from entity. It considers null values also
12
     * @param expEntity
13
     * @param expEntity
13
     * @return
14
     * @return
14
     */
15
     */
15
	public static String getProductName(ExpandedEntity expEntity){
16
	public static String getProductName(Entity expEntity){
16
		//FIXME Use stringbuilder
17
		//FIXME Use stringbuilder
17
		String productName = ((expEntity.getBrand() != null) ? expEntity.getBrand().trim() + " " : "")
18
		String productName = ((expEntity.getBrand() != null) ? expEntity.getBrand().trim() + " " : "")
18
		+ ((expEntity.getModelName() != null) ? expEntity.getModelName().trim() + " " : "")
19
		+ ((expEntity.getModelName() != null) ? expEntity.getModelName().trim() + " " : "")
19
		+ (( expEntity.getModelNumber() != null ) ? expEntity.getModelNumber().trim() : "" );	
20
		+ (( expEntity.getModelNumber() != null ) ? expEntity.getModelNumber().trim() : "" );	
20
		return productName;
21
		return productName;
Line 43... Line 44...
43
	 * Gets media prefix to be used for naming files
44
	 * Gets media prefix to be used for naming files
44
	 *
45
	 *
45
	 * @param expEntity
46
	 * @param expEntity
46
	 * @return
47
	 * @return
47
	 */
48
	 */
48
	public static String getMediaPrefix(ExpandedEntity expEntity){
49
	public static String getMediaPrefix(Entity expEntity){
49
		String productName = getProductName(expEntity);
50
		String productName = getProductName(expEntity);
50
		String mediaPrefix = productName.toLowerCase().replace(' ', '-');
51
		String mediaPrefix = productName.toLowerCase().replace(' ', '-');
51
		mediaPrefix = mediaPrefix.replaceAll("/", "-");
52
		mediaPrefix = mediaPrefix.replaceAll("/", "-");
52
		mediaPrefix = mediaPrefix.replaceAll("-+", "-");
53
		mediaPrefix = mediaPrefix.replaceAll("-+", "-");
53
		return mediaPrefix;
54
		return mediaPrefix;