/** Initialises the database connection and associated data access objects. */ private void initialize() { if (dbCtx == null) { ActionDao actionDao; dbCtx = new DatabaseContext(loginCredentials); jdbcTemplate = dbCtx.getSimpleJdbcTemplate(); dbCtx.beginTransaction(); new SchemaVersionValidator(jdbcTemplate, preferences) .validateVersion(PostgreSqlVersionConstants.SCHEMA_VERSION); capabilityChecker = new DatabaseCapabilityChecker(dbCtx); actionDao = new ActionDao(dbCtx); userDao = new UserDao(dbCtx, actionDao); nodeDao = new NodeDao(dbCtx, actionDao); wayDao = new WayDao(dbCtx, actionDao); relationDao = new RelationDao(dbCtx, actionDao); nodeManager = new PostgreSqlEntityManager<Node>(nodeDao, userDao); wayManager = new PostgreSqlEntityManager<Way>(wayDao, userDao); relationManager = new PostgreSqlEntityManager<Relation>(relationDao, userDao); } initialized = true; }
/** {@inheritDoc} */ public void release() { if (dbCtx != null) { dbCtx.release(); dbCtx = null; } }
/** * Creates a new instance. * * @param dbCtx The database context to use for accessing the database. * @param actionDao The dao to use for adding action records to the database. */ public NodeDao(DatabaseContext dbCtx, ActionDao actionDao) { super(dbCtx.getJdbcTemplate(), new NodeMapper(), actionDao); jdbcTemplate = dbCtx.getJdbcTemplate(); capabilityChecker = new DatabaseCapabilityChecker(dbCtx); }
/** {@inheritDoc} */ public void complete() { dbCtx.commitTransaction(); }