Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
3a000574
Commit
3a000574
authored
Apr 03, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tours and files db model, download use case
parent
3dd76784
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
541 additions
and
0 deletions
+541
-0
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+32
-0
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+196
-0
DownloadUseCase.kt
...iganto/visual/roompark/domain/use_case/DownloadUseCase.kt
+313
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
3a000574
package
com.biganto.visual.roompark.data.repository.db
import
com.biganto.visual.roompark.data.repository.db.requrey.RevisionString
import
com.biganto.visual.roompark.data.repository.db.requrey.model.*
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.DownloadState
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
import
io.reactivex.Completable
import
io.reactivex.Flowable
import
io.reactivex.Observable
import
io.reactivex.Single
import
io.requery.Persistable
import
io.requery.reactivex.ReactiveResult
import
io.requery.reactivex.ReactiveScalar
/**
* Created by Vladislav Bogdashkin on 29.10.2019.
...
...
@@ -36,4 +41,31 @@ interface IDb {
fun
setDealReadState
(
id
:
String
,
state
:
Boolean
):
Completable
fun
saveSubscription
(
subscription
:
SubscriptionEntity
):
Single
<
SubscriptionEntity
>
fun
getSubscription
(
id
:
Int
):
ReactiveResult
<
SubscriptionEntity
>
fun
deleteTourPreview
(
id
:
String
):
Int
?
fun
deleteTourPreview
(
entity
:
TourPreviewEntity
)
fun
deleteFiles
(
entity
:
List
<
FileEntity
>)
fun
deleteFile
(
entity
:
FileEntity
)
fun
deleteTourFilesJunction
(
tourId
:
String
):
ReactiveScalar
<
Int
>
fun
deleteTourFilesJunction
(
entity
:
List
<
TourFileJunctionEntity
>)
fun
getTourFilesJunctionUniqueFiles
(
tourId
:
String
):
List
<
TourFileJunctionEntity
?
>
fun
getTourFilesJunction
(
tourId
:
String
):
ReactiveResult
<
TourFileJunctionEntity
>
fun
upsertFileEntity
(
entity
:
List
<
FileEntity
>):
Observable
<
Iterable
<
FileEntity
>>
fun
upsertFileEntity
(
entity
:
FileEntity
):
Observable
<
FileEntity
>
fun
flowableFileEntityes
(
uris
:
List
<
RevisionString
>):
Flowable
<
FileEntity
>
fun
getDownloadedSumFileEntityes
(
uris
:
List
<
RevisionString
>):
Long
fun
fetchTouresWithStates
(
states
:
List
<
DownloadState
>):
MutableList
<
TourPreviewEntity
>?
fun
fetchFileEntityes
(
uris
:
List
<
RevisionString
>):
MutableList
<
FileEntity
>
fun
pushFileEntities
(
uris
:
List
<
FileEntity
>):
Observable
<
Iterable
<
FileEntity
>>
fun
getFileEntity
(
uri
:
RevisionString
):
ReactiveResult
<
FileEntity
>
fun
getTourFiles
(
entity
:
TourPreviewEntity
):
MutableList
<
TourFileJunctionEntity
>
fun
getTourFiles
(
tourId
:
String
):
MutableList
<
TourFileJunctionEntity
>
fun
getTourFilesObservable
(
tourId
:
String
):
ReactiveResult
<
TourFileJunctionEntity
>
fun
upsertTourPreview
(
list
:
List
<
TourPreviewEntity
>):
Observable
<
Iterable
<
TourPreviewEntity
>>
fun
upsertTourPreview
(
entity
:
TourPreviewEntity
):
Observable
<
TourPreviewEntity
>
fun
upsertTourFileJunction
(
entity
:
List
<
TourFileJunctionEntity
>):
Observable
<
Iterable
<
TourFileJunctionEntity
>>
fun
upsertTourFileJunction
(
entity
:
TourFileJunctionEntity
):
Observable
<
TourFileJunctionEntity
>
fun
observableTourDownloadState
():
Flowable
<
TourPreviewEntity
>
fun
getFileEntitysOrDefault
(
uri
:
RevisionString
):
FileEntity
fun
getTourPreview
(
tourId
:
String
):
ReactiveResult
<
TourPreviewEntity
>
fun
getTourPreviewsObservableResult
(
estateId
:
Int
):
Observable
<
ReactiveResult
<
TourPreviewEntity
>>
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
3a000574
...
...
@@ -5,11 +5,16 @@ import com.biganto.visual.roompark.Models
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.*
import
com.biganto.visual.roompark.di.dagger.DATABASE_VERSION
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.DownloadState
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreview
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
import
dagger.Module
import
dagger.Provides
import
io.reactivex.BackpressureStrategy
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Single
import
io.reactivex.schedulers.Schedulers
import
io.requery.Persistable
import
io.requery.android.sqlite.DatabaseSource
import
io.requery.reactivex.KotlinReactiveEntityStore
...
...
@@ -185,4 +190,195 @@ class RequeryRepository @Inject constructor(
.
where
(
SubscriptionEntity
.
ID
.
eq
(
id
))
.
get
()
///region tours files
override
fun
getTourPreviewsObservableResult
(
estateId
:
Int
)
=
store
.
select
(
TourPreviewEntity
::
class
)
// .join(UserEntity::class).on(UserEntity::uuid.eq(estateId))
.
where
(
TourPreviewEntity
.
ESTATE_ID
.
eq
(
estateId
))
.
get
()
.
observableResult
()
override
fun
getTourPreview
(
tourId
:
String
)
=
store
.
select
(
TourPreviewEntity
::
class
)
.
where
(
TourPreviewEntity
.
ID
.
eq
(
tourId
))
.
get
()
override
fun
upsertTourPreview
(
list
:
List
<
TourPreviewEntity
>)
=
store
.
upsert
(
list
)
.
doOnSuccess
{
Timber
.
d
(
"Upsertd succses %s"
,
it
.
count
())
}
.
toObservable
()
override
fun
upsertTourPreview
(
entity
:
TourPreviewEntity
)
=
store
.
upsert
(
entity
)
.
toObservable
()
override
fun
upsertTourFileJunction
(
entity
:
List
<
TourFileJunctionEntity
>)
:
Observable
<
Iterable
<
TourFileJunctionEntity
>>
=
store
.
upsert
(
entity
).
toObservable
()
override
fun
upsertTourFileJunction
(
entity
:
TourFileJunctionEntity
)
=
store
.
upsert
(
entity
)
.
toObservable
()
override
fun
observableTourDownloadState
()
=
store
.
select
(
TourPreviewEntity
::
class
)
.
where
(
TourPreviewEntity
.
DOWNLOADED
.
notIn
(
arrayListOf
(
DownloadState
.
NotDownloaded
,
DownloadState
.
MetaPreparation
)))
.
get
()
// .flowable()
// .
.
observableResult
()
.
flatMap
{
it
.
observable
()
}
.
toFlowable
(
BackpressureStrategy
.
BUFFER
)
.
subscribeOn
(
Schedulers
.
io
())
override
fun
getFileEntitysOrDefault
(
uri
:
RevisionString
)
=
store
.
select
(
FileEntity
::
class
)
.
where
(
FileEntity
.
URI
.
eq
(
uri
))
.
get
()
.
firstOr
{
val
entity
=
FileEntity
()
entity
.
setUri
(
uri
)
entity
.
setDownloadedSize
(
0
)
entity
.
setTotalSize
(
0
)
entity
.
setDownloaded
(
false
)
entity
}
override
fun
getFileEntity
(
uri
:
RevisionString
)
=
store
.
select
(
FileEntity
::
class
)
.
where
(
FileEntity
.
URI
.
eq
(
uri
))
.
get
()
override
fun
getTourFiles
(
entity
:
TourPreviewEntity
)
=
store
.
select
(
TourFileJunctionEntity
::
class
)
.
where
(
TourFileJunctionEntity
.
TOUR
.
eq
(
entity
.
id
))
.
get
()
.
toList
()
override
fun
getTourFiles
(
tourId
:
String
)
=
store
.
select
(
TourFileJunctionEntity
::
class
)
.
where
(
TourFileJunctionEntity
.
TOUR
.
eq
(
tourId
))
.
get
()
.
toList
()
override
fun
getTourFilesObservable
(
tourId
:
String
)
=
store
.
select
(
TourFileJunctionEntity
::
class
)
.
where
(
TourFileJunctionEntity
.
TOUR
.
eq
(
tourId
))
.
get
()
override
fun
pushFileEntities
(
uris
:
List
<
FileEntity
>)
=
store
.
select
(
FileEntity
::
class
)
.
where
(
FileEntity
.
URI
.
`in`
(
uris
.
map
{
it
.
uri
}.
toList
()))
.
get
()
.
observable
()
.
toList
()
.
map
{
existedUris
->
uris
.
filter
{!
existedUris
.
map
{
file
->
file
.
uri
.
revisionUri
()
}.
contains
(
it
.
uri
.
revisionUri
())
}.
toList
()}
.
flatMapObservable
{
store
.
insert
(
it
).
toObservable
()
}
override
fun
fetchFileEntityes
(
uris
:
List
<
RevisionString
>)
=
store
.
select
(
FileEntity
::
class
)
.
where
(
FileEntity
.
URI
.
`in`
(
uris
))
.
get
()
.
toList
()
override
fun
fetchTouresWithStates
(
states
:
List
<
DownloadState
>)
=
store
.
select
(
TourPreviewEntity
::
class
)
.
where
(
TourPreviewEntity
.
DOWNLOADED
.
`in`
(
states
))
.
get
()
.
toList
()
override
fun
getDownloadedSumFileEntityes
(
uris
:
List
<
RevisionString
>)
=
store
.
select
(
FileEntity
::
class
)
.
where
(
FileEntity
.
URI
.
`in`
(
uris
))
.
get
()
.
map
{
it
.
downloadedSize
}
.
sum
()
// .observable()
override
fun
flowableFileEntityes
(
uris
:
List
<
RevisionString
>)
=
store
.
select
(
FileEntity
::
class
)
.
where
(
FileEntity
.
URI
.
`in`
(
uris
))
.
get
()
.
flowable
()
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
Schedulers
.
computation
())
override
fun
upsertFileEntity
(
entity
:
FileEntity
)
=
store
.
upsert
(
entity
)
.
toObservable
()
override
fun
upsertFileEntity
(
entity
:
List
<
FileEntity
>)
=
store
.
upsert
(
entity
)
.
toObservable
()
override
fun
getTourFilesJunction
(
tourId
:
String
)
=
store
.
select
(
TourFileJunctionEntity
::
class
)
.
where
(
TourFileJunctionEntity
.
TOUR
.
eq
(
tourId
))
.
get
()
override
fun
getTourFilesJunctionUniqueFiles
(
tourId
:
String
):
List
<
TourFileJunctionEntity
?
>
=
store
.
raw
(
TourFileJunctionEntity
::
class
,
"SELECT tfj.* from TourFileJunction tfj "
+
"join TourFileJunction tfj2 on tfj2.file = tfj.File "
+
"WHERE tfj2.tour = $tourId "
+
"GROUP BY tfj.file "
+
"HAVING COUNT(tfj.file) < 2"
)
.
toList
()
private
fun
<
E
:
Persistable
>
deleteBlocking
(
entity
:
E
)
=
store
.
delete
(
entity
)
.
blockingAwait
()
private
fun
<
E
:
List
<
Persistable
>
>
deleteBlocking
(
entity
:
E
)
=
store
.
delete
(
entity
)
.
blockingAwait
()
override
fun
deleteTourFilesJunction
(
entity
:
List
<
TourFileJunctionEntity
>)
=
deleteBlocking
(
entity
)
override
fun
deleteTourFilesJunction
(
tourId
:
String
)
=
store
.
delete
(
TourFileJunctionEntity
::
class
)
.
where
(
TourFileJunctionEntity
.
TOUR
.
eq
(
tourId
))
.
get
()
override
fun
deleteFile
(
entity
:
FileEntity
)
=
deleteBlocking
(
entity
)
override
fun
deleteFiles
(
entity
:
List
<
FileEntity
>)
=
deleteBlocking
(
entity
)
override
fun
deleteTourPreview
(
entity
:
TourPreviewEntity
)
=
deleteBlocking
(
entity
)
override
fun
deleteTourPreview
(
id
:
String
)
=
store
.
delete
(
TourPreview
::
class
)
.
where
(
TourPreviewEntity
.
ID
.
eq
(
id
))
.
get
()
.
single
()
.
blockingGet
()
///endregion
}
app/src/main/java/com/biganto/visual/roompark/domain/use_case/DownloadUseCase.kt
0 → 100644
View file @
3a000574
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment