Examples of GeogigTransaction


Examples of org.locationtech.geogig.api.GeogigTransaction

     * @param context - the context to get the information needed to get the commandLocator
     * @return
     */
    public Context getCommandLocator(CommandContext context) {
        if (transactionId != null) {
            return new GeogigTransaction(context.getGeoGIG().getContext(), transactionId);
        }
        return context.getGeoGIG().getContext();
    }
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

        }

        public Optional<UUID> getTransactionId() {
            Context context = command.command.context();
            if (context instanceof GeogigTransaction) {
                GeogigTransaction tx = (GeogigTransaction) context;
                UUID txId = tx.getTransactionId();
                return Optional.of(txId);
            }
            return Optional.absent();
        }
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

    public void createSchema(SimpleFeatureType featureType) throws IOException {
        if (!allowTransactions) {
            throw new IllegalStateException("Configured head " + refspec
                    + " is not a branch; transactions are not supported.");
        }
        GeogigTransaction tx = getCommandLocator(null).command(TransactionBegin.class).call();
        boolean abort = false;
        try {
            String treePath = featureType.getName().getLocalPart();
            // check out the datastore branch on the transaction space
            final String branch = getOrFigureOutBranch();
            tx.command(CheckoutOp.class).setForce(true).setSource(branch).call();
            // now we can use the transaction working tree with the correct branch checked out
            WorkingTree workingTree = tx.workingTree();
            workingTree.createTypeTree(treePath, featureType);
            tx.command(AddOp.class).addPattern(treePath).call();
            tx.command(CommitOp.class).setMessage("Created feature type tree " + treePath).call();
            tx.commit();
        } catch (IllegalArgumentException alreadyExists) {
            abort = true;
            throw new IOException(alreadyExists.getMessage(), alreadyExists);
        } catch (Exception e) {
            abort = true;
            throw Throwables.propagate(e);
        } finally {
            if (abort) {
                tx.abort();
            }
        }
    }
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

        Form options = getRequest().getResourceRef().getQueryAsForm();
        String txId = options.getFirstValue("transactionId");
        if (txId != null) {
            UUID transactionId = UUID.fromString(txId);
            GeogigTransaction tx = new GeogigTransaction(geogigContext, transactionId);
            geogigContext = tx;
        }
        return geogigContext;
    }
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

    @Override
    protected GeogigTransaction _call() {
        Preconditions.checkState(!(context instanceof GeogigTransaction),
                "Cannot start a new transaction within a transaction!");

        GeogigTransaction t = new GeogigTransaction(context, UUID.randomUUID());

        // Lock the repository
        try {
            refDatabase().lock();
        } catch (TimeoutException e) {
            Throwables.propagate(e);
        }
        try {
            // Copy original refs
            t.create();
        } finally {
            // Unlock the repository
            refDatabase().unlock();
        }
        // Return the transaction
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

                "The specified bounding box is not correct");

        osmAPIUrl = resolveAPIURL();

        Optional<OSMReport> report;
        GeogigTransaction tx = geogig.command(TransactionBegin.class).call();
        try {
            AbstractGeoGigOp<Optional<OSMReport>> cmd;
            if (update) {
                cmd = tx.command(OSMUpdateOp.class).setAPIUrl(osmAPIUrl).setRebase(rebase)
                        .setMessage(message).setProgressListener(cli.getProgressListener());
            } else {
                cmd = tx.command(OSMDownloadOp.class).setBbox(bbox).setFilterFile(filterFile)
                        .setKeepFiles(keepFiles).setMessage(message).setMappingFile(mappingFile)
                        .setOsmAPIUrl(osmAPIUrl).setSaveFile(saveFile)
                        .setProgressListener(cli.getProgressListener());
            }
            report = cmd.call();
            tx.commit();
        } catch (RuntimeException e) {
            tx.abort();
            if (e instanceof NothingToCommitException) {
                throw new CommandFailedException(e.getMessage(), e);
            }
            throw e;
        }
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

        RevCommit commit = geogig.command(CommitOp.class).call();
        expectedMain.addFirst(commit);
        expectedTransaction.addFirst(commit);

        // start a transaction
        GeogigTransaction t = geogig.command(TransactionBegin.class).call();

        // perform a commit in the transaction
        insertAndAdd(t, points2);
        commit = t.command(CommitOp.class).call();
        expectedTransaction.addFirst(commit);

        // Verify that the base repository is unchanged
        Iterator<RevCommit> logs = geogig.command(LogOp.class).call();
        List<RevCommit> logged = new ArrayList<RevCommit>();
        for (; logs.hasNext();) {
            logged.add(logs.next());
        }

        assertEquals(expectedMain, logged);

        // Verify that the transaction has the commit
        logs = t.command(LogOp.class).call();
        logged = new ArrayList<RevCommit>();
        for (; logs.hasNext();) {
            logged.add(logs.next());
        }
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

        RevCommit firstCommit = geogig.command(CommitOp.class).call();
        expectedMain.addFirst(firstCommit);
        expectedTransaction.addFirst(firstCommit);

        // start a transaction
        GeogigTransaction t = geogig.command(TransactionBegin.class).call();

        // perform a commit in the transaction
        insertAndAdd(t, points2);
        RevCommit transactionCommit = t.command(CommitOp.class).call();
        expectedTransaction.addFirst(transactionCommit);

        // perform a commit on the repo
        insertAndAdd(points3);
        RevCommit repoCommit = geogig.command(CommitOp.class).call();
        expectedMain.addFirst(repoCommit);

        // Verify that the base repository is unchanged
        Iterator<RevCommit> logs = geogig.command(LogOp.class).call();
        List<RevCommit> logged = new ArrayList<RevCommit>();
        for (; logs.hasNext();) {
            logged.add(logs.next());
        }

        assertEquals(expectedMain, logged);

        // Verify that the transaction has the commit
        logs = t.command(LogOp.class).call();
        logged = new ArrayList<RevCommit>();
        for (; logs.hasNext();) {
            logged.add(logs.next());
        }
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

        RevCommit firstCommit = geogig.command(CommitOp.class).call();
        expectedMain.addFirst(firstCommit);
        expectedTransaction.addFirst(firstCommit);

        // start a transaction
        GeogigTransaction t = geogig.command(TransactionBegin.class).call();

        t.setAuthor("Transaction Author", "transaction@author.com");

        // perform a commit in the transaction
        insertAndAdd(t, points2);
        RevCommit transactionCommit = t.command(CommitOp.class).call();
        expectedTransaction.addFirst(transactionCommit);

        // perform a commit on the repo
        insertAndAdd(points3);
        RevCommit repoCommit = geogig.command(CommitOp.class).call();
        expectedMain.addFirst(repoCommit);

        // Verify that the base repository is unchanged
        Iterator<RevCommit> logs = geogig.command(LogOp.class).call();
        List<RevCommit> logged = new ArrayList<RevCommit>();
        for (; logs.hasNext();) {
            logged.add(logs.next());
        }

        assertEquals(expectedMain, logged);

        // Verify that the transaction has the commit
        logs = t.command(LogOp.class).call();
        logged = new ArrayList<RevCommit>();
        for (; logs.hasNext();) {
            logged.add(logs.next());
        }

        assertEquals(expectedTransaction, logged);

        // Commit the transaction
        t.commitSyncTransaction();

        // Verify that a merge commit was created
        logs = geogig.command(LogOp.class).call();
        RevCommit lastCommit = logs.next();
        assertFalse(lastCommit.equals(repoCommit));
View Full Code Here

Examples of org.locationtech.geogig.api.GeogigTransaction

        // make a commit
        insertAndAdd(points1);
        RevCommit mainCommit = geogig.command(CommitOp.class).setMessage("Commit1").call();

        // start the first transaction
        GeogigTransaction transaction1 = geogig.command(TransactionBegin.class).call();

        // perform a commit in the transaction
        insertAndAdd(transaction1, points2);
        RevCommit transaction1Commit = transaction1.command(CommitOp.class).setMessage("Commit2")
                .call();

        // Verify that the base repository is unchanged
        Iterator<RevCommit> logs = geogig.command(LogOp.class).call();
        assertEquals(mainCommit, logs.next());
        assertFalse(logs.hasNext());

        // Verify that the transaction has the commit
        logs = transaction1.command(LogOp.class).call();
        assertEquals(transaction1Commit, logs.next());
        assertEquals(mainCommit, logs.next());
        assertFalse(logs.hasNext());

        // start the second transaction
        GeogigTransaction transaction2 = geogig.command(TransactionBegin.class).call();

        // perform a commit in the transaction
        insertAndAdd(transaction2, points3);
        RevCommit transaction2Commit = transaction2.command(CommitOp.class).setMessage("Commit3")
                .call();

        // Verify that the base repository is unchanged
        logs = geogig.command(LogOp.class).call();
        assertEquals(mainCommit, logs.next());
        assertFalse(logs.hasNext());

        // Verify that the transaction has the commit
        logs = transaction2.command(LogOp.class).call();
        assertEquals(transaction2Commit, logs.next());
        assertEquals(mainCommit, logs.next());
        assertFalse(logs.hasNext());

        // Commit the first transaction
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.