Subversion Repositories SmartDukaan

Rev

Rev 2720 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
479 rajveer 1
/**
2
 * 
3
 */
4
package in.shop2020.metamodel.core;
5
 
6
import in.shop2020.metamodel.util.MetaModelComponent;
7
 
8
import java.io.UnsupportedEncodingException;
9
import java.net.URLEncoder;
2720 mandeep.dh 10
import java.util.Date;
479 rajveer 11
 
12
/**
13
 * @author naveen
2720 mandeep.dh 14
 * 
479 rajveer 15
 */
16
public class Media extends MetaModelComponent {
8765 amit.gupta 17
    Media() {
18
	}
19
 
20
	/**
2720 mandeep.dh 21
     * 
22
     */
23
    private static final long serialVersionUID = 1L;
479 rajveer 24
 
2720 mandeep.dh 25
    public static enum Type {
26
        IMAGE("file"),
27
        VIDEO_WITH_SKIN("text"),
28
        VIDEO_WITHOUT_SKIN("text"),
29
        DOCUMENT("file");
479 rajveer 30
 
2720 mandeep.dh 31
        String inputType;
32
        Type(String inputType) {
33
            this.inputType = inputType;
34
        }
35
        public String getInputType() {
36
            return inputType;
37
        }
38
    }
479 rajveer 39
 
2720 mandeep.dh 40
    /**
41
     * 
42
     */
43
    private String label;
44
    private Type   type;
45
    private String title;
46
    private String location;
47
    private Date   creationTime;  
479 rajveer 48
 
2720 mandeep.dh 49
    // used only for images and documents
50
    private String fileName;
51
    /**
52
     * 
53
     * @param label
54
     * @param type
55
     * @param location
56
     */
57
    public Media(String label, Type type, String location) {
58
        this.label        = label;
59
        this.type         = type;
60
        this.location     = location;
61
        this.creationTime = new Date();
62
    }
479 rajveer 63
 
2720 mandeep.dh 64
    /**
65
     * @param label
66
     *            the label to set
67
     */
68
    public void setLabel(String label) {
69
        this.label = label;
70
    }
71
 
72
    /**
73
     * @return the label
74
     */
75
    public String getLabel() {
76
        return label;
77
    }
78
 
79
    public void setTitle(String title) {
80
        this.title = title;
81
    }
82
 
83
    public String getTitle() {
84
        return title;
85
    }
86
 
87
    /**
88
     * @return the label
89
     */
90
    public String getEncodedLabel() {
91
        try {
92
            return URLEncoder.encode(label, "UTF-8");
93
        } catch (UnsupportedEncodingException e) {
94
            // CreationUtils.getStackTrace(e);
95
            e.printStackTrace();
96
            return "";
97
        }
98
    }
99
 
100
    /**
101
     * @param type
102
     *            the type to set
103
     */
104
    public void setType(Type type) {
105
        this.type = type;
106
    }
107
 
108
    /**
109
     * @return the type
110
     */
111
    public Type getType() {
112
        return type;
113
    }
114
 
115
    /**
116
     * @param location
117
     *            the location to set
118
     */
119
    public void setLocation(String location) {
120
        this.location = location;
121
    }
122
 
123
    /**
124
     * @return the location
125
     */
126
    public String getLocation() {
127
        return location;
128
    }
129
 
130
    /**
131
     * parse the youtube url and return youtube id
132
     * 
133
     * @return the youtube id.
134
     */
135
    public String getYoutubeId() {
580 rajveer 136
        String[] token = location.split("\\?v=");
2720 mandeep.dh 137
        if (token.length == 2) {
138
            return token[1];
139
        }
140
        return "";
141
    }
479 rajveer 142
 
2720 mandeep.dh 143
    /*
144
     * (non-Javadoc)
145
     * 
146
     * @see java.lang.Object#toString()
147
     */
148
    @Override
149
    public String toString() {
150
        return "Media [label=" + label + ", location=" + location + ", type="
151
                + type + "]";
152
    }
479 rajveer 153
 
2720 mandeep.dh 154
    public Date getCreationTime() {
155
        return creationTime;
156
    }
479 rajveer 157
 
2720 mandeep.dh 158
    public String getFileName() {
159
        return fileName;
160
    }
479 rajveer 161
 
2720 mandeep.dh 162
    public void setFileName(String fileName) {
163
        this.fileName = fileName;
164
    }
479 rajveer 165
}