Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 8.01 KB | None | 0 0
  1. package com.infullmobile.scout.repository.database.model.feed
  2.  
  3. import com.google.gson.Gson
  4. import com.google.gson.reflect.TypeToken
  5. import com.infullmobile.scout.domain.model.feed.EventType
  6. import com.infullmobile.scout.repository.scout.model.event.AttendanceEntity
  7. import com.infullmobile.scout.repository.scout.model.facilities.FacilityEntity
  8. import com.infullmobile.scout.repository.scout.model.feed.AttachmentEntity
  9. import com.infullmobile.scout.repository.scout.model.feed.AudienceEntity
  10. import com.infullmobile.scout.repository.scout.model.feed.ImageEntity
  11. import com.infullmobile.scout.repository.scout.model.feed.LocationEntity
  12. import com.infullmobile.scout.repository.scout.model.feed.ProfileEntity
  13. import com.infullmobile.scout.repository.scout.model.feed.ScoutFeedItemEntity
  14. import com.infullmobile.scout.repository.scout.model.feed.TagEntity
  15. import com.infullmobile.scout.repository.scout.model.feed.TopicEntity
  16. import com.infullmobile.scout.repository.scout.model.feed.UpdateEntity
  17. import com.infullmobile.scout.repository.scout.model.user_profile.UserProfileEntity
  18. import nl.qbusict.cupboard.DatabaseCompartment
  19.  
  20. class ScoutFeedItemEntityDb {
  21.  
  22.     var _id: Long? = -1
  23.     var shareUrl: String? = null
  24.     var type: String? = null
  25.     var image: String? = null
  26.     var language: String? = null
  27.     var author: String? = null
  28.     var date: Long? = null
  29.     var description: String? = null
  30.     var creator: String? = null
  31.     var tags: String? = null
  32.     var links: String? = null
  33.     var attachments: String? = null
  34.     var originalArticle: String? = null
  35.     var gallery: String? = null
  36.     var topics: String? = null
  37.     var title: String? = null
  38.     var location: String? = null
  39.     var contactInfo: String? = null
  40.     var organizer: String? = null
  41.     var eventType: String? = null
  42.     var startDate: Long? = null
  43.     var endDate: Long? = null
  44.     var updates: String? = null
  45.     var originalNumberOfParticipants: Long? = null
  46.     var numberOfServiceHoursOfParticipants: Long? = null
  47.     var attendance: String? = null
  48.     var audience: String? = null
  49.     var copyright: String? = null
  50.     var categoriesAndFacilities: String? = null
  51.  
  52.     constructor()
  53.  
  54.     constructor(
  55.             _id: Long?,
  56.             shareUrl: String?,
  57.             type: String?,
  58.             image: ImageEntity?,
  59.             language: String?,
  60.             author: ProfileEntity?,
  61.             date: Long?,
  62.             description: String?,
  63.             creator: ProfileEntity?,
  64.             tags: List<TagEntity>?,
  65.             links: List<String>?,
  66.             attachments: List<AttachmentEntity>?,
  67.             originalArticle: String?,
  68.             gallery: List<ImageEntity>?,
  69.             topics: List<TopicEntity>?,
  70.             title: String?,
  71.             location: LocationEntity?,
  72.             contactInfo: String?,
  73.             organizer: ProfileEntity?,
  74.             eventType: EventType?,
  75.             startDate: Long?,
  76.             endDate: Long?,
  77.             updates: List<UpdateEntity>?,
  78.             originalNumberOfParticipants: Long?,
  79.             numberOfServiceHoursOfParticipants: Long?,
  80.             usersAttendance: AttendanceEntity?,
  81.             audience: List<AudienceEntity>?,
  82.             copyright: String?,
  83.             facilities: List<FacilityEntity>?
  84.     ) {
  85.         val gson = Gson()
  86.         this._id = _id
  87.         this.shareUrl = shareUrl
  88.         this.type = type
  89.         this.image = ""
  90.         this.language = language
  91.         this.author = ""
  92.         this.date = date
  93.         this.description = description
  94.         this.creator = ""
  95.         this.tags = ""
  96.         this.links = ""
  97.         this.attachments = ""
  98.         this.originalArticle = originalArticle
  99.         this.gallery = ""
  100.         this.topics = gson.toJson(topics)
  101.         this.title = title
  102.         this.location = ""
  103.         this.contactInfo = contactInfo
  104.         this.organizer = ""
  105.         this.eventType = ""
  106.         this.startDate = startDate
  107.         this.endDate = endDate
  108.         this.updates = ""
  109.         this.originalNumberOfParticipants = originalNumberOfParticipants
  110.         this.numberOfServiceHoursOfParticipants = numberOfServiceHoursOfParticipants
  111.         this.attendance = ""
  112.         this.audience = ""
  113.         this.copyright = copyright
  114.         this.categoriesAndFacilities = ""
  115.     }
  116.  
  117.     constructor(scoutFeedItemEntity: ScoutFeedItemEntity) : this(
  118.             scoutFeedItemEntity.id,
  119.             scoutFeedItemEntity.shareUrl,
  120.             scoutFeedItemEntity.type,
  121.             scoutFeedItemEntity.image,
  122.             scoutFeedItemEntity.language,
  123.             scoutFeedItemEntity.author,
  124.             scoutFeedItemEntity.date,
  125.             scoutFeedItemEntity.description,
  126.             scoutFeedItemEntity.creator,
  127.             scoutFeedItemEntity.tags,
  128.             scoutFeedItemEntity.links,
  129.             scoutFeedItemEntity.attachments,
  130.             scoutFeedItemEntity.originalArticle,
  131.             scoutFeedItemEntity.gallery,
  132.             scoutFeedItemEntity.topics,
  133.             scoutFeedItemEntity.title,
  134.             scoutFeedItemEntity.location,
  135.             scoutFeedItemEntity.contactInfo,
  136.             scoutFeedItemEntity.organizer,
  137.             scoutFeedItemEntity.eventType,
  138.             scoutFeedItemEntity.startDate,
  139.             scoutFeedItemEntity.endDate,
  140.             scoutFeedItemEntity.updates,
  141.             scoutFeedItemEntity.originalNumberOfParticipants,
  142.             scoutFeedItemEntity.numberOfServiceHoursOfParticipants,
  143.             scoutFeedItemEntity.attendance,
  144.             scoutFeedItemEntity.audience,
  145.             scoutFeedItemEntity.copyright,
  146.             scoutFeedItemEntity.categoriesAndFacilities
  147.     )
  148.  
  149.     fun store(compartment: DatabaseCompartment) {
  150.         compartment.put(this)
  151.     }
  152.  
  153.     fun toScoutFeedItemEntity(): ScoutFeedItemEntity {
  154.         val gson = Gson()
  155.         val tagListType = object : TypeToken<List<TagEntity>>() {}.type
  156.         val stringListType = object : TypeToken<List<String>>() {}.type
  157.         val attachmentListType = object : TypeToken<List<AttachmentEntity>>() {}.type
  158.         val galleryListType = object : TypeToken<List<ImageEntity>>() {}.type
  159.         val topicsListType = object : TypeToken<List<TopicEntity>>() {}.type
  160.         val updatesListType = object : TypeToken<List<UpdateEntity>>() {}.type
  161.         val audienceListType = object : TypeToken<List<AudienceEntity>>() {}.type
  162.         val categoriesFacilitiesType = object : TypeToken<List<FacilityEntity>>() {}.type
  163.         return ScoutFeedItemEntity(
  164.                 _id,
  165.                 shareUrl,
  166.                 type,
  167.                 ImageEntity("", ""),
  168.                 language,
  169.                 ProfileEntity(0L, "", UserProfileEntity(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)),
  170.                 date,
  171.                 description,
  172.                 ProfileEntity(0L, "", UserProfileEntity(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)),
  173.                 listOf(TagEntity(0L, "")),
  174.                 listOf(""),
  175.                 listOf(AttachmentEntity(0L, "", "")),
  176.                 originalArticle,
  177.                 listOf(ImageEntity("", "")),
  178.                 gson.fromJson(topics, topicsListType),
  179.                 title,
  180.                 LocationEntity("", "", "", "", ""),
  181.                 contactInfo,
  182.                 ProfileEntity(0L, "", UserProfileEntity(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)),
  183.                 EventType.GLOBAL,
  184.                 startDate,
  185.                 endDate,
  186.                 listOf(UpdateEntity(0L, ImageEntity("", ""), "", "", "", null, null)),
  187.                 originalNumberOfParticipants,
  188.                 numberOfServiceHoursOfParticipants,
  189.                 AttendanceEntity.GOING,
  190.                 listOf(AudienceEntity(0L, "")),
  191.                 copyright,
  192.                 listOf(FacilityEntity("", listOf("")))
  193.         )
  194.     }
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement