Converts the given database to a map of CSL citation items
@param db the database
@return a map consisting of citation keys and citation items
779912
public Map<String, CSLItemData> toItemData(BibTeXDatabase db) {
		Map<String, CSLItemData> result = new HashMap<>();
		for (Map.Entry<Key, BibTeXEntry> e : db.getEntries().entrySet()) {
			result.put(e.getKey().getValue(), toItemData(e.getValue()));
		}
		return result;
	}
1323926
public List<D6TableMetaInfo> getTablesInfo(DBConnInfo dbConnInfo) {

		final List<D6TableMetaInfo> retTablesInfo = new ArrayList<D6TableMetaInfo>();

		final Connection conn = new DBConnCreator(dbConnInfo).createDBConnection();

		final List<String> tableList = new ArrayList<String>();

		ResultSet rs = null;

		try {
			final DatabaseMetaData metaData = conn.getMetaData();

			rs = metaData.getTables(null, null, "%", new String[] { "TABLE" });

			try {
				while (rs.next()) {
					final String tableName = rs.getString("TABLE_NAME");
					tableList.add(tableName);
				}
			} finally {
				rs.close();
			}

			for (String tableName : tableList) {

				final D6TableMetaInfo tableInfo = new D6TableMetaInfo();

				tableInfo.tableName = tableName;

				final Map<String, D6ColumnMetaInfo> colInfoMap = new LinkedHashMap<String, D6ColumnMetaInfo>();

				rs = metaData.getColumns(null, null, tableName, null);

				try {
					while (rs.next()) {
						D6ColumnMetaInfo colMeta = new D6ColumnMetaInfo();
						colMeta.columnName = rs.getString("COLUMN_NAME");
						colMeta.typeName = rs.getString("TYPE_NAME");
						colMeta.columnSize = rs.getInt("COLUMN_SIZE");
						colMeta.isNullable = "YES".equals(rs.getString("IS_NULLABLE"));
						colMeta.isAutoIncrement = "YES".equals("IS_AUTOINCREMENT");
						// java.sql.Types
						colMeta.dataType = rs.getInt("DATA_TYPE");

						colInfoMap.put(colMeta.columnName, colMeta);
					}
				} finally {
					rs.close();
				}

				rs = metaData.getPrimaryKeys(null, null, tableName);

				try {
					while (rs.next()) {
						final String columnName = rs.getString("COLUMN_NAME");
						final String pkName = rs.getString("PK_NAME");
						final short primaryKeySequentialIndex = rs.getShort("KEY_SEQ");

						final D6ColumnMetaInfo colMeta = colInfoMap.get(columnName);
						if (colMeta != null) {
							colMeta.pkName = pkName;
							colMeta.isPrimaryKey = true;
							colMeta.primaryKeySeqNum = primaryKeySequentialIndex;
						}

					}
				} finally {
					rs.close();
				}

				final Statement stmt = conn.createStatement();

				try {

					rs = stmt.executeQuery("SELECT * FROM " + tableName + " WHERE 0=1");
					try {
						ResultSetMetaData rmd = rs.getMetaData();
						for (int i = 1; i <= rmd.getColumnCount(); i++) {
							String columnName = rmd.getColumnName(i);
							final D6ColumnMetaInfo colMeta = colInfoMap.get(columnName);
							if (colMeta != null) {
								colMeta.className = rmd.getColumnClassName(i);
							}

						}
					} finally {
						rs.close();
					}
				} finally {
					stmt.close();
				}

				for (String columnName : colInfoMap.keySet()) {
					D6ColumnMetaInfo colMeta = colInfoMap.get(columnName);
					tableInfo.columnList.add(colMeta);
				}

				retTablesInfo.add(tableInfo);
			}

		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
			}
		}
		return retTablesInfo;
	}
404363
static Cl map(ResultSet rs, int colShift)
    {
        Cl tmp = new Cl();

        try
        {
            tmp.id = rs.getInt(1 + colShift);
            tmp.name = rs.getString(2 + colShift);
            tmp.childFirst = rs.getBoolean(3 + colShift);
            tmp.hiddenClasses = rs.getString(4 + colShift);
            tmp.tracingEnabled = rs.getBoolean(5 + colShift);
            tmp.persistent = rs.getBoolean(6 + colShift);
            tmp.allowedRunners = rs.getString(7 + colShift);
        }
        catch (SQLException e)
        {
            throw new DatabaseException(e);
        }
        return tmp;
    }
192226
@Deprecated
    public DatastoreImpl copy(final String database) {
        return new DatastoreImpl(morphia, mapper, mongoClient, database);
    }
52751
public List<Long> getMappingsForBase(String tableName, long baseId) {

		List<Long> relatedIds = new ArrayList<>();

		UserMappingDao userMappingDao = getMappingDao(tableName);
		UserCustomResultSet resultSet = userMappingDao.queryByBaseId(baseId);
		try {
			while (resultSet.moveToNext()) {
				UserMappingRow row = userMappingDao.getRow(resultSet);
				relatedIds.add(row.getRelatedId());
			}
		} finally {
			resultSet.close();
		}

		return relatedIds;
	}
1214668
public Map<String, String[]> toParameterMap() {

        Map<String, String[]> result = new HashMap<String, String[]>();

        result.put("dbCreateConStr", new String[] {getConnectionUrl()});
        result.put("dbName", new String[] {getDbName()});
        result.put("dbProduct", new String[] {getDbProduct()});
        result.put("dbProvider", new String[] {getDbProvider()});
        result.put("dbName", new String[] {getDbName()});
        result.put("db", new String[] {getDbName()});
        result.put("createDb", new String[] {Boolean.toString(isCreateDb())});
        result.put("createTables", new String[] {Boolean.toString(isCreateTables())});
        result.put("jdbcDriver", new String[] {getJdbcDriver()});
        result.put("templateDb", new String[] {getTemplateDb()});
        result.put("dbCreateUser", new String[] {getCreateUser()});
        result.put("dbCreatePwd", new String[] {getCreatePwd() == null ? "" : getCreatePwd()});
        result.put("dbWorkUser", new String[] {getWorkerUser()});
        result.put("dbWorkPwd", new String[] {getWorkerPwd() == null ? "" : getWorkerPwd()});
        result.put("dbDefaultTablespace", new String[] {getDefaultTablespace()});
        result.put("dbTemporaryTablespace", new String[] {getTemporaryTablespace()});
        result.put("dbIndexTablespace", new String[] {getIndexTablespace()});
        result.put("dropDb", new String[] {Boolean.toString(isDropDb())});
        result.put("servletMapping", new String[] {getServeltMapping()});
        result.put("submit", new String[] {Boolean.TRUE.toString()});

        return result;
    }
270211
public Map<Long, FeatureShape> getFeatureIds(String database, String table) {
        Map<String, Map<Long, FeatureShape>> tables = getTables(database);
        Map<Long, FeatureShape> featureIds = getFeatureIds(tables, table);
        return featureIds;
    }
961539
private ImmutableMap<CQIE, PPMappingAssertionProvenance> convertIntoDatalog(SQLPPMapping ppMapping, RDBMetadata dbMetadata)
            throws InvalidMappingSourceQueriesException {

        /*
         * May also add views in the DBMetadata!
         */
        ImmutableMap<CQIE, PPMappingAssertionProvenance> datalogMap = ppMapping2DatalogConverter.convert(
                ppMapping.getTripleMaps(), dbMetadata);

        LOGGER.debug("Original mapping size: {}", datalogMap.size());

        // Normalizing language tags and equalities (SIDE-EFFECT!)
        normalizeMapping(datalogMap.keySet());

        return datalogMap;
    }
817331
private Map<String, String[]> getShards(DBCollection collection) {
        DB config = collection.getDB().getSisterDB("config");
        DBCollection configShards = config.getCollection("shards");

        DBCursor cursorShards = configShards.find();

        Map<String, String[]> map = new HashMap<>();
        while (cursorShards.hasNext()) {
            DBObject currentShard = cursorShards.next();
            String currentHost = (String) currentShard.get("host");
            int slashIndex = currentHost.indexOf("/");
            if (slashIndex > 0) {
                map.put((String) currentShard.get(MONGO_DEFAULT_ID),
                        currentHost.substring(slashIndex + 1).split(","));
            }
        }
        return map;
    }
310798
def _query_db(self, mapping):
        
        model = self.models[mapping.get("table")]

        # Use primary key instead of the field mapped to SF Id
        fields = mapping.get("fields", {}).copy()
        if mapping["oid_as_pk"]:
            del fields["Id"]
        id_column = model.__table__.primary_key.columns.keys()[0]
        columns = [getattr(model, id_column)]

        for f in fields.values():
            columns.append(model.__table__.columns[f])
        lookups = mapping.get("lookups", {}).copy()
        for lookup in lookups.values():
            lookup["aliased_table"] = aliased(
                self.metadata.tables["{}_sf_ids".format(lookup["table"])]
            )
            columns.append(lookup["aliased_table"].columns.sf_id)

        query = self.session.query(*columns)
        if "record_type" in mapping and hasattr(model, "record_type"):
            query = query.filter(model.record_type == mapping["record_type"])
        if "filters" in mapping:
            filter_args = []
            for f in mapping["filters"]:
                filter_args.append(text(f))
            query = query.filter(*filter_args)
        for sf_field, lookup in lookups.items():
            # Outer join with lookup ids table:
            # returns main obj even if lookup is null
            key_field = get_lookup_key_field(lookup, sf_field)
            value_column = getattr(model, key_field)
            query = query.outerjoin(
                lookup["aliased_table"],
                lookup["aliased_table"].columns.id == value_column,
            )
            # Order by foreign key to minimize lock contention
            # by trying to keep lookup targets in the same batch
            lookup_column = getattr(model, key_field)
            query = query.order_by(lookup_column)
        self.logger.info(str(query))
        return query
1179375
private void mapIds() {
		if (queryReferences != null) {
			queryReferencesMap = new HashMap<String,Sequence>(queryReferences.size());
			for (int counter=0; counter < queryReferences.size() ; counter ++){
				String id = "Query_"+(counter+1);
				queryReferencesMap.put(id, queryReferences.get(counter));
			}
		}

		if (databaseReferences != null) {
			databaseReferencesMap = new HashMap<String,Sequence>(databaseReferences.size());
			for (int counter=0; counter < databaseReferences.size() ; counter ++){
				// this is strange: while Query_id are 1 based, Hit (database) id are 0 based
				String id = "gnl|BL_ORD_ID|"+(counter);
				databaseReferencesMap.put(id, databaseReferences.get(counter));
			}
		}
	}
905821
public Multimap<String, String> listCorpusAlias(File databaseProperties)
  {
    Multimap<String, String> result = TreeMultimap.create();

    DataSource origDataSource = getDataSource().getInnerDataSource();
    try
    {
      if (databaseProperties != null)
      {
        getDataSource().setInnerDataSource(createDataSource(databaseProperties));
      }
      result = getJdbcTemplate().query(
        "SELECT a.alias AS alias, c.name AS corpus\n"
        + "FROM corpus_alias AS a, corpus AS c\n" + "WHERE\n"
        + " a.corpus_ref = c.id",
        new ResultSetExtractor<Multimap<String, String>>()
        {

          @Override
          public Multimap<String, String> extractData(ResultSet rs) throws
          SQLException,
          DataAccessException
          {
            Multimap<String, String> data = TreeMultimap.create();
            while (rs.next())
            {
              // alias -> corpus name
              data.put(rs.getString(1), rs.getString(2));
            }
            return data;
          }
        });

    }
    catch (IOException | URISyntaxException | DataAccessException ex)
    {
      if (databaseProperties == null)
      {
        log.error(
          "Could not query corpus list", ex);
      }
      else
      {
        log.error(
          "Could not query corpus list for the file " + databaseProperties.
          getAbsolutePath(), ex);
      }
    }
    finally
    {
      getDataSource().setInnerDataSource(origDataSource);
    }

    return result;
  }
1287645
public function listCollections($db = null)
    {
        $collections = [];
        $result = $this->command(['listCollections' => 1], $db);
        foreach ($result as $collection) {
            $collections[] = $collection['name'];
        }

        return $collections;
    }
1314830
def _get_collections(self, db_names=None):
        
        if db_names:
            db_list = db_names
        else:
            db_list = self.client.list_database_names()

        for db_name in db_list:
            db = self.client.get_database(db_name)
            for col_name in db.list_collection_names():
                size = db[col_name].g
                yield f"{db_name}.{col_name}"
247130
def db(self, db_alias, shard_key=None):
        
        if shard_key is None:
            shard_key = ''

        db_key = db_alias + '__' + str(shard_key)
        if db_key not in self.__db_list:
            self.__db_list[db_key] = DbQueryService(self, self.__default_headers, {"db_alias": db_alias, "dbAlias": db_alias, "shard_find_key": shard_key, "shardKey": shard_key})
        return self.__db_list[db_key]
72102
public static function createDataMapper($table = null, $keys = null, $db = null)
    {
        $table = $table ?: static::$table;
        $keys = $keys ?: static::$keys;

        $mapper = new DataMapper($table, $keys, $db);

        if (static::$alias !== null) {
            $mapper->alias(static::$alias);
        } else {
            $mapper->alias(StringInflector::getInstance()->toSingular($table));
        }

        if (static::$dataClass) {
            $mapper->setDataClass(static::$dataClass);
        }

        if (static::$dataSetClass) {
            $mapper->setDatasetClass(static::$dataSetClass);
        }

        $mapper->getDispatcher()->addListener(new static());

        static::init($mapper);

        return $mapper;
    }
1024878
public DMap newDMap()
    {
        if ((getCurrentDatabase() == null))
        {
            throw new DatabaseClosedException("Database is NULL, cannot create a DMap with a null database.");
        }
        return (DMap) DMapFactory.singleton.createCollectionOrMap(getCurrentPBKey());
    }