Package org.geotools.arcsde.session

Examples of org.geotools.arcsde.session.ISession


    @Test
    public void testEditVersionedTableTransaction() throws Exception {
        try {
            final String tableName;
            {
                ISession session = testData.getConnectionPool().getSession();
                try {
                    SeTable versionedTable = testData.createVersionedTable(session);
                    tableName = versionedTable.getQualifiedName();
                } finally {
                    session.dispose();
                }
            }

            final ArcSDEDataStore dataStore = testData.getDataStore();
            final SimpleFeatureSource source;
View Full Code Here


        }
        return this._pool;
    }

    public String getTempTableName() throws IOException, UnavailableConnectionException {
        ISession session = getConnectionPool().getSession();
        String tempTableName;
        try {
            tempTableName = getTempTableName(session);
        } finally {
            session.dispose();
        }
        return tempTableName;
    }
View Full Code Here

    }

    private static void deleteTable(final ISessionPool connPool, final String tableName)
            throws IOException, UnavailableConnectionException {

        final ISession session = connPool.getSession();

        // final SeTable layer = session.createSeTable(tableName);

        final Command<Void> deleteCmd = new Command<Void>() {

            @Override
            public Void execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                // try {
                // layer.delete();
                // } catch (NoSuchElementException e) {
                // // nothing to do
                // } catch (SeException e) {
                // // LOGGER.log(Level.WARNING, "while deleteing layer " +
                // tableName + " got '" +
                // // e.getSeError().getErrDesc() + "'");
                // }
                SeTable table = new SeTable(connection, tableName);
                try {
                    table.delete();
                } catch (SeException ignorable) {
                    // table did not already exist
                }
                return null;
            }
        };

        session.issue(deleteCmd);
        session.dispose();
    }
View Full Code Here

    public void createTempTable(final boolean insertTestData) throws Exception {
        ISessionPool connPool = getConnectionPool();

        deleteTempTable(connPool);

        ISession session = connPool.getSession();

        try {
            /*
             * Create a qualified table name with current user's name and the name of the table to
             * be created, "EXAMPLE".
             */
            final String tableName = getTempTableName(session);

            final SeTable tempTable = session.createSeTable(tableName);
            final SeLayer tempTableLayer = session.issue(new Command<SeLayer>() {
                @Override
                public SeLayer execute(ISession session, SeConnection connection)
                        throws SeException, IOException {
                    SeLayer tempTableLayer = new SeLayer(connection);
                    tempTableLayer.setTableName(tableName);
                    return tempTableLayer;
                }
            });

            tempTableColumns = createBaseTable(session, tempTable, tempTableLayer, configKeyword);

            if (insertTestData) {
                insertData(tempTableLayer, session, tempTableColumns);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            session.dispose();
        }
    }
View Full Code Here

     * @throws Exception
     */
    public void insertTestData() throws Exception {
        truncateTempTable();
        ISessionPool connPool = getConnectionPool();
        ISession session = connPool.getSession();
        try {
            SeLayer tempTableLayer = getTempLayer(session);
            insertData(tempTableLayer, session, tempTableColumns);
        } finally {
            session.dispose();
        }
    }
View Full Code Here

        }
    }

    public void truncateTempTable() throws IOException, UnavailableConnectionException {
        final ISessionPool connPool = getConnectionPool();
        final ISession session = connPool.getSession();
        final String tempTableName = getTempTableName(session);

        try {
            session.issue(new Command<Void>() {
                @Override
                public Void execute(ISession session, SeConnection connection) throws SeException,
                        IOException {
                    SeTable table;
                    try {
                        table = session.getTable(tempTableName);
                    } catch (IOException e) {
                        // table does not exist, its ok.
                        return null;
                    }
                    table.truncate();
                    return null;
                }
            });
        } finally {
            session.dispose();
        }
    }
View Full Code Here

     * @throws DataSourceException
     */
    @Test
    public void testTransactionStateRead() throws Exception {
        // connection with a transaction in progress
        final ISession transSession;

        testData.truncateTempTable();

        {
            final ISessionPool connPool = testData.getConnectionPool();
            transSession = connPool.getSession();
            // start a transaction on transConn
            transSession.startTransaction();
        }

        // flag to rollback or not at finally{}
        boolean commited = false;

        try {
            final String[] columns = { "INT32_COL", "STRING_COL" };
            final String tableName = testData.getTempTableName(transSession);

            transSession.issue(new Command<Void>() {
                @Override
                public Void execute(ISession session, SeConnection connection) throws SeException,
                        IOException {
                    SeInsert insert = new SeInsert(connection);
                    insert.intoTable(tableName, columns);
                    insert.setWriteMode(true);
                    SeRow row = insert.getRowToSet();
                    row.setInteger(0, Integer.valueOf(50));
                    row.setString(1, "inside transaction");

                    insert.execute();
                    // IMPORTANT to call close for the diff to take effect
                    insert.close();
                    return null;
                }
            });

            final SeSqlConstruct sqlConstruct = new SeSqlConstruct(tableName);

            final SeRow transRow = transSession.issue(new Command<SeRow>() {
                @Override
                public SeRow execute(ISession session, SeConnection connection) throws SeException,
                        IOException {
                    // the query over the transaction connection
                    SeQuery transQuery = new SeQuery(connection, columns, sqlConstruct);
                    // transaction is not committed, so transQuery should give
                    // the
                    // inserted
                    // record and query don't
                    transQuery.prepareQuery();
                    transQuery.execute();
                    SeRow transRow = transQuery.fetch();
                    // querying over a transaction in progress does give diff
                    // assertEquals(Integer.valueOf(50), transRow.getInteger(0))
                    transQuery.close();
                    return transRow;
                }
            });

            assertNotNull(transRow);

            // commit transaction
            transSession.commitTransaction();
            commited = true;

            final SeRow noTransRow = session.issue(new Command<SeRow>() {
                @Override
                public SeRow execute(ISession session, SeConnection connection) throws SeException,
                        IOException {
                    SeQuery query = new SeQuery(connection, columns, sqlConstruct);
                    query.prepareQuery();
                    query.execute();
                    SeRow row = query.fetch();
                    query.close();
                    return row;
                }
            });

            assertNotNull(noTransRow);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (!commited) {
                transSession.rollbackTransaction();
            }
            transSession.dispose();
            // conn.close(); closed at tearDown
        }
    }
View Full Code Here

     * @throws UnavailableConnectionException
     */
    @Test
    public void testCreateDataStoreWithInProcessViews() throws IOException, SeException,
            UnavailableConnectionException {
        ISession session = testData.getConnectionPool().getSession(true);
        try {
            InProcessViewSupportTestData.setUp(session, testData);
        } finally {
            session.dispose();
        }

        Map<String, Serializable> workingParamsWithSqlView = new HashMap<String, Serializable>(
                workingParams);
        workingParamsWithSqlView.putAll(InProcessViewSupportTestData.registerViewParams);
View Full Code Here

        store.dispose();
    }

    @Test
    public void testVersionParamCheck() throws IOException, UnavailableConnectionException {
        ISession session = testData.getConnectionPool().getSession(true);
        final String versionName = "testVersionParamCheck";
        try {
            testData.createVersion(session, versionName,
                    SeVersion.SE_QUALIFIED_DEFAULT_VERSION_NAME);
        } finally {
            session.dispose();
        }

        Map<String, Serializable> paramsWithVersion = new HashMap<String, Serializable>(
                workingParams);
        try {
View Full Code Here

        }
    }

    @Test
    public void testVersioned() throws IOException, UnavailableConnectionException {
        ISession session = testData.getConnectionPool().getSession(true);
        final String versionName = "testVersioned";
        try {
            testData.createVersion(session, versionName,
                    SeVersion.SE_QUALIFIED_DEFAULT_VERSION_NAME);
        } finally {
            session.dispose();
        }

        Map<String, Serializable> paramsWithVersion = new HashMap<String, Serializable>(
                workingParams);
        paramsWithVersion.put(VERSION_PARAM_NAME, versionName);
        DataStore ds = dsFactory.createDataStore(paramsWithVersion);
        assertNotNull(ds);
        ds.dispose();

        String qualifiedVersionName = session.getUser() + "." + versionName;
        paramsWithVersion.put(VERSION_PARAM_NAME, qualifiedVersionName);
        ds = dsFactory.createDataStore(paramsWithVersion);
        assertNotNull(ds);
        ds.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.