This repository has been archived by the owner on Apr 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from lakshyagupta21/SHARE_81
Added UUID to forms so that forms can be identified uniquely
- Loading branch information
Showing
20 changed files
with
640 additions
and
74 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
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
87 changes: 87 additions & 0 deletions
87
share_app/src/main/java/org/odk/share/dao/InstanceMapDao.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,87 @@ | ||
package org.odk.share.dao; | ||
|
||
import android.content.ContentValues; | ||
import android.database.Cursor; | ||
|
||
import org.odk.share.application.Share; | ||
|
||
import java.util.HashMap; | ||
|
||
import timber.log.Timber; | ||
|
||
import static org.odk.share.dto.InstanceMap.INSTANCE_ID; | ||
import static org.odk.share.dto.InstanceMap.INSTANCE_UUID; | ||
import static org.odk.share.provider.InstanceMapProvider.CONTENT_URI; | ||
|
||
|
||
/** | ||
* Created by laksh on 8/2/2018. | ||
*/ | ||
|
||
public class InstanceMapDao { | ||
|
||
public int updateInstance(ContentValues values, String where, String[] whereArgs) { | ||
return Share.getInstance().getContentResolver().update(CONTENT_URI, values, where, whereArgs); | ||
} | ||
|
||
public HashMap<Long, String> getInstanceMap() { | ||
Cursor cursor = getInstancesCursor(null, null, null, null); | ||
|
||
HashMap<Long, String> instanceMap = new HashMap<>(); | ||
if (cursor != null) { | ||
Timber.d("CUrsor " + cursor.getCount()); | ||
try { | ||
while (cursor.moveToNext()) { | ||
long instanceId = cursor.getLong(cursor.getColumnIndex(INSTANCE_ID)); | ||
String uuid = cursor.getString(cursor.getColumnIndex(INSTANCE_UUID)); | ||
instanceMap.put(instanceId, uuid); | ||
} | ||
} finally { | ||
cursor.close(); | ||
} | ||
} | ||
return instanceMap; | ||
} | ||
|
||
public HashMap<String, Long> getInstanceUUIDMap() { | ||
Cursor cursor = getInstancesCursor(null, null, null, null); | ||
|
||
HashMap<String, Long> instanceMap = new HashMap<>(); | ||
if (cursor != null) { | ||
try { | ||
while (cursor.moveToNext()) { | ||
long instanceId = cursor.getLong(cursor.getColumnIndex(INSTANCE_ID)); | ||
String uuid = cursor.getString(cursor.getColumnIndex(INSTANCE_UUID)); | ||
instanceMap.put(uuid, instanceId); | ||
} | ||
} finally { | ||
cursor.close(); | ||
} | ||
} | ||
return instanceMap; | ||
} | ||
|
||
public Cursor getInstancesCursor(String[] projection, String selection, String[] selectionArgs, String sortOrder) { | ||
return Share.getInstance().getContentResolver() | ||
.query(CONTENT_URI, projection, selection, selectionArgs, sortOrder); | ||
} | ||
|
||
public long getInstanceId(String uuid) { | ||
String selection = INSTANCE_UUID + "=?"; | ||
String[] selectionArgs = {uuid}; | ||
|
||
Cursor cursor = getInstancesCursor(null, selection, selectionArgs, null); | ||
long id = -1; | ||
|
||
if (cursor != null) { | ||
try { | ||
if (cursor.moveToNext()) { | ||
id = cursor.getLong(cursor.getColumnIndex(INSTANCE_ID)); | ||
} | ||
} finally { | ||
cursor.close(); | ||
} | ||
} | ||
return id; | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
share_app/src/main/java/org/odk/share/dto/InstanceMap.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,39 @@ | ||
package org.odk.share.dto; | ||
|
||
/** | ||
* Created by laksh on 8/2/2018. | ||
*/ | ||
|
||
public class InstanceMap { | ||
public static final String INSTANCE_UUID = "instance_uuid"; | ||
public static final String ID = "_id"; | ||
public static final String INSTANCE_ID = "instanceId"; | ||
|
||
long id; | ||
String uuid; | ||
long transferId; | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getUuid() { | ||
return uuid; | ||
} | ||
|
||
public void setUuid(String uuid) { | ||
this.uuid = uuid; | ||
} | ||
|
||
public long getTransferId() { | ||
return transferId; | ||
} | ||
|
||
public void setTransferId(long transferId) { | ||
this.transferId = transferId; | ||
} | ||
} |
Oops, something went wrong.