Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.ObjectId


    }

    @Test
    public void testRevertModifiedFeatureConflictSolveAndContinue() throws Exception {
        ObjectId oId1 = insertAndAdd(points1);
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        insertAndAdd(points1_modified);
        RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1)
                .call();
        Feature points1_modifiedB = feature(pointsType, idP1, "StringProp1_2", new Integer(2000),
View Full Code Here


        insertAndAdd(points1_modified);
        RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1)
                .call();
        Feature points1_modifiedB = feature(pointsType, idP1, "StringProp1_2", new Integer(2000),
                "POINT(1 1)");
        ObjectId oId = insertAndAdd(points1_modifiedB);
        RevCommit c3 = geogig.command(CommitOp.class)
                .setMessage("commit for modified " + idP1 + " again").call();
        try {
            geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).call();
            fail();
View Full Code Here

    @Test
    public void testParseHeadParentIndex() {
        // sanity check first
        assertEquals(mergeCommit.getId(), masterCommit4.getParentIds().get(0));

        ObjectId expected;

        expected = masterCommit4.parentN(0).get();
        assertParsed(expected, revParse("HEAD^"));
        assertParsed(expected, revParse("HEAD^1"));
        assertAbsent(revParse("HEAD^2"));
View Full Code Here

    /**
     * Inserts the Feature to the index and stages it to be committed.
     */
    public ObjectId insertAndAdd(GeogigTransaction transaction, Feature f) throws Exception {
        ObjectId objectId = insert(transaction, f);

        if (transaction != null) {
            transaction.command(AddOp.class).call();
        } else {
            geogig.command(AddOp.class).call();
View Full Code Here

        final WorkingTree workTree = (transaction != null ? transaction.workingTree() : repo
                .workingTree());
        Name name = f.getType().getName();
        String parentPath = name.getLocalPart();
        Node ref = workTree.insert(parentPath, f);
        ObjectId objectId = ref.getObjectId();
        return objectId;
    }
View Full Code Here

            fail("expected NothingToCommitException");
        } catch (NothingToCommitException e) {
            assertTrue(true);
        }

        ObjectId oid1 = insertAndAdd(points1);

        ObjectId oid2 = insertAndAdd(points2);

        geogig.command(AddOp.class).addPattern(".").call();
        RevCommit commit = geogig.command(CommitOp.class).call();
        assertNotNull(commit);
        assertNotNull(commit.getParentIds());
        assertEquals(0, commit.getParentIds().size());
        assertFalse(commit.parentN(0).isPresent());
        assertNotNull(commit.getId());
        assertEquals("groldan", commit.getAuthor().getName().get());
        assertEquals("groldan@boundlessgeo.com", commit.getAuthor().getEmail().get());

        ObjectId treeId = commit.getTreeId();

        assertNotNull(treeId);
        RevTree root = repo.getTree(treeId);
        assertNotNull(root);

        Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
        assertTrue(typeTreeId.isPresent());

        RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
        assertNotNull(typeTree);

        String featureId = points1.getIdentifier().getID();

        String path = NodeRef.appendChild(pointsName, featureId);
        Optional<Node> featureBlobId = repo.getTreeChild(root, path);
        assertTrue(featureBlobId.isPresent());
        assertEquals(oid1, featureBlobId.get().getObjectId());

        featureId = points2.getIdentifier().getID();
        featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
        assertTrue(featureBlobId.isPresent());
        assertEquals(oid2, featureBlobId.get().getObjectId());

        ObjectId commitId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call().get();
        assertEquals(commit.getId(), commitId);
    }
View Full Code Here

    }

    @Test
    public void testCommitAddsFeatureTypeToObjectDatabase() throws Exception {
        insertAndAdd(points1);
        ObjectId id = RevFeatureTypeImpl.build(pointsType).getId();
        geogig.command(AddOp.class).addPattern(".").call();
        RevCommit commit = geogig.command(CommitOp.class).call();
        assertNotNull(commit);
        RevFeatureType type = geogig.getRepository().objectDatabase().getFeatureType(id);
        assertEquals(id, type.getId());
View Full Code Here

    @Test
    public void testMultipleCommits() throws Exception {

        // insert and commit points1
        final ObjectId oId1_1 = insertAndAdd(points1);

        geogig.command(AddOp.class).call();
        final RevCommit commit1 = geogig.command(CommitOp.class).call();
        {
            assertCommit(commit1, null, null, null);
            // check points1 is there
            assertEquals(oId1_1, repo.getRootTreeChild(appendChild(pointsName, idP1)).get()
                    .getObjectId());
            // and check the objects were actually copied
            assertNotNull(repo.objectDatabase().get(oId1_1));
        }
        // insert and commit points2, points3 and lines1
        final ObjectId oId1_2 = insertAndAdd(points2);
        final ObjectId oId1_3 = insertAndAdd(points3);
        final ObjectId oId2_1 = insertAndAdd(lines1);

        geogig.command(AddOp.class).call();
        final RevCommit commit2 = geogig.command(CommitOp.class).setMessage("msg").call();
        {
            assertCommit(commit2, commit1.getId(), "groldan", "msg");

            // repo.getHeadTree().accept(
            // new PrintVisitor(repo.objectDatabase(), new PrintWriter(System.out)));

            // check points2, points3 and lines1
            assertEquals(oId1_2, repo.getRootTreeChild(appendChild(pointsName, idP2)).get()
                    .getObjectId());
            assertEquals(oId1_3, repo.getRootTreeChild(appendChild(pointsName, idP3)).get()
                    .getObjectId());
            assertEquals(oId2_1, repo.getRootTreeChild(appendChild(linesName, idL1)).get()
                    .getObjectId());
            // and check the objects were actually copied
            assertNotNull(repo.objectDatabase().get(oId1_2));
            assertNotNull(repo.objectDatabase().get(oId1_3));
            assertNotNull(repo.objectDatabase().get(oId2_1));

            // as well as feature1_1 from the previous commit
            assertEquals(oId1_1, repo.getRootTreeChild(appendChild(pointsName, idP1)).get()
                    .getObjectId());
        }
        // delete feature1_1, feature1_3, and feature2_1
        assertTrue(deleteAndAdd(points1));
        assertTrue(deleteAndAdd(points3));
        assertTrue(deleteAndAdd(lines1));
        // and insert feature2_2
        final ObjectId oId2_2 = insertAndAdd(lines2);

        geogig.command(AddOp.class).call();
        final RevCommit commit3 = geogig.command(CommitOp.class).call();
        {
            assertCommit(commit3, commit2.getId(), "groldan", null);
View Full Code Here

            fail("expected NothingToCommitException");
        } catch (NothingToCommitException e) {
            assertTrue(true);
        }

        ObjectId oid1 = insertAndAdd(points1);

        ObjectId oid2 = insertAndAdd(points2);

        geogig.command(AddOp.class).addPattern(".").call();
        CommitOp commitCommand = geogig.command(CommitOp.class);
        commitCommand.setAuthor("John Doe", "John@Doe.com");
        commitCommand.setCommitter("Jane Doe", "Jane@Doe.com");
        RevCommit commit = commitCommand.call();
        assertNotNull(commit);
        assertNotNull(commit.getParentIds());
        assertEquals(0, commit.getParentIds().size());
        assertFalse(commit.parentN(0).isPresent());
        assertNotNull(commit.getId());
        assertEquals("John Doe", commit.getAuthor().getName().get());
        assertEquals("John@Doe.com", commit.getAuthor().getEmail().get());
        assertEquals("Jane Doe", commit.getCommitter().getName().get());
        assertEquals("Jane@Doe.com", commit.getCommitter().getEmail().get());

        ObjectId treeId = commit.getTreeId();

        assertNotNull(treeId);
        RevTree root = repo.getTree(treeId);
        assertNotNull(root);

        Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
        assertTrue(typeTreeId.isPresent());

        RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
        assertNotNull(typeTree);

        String featureId = points1.getIdentifier().getID();
        Optional<Node> featureBlobId = repo.getTreeChild(root,
                NodeRef.appendChild(pointsName, featureId));
        assertTrue(featureBlobId.isPresent());
        assertEquals(oid1, featureBlobId.get().getObjectId());

        featureId = points2.getIdentifier().getID();
        featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
        assertTrue(featureBlobId.isPresent());
        assertEquals(oid2, featureBlobId.get().getObjectId());

        ObjectId commitId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call().get();
        assertEquals(commit.getId(), commitId);
    }
View Full Code Here

        insertAndAdd(points1);

        geogig.command(AddOp.class).addPattern(".").call();
        RevCommit commit = geogig.command(CommitOp.class).call();

        ObjectId oid = insertAndAdd(points1_modified);

        CommitOp commitCommand = geogig.command(CommitOp.class);
        commit = commitCommand.setAll(true).call();
        assertNotNull(commit);
        assertNotNull(commit.getParentIds());
        assertEquals(1, commit.getParentIds().size());
        assertNotNull(commit.getId());

        ObjectId treeId = commit.getTreeId();

        assertNotNull(treeId);
        RevTree root = repo.getTree(treeId);
        assertNotNull(root);

        Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
        assertTrue(typeTreeId.isPresent());

        RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
        assertNotNull(typeTree);

        String featureId = points1.getIdentifier().getID();
        Optional<Node> featureBlobId = repo.getTreeChild(root,
                NodeRef.appendChild(pointsName, featureId));
        assertTrue(featureBlobId.isPresent());
        assertEquals(oid, featureBlobId.get().getObjectId());

        ObjectId commitId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call().get();
        assertEquals(commit.getId(), commitId);
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.ObjectId

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.