Examples of SeVersion


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

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

                final SeVersion parentVersion = session.issue(new GetVersionCommand(
                        parentVersionName));
                SeVersion version = null;
                try {
                    version = session.issue(new GetVersionCommand(versionName));
                } catch (ArcSdeException e) {
                    // ignore
                }
                if (version != null) {
                    // already exists, no need to create it
                    return null;
                }

                SeVersion newVersion = new SeVersion(connection, parentVersionName);
                // newVersion.getInfo();
                newVersion.setName(versionName);
                newVersion.setOwner(session.getUser());
                newVersion.setParentName(parentVersionName);
                newVersion.setDescription(parentVersion.getName()
                        + " child for GeoTools ArcSDE unit tests");
                // do not require ArcSDE to create a unique name if the
                // required
                // version already exists
                boolean uniqueName = false;
                try {
                    newVersion.create(uniqueName, newVersion);
                    // newVersion.alter();
                    newVersion.getInfo();
                } catch (SeException e) {
                    throw new ArcSdeException(e);
                }
                return null;
            }
View Full Code Here

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

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

                final SeVersion version;
                try {
                    version = session.issue(new Commands.GetVersionCommand(versionName));
                } catch (IOException e) {
                    // version does not exist, we're ok...
                    return null;
                }

                LOGGER.fine("Deleting version " + versionName);
                version.delete();
                LOGGER.fine("Version " + versionName + " deleted!");

                return null;
            }
        });
View Full Code Here

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

    @Test
    public void testEditVersionedTable_DefaultVersion() throws Exception {
        final SeTable versionedTable = testData.createVersionedTable(session);

        // create a new version
        final SeVersion defaultVersion;
        final SeVersion newVersion;
        {
            defaultVersion = session.issue(new Commands.GetVersionCommand(
                    SeVersion.SE_QUALIFIED_DEFAULT_VERSION_NAME));

            newVersion = session.issue(new Command<SeVersion>() {

                @Override
                public SeVersion execute(ISession session, SeConnection connection)
                        throws SeException, IOException {
                    SeVersion newVersion = new SeVersion(connection,
                            SeVersion.SE_QUALIFIED_DEFAULT_VERSION_NAME);
                    // newVersion.getInfo();
                    newVersion.setName(connection.getUser() + ".GeoToolsTestVersion");
                    newVersion.setParentName(defaultVersion.getName());
                    newVersion.setDescription(defaultVersion.getName()
                            + " child for GeoTools ArcSDE unit tests");
                    // do not require ArcSDE to create a unique name if the
                    // required
                    // version already exists
                    boolean uniqueName = false;
                    try {
                        newVersion.create(uniqueName, newVersion);
                    } catch (SeException e) {
                        int sdeError = e.getSeError().getSdeError();
                        if (sdeError != -177) {
                            throw new ArcSdeException(e);
                        }
                        // "VERSION ALREADY EXISTS", ignore and continue..
                        newVersion.getInfo();
                    }
                    return newVersion;
                }
            });
        }

        // edit default version
        SeState newState1 = session.issue(new Command<SeState>() {
            @Override
            public SeState execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                SeObjectId defVersionStateId = defaultVersion.getStateId();
                SeState defVersionState = new SeState(connection, defVersionStateId);
                // create a new state as a child of the current one, the current
                // one
                // must be closed
                if (defVersionState.isOpen()) {
                    defVersionState.close();
                }
                SeState newState1 = new SeState(connection);
                newState1.create(defVersionState.getId());
                return newState1;
            }
        });

        session.startTransaction();
        testData.insertIntoVersionedTable(session, newState1, versionedTable.getName(),
                "name 1 state 1");
        testData.insertIntoVersionedTable(session, newState1, versionedTable.getName(),
                "name 2 state 1");

        final SeObjectId parentStateId = newState1.getId();
        session.close(newState1);

        final SeState newState2 = session.issue(new Command<SeState>() {
            @Override
            public SeState execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                SeState newState = new SeState(connection);
                newState.create(parentStateId);
                return newState;
            }
        });

        testData.insertIntoVersionedTable(session, newState2, versionedTable.getName(),
                "name 1 state 2");

        session.issue(new Command<Void>() {
            @Override
            public Void execute(ISession session, SeConnection connection) throws SeException,
                    IOException {
                // Change the version's state pointer to the last edit state.
                defaultVersion.changeState(newState2.getId());

                // Trim the state tree.
                newState2.trimTree(parentStateId, newState2.getId());

                return null;
            }
        });
        session.commitTransaction();

        // we edited the default version, lets query the default version and the
        // new version and assert they have the correct feature count
        final SeObjectId defaultVersionStateId = defaultVersion.getStateId();
        SeState defVersionState = session.createState(defaultVersionStateId);

        int defVersionCount = getTempTableCount(session, versionedTable.getName(), null, null,
                defVersionState);
        assertEquals(3, defVersionCount);

        SeState newVersionState = session.createState(newVersion.getStateId());
        int newVersionCount = getTempTableCount(session, versionedTable.getName(), null, null,
                newVersionState);
        assertEquals(0, newVersionCount);
    }
View Full Code Here

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

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

            final SeVersion version;
            try {
                version = new SeVersion(connection, versionName);
            } catch (SeException cause) {

                if (cause.getSeError().getSdeError() == -126) {
                    ArrayList<String> available = new ArrayList<String>();
                    try {
                        SeVersion[] versionList = connection.getVersionList(null);
                        for (SeVersion v : versionList) {
                            available.add(v.getName());
                        }
                        throw new ArcSdeException("Specified ArcSDE version does not exist: "
                                + versionName + ". Available versions are: " + available, cause);
                    } catch (SeException ignorable) {
                        // hum... ignore
                        throw new ArcSdeException("Specified ArcSDE version does not exist: "
                                + versionName, cause);
                    }
                } else {
                    throw cause;
                }
            }
            version.getInfo();
            return version;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.