nameSearch method

dynamic nameSearch(
  1. dynamic selectQuery,
  2. GlobalSearchParameters params,
  3. LocalSqlDataStore sql
)

Implementation

nameSearch(
    selectQuery, GlobalSearchParameters params, LocalSqlDataStore sql) async {
  if (params.nameSearch == null || params.nameSearch!.isEmpty) {
    return selectQuery;
  } else if (params.nameSearch != null ||
      params.nameSearch!.isNotEmpty && selectQuery == null) {
    selectQuery = super.sql.individual.select().join(
        [joinName(sql), joinIdentifier(sql), joinIndividualAddress(sql)]);
    await searchByName(selectQuery, params, sql);
    selectQuery = selectQuery.join([
      leftOuterJoin(
          sql.householdMember,
          sql.householdMember.individualClientReferenceId
              .equalsExp(sql.individual.clientReferenceId))
    ]);
    selectQuery.join([
      leftOuterJoin(
          sql.household,
          sql.household.clientReferenceId
              .equalsExp(sql.householdMember.householdClientReferenceId)),
      leftOuterJoin(
          sql.projectBeneficiary,
          sql.projectBeneficiary.beneficiaryClientReferenceId
              .equalsExp(sql.household.clientReferenceId))
    ]);
  } else if (params.nameSearch != null &&
      params.nameSearch!.isNotEmpty &&
      selectQuery != null) {
    selectQuery = selectQuery.join([joinName(sql), joinIdentifier(sql)]);
    selectQuery = searchByName(selectQuery, params, sql);
  }
  return selectQuery;
}