/** * Creates a new instance. * * @param loginCredentials * Contains all information required to connect to the database. * @param preferences * Contains preferences configuring database behaviour. */ public PostgreSqlTruncator(DatabaseLoginCredentials loginCredentials, DatabasePreferences preferences) { dbCtx = new DatabaseContext(loginCredentials); schemaVersionValidator = new SchemaVersionValidator(dbCtx, preferences); }
/** * Creates a new instance. * * @param loginCredentials * Contains all information required to connect to the database. * @param preferences * Contains preferences configuring database behaviour. */ public PostgreSqlChangeWriter(DatabaseLoginCredentials loginCredentials, DatabasePreferences preferences) { dbCtx = new DatabaseContext(loginCredentials); changeWriter = new ChangeWriter(dbCtx); actionWriterMap = new HashMap<ChangeAction, ActionChangeWriter>(); actionWriterMap.put(ChangeAction.Create, new ActionChangeWriter(changeWriter, ChangeAction.Create)); actionWriterMap.put(ChangeAction.Modify, new ActionChangeWriter(changeWriter, ChangeAction.Modify)); actionWriterMap.put(ChangeAction.Delete, new ActionChangeWriter(changeWriter, ChangeAction.Delete)); schemaVersionValidator = new SchemaVersionValidator(dbCtx, preferences); }
private void initialize() { if (!initialized) { LOG.fine("Initializing the database and temporary processing files."); try (DatabaseContext dbCtx = new DatabaseContext(loginCredentials)) { DatabaseCapabilityChecker capabilityChecker = new DatabaseCapabilityChecker(dbCtx); populateBbox = capabilityChecker.isWayBboxSupported(); populateLinestring = capabilityChecker.isWayLinestringSupported(); copyFilesetBuilder = new CopyFilesetBuilder(copyFileset, populateBbox, populateLinestring, storeType); copyFilesetLoader = new CopyFilesetLoader(loginCredentials, preferences, copyFileset); LOG.fine("Processing input data, building geometries and creating database load files."); } initialized = true; } }
try (DatabaseContext dbCtx = new DatabaseContext(loginCredentials)) { IndexManager indexManager;
DatabaseLoginCredentials loginCredentials, DatabasePreferences preferences, boolean enableBboxBuilder, boolean enableLinestringBuilder, NodeLocationStoreType storeType) { dbCtx = new DatabaseContext(loginCredentials);
/** * Initialises the database connection and associated data access objects. */ private void initialize() { if (dbCtx == null) { ActionDao actionDao; dbCtx = new DatabaseContext(loginCredentials); new SchemaVersionValidator(dbCtx, preferences).validateVersion( PostgreSqlVersionConstants.SCHEMA_VERSION); capabilityChecker = new DatabaseCapabilityChecker(dbCtx); actionDao = releasableContainer.add(new ActionDao(dbCtx)); userDao = releasableContainer.add(new UserDao(dbCtx, actionDao)); nodeDao = releasableContainer.add(new NodeDao(dbCtx, actionDao)); wayDao = releasableContainer.add(new WayDao(dbCtx, actionDao)); relationDao = releasableContainer.add(new RelationDao(dbCtx, actionDao)); nodeManager = new PostgreSqlEntityManager<Node>(nodeDao, userDao); wayManager = new PostgreSqlEntityManager<Way>(wayDao, userDao); relationManager = new PostgreSqlEntityManager<Relation>(relationDao, userDao); } initialized = true; }