Search in sources :

Example 6 with VersionControl

use of org.geotoolkit.version.VersionControl in project geotoolkit by Geomatys.

the class PGCoverageStore method createCoverageReference.

private GridCoverageResource createCoverageReference(final GenericName name, Version version) throws DataStoreException {
    if (version == null) {
        try {
            // grab the latest
            VersionControl vc = new PGVersionControl(this, name);
            final List<Version> versions = vc.list();
            if (versions.isEmpty()) {
                final Calendar cal = Calendar.getInstance(PGVersionControl.GMT0);
                cal.setTimeInMillis(0);
                version = vc.createVersion(cal.getTime());
            } else {
                version = versions.get(versions.size() - 1);
            }
        } catch (VersioningException ex) {
            throw new DataStoreException(ex.getMessage(), ex);
        }
    }
    return new PGCoverageResource(this, name, version);
}
Also used : DataStoreException(org.apache.sis.storage.DataStoreException) Version(org.geotoolkit.version.Version) Calendar(java.util.Calendar) VersioningException(org.geotoolkit.version.VersioningException) VersionControl(org.geotoolkit.version.VersionControl)

Example 7 with VersionControl

use of org.geotoolkit.version.VersionControl in project geotoolkit by Geomatys.

the class PostgresComplexTypeTest method reload.

private void reload(boolean simpleType) throws DataStoreException, VersioningException {
    if (store != null) {
        store.close();
    }
    // open in complex type to delete all types
    params.getOrCreate(PostgresProvider.SIMPLETYPE).setValue(false);
    store = (PostgresStore) DataStores.open(params);
    while (!store.getNames().isEmpty()) {
        // we get the list each type because relations may delete multiple types each time
        final GenericName n = store.getNames().iterator().next();
        final VersionControl vc = store.getVersioning(n.toString());
        vc.dropVersioning();
        store.deleteFeatureType(n.toString());
    }
    assertTrue(store.getNames().isEmpty());
    store.close();
    // reopen the way it was asked
    params.getOrCreate(PostgresProvider.SIMPLETYPE).setValue(simpleType);
    store = (PostgresStore) DataStores.open(params);
    assertTrue(store.getNames().isEmpty());
}
Also used : GenericName(org.opengis.util.GenericName) VersionControl(org.geotoolkit.version.VersionControl)

Example 8 with VersionControl

use of org.geotoolkit.version.VersionControl in project geotoolkit by Geomatys.

the class PostgresCoverageTest method reload.

private void reload(boolean simpleType) throws DataStoreException, VersioningException {
    if (store != null) {
        store.close();
    }
    // open in complex type to delete all types
    params.getOrCreate(PostgresProvider.SIMPLETYPE).setValue(false);
    store = (PostgresStore) DataStores.open(params);
    while (!store.getNames().isEmpty()) {
        // we get the list each type because relations may delete multiple types each time
        final GenericName n = store.getNames().iterator().next();
        final VersionControl vc = store.getVersioning(n.toString());
        vc.dropVersioning();
        store.deleteFeatureType(n.toString());
    }
    assertTrue(store.getNames().isEmpty());
    store.close();
    // reopen the way it was asked
    params.getOrCreate(PostgresProvider.SIMPLETYPE).setValue(simpleType);
    store = (PostgresStore) DataStores.open(params);
    assertTrue(store.getNames().isEmpty());
}
Also used : GenericName(org.opengis.util.GenericName) VersionControl(org.geotoolkit.version.VersionControl)

Example 9 with VersionControl

use of org.geotoolkit.version.VersionControl in project geotoolkit by Geomatys.

the class PostgresSpatialQueryTest method reload.

private void reload(boolean simpleType) throws DataStoreException, VersioningException {
    if (store != null) {
        store.close();
    }
    // open in complex type to delete all types
    params.getOrCreate(PostgresProvider.SIMPLETYPE).setValue(false);
    store = (PostgresStore) DataStores.open(params);
    for (GenericName n : store.getNames()) {
        VersionControl vc = store.getVersioning(n.toString());
        vc.dropVersioning();
        store.deleteFeatureType(n.toString());
    }
    assertTrue(store.getNames().isEmpty());
    store.close();
    // reopen the way it was asked
    params.getOrCreate(PostgresProvider.SIMPLETYPE).setValue(simpleType);
    store = (PostgresStore) DataStores.open(params);
    assertTrue(store.getNames().isEmpty());
}
Also used : GenericName(org.opengis.util.GenericName) VersionControl(org.geotoolkit.version.VersionControl)

Example 10 with VersionControl

use of org.geotoolkit.version.VersionControl in project geotoolkit by Geomatys.

the class PostgresVersioningTest method reload.

private void reload(boolean simpleType) throws DataStoreException, VersioningException {
    if (store != null) {
        store.close();
    }
    // open in complex type to delete all types
    params.getOrCreate(PostgresProvider.SIMPLETYPE).setValue(false);
    store = (PostgresStore) DataStores.open(params);
    for (GenericName n : store.getNames()) {
        VersionControl vc = store.getVersioning(n.toString());
        vc.dropVersioning();
        store.deleteFeatureType(n.toString());
    }
    assertTrue(store.getNames().isEmpty());
    store.close();
    // reopen the way it was asked
    params.getOrCreate(PostgresProvider.SIMPLETYPE).setValue(simpleType);
    store = (PostgresStore) DataStores.open(params);
    assertTrue(store.getNames().isEmpty());
    // delete historisation functions, he must create them himself
    store.dropHSFunctions();
}
Also used : GenericName(org.opengis.util.GenericName) VersionControl(org.geotoolkit.version.VersionControl)

Aggregations

VersionControl (org.geotoolkit.version.VersionControl)13 Version (org.geotoolkit.version.Version)8 GenericName (org.opengis.util.GenericName)8 Test (org.junit.Test)7 Date (java.util.Date)6 HashMap (java.util.HashMap)6 FeatureIterator (org.geotoolkit.storage.feature.FeatureIterator)6 Query (org.geotoolkit.storage.feature.query.Query)6 Coordinate (org.locationtech.jts.geom.Coordinate)6 Point (org.locationtech.jts.geom.Point)6 Feature (org.opengis.feature.Feature)6 FeatureType (org.opengis.feature.FeatureType)6 ResourceId (org.opengis.filter.ResourceId)6 FeatureStoreRuntimeException (org.geotoolkit.storage.feature.FeatureStoreRuntimeException)3 Calendar (java.util.Calendar)2 DataStoreException (org.apache.sis.storage.DataStoreException)2 Session (org.geotoolkit.storage.feature.session.Session)2 VersioningException (org.geotoolkit.version.VersioningException)2 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1