app/repository/ArtistRepository.java
private void saveAdminArtistCountries(Artist newArtist) {
        for (String countryName : newArtist.getCountryList()) {
            Optional<Integer> countryObject = passportCountryRepository.getPassportCountryId(countryName);
            if (countryObject.isPresent()) {
                ArtistCountry artistCountry = new ArtistCountry(newArtist.getArtistId(), countryObject.get());
                addCountrytoArtistCountryTable(artistCountry);
            } else {
                PassportCountry passportCountry = new PassportCountry(countryName);
                passportCountryRepository.insert(passportCountry).thenApplyAsync(id -> {
                    if (id.isPresent()) {
                        ArtistCountry artistCountry = new ArtistCountry(newArtist.getArtistId(), id.get());
                        addCountrytoArtistCountryTable(artistCountry);
                    }
                    return null;
                });
            }
        }
    }
/**
     * Method to save a new artist object with newly set attributes from the edit artist model
     *
     * @param newArtist the artist object to be edited
     */
Method to save a new artist object with newly set attributes from the edit artist model
@param newArtist the artist object to be edited
Method to save a new artist object with newly set attributes from the edit artist model @param newArtist the artist object to be edited
private void saveAdminArtistCountries(Artist newArtist) {
        for (String countryName : newArtist.getCountryList()) {
            Optional<Integer> countryObject = passportCountryRepository.getPassportCountryId(countryName);
            if (countryObject.isPresent()) {
                ArtistCountry artistCountry = new ArtistCountry(newArtist.getArtistId(), countryObject.get());
                addCountrytoArtistCountryTable(artistCountry);
            } else {
                PassportCountry passportCountry = new PassportCountry(countryName);
                passportCountryRepository.insert(passportCountry).thenApplyAsync(id -> {
                    if (id.isPresent()) {
                        ArtistCountry artistCountry = new ArtistCountry(newArtist.getArtistId(), id.get());
                        addCountrytoArtistCountryTable(artistCountry);
                    }
                    return null;
                });
            }
        }
    }
private void saveAdminArtistCountries ( Artist newArtist ) { for ( String countryName : newArtist . getCountryList ( ) ) { Optional < Integer > countryObject = passportCountryRepository . getPassportCountryId ( countryName ) ; if ( countryObject . isPresent ( ) ) { ArtistCountry artistCountry = new ArtistCountry ( newArtist . getArtistId ( ) , countryObject . get ( ) ) ; addCountrytoArtistCountryTable ( artistCountry ) ; } else { PassportCountry passportCountry = new PassportCountry ( countryName ) ; passportCountryRepository . insert ( passportCountry ) . thenApplyAsync ( id -> { if ( id . isPresent ( ) ) { ArtistCountry artistCountry = new ArtistCountry ( newArtist . getArtistId ( ) , id . get ( ) ) ; addCountrytoArtistCountryTable ( artistCountry ) ; } return null ; } ) ; } } }
Method to save a new artist object with newly set attributes from the edit artist model
 @param newArtist the artist object to be edited
Method to save a new artist object with newly set attributes from the edit artist model @param newArtist the artist object to be edited