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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations