Package com.esri.sde.sdk.client

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


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

                final SeInsert insertStream = (SeInsert) createStream(SeInsert.class);
                Number newId = null;

                try {
                    final SeRow row;

                    // ensure we get the next sequence id when the fid is user managed
                    // and include it in the attributes to set
                    if (fidReader instanceof FIDReader.UserManagedFidReader) {
                        newId = getNextAvailableUserManagedId();
                        if (newId == null) {
                            LOGGER.finest("There seems not to be a sequence"
                                    + " for the table, not setting a generated id, "
                                    + "user ought to be taking care of it");
                            newId = (Number) newFeature.getAttribute(fidReader.getColumnIndex());
                        } else {
                            final int rowIdIndex = fidReader.getColumnIndex();
                            newFeature.setAttribute(rowIdIndex, newId);
                        }
                    }
                    String[] rowColumnNames = new ArrayList<String>(insertColumns.values())
                            .toArray(new String[0]);
                    String typeName = featureType.getTypeName();
                    insertStream.intoTable(typeName, rowColumnNames);
                    insertStream.setWriteMode(true);
                    row = insertStream.getRowToSet();

                    setRowProperties(newFeature, seCoordRef, insertColumns, row);
                    insertStream.execute();

                    if (fidReader instanceof FIDReader.SdeManagedFidReader) {
                        SeObjectId newRowId = insertStream.lastInsertedRowId();
                        newId = Long.valueOf(newRowId.longValue());
                    }

                    insertStream.flushBufferedWrites(); // jg: my customer wanted this uncommented
                    versionHandler.editOperationWritten(insertStream);
                } catch (Exception e) {
                    versionHandler.editOperationFailed(insertStream);
                    if (e instanceof SeException) {
                        throw (SeException) e;
                    } else if (e instanceof IOException) {
                        throw (IOException) e;
                    }
                    throw new DataSourceException(e);
                }
                insertStream.close();
                return newId;
            }
        };

        final Number newId;
View Full Code Here


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

                SeInsert insert = new SeInsert(connection);
                insert.intoTable(layer.getName(), columns);
                insert.setWriteMode(true);

                Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                // Year, month, date, hour, minute, second.
                cal.set(2004, 06, 1, 0, 0, 0);

                try {
                    for (int i = 1; i <= shapes.length; i++) {
                        SeRow row = insert.getRowToSet();
                        // col #0 is the sde managed row id
                        row.setInteger(0, Integer.valueOf(i));
                        row.setShort(1, Short.valueOf((short) i));
                        row.setFloat(2, new Float(i / 10.0F));
                        row.setDouble(3, new Double(i / 10D));
                        row.setString(4, "FEATURE_" + i);
                        row.setNString(5, "NSTRING_" + i);
                        cal.set(Calendar.DAY_OF_MONTH, i);
                        row.setTime(6, cal);
                        SeShape seShape = shapes[i - 1];
                        row.setShape(7, seShape);

                        insert.execute();
                    }
                } finally {
                    insert.close();
                }
                return null;
            }
        };
View Full Code Here

        session.issue(new Command<Void>() {

            @Override
            public Void execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                final SeInsert insert = new SeInsert(connection);
                SeObjectId differencesId = new SeObjectId(SeState.SE_NULL_STATE_ID);
                insert.setState(state.getId(), differencesId, SeState.SE_STATE_DIFF_NOCHECK);

                insert.intoTable(tableName, new String[] { "NAME" });
                SeRow row = insert.getRowToSet();
                row.setString(0, "NAME 1");
                insert.execute();
                insert.close();
                return null;
            }
        });
    }
View Full Code Here

            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);
View Full Code Here

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

                SeInsert insert = new SeInsert(connection);
                insert.intoTable(layer.getName(), columns);
                insert.setWriteMode(true);

                try {
                    for (int i = 0; i < shapes.length; i++) {
                        SeRow row = insert.getRowToSet();
                        row.setClob(0, new ByteArrayInputStream(strings[i]));

                        SeShape seShape = shapes[i];
                        row.setShape(tempTableColumns.length - 1, seShape);

                        insert.execute();
                    }
                } finally {
                    insert.close();
                }
                return null;
            }
        };
View Full Code Here

        Command<Void> insertCmd = new Command<Void>() {

            @Override
            public Void execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                SeInsert insert = null;
                SeCoordinateReference coordref = layer.getCoordRef();
                final String[] columns = { "ID", "NAME", "SHAPE" };

                for (int i = 1; i < 4; i++) {
                    insert = new SeInsert(connection);
                    insert.intoTable(layer.getName(), columns);
                    insert.setWriteMode(true);

                    SeRow row = insert.getRowToSet();
                    SeShape shape = new SeShape(coordref);
                    SDEPoint[] points = { new SDEPoint(i, i) };
                    shape.generatePoint(1, points);

                    row.setInteger(0, Integer.valueOf(i));
                    row.setString(1, "name" + i);
                    row.setShape(2, shape);
                    insert.execute();
                    insert.close();
                }
                return null;
            }
        };
View Full Code Here

                for (int master = 1; master < 4; master++) {
                    for (int child = 0; child < master; child++) {
                        childId++;

                        SeInsert insert = new SeInsert(connection);
                        insert.intoTable(table.getName(), columns);
                        insert.setWriteMode(true);

                        SeRow row = insert.getRowToSet();

                        row.setInteger(0, Integer.valueOf(childId));
                        row.setInteger(1, Integer.valueOf(master));
                        row.setString(2, "child" + (childId));
                        row.setString(3, "description" + (childId));
                        insert.execute();
                        // insert.close();
                    }
                }
                // add the 7th row to test group by
                SeInsert insert = new SeInsert(connection);
                insert.intoTable(table.getName(), columns);
                insert.setWriteMode(true);
                SeRow row = insert.getRowToSet();

                row.setInteger(0, new Integer(7));
                row.setInteger(1, new Integer(3));
                row.setString(2, "child6");
                row.setString(3, "description7");
                insert.execute();
                // insert.close();
                return null;
            }
        };
        session.issue(insertCmd);
View Full Code Here

TOP

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

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.