Search in sources :

Example 1 with ProgramType

use of org.hisp.dhis.client.sdk.models.program.ProgramType in project pictureapp by EyeSeeTea.

the class SdkQueries method getProgramsForOrganisationUnit.

public static List<ProgramFlow> getProgramsForOrganisationUnit(String UId, ProgramType... programType) {
    List<OrganisationUnitToProgramRelationFlow> organisationUnitProgramRelationships = new Select().from(OrganisationUnitToProgramRelationFlow.class).where(OrganisationUnitToProgramRelationFlow_Table.organisationUnit.is(UId)).queryList();
    List<ProgramFlow> programs = new ArrayList<ProgramFlow>();
    for (OrganisationUnitToProgramRelationFlow oupr : organisationUnitProgramRelationships) {
        if (programType != null) {
            for (ProgramType kind : programType) {
                List<ProgramFlow> plist = new Select().from(ProgramFlow.class).where(ProgramFlow_Table.id.is(oupr.getProgram().getId())).and(ProgramFlow_Table.programType.is(kind)).queryList();
                programs.addAll(plist);
            }
        }
    }
    return programs;
}
Also used : OrganisationUnitToProgramRelationFlow(org.hisp.dhis.client.sdk.android.api.persistence.flow.OrganisationUnitToProgramRelationFlow) Select(com.raizlabs.android.dbflow.sql.language.Select) ArrayList(java.util.ArrayList) ProgramType(org.hisp.dhis.client.sdk.models.program.ProgramType) ProgramFlow(org.hisp.dhis.client.sdk.android.api.persistence.flow.ProgramFlow)

Aggregations

Select (com.raizlabs.android.dbflow.sql.language.Select)1 ArrayList (java.util.ArrayList)1 OrganisationUnitToProgramRelationFlow (org.hisp.dhis.client.sdk.android.api.persistence.flow.OrganisationUnitToProgramRelationFlow)1 ProgramFlow (org.hisp.dhis.client.sdk.android.api.persistence.flow.ProgramFlow)1 ProgramType (org.hisp.dhis.client.sdk.models.program.ProgramType)1