Skip to content

Commit

Permalink
#850 | Dynamically generated address columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ombhardwajj committed Feb 13, 2025
1 parent 1248e85 commit ea85d32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.avni.server.service.metabase;

import org.avni.server.dao.AddressLevelTypeRepository;
import org.avni.server.dao.metabase.CollectionRepository;
import org.avni.server.dao.metabase.DatabaseRepository;
import org.avni.server.dao.metabase.MetabaseDashboardRepository;
Expand Down Expand Up @@ -57,14 +58,16 @@ public class DatabaseService implements IQuestionCreationService {
private final CollectionRepository collectionRepository;
private final QuestionRepository questionRepository;
private final MetabaseDashboardRepository metabaseDashboardRepository;
private final AddressLevelTypeRepository addressLevelTypeRepository;

@Autowired
public DatabaseService(DatabaseRepository databaseRepository, MetabaseService metabaseService, CollectionRepository collectionRepository, QuestionRepository questionRepository, MetabaseDashboardRepository metabaseDashboardRepository) {
public DatabaseService(DatabaseRepository databaseRepository, MetabaseService metabaseService, CollectionRepository collectionRepository, QuestionRepository questionRepository, MetabaseDashboardRepository metabaseDashboardRepository, AddressLevelTypeRepository addressLevelTypeRepository) {
this.databaseRepository = databaseRepository;
this.metabaseService = metabaseService;
this.collectionRepository = collectionRepository;
this.questionRepository = questionRepository;
this.metabaseDashboardRepository = metabaseDashboardRepository;
this.addressLevelTypeRepository = addressLevelTypeRepository;
}

private Database getGlobalDatabase() {
Expand Down Expand Up @@ -276,7 +279,9 @@ private List<JoinTableConfig> getISGAJoinTableConfigs(Database database, List<Fi

private List<FieldDetails> getAddressFields(Database database, TableDetails addressTableDetails) {
List<FieldDetails> addressTableFieldsDetails = new ArrayList<>();
List<String> addressTableFields = List.of(ID,BLOCK,UUID, VILLAGE_HAMLET, PROJECT_BLOCK);
List<String> addressLevelTypeNames = addressLevelTypeRepository.getAllNames();
List<String> addressTableFields = new ArrayList<>(List.of(ID, UUID));
addressTableFields.addAll(addressLevelTypeNames);
for(String addressTableField : addressTableFields) {
addressTableFieldsDetails.add(databaseRepository.getFieldDetailsByName(database, addressTableDetails, new FieldDetails(addressTableField)));
}
Expand Down Expand Up @@ -416,6 +421,7 @@ private List<Parameters> createParametersForDashboard(){
}

public void addCollectionItems() {
//todo add field details and table details to request scope
createQuestionsForSubjectTypes();
createQuestionsForProgramsAndEncounters();
createQuestionsForMiscSingleTables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private void setupGlobalDashboard() {
}

public void setupMetabase() {
//todos remove sleep and use status check APIs to determine completion of previous step
setupGlobalDatabase();
sleepAwhile(10);
setupGlobalCollection();
Expand Down

0 comments on commit ea85d32

Please sign in to comment.