Skip to content

Commit

Permalink
tei-capture-scope: extract the get orgUnitUids functionality to a method
Browse files Browse the repository at this point in the history
  • Loading branch information
marcamsn committed May 16, 2018
1 parent 9df7f15 commit 5354d82
Showing 1 changed file with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,7 @@ public Response call() throws Exception {
private Response trackerCall(GenericCallData genericCallData) throws Exception {
Response response = null;

Set<UserOrganisationUnitLinkModel> userOrganisationUnitLinks = userOrganisationUnitLinkStore.selectAll(
UserOrganisationUnitLinkModel.factory);

Set<String> organisationUnitUids = new HashSet<>();

for (UserOrganisationUnitLinkModel linkModel: userOrganisationUnitLinks) {
if (linkModel.organisationUnitScope().equals(
OrganisationUnitModel.Scope.SCOPE_DATA_CAPTURE.name())) {
organisationUnitUids.add(linkModel.organisationUnit());
}
}
Set<String> organisationUnitUids = getOrgUnitUids();

int pageSize = TeiQuery.Builder.create().build().getPageSize();

Expand Down Expand Up @@ -131,6 +121,22 @@ private Response trackerCall(GenericCallData genericCallData) throws Exception {
return response;
}

private Set<String> getOrgUnitUids() {
Set<UserOrganisationUnitLinkModel> userOrganisationUnitLinks = userOrganisationUnitLinkStore.selectAll(
UserOrganisationUnitLinkModel.factory);

Set<String> organisationUnitUids = new HashSet<>();

for (UserOrganisationUnitLinkModel linkModel: userOrganisationUnitLinks) {
if (linkModel.organisationUnitScope().equals(
OrganisationUnitModel.Scope.SCOPE_DATA_CAPTURE.name())) {
organisationUnitUids.add(linkModel.organisationUnit());
}
}

return organisationUnitUids;
}


public static TrackerEntitiesDataCall create(DatabaseAdapter databaseAdapter, Retrofit retrofit,
int teiLimitByOrgUnit) {
Expand Down

0 comments on commit 5354d82

Please sign in to comment.