Skip to content

Commit

Permalink
Merge pull request #1292 from dhis2/master-dev
Browse files Browse the repository at this point in the history
feat: [MASTER-DEV] Version 1.1.2
  • Loading branch information
vgarciabnz authored Jun 10, 2020
2 parents 2fdd619 + a1ab410 commit 4dc6ad8
Show file tree
Hide file tree
Showing 44 changed files with 281 additions and 104 deletions.
4 changes: 2 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ext {
buildToolsVersion: "28.0.3",
minSdkVersion : 19,
targetSdkVersion : 28,
versionCode : 211,
versionName : "1.1.1"
versionCode : 212,
versionName : "1.1.2"
]

libraries = [
Expand Down
4 changes: 2 additions & 2 deletions core/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
# Properties which are consumed by plugins/gradle-mvn-push.gradle plugin.
# They are used for publishing artifact to snapshot repository.

VERSION_NAME=1.1.1
VERSION_CODE=211
VERSION_NAME=1.1.2
VERSION_CODE=212

GROUP=org.hisp.dhis

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@
import org.junit.Assert;
import org.junit.Test;

import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

public class DataSetCompleteRegistrationObjectRepositoryMockIntegrationShould extends BaseMockIntegrationTestFullDispatcher {

private String dataSetUid = "lyLU2wR22tC";
private String orgUnitUid = "DiszpKrYNg8";
private String cocUid = "bRowv6yZOF2";

@Test
public void delete() {

List<DataSetCompleteRegistration> dataSetCompleteRegistrations = d2.dataSetModule().dataSetCompleteRegistrations().blockingGet();

try {
objectRepository().blockingDelete();
} catch (D2Error d2Error) {
Expand All @@ -58,11 +59,24 @@ public void delete() {

assertThat(dataSetCompleteRegistration.deleted(), is(true));
assertThat(dataSetCompleteRegistration.state(), is(State.TO_UPDATE));
}

@Test
public void delete_newly_created_record() throws D2Error {
DataSetCompleteRegistrationObjectRepository newObjectRepository =
d2.dataSetModule().dataSetCompleteRegistrations().value("2019", orgUnitUid, dataSetUid, cocUid);

newObjectRepository.blockingSet();
newObjectRepository.blockingDelete();

DataSetCompleteRegistration newObject = newObjectRepository.blockingGet();
assertNull(newObject);

DataSetCompleteRegistration existingObject = objectRepository().blockingGet();
assertNotNull(existingObject);
}

private DataSetCompleteRegistrationObjectRepository objectRepository() {
return d2.dataSetModule().dataSetCompleteRegistrations().value(
"2018", "DiszpKrYNg8", "lyLU2wR22tC","bRowv6yZOF2");
return d2.dataSetModule().dataSetCompleteRegistrations().value("2018", orgUnitUid, dataSetUid, cocUid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ public void by_form_name() {
assertThat(trackedEntityAttributes.size(), is(1));
}

@Test
public void by_display_form_name() {
List<TrackedEntityAttribute> trackedEntityAttributes =
d2.trackedEntityModule().trackedEntityAttributes()
.byDisplayFormName().eq("displayformname")
.blockingGet();

assertThat(trackedEntityAttributes.size(), is(1));
}

@Test
public void filter_by_field_color() {
List<TrackedEntityAttribute> trackedEntityAttributes =
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/assets/migrations/73.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Related to ANDROSDK-1151
UPDATE DataSetCompleteRegistration SET date = date() || 'T00:00:00.000' WHERE date IS NULL;
3 changes: 3 additions & 0 deletions core/src/main/assets/migrations/74.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Related to ANDROSDK-1147
ALTER TABLE ProgramSectionAttributeLink ADD COLUMN sortOrder INTEGER;
UPDATE ProgramSectionAttributeLink SET sortOrder=_id;
3 changes: 3 additions & 0 deletions core/src/main/assets/migrations/75.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Related to ANDROSDK-831
ALTER TABLE TrackedEntityAttribute ADD COLUMN displayFormName TEXT;
UPDATE TrackedEntityAttribute SET displayFormName=displayName;
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CREATE TABLE Legend (_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT NOT NULL UN
CREATE TABLE LegendSet (_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT NOT NULL UNIQUE, code TEXT, name TEXT, displayName TEXT, created TEXT, lastUpdated TEXT, symbolizer TEXT);
CREATE TABLE ProgramIndicatorLegendSetLink (_id INTEGER PRIMARY KEY AUTOINCREMENT, programIndicator TEXT NOT NULL, legendSet TEXT NOT NULL, FOREIGN KEY (programIndicator) REFERENCES ProgramIndicator (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (legendSet) REFERENCES LegendSet (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, UNIQUE (programIndicator, legendSet));
CREATE TABLE SystemSetting (_id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, value TEXT, UNIQUE (key));
CREATE TABLE ProgramSectionAttributeLink (_id INTEGER PRIMARY KEY AUTOINCREMENT, programSection TEXT NOT NULL, attribute TEXT NOT NULL, FOREIGN KEY (programSection) REFERENCES ProgramSection (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (attribute) REFERENCES TrackedEntityAttribute (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, UNIQUE (programSection, attribute));
CREATE TABLE ProgramSectionAttributeLink (_id INTEGER PRIMARY KEY AUTOINCREMENT, programSection TEXT NOT NULL, attribute TEXT NOT NULL, sortOrder INTEGER, FOREIGN KEY (programSection) REFERENCES ProgramSection (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (attribute) REFERENCES TrackedEntityAttribute (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, UNIQUE (programSection, attribute));
CREATE TABLE TrackedEntityAttributeReservedValue (_id INTEGER PRIMARY KEY AUTOINCREMENT, ownerObject TEXT, ownerUid TEXT, key TEXT, value TEXT, created TEXT, expiryDate TEXT, organisationUnit TEXT, temporalValidityDate TEXT);
CREATE TABLE CategoryOptionComboCategoryOptionLink (_id INTEGER PRIMARY KEY AUTOINCREMENT, categoryOptionCombo TEXT NOT NULL, categoryOption TEXT NOT NULL, FOREIGN KEY (categoryOptionCombo) REFERENCES CategoryOptionCombo (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (categoryOption) REFERENCES CategoryOption (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, UNIQUE (categoryOptionCombo, categoryOption));
CREATE TABLE Section (_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT NOT NULL UNIQUE, code TEXT, name TEXT, displayName TEXT, created TEXT, lastUpdated TEXT, description TEXT, sortOrder INTEGER, dataSet TEXT NOT NULL, showRowTotals INTEGER, showColumnTotals INTEGER, FOREIGN KEY (dataSet) REFERENCES DataSet (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED);
Expand All @@ -61,7 +61,7 @@ CREATE TABLE ProgramRuleAction (_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT
CREATE TABLE OrganisationUnitLevel (_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT NOT NULL UNIQUE, code TEXT, name TEXT, displayName TEXT, created TEXT, lastUpdated TEXT, level INTEGER);
CREATE TABLE ProgramSection (_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT NOT NULL UNIQUE, code TEXT, name TEXT, displayName TEXT, created TEXT, lastUpdated TEXT, description TEXT, program TEXT, sortOrder INTEGER, formName TEXT, color TEXT, icon TEXT, FOREIGN KEY (program) REFERENCES Program (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE DataApproval (_id INTEGER PRIMARY KEY AUTOINCREMENT, workflow TEXT NOT NULL, organisationUnit TEXT NOT NULL, period TEXT NOT NULL, attributeOptionCombo TEXT NOT NULL, state TEXT, FOREIGN KEY (attributeOptionCombo) REFERENCES CategoryOptionCombo (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (period) REFERENCES Period (periodId), FOREIGN KEY (organisationUnit) REFERENCES OrganisationUnit (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, UNIQUE (attributeOptionCombo, period, organisationUnit, workflow));
CREATE TABLE TrackedEntityAttribute (_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT NOT NULL UNIQUE, code TEXT, name TEXT, displayName TEXT, created TEXT, lastUpdated TEXT, shortName TEXT, displayShortName TEXT, description TEXT, displayDescription TEXT, pattern TEXT, sortOrderInListNoProgram INTEGER, optionSet TEXT, valueType TEXT, expression TEXT, programScope INTEGER, displayInListNoProgram INTEGER, generated INTEGER, displayOnVisitSchedule INTEGER, orgunitScope INTEGER, uniqueProperty INTEGER, inherit INTEGER, formName TEXT, fieldMask TEXT, color TEXT, icon TEXT, FOREIGN KEY (optionSet) REFERENCES OptionSet (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE TrackedEntityAttribute (_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT NOT NULL UNIQUE, code TEXT, name TEXT, displayName TEXT, created TEXT, lastUpdated TEXT, shortName TEXT, displayShortName TEXT, description TEXT, displayDescription TEXT, pattern TEXT, sortOrderInListNoProgram INTEGER, optionSet TEXT, valueType TEXT, expression TEXT, programScope INTEGER, displayInListNoProgram INTEGER, generated INTEGER, displayOnVisitSchedule INTEGER, orgunitScope INTEGER, uniqueProperty INTEGER, inherit INTEGER, formName TEXT, displayFormName TEXT, fieldMask TEXT, color TEXT, icon TEXT, FOREIGN KEY (optionSet) REFERENCES OptionSet (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE TrackerImportConflict (_id INTEGER PRIMARY KEY AUTOINCREMENT, conflict TEXT, value TEXT, trackedEntityInstance TEXT, enrollment TEXT, event TEXT, tableReference TEXT, errorCode TEXT, status TEXT, created TEXT, FOREIGN KEY (trackedEntityInstance) REFERENCES TrackedEntityInstance (uid) DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (enrollment) REFERENCES Enrollment (uid) DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (event) REFERENCES Event (uid) DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE DataSetOrganisationUnitLink (_id INTEGER PRIMARY KEY AUTOINCREMENT, dataSet TEXT NOT NULL, organisationUnit TEXT NOT NULL, FOREIGN KEY (dataSet) REFERENCES DataSet (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (organisationUnit) REFERENCES OrganisationUnit (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, UNIQUE (organisationUnit, dataSet));
CREATE TABLE UserOrganisationUnit (_id INTEGER PRIMARY KEY AUTOINCREMENT, user TEXT NOT NULL, organisationUnit TEXT NOT NULL, organisationUnitScope TEXT NOT NULL, root INTEGER, FOREIGN KEY (user) REFERENCES User (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (organisationUnit) REFERENCES OrganisationUnit (uid) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, UNIQUE (organisationUnitScope, user, organisationUnit));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

class BaseDatabaseOpenHelper {

static final int VERSION = 72;
static final int VERSION = 75;

private final AssetManager assetManager;
private final int targetVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DatabaseMigrationExecutor {
private final DatabaseAdapter databaseAdapter;
private final DatabaseMigrationParser parser;

private static final int SNAPSHOT_VERSION = 72;
private static final int SNAPSHOT_VERSION = 75;

DatabaseMigrationExecutor(DatabaseAdapter databaseAdapter, AssetManager assetManager) {
this.databaseAdapter = databaseAdapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.hisp.dhis.android.core.dataset.DataSetCompleteRegistrationTableInfo.Columns;
import org.hisp.dhis.android.core.dataset.internal.DataSetCompleteRegistrationPostCall;
import org.hisp.dhis.android.core.dataset.internal.DataSetCompleteRegistrationStore;
import org.hisp.dhis.android.core.user.UserCredentialsObjectRepository;

import java.util.Map;

Expand All @@ -59,21 +60,24 @@ public final class DataSetCompleteRegistrationCollectionRepository

private final DataSetCompleteRegistrationPostCall postCall;
private final DataSetCompleteRegistrationStore dataSetCompleteRegistrationStore;
private final UserCredentialsObjectRepository credentialsRepository;

@Inject
DataSetCompleteRegistrationCollectionRepository(
final DataSetCompleteRegistrationStore store,
final Map<String, ChildrenAppender<DataSetCompleteRegistration>> childrenAppenders,
final RepositoryScope scope,
final Handler<DataSetCompleteRegistration> handler,
final DataSetCompleteRegistrationPostCall postCall) {
final DataSetCompleteRegistrationPostCall postCall,
final UserCredentialsObjectRepository credentialsRepository) {

super(store, childrenAppenders, scope, new FilterConnectorFactory<>(scope,
s -> new DataSetCompleteRegistrationCollectionRepository(store, childrenAppenders,
s, handler, postCall)));
s, handler, postCall, credentialsRepository)));

this.postCall = postCall;
this.dataSetCompleteRegistrationStore = store;
this.credentialsRepository = credentialsRepository;
}

public DataSetCompleteRegistrationObjectRepository value(final String period,
Expand All @@ -88,7 +92,7 @@ public DataSetCompleteRegistrationObjectRepository value(final String period,
.scope;

return new DataSetCompleteRegistrationObjectRepository(
dataSetCompleteRegistrationStore, childrenAppenders,
dataSetCompleteRegistrationStore, credentialsRepository, childrenAppenders,
updatedScope, period, organisationUnit, dataSet, attributeOptionCombo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
import org.hisp.dhis.android.core.maintenance.D2Error;
import org.hisp.dhis.android.core.maintenance.D2ErrorCode;
import org.hisp.dhis.android.core.maintenance.D2ErrorComponent;
import org.hisp.dhis.android.core.user.UserCredentialsObjectRepository;

import java.util.Date;
import java.util.Map;

import io.reactivex.Completable;
Expand All @@ -50,6 +52,7 @@ public final class DataSetCompleteRegistrationObjectRepository
implements ReadWriteObjectRepository<DataSetCompleteRegistration> {

private final DataSetCompleteRegistrationStore dataSetCompleteRegistrationStore;
private final UserCredentialsObjectRepository credentialsRepository;

private final String period;
private final String dataSet;
Expand All @@ -58,6 +61,7 @@ public final class DataSetCompleteRegistrationObjectRepository

DataSetCompleteRegistrationObjectRepository(
final DataSetCompleteRegistrationStore dataSetCompleteRegistrationStore,
final UserCredentialsObjectRepository credentialsRepository,
final Map<String, ChildrenAppender<DataSetCompleteRegistration>> childrenAppenders,
final RepositoryScope scope,
final String period,
Expand All @@ -67,10 +71,11 @@ public final class DataSetCompleteRegistrationObjectRepository
) {
super(dataSetCompleteRegistrationStore, childrenAppenders, scope,
s -> new DataSetCompleteRegistrationObjectRepository(
dataSetCompleteRegistrationStore, childrenAppenders, s,
dataSetCompleteRegistrationStore, credentialsRepository, childrenAppenders, s,
period, organisationUnit, dataSet, attributeOptionCombo));

this.dataSetCompleteRegistrationStore = dataSetCompleteRegistrationStore;
this.credentialsRepository = credentialsRepository;

this.period = period;
this.dataSet = dataSet;
Expand All @@ -79,25 +84,31 @@ public final class DataSetCompleteRegistrationObjectRepository
}

public Completable set() {
return Completable.fromAction(() -> blockingSet());
return Completable.fromAction(this::blockingSet);
}

public void blockingSet() {
DataSetCompleteRegistration dataSetCompleteRegistration = blockingGetWithoutChildren();

if (dataSetCompleteRegistration == null) {
String username = credentialsRepository.blockingGet().username();
dataSetCompleteRegistrationStore.insert(
DataSetCompleteRegistration.builder()
.state(State.TO_POST)
.deleted(false)
.period(period)
.dataSet(dataSet)
.organisationUnit(organisationUnit)
.attributeOptionCombo(attributeOptionCombo)
.date(new Date())
.storedBy(username)
.state(State.TO_POST)
.deleted(false)
.build());
} else {
dataSetCompleteRegistrationStore.setState(dataSetCompleteRegistration,
dataSetCompleteRegistration.state() == State.TO_POST ? State.TO_POST : State.TO_UPDATE);
DataSetCompleteRegistration newRecord = dataSetCompleteRegistration.toBuilder()
.deleted(false)
.state(dataSetCompleteRegistration.state() == State.TO_POST ? State.TO_POST : State.TO_UPDATE)
.build();
dataSetCompleteRegistrationStore.updateWhere(newRecord);
}
}

Expand All @@ -119,11 +130,13 @@ public void blockingDelete() throws D2Error {
.build();
} else {
if (dataSetCompleteRegistration.state() == State.TO_POST) {
dataSetCompleteRegistrationStore.delete();
dataSetCompleteRegistrationStore.deleteWhere(dataSetCompleteRegistration);
} else {

dataSetCompleteRegistrationStore.setState(
dataSetCompleteRegistration.toBuilder().deleted(true).build(), State.TO_UPDATE);
DataSetCompleteRegistration deletedRecord = dataSetCompleteRegistration.toBuilder()
.deleted(true)
.state(State.TO_UPDATE)
.build();
dataSetCompleteRegistrationStore.updateWhere(deletedRecord);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,18 @@ List<AggregatedDataCallBundle> getDataValueQueriesForDataSets(Collection<DataSet
PastFuturePair pair = new PastFuturePair(entry.getKey());

List<Period> periods = periodManager.getPeriodsInRange(periodType, pair.past, pair.future);
List<String> periodIds = selectPeriodIds(periods);

AggregatedDataCallBundle bundle = AggregatedDataCallBundle.builder()
.dataSets(entry.getValue())
.periodIds(periodIds)
.orgUnitUids(organisationUnitUids)
.build();
if (!periods.isEmpty()) {
List<String> periodIds = selectPeriodIds(periods);

queries.add(bundle);
AggregatedDataCallBundle bundle = AggregatedDataCallBundle.builder()
.dataSets(entry.getValue())
.periodIds(periodIds)
.orgUnitUids(organisationUnitUids)
.build();

queries.add(bundle);
}
}
return queries;
}
Expand Down
Loading

0 comments on commit 4dc6ad8

Please sign in to comment.