/* * Copyright 2012 Tallinn University Centre for Educational Technology * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package ee.htk.dippler.app.entities; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; public class Course implements Parcelable { private int id = 0; private String title = null; private int start_date = 0; private int end_date = 0; private int owner_id = 0; private Profile facilitator; private String start; private String end; public int getId() { return id; } public void setId(int id) { Log.i("dippler-app", "Setting course ID " + id); this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public int getStart_date() { return start_date; } public void setStart_date(String start_date) { Log.i("dippler-app", "Start timestamp " + start_date); try { this.start_date = Integer.parseInt(start_date); } catch (NumberFormatException e) { // TODO: handle exception } } public int getEnd_date() { return end_date; } public void setEnd_date(String end_date) { try { this.end_date = Integer.parseInt(end_date); } catch(NumberFormatException e) { } } public int getOwner_id() { return owner_id; } public void setOwner_id(String owner_id) { this.owner_id = Integer.parseInt(owner_id); } public Course getInstance() { Course course_instance = new Course(); course_instance.setId(this.getId()); course_instance.setTitle("Course with ID " + this.getId() ); return course_instance; } public void setFacilitator(Profile profile) { this.facilitator = profile; } public Profile getFacilitator() { return this.facilitator; } @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(title); dest.writeInt(id); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public Course createFromParcel(Parcel in) { return new Course(in); } public Course[] newArray(int size) { return new Course[size]; } }; private Course(Parcel in) { title = in.readString(); id = in.readInt(); } public Course() { } public void setEnd(String formatted_date) { this.end = formatted_date; } public void setStart(String formatted_date) { this.start = formatted_date; } public String getEnd() { return this.end; } public String getStart() { return this.start; } }