Commit 241cf0ba authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

actualize raw models

parent 7fcc5468
......@@ -74,7 +74,6 @@ data class EstateRoomRaw(
)
data class FeedRaw(
val id:Int,
val alias:String,
val title:String
)
......@@ -99,6 +98,8 @@ data class ArticleRaw(
val id : Int,
val published : Date,
val title : String,
val announce: String,
val preview: String?,
val body : String,
val feed_alias : String,
val photo : List<NewsPhotoRaw>?
......@@ -156,4 +157,16 @@ data class AppVersionRaw(
val message : String?,
val critical : Boolean,
val errors : List<ErrorRaw>?
)
data class WebCamRaw(
val id:Int,
val title:String,
val Streams:List<StreamRaw>
)
data class StreamRaw(
val res_name:String,
val hls:String,
val rtmp:String
)
\ No newline at end of file
......@@ -22,7 +22,7 @@ interface Article : Persistable {
val preview : String?
@get:Nullable
val body : String?
@get:ForeignKey(references = Feed::class, referencedColumn = "id")
@get:ForeignKey(references = Feed::class, referencedColumn = "alias")
@get:ManyToOne(cascade = [CascadeAction.NONE])
val feed : Feed?
@get:Convert(TitledPhotoListConverter::class)
......
......@@ -9,11 +9,9 @@ import io.requery.*
@Entity
interface Feed : Persistable {
@get:Key
val id: Int
val title:String
val alias: String
val title:String
@get:JunctionTable(name= "FeedArticlesRule")
@get:OneToMany( cascade = [CascadeAction.DELETE])
val articles:Set<Article>?
......
......@@ -27,7 +27,6 @@ fun fromRaw(raw: AuthRaw) : UserEntity {
fun fromRaw(raw:FeedRaw) : FeedEntity {
val entity = FeedEntity()
entity.setId(raw.id)
entity.setTitle(raw.title)
entity.setAlias(raw.alias)
return entity
......@@ -36,9 +35,12 @@ fun fromRaw(raw:FeedRaw) : FeedEntity {
fun fromRaw(raw:ArticleRaw) : ArticleEntity {
val entity = ArticleEntity()
entity.setId(raw.id)
entity.setPublished(raw.published)
entity.setTitle(raw.title)
entity.setBody(raw.body)
entity.setPreview(raw.feed_alias)
entity.setAnnounce(raw.announce)
entity.setPreview(raw.preview)
raw.photo?.let {entity.photo = fromRawList(it, ::fromRaw)}
val feed = FeedEntity()
feed.setAlias(raw.feed_alias)
entity.setFeed(feed)
......@@ -47,7 +49,7 @@ fun fromRaw(raw:ArticleRaw) : ArticleEntity {
}
fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{
fun fromRaw(raw:NewsArticleRaw,feedAlias:String):ArticleEntity{
val entity = ArticleEntity()
entity.setId(raw.id)
entity.setPreview(raw.preview)
......@@ -55,31 +57,12 @@ fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{
entity.setPublished(raw.published)
entity.setTitle(raw.title)
val feed = FeedEntity()
feed.setId(feedId)
// feed.setAlias(feedAlias)
feed.setAlias(feedAlias)
entity.setFeed(feed)
return entity
}
fun fromRaw(raw:ArticleRaw,feedId: Int):ArticleEntity{
val entity = ArticleEntity()
entity.setId(raw.id)
entity.setPublished(raw.published)
entity.setTitle(raw.title)
entity.setBody(raw.body)
raw.photo?.let {
entity.photo = fromRawList(it,::fromRaw)
}
val feed = FeedEntity()
feed.setId(feedId)
// feed.setAlias(raw.feed_alias)
entity.setFeed(feed)
return entity
}
fun fromRaw(raw:NewsPhotoRaw):TitledPhoto{
return TitledPhoto(raw.title,raw.url)
}
......@@ -99,7 +82,7 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
fun <E,M> fromRawList(raw: List<E>,block:(E)->M):List<M> = List(raw.size) { index-> block(raw[index]) }
fun fromRaw(raw: List<NewsArticleRaw>,feedId:Int):List<ArticleEntity> =
List(raw.size) { index-> fromRaw(raw[index],feedId) }
fun fromRaw(raw: List<NewsArticleRaw>,feedAlias:String):List<ArticleEntity> =
List(raw.size) { index-> fromRaw(raw[index],feedAlias) }
val calcTargetResolution = max(display.widthPixels,display.heightPixels)
......@@ -21,7 +21,7 @@ const val ESTATES_CACHE_LIMIT_SECONDS_INACTIVE = 200L
const val FILES_CACHE_LIMIT_SIZE = 10000
const val FILES_CACHE_LIMIT_SECONDS_INACTIVE = 60L
const val DATABASE_VERSION = 7
const val DATABASE_VERSION = 8
@Module
abstract class AppModule{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment