forked from rapidftr/RapidFTR-Android
-
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.
1237 | Subhas/Kavitha | Added both integration and unit tests for DAO
- Loading branch information
Subhas Dandapani
committed
Oct 29, 2012
1 parent
d8feacb
commit 2d1acf3
Showing
23 changed files
with
386 additions
and
194 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
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
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
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
25 changes: 25 additions & 0 deletions
25
RapidFTR-Android/src/main/java/com/rapidftr/database/FluentInsert.java
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,25 @@ | ||
package com.rapidftr.database; | ||
|
||
import android.content.ContentValues; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor(suppressConstructorProperties = true) | ||
public class FluentInsert { | ||
|
||
public interface Interface { | ||
public FluentInsert insert(); | ||
} | ||
|
||
protected ContentValues values; | ||
protected final DatabaseSession session; | ||
|
||
public FluentInsert set(String column, String value) { | ||
values.put(column, value); | ||
return this; | ||
} | ||
|
||
public long insertInto(String table) { | ||
return session.insert(table, null, values); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
RapidFTR-Android/src/main/java/com/rapidftr/database/FluentSelect.java
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,68 @@ | ||
package com.rapidftr.database; | ||
|
||
import android.database.Cursor; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor(suppressConstructorProperties = true) | ||
public class FluentSelect { | ||
|
||
public interface Interface { | ||
public FluentSelect select(); | ||
} | ||
|
||
protected String table; | ||
protected List<String> columns = new ArrayList<String>(); | ||
protected StringBuffer selection; | ||
protected List<String> selectionArgs = new ArrayList<String>(); | ||
protected StringBuffer orderBy; | ||
protected String limit; | ||
|
||
protected final DatabaseSession session; | ||
protected @Getter Cursor cursor; | ||
|
||
public FluentSelect from(String table) { | ||
this.table = table; | ||
return this; | ||
} | ||
|
||
public FluentSelect select(String column) { | ||
this.columns.add(column); | ||
return this; | ||
} | ||
|
||
public FluentSelect where(String criteria, String arg) { | ||
this.selection.append("(").append(criteria).append(")"); | ||
this.selectionArgs.add(arg); | ||
return this; | ||
} | ||
|
||
public FluentSelect and(String criteria, String arg) { | ||
this.selection.append(" AND "); | ||
return this.where(criteria, arg); | ||
} | ||
|
||
public FluentSelect or(String criteria, String arg) { | ||
this.selection.append(" OR "); | ||
return this.where(criteria, arg); | ||
} | ||
|
||
public FluentSelect orderBy(String orderBy, boolean asc) { | ||
this.orderBy.append(orderBy).append(asc ? " ASC" : " DESC"); | ||
return this; | ||
} | ||
|
||
public FluentSelect limit(String limit) { | ||
this.limit = limit; | ||
return this; | ||
} | ||
|
||
public FluentSelect execute() { | ||
this.cursor = session.query(table, columns.toArray(new String[columns.size()]), selection.toString(), selectionArgs.toArray(new String[selectionArgs.size()]), null, null, orderBy.toString(), limit); | ||
return this; | ||
} | ||
|
||
} |
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
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
6 changes: 3 additions & 3 deletions
6
RapidFTR-Android/src/main/java/com/rapidftr/forms/FormField.java
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
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
6 changes: 3 additions & 3 deletions
6
RapidFTR-Android/src/main/java/com/rapidftr/forms/HighlightInfo.java
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
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
Oops, something went wrong.