Package com.esri.sde.sdk.client

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


        String dbName = session.getDatabaseName();
        tableName = ((dbName == null || "".equals(dbName)) ? "" : (dbName + "."))
                + session.getUser() + "." + tableName;
        tableName = tableName.toUpperCase();

        SeTable table = session.getTable(tableName);
        SeLayer layer = session.getLayer(tableName);
        SeRegistration reg = session.createSeRegistration(tableName);
        fidReader = FIDReader.getFidReader(session, table, layer, reg);
        return fidReader;
    }
View Full Code Here


                final String[] typeNameParts = featureType.getTypeName().split("\\.");
                final String unqualifiedTypeName = typeNameParts[typeNameParts.length - 1];

                // Create a new SeTable/SeLayer with the specified attributes....
                SeTable table = null;
                SeLayer layer = null;

                // flag to know if the table was created by us when catching an
                // exception.
                boolean tableCreated = false;

                // table/layer creation hints information
                int rowIdType = SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_NONE;
                String rowIdColumn = null;
                String configKeyword = "DEFAULTS";
                if (hints.containsKey("configuration.keyword")) {
                    configKeyword = String.valueOf(hints.get("configuration.keyword"));
                }
                if (hints.get("rowid.column.type") instanceof String) {
                    String rowIdStr = (String) hints.get("rowid.column.type");
                    if (rowIdStr.equalsIgnoreCase("NONE")) {
                        rowIdType = SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_NONE;
                    } else if (rowIdStr.equalsIgnoreCase("USER")) {
                        rowIdType = SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_USER;
                    } else if (rowIdStr.equalsIgnoreCase("SDE")) {
                        rowIdType = SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_SDE;
                    } else {
                        throw new DataSourceException(
                                "createSchema hint 'rowid.column.type' must be one of 'NONE', 'USER' or 'SDE'");
                    }
                }
                if (hints.get("rowid.column.name") instanceof String) {
                    rowIdColumn = (String) hints.get("rowid.column.name");
                }

                // placeholder to a catched exception to know in the finally block
                // if we should cleanup the crap we left in the database
                Exception error = null;

                try {
                    // create a table with provided username
                    String qualifiedName = null;

                    if (unqualifiedTypeName.indexOf('.') == -1) {
                        // Use the already parsed name (unqualifiedTypeName)
                        qualifiedName = connection.getUser() + "." + unqualifiedTypeName; // featureType.getTypeName();
                        LOGGER.finer("new full qualified type name: " + qualifiedName);
                    } else {
                        qualifiedName = unqualifiedTypeName;
                        LOGGER.finer("full qualified type name provided by user: " + qualifiedName);
                    }

                    layer = new SeLayer(connection);
                    layer.setTableName(qualifiedName);
                    layer.setCreationKeyword(configKeyword);

                    final String HACK_COL_NAME = "gt_workaround_col_";

                    table = createSeTable(connection, qualifiedName, HACK_COL_NAME, configKeyword);
                    tableCreated = true;

                    final List<AttributeDescriptor> atts = featureType.getAttributeDescriptors();
                    AttributeDescriptor currAtt;

                    for (Iterator<AttributeDescriptor> it = atts.iterator(); it.hasNext();) {
                        currAtt = it.next();

                        if (currAtt instanceof GeometryDescriptor) {
                            GeometryDescriptor geometryAtt = (GeometryDescriptor) currAtt;
                            createSeLayer(layer, qualifiedName, geometryAtt);
                        } else {
                            LOGGER.fine("Creating column definition for " + currAtt);

                            SeColumnDefinition newCol = ArcSDEAdapter
                                    .createSeColumnDefinition(currAtt);

                            // /////////////////////////////////////////////////////////////
                            // HACK!!!!: this hack is just to avoid the error that
                            // occurs //
                            // when adding a column wich is not nillable. Need to fix
                            // this//
                            // but by now it conflicts with the requirement of creating
                            // //
                            // the schema with the correct attribute order. //
                            // /////////////////////////////////////////////////////////////
                            newCol = new SeColumnDefinition(newCol.getName(), newCol.getType(),
                                    newCol.getSize(), newCol.getScale(), true);

                            // /////////////////////////////////////////////////////////////
                            // END of horrible HACK //
                            // /////////////////////////////////////////////////////////////
                            LOGGER.fine("Adding column " + newCol.getName()
                                    + " to the actual table.");
                            table.addColumn(newCol);
                        }
                    }

                    LOGGER.fine("deleting the 'workaround' column...");
                    table.dropColumn(HACK_COL_NAME);

                    LOGGER.fine("setting up table registration with ArcSDE...");
                    SeRegistration reg = new SeRegistration(connection, table.getName());
                    if (rowIdColumn != null) {
                        LOGGER.fine("setting rowIdColumnName to " + rowIdColumn + " in table "
                                + reg.getTableName());
                        reg.setRowIdColumnName(rowIdColumn);
                        reg.setRowIdColumnType(rowIdType);
View Full Code Here

     * @throws SeException
     */
    private static SeTable createSeTable(final SeConnection connection, final String qualifiedName,
            final String hackColName, final String configKeyword) throws SeException {

        final SeTable table;
        final SeColumnDefinition[] tmpCol = new SeColumnDefinition[1];
        tmpCol[0] = new SeColumnDefinition(hackColName, SeColumnDefinition.TYPE_STRING, 4, 0, true);

        table = new SeTable(connection, qualifiedName);

        LOGGER.info("creating table " + qualifiedName);

        // create the table using DBMS default configuration keyword.
        // valid keywords are defined in the dbtune table.
        table.create(tmpCol, configKeyword);
        LOGGER.info("table " + qualifiedName + " created...");

        return table;
    }
View Full Code Here

    private String[] getRasterColumns(final SeConnection scon, final String rasterTable)
            throws IOException, SeException {

        String[] rasterColumns;
        SeTable sTable = new SeTable(scon, rasterTable);
        SeColumnDefinition[] cols;
        try {
            cols = sTable.describe();
        } catch (SeException e) {
            throw new ArcSdeException("Exception fetching the list of columns for table "
                    + rasterTable, e);
        }
        List<String> fetchColumns = new ArrayList<String>(cols.length / 2);
View Full Code Here

     * @param session
     * @throws DataSourceException
     */
    private void truncate(final String typeName, final ISession session) throws IOException {
        final boolean transactionInProgress = session.isTransactionActive();
        final SeTable table = session.getTable(typeName);
        if (transactionInProgress) {
            // need to do actual deletes, as SeTable.truncate does not respects
            // transactions and would delete all content
            LOGGER.fine("deleting all table records for " + typeName);
            final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore
                    .getFeatureWriter(typeName, transaction);
            while (writer.hasNext()) {
                writer.next();
                writer.remove();
            }
        } else {
            // we're in auto commit mode, lets truncate the table the fast way
            LOGGER.fine("truncating table " + typeName);
            session.issue(new Command<Void>() {
                @Override
                public Void execute(ISession session, SeConnection connection) throws SeException,
                        IOException {
                    table.truncate();
                    return null;
                }
            });
        }
    }
View Full Code Here

    public SeLayer getLayer(final String layerName) throws IOException {
        checkActive();
        if (!cachedLayers.containsKey(layerName)) {
            synchronized (cachedLayers) {
                if (!cachedLayers.containsKey(layerName)) {
                    SeTable table = getTable(layerName);
                    SeLayer layer = issue(new Commands.GetLayerCommand(table));
                    if (layer != null) {
                        cachedLayers.put(layerName, layer);
                    }
                }
View Full Code Here

    public SeTable getTable(final String tableName) throws IOException {
        checkActive();
        if (!cachedTables.containsKey(tableName)) {
            synchronized (cachedTables) {
                if (!cachedTables.containsKey(tableName)) {
                    SeTable table = issue(new Commands.GetTableCommand(tableName));
                    cachedTables.put(tableName, table);
                }
            }
        }

        SeTable seTable = (SeTable) cachedTables.get(tableName);

        return seTable;
    }
View Full Code Here

    /**
     * @see ISession#describe(java.lang.String)
     */
    public SeColumnDefinition[] describe(final String tableName) throws IOException {
        final SeTable table = getTable(tableName);
        return describe(table);
    }
View Full Code Here

            @Override
            public Void execute(ISession session, SeConnection connection) throws SeException,
                    IOException {

                SeLayer layer = new SeLayer(connection);
                SeTable table = null;

                /*
                 * Create a qualified table name with current user's name and the name of the table
                 * to be created, "EXAMPLE".
                 */
                String tableName = (connection.getUser() + ".EXAMPLE");
                table = new SeTable(connection, tableName);
                layer.setTableName("EXAMPLE");

                try {
                    table.delete();
                } catch (Exception e) {
                    LOGGER.warning(e.getMessage());
                }

                /*
                 * Create the table using the DBMS default configuration keyword. Valid keywords are
                 * defined in the dbtune table.
                 */
                if (LOGGER.isLoggable(Level.FINE)) {
                    LOGGER.fine("\n--> Creating a table using DBMS Default Keyword");
                }
                table.create(colDefs, testData.getConfigKeyword());
                if (LOGGER.isLoggable(Level.FINE)) {
                    LOGGER.fine(" - Done.");
                }
                /*
                 * Define the attributes of the spatial column
View Full Code Here

                /*
                 * Create a qualified table name with current user's name and the name of the table
                 * to be created, "EXAMPLE".
                 */
                final String tableName = (connection.getUser() + ".NOTENDSWITHGEOM");
                final SeTable table = new SeTable(connection, tableName);
                try {
                    layer.setTableName("NOTENDSWITHGEOM");

                    try {
                        table.delete();
                    } catch (Exception e) {
                        // intentionally blank
                    }

                    /*
                     * Create the table using the DBMS default configuration keyword. Valid keywords
                     * are defined in the dbtune table.
                     */
                    if (LOGGER.isLoggable(Level.FINE)) {
                        System.out.println("\n--> Creating a table using DBMS Default Keyword");
                    }
                    SeColumnDefinition[] tmpCols = new SeColumnDefinition[] { new SeColumnDefinition(
                            "tmp", SeColumnDefinition.TYPE_STRING, 5, 0, true) };
                    table.create(tmpCols, testData.getConfigKeyword());
                    if (LOGGER.isLoggable(Level.FINE)) {
                        System.out.println(" - Done.");
                    }
                    SeColumnDefinition[] colDefs = new SeColumnDefinition[7];

                    /*
                     * Define the columns and their attributes for the table to be created. NOTE:
                     * The valid range/values of size and scale parameters vary from one database to
                     * another.
                     */
                    boolean isNullable = true;
                    colDefs[0] = new SeColumnDefinition("INT32_COL",
                            SeColumnDefinition.TYPE_INTEGER, 10, 0, isNullable);
                    colDefs[1] = new SeColumnDefinition("INT16_COL",
                            SeColumnDefinition.TYPE_SMALLINT, 4, 0, isNullable);
                    colDefs[2] = new SeColumnDefinition("FLOAT32_COL",
                            SeColumnDefinition.TYPE_FLOAT, 5, 2, isNullable);
                    colDefs[3] = new SeColumnDefinition("FLOAT64_COL",
                            SeColumnDefinition.TYPE_DOUBLE, 15, 4, isNullable);
                    colDefs[4] = new SeColumnDefinition("STRING_COL",
                            SeColumnDefinition.TYPE_STRING, 25, 0, isNullable);
                    colDefs[5] = new SeColumnDefinition("DATE_COL", SeColumnDefinition.TYPE_DATE,
                            1, 0, isNullable);
                    colDefs[6] = new SeColumnDefinition("INT64_COL",
                            SeColumnDefinition.TYPE_INTEGER, 10, 0, isNullable);

                    table.addColumn(colDefs[0]);
                    table.addColumn(colDefs[1]);
                    table.addColumn(colDefs[2]);
                    table.addColumn(colDefs[3]);
                    table.dropColumn(tmpCols[0].getName());

                    /*
                     * Define the attributes of the spatial column
                     */
                    layer.setSpatialColumnName("SHAPE");

                    /*
                     * Set the type of shapes that can be inserted into the layer. Shape type can be
                     * just one or many. NOTE: Layers that contain more than one shape type can only
                     * be accessed through the C and Java APIs and Arc Explorer Java 3.x. They
                     * cannot be seen from ArcGIS desktop applications.
                     */
                    layer.setShapeTypes(SeLayer.SE_NIL_TYPE_MASK | SeLayer.SE_POINT_TYPE_MASK
                            | SeLayer.SE_LINE_TYPE_MASK | SeLayer.SE_SIMPLE_LINE_TYPE_MASK
                            | SeLayer.SE_AREA_TYPE_MASK | SeLayer.SE_MULTIPART_TYPE_MASK);
                    layer.setGridSizes(1100.0, 0.0, 0.0);
                    layer.setDescription("Layer Example");

                    SeExtent ext = new SeExtent(0.0, 0.0, 10000.0, 10000.0);
                    layer.setExtent(ext);

                    /*
                     * Define the layer's Coordinate Reference
                     */
                    SeCoordinateReference coordref = new SeCoordinateReference();
                    coordref.setXY(0D, 0D, 100D);
                    layer.setCoordRef(coordref);

                    /*
                     * Spatially enable the new table...
                     */
                    if (LOGGER.isLoggable(Level.FINE)) {
                        LOGGER.fine("\n--> Adding spatial column \"SHAPE\"...");
                    }
                    layer.setCreationKeyword(testData.getConfigKeyword());

                    layer.create(3, 4);
                    if (LOGGER.isLoggable(Level.FINE)) {
                        LOGGER.fine(" - Done.");
                    }

                    table.addColumn(colDefs[4]);
                    table.addColumn(colDefs[5]);
                    table.addColumn(colDefs[6]);
                    // } catch (SeException e) {
                    // LOGGER.throwing(this.getClass().getName(),
                    // "testCreateNonStandardSchema", e);
                    // throw e;
                } finally {
                    try {
                        table.delete();
                    } catch (Exception e) {
                        // intentionally blank
                    }

                    try {
View Full Code Here

TOP

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

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.