Subversion Repositories SmartDukaan

Rev

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

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