Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.infullmobile.scout.repository.database.model.feed
- import com.google.gson.Gson
- import com.google.gson.reflect.TypeToken
- import com.infullmobile.scout.domain.model.feed.EventType
- import com.infullmobile.scout.repository.scout.model.event.AttendanceEntity
- import com.infullmobile.scout.repository.scout.model.facilities.FacilityEntity
- import com.infullmobile.scout.repository.scout.model.feed.AttachmentEntity
- import com.infullmobile.scout.repository.scout.model.feed.AudienceEntity
- import com.infullmobile.scout.repository.scout.model.feed.ImageEntity
- import com.infullmobile.scout.repository.scout.model.feed.LocationEntity
- import com.infullmobile.scout.repository.scout.model.feed.ProfileEntity
- import com.infullmobile.scout.repository.scout.model.feed.ScoutFeedItemEntity
- import com.infullmobile.scout.repository.scout.model.feed.TagEntity
- import com.infullmobile.scout.repository.scout.model.feed.TopicEntity
- import com.infullmobile.scout.repository.scout.model.feed.UpdateEntity
- import com.infullmobile.scout.repository.scout.model.user_profile.UserProfileEntity
- import nl.qbusict.cupboard.DatabaseCompartment
- class ScoutFeedItemEntityDb {
- var _id: Long? = -1
- var shareUrl: String? = null
- var type: String? = null
- var image: String? = null
- var language: String? = null
- var author: String? = null
- var date: Long? = null
- var description: String? = null
- var creator: String? = null
- var tags: String? = null
- var links: String? = null
- var attachments: String? = null
- var originalArticle: String? = null
- var gallery: String? = null
- var topics: String? = null
- var title: String? = null
- var location: String? = null
- var contactInfo: String? = null
- var organizer: String? = null
- var eventType: String? = null
- var startDate: Long? = null
- var endDate: Long? = null
- var updates: String? = null
- var originalNumberOfParticipants: Long? = null
- var numberOfServiceHoursOfParticipants: Long? = null
- var attendance: String? = null
- var audience: String? = null
- var copyright: String? = null
- var categoriesAndFacilities: String? = null
- constructor()
- constructor(
- _id: Long?,
- shareUrl: String?,
- type: String?,
- image: ImageEntity?,
- language: String?,
- author: ProfileEntity?,
- date: Long?,
- description: String?,
- creator: ProfileEntity?,
- tags: List<TagEntity>?,
- links: List<String>?,
- attachments: List<AttachmentEntity>?,
- originalArticle: String?,
- gallery: List<ImageEntity>?,
- topics: List<TopicEntity>?,
- title: String?,
- location: LocationEntity?,
- contactInfo: String?,
- organizer: ProfileEntity?,
- eventType: EventType?,
- startDate: Long?,
- endDate: Long?,
- updates: List<UpdateEntity>?,
- originalNumberOfParticipants: Long?,
- numberOfServiceHoursOfParticipants: Long?,
- usersAttendance: AttendanceEntity?,
- audience: List<AudienceEntity>?,
- copyright: String?,
- facilities: List<FacilityEntity>?
- ) {
- val gson = Gson()
- this._id = _id
- this.shareUrl = shareUrl
- this.type = type
- this.image = ""
- this.language = language
- this.author = ""
- this.date = date
- this.description = description
- this.creator = ""
- this.tags = ""
- this.links = ""
- this.attachments = ""
- this.originalArticle = originalArticle
- this.gallery = ""
- this.topics = gson.toJson(topics)
- this.title = title
- this.location = ""
- this.contactInfo = contactInfo
- this.organizer = ""
- this.eventType = ""
- this.startDate = startDate
- this.endDate = endDate
- this.updates = ""
- this.originalNumberOfParticipants = originalNumberOfParticipants
- this.numberOfServiceHoursOfParticipants = numberOfServiceHoursOfParticipants
- this.attendance = ""
- this.audience = ""
- this.copyright = copyright
- this.categoriesAndFacilities = ""
- }
- constructor(scoutFeedItemEntity: ScoutFeedItemEntity) : this(
- scoutFeedItemEntity.id,
- scoutFeedItemEntity.shareUrl,
- scoutFeedItemEntity.type,
- scoutFeedItemEntity.image,
- scoutFeedItemEntity.language,
- scoutFeedItemEntity.author,
- scoutFeedItemEntity.date,
- scoutFeedItemEntity.description,
- scoutFeedItemEntity.creator,
- scoutFeedItemEntity.tags,
- scoutFeedItemEntity.links,
- scoutFeedItemEntity.attachments,
- scoutFeedItemEntity.originalArticle,
- scoutFeedItemEntity.gallery,
- scoutFeedItemEntity.topics,
- scoutFeedItemEntity.title,
- scoutFeedItemEntity.location,
- scoutFeedItemEntity.contactInfo,
- scoutFeedItemEntity.organizer,
- scoutFeedItemEntity.eventType,
- scoutFeedItemEntity.startDate,
- scoutFeedItemEntity.endDate,
- scoutFeedItemEntity.updates,
- scoutFeedItemEntity.originalNumberOfParticipants,
- scoutFeedItemEntity.numberOfServiceHoursOfParticipants,
- scoutFeedItemEntity.attendance,
- scoutFeedItemEntity.audience,
- scoutFeedItemEntity.copyright,
- scoutFeedItemEntity.categoriesAndFacilities
- )
- fun store(compartment: DatabaseCompartment) {
- compartment.put(this)
- }
- fun toScoutFeedItemEntity(): ScoutFeedItemEntity {
- val gson = Gson()
- val tagListType = object : TypeToken<List<TagEntity>>() {}.type
- val stringListType = object : TypeToken<List<String>>() {}.type
- val attachmentListType = object : TypeToken<List<AttachmentEntity>>() {}.type
- val galleryListType = object : TypeToken<List<ImageEntity>>() {}.type
- val topicsListType = object : TypeToken<List<TopicEntity>>() {}.type
- val updatesListType = object : TypeToken<List<UpdateEntity>>() {}.type
- val audienceListType = object : TypeToken<List<AudienceEntity>>() {}.type
- val categoriesFacilitiesType = object : TypeToken<List<FacilityEntity>>() {}.type
- return ScoutFeedItemEntity(
- _id,
- shareUrl,
- type,
- ImageEntity("", ""),
- language,
- ProfileEntity(0L, "", UserProfileEntity(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)),
- date,
- description,
- ProfileEntity(0L, "", UserProfileEntity(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)),
- listOf(TagEntity(0L, "")),
- listOf(""),
- listOf(AttachmentEntity(0L, "", "")),
- originalArticle,
- listOf(ImageEntity("", "")),
- gson.fromJson(topics, topicsListType),
- title,
- LocationEntity("", "", "", "", ""),
- contactInfo,
- ProfileEntity(0L, "", UserProfileEntity(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)),
- EventType.GLOBAL,
- startDate,
- endDate,
- listOf(UpdateEntity(0L, ImageEntity("", ""), "", "", "", null, null)),
- originalNumberOfParticipants,
- numberOfServiceHoursOfParticipants,
- AttendanceEntity.GOING,
- listOf(AudienceEntity(0L, "")),
- copyright,
- listOf(FacilityEntity("", listOf("")))
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement