Skip to content

Commit

Permalink
Merge pull request #5 from teogor/feature/introduce-core-database-pac…
Browse files Browse the repository at this point in the history
…kage

Add :core:database package for data management
  • Loading branch information
teogor authored Feb 15, 2024
2 parents fd9ac93 + ffceb58 commit 749d858
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {
ksp {
arg("stitch.addDocumentation", "true")
arg("stitch.generateOperations", "true")
arg("stitch.generatedPackageName", "dev.teogor.stitch.database")
arg("stitch.generatedPackageName", "dev.teogor.stitch")
}

android {
Expand Down Expand Up @@ -94,4 +94,4 @@ dependencies {

implementation(project(":common"))
ksp(project(":ksp"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@
* limitations under the License.
*/

package dev.teogor.stitch.data
package dev.teogor.stitch.core.database

// import dev.teogor.stitch.data.dao.GameWithBoardDao
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import dev.teogor.stitch.data.converters.Converters
import dev.teogor.stitch.data.converters.DurationConverter
import dev.teogor.stitch.data.converters.ZonedDateTimeConverter
import dev.teogor.stitch.data.dao.SavedGameDao
import dev.teogor.stitch.data.dao.TestingKindDao
import dev.teogor.stitch.data.model.SavedGame
import dev.teogor.stitch.data.model.TestingKind
import dev.teogor.stitch.core.database.util.Converters
import dev.teogor.stitch.core.database.util.DurationConverter
import dev.teogor.stitch.core.database.util.ZonedDateTimeConverter
import dev.teogor.stitch.core.database.dao.SavedGameDao
import dev.teogor.stitch.core.database.dao.TestingKindDao
import dev.teogor.stitch.core.database.model.SavedGame
import dev.teogor.stitch.core.database.model.TestingKind

@Database(
entities = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.dao
package dev.teogor.stitch.core.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import dev.teogor.stitch.data.model.SavedGame
import dev.teogor.stitch.core.database.model.SavedGame
import kotlinx.coroutines.flow.Flow

@Dao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.dao
package dev.teogor.stitch.core.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import dev.teogor.stitch.data.model.SavedGame
import dev.teogor.stitch.core.database.model.SavedGame
import kotlinx.coroutines.flow.Flow

@Dao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.model
package dev.teogor.stitch.core.database.model

/**
* Represents the difficulty levels of Sudoku puzzles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.model
package dev.teogor.stitch.core.database.model

// TODO get box size and row/col size

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.model
package dev.teogor.stitch.core.database.model

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.model
package dev.teogor.stitch.core.database.model

enum class SudokuEventType {
Daily,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.model
package dev.teogor.stitch.core.database.model

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.converters
package dev.teogor.stitch.core.database.util

import androidx.room.TypeConverter
import dev.teogor.stitch.data.model.Difficulty
import dev.teogor.stitch.data.model.GameType
import dev.teogor.stitch.data.model.SudokuEventType
import dev.teogor.stitch.core.database.model.Difficulty
import dev.teogor.stitch.core.database.model.GameType
import dev.teogor.stitch.core.database.model.SudokuEventType

object Converters {
@TypeConverter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.converters
package dev.teogor.stitch.core.database.util

import androidx.room.TypeConverter
import java.time.Duration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.teogor.stitch.data.converters
package dev.teogor.stitch.core.database.util

import androidx.room.TypeConverter
import java.time.Instant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class OperationOutputWriter(
generatedClasses.forEach { (baseName, invokeFunctions) ->
val className = "${room.name}${baseName.titleCase()}Operation"
fileBuilder(
packageName = "${room.getPackageName()}.operations",
packageName = "${room.getPackageName()}.database.operation",
fileName = className,
) {
addType(
Expand All @@ -88,7 +88,7 @@ class OperationOutputWriter(
PropertySpec.builder(
"repository",
ClassName(
"${room.getPackageName()}.repository",
"${room.getPackageName()}.data.repository",
"${room.name}Repository",
),
)
Expand All @@ -101,7 +101,7 @@ class OperationOutputWriter(
.addParameter(
"repository",
ClassName(
"${room.getPackageName()}.repository",
"${room.getPackageName()}.data.repository",
"${room.name}Repository",
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RepositoryImplOutputWriter(
repositoryType: TypeName,
) {
fileBuilder(
packageName = "${roomModel.getPackageName()}.repository.impl",
packageName = "${roomModel.getPackageName()}.data.repository.impl",
fileName = "${roomModel.name}RepositoryImpl",
) {
addType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RepositoryOutputWriter(

fun write(roomModel: RoomModel): TypeName {
fileBuilder(
packageName = "${roomModel.getPackageName()}.repository",
packageName = "${roomModel.getPackageName()}.data.repository",
fileName = "${roomModel.name}Repository",
) {
addType(
Expand Down Expand Up @@ -103,7 +103,7 @@ class RepositoryOutputWriter(
}.writeWith(codeOutputStreamMaker)

return ClassName(
"${roomModel.getPackageName()}.repository",
"${roomModel.getPackageName()}.data.repository",
"${roomModel.name}Repository",
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class StitchModuleOutputWriter(
.addAnnotation(DAGGER_PROVIDES)
.returns(
ClassName(
"${roomModel.getPackageName()}.repository",
"${roomModel.getPackageName()}.data.repository",
"${roomModel.name}Repository",
),
)
Expand All @@ -149,7 +149,7 @@ class StitchModuleOutputWriter(
.addStatement(
"return %T(dao)",
ClassName(
"${roomModel.getPackageName()}.repository.impl",
"${roomModel.getPackageName()}.data.repository.impl",
"${roomModel.name}RepositoryImpl",
),
)
Expand Down

0 comments on commit 749d858

Please sign in to comment.