forked from openMF/android-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b412a2
commit cec92e8
Showing
31 changed files
with
1,109 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
core/data/src/main/java/com/mifos/core/data/model/client/Client.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* This project is licensed under the open source MPL V2. | ||
* See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
*/ | ||
package com.mifos.core.data.model.client | ||
|
||
import android.os.Parcelable | ||
import com.mifos.core.data.model.database.MifosBaseModel | ||
import com.mifos.core.data.model.database.MifosDatabase | ||
import com.raizlabs.android.dbflow.annotation.Column | ||
import com.raizlabs.android.dbflow.annotation.ForeignKey | ||
import com.raizlabs.android.dbflow.annotation.ModelContainer | ||
import com.raizlabs.android.dbflow.annotation.PrimaryKey | ||
import com.raizlabs.android.dbflow.annotation.Table | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* Created by ishankhanna on 08/02/14. | ||
*/ | ||
@Parcelize | ||
@Table(database = MifosDatabase::class, useBooleanGetterSetters = false) | ||
@ModelContainer | ||
data class Client( | ||
@PrimaryKey | ||
var id: Int = 0, | ||
|
||
@Column | ||
@Transient | ||
var groupId: Int? = 0, | ||
|
||
@Column | ||
var accountNo: String? = null, | ||
|
||
var clientId: Int? = null, | ||
|
||
@Column | ||
@ForeignKey(saveForeignKeyModel = true) | ||
var status: Status? = null, | ||
|
||
@Column | ||
@Transient | ||
var sync: Boolean = false, | ||
|
||
@Column | ||
var active: Boolean = false, | ||
|
||
@Column | ||
@ForeignKey(saveForeignKeyModel = true) | ||
var clientDate: ClientDate? = null, | ||
|
||
var activationDate: List<Int?> = ArrayList(), | ||
|
||
var dobDate: List<Int?> = ArrayList(), | ||
|
||
var groups: List<Group?> = ArrayList(), | ||
|
||
var mobileNo: String? = null, | ||
|
||
@Column | ||
var firstname: String? = null, | ||
|
||
@Column | ||
var middlename: String? = null, | ||
|
||
@Column | ||
var lastname: String? = null, | ||
|
||
@Column | ||
var displayName: String? = null, | ||
|
||
@Column | ||
var officeId: Int = 0, | ||
|
||
@Column | ||
var officeName: String? = null, | ||
|
||
@Column | ||
var staffId: Int = 0, | ||
|
||
@Column | ||
var staffName: String? = null, | ||
|
||
var timeline: Timeline? = null, | ||
|
||
@Column | ||
var fullname: String? = null, | ||
|
||
@Column | ||
var imageId: Int = 0, | ||
|
||
@Column | ||
var imagePresent: Boolean = false, | ||
|
||
@Column | ||
var externalId: String? = null | ||
) : MifosBaseModel(), Parcelable { | ||
|
||
/** | ||
* This method is returning the comma separated names of all the client's group | ||
* in the form of a string. | ||
*/ | ||
val groupNames: String | ||
get() { | ||
var groupNames = "" | ||
if (groups.isEmpty()) return "" | ||
for (group in groups) { | ||
groupNames += group!!.name + ", " | ||
} | ||
return groupNames.substring(0, groupNames.length - 2) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
core/data/src/main/java/com/mifos/core/data/model/client/ClientDate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.mifos.core.data.model.client | ||
|
||
import android.os.Parcelable | ||
import com.mifos.core.data.model.database.MifosBaseModel | ||
import com.mifos.core.data.model.database.MifosDatabase | ||
import com.raizlabs.android.dbflow.annotation.Column | ||
import com.raizlabs.android.dbflow.annotation.ModelContainer | ||
import com.raizlabs.android.dbflow.annotation.PrimaryKey | ||
import com.raizlabs.android.dbflow.annotation.Table | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* Created by Rajan Maurya on 04/07/16. | ||
*/ | ||
@Parcelize | ||
@Table(database = MifosDatabase::class) | ||
@ModelContainer | ||
data class ClientDate( | ||
@PrimaryKey | ||
var clientId: Long = 0, | ||
|
||
@PrimaryKey | ||
var chargeId: Long = 0, | ||
|
||
@Column | ||
var day: Int = 0, | ||
|
||
@Column | ||
var month: Int = 0, | ||
|
||
@Column | ||
var year: Int = 0 | ||
) : MifosBaseModel(), Parcelable |
77 changes: 77 additions & 0 deletions
77
core/data/src/main/java/com/mifos/core/data/model/client/Group.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* This project is licensed under the open source MPL V2. | ||
* See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
*/ | ||
package com.mifos.core.data.model.client | ||
|
||
import android.os.Parcelable | ||
import com.mifos.core.data.model.database.MifosBaseModel | ||
import com.mifos.core.data.model.database.MifosDatabase | ||
import com.raizlabs.android.dbflow.annotation.Column | ||
import com.raizlabs.android.dbflow.annotation.ForeignKey | ||
import com.raizlabs.android.dbflow.annotation.ModelContainer | ||
import com.raizlabs.android.dbflow.annotation.PrimaryKey | ||
import com.raizlabs.android.dbflow.annotation.Table | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* This is the Groups Model Table | ||
* Created by ishankhanna on 28/06/14. | ||
*/ | ||
@Parcelize | ||
@Table(database = MifosDatabase::class, useBooleanGetterSetters = false) | ||
@ModelContainer | ||
data class Group( | ||
@PrimaryKey | ||
var id: Int? = null, | ||
|
||
@Column | ||
var accountNo: String? = null, | ||
|
||
@Column | ||
@Transient | ||
var sync: Boolean = false, | ||
|
||
@Column | ||
var name: String? = null, | ||
|
||
var status: Status? = null, | ||
|
||
@Column | ||
var active: Boolean? = null, | ||
|
||
@Column | ||
@ForeignKey(saveForeignKeyModel = true) | ||
@Transient | ||
var groupDate: GroupDate? = null, | ||
|
||
var activationDate: List<Int> = ArrayList(), | ||
|
||
@Column | ||
var officeId: Int? = null, | ||
|
||
@Column | ||
var officeName: String? = null, | ||
|
||
@Column | ||
var centerId: Int? = 0, | ||
|
||
@Column | ||
var centerName: String? = null, | ||
|
||
@Column | ||
var staffId: Int? = null, | ||
|
||
@Column | ||
var staffName: String? = null, | ||
|
||
@Column | ||
var hierarchy: String? = null, | ||
|
||
@Column | ||
var groupLevel: Int = 0, | ||
|
||
var timeline: Timeline? = null, | ||
|
||
var externalId: String? = null | ||
) : MifosBaseModel(), Parcelable |
33 changes: 33 additions & 0 deletions
33
core/data/src/main/java/com/mifos/core/data/model/client/GroupDate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.mifos.core.data.model.client | ||
|
||
import android.os.Parcelable | ||
import com.mifos.core.data.model.database.MifosBaseModel | ||
import com.mifos.core.data.model.database.MifosDatabase | ||
import com.raizlabs.android.dbflow.annotation.Column | ||
import com.raizlabs.android.dbflow.annotation.ModelContainer | ||
import com.raizlabs.android.dbflow.annotation.PrimaryKey | ||
import com.raizlabs.android.dbflow.annotation.Table | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* Created by Rajan Maurya on 18/09/16. | ||
*/ | ||
@Parcelize | ||
@Table(database = MifosDatabase::class) | ||
@ModelContainer | ||
data class GroupDate( | ||
@PrimaryKey | ||
var groupId: Long = 0, | ||
|
||
@PrimaryKey | ||
var chargeId: Long = 0, | ||
|
||
@Column | ||
var day: Int = 0, | ||
|
||
@Column | ||
var month: Int = 0, | ||
|
||
@Column | ||
var year: Int = 0 | ||
) : MifosBaseModel(), Parcelable |
41 changes: 41 additions & 0 deletions
41
core/data/src/main/java/com/mifos/core/data/model/client/Status.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* This project is licensed under the open source MPL V2. | ||
* See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
*/ | ||
package com.mifos.core.data.model.client | ||
|
||
import android.os.Parcelable | ||
import com.mifos.core.data.model.database.MifosBaseModel | ||
import com.mifos.core.data.model.database.MifosDatabase | ||
import com.raizlabs.android.dbflow.annotation.Column | ||
import com.raizlabs.android.dbflow.annotation.PrimaryKey | ||
import com.raizlabs.android.dbflow.annotation.Table | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* This Model is the common for Client and Group. So we can use it in both client and group | ||
* database. | ||
* Created by ishankhanna on 09/02/14. | ||
*/ | ||
@Parcelize | ||
@Table(database = MifosDatabase::class) | ||
data class Status( | ||
@PrimaryKey | ||
var id: Int = 0, | ||
|
||
@Column | ||
var code: String? = null, | ||
|
||
@Column | ||
var value: String? = null, | ||
) : MifosBaseModel(), Parcelable { | ||
|
||
|
||
companion object { | ||
private val STATUS_ACTIVE = "Active" | ||
|
||
fun isActive(value: String): Boolean { | ||
return value == STATUS_ACTIVE | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
core/data/src/main/java/com/mifos/core/data/model/client/Timeline.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* This project is licensed under the open source MPL V2. | ||
* See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
*/ | ||
package com.mifos.core.data.model.client | ||
|
||
import android.os.Parcelable | ||
import com.mifos.core.data.model.database.MifosBaseModel | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* Created by ishankhanna on 09/02/14. | ||
*/ | ||
@Parcelize | ||
class Timeline( | ||
var submittedOnDate: MutableList<Int> = ArrayList(), | ||
|
||
var submittedByUsername: String? = null, | ||
|
||
var submittedByFirstname: String? = null, | ||
|
||
var submittedByLastname: String? = null, | ||
|
||
var activatedOnDate: MutableList<Int> = ArrayList(), | ||
|
||
var activatedByUsername: String? = null, | ||
|
||
var activatedByFirstname: String? = null, | ||
|
||
var activatedByLastname: String? = null, | ||
|
||
var closedOnDate: MutableList<Int> = ArrayList(), | ||
|
||
var closedByUsername: String? = null, | ||
|
||
var closedByFirstname: String? = null, | ||
|
||
var closedByLastname: String? = null | ||
) : MifosBaseModel(), Parcelable |
13 changes: 13 additions & 0 deletions
13
core/data/src/main/java/com/mifos/core/data/model/database/MifosBaseModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.mifos.core.data.model.database | ||
|
||
import com.google.gson.Gson | ||
import com.raizlabs.android.dbflow.structure.BaseModel | ||
|
||
/** | ||
* Created by Rajan Maurya on 23/06/16. | ||
*/ | ||
open class MifosBaseModel : BaseModel() { | ||
override fun toString(): String { | ||
return Gson().toJson(this) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
core/data/src/main/java/com/mifos/core/data/model/database/MifosDatabase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.mifos.core.data.model.database | ||
|
||
import com.raizlabs.android.dbflow.annotation.Database | ||
|
||
/** | ||
* Created by Rajan Maurya on 23/06/16. | ||
*/ | ||
@Database(name = MifosDatabase.NAME, version = MifosDatabase.VERSION, foreignKeysSupported = true) | ||
object MifosDatabase { | ||
// database name will be Mifos.db | ||
const val NAME = "Mifos" | ||
|
||
//Always Increase the Version Number | ||
const val VERSION = 2 | ||
} |
Oops, something went wrong.