public function getDatabase()
    {

        // if a DB ID has been set, try to load the database
        if ($useDbId = $this->getUseDbId()) {
            return $this->getDatabaseById($useDbId);
        }

        // iterate over the configured databases and try return the default database
        /** @var TechDivision\Import\Configuration\DatabaseInterface  $database */
        foreach ($this->databases as $database) {
            if ($database->isDefault()) {
                return $database;
            }
        }

        // try to return the first database configurtion
        if ($this->databases->count() > 0) {
            return $this->databases->first();
        }

        // throw an exception, if no database configuration is available
        throw new \Exception('There is no database configuration available');
    }