/* * 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.content.Context; import ee.htk.dippler.app.R; public class Event { private String event; private String object_type; private String object_title; private String creator; private String date; private String id; public void setId(String id) { this.id = id; } public String getId() { return this.id; } public String getEvent() { return event; } public String getEvent(Context context) { String event_str = this.getEvent(); if ( event.equalsIgnoreCase("CREATE") ) { event_str = context.getString(R.string.event_create); } else if ( event.equalsIgnoreCase("EDIT") ) { event_str = context.getString(R.string.event_edit); } else if ( event.equalsIgnoreCase("DELETE") ) { event_str = context.getString(R.string.event_delete); } else if ( event.equalsIgnoreCase("ACCEPT") ) { event_str = context.getString(R.string.event_accept); } else if ( event.equalsIgnoreCase("ENROLL") ) { event_str = context.getString(R.string.event_enroll); } else if ( event.equalsIgnoreCase("APPROVE") ) { event_str = context.getString(R.string.event_approve); } return event_str; } public void setEvent(String event) { this.event = event; } public String getObject_type() { return object_type; } public String getObject_type(Context context) { //If event type edit, use past forms for all langs if ( this.getEvent().equalsIgnoreCase("EDIT")) { return this.getObject_type_edited(context); } //Otherwise not in past if ( object_type.equalsIgnoreCase("CourseBlogPost") ) { object_type = context.getString(R.string.object_blogpost); } else if ( object_type.equalsIgnoreCase("Assignment") ) { object_type = context.getString(R.string.object_assignment); } else if ( object_type.equalsIgnoreCase("Answer") ) { object_type = context.getString(R.string.object_answer); } else if ( object_type.equalsIgnoreCase("Course") ) { object_type = context.getString(R.string.object_course); } else if ( object_type.equalsIgnoreCase("LearningOutcome") ) { object_type = context.getString(R.string.object_outcome); } else if ( object_type.equalsIgnoreCase("Learner") ) { object_type = context.getString(R.string.object_learner); } else if ( object_type.equalsIgnoreCase("Coursegroup") ) { object_type = context.getString(R.string.object_group); } else if ( object_type.equalsIgnoreCase("ResourceFolder") ) { object_type = context.getString(R.string.object_folder); } else if ( object_type.equalsIgnoreCase("Facilitator") ) { object_type = context.getString(R.string.object_facilitator); } else if ( object_type.equalsIgnoreCase("LearningResource") ) { object_type = context.getString(R.string.object_resource); } return object_type; } public String getObject_type_edited(Context context) { if ( object_type.equalsIgnoreCase("CourseBlogPost") ) { object_type = context.getString(R.string.object_blogpost_edited); } else if ( object_type.equalsIgnoreCase("Assignment") ) { object_type = context.getString(R.string.object_assignment_edited); } else if ( object_type.equalsIgnoreCase("Answer") ) { object_type = context.getString(R.string.object_answer_edited); } else if ( object_type.equalsIgnoreCase("Course") ) { object_type = context.getString(R.string.object_course_edited); } else if ( object_type.equalsIgnoreCase("LearningOutcome") ) { object_type = context.getString(R.string.object_outcome_edited); } else if ( object_type.equalsIgnoreCase("Learner") ) { object_type = context.getString(R.string.object_learner_edited); } else if ( object_type.equalsIgnoreCase("Coursegroup") ) { object_type = context.getString(R.string.object_group_edited); } else if ( object_type.equalsIgnoreCase("ResourceFolder") ) { object_type = context.getString(R.string.object_folder_edited); } else if ( object_type.equalsIgnoreCase("Facilitator") ) { object_type = context.getString(R.string.object_facilitator_edited); } else if ( object_type.equalsIgnoreCase("LearningResource") ) { object_type = context.getString(R.string.object_resource_edited); } return object_type; } public void setObject_type(String object_type) { this.object_type = object_type; } public String getCreator() { return creator; } public void setCreator(String creator) { this.creator = creator; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } public String getObject_title() { return object_title; } public void setObject_title(String object_title) { this.object_title = object_title; } public Event getInstance() { Event new_instance = new Event(); new_instance.setId(this.id); new_instance.setEvent(this.event); new_instance.setObject_title(this.object_title); new_instance.setObject_type(this.object_type); new_instance.setCreator(this.creator); new_instance.setDate(this.date); return new_instance; } @Override public boolean equals(Object o) { Event b = (Event) o; return this.getId().equalsIgnoreCase(b.getId()); } }