Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCS-1329 | dbflow removal #125

Open
wants to merge 1 commit into
base: SCS-1329
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ dependencies {
compile fileTree(dir: 'src/main/libs', include: ['*.jar'])

//DBFlow dependencies
annotationProcessor "com.github.raizlabs.dbflow:dbflow-processor:$rootProject.raizLabsDBFlow"
//apt "com.github.raizlabs.dbflow:dbflow-processor:$rootProject.raizLabsDBFlow"
compile "com.github.raizlabs.dbflow:dbflow-core:$rootProject.raizLabsDBFlow"
compile "com.github.raizlabs.dbflow:dbflow:$rootProject.raizLabsDBFlow"

// App's Support dependencies, including test
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/mifos/api/local/MifosBaseModel.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mifos.api.local;

import com.google.gson.Gson;
import com.raizlabs.android.dbflow.structure.BaseModel;


/**
* Created by Rajan Maurya on 23/06/16.
*/
public class MifosBaseModel extends BaseModel {
public class MifosBaseModel {

@Override
public String toString() {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/mifos/api/local/MifosDatabase.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.mifos.api.local;

import com.raizlabs.android.dbflow.annotation.Database;

/**
* Created by Rajan Maurya on 23/06/16.
*/
@Database(name = MifosDatabase.NAME, version = MifosDatabase.VERSION)
public class MifosDatabase {

// database name will be Mifos.db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.mifos.objects.client.Page;
import com.mifos.objects.group.Center;
import com.raizlabs.android.dbflow.sql.language.SQLite;

import javax.inject.Inject;
import javax.inject.Singleton;
Expand Down Expand Up @@ -34,15 +33,6 @@ public DatabaseHelperCenter() {
*/
@Nullable
public Observable<Void> saveAllCenters(final Page<Center> centerPage) {
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
@Override
public void run() {

for (Center center : centerPage.getPageItems()) {
center.save();
}
}
});
return null;
}

Expand All @@ -54,18 +44,7 @@ public void run() {
//TODO Implement Observable Transaction to load Center List
public Observable<Page<Center>> readAllCenters() {

return Observable.create(new Observable.OnSubscribe<Page<Center>>() {
@Override
public void call(Subscriber<? super Page<Center>> subscriber) {

Page<Center> centerPage = new Page<>();
centerPage.setPageItems(SQLite.select()
.from(Center.class)
.queryList());
subscriber.onNext(centerPage);
subscriber.onCompleted();
}
});
return null;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import android.os.AsyncTask;

import com.mifos.objects.client.Charges;
import com.mifos.objects.client.Charges_Table;
import com.mifos.objects.client.ClientDate;
import com.mifos.objects.client.Page;
import com.raizlabs.android.dbflow.sql.language.SQLite;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -51,7 +49,6 @@ public void run() {
charges.getDueDate().get(1),
charges.getDueDate().get(0));
charges.setChargeDueDate(clientDate);
charges.save();
}
}
});
Expand All @@ -67,30 +64,7 @@ public void run() {
* @return Page of Charges
*/
public Observable<Page<Charges>> readClientCharges(final int clientId) {
return Observable.create(new Observable.OnSubscribe<Page<Charges>>() {
@Override
public void call(Subscriber<? super Page<Charges>> subscriber) {

//Loading All charges from Charges_Table as reference to client id
List<Charges> chargesList = SQLite.select()
.from(Charges.class)
.where(Charges_Table.clientId.eq(clientId))
.queryList();

//Setting the Charge Due Date
for (int i = 0; i < chargesList.size(); i++) {
chargesList.get(i).setDueDate(Arrays.asList(
chargesList.get(i).getChargeDueDate().getYear(),
chargesList.get(i).getChargeDueDate().getMonth(),
chargesList.get(i).getChargeDueDate().getDay()));
}

Page<Charges> chargePage = new Page<Charges>();
chargePage.setPageItems(chargesList);
subscriber.onNext(chargePage);

}
});
return Observable.just(null);

}

Expand Down
Loading