use of com.raizlabs.android.dbflow.sql.language.Select in project pictureapp by EyeSeeTea.
the class Question method getPropagationQuestions.
public List<Question> getPropagationQuestions() {
if (propagationQuestion != null) {
return propagationQuestion;
}
//No matches no children
List<Match> matches = getMatches();
if (matches.size() == 0) {
this.propagationQuestion = new ArrayList<>();
return this.propagationQuestion;
}
//Select question from questionrelation where operator=1 and id_match in (..)
propagationQuestion = new Select().from(Question.class).as(questionName).join(QuestionRelation.class, Join.JoinType.LEFT_OUTER).as(questionRelationName).on(Question_Table.id_question.withTable(questionAlias).eq(QuestionRelation_Table.id_question_fk.withTable(questionRelationAlias))).join(Match.class, Join.JoinType.LEFT_OUTER).as(matchName).on(QuestionRelation_Table.id_question_relation.withTable(questionRelationAlias).eq(Match_Table.id_question_relation_fk.withTable(matchAlias))).join(QuestionOption.class, Join.JoinType.LEFT_OUTER).as(questionOptionName).on(QuestionOption_Table.id_match_fk.withTable(questionOptionAlias).eq(Match_Table.id_match.withTable(matchAlias))).where(QuestionRelation_Table.operation.withTable(questionRelationAlias).eq(QuestionRelation.MATCH_PROPAGATE)).and(QuestionOption_Table.id_question_fk.withTable(questionOptionAlias).is(id_question)).queryList();
return propagationQuestion;
}
use of com.raizlabs.android.dbflow.sql.language.Select in project pictureapp by EyeSeeTea.
the class Translation method getLocalizedString.
public static String getLocalizedString(Long id_string, String language) {
Translation translation = new Select().from(Translation.class).where(Translation_Table.id_string_key.is(id_string)).and(Translation_Table.language.is(language)).querySingle();
if (translation == null || translation.getTranslation() == null || translation.getTranslation().isEmpty()) {
String generalLanguage = language.split("_")[0];
translation = new Select().from(Translation.class).where(Translation_Table.id_string_key.is(id_string)).and(Translation_Table.language.is(generalLanguage)).querySingle();
}
if (translation == null || translation.getTranslation() == null || translation.getTranslation().isEmpty()) {
translation = new Select().from(Translation.class).where(Translation_Table.id_string_key.is(id_string)).and(Translation_Table.language.is(DEFAULT_LANGUAGE)).querySingle();
}
return translation != null && translation.getTranslation() != null ? translation.getTranslation() : id_string + "";
}
use of com.raizlabs.android.dbflow.sql.language.Select in project pictureapp by EyeSeeTea.
the class Treatment method getAlternativeTreatments.
public List<Treatment> getAlternativeTreatments() {
Match match = new Select().from(Match.class).as(matchName).join(TreatmentMatch.class, Join.JoinType.INNER).as(treatmentMatchName).on(Match_Table.id_match.withTable(matchAlias).is(TreatmentMatch_Table.id_match_fk.withTable(treatmentMatchAlias))).where(TreatmentMatch_Table.id_treatment_fk.withTable(treatmentMatchAlias).is(id_treatment)).querySingle();
List<Treatment> treatments = new Select().from(Treatment.class).as(treatmentName).join(TreatmentMatch.class, Join.JoinType.INNER).as(treatmentMatchName).on(Treatment_Table.id_treatment.withTable(treatmentAlias).eq(TreatmentMatch_Table.id_treatment_fk.withTable(treatmentMatchAlias))).where(TreatmentMatch_Table.id_match_fk.withTable(treatmentMatchAlias).is(match.getId_match())).and(Treatment_Table.type.withTable(treatmentAlias).is(TYPE_NOT_MAIN)).queryList();
//FIXME: select split in two because DBFLOW bug
return treatments;
}
use of com.raizlabs.android.dbflow.sql.language.Select 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;
}
use of com.raizlabs.android.dbflow.sql.language.Select in project dev-summit-architecture-demo by yigit.
the class UserModel method loadUsersAsMap.
public Map<Long, User> loadUsersAsMap(List<Long> userIds) {
final HashMap<Long, User> result = new HashMap<>();
if (userIds.isEmpty()) {
return result;
}
long first = userIds.get(0);
List<Long> rest = userIds.subList(1, userIds.size());
FlowCursorList<User> userFlowCursorList = new Select().from(User.class).where(Condition.column(User$Table.MID).in(first, rest.toArray())).queryCursorList();
try {
final int size = userFlowCursorList.getCount();
for (int i = 0; i < size; i++) {
User user = userFlowCursorList.getItem(i);
result.put(user.getId(), user);
}
} finally {
userFlowCursorList.close();
}
return result;
}
Aggregations