Package com.esri.sde.sdk.client

Examples of com.esri.sde.sdk.client.SeQuery


            public Integer execute(ISession session, SeConnection connection) throws SeException,
                    IOException {

                final SeQueryInfo queryInfo = qInfo;

                SeQuery query = new SeQuery(connection);

                try {
                    versioningHandler.setUpStream(session, query);

                    if (spatialFilters != null && spatialFilters.length > 0) {

                        final boolean calcMasks = true;// use the spatial query to calculate
                        // statistics.
                        final short searchOrder = SeQuery.SE_OPTIMIZE;
                        query.setSpatialConstraints(searchOrder, calcMasks, spatialFilters);

                        final SeDBMSInfo dbmsInfo = connection.getDBMSInfo();
                        final boolean unsupported = versioningHandler != ArcSdeVersionHandler.NONVERSIONED_HANDLER
                                && dbmsInfo.dbmsId == SeDBMSInfo.SE_DBMS_IS_ORACLE;

                        if (unsupported) {
                            LOGGER.fine("ArcSDE on Oracle can't calculate count statistics "
                                    + "on versioned layers with spatial filters");
                            /*
                             * Despite the FeatureSource.getCount() contract saying it's ok to
                             * return -1 if count is too expensive to calculate, the GeoServer
                             * codebase is plagued of FeatureCollection.size() calls depending on
                             * actual result counts or some operations don't work at all. return -1;
                             */

                            query.prepareQueryInfo(queryInfo);
                            query.execute();
                            int count = 0;
                            while (query.fetch() != null) {
                                count++;
                            }
                            return count;
                        }
                    }

                    final int defaultMaxDistinctValues = 0;
                    final SeTable.SeTableStats tableStats;
                    final String statsCol = colNames.get(0);
                    tableStats = query.calculateTableStatistics(statsCol,
                            SeTable.SeTableStats.SE_COUNT_STATS, queryInfo, defaultMaxDistinctValues);

                    int actualCount = tableStats.getCount();
                    return new Integer(actualCount);
                } finally {
                    query.close();
                }
            }
        };

        final Integer count = session.issue(countCmd);
View Full Code Here


                    }
                    final SeFilter[] spatialConstraints = filters.getSpatialFilters();

                    SeExtent extent;

                    final SeQuery extentQuery = new SeQuery(connection);
                    try {
                        versioningHandler.setUpStream(session, extentQuery);

                        if (spatialConstraints.length > 0) {
                            extentQuery.setSpatialConstraints(SeQuery.SE_OPTIMIZE, false,
                                    spatialConstraints);
                        }

                        SeSqlConstruct sqlCons = new SeSqlConstruct();
                        sqlCons.setTables(fullConstruct.getTables());
                        sqlCons.setWhere(whereClause);

                        final SeQueryInfo seQueryInfo = new SeQueryInfo();
                        seQueryInfo.setColumns(queryColumns);
                        seQueryInfo.setConstruct(sqlCons);

                        extent = extentQuery.calculateLayerExtent(seQueryInfo);
                    } finally {
                        extentQuery.close();
                    }

                    return extent;
                }
            });
View Full Code Here

     * Tells the server to execute a stream operation.
     *
     * @throws IOException
     */
    public void execute() throws IOException {
        final SeQuery seQuery = getSeQuery();
        session.issue(new Command<Void>() {
            @Override
            public Void execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                seQuery.execute();
                return null;
            }
        });
    }
View Full Code Here

    public SdeRow fetch() throws IOException, IllegalStateException {
        if (this.query == null) {
            throw new IllegalStateException("query closed or not yet executed");
        }

        final SeQuery seQuery = getSeQuery();
        // commented out while SeToJTSGeometryFactory is in development
        // if (currentRow == null) {
        // GeometryFactory geomFac = new SeToJTSGeometryFactory();
        // currentRow = new SdeRow(geomFac);
        // int geometryIndex = -1;
View Full Code Here

            String[] rasterColumns) throws IOException {

        LOGGER.fine("Gathering raster attributes for " + rasterTable);
        SeRasterAttr rasterAttributes;
        LinkedList<SeRasterAttr> rasterAttList = new LinkedList<SeRasterAttr>();
        SeQuery query = null;
        try {
            query = new SeQuery(scon, rasterColumns, new SeSqlConstruct(rasterTable));
            query.prepareQuery();
            query.execute();

            SeRow row = query.fetch();
            while (row != null) {
                rasterAttributes = row.getRaster(0);
                rasterAttList.addFirst(rasterAttributes);
                row = query.fetch();
            }
        } catch (SeException se) {
            throw new ArcSdeException("Error fetching raster attributes for " + rasterTable, se);
        } finally {
            if (query != null) {
                try {
                    query.close();
                } catch (SeException e) {
                    throw new ArcSdeException(e);
                }
            }
        }
View Full Code Here

        final String auxTableName = getAuxTableName(rasterColumnId, scon);
        LOGGER.fine("Quering auxiliary table " + auxTableName + " for color map data");

        Map<Long, IndexColorModel> colorMaps = new HashMap<Long, IndexColorModel>();
        SeQuery query = null;
        try {
            SeSqlConstruct sqlConstruct = new SeSqlConstruct();
            sqlConstruct.setTables(new String[] { auxTableName });
            String whereClause = "TYPE = 3";
            sqlConstruct.setWhere(whereClause);

            query = new SeQuery(scon, new String[] { "RASTERBAND_ID", "OBJECT" }, sqlConstruct);
            query.prepareQuery();
            query.execute();

            long bandId;
            ByteArrayInputStream colorMapIS;
            DataBuffer colorMapData;
            IndexColorModel colorModel;

            SeRow row = query.fetch();
            while (row != null) {
                bandId = ((Number) row.getObject(0)).longValue();
                colorMapIS = row.getBlob(1);

                colorMapData = readColorMap(colorMapIS);
                colorModel = RasterUtils.sdeColorMapToJavaColorModel(colorMapData, bitsPerSample);

                colorMaps.put(Long.valueOf(bandId), colorModel);

                row = query.fetch();
            }
        } catch (SeException e) {
            throw new ArcSdeException("Error fetching colormap data for column " + rasterColumnId
                    + " from table " + auxTableName, e);
        } finally {
            if (query != null) {
                try {
                    query.close();
                } catch (SeException e) {
                    LOGGER.log(Level.INFO, "ignoring exception when closing query to "
                            + "fetch colormap data", e);
                }
            }
View Full Code Here

    }

    private String getAuxTableName(long rasterColumnId, SeConnection scon) throws IOException {

        final String owner;
        SeQuery query = null;
        try {
            final String dbaName = scon.getSdeDbaName();
            String rastersColumnsTable = dbaName + ".SDE_RASTER_COLUMNS";

            SeSqlConstruct sqlCons = new SeSqlConstruct(rastersColumnsTable);
            sqlCons.setWhere("RASTERCOLUMN_ID = " + rasterColumnId);

            try {
                query = new SeQuery(scon, new String[] { "OWNER" }, sqlCons);
                query.prepareQuery();
            } catch (SeException e) {
                // sde 9.3 calls it raster_columns, not sde_raster_columns...
                rastersColumnsTable = dbaName + ".RASTER_COLUMNS";
                sqlCons = new SeSqlConstruct(rastersColumnsTable);
                sqlCons.setWhere("RASTERCOLUMN_ID = " + rasterColumnId);
                query = new SeQuery(scon, new String[] { "OWNER" }, sqlCons);
                query.prepareQuery();
            }
            query.execute();

            SeRow row = query.fetch();
            if (row == null) {
                throw new IllegalArgumentException("No raster column registered with id "
                        + rasterColumnId);
            }
            owner = row.getString(0);
            query.close();
        } catch (SeException e) {
            throw new ArcSdeException("Error getting auxiliary table for raster column "
                    + rasterColumnId, e);
        } finally {
            if (query != null) {
                try {
                    query.close();
                } catch (SeException e) {
                    LOGGER.log(Level.INFO, "ignoring exception when closing query to "
                            + "fetch colormap data", e);
                }
            }
View Full Code Here

        // SeRow.SE_IS_NOT_NULL_VALUE, // child3
        // SeRow.SE_IS_REPEATED_FEATURE, // child2
        // SeRow.SE_IS_NOT_NULL_VALUE // child1
        // };

        final SeQuery query = session.issue(new Command<SeQuery>() {

            @Override
            public SeQuery execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                SeQuery query = new SeQuery(connection);
                query.prepareQueryInfo(queryInfo);
                query.execute();
                return query;
            }
        });

        try {
View Full Code Here

        final SeQueryInfo queryInfo = new SeQueryInfo();
        queryInfo.setConstruct(sqlConstruct);
        queryInfo.setColumns(propertyNames);

        final SeQuery query = session.issue(new Command<SeQuery>() {
            @Override
            public SeQuery execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                SeQuery query = new SeQuery(connection);
                query.prepareQueryInfo(queryInfo);
                query.execute();
                return query;
            }
        });

        try {
View Full Code Here

        // SeRow.SE_IS_NOT_NULL_VALUE, // child3
        // SeRow.SE_IS_REPEATED_FEATURE, // child2
        // SeRow.SE_IS_NOT_NULL_VALUE // child1
        // };

        SeQuery query = session.issue(new Command<SeQuery>() {
            @Override
            public SeQuery execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                SeQuery query = new SeQuery(connection);
                query.prepareQueryInfo(queryInfo);
                query.execute();
                return query;
            }
        });
        try {
            SdeRow row = session.fetch(query);
View Full Code Here

TOP

Related Classes of com.esri.sde.sdk.client.SeQuery

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.