Skip to content

Commit

Permalink
Merge branch 'master' into translations_strings-xml--master_pt
Browse files Browse the repository at this point in the history
# Conflicts:
#	opensrp-immunization/src/main/res/values-pt/strings.xml
  • Loading branch information
hamza-vd committed Jan 7, 2021
2 parents 3b4e208 + 57d1703 commit 55ee520
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 28 deletions.
8 changes: 8 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[main]
host = https://www.transifex.com

[opensrp-client-immunization.strings-xml--master]
file_filter = opensrp-immunization/src/main/res/values-<lang>/strings.xml
source_file = opensrp-immunization/src/main/res/values/strings.xml
source_lang = en
type = ANDROID
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=3.0.1-SNAPSHOT
VERSION_NAME=3.0.3-SNAPSHOT
VERSION_CODE=2
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Immunization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ServiceRecord {
private String team;
private String teamId;
private String childLocationId;
private Integer isVoided;

public ServiceRecord() {
}
Expand Down Expand Up @@ -213,4 +214,12 @@ public String getChildLocationId() {
public void setChildLocationId(String childLocationId) {
this.childLocationId = childLocationId;
}

public Integer getIsVoided() {
return isVoided;
}

public void setIsVoided(Integer isVoided) {
this.isVoided = isVoided;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Vaccine {
private Long updatedAt;
private String eventId;
private String formSubmissionId;
private Integer isVoided;
private Integer outOfCatchment;
private Date createdAt;

Expand Down Expand Up @@ -53,7 +54,7 @@ public Vaccine(Long id, String baseEntityId, String name, Integer calculation, D
public Vaccine(Long id, String baseEntityId, String programClientId, String name, Integer
calculation, Date date, String anmId, String locationId, String syncStatus, String
hia2Status, Long updatedAt, String eventId, String formSubmissionId, Integer
outOfCatchment, Date createdAt) {
outOfCatchment, Date createdAt, Integer isVoided) {
this.id = id;
this.baseEntityId = baseEntityId;
this.programClientId = programClientId;
Expand All @@ -69,6 +70,7 @@ public Vaccine(Long id, String baseEntityId, String programClientId, String name
this.formSubmissionId = formSubmissionId;
this.outOfCatchment = outOfCatchment;
this.createdAt = createdAt;
this.isVoided = isVoided;
}

public Long getId() {
Expand Down Expand Up @@ -104,6 +106,14 @@ public HashMap<String, String> getIdentifiers() {
return identifiers;
}

public Integer getIsVoided() {
return isVoided;
}

public void setIsVoided(Integer isVoided) {
this.isVoided = isVoided;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class RecurringServiceRecordRepository extends BaseRepository {
private static final String BASE_ENTITY_ID_INDEX = "CREATE INDEX " + TABLE_NAME + "_" + BASE_ENTITY_ID + "_index ON " + TABLE_NAME + "(" + BASE_ENTITY_ID + " COLLATE NOCASE);";
private static final String UPDATED_AT_INDEX = "CREATE INDEX " + TABLE_NAME + "_" + UPDATED_AT_COLUMN + "_index ON " + TABLE_NAME + "(" + UPDATED_AT_COLUMN + ");";
public static final String UPDATE_TABLE_ADD_OUT_OF_AREA_COL = "ALTER TABLE " + TABLE_NAME + " ADD COLUMN " + VaccineRepository.OUT_OF_AREA + " INTEGER;";
public static final String UPDATE_TABLE_ADD_IS_VOIDED_COL = "ALTER TABLE " + TABLE_NAME + " ADD COLUMN " + VaccineRepository.IS_VOIDED + " INTEGER;";

public static void createTable(SQLiteDatabase database) {
database.execSQL(CREATE_TABLE_SQL);
Expand All @@ -59,6 +60,7 @@ public static void createTable(SQLiteDatabase database) {
database.execSQL(FORMSUBMISSION_INDEX);
database.execSQL(UPDATED_AT_INDEX);
database.execSQL(UPDATE_TABLE_ADD_OUT_OF_AREA_COL);
database.execSQL(UPDATE_TABLE_ADD_IS_VOIDED_COL);
}

public static void migrateCreatedAt(SQLiteDatabase database) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ public class VaccineRepository extends BaseRepository {
public static final String HIA2_STATUS = "hia2_status";
public static final String UPDATED_AT_COLUMN = "updated_at";
public static final String OUT_OF_AREA = "out_of_area";
public static final String IS_VOIDED = "is_voided";
public static final String CREATED_AT = "created_at";
public static final String TEAM_ID = "team_id";
public static final String TEAM = "team";
public static final String[] VACCINE_TABLE_COLUMNS = {ID_COLUMN, BASE_ENTITY_ID, PROGRAM_CLIENT_ID, NAME, CALCULATION, DATE, ANMID, LOCATION_ID, CHILD_LOCATION_ID, TEAM, TEAM_ID, SYNC_STATUS, HIA2_STATUS, UPDATED_AT_COLUMN, EVENT_ID, FORMSUBMISSION_ID, OUT_OF_AREA, CREATED_AT};
public static final String[] VACCINE_TABLE_COLUMNS = {ID_COLUMN, BASE_ENTITY_ID, PROGRAM_CLIENT_ID, NAME, CALCULATION, DATE, ANMID, LOCATION_ID, CHILD_LOCATION_ID, TEAM, TEAM_ID, SYNC_STATUS, HIA2_STATUS, UPDATED_AT_COLUMN, EVENT_ID, FORMSUBMISSION_ID, OUT_OF_AREA, IS_VOIDED, CREATED_AT};
public static final String UPDATE_TABLE_ADD_EVENT_ID_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + EVENT_ID + " VARCHAR;";
public static final String EVENT_ID_INDEX = "CREATE INDEX " + VACCINE_TABLE_NAME + "_" + EVENT_ID + "_index ON " + VACCINE_TABLE_NAME + "(" + EVENT_ID + " COLLATE NOCASE);";
public static final String UPDATE_TABLE_ADD_FORMSUBMISSION_ID_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + FORMSUBMISSION_ID + " VARCHAR;";
public static final String FORMSUBMISSION_INDEX = "CREATE INDEX " + VACCINE_TABLE_NAME + "_" + FORMSUBMISSION_ID + "_index ON " + VACCINE_TABLE_NAME + "(" + FORMSUBMISSION_ID + " COLLATE NOCASE);";
public static final String UPDATE_TABLE_ADD_OUT_OF_AREA_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + OUT_OF_AREA + " INTEGER;";
public static final String UPDATE_TABLE_ADD_IS_VOIDED_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + IS_VOIDED + " INTEGER;";
public static final String UPDATE_TABLE_ADD_OUT_OF_AREA_COL_INDEX = "CREATE INDEX " + VACCINE_TABLE_NAME + "_" + OUT_OF_AREA + "_index ON " + VACCINE_TABLE_NAME + "(" + OUT_OF_AREA + " COLLATE NOCASE);";
public static final String UPDATE_TABLE_ADD_IS_VOIDED_COL_INDEX = "CREATE INDEX " + VACCINE_TABLE_NAME + "_" + IS_VOIDED + "_index ON " + VACCINE_TABLE_NAME + "(" + IS_VOIDED + " COLLATE NOCASE);";
public static final String UPDATE_TABLE_ADD_HIA2_STATUS_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + HIA2_STATUS + " VARCHAR;";
public static final String ALTER_ADD_CREATED_AT_COLUMN = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + CREATED_AT + " DATETIME NULL ";
public static final String UPDATE_TABLE_ADD_TEAM_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + TEAM + " VARCHAR;";
Expand Down Expand Up @@ -157,7 +160,7 @@ public void update(SQLiteDatabase database, Vaccine vaccine) {
try {
String idSelection = ID_COLUMN + " = ?";
database.update(VACCINE_TABLE_NAME, createValuesFor(vaccine), idSelection,
new String[] {vaccine.getId().toString()});
new String[]{vaccine.getId().toString()});
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
Expand All @@ -182,6 +185,7 @@ private ContentValues createValuesFor(Vaccine vaccine) {
values.put(EVENT_ID, vaccine.getEventId());
values.put(FORMSUBMISSION_ID, vaccine.getFormSubmissionId());
values.put(OUT_OF_AREA, vaccine.getOutOfCatchment());
values.put(IS_VOIDED, vaccine.getIsVoided());
values.put(CREATED_AT,
vaccine.getCreatedAt() != null ? EventClientRepository.dateFormat.format(vaccine.getCreatedAt()) : null);
return values;
Expand All @@ -204,7 +208,7 @@ public List<Vaccine> findUnSyncedBeforeTime(int minutes) {
Long time = calendar.getTimeInMillis();

cursor = getReadableDatabase().query(VACCINE_TABLE_NAME, VACCINE_TABLE_COLUMNS,
UPDATED_AT_COLUMN + " < ? AND " + SYNC_STATUS + " = ? ", new String[] {time.toString(), TYPE_Unsynced},
UPDATED_AT_COLUMN + " < ? AND " + SYNC_STATUS + " = ? ", new String[]{time.toString(), TYPE_Unsynced},
null, null, null, null);
vaccines = readAllVaccines(cursor);
} catch (Exception e) {
Expand All @@ -223,7 +227,7 @@ public List<Vaccine> findUnSynced() {
try {

cursor = getReadableDatabase().query(VACCINE_TABLE_NAME, VACCINE_TABLE_COLUMNS,
SYNC_STATUS + " = ? ", new String[] {TYPE_Unsynced},
SYNC_STATUS + " = ? ", new String[]{TYPE_Unsynced},
null, null, null, null);
vaccines = readAllVaccines(cursor);
} catch (Exception e) {
Expand Down Expand Up @@ -271,7 +275,8 @@ public List<Vaccine> readAllVaccines(Cursor cursor) {
cursor.getString(cursor.getColumnIndex(EVENT_ID)),
cursor.getString(cursor.getColumnIndex(FORMSUBMISSION_ID)),
cursor.getInt(cursor.getColumnIndex(OUT_OF_AREA)),
createdAt
createdAt,
cursor.getInt(cursor.getColumnIndex(IS_VOIDED))
);

vaccine.setTeam(cursor.getString(cursor.getColumnIndex(TEAM)));
Expand Down Expand Up @@ -301,7 +306,7 @@ public static String removeHyphen(String s) {
public List<Vaccine> findByEntityId(String entityId) {
SQLiteDatabase database = getReadableDatabase();
Cursor cursor = database.query(VACCINE_TABLE_NAME, VACCINE_TABLE_COLUMNS,
BASE_ENTITY_ID + " = ? " + COLLATE_NOCASE + " ORDER BY " + UPDATED_AT_COLUMN, new String[] {entityId}, null,
BASE_ENTITY_ID + " = ? " + COLLATE_NOCASE + " ORDER BY " + UPDATED_AT_COLUMN, new String[]{entityId}, null,
null, null, null);
return readAllVaccines(cursor);
}
Expand All @@ -310,7 +315,7 @@ public List<Vaccine> findLatestTwentyFourHoursByEntityId(String entityId) {
SQLiteDatabase database = getReadableDatabase();
Cursor cursor = database.query(VACCINE_TABLE_NAME, VACCINE_TABLE_COLUMNS,
BASE_ENTITY_ID + " = ? and (" + UPDATED_AT_COLUMN + "/1000 < strftime('%s',datetime('now','-1 day')))",
new String[] {entityId}, null, null, null, null);
new String[]{entityId}, null, null, null, null);
return readAllVaccines(cursor);
}

Expand All @@ -329,13 +334,13 @@ public Vaccine findUnique(SQLiteDatabase database, Vaccine vaccine) {
String[] selectionArgs = null;
if (StringUtils.isNotBlank(vaccine.getFormSubmissionId()) && StringUtils.isNotBlank(vaccine.getEventId())) {
selection = FORMSUBMISSION_ID + " = ? " + COLLATE_NOCASE + " OR " + EVENT_ID + " = ? " + COLLATE_NOCASE;
selectionArgs = new String[] {vaccine.getFormSubmissionId(), vaccine.getEventId()};
selectionArgs = new String[]{vaccine.getFormSubmissionId(), vaccine.getEventId()};
} else if (StringUtils.isNotBlank(vaccine.getEventId())) {
selection = EVENT_ID + " = ? " + COLLATE_NOCASE;
selectionArgs = new String[] {vaccine.getEventId()};
selectionArgs = new String[]{vaccine.getEventId()};
} else if (StringUtils.isNotBlank(vaccine.getFormSubmissionId())) {
selection = FORMSUBMISSION_ID + " = ? " + COLLATE_NOCASE;
selectionArgs = new String[] {vaccine.getFormSubmissionId()};
selectionArgs = new String[]{vaccine.getFormSubmissionId()};
}

Cursor cursor = database.query(VACCINE_TABLE_NAME, VACCINE_TABLE_COLUMNS, selection, selectionArgs, null, null,
Expand Down Expand Up @@ -372,7 +377,7 @@ public List<Vaccine> findWithNullHia2Status() {

public void deleteVaccine(String baseEntityId, String vaccineName) {
try {
getWritableDatabase().delete(VACCINE_TABLE_NAME, BASE_ENTITY_ID + " = ? AND " + NAME + " = ? ", new String[] {baseEntityId, vaccineName});
getWritableDatabase().delete(VACCINE_TABLE_NAME, BASE_ENTITY_ID + " = ? AND " + NAME + " = ? ", new String[]{baseEntityId, vaccineName});
updateFtsSearch(baseEntityId, vaccineName);
} catch (Exception e) {
Timber.e(e);
Expand All @@ -383,7 +388,7 @@ public void deleteVaccine(Long caseId) {
try {
Vaccine vaccine = find(caseId);
if (vaccine != null) {
getWritableDatabase().delete(VACCINE_TABLE_NAME, ID_COLUMN + "= ?", new String[] {caseId.toString()});
getWritableDatabase().delete(VACCINE_TABLE_NAME, ID_COLUMN + "= ?", new String[]{caseId.toString()});

updateFtsSearch(vaccine.getBaseEntityId(), vaccine.getName());
}
Expand All @@ -397,7 +402,7 @@ public Vaccine find(Long caseId) {
Cursor cursor = null;
try {
cursor = getReadableDatabase()
.query(VACCINE_TABLE_NAME, VACCINE_TABLE_COLUMNS, ID_COLUMN + " = ?", new String[] {caseId.toString()},
.query(VACCINE_TABLE_NAME, VACCINE_TABLE_COLUMNS, ID_COLUMN + " = ?", new String[]{caseId.toString()},
null, null, null, null);
List<Vaccine> vaccines = readAllVaccines(cursor);
if (!vaccines.isEmpty()) {
Expand Down Expand Up @@ -443,7 +448,7 @@ public void close(Long caseId) {
try {
ContentValues values = new ContentValues();
values.put(SYNC_STATUS, TYPE_Synced);
getWritableDatabase().update(VACCINE_TABLE_NAME, values, ID_COLUMN + " = ?", new String[] {caseId.toString()});
getWritableDatabase().update(VACCINE_TABLE_NAME, values, ID_COLUMN + " = ?", new String[]{caseId.toString()});
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class VaccineIntentService extends IntentService {
public static final String EVENT_TYPE = "Vaccination";
public static final String EVENT_TYPE_OUT_OF_CATCHMENT = "Out of Area Service - Vaccination";
public static final String EVENT_TYPE_IS_VOIDED = "Void Event";
public static final String ENTITY_TYPE = "vaccination";
private static final String TAG = VaccineIntentService.class.getCanonicalName();
private VaccineRepository vaccineRepository;
Expand Down Expand Up @@ -138,6 +139,10 @@ protected void onHandleIntent(Intent intent) {
if (vaccine.getBaseEntityId() == null || vaccine.getBaseEntityId().isEmpty() || new Integer(1).equals(vaccine.getOutOfCatchment())) {
JsonFormUtils.createVaccineEvent(getApplicationContext(), vaccine, getEventTypeOutOfCatchment(), getEntityType(), jsonArray);

}
if (vaccine.getBaseEntityId() == null || vaccine.getBaseEntityId().isEmpty() || new Integer(1).equals(vaccine.getOutOfCatchment())) {
JsonFormUtils.createVaccineEvent(getApplicationContext(), vaccine, getEventTypeIsVoided(), getEntityType(), jsonArray);

}
vaccineRepository.close(vaccine.getId());
}
Expand All @@ -155,6 +160,10 @@ protected String getEventTypeOutOfCatchment() {
return EVENT_TYPE_OUT_OF_CATCHMENT;
}

protected String getEventTypeIsVoided() {
return EVENT_TYPE_IS_VOIDED;
}

protected String getEntityType() {
return ENTITY_TYPE;
}
Expand Down
4 changes: 2 additions & 2 deletions opensrp-immunization/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<string name="record_all">Registrar Tudo</string>
<string name="record_">Registar%1$s</string>
<string name="record_due_">Registar %1$s- Vencimento %2$s</string>
<string name="mr_due_">%1$s - Vencimento %2$s</string>
<string name="due_">%1$s: Vencimento %2$s</string>
<string name="mr_due_">%1$s - Limite %2$s</string>
<string name="due_">%1$s: Limite %2$s</string>
<string name="today">Hoje</string>

<!-- Recurring Services -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class VaccineScheduleTest extends BaseUnitTest {
private Vaccine newVaccine = new Vaccine(0l, VaccineTest.BASEENTITYID, VaccineTest.PROGRAMCLIENTID, magicOPV0, 0,
new Date(),
VaccineTest.ANMID, VaccineTest.LOCATIONID, VaccineTest.SYNCSTATUS, VaccineTest.HIA2STATUS, 0l,
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date());
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date(), 1);

@Before
public void setUp() {
Expand Down Expand Up @@ -157,7 +157,7 @@ public void testVaccineOrCondition() throws ParseException {
list.add(new Vaccine(0l, VaccineTest.BASEENTITYID, VaccineTest.PROGRAMCLIENTID, "MCV 1", 0,
sdf.parse("2020-01-28"),
VaccineTest.ANMID, VaccineTest.LOCATIONID, VaccineTest.SYNCSTATUS, VaccineTest.HIA2STATUS, 0l,
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date()));
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date(), 1));

Condition object = new Condition();
object.type = "join";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void assertDefaultConstructorsCreateNonNullObjectOnInstantiation() {
junit.framework.Assert.assertNotNull(new Vaccine(0l, BASEENTITYID, NAME, 0, new Date(),
ANMID, LOCATIONID, SYNCSTATUS, HIA2STATUS, 0l, EVENTID, FORMSUBMISSIONID, 0));
junit.framework.Assert.assertNotNull(new Vaccine(0l, BASEENTITYID, PROGRAMCLIENTID, NAME, 0, new Date(),
ANMID, LOCATIONID, SYNCSTATUS, HIA2STATUS, 0l, EVENTID, FORMSUBMISSIONID, 0, new Date()));
ANMID, LOCATIONID, SYNCSTATUS, HIA2STATUS, 0l, EVENTID, FORMSUBMISSIONID, 0, new Date(), 1));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void assertInstantiatesSuccessfullyOnConstructorCall() {
@Test
public void verifyCreateTableCallsExecuteSQLMethod() {
RecurringServiceRecordRepository.createTable(sqliteDatabase);
Mockito.verify(sqliteDatabase, Mockito.times(7)).execSQL(org.mockito.ArgumentMatchers.anyString());
Mockito.verify(sqliteDatabase, Mockito.times(8)).execSQL(org.mockito.ArgumentMatchers.anyString());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void verifyaddTestShouldCallInsertAndUpdate1Time() {
Vaccine newVaccine = new Vaccine(0l, VaccineTest.BASEENTITYID, VaccineTest.PROGRAMCLIENTID, VaccineTest.NAME, 0,
new Date(),
VaccineTest.ANMID, VaccineTest.LOCATIONID, VaccineTest.SYNCSTATUS, VaccineTest.HIA2STATUS, 0l,
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date());
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date(), 1);

VaccineRepository vaccineRepositoryspy = Mockito.spy(vaccineRepository);
Vaccine vaccineToReturn = Mockito.mock(Vaccine.class);
Expand Down Expand Up @@ -186,11 +186,12 @@ public void testReadAllReturnsListOfVaccines(){
VaccineRepository.CREATED_AT,
VaccineRepository.TEAM,
VaccineRepository.TEAM_ID,
VaccineRepository.CHILD_LOCATION_ID
VaccineRepository.CHILD_LOCATION_ID,
VaccineRepository.IS_VOIDED
};

MatrixCursor cursor = new MatrixCursor(columns);
cursor.addRow(new Object[]{1l, "", "", magicName, magic10, magicTime, "", "", "", "", 1l, "", "", 1,magicTime,"","",""});
cursor.addRow(new Object[]{1l, "", "", magicName, magic10, magicTime, "", "", "", "", 1l, "", "", 1,magicTime,"","","", 1});

List<Vaccine> vaccines = vaccineRepository.readAllVaccines(cursor);
Assert.assertFalse(vaccines.isEmpty());
Expand Down
Loading

0 comments on commit 55ee520

Please sign in to comment.