src/main/java/nl/bioinf/minorapplicationdesign/ontpillen/model/web_scraping/DrugFetcher.java
/**
     * Method that will store the drugs in the Dao. The input is an List containing Element
     * objects. Since there can be multiple drug Groups in a single drug Group the method will
     * run recursive until there are no drugGroups left and all drugs are added.
     * @param drugGroups is a list with Element objects containing the drugGroups
     */
Method that will store the drugs in the Dao. The input is an List containing Element
objects. Since there can be multiple drug Groups in a single drug Group the method will
run recursive until there are no drugGroups left and all drugs are added.
@param drugGroups is a list with Element objects containing the drugGroups
Method that will store the drugs in the Dao . The input is an List containing Element objects . Since there can be multiple drug Groups in a single drug Group the method will run recursive until there are no drugGroups left and all drugs are added . @param drugGroups is a list with Element objects containing the drugGroups
private void storeDrugsInDao(List<Element> drugGroups){
        Element currentDrugElement = drugGroups.get(0);
        String currentDrugName = currentDrugElement.text().toLowerCase();
        DrugGroup currentDrug;
        if (!drugDao.getAllDrugNames().contains(currentDrugName)) {
            drugDao.addDrug(new DrugGroup(currentDrugName));
        }
        currentDrug = (DrugGroup) drugDao.getDrugByName(currentDrugName);
        addDrugs(drugGroups, currentDrugElement, currentDrug);
        drugGroups.remove(0);
        if (drugGroups.size() != 0) {
            storeDrugsInDao(drugGroups);
        }
    }
private void storeDrugsInDao ( List < Element > drugGroups ) { Element currentDrugElement = drugGroups . get ( 0 ) ; String currentDrugName = currentDrugElement . text ( ) . toLowerCase ( ) ; DrugGroup currentDrug ; if ( ! drugDao . getAllDrugNames ( ) . contains ( currentDrugName ) ) { drugDao . addDrug ( new DrugGroup ( currentDrugName ) ) ; } currentDrug = ( DrugGroup ) drugDao . getDrugByName ( currentDrugName ) ; addDrugs ( drugGroups , currentDrugElement , currentDrug ) ; drugGroups . remove ( 0 ) ; if ( drugGroups . size ( ) != 0 ) { storeDrugsInDao ( drugGroups ) ; } }
Method that will store the drugs in the Dao.
Method that will store the drugs in the Dao .
// As long as there are elements in this.drugGroups run this method again