Subversion Repositories SmartDukaan

Rev

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