Search in sources :

Example 11 with Select

use of com.raizlabs.android.dbflow.sql.language.Select in project pictureapp by EyeSeeTea.

the class Question method isTriggered.

/**
     * Checks if this question is triggered according to the current values of the given survey.
     * Only applies to question with answers DROPDOWN_DISABLED
     */
public boolean isTriggered(float idSurvey) {
    //Only disabled dropdowns
    if (this.getOutput() != Constants.DROPDOWN_LIST_DISABLED) {
        return false;
    }
    //Find questionoptions for q1 and q2 and check same match
    List<QuestionOption> questionOptions = new Select().from(QuestionOption.class).as(questionOptionName).join(Match.class, Join.JoinType.LEFT_OUTER).as(matchName).on(QuestionOption_Table.id_match_fk.withTable(questionOptionAlias).eq(Match_Table.id_match.withTable(matchAlias))).join(QuestionRelation.class, Join.JoinType.LEFT_OUTER).as(questionRelationName).on(Match_Table.id_question_relation_fk.withTable(matchAlias).eq(QuestionRelation_Table.id_question_relation)).join(Value.class, Join.JoinType.LEFT_OUTER).as(valueName).on(Value_Table.id_question_fk.withTable(valueAlias).eq(QuestionOption_Table.id_question_fk.withTable(questionOptionAlias)), Value_Table.id_option_fk.withTable(valueAlias).eq(QuestionOption_Table.id_option_fk.withTable(questionOptionAlias))).where(Value_Table.id_survey_fk.withTable(valueAlias).eq((long) idSurvey)).and(QuestionRelation_Table.id_question_fk.withTable(questionRelationAlias).eq(this.getId_question())).and(QuestionRelation_Table.operation.withTable(questionRelationAlias).eq(QuestionRelation.MATCH)).queryList();
    //No values no match
    if (questionOptions.size() != 2) {
        return false;
    }
    //Match is triggered if questionoptions have same matchid
    long idmatchQ1 = questionOptions.get(0).getMatch().getId_match();
    long idmatchQ2 = questionOptions.get(1).getMatch().getId_match();
    return idmatchQ1 == idmatchQ2;
}
Also used : Select(com.raizlabs.android.dbflow.sql.language.Select)

Example 12 with Select

use of com.raizlabs.android.dbflow.sql.language.Select in project pictureapp by EyeSeeTea.

the class User method getOrganisation.

public Long getOrganisation() {
    if (organisation_fk == null) {
        User user = new Select().from(User.class).where(User_Table.name.is(name)).querySingle();
        organisation_fk = user.getOrganisationId();
    }
    return organisation_fk;
}
Also used : Select(com.raizlabs.android.dbflow.sql.language.Select)

Example 13 with Select

use of com.raizlabs.android.dbflow.sql.language.Select in project pictureapp by EyeSeeTea.

the class EventExtended method removeDataValues.

public EventFlow removeDataValues() {
    //Remove all dataValues
    List<TrackedEntityDataValueFlow> dataValues = new Select().from(TrackedEntityDataValueFlow.class).where(TrackedEntityDataValueFlow_Table.event.eq(event.getUId())).queryList();
    if (dataValues != null) {
        for (int i = dataValues.size() - 1; i >= 0; i--) {
            TrackedEntityDataValueFlow dataValue = dataValues.get(i);
            dataValue.delete();
            dataValues.remove(i);
        }
    }
    //// TODO: 15/11/2016
    //event.setDataValues(null);
    event.save();
    return event;
}
Also used : TrackedEntityDataValueFlow(org.hisp.dhis.client.sdk.android.api.persistence.flow.TrackedEntityDataValueFlow) Select(com.raizlabs.android.dbflow.sql.language.Select)

Example 14 with Select

use of com.raizlabs.android.dbflow.sql.language.Select in project pictureapp by EyeSeeTea.

the class SdkQueries method getAssignedPrograms.

public static List<String> getAssignedPrograms() {
    //return MetaDataController.getAssignedPrograms();
    List<String> uids = new ArrayList<>();
    List<ProgramFlow> programsFlow = new Select().from(ProgramFlow.class).queryList();
    for (ProgramFlow programFlow : programsFlow) {
        uids.add(programFlow.getUId());
    }
    return uids;
}
Also used : ArrayList(java.util.ArrayList) Select(com.raizlabs.android.dbflow.sql.language.Select) ProgramFlow(org.hisp.dhis.client.sdk.android.api.persistence.flow.ProgramFlow)

Example 15 with Select

use of com.raizlabs.android.dbflow.sql.language.Select in project pictureapp by EyeSeeTea.

the class SurveyService method prepareSurveyInfo.

/**
     * Prepares required data to show a survey completely (tabs and composite scores).
     */
private void prepareSurveyInfo() {
    Log.d(TAG, "prepareSurveyInfo (Thread:" + Thread.currentThread().getId() + ")");
    //Get composite scores for current program & register them (scores)
    List<CompositeScore> compositeScores = new Select().from(CompositeScore.class).queryList();
    ScoreRegister.registerCompositeScores(compositeScores);
    //Get tabs for current program & register them (scores)
    List<Tab> tabs = new Select().from(Tab.class).queryList();
    ScoreRegister.registerTabScores(tabs);
    //Since intents does NOT admit NON serializable as values we use Session instead
    Session.putServiceValue(PREPARE_SURVEY_ACTION_COMPOSITE_SCORES, compositeScores);
    Session.putServiceValue(PREPARE_SURVEY_ACTION_TABS, tabs);
    //Returning result to anyone listening
    Intent resultIntent = new Intent(PREPARE_SURVEY_ACTION);
    LocalBroadcastManager.getInstance(this).sendBroadcast(resultIntent);
}
Also used : CompositeScore(org.eyeseetea.malariacare.data.database.model.CompositeScore) Tab(org.eyeseetea.malariacare.data.database.model.Tab) Select(com.raizlabs.android.dbflow.sql.language.Select) Intent(android.content.Intent)

Aggregations

Select (com.raizlabs.android.dbflow.sql.language.Select)15 ArrayList (java.util.ArrayList)3 Condition (com.raizlabs.android.dbflow.sql.language.Condition)2 ProgramFlow (org.hisp.dhis.client.sdk.android.api.persistence.flow.ProgramFlow)2 Intent (android.content.Intent)1 User (com.android.example.devsummit.archdemo.vo.User)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 CompositeScore (org.eyeseetea.malariacare.data.database.model.CompositeScore)1 Tab (org.eyeseetea.malariacare.data.database.model.Tab)1 OrganisationUnitToProgramRelationFlow (org.hisp.dhis.client.sdk.android.api.persistence.flow.OrganisationUnitToProgramRelationFlow)1 TrackedEntityDataValueFlow (org.hisp.dhis.client.sdk.android.api.persistence.flow.TrackedEntityDataValueFlow)1 ProgramType (org.hisp.dhis.client.sdk.models.program.ProgramType)1