Package org.geotools.arcsde.session

Examples of org.geotools.arcsde.session.ISession


    /**
     *
     */
    public void rollback() throws IOException {
        failIfClosed();
        final ISession session = this.session;
        try {
            session.issue(new Command<Void>() {
                @Override
                public Void execute(ISession session, SeConnection connection) throws SeException,
                        IOException {
                    session.rollbackTransaction();
                    // and keep editing
                    session.startTransaction();
                    return null;
                }
            });
        } catch (IOException se) {
            close();
View Full Code Here


        synchronized (SessionTransactionState.class) {
            state = (SessionTransactionState) transaction.getState(pool);
            if (state == null) {
                // start a transaction
                ISession session;
                try {
                    session = pool.getSession(true);
                } catch (UnavailableConnectionException e) {
                    throw new RuntimeException(
                            "Can't create a transaction state, connection pool exhausted", e);
                }
                try {
                    session.startTransaction();
                } catch (IOException e) {
                    try {
                        session.rollbackTransaction();
                    } finally {
                        session.dispose();
                    }
                    throw new DataSourceException("Exception initiating transaction on " + session,
                            e);
                }
                state = new SessionTransactionState(session);
View Full Code Here

        modifyFeatures(attributeNames, value, filter);
    }

    public void modifyFeatures(final Name[] attributes, final Object[] values, final Filter filter)
            throws IOException {
        final ISession session = getSession();
        try {
            final String typeName = typeInfo.getFeatureTypeName();
            final Transaction currTransaction = getTransaction();
            final FeatureWriter<SimpleFeatureType, SimpleFeature> writer;
            writer = dataStore.getFeatureWriter(typeName, filter, currTransaction);

            try {
                SimpleFeature feature;
                while (writer.hasNext()) {
                    feature = writer.next();
                    for (int i = 0; i < values.length; i++) {
                        feature.setAttribute(attributes[i].getLocalPart(), values[i]);
                    }
                    writer.write();
                }
            } finally {
                writer.close();
            }
        } finally {
            session.dispose();
        }
    }
View Full Code Here

        if (!getSchema().equals(readerType)) {
            throw new IllegalArgumentException("Type mismatch: " + readerType);
        }

        final String typeName = typeInfo.getFeatureTypeName();
        final ISession session = getSession();
        try {
            // truncate using this connection to apply or not depending on
            // whether a transaction is in progress
            truncate(typeName, session);
        } finally {
            session.dispose();
        }

        final FeatureWriter<SimpleFeatureType, SimpleFeature> writer;
        writer = dataStore.getFeatureWriterAppend(typeName, transaction);
        try {
View Full Code Here

    private void setupVersioningHandling(final String versionName) throws IOException {
        // create a versioned handler only if not already settled up, as this method
        // may be called for each layer inside a transaction
        if (versionHandler == ArcSdeVersionHandler.NONVERSIONED_HANDLER) {
            ISession session = getConnection();
            versionHandler = new TransactionVersionHandler(session, versionName);
        }
    }
View Full Code Here

     * </ul>
     * </p>
     */
    public void commit() throws IOException {
        failIfClosed();
        final ISession session = this.getConnection();

        final Command<Void> commitCommand = new Command<Void>() {
            @Override
            public Void execute(ISession session, SeConnection connection) throws SeException,
                    IOException {

                try {
                    if (currentVersionState != null) {
                        SeObjectId parentStateId = initialStateId;
                        // Change the version's state pointer to the last edit state.
                        defaultVersion.changeState(currentVersionState.getId());
                        // Trim the state tree.
                        currentVersionState.trimTree(parentStateId, currentVersionState.getId());
                    }
                } catch (SeException se) {
                    LOGGER.log(Level.WARNING, se.getMessage(), se);
                    close();
                    throw se;
                }
                return null;
            }
        };

        try {
            session.issue(commitCommand);
            fireChanges(true);
            versionHandler.commitEditState();
        } catch (IOException e) {
            versionHandler.rollbackEditState();
            throw e;
View Full Code Here

            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Building ArcSDEGridCoverageReader2D for " + rasterTable);
            }
        }

        ISession scon;
        try {
            scon = connectionPool.getSession(false);
        } catch (UnavailableConnectionException e) {
            throw new RuntimeException(e);
        }

        RasterDatasetInfo rasterInfo;

        try {
            GatherCoverageMetadataCommand command = new GatherCoverageMetadataCommand(rasterTable,
                    statisticsMandatory);
            rasterInfo = scon.issue(command);
        } finally {
            scon.dispose();
        }
        return rasterInfo;
    }
View Full Code Here

    }

    final ArcSDEDataStore createDataStore(ArcSDEDataStoreConfig config, final ISessionPool connPool)
            throws IOException {
        ArcSDEDataStore sdeDStore;
        ISession session;
        try {
            session = connPool.getSession(false);
        } catch (UnavailableConnectionException e) {
            throw new RuntimeException(e);
        }
        try {
            // check to see if our sdk is compatible with this arcsde instance
            SeRelease releaseInfo = session.getRelease();
            int majVer = releaseInfo.getMajor();
            int minVer = releaseInfo.getMinor();

            if (majVer == 9 && minVer > 1 && JSDE_CLIENT_VERSION < JSDE_VERSION_91) {
                // we can't connect to ArcSDE 9.2 with the arcsde 9.0 jars. It
                // just won't
                // work when trying to draw maps. Oh well, at least we'll warn
                // people.
                LOGGER.severe("\n\n**************************\n"
                        + "DANGER DANGER DANGER!!!  You're using the ArcSDE 9.0 (or earlier) jars with "
                        + "ArcSDE "
                        + majVer
                        + "."
                        + minVer
                        + " on host '"
                        + config.getServerName()
                        + "' .  "
                        + "This PROBABLY WON'T WORK.  If you have issues "
                        + "or unexplained exceptions when rendering maps, upgrade your ArcSDE jars to version "
                        + "9.2 or higher.  See http://docs.codehaus.org/display/GEOTOOLS/ArcSDE+Plugin\n"
                        + "**************************\n\n");
            }

            // if a version was specified, verify it exists
            final String versionName = config.getVersion();
            if (versionName != null && !("".equals(versionName.trim()))) {
                session.issue(new Commands.GetVersionCommand(versionName));
            }
        } finally {
            session.dispose();
        }

        String namespaceUri = config.getNamespaceUri();
        if (namespaceUri != null && "".equals(namespaceUri.trim())) {
            namespaceUri = null;
View Full Code Here

        testInsertGeometries(testMultiPolygons, testData);
    }

    private void testInsertGeometries(Geometry[] original, TestData testData) throws Exception {
        testData.truncateTempTable();
        ISession session = testData.getConnectionPool().getSession();
        SeLayer layer = testData.getTempLayer(session);

        Geometry[] fetched = new Geometry[original.length];
        try {
            testData.insertData(original, layer, session);
            final SeSqlConstruct sqlCons = new SeSqlConstruct(layer.getName());

            SeQuery query = session.createAndExecuteQuery(new String[] { "SHAPE" }, sqlCons);

            SdeRow row;
            SeShape shape;

            int i = 0;
            row = session.fetch(query);
            while (i < fetched.length && row != null) {
                shape = row.getShape(0);
                assertNotNull(shape);
                Class<? extends Geometry> clazz = ArcSDEAdapter.getGeometryTypeFromSeShape(shape);
                ArcSDEGeometryBuilder builder = ArcSDEGeometryBuilder.builderFor(clazz);
                fetched[i] = builder.construct(shape, new GeometryFactory());
                i++;
                row = session.fetch(query);
            }
            session.close(query);
        } finally {
            session.dispose();
        }

        for (int i = 0; i < fetched.length; i++) {
            final Geometry expected = original[i];
            final Geometry actual = fetched[i];
View Full Code Here

    @Before
    public void setUp() throws Exception {
        testData = new TestData();
        testData.setUp();
        {
            ISession session = testData.getConnectionPool().getSession();
            try {
                SeTable versionedTable = testData.createVersionedTable(session);
                tableName = versionedTable.getQualifiedName();
            } finally {
                session.dispose();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.arcsde.session.ISession

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.