-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify tables to enable for tracking of last sent data
Fixes #6
- Loading branch information
Showing
7 changed files
with
78 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,44 +3,47 @@ | |
import android.arch.persistence.room.ColumnInfo; | ||
import android.arch.persistence.room.Entity; | ||
import android.arch.persistence.room.PrimaryKey; | ||
import android.support.annotation.NonNull; | ||
|
||
/** | ||
* Created by Ephraim Kigamba - [email protected] on 26/03/2019 | ||
*/ | ||
|
||
@Entity(tableName = "p2p_received_history") | ||
@Entity(tableName = "p2p_received_history", primaryKeys = {"entity_type", "sending_device_id"}) | ||
public class P2pReceivedHistory { | ||
|
||
@PrimaryKey | ||
private int id; | ||
|
||
@NonNull | ||
@ColumnInfo(name = "sending_device_id") | ||
private int sendingDeviceId; | ||
private String sendingDeviceId; | ||
|
||
@NonNull | ||
@ColumnInfo(name = "entity_type") | ||
private String entityType; | ||
|
||
@ColumnInfo(name = "entity_name") | ||
private String entityName; | ||
@ColumnInfo(name = "last_record_id") | ||
private long lastRecordId; | ||
|
||
public int getId() { | ||
return id; | ||
public String getSendingDeviceId() { | ||
return sendingDeviceId; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
public void setSendingDeviceId(String sendingDeviceId) { | ||
this.sendingDeviceId = sendingDeviceId; | ||
} | ||
|
||
public int getSendingDeviceId() { | ||
return sendingDeviceId; | ||
public String getEntityType() { | ||
return entityType; | ||
} | ||
|
||
public void setSendingDeviceId(int sendingDeviceId) { | ||
this.sendingDeviceId = sendingDeviceId; | ||
public void setEntityType(String entityType) { | ||
this.entityType = entityType; | ||
} | ||
|
||
public String getEntityName() { | ||
return entityName; | ||
public long getLastRecordId() { | ||
return lastRecordId; | ||
} | ||
|
||
public void setEntityName(String entityName) { | ||
this.entityName = entityName; | ||
public void setLastRecordId(long lastRecordId) { | ||
this.lastRecordId = lastRecordId; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,36 +3,29 @@ | |
import android.arch.persistence.room.ColumnInfo; | ||
import android.arch.persistence.room.Entity; | ||
import android.arch.persistence.room.PrimaryKey; | ||
import android.support.annotation.NonNull; | ||
|
||
/** | ||
* Created by Ephraim Kigamba - [email protected] on 26/03/2019 | ||
*/ | ||
@Entity(tableName = "sending_devices") | ||
public class SendingDevice { | ||
|
||
@PrimaryKey(autoGenerate = true) | ||
private int id; | ||
|
||
@ColumnInfo(name = "device_unique_id", index = true) | ||
private String deviceUniqueId; | ||
@NonNull | ||
@PrimaryKey | ||
@ColumnInfo(name = "device_id") | ||
private String deviceId; | ||
|
||
@NonNull | ||
@ColumnInfo(name = "app_lifetime_key") | ||
private String appLifetimeKey; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getDeviceUniqueId() { | ||
return deviceUniqueId; | ||
public String getDeviceId() { | ||
return deviceId; | ||
} | ||
|
||
public void setDeviceUniqueId(String deviceUniqueId) { | ||
this.deviceUniqueId = deviceUniqueId; | ||
public void setDeviceId(String deviceId) { | ||
this.deviceId = deviceId; | ||
} | ||
|
||
public String getAppLifetimeKey() { | ||
|
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package org.smartregister.p2p.model.dao; | ||
|
||
import android.arch.persistence.room.Dao; | ||
import android.arch.persistence.room.Insert; | ||
import android.arch.persistence.room.Query; | ||
import android.arch.persistence.room.Update; | ||
import android.support.annotation.NonNull; | ||
|
||
import org.smartregister.p2p.model.P2pReceivedHistory; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Ephraim Kigamba - [email protected] on 26/03/2019 | ||
|
@@ -10,6 +17,15 @@ | |
@Dao | ||
public interface P2pReceivedHistoryDao { | ||
|
||
@Insert | ||
void addReceivedHistory(@NonNull P2pReceivedHistory receivedHistory); | ||
|
||
@Update | ||
void updateReceivedHistory(@NonNull P2pReceivedHistory receivedHistory); | ||
|
||
@Query("DELETE FROM p2p_received_history WHERE sending_device_id = :sendingDeviceId") | ||
int clearDeviceRecords(int sendingDeviceId); | ||
int clearDeviceRecords(@NonNull String sendingDeviceId); | ||
|
||
@Query("SELECT * FROM p2p_received_history WHERE sending_device_id = :sendingDeviceId") | ||
List<P2pReceivedHistory> getDeviceReceivedHistory(@NonNull String sendingDeviceId); | ||
} |
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