11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SamplePromiseApp
4 | Project SamplePromiseApp created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.buildship.core.gradleprojectbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.buildship.core.gradleprojectnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | arguments=
2 | auto.sync=false
3 | build.scans.enabled=false
4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5 | connection.project.dir=
6 | eclipse.preferences.version=1
7 | gradle.user.home=
8 | java.home=C\:/Program Files/Java/jdk-13.0.1
9 | jvm.arguments=
10 | offline.mode=false
11 | override.workspace.settings=true
12 | show.console.view=true
13 | show.executions.view=true
14 |
--------------------------------------------------------------------------------
/app/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | app
4 | Project app created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=..
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/app/deps.txt:
--------------------------------------------------------------------------------
1 | // implementation 'com.google.dagger:dagger:2.27'
2 | // kapt 'com.google.dagger:dagger-compiler:2.27'
3 | //
4 | // implementation 'com.google.dagger:dagger-android:2.27'
5 | // implementation 'com.google.dagger:dagger-android-support:2.27' // if you use the support libraries
6 | // kapt 'com.google.dagger:dagger-android-processor:2.27'
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class tableName to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file tableName.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/promise/dbapp/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp
15 |
16 | import androidx.test.InstrumentationRegistry
17 | import androidx.test.runner.AndroidJUnit4
18 | import org.junit.Assert.assertEquals
19 | import org.junit.Test
20 | import org.junit.runner.RunWith
21 |
22 | /**
23 | * Instrumented test, which will execute on an Android device.
24 | *
25 | * See [testing documentation](http://d.android.com/tools/testing).
26 | */
27 | @RunWith(AndroidJUnit4::class)
28 | class ExampleInstrumentedTest {
29 | @Test
30 | fun useAppContext() {
31 | // Context of the app under test.
32 | val appContext = InstrumentationRegistry.getTargetContext()
33 | assertEquals("promise.dbapp", appContext.packageName)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
17 |
18 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/AppDatabase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.base
15 |
16 | import promise.base.comment.Like
17 | import promise.base.comment.PostComment
18 | import promise.base.photo.Photo
19 | import promise.base.post.Post
20 | import promise.base.session.User
21 | import promise.base.todo.Todo
22 | import promise.commons.data.log.LogUtil
23 | import promise.database.DatabaseEntity
24 | import promise.db.FastDatabase
25 | import promise.db.PromiseDatabase
26 | import promise.utils.Visitor
27 |
28 | @DatabaseEntity(
29 | persistableEntities = [
30 | PostComment::class,
31 | Photo::class,
32 | Post::class,
33 | Todo::class,
34 | Like::class,
35 | User::class
36 | ],
37 | version = 2
38 | )
39 | abstract class AppDatabase(fastDatabase: FastDatabase)
40 | : PromiseDatabase(fastDatabase) {
41 |
42 | init {
43 | fastDatabase.setErrorHandler {
44 | LogUtil.e(TAG, "database error: ${it.path}")
45 | }
46 | fastDatabase.fallBackToDestructiveMigration()
47 | }
48 |
49 | //abstract fun getPostCommentsDao(): PostCommentDao
50 |
51 | companion object {
52 | val TAG: String = LogUtil.makeTag(AppDatabase::class.java)
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/AppTypeConverter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.base
15 |
16 | import promise.database.TypeConverter
17 | import java.util.*
18 |
19 | @TypeConverter
20 | class AppTypeConverter {
21 |
22 | fun dateToString(date: Date?): String = (date ?: Date()).time.toString()
23 |
24 | fun stringToDate(data: String): Date = Date(data.toLong())
25 |
26 | fun toUniqueId(data: String): ID = ID().apply { id = data }
27 |
28 | fun toString(data: ID?): String = data?.id ?: ""
29 |
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/ID.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.base
15 |
16 | import android.os.Parcel
17 | import android.os.Parcelable
18 |
19 | class ID() : Parcelable {
20 | var id: String? = ""
21 |
22 | constructor(parcel: Parcel) : this() {
23 | id = parcel.readString()
24 | }
25 |
26 | override fun writeToParcel(parcel: Parcel, flags: Int) {
27 | parcel.writeString(id)
28 | }
29 |
30 | override fun describeContents(): Int = 0
31 |
32 | companion object CREATOR : Parcelable.Creator {
33 | override fun createFromParcel(parcel: Parcel): ID = ID(parcel)
34 | override fun newArray(size: Int): Array = arrayOfNulls(size)
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/comment/PostCommentDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.base.comment;
15 |
16 | import java.util.List;
17 |
18 | import promise.database.DAO;
19 | import promise.db.criteria.Criteria;
20 |
21 | @DAO
22 | public interface PostCommentDao {
23 |
24 | List getPostComments(Criteria criteria);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/comment/PostCommentToReplyRelation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.base.comment;
15 |
16 | import java.util.List;
17 |
18 | import promise.database.Child;
19 | import promise.database.Parent;
20 | import promise.database.Relation;
21 |
22 | @Relation
23 | public class PostCommentToReplyRelation {
24 |
25 | @Parent
26 | private PostComment postComment;
27 |
28 | @Child(fieldRelatedToParent = "postCommentId")
29 | private List postCommentReplies;
30 |
31 | public PostComment getPostComment() {
32 | return postComment;
33 | }
34 |
35 | public void setPostComment(PostComment postComment) {
36 | this.postComment = postComment;
37 | }
38 |
39 | public List getPostCommentReplies() {
40 | return postCommentReplies;
41 | }
42 |
43 | public void setPostCommentReplies(List postCommentReplies) {
44 | this.postCommentReplies = postCommentReplies;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/photo/Photo.kt:
--------------------------------------------------------------------------------
1 | package promise.base.photo
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 | import promise.base.post.Post
6 | import promise.database.Entity
7 | import promise.database.HasOne
8 | import promise.db.ActiveRecord
9 |
10 | @Entity
11 | class Photo() : ActiveRecord() {
12 | var albumId: Int? = null
13 | var title: String? = null
14 | var url: String? = null
15 | var thumbnailUrl: String? = null
16 |
17 | @HasOne
18 | var photoPost: Post? = null
19 |
20 | constructor(parcel: Parcel) : this() {
21 | albumId = parcel.readValue(Int::class.java.classLoader) as? Int
22 | title = parcel.readString()
23 | url = parcel.readString()
24 | thumbnailUrl = parcel.readString()
25 | photoPost = parcel.readParcelable(Post::class.java.classLoader)
26 | }
27 |
28 | override fun getEntity(): Photo = this
29 |
30 | override fun writeToParcel(parcel: Parcel, flags: Int) {
31 | super.writeToParcel(parcel, flags)
32 | parcel.writeValue(albumId)
33 | parcel.writeString(title)
34 | parcel.writeString(url)
35 | parcel.writeString(thumbnailUrl)
36 | parcel.writeParcelable(photoPost, flags)
37 | }
38 |
39 | override fun describeContents(): Int = 0
40 |
41 | companion object CREATOR : Parcelable.Creator {
42 | override fun createFromParcel(parcel: Parcel): Photo = Photo(parcel)
43 | override fun newArray(size: Int): Array = arrayOfNulls(size)
44 | }
45 |
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/post/PostRepository.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.base.post
15 |
16 | import promise.base.ID
17 | import promise.base.comment.PostComment
18 | import promise.model.IdentifiableList
19 | import javax.inject.Inject
20 | import javax.inject.Singleton
21 |
22 | interface PostRepository {
23 |
24 | fun savePost(post: Post)
25 |
26 | fun getPosts(): List
27 |
28 | fun deletePosts()
29 | }
30 |
31 | @Singleton
32 | class PostRepositoryImpl
33 | @Inject
34 | constructor(
35 | private var postRelationsDao: PostRelationsDao,
36 | private var postsTable: PostsTable) : PostRepository {
37 | init {
38 | val posts = IdentifiableList(promise.commons.model.List.generate(5) {
39 | Post().apply {
40 | uId = ID().apply {
41 | id = it.toString()
42 | }
43 | title = "post".plus(it)
44 | body = "body".plus(it)
45 | userId = it
46 | comments = promise.commons.model.List.generate(4) {
47 | PostComment().apply {
48 | name = "nm".repeat(it)
49 | uId = ID().apply {
50 | id = (it + 1).toString()
51 | }
52 | body = "hbytcvbcrxgfvbtrxt"
53 | email = "ejmail;jgfccghcfcvhbhcgvb"
54 | }
55 | }
56 | }
57 | })
58 |
59 | postRelationsDao.saveWithComments(posts)
60 | }
61 |
62 | override fun savePost(post: Post) {
63 | postsTable.save(post)
64 | }
65 |
66 | override fun getPosts(): List = postRelationsDao.listWithComments()
67 |
68 | override fun deletePosts() {
69 | val persons = getPosts()
70 | persons.forEach {
71 | postRelationsDao.deleteComments(it)
72 | it.delete()
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/session/User.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.base.session
15 |
16 | import android.annotation.SuppressLint
17 | import promise.database.AddedEntity
18 | import promise.database.Entity
19 | import promise.db.ActiveRecord
20 |
21 | @SuppressLint("ParcelCreator")
22 | @Entity
23 | @AddedEntity(fromVersion = 1, toVersion = 2)
24 | class User: ActiveRecord() {
25 |
26 | var email: String = ""
27 | var likedinProfileUrl = ""
28 | var photoUrl = ""
29 | var names = ""
30 | override fun getEntity(): User = this
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/promise/base/todo/Todo.java:
--------------------------------------------------------------------------------
1 | package promise.base.todo;
2 |
3 | import android.annotation.SuppressLint;
4 |
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | import promise.base.photo.Photo;
8 | import promise.database.Entity;
9 | import promise.database.HasOne;
10 | import promise.db.ActiveRecord;
11 |
12 | @SuppressLint("ParcelCreator")
13 | @Entity
14 | public class Todo extends ActiveRecord {
15 | private int uid;
16 | private boolean completed;
17 |
18 | private String title;
19 |
20 | private long timeStarted;
21 | private long timeFinished;
22 | private String description;
23 | @HasOne
24 | private Photo photo;
25 |
26 | public long getTimeFinished() {
27 | return timeFinished;
28 | }
29 |
30 | public void setTimeFinished(long timeFinished) {
31 | this.timeFinished = timeFinished;
32 | }
33 |
34 | public long getTimeStarted() {
35 | return timeStarted;
36 | }
37 |
38 | public void setTimeStarted(long timeStarted) {
39 | this.timeStarted = timeStarted;
40 | }
41 |
42 | public int getUid() {
43 | return uid;
44 | }
45 |
46 | public void setUid(int uid) {
47 | this.uid = uid;
48 | }
49 |
50 | public Photo getPhoto() {
51 | return photo;
52 | }
53 |
54 | public void setPhoto(Photo photo) {
55 | this.photo = photo;
56 | }
57 |
58 | public boolean isCompleted() {
59 | return completed;
60 | }
61 |
62 | public void setCompleted(boolean completed) {
63 | this.completed = completed;
64 | }
65 |
66 | public String getTitle() {
67 | return title;
68 | }
69 |
70 | public void setTitle(String title) {
71 | this.title = title;
72 | }
73 |
74 | public String getDescription() {
75 | return description;
76 | }
77 |
78 | public void setDescription(String description) {
79 | this.description = description;
80 | }
81 |
82 | @Override
83 | public String toString() {
84 | return
85 | "Todo{" +
86 | "id = '" + uid + '\'' +
87 | ",completed = '" + completed + '\'' +
88 | ",title = '" + title + '\'' +
89 | "}";
90 | }
91 |
92 | @NotNull
93 | @Override
94 | public Todo getEntity() {
95 | return this;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/dbapp/ActivityBuildersModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp
15 |
16 | import dagger.Module
17 | import dagger.android.ContributesAndroidInjector
18 |
19 | @Module
20 | abstract class ActivityBuildersModule {
21 | @ContributesAndroidInjector(
22 | modules = [
23 | ReposModule::class
24 | ]
25 | )
26 | abstract fun contributeMainActivity(): MainActivity
27 | }
--------------------------------------------------------------------------------
/app/src/main/java/promise/dbapp/App.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp
15 |
16 | import dagger.android.AndroidInjector
17 | import dagger.android.support.DaggerApplication
18 | import promise.commons.AndroidPromise
19 |
20 | class App : DaggerApplication() {
21 | override fun onCreate() {
22 | super.onCreate()
23 | AndroidPromise.init(this, BuildConfig.DEBUG)
24 | }
25 |
26 | override fun applicationInjector(): AndroidInjector =
27 | DaggerAppComponent.factory().create(this)
28 |
29 | }
--------------------------------------------------------------------------------
/app/src/main/java/promise/dbapp/AppComponent.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp
15 |
16 | import dagger.BindsInstance
17 | import dagger.Component
18 | import dagger.android.AndroidInjector
19 | import dagger.android.support.AndroidSupportInjectionModule
20 | import javax.inject.Singleton
21 |
22 | @Component(
23 | modules = [
24 | AndroidSupportInjectionModule::class,
25 | ActivityBuildersModule::class,
26 | DatabaseDependencies::class
27 | ]
28 | )
29 | @Singleton
30 | interface AppComponent : AndroidInjector {
31 |
32 | @Component.Factory
33 | interface Builder {
34 | fun create(@BindsInstance app: App): AppComponent
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/java/promise/dbapp/DatabaseDependencies.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp
15 |
16 | import dagger.Module
17 | import dagger.Provides
18 | import promise.base.AppDatabaseImpl
19 | import promise.base.post.PostRelationsDao
20 | import promise.base.post.PostsTable
21 | import javax.inject.Singleton
22 |
23 | @Module
24 | object DatabaseDependencies {
25 |
26 | @Provides
27 | @Singleton
28 | @JvmStatic
29 | fun provideAppDatabase(): AppDatabaseImpl = AppDatabaseImpl.createDatabase("blog_db")
30 |
31 | @Provides
32 | @JvmStatic
33 | fun providePostRelationsDao(appDatabase: AppDatabaseImpl): PostRelationsDao =
34 | appDatabase.postRelationsDao
35 |
36 | @Provides
37 | @JvmStatic
38 | fun providePostTable(appDatabase: AppDatabaseImpl): PostsTable =
39 | appDatabase.postsTable
40 |
41 | }
--------------------------------------------------------------------------------
/app/src/main/java/promise/dbapp/MainActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp
15 |
16 | import android.os.Bundle
17 | import com.google.android.material.snackbar.Snackbar
18 | import dagger.android.support.DaggerAppCompatActivity
19 | import kotlinx.android.synthetic.main.activity_main.*
20 | import kotlinx.android.synthetic.main.content_main.*
21 | import promise.base.post.PostRepository
22 | import javax.inject.Inject
23 |
24 | class MainActivity : DaggerAppCompatActivity() {
25 |
26 | @Inject
27 | lateinit var postRepository: PostRepository
28 |
29 | override fun onCreate(savedInstanceState: Bundle?) {
30 | super.onCreate(savedInstanceState)
31 | setContentView(R.layout.activity_main)
32 | setSupportActionBar(toolbar)
33 |
34 | fab.setOnClickListener { view ->
35 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
36 | .setAction("Action", null).show()
37 | }
38 | }
39 |
40 | override fun onPostCreate(savedInstanceState: Bundle?) {
41 | super.onPostCreate(savedInstanceState)
42 | showInfo()
43 | clear_button.setOnClickListener {
44 | deleteInfo()
45 | showInfo()
46 | }
47 | }
48 |
49 | private fun showInfo() {
50 | val persons = postRepository.getPosts()
51 | complex_values_textview.text = persons.toString()
52 | }
53 |
54 | private fun deleteInfo() {
55 | postRepository.deletePosts()
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/dbapp/ReposModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp
15 |
16 | import dagger.Binds
17 | import dagger.Module
18 | import promise.base.post.PostRepository
19 | import promise.base.post.PostRepositoryImpl
20 |
21 | @Module
22 | abstract class ReposModule {
23 |
24 | @Binds
25 | abstract fun bindPostsRepository(postRepositoryImpl: PostRepositoryImpl): PostRepository
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/promise/dbapp/test/PostCommentsDaoImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp.test;
15 |
16 | import android.database.Cursor;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import promise.base.comment.PostComment;
22 | import promise.base.comment.PostCommentDao;
23 | import promise.base.comment.PostCommentToReplyRelation;
24 | import promise.base.comment.PostCommentsTable;
25 | import promise.db.PromiseDatabase;
26 | import promise.db.criteria.Criteria;
27 | import promise.model.IdentifiableList;
28 |
29 | public class PostCommentsDaoImpl
30 | implements PostCommentDao {
31 |
32 | private PromiseDatabase promiseDatabase;
33 |
34 | public PostCommentsDaoImpl(PromiseDatabase fastDatabase) {
35 | this.promiseDatabase = fastDatabase;
36 | }
37 |
38 | private PostCommentToReplyRelation getPostCommentToReplyRelation(PostComment postComment) {
39 | return new PostCommentToReplyRelation() {{
40 | setPostComment(postComment);
41 | setPostCommentReplies(new ArrayList<>(
42 | promiseDatabase.tableOf(PostComment.class).findAll(
43 | PostCommentsTable.postCommentIdColumn.with(
44 | postComment.getId().toString()))));
45 | }};
46 | }
47 |
48 | @Override
49 | public List getPostComments(Criteria andCriteria) {
50 | Cursor cursor = promiseDatabase.getDatabaseInstance().query(
51 | promiseDatabase.tableOf(PostComment.class).queryBuilder()
52 | .whereAnd(andCriteria));
53 | return getPostCommentToReplyRelationCollection(cursor);
54 | }
55 |
56 | private List getPostCommentToReplyRelationCollection(Cursor cursor) {
57 | IdentifiableList extends PostComment> postComments = promiseDatabase.tableOf(PostComment.class).collection(cursor);
58 | return postComments.map(this::getPostCommentToReplyRelation);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/promise/dbapp/test/TestUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp.test;
15 |
16 |
17 | public class TestUtils {
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
20 |
21 |
25 |
26 |
32 |
33 |
34 |
35 |
36 |
37 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/complex_layout.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
22 |
23 |
27 |
28 |
33 |
34 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 | #008577
16 | #00574B
17 | #D81B60
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 | 16dp
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 | DBApp
16 | Settings
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
23 |
24 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/test/java/promise/dbapp/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.dbapp
15 |
16 | import org.junit.Assert.assertEquals
17 | import org.junit.Test
18 |
19 | /**
20 | * Example local unit test, which will execute on the development machine (host).
21 | *
22 | * See [testing documentation](http://d.android.com/tools/testing).
23 | */
24 | class ExampleUnitTest {
25 | @Test
26 | fun addition_isCorrect() {
27 | assertEquals(4, 2 + 2)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/commons/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/commons/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/commons/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | promisedatabase
4 | Project promisedatabase created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/commons/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=..
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/Corrupt.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/commons/bin/main/promise/db/Corrupt.class
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/DBError.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/commons/bin/main/promise/db/DBError.class
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/DatabaseEntity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/commons/bin/main/promise/db/DatabaseEntity.class
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/EntityInfo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db
15 |
16 | import kotlin.reflect.KClass
17 |
18 | @Target(AnnotationTarget.CLASS)
19 | @Retention(AnnotationRetention.SOURCE)
20 | annotation class AddedEntity(val fromVersion: Int,
21 | val toVersion: Int)
22 |
23 | @Target(AnnotationTarget.CLASS)
24 | @Retention(AnnotationRetention.SOURCE)
25 | annotation class Entity(val tableName: String = "",
26 | /**
27 | * @return
28 | */
29 | val compoundIndices: Array = []
30 | ) {
31 | /**
32 | *
33 | */
34 | @Target(AnnotationTarget.FIELD)
35 | @Retention(AnnotationRetention.SOURCE)
36 | annotation class CompoundIndex(
37 | val columns: Array,
38 | /**
39 | * @return
40 | */
41 | val unique: Boolean = false)
42 |
43 | /**
44 | *
45 | */
46 |
47 | }
48 |
49 | @Target(AnnotationTarget.FIELD)
50 | @Retention(AnnotationRetention.SOURCE)
51 | annotation class Index
52 |
53 | @Target(AnnotationTarget.FIELD)
54 | @Retention(AnnotationRetention.SOURCE)
55 | annotation class ForeignKey(
56 | /**
57 | * @return
58 | */
59 | val referencedEntity: KClass<*>,
60 | /**
61 | * @return
62 | */
63 | val referencedEntityColumnName: String = "id")
64 |
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/Query.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db
15 |
16 | @Target(AnnotationTarget.FUNCTION)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Query(val value: String)
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/Table$CompoundIndex.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/commons/bin/main/promise/db/Table$CompoundIndex.class
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/Table$ForeignKey.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/commons/bin/main/promise/db/Table$ForeignKey.class
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/Table$Index.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/commons/bin/main/promise/db/Table$Index.class
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/Table.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/commons/bin/main/promise/db/Table.class
--------------------------------------------------------------------------------
/commons/bin/main/promise/db/model/ITimeAware.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/commons/bin/main/promise/db/model/ITimeAware.class
--------------------------------------------------------------------------------
/commons/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | apply plugin: 'java-library'
15 | apply plugin: 'kotlin'
16 | apply plugin: 'maven'
17 |
18 | dependencies {
19 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
20 | }
21 |
22 | sourceCompatibility = "8"
23 | targetCompatibility = "8"
24 |
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/AddedEntity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.CLASS)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class AddedEntity(val fromVersion: Int,
19 | val toVersion: Int)
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Child.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Child(val fieldRelatedToParent: String,
19 | val parentRelatedField: String = "id")
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/ColumnInfo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class ColumnInfo(
19 | val columnName: String = "",
20 | val nullable: Boolean = true,
21 | val unique: Boolean = false,
22 | val default: Int = 0,
23 | val length: Int = 0
24 | )
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/DAO.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.CLASS)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class DAO
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/DatabaseEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database;
15 |
16 | import java.lang.annotation.ElementType;
17 | import java.lang.annotation.Retention;
18 | import java.lang.annotation.RetentionPolicy;
19 | import java.lang.annotation.Target;
20 |
21 | @Target(ElementType.TYPE)
22 | @Retention(RetentionPolicy.SOURCE)
23 | public @interface DatabaseEntity {
24 | int version() default 1;
25 |
26 | boolean generateCrudStubs() default false;
27 |
28 | Class>[] persistableEntities();
29 | }
30 |
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Embedded.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Embedded(val prefix: String = "")
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Entity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.CLASS)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Entity(val tableName: String = "",
19 | val compoundIndices: Array = [],
20 | val generateRelations: Boolean = true
21 | ) {
22 | @Target(AnnotationTarget.FIELD)
23 | @Retention(AnnotationRetention.SOURCE)
24 | annotation class CompoundIndex(
25 | val columns: Array,
26 | val unique: Boolean = false)
27 | }
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/ForeignKey.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | import kotlin.reflect.KClass
17 |
18 | @Target(AnnotationTarget.FIELD)
19 | @Retention(AnnotationRetention.SOURCE)
20 | annotation class ForeignKey(
21 | val referencedEntity: KClass<*>,
22 | val referencedEntityColumnName: String = "id")
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/HasMany.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 |
17 | @Target(AnnotationTarget.FIELD)
18 | @Retention(AnnotationRetention.SOURCE)
19 | annotation class HasMany
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/HasOne.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class HasOne
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Ignore.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Ignore
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Index.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Index
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Migrate.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Migrate(val fromVersion: Int,
19 | val toVersion: Int,
20 | val action: MigrationOptions)
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/MigrationOptions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | enum class MigrationOptions {
17 | CREATE, DROP, CREATE_INDEX, RENAME_COLUMN
18 | }
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Migrations.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Migrations(val values: Array)
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Parent.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Parent
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/PrimaryKey.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class PrimaryKey(val name: String = "")
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/PrimaryKeyAutoIncrement.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FIELD)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class PrimaryKeyAutoIncrement
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Query.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.FUNCTION)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Query(val where: String)
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Relation.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database
15 |
16 | @Target(AnnotationTarget.CLASS)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class Relation
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/Table.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | package promise.database
14 |
15 | @Target(AnnotationTarget.CLASS)
16 | @Retention(AnnotationRetention.RUNTIME)
17 | annotation class Table(val tableName: String,
18 | val indices: Array = [],
19 | val compoundIndexes: Array = [],
20 | val foreignKeys: Array = []) {
21 | @Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS)
22 | @Retention(AnnotationRetention.RUNTIME)
23 | annotation class Index(val columnName: String)
24 |
25 | @Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS)
26 | @Retention(AnnotationRetention.RUNTIME)
27 | annotation class CompoundIndex(val unique: Boolean = false,
28 | val indexes: Array = [])
29 |
30 | @Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS)
31 | @Retention(AnnotationRetention.RUNTIME)
32 | annotation class ForeignKey(val columnName: String,
33 | val referencedTableName: String,
34 | val referencedColumnName: String)
35 | }
--------------------------------------------------------------------------------
/commons/src/main/java/promise/database/TypeConverter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | package promise.database
14 |
15 |
16 | @Target(AnnotationTarget.CLASS)
17 | @Retention(AnnotationRetention.SOURCE)
18 | annotation class TypeConverter
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/compiler/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/compiler/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/compiler/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | androidpromisedatabasecompiler
4 | Project androidpromisedatabasecompiler created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/compiler/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=..
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/compiler/bin/main/promise/db/ompiler/CodeBlockGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db.ompiler
15 |
16 |
17 | interface CodeBlockGenerator {
18 | @Throws(Exception::class)
19 | fun generate(): T
20 | }
--------------------------------------------------------------------------------
/compiler/bin/main/promise/db/ompiler/JavaUtils$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/compiler/bin/main/promise/db/ompiler/JavaUtils$1.class
--------------------------------------------------------------------------------
/compiler/bin/main/promise/db/ompiler/JavaUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/compiler/bin/main/promise/db/ompiler/JavaUtils.class
--------------------------------------------------------------------------------
/compiler/bin/main/promise/db/ompiler/RegisterColumnsGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db.ompiler
15 |
16 | import com.squareup.javapoet.ClassName
17 | import com.squareup.javapoet.CodeBlock
18 | import com.squareup.javapoet.MethodSpec
19 | import com.squareup.javapoet.ParameterizedTypeName
20 | import com.squareup.javapoet.TypeName
21 | import com.squareup.javapoet.WildcardTypeName
22 | import org.jetbrains.annotations.NotNull
23 | import java.lang.reflect.Type
24 | import javax.lang.model.element.Modifier
25 | import javax.lang.model.type.TypeVariable
26 | import javax.lang.model.type.WildcardType
27 |
28 |
29 | class RegisterColumnsGenerator(
30 | private val columns: List) : CodeBlockGenerator {
31 | init {
32 | //fileSpec.addImport("promise.commons.model", "List")
33 | }
34 |
35 | override fun generate(): MethodSpec {
36 |
37 | var stmt = "return List.fromArray("
38 | columns.forEachIndexed { index, s ->
39 | stmt += s
40 | if (index != columns.size - 1) {
41 | stmt += ", "
42 | }
43 | }
44 | stmt += ");"
45 | return MethodSpec.methodBuilder("getColumns")
46 | .returns(
47 | ParameterizedTypeName.get(ClassName.get("promise.commons.model", "List"),
48 | WildcardTypeName.subtypeOf(
49 | ParameterizedTypeName.get(ClassName.get("promise.db", "Column"),
50 | WildcardTypeName.subtypeOf(TypeName.OBJECT)
51 | )
52 | )
53 | )
54 | )
55 | .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
56 | .addAnnotation(Override::class.java)
57 | .addAnnotation(NotNull::class.java)
58 | .addCode(CodeBlock.of(stmt))
59 | .build()
60 |
61 | }
62 | }
--------------------------------------------------------------------------------
/compiler/bin/main/promise/db/ompiler/annotation/TableAnnotationGenerator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/compiler/bin/main/promise/db/ompiler/annotation/TableAnnotationGenerator.class
--------------------------------------------------------------------------------
/compiler/bin/main/promise/db/ompiler/relations/RelationsGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db.ompiler.relations
15 |
16 | import com.squareup.javapoet.MethodSpec
17 | import promise.db.ManyToOne
18 | import promise.db.OneToOne
19 | import promise.db.ompiler.CodeBlockGenerator
20 | import java.util.*
21 | import javax.annotation.processing.ProcessingEnvironment
22 | import javax.lang.model.element.Element
23 | import javax.tools.Diagnostic
24 | import kotlin.collections.ArrayList
25 |
26 | class RelationsGenerator(
27 | private val processingEnvironment: ProcessingEnvironment
28 | ,
29 | private val setElements: List
30 | ) : CodeBlockGenerator?> {
31 |
32 | override fun generate(): List? {
33 | val funSpecs = ArrayList()
34 | filterNotPrimitiveElements(setElements.filter {
35 | it.kind.isField
36 | }).also {
37 | if (it.isEmpty()) return null
38 | }.forEach {
39 |
40 | }
41 | return funSpecs
42 | }
43 |
44 | private fun getNameOfColumn(element: Element): String {
45 | return element.simpleName.toString()
46 | }
47 |
48 | private fun filterNotPrimitiveElements(elements: List): List = elements.filter {
49 | try {
50 | it.getAnnotation(OneToOne::class.java) != null ||
51 | it.getAnnotation(ManyToOne::class.java) != null
52 | } catch (e: Throwable) {
53 | processingEnvironment.messager.printMessage(Diagnostic.Kind.ERROR,
54 | "FilterPrimitiveElement ${it.kind.name}: ${Arrays.toString(e.stackTrace)}")
55 | true
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/compiler/bin/test/promise/db/ompiler/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db.ompiler
15 |
16 | import org.junit.Test
17 |
18 | import org.junit.Assert.*
19 |
20 | /**
21 | * Example local unit test, which will execute on the development machine (host).
22 | *
23 | * See [testing documentation](http://d.android.com/tools/testing).
24 | */
25 | class ExampleUnitTest {
26 | @Test
27 | fun addition_isCorrect() {
28 | assertEquals(4, 2 + 2)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/compiler/build.gradle:
--------------------------------------------------------------------------------
1 | import org.gradle.internal.jvm.Jvm
2 |
3 | /*
4 | * Copyright 2017, Peter Vincent
5 | * Licensed under the Apache License, Version 2.0, Android Promise.
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | * Unless required by applicable law or agreed to in writing,
10 | * software distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | apply plugin: 'java-library'
17 | apply plugin: 'kotlin'
18 | apply plugin: 'kotlin-kapt'
19 | apply plugin: 'maven'
20 |
21 | dependencies {
22 | //compileOnly 'com.github.android-promise.database:commons:1.0.3-alpha7'
23 | compileOnly project(path: ':commons')
24 | compileOnly files(Jvm.current().getToolsJar())
25 | implementation 'com.google.auto.value:auto-value-annotations:1.7.4'
26 | kapt 'com.google.auto.value:auto-value:1.7.4'
27 | implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.0'
28 | implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.0'
29 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
30 | implementation 'org.atteo:evo-inflector:1.0.1'
31 | implementation 'com.squareup:javapoet:1.13.0'
32 | implementation "org.jetbrains.kotlin:kotlin-reflect:1.4.10"
33 | implementation 'com.google.auto:auto-common:0.10'
34 | compileOnly "com.google.auto.service:auto-service:1.0-rc4"
35 | kapt "com.google.auto.service:auto-service:1.0-rc4"
36 | testImplementation 'junit:junit:4.13'
37 | }
38 |
--------------------------------------------------------------------------------
/compiler/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/droid-forge/database/65208fab30e3ef2f1c71617e4403a2153b687084/compiler/consumer-rules.pro
--------------------------------------------------------------------------------
/compiler/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2017, Peter Vincent
3 | # Licensed under the Apache License, Version 2.0, Android Promise.
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | # http://www.apache.org/licenses/LICENSE-2.0
7 | # Unless required by applicable law or agreed to in writing,
8 | # software distributed under the License is distributed on an "AS IS" BASIS,
9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | # See the License for the specific language governing permissions and
11 | # limitations under the License.
12 | #
13 | POM_NAME=Promise Database Compiler
14 | POM_ARTIFACT_ID=promise-db-compiler
15 | POM_PACKAGING=war
--------------------------------------------------------------------------------
/compiler/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/compiler/src/androidTest/java/promise/db/ompiler/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db.ompiler
15 |
16 | import androidx.test.platform.app.InstrumentationRegistry
17 | import androidx.test.ext.junit.runners.AndroidJUnit4
18 |
19 | import org.junit.Test
20 | import org.junit.runner.RunWith
21 |
22 | import org.junit.Assert.*
23 |
24 | /**
25 | * Instrumented test, which will execute on an Android device.
26 | *
27 | * See [testing documentation](http://d.android.com/tools/testing).
28 | */
29 | @RunWith(AndroidJUnit4::class)
30 | class ExampleInstrumentedTest {
31 | @Test
32 | fun useAppContext() {
33 | // Context of the app under test.
34 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
35 | assertEquals("promise.db.androidpromisedatabasecompiler.test", appContext.packageName)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/compiler/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/AnnotatedClassProcessor.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler
15 |
16 | import com.squareup.javapoet.JavaFile
17 | import javax.annotation.processing.RoundEnvironment
18 |
19 | abstract class AnnotatedClassProcessor {
20 | abstract fun process(environment: RoundEnvironment?): List?
21 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/CodeGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler
15 |
16 |
17 | interface CodeGenerator {
18 | @Throws(Exception::class)
19 | fun generate(): T
20 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/DatabaseAnnotationGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler
15 |
16 | import com.squareup.javapoet.AnnotationSpec
17 | import com.squareup.javapoet.ClassName
18 | import com.squareup.javapoet.CodeBlock
19 | import promise.database.compiler.utils.LogUtil
20 | import promise.database.compiler.utils.getDatabaseVersion
21 | import promise.database.compiler.utils.getTableClassNameString
22 | import promise.database.compiler.utils.getTableEntities
23 | import javax.annotation.processing.ProcessingEnvironment
24 | import javax.lang.model.element.Element
25 | import javax.lang.model.element.TypeElement
26 | import kotlin.math.max
27 |
28 | class DatabaseAnnotationGenerator(
29 | private val processingEnv: ProcessingEnvironment,
30 | private val element: Element) : CodeGenerator {
31 |
32 | override fun generate(): AnnotationSpec {
33 | if (element is TypeElement) {
34 | var stmt = "{\n"
35 | var entities: Array? = null
36 | try {
37 | entities = element.getTableEntities(processingEnv)
38 | } catch (e: Throwable) {
39 | LogUtil.e(e)
40 | }
41 | val generatedVersion = TableMetaDataWriter.finalMaxDbVersion()
42 | val version = max(element.getDatabaseVersion(), generatedVersion)
43 | try {
44 | entities?.forEachIndexed { index, entityClass ->
45 | val className = entityClass.getTableClassNameString()
46 | stmt += "$className.class"
47 | if (index != entities.size - 1) {
48 | stmt += ",\n"
49 | }
50 | }
51 | stmt += "\n}"
52 | } catch (e: Throwable) {
53 | LogUtil.e(e)
54 | }
55 | return AnnotationSpec.builder(ClassName.get("promise.db", "Database"))
56 | .addMember("tables", CodeBlock.of(stmt))
57 | .addMember("version", "$version")
58 | .build()
59 | }
60 | throw IllegalStateException("Element must be a type element")
61 | }
62 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/DatabaseCrudStubMethodsGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler
15 |
16 | import com.squareup.javapoet.TypeSpec
17 | import javax.annotation.processing.ProcessingEnvironment
18 | import javax.lang.model.element.Element
19 |
20 | class DatabaseCrudStubMethodsGenerator(
21 | private val typeSpec: TypeSpec.Builder,
22 | private val element: Element,
23 | private val processingEnv: ProcessingEnvironment) : CodeGenerator {
24 |
25 | override fun generate(): String {
26 | // val pack = processingEnv.elementUtils.getPackageOf(element).toString()
27 | //
28 | // val entities = (element as TypeElement).getTableEntities(processingEnv)
29 |
30 | return "created"
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/RelationsDaoProcessor.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler
15 |
16 | import com.squareup.javapoet.JavaFile
17 | import promise.database.Entity
18 | import promise.database.compiler.utils.isElementAnnotatedAsRelation
19 | import javax.annotation.processing.ProcessingEnvironment
20 | import javax.annotation.processing.RoundEnvironment
21 | import javax.lang.model.element.Element
22 | import javax.lang.model.element.TypeElement
23 | import javax.lang.model.util.ElementFilter
24 |
25 | class RelationsDaoProcessor(private val processingEnv: ProcessingEnvironment) : AnnotatedClassProcessor() {
26 | override fun process(environment: RoundEnvironment?): List? {
27 | val javaFiles = ArrayList()
28 | environment?.getElementsAnnotatedWith(Entity::class.java)
29 | ?.forEach { element ->
30 | if (element.getAnnotation(Entity::class.java).generateRelations)
31 | javaFiles.addAll(processElementDaos(element))
32 | }
33 | return javaFiles
34 | }
35 |
36 | private fun processElementDaos(element: Element): List {
37 | val javaFiles = ArrayList()
38 | val fields = ElementFilter.fieldsIn(element.enclosedElements).filter {
39 | it.isElementAnnotatedAsRelation()
40 | }
41 | if (fields.isNotEmpty())
42 | javaFiles.addAll(RelationsDaoGenerator(processingEnv, element as TypeElement, fields).generate())
43 | return javaFiles
44 | }
45 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/TableRegisteredColumnsMethodGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler
15 |
16 | import com.squareup.javapoet.ClassName
17 | import com.squareup.javapoet.CodeBlock
18 | import com.squareup.javapoet.MethodSpec
19 | import com.squareup.javapoet.ParameterizedTypeName
20 | import com.squareup.javapoet.TypeName
21 | import com.squareup.javapoet.WildcardTypeName
22 | import org.jetbrains.annotations.NotNull
23 | import javax.lang.model.element.Modifier
24 |
25 | class TableRegisteredColumnsMethodGenerator(
26 | private val columns: List) : CodeGenerator {
27 | override fun generate(): MethodSpec {
28 | var stmt = "return List.fromArray("
29 | columns.forEachIndexed { index, s ->
30 | stmt += s
31 | if (index != columns.size - 1) stmt += ", "
32 | }
33 | stmt += ");"
34 | return MethodSpec.methodBuilder("getColumns")
35 | .returns(
36 | ParameterizedTypeName.get(ClassName.get("promise.commons.model", "List"),
37 | WildcardTypeName.subtypeOf(
38 | ParameterizedTypeName.get(ClassName.get("promise.db", "Column"),
39 | WildcardTypeName.subtypeOf(TypeName.OBJECT)
40 | )
41 | )
42 | )
43 | )
44 | .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
45 | .addAnnotation(Override::class.java)
46 | .addAnnotation(NotNull::class.java)
47 | .addCode(CodeBlock.of(stmt))
48 | .build()
49 | }
50 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/TypeConverterAnnotatedProcessor.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler
15 |
16 | import com.squareup.javapoet.ClassName
17 | import com.squareup.javapoet.JavaFile
18 | import promise.database.TypeConverter
19 | import promise.database.compiler.utils.LogUtil
20 | import promise.database.compiler.utils.Utils
21 | import java.util.*
22 | import javax.annotation.processing.ProcessingEnvironment
23 | import javax.annotation.processing.RoundEnvironment
24 | import javax.lang.model.element.TypeElement
25 |
26 | class TypeConverterAnnotatedProcessor(private val processingEnv: ProcessingEnvironment) : AnnotatedClassProcessor() {
27 |
28 | override fun process(environment: RoundEnvironment?): List? {
29 | val typeConverters = environment?.getElementsAnnotatedWith(TypeConverter::class.java)
30 | if (typeConverters != null) {
31 | if (typeConverters.size > 1)
32 | LogUtil.e(Exception("There can only be one typeConverter in the module"))
33 | else if (typeConverters.size == 1) try {
34 | typeConverter = typeConverters.first() as TypeElement
35 | return Collections.singletonList(processElement(typeConverter!!))
36 | } catch (e: Throwable) {
37 | LogUtil.e(e, typeConverter)
38 | }
39 | }
40 | return null
41 | }
42 |
43 | private fun processElement(element: TypeElement): JavaFile.Builder {
44 | val className = element.simpleName.toString()
45 | val pack = processingEnv.elementUtils.getPackageOf(element).toString()
46 | return Utils.generateInstanceProviderHolder(ClassName.get(pack, className))
47 | }
48 | ;
49 | companion object {
50 | var typeConverter: TypeElement? = null
51 | }
52 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/migration/DatabaseMetaData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.migration
15 |
16 | class DatabaseMetaData {
17 | var dbVersion: Int = 1
18 | var tableMetaData: List = emptyList()
19 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/migration/TableMetaData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.migration
15 |
16 | import com.fasterxml.jackson.annotation.JsonInclude
17 |
18 | class Field {
19 | var fieldName = ""
20 | var columnName = ""
21 | var nullable = true
22 | }
23 |
24 | class TableMetaData {
25 | var tableName: String = ""
26 | var fields: List = emptyList()
27 |
28 | @JsonInclude(JsonInclude.Include.NON_NULL)
29 | var migrations: List = emptyList()
30 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/migration/TableMigration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.migration
15 |
16 | import promise.database.MigrationOptions
17 |
18 | open class TableMigration {
19 | var versionChange: VersionChange? = null
20 | var field: String? = null
21 | var action: MigrationOptions? = null
22 |
23 | override fun equals(other: Any?): Boolean {
24 | if (javaClass != other?.javaClass) return false
25 | other as TableMigration
26 |
27 | if (versionChange != other.versionChange) return false
28 | if (field != other.field) return false
29 | if (action != other.action) return false
30 | return true
31 | }
32 |
33 | override fun hashCode(): Int {
34 | var result = versionChange?.hashCode() ?: 0
35 | result = 31 * result + (field?.hashCode() ?: 0)
36 | result = 31 * result + (action?.hashCode() ?: 0)
37 | return result
38 | }
39 | }
40 |
41 | class RenameColumnTableMigration : TableMigration() {
42 |
43 | var oldColumnName: String? = null
44 |
45 | init {
46 | super.action = MigrationOptions.RENAME_COLUMN
47 | }
48 |
49 | override fun equals(other: Any?): Boolean {
50 | if (this === other) return true
51 | if (javaClass != other?.javaClass) return false
52 | if (!super.equals(other)) return false
53 | other as RenameColumnTableMigration
54 | if (oldColumnName != other.oldColumnName) return false
55 | return true
56 | }
57 |
58 | override fun hashCode(): Int {
59 | var result = 0
60 | result = 31 * result + (oldColumnName?.hashCode() ?: 0)
61 | return result
62 | }
63 |
64 | }
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/migration/VersionChange.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.migration
15 |
16 | class VersionChange {
17 | var fromVersion: Int = 0
18 | var toVersion: Int = 0
19 | override fun equals(other: Any?): Boolean {
20 | if (this === other) return true
21 | if (javaClass != other?.javaClass) return false
22 | other as VersionChange
23 | if (fromVersion != other.fromVersion) return false
24 | if (toVersion != other.toVersion) return false
25 | return true
26 | }
27 |
28 | override fun hashCode(): Int {
29 | var result = fromVersion
30 | result = 31 * result + toVersion
31 | return result
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/Arrangeable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils;
15 |
16 | public class Arrangeable {
17 | private Value value;
18 | private Key key;
19 |
20 | Value value() {
21 | return value;
22 | }
23 |
24 | Arrangeable value(Value value) {
25 | this.value = value;
26 | return this;
27 | }
28 |
29 | Key key() {
30 | return key;
31 | }
32 |
33 | Arrangeable key(Key key) {
34 | this.key = key;
35 | return this;
36 | }
37 |
38 | @Override
39 | public boolean equals(Object o) {
40 | if (this == o) return true;
41 | if (o == null || getClass() != o.getClass()) return false;
42 | Arrangeable, ?> that = (Arrangeable, ?>) o;
43 | return value.equals(that.value) &&
44 | key.equals(that.key);
45 | }
46 |
47 | @Override
48 | public int hashCode() {
49 | return key.hashCode() + value.hashCode();
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/Category.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils;
15 |
16 | public class Category {
17 | private List extends T> list;
18 | private K name;
19 |
20 | Category(K name) {
21 | this.name = name;
22 | }
23 |
24 | public List extends T> list() {
25 | return list;
26 | }
27 |
28 | public Category list(List extends T> list) {
29 | this.list = list;
30 | return this;
31 | }
32 |
33 | public K name() {
34 | return name;
35 | }
36 |
37 | public Category name(K name) {
38 | this.name = name;
39 | return this;
40 | }
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/LogUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils;
15 |
16 | import java.util.Arrays;
17 |
18 | import javax.annotation.processing.ProcessingEnvironment;
19 | import javax.lang.model.element.Element;
20 | import javax.tools.Diagnostic;
21 |
22 | public class LogUtil {
23 |
24 | private static final String TAG = "PromiseDatabaseCompiler: ";
25 | private static ProcessingEnvironment processingEnv;
26 |
27 | private LogUtil() {
28 | //no instance
29 | }
30 |
31 | public static void initLogger(ProcessingEnvironment processingEnvironment) {
32 | LogUtil.processingEnv = processingEnvironment;
33 | }
34 |
35 | public static void w(Object... messages) {
36 | StringBuilder builder = new StringBuilder();
37 | builder.append(TAG);
38 | for (Object message : messages) {
39 | builder.append(message.toString());
40 | }
41 | processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, builder.toString());
42 | }
43 |
44 | public static void n(Object... messages) {
45 |
46 | StringBuilder builder = new StringBuilder();
47 |
48 | builder.append(TAG);
49 | for (Object message : messages) {
50 | builder.append(message.toString());
51 | }
52 | processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, builder.toString());
53 | }
54 |
55 | public static void e(Throwable t) {
56 | processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
57 | TAG + Utils.INSTANCE.getStackTraceString(t));
58 | }
59 |
60 | public static void eTrace(Throwable t) {
61 | processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
62 | TAG + Arrays.asList(t.getStackTrace()));
63 | }
64 |
65 | public static void e(Throwable t, Element element) {
66 | processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
67 | TAG + Utils.INSTANCE.getStackTraceString(t), element);
68 | }
69 |
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/BIConsumer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 | public interface BIConsumer {
17 | void accept(T t, U u);
18 | }
19 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/Combiner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 |
17 | public interface Combiner {
18 | T join(T t, K k);
19 | }
20 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/FilterFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 | public interface FilterFunction {
17 | boolean select(T t);
18 | }
19 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/FilterFunction2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 | public interface FilterFunction2 {
17 | K filterBy(U u);
18 |
19 | K getKey(T t);
20 | }
21 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/GroupFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 | public interface GroupFunction {
17 | K getKey(T t);
18 | }
19 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/GroupFunction2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 |
17 | import promise.database.compiler.utils.List;
18 |
19 | public interface GroupFunction2 {
20 | K getKey(T t);
21 |
22 | E get(K k);
23 |
24 | void apply(E e, List list);
25 | }
26 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/GroupFunction3.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 |
17 | import promise.database.compiler.utils.List;
18 |
19 | public interface GroupFunction3 {
20 | List group(List list);
21 | }
22 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/JoinFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 | public interface JoinFunction {
17 | boolean joinBy(T t, U u);
18 | }
19 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/MapFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 | public interface MapFunction {
17 | E from(T t);
18 | }
19 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/MapIndexFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 | public interface MapIndexFunction {
17 | E from(int index, T t);
18 | }
19 |
--------------------------------------------------------------------------------
/compiler/src/main/java/promise/database/compiler/utils/function/ReduceFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.compiler.utils.function;
15 |
16 |
17 | import promise.database.compiler.utils.List;
18 |
19 | public interface ReduceFunction {
20 | K reduce(List list);
21 | }
22 |
--------------------------------------------------------------------------------
/compiler/src/test/java/promise/database/ompiler/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.ompiler
15 |
16 | import org.junit.Assert.assertEquals
17 | import org.junit.Test
18 |
19 | /**
20 | * Example local unit test, which will execute on the development machine (host).
21 | *
22 | * See [testing documentation](http://d.android.com/tools/testing).
23 | */
24 | class ExampleUnitTest {
25 | @Test
26 | fun addition_isCorrect() {
27 | assertEquals(4, 2 + 2)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/compiler/src/test/java/promise/database/ompiler/PersistableEntityUtilsKtTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database.ompiler
15 |
16 | import org.junit.After
17 | import org.junit.Before
18 |
19 | class PersistableEntityUtilsKtTest {
20 |
21 | @Before
22 | fun setUp() {
23 | }
24 |
25 | @After
26 | fun tearDown() {
27 | }
28 | }
--------------------------------------------------------------------------------
/database/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/database/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | androidpromisedatabase
4 | Project androidpromisedatabase created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/database/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=..
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/database/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | apply plugin: 'com.android.library'
15 | apply plugin: 'kotlin-android'
16 | apply plugin: 'com.github.dcendents.android-maven'
17 |
18 | android {
19 | compileSdkVersion 29
20 |
21 | defaultConfig {
22 | minSdkVersion 17
23 | targetSdkVersion 29
24 | versionCode 1
25 | versionName "1.0"
26 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
27 | }
28 |
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 |
36 | compileOptions {
37 | sourceCompatibility = '1.8'
38 | targetCompatibility = '1.8'
39 | }
40 | }
41 |
42 | dependencies {
43 | //api 'com.github.android-promise.database:commons:1.0.3-alpha7'
44 | api project(path: ':commons')
45 | api 'androidx.sqlite:sqlite:2.1.0'
46 | implementation 'androidx.sqlite:sqlite-framework:2.1.0'
47 | compileOnly 'io.reactivex.rxjava2:rxjava:2.2.17'
48 | implementation 'androidx.core:core-ktx:1.3.2'
49 | compileOnly 'com.github.android-promise:commons:1.1-beta02'
50 | testImplementation 'junit:junit:4.13'
51 | androidTestImplementation 'androidx.test:runner:1.3.0'
52 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
53 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
54 | }
55 | repositories {
56 | mavenCentral()
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/database/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class tableName to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file tableName.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/database/src/androidTest/java/promise/database/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.database;
15 |
16 | import android.content.Context;
17 |
18 | import androidx.test.InstrumentationRegistry;
19 | import androidx.test.runner.AndroidJUnit4;
20 |
21 | import org.junit.Test;
22 | import org.junit.runner.RunWith;
23 |
24 | import static org.junit.Assert.assertEquals;
25 |
26 | /**
27 | * Instrumented test, which will execute on an Android device.
28 | *
29 | * @see Testing documentation
30 | */
31 | @RunWith(AndroidJUnit4.class)
32 | public class ExampleInstrumentedTest {
33 | @Test
34 | public void useAppContext() {
35 | // Context of the app under test.
36 | Context appContext = InstrumentationRegistry.getTargetContext();
37 |
38 | assertEquals("promise.promisedb.test", appContext.getPackageName());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/database/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/ActiveRecord.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db
15 |
16 | import android.os.Parcel
17 | import promise.commons.model.Identifiable
18 | import promise.commons.util.Conditions
19 | import promise.model.TimeStamped
20 |
21 | abstract class ActiveRecord>() : TimeStamped() {
22 |
23 | internal var table: FastTable? = null
24 |
25 | constructor(parcel: Parcel?) : this() {
26 | super.readFromParcel(parcel)
27 | }
28 |
29 | @Throws(Exception::class)
30 | fun save(): Long {
31 | Conditions.checkNotNull(table, "This record has not been read from the database and can't be saved")
32 | return table!!.save(getEntity())
33 | }
34 |
35 | @Throws(Exception::class)
36 | fun update(): Boolean {
37 | Conditions.checkNotNull(table, "This record has not been read from the database and can't be updated")
38 | return table!!.update(getEntity())
39 | }
40 |
41 | @Throws(Exception::class)
42 | fun delete(): Boolean {
43 | Conditions.checkNotNull(table, "This record has not been read from the database and can't be deleted")
44 | return table!!.delete(getEntity())
45 | }
46 |
47 | abstract fun getEntity(): T
48 | }
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/Corrupt.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db;
15 |
16 | import androidx.sqlite.db.SupportSQLiteDatabase;
17 |
18 | public interface Corrupt {
19 | void onCorrupt(SupportSQLiteDatabase database);
20 | }
21 |
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/Crud.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | package promise.db
14 |
15 | import promise.commons.model.Identifiable
16 | import promise.commons.model.List
17 | import promise.model.IdentifiableList
18 |
19 | interface Crud {
20 |
21 | fun > find(tableCrud: TableCrud): TableCrud.Extras
22 |
23 | fun > findAll(tableCrud: TableCrud): IdentifiableList
24 |
25 | fun > update(t: T, tableCrud: TableCrud, column: Column<*>): Boolean
26 |
27 | fun > update(t: T, tableCrud: TableCrud): Boolean
28 |
29 | fun > findAll(tableCrud: TableCrud, vararg columns: Column<*>): IdentifiableList
30 |
31 | fun delete(tableCrud: TableCrud<*, in X>, column: Column<*>): Boolean
32 |
33 | fun > delete(tableCrud: TableCrud, t: T): Boolean
34 |
35 | fun delete(tableCrud: TableCrud<*, in X>): Boolean
36 |
37 | fun delete(tableCrud: TableCrud<*, in X>, column: Column, list: List): Boolean
38 |
39 | fun > save(t: T, tableCrud: TableCrud): Long
40 |
41 | fun > save(list: IdentifiableList, tableCrud: TableCrud): Boolean
42 |
43 | fun deleteAll(): Boolean
44 |
45 | fun getLastId(tableCrud: TableCrud<*, in X>): Int
46 | }
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/DBError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db;
15 |
16 |
17 | public final class DBError extends Exception {
18 | DBError() {
19 | }
20 |
21 | DBError(String message) {
22 | super(message);
23 | }
24 |
25 | DBError(Throwable cause) {
26 | super(cause);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/DDLFunctions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db
15 |
16 | interface DDLFunctions {
17 | /**
18 | * creates the table in the database
19 | *
20 | * @param x the database instance
21 | * @return true if the table is created
22 | * @throws TableError if theirs an error creating the table
23 | */
24 | @Throws(TableError::class)
25 | fun onCreate(x: X): Boolean
26 |
27 | /**
28 | * upgraded the table from one version to the next
29 | *
30 | * @param x database instance
31 | * @param v1 last version of [X]
32 | * @param v2 next version of [X]
33 | * @throws TableError if theirs problem running the migration
34 | */
35 | @Throws(TableError::class)
36 | fun onUpgrade(x: X, v1: Int, v2: Int)
37 |
38 | /**
39 | * @param x
40 | * @return
41 | * @throws TableError
42 | */
43 | @Throws(TableError::class)
44 | fun onDrop(x: X): Boolean
45 | }
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/DMLFunctions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db
15 |
16 | import android.database.Cursor
17 | import io.reactivex.Maybe
18 | import io.reactivex.Single
19 | import promise.commons.model.Identifiable
20 | import promise.commons.model.List
21 | import promise.model.IdentifiableList
22 |
23 | interface DMLFunctions> {
24 |
25 | fun transact(block: FastTable.() -> Unit)
26 |
27 | fun querySql(sql: String): Cursor
28 |
29 | fun save(t: T): Long
30 |
31 | fun saveAsync(t: T): Single
32 |
33 | fun save(list: IdentifiableList): Boolean
34 |
35 | fun saveAsync(list: IdentifiableList): Single
36 |
37 | fun update(t: T): Boolean
38 |
39 | fun updateAsync(t: T): Maybe
40 |
41 | fun update(t: T, column: Column<*>): Boolean
42 |
43 | fun updateAsync(t: T, column: Column<*>): Maybe
44 |
45 | fun query(queryBuilder: QueryBuilder): Cursor
46 |
47 | fun queryAsync(queryBuilder: QueryBuilder): Single
48 |
49 | fun find(): TableCrud.Extras
50 |
51 | fun findById(idLong: Long): T?
52 |
53 | fun findOne(vararg columns: Column<*>): T?
54 |
55 | @Throws(TableError::class)
56 | fun findAsync(): ReactiveTable.Extras
57 |
58 | fun findAll(): IdentifiableList
59 |
60 | fun findAllAsync(): Maybe>
61 |
62 | fun findAll(vararg column: Column<*>): IdentifiableList
63 |
64 | fun findAllAsync(vararg column: Column<*>): Maybe>
65 |
66 | fun delete(column: Column<*>): Boolean
67 |
68 | fun deleteAsync(column: Column<*>): Maybe
69 |
70 | fun delete(t: T): Boolean
71 |
72 | fun deleteAsync(t: T): Maybe
73 |
74 | fun delete(column: Column, list: List): Boolean
75 |
76 | fun deleteAsync(column: Column, list: List): Maybe
77 |
78 | fun clear(): Boolean
79 |
80 | fun clearAsync(): Maybe
81 |
82 | val lastId: Int
83 |
84 | val lastIdAsync: Maybe
85 | }
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/Database.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db;
15 |
16 | import java.lang.annotation.ElementType;
17 | import java.lang.annotation.Retention;
18 | import java.lang.annotation.RetentionPolicy;
19 | import java.lang.annotation.Target;
20 |
21 | @Target(ElementType.TYPE)
22 | @Retention(RetentionPolicy.RUNTIME)
23 | public @interface Database {
24 | int version() default 1;
25 |
26 | Class extends FastTable>>[] tables() default {};
27 | }
28 |
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/DatabaseCreationCallback.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db
15 |
16 | import androidx.sqlite.db.SupportSQLiteDatabase
17 |
18 | interface DatabaseCreationCallback {
19 |
20 | fun beforeCreate(database: SupportSQLiteDatabase)
21 |
22 | fun afterCreate(database: SupportSQLiteDatabase)
23 |
24 | }
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/Migration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db
15 |
16 | import androidx.sqlite.db.SupportSQLiteDatabase
17 |
18 | interface Migration {
19 | fun onMigrate(database: FastDatabase,
20 | sqLiteDatabase: SupportSQLiteDatabase,
21 | oldVersion: Int,
22 | newVersion: Int)
23 | }
24 |
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/PromiseDatabase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | package promise.db
14 |
15 | import promise.commons.model.Identifiable
16 | import promise.utils.Visitor
17 |
18 | /**
19 | * Base class for classes annotated with DatabaseEntity
20 | */
21 | abstract class PromiseDatabase(private val fastDatabase: FastDatabase?) {
22 |
23 | /**
24 | * @return an instance of FastDatabase
25 | */
26 | val databaseInstance: FastDatabase
27 | get() {
28 | checkNotNull(fastDatabase) { "Database not initialized or created yet" }
29 | return fastDatabase
30 | }
31 |
32 | abstract fun > getEntityClassVisitor(): Visitor, FastTable>
33 |
34 | /**
35 | * returns the table associated with the entity class
36 | *
37 | * @param entityClass class of the entity persisted
38 | * @param entity
39 | * @return FastTable of the entity
40 | * @throws IllegalArgumentException if entity is not registered with the database
41 | */
42 | @Throws(IllegalArgumentException::class)
43 | fun > tableOf(entityClass: Class): FastTable {
44 | val t: Visitor, FastTable> = getEntityClassVisitor()
45 | return t.visit(entityClass)
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/ReactiveCrud.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | package promise.db
14 |
15 | import android.database.Cursor
16 | import io.reactivex.Maybe
17 | import io.reactivex.Single
18 | import promise.commons.model.Identifiable
19 | import promise.commons.model.List
20 | import promise.model.IdentifiableList
21 |
22 | interface ReactiveCrud : Crud {
23 |
24 | fun queryAsync(queryBuilder: QueryBuilder): Single
25 |
26 | @Throws(TableError::class)
27 | fun > readAsync(tableCrud: TableCrud): ReactiveTable.Extras
28 |
29 | fun > readAllAsync(tableCrud: TableCrud): Maybe>
30 |
31 | fun > readAllAsync(tableCrud: TableCrud, vararg column: Column<*>): Maybe>
32 |
33 | fun > updateAsync(t: T, tableCrud: TableCrud, column: Column<*>): Maybe
34 |
35 | fun > updateAsync(t: T, tableCrud: TableCrud): Maybe
36 |
37 | fun > deleteAsync(tableCrud: TableCrud, column: Column<*>): Maybe
38 |
39 | fun > deleteAsync(tableCrud: TableCrud, t: T): Maybe
40 |
41 | fun deleteAsync(tableCrud: TableCrud<*, in X>): Maybe
42 |
43 | fun deleteAsync(tableCrud: TableCrud<*, in X>, column: Column, list: List): Maybe
44 |
45 | fun > saveAsync(t: T, tableCrud: TableCrud): Single
46 |
47 | fun > saveAsync(list: IdentifiableList, tableCrud: TableCrud): Single
48 |
49 | fun deleteAllAsync(): Maybe
50 |
51 | fun > getLastIdAsync(tableCrud: TableCrud): Maybe
52 | }
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/TableError.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | package promise.db
14 |
15 |
16 | class TableError : Exception {
17 | internal constructor(cause: Throwable) : super(cause)
18 | internal constructor(cause: String) : super(cause)
19 | }
--------------------------------------------------------------------------------
/database/src/main/java/promise/db/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, Peter Vincent
3 | * Licensed under the Apache License, Version 2.0, Android Promise.
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | * Unless required by applicable law or agreed to in writing,
8 | * software distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 |
14 | package promise.db;
15 |
16 | import java.math.BigDecimal;
17 |
18 | import promise.commons.model.List;
19 | import promise.db.projection.Projection;
20 |
21 | public class Utils {
22 | public static final List