// Copyright (c) 2010 Mahesh Sharma,Matt MacDonald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package org.prx.prp.model;
import org.json.JSONException;
import org.json.JSONObject;
import org.prx.prp.utility.DatabaseAdapter;
import android.content.ContentValues;
public class Scheduling {
private int streamId;
private int programId;
private String programTitle;
public String getProgramTitle() {
return programTitle;
}
public void setProgramTitle(String programTitle) {
this.programTitle = programTitle;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
private String programPodcast;
public String getProgramPodcast() {
return programPodcast;
}
public void setProgramPodcast(String programPodcast) {
this.programPodcast = programPodcast;
}
private String streamDisplayName;
private String startTime;
private String endTime;
private int schedulingID;
public boolean programHasEpisodes()
{
if (this.programPodcast == null || this.programPodcast.length()==0 || this.programPodcast.equals("null")) {
return false;
} else {
return true;
}
}
public Scheduling(JSONObject c) {
super();
try {
this.schedulingID=c.getInt("id");
this.streamId = c.getInt("stream_id");
this.programId = c.getInt("program_id");
this.programTitle = c.getJSONObject("program").getString("title");
this.programPodcast = c.getJSONObject("program").getString("podcast");
this.streamDisplayName = c.getJSONObject("stream").getString("display_name");
this.startTime = c.getString("start_time");
this.endTime = c.getString("end_time");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void syncObject()
{
ContentValues params=new ContentValues();
params.put("stream_id",this.streamId);
params.put("program_id",this.programId);
params.put("id",this.schedulingID);
params.put("program_title",this.programTitle);
params.put("program_podcast",this.programPodcast);
params.put("stream_display_name",this.streamDisplayName);
params.put("start_time",this.startTime);
params.put("end_time",this.endTime);
DatabaseAdapter.insertRecord("SCHEDULINGS", params);
}
public int getProgramID() {
return programId;
}
}
|