Package org.openstreetmap.osmosis.pgsnapshot.common

Examples of org.openstreetmap.osmosis.pgsnapshot.common.DatabaseContext


   */
  private void initialize() {
    if (dbCtx == null) {
      ActionDao actionDao;
     
      dbCtx = new DatabaseContext(loginCredentials);
      jdbcTemplate = dbCtx.getJdbcTemplate();
     
      dbCtx.beginTransaction();
     
      new SchemaVersionValidator(jdbcTemplate, preferences).validateVersion(
View Full Code Here


    /**
     * Reads all data from the database and send it to the sink.
     */
    public void run() {
      DatabaseContext dbCtx = new DatabaseContext(loginCredentials);
     
      try {
        DatabaseCapabilityChecker capabilityChecker;
      IndexManager indexManager;
      String[] wayColumns;
     
      dbCtx.beginTransaction();
     
      capabilityChecker = new DatabaseCapabilityChecker(dbCtx);
      new SchemaVersionValidator(dbCtx.getJdbcTemplate(), preferences)
        .validateVersion(PostgreSqlVersionConstants.SCHEMA_VERSION);
     
      wayColumns = WAY_COLUMNS;
      if (capabilityChecker.isWayBboxSupported()) {
        wayColumns = appendColumn(wayColumns, "bbox");
      }
      if (capabilityChecker.isWayLinestringSupported()) {
        wayColumns = appendColumn(wayColumns, "linestring");
      }
       
        indexManager = new IndexManager(dbCtx, false, false);
       
      // Drop all constraints and indexes.
      indexManager.prepareForLoad();
       
        LOG.finer("Loading users.");
        dbCtx.loadCopyFile(copyFileset.getUserFile(), "users");
        LOG.finer("Loading nodes.");
        dbCtx.loadCopyFile(copyFileset.getNodeFile(), "nodes", NODE_COLUMNS);
        LOG.finer("Loading ways.");
        dbCtx.loadCopyFile(copyFileset.getWayFile(), "ways", wayColumns);
        LOG.finer("Loading way nodes.");
        dbCtx.loadCopyFile(copyFileset.getWayNodeFile(), "way_nodes");
        LOG.finer("Loading relations.");
        dbCtx.loadCopyFile(copyFileset.getRelationFile(), "relations", RELATION_COLUMNS);
        LOG.finer("Loading relation members.");
        dbCtx.loadCopyFile(copyFileset.getRelationMemberFile(), "relation_members");
        LOG.finer("Committing changes.");
       
        LOG.fine("Data load complete.");
       
        // Add all constraints and indexes.
        indexManager.completeAfterLoad();
       
        dbCtx.commitTransaction();
       
        LOG.fine("Clustering database.");
        dbCtx.getJdbcTemplate().update("CLUSTER");
       
        LOG.fine("Vacuuming database.");
        dbCtx.getJdbcTemplate().update("VACUUM ANALYZE");
       
        LOG.fine("Complete.");
       
      } finally {
        dbCtx.release();
      }
    }
View Full Code Here

   *            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.getJdbcTemplate(), preferences);
  }
View Full Code Here

  }
 
 
  private void initialize() {
    if (!initialized) {
      DatabaseContext dbCtx;
      DatabaseCapabilityChecker capabilityChecker;
     
      LOG.fine("Initializing the database and temporary processing files.");
     
      dbCtx = new DatabaseContext(loginCredentials);
      try {
        capabilityChecker = new DatabaseCapabilityChecker(dbCtx);

        populateBbox = capabilityChecker.isWayBboxSupported();
        populateLinestring = capabilityChecker.isWayLinestringSupported();
      } finally {
        dbCtx.release();
      }

      copyFilesetBuilder =
        new CopyFilesetBuilder(copyFileset, populateBbox, populateLinestring, storeType, keepInvalidWays);
     
View Full Code Here

   *            silently dropped to avoid putting invalid geometries into the
   *            database which can cause problems with postgis functions.
   */
  public PostgreSqlChangeWriter(DatabaseLoginCredentials loginCredentials,
      DatabasePreferences preferences, boolean keepInvalidWays) {
    dbCtx = new DatabaseContext(loginCredentials);
    changeWriter = new ChangeWriter(dbCtx);
    actionWriterMap = new HashMap<ChangeAction, ActionChangeWriter>();
    actionWriterMap.put(ChangeAction.Create,
        new ActionChangeWriter(changeWriter, ChangeAction.Create, keepInvalidWays));
    actionWriterMap.put(ChangeAction.Modify,
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.pgsnapshot.common.DatabaseContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.