Subversion Repositories SmartDukaan

Rev

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

Rev 3018 Rev 3929
Line 1... Line 1...
1
package in.shop2020.util;
1
package in.shop2020.util;
2
 
2
 
-
 
3
import java.util.Map;
-
 
4
 
-
 
5
import in.shop2020.metamodel.core.FreeformContent;
-
 
6
import in.shop2020.metamodel.core.Media;
3
import in.shop2020.metamodel.util.ExpandedEntity;
7
import in.shop2020.metamodel.util.ExpandedEntity;
4
 
8
 
5
public class EntityUtils {
9
public class EntityUtils {
6
    /**
10
    /**
7
     * Get the name of the product from entity. It considers null values also
11
     * Get the name of the product from entity. It considers null values also
Line 34... Line 38...
34
		url = url.replaceAll("-+", "-");
38
		url = url.replaceAll("-+", "-");
35
		return url;
39
		return url;
36
	}
40
	}
37
	
41
	
38
	/**
42
	/**
39
	 * get image prefix
43
	 * Gets media prefix to be used for naming files
-
 
44
	 *
40
	 * @param expEntity
45
	 * @param expEntity
41
	 * @return
46
	 * @return
42
	 */
47
	 */
43
	public static String getImagePrefix(ExpandedEntity expEntity){
48
	public static String getMediaPrefix(ExpandedEntity expEntity){
44
		String productName = getProductName(expEntity);
49
		String productName = getProductName(expEntity);
45
		String imagePrefix = productName.toLowerCase().replace(' ', '-');
50
		String mediaPrefix = productName.toLowerCase().replace(' ', '-');
46
		imagePrefix = imagePrefix.replaceAll("/", "-");
51
		mediaPrefix = mediaPrefix.replaceAll("/", "-");
47
		imagePrefix = imagePrefix.replaceAll("-+", "-");
52
		mediaPrefix = mediaPrefix.replaceAll("-+", "-");
48
		return imagePrefix;
53
		return mediaPrefix;
49
	}
54
	}
50
 
55
 
-
 
56
	/**
-
 
57
	 * Returns the creation timestamp of the media with a given label
-
 
58
	 * in summary slide.
-
 
59
	 *
-
 
60
	 * @param expEntity
-
 
61
	 * @return
-
 
62
	 */
-
 
63
    public static long getCreationTimeFromSummarySlide(ExpandedEntity expEntity, String label) {
-
 
64
        long defaultSuffix = 0;
-
 
65
 
-
 
66
        if (expEntity != null && expEntity.getSlide(Utils.SUMMARY_SLIDE_DEFINITION_ID) != null) {
-
 
67
            FreeformContent content = expEntity.getSlide(Utils.SUMMARY_SLIDE_DEFINITION_ID).getFreeformContent();
-
 
68
            if (content != null) {
-
 
69
                Map<String, Media> media = content.getMedias();
-
 
70
                if (media != null) {
-
 
71
                    Media defaultImage = media.get(label);
-
 
72
                    if (defaultImage != null) {
-
 
73
                        defaultSuffix = defaultImage.getCreationTime().getTime();
-
 
74
                    }
-
 
75
                }
-
 
76
            }
-
 
77
        }
-
 
78
 
-
 
79
        return defaultSuffix;
-
 
80
    }
51
}
81
}