Examples of StagingDatabase


Examples of org.locationtech.geogig.storage.StagingDatabase

    }

    private void applyPatch(Patch patch) {
        final WorkingTree workTree = workingTree();
        final StagingDatabase indexDb = stagingDatabase();
        if (reverse) {
            patch = patch.reversed();
        }

        List<FeatureInfo> removed = patch.getRemovedFeatures();
View Full Code Here

Examples of org.locationtech.geogig.storage.StagingDatabase

     *
     * @return a FeatureCollection with the specified features
     */
    @Override
    protected SimpleFeatureStore _call() {
        final StagingDatabase database = stagingDatabase();
        if (filterFeatureTypeId != null) {
            RevObject filterType = database.getIfPresent(filterFeatureTypeId);
            checkArgument(filterType instanceof RevFeatureType,
                    "Provided filter feature type is does not exist");
        }

        final SimpleFeatureStore targetStore = getTargetStore();

        final String refspec = resolveRefSpec();
        final String treePath = refspec.substring(refspec.indexOf(':') + 1);
        final RevTree rootTree = resolveRootTree(refspec);
        final NodeRef typeTreeRef = resolTypeTreeRef(refspec, treePath, rootTree);

        final ObjectId defaultMetadataId = typeTreeRef.getMetadataId();

        final RevTree typeTree = database.getTree(typeTreeRef.objectId());

        final ProgressListener progressListener = getProgressListener();

        progressListener.started();
        progressListener.setDescription("Exporting from " + path + " to "
View Full Code Here

Examples of org.locationtech.geogig.storage.StagingDatabase

        final RevTree currentIndexHead = getTree();

        Map<String, RevTreeBuilder> parentTress = Maps.newHashMap();
        Map<String, ObjectId> parentMetadataIds = Maps.newHashMap();
        Set<String> removedTrees = Sets.newHashSet();
        StagingDatabase database = getDatabase();
        while (unstaged.hasNext()) {
            final DiffEntry diff = unstaged.next();
            final String fullPath = diff.oldPath() == null ? diff.newPath() : diff.oldPath();
            final String parentPath = NodeRef.parentPath(fullPath);
            /*
             * TODO: revisit, ideally the list of diff entries would come with one single entry for
             * the whole removed tree instead of that one and every single children of it.
             */
            if (removedTrees.contains(parentPath)) {
                continue;
            }
            if (null == parentPath) {
                // it is the root tree that's been changed, update head and ignore anything else
                ObjectId newRoot = diff.newObjectId();
                updateStageHead(newRoot);
                progress.setProgress(100f);
                progress.complete();
                return;
            }
            RevTreeBuilder parentTree = getParentTree(currentIndexHead, parentPath, parentTress,
                    parentMetadataIds);

            i++;
            progress.setProgress((float) (i * 100) / numChanges);

            NodeRef oldObject = diff.getOldObject();
            NodeRef newObject = diff.getNewObject();
            if (newObject == null) {
                // Delete
                parentTree.remove(oldObject.name());
                if (TYPE.TREE.equals(oldObject.getType())) {
                    removedTrees.add(oldObject.path());
                }
            } else if (oldObject == null) {
                // Add
                Node node = newObject.getNode();
                parentTree.put(node);
                parentMetadataIds.put(newObject.path(), newObject.getMetadataId());
            } else {
                // Modify
                Node node = newObject.getNode();
                parentTree.put(node);
            }

            database.removeConflict(null, fullPath);
        }

        ObjectId newRootTree = currentIndexHead.getId();

        for (Map.Entry<String, RevTreeBuilder> entry : parentTress.entrySet()) {
            String changedTreePath = entry.getKey();
            RevTreeBuilder changedTreeBuilder = entry.getValue();
            RevTree changedTree = changedTreeBuilder.build();
            ObjectId parentMetadataId = parentMetadataIds.get(changedTreePath);
            if (NodeRef.ROOT.equals(changedTreePath)) {
                // root
                database.put(changedTree);
                newRootTree = changedTree.getId();
            } else {
                // parentMetadataId = parentMetadataId == null ?
                Supplier<RevTreeBuilder> rootTreeSupplier = getTreeSupplier();
                newRootTree = context.command(WriteBack.class).setAncestor(rootTreeSupplier)
View Full Code Here

Examples of org.locationtech.geogig.storage.StagingDatabase

                        new TestModule(testPlatform))).getInstance(Context.class);
    }

    @Test
    public void testConflicts() {
        StagingDatabase db = geogig.getRepository().stagingDatabase();

        List<Conflict> conflicts = db.getConflicts(null, null);
        assertTrue(conflicts.isEmpty());
        Conflict conflict = new Conflict(idP1, ObjectId.forString("ancestor"),
                ObjectId.forString("ours"), ObjectId.forString("theirs"));
        Conflict conflict2 = new Conflict(idP2,
                ObjectId.forString("ancestor2"), ObjectId.forString("ours2"),
                ObjectId.forString("theirs2"));
        db.addConflict(null, conflict);
        Optional<Conflict> returnedConflict = db.getConflict(null, idP1);
        assertTrue(returnedConflict.isPresent());
        assertEquals(conflict, returnedConflict.get());
        db.removeConflict(null, idP1);
        conflicts = db.getConflicts(null, null);
        assertTrue(conflicts.isEmpty());
        db.addConflict(null, conflict);
        db.addConflict(null, conflict2);
        assertEquals(2, db.getConflicts(null, null).size());
        db.removeConflicts(null);
        conflicts = db.getConflicts(null, null);
        assertTrue(conflicts.isEmpty());

        final String NS = "ns";
        db.addConflict(NS, conflict);
        db.addConflict(null, conflict2);
        returnedConflict = db.getConflict(NS, idP1);
        assertTrue(returnedConflict.isPresent());
        assertEquals(conflict, returnedConflict.get());
        assertEquals(1, db.getConflicts(NS, null).size());
        db.removeConflict(NS, idP1);
        conflicts = db.getConflicts(NS, null);
        assertTrue(conflicts.isEmpty());
        db.addConflict(NS, conflict);
        db.addConflict(NS, conflict2);
        assertEquals(2, db.getConflicts(NS, null).size());
        assertEquals(1, db.getConflicts(null, null).size());
        db.removeConflicts(NS);
        conflicts = db.getConflicts(NS, null);
        assertTrue(conflicts.isEmpty());
        conflicts = db.getConflicts(null, null);
        assertFalse(conflicts.isEmpty());
    }
View Full Code Here

Examples of org.locationtech.geogig.storage.StagingDatabase

        // TODO Auto-generated method stub
    }

    @Test
    public void testConflicts() {
        StagingDatabase db = geogig.getRepository().stagingDatabase();

        List<Conflict> conflicts = db.getConflicts(null, null);
        assertTrue(conflicts.isEmpty());
        Conflict conflict = new Conflict(idP1, ObjectId.forString("ancestor"),
                ObjectId.forString("ours"), ObjectId.forString("theirs"));
        Conflict conflict2 = new Conflict(idP2, ObjectId.forString("ancestor2"),
                ObjectId.forString("ours2"), ObjectId.forString("theirs2"));
        db.addConflict(null, conflict);
        Optional<Conflict> returnedConflict = db.getConflict(null, idP1);
        assertTrue(returnedConflict.isPresent());
        assertEquals(conflict, returnedConflict.get());
        db.removeConflict(null, idP1);
        conflicts = db.getConflicts(null, null);
        assertTrue(conflicts.isEmpty());
        db.addConflict(null, conflict);
        db.addConflict(null, conflict2);
        assertEquals(2, db.getConflicts(null, null).size());
        db.removeConflicts(null);
        conflicts = db.getConflicts(null, null);
        assertTrue(conflicts.isEmpty());

        final String NS = "ns";
        db.addConflict(NS, conflict);
        db.addConflict(null, conflict2);
        returnedConflict = db.getConflict(NS, idP1);
        assertTrue(returnedConflict.isPresent());
        assertEquals(conflict, returnedConflict.get());
        assertEquals(1, db.getConflicts(NS, null).size());
        db.removeConflict(NS, idP1);
        conflicts = db.getConflicts(NS, null);
        assertTrue(conflicts.isEmpty());
        db.addConflict(NS, conflict);
        db.addConflict(NS, conflict2);
        assertEquals(2, db.getConflicts(NS, null).size());
        assertEquals(1, db.getConflicts(null, null).size());
        db.removeConflicts(NS);
        conflicts = db.getConflicts(NS, null);
        assertTrue(conflicts.isEmpty());
        conflicts = db.getConflicts(null, null);
        assertFalse(conflicts.isEmpty());

    }
View Full Code Here

Examples of org.locationtech.geogig.storage.StagingDatabase

        final RevTree oldTree = getTree(oldRefSpec);
        final RevTree newTree = getTree(newRefSpec);

        DiffObjectCount diffCount;
        StagingDatabase index = stagingDatabase();
        PreOrderDiffWalk visitor = new PreOrderDiffWalk(oldTree, newTree, index, index);

        DiffCountConsumer counter = new DiffCountConsumer(index);
        PreOrderDiffWalk.Consumer filter = counter;
        if (!pathFilters.isEmpty()) {
View Full Code Here

Examples of org.locationtech.geogig.storage.StagingDatabase

        // move new blobs from the index to the repository (note: this could be parallelized)
        Supplier<Iterator<Node>> nodesToMove = asNodeSupplierOfNewContents(diffs,
                strippedPathFilters);
        command(DeepMove.class).setObjects(nodesToMove).call();

        final StagingDatabase stagingDatabase = stagingDatabase();

        final RevTree currentLeftTree = stagingDatabase.getTree(leftTreeId);

        final RevTreeBuilder builder = currentLeftTree.builder(repositoryDatabase);

        // remove the exists filter, we need to create the new trees taking into account all the
        // nodes
View Full Code Here

Examples of org.locationtech.geogig.storage.StagingDatabase

        geogig.command(RevParse.class).setRefSpec(poId1.toString() + "^{blah}").call();
    }

    @Test
    public void testResolveToMultipleIds() {
        StagingDatabase mockIndexDb = mock(StagingDatabase.class);
        Context mockCommands = mock(Context.class);
        RefParse mockRefParse = mock(RefParse.class);

        when(mockRefParse.setName(anyString())).thenReturn(mockRefParse);
        when(mockCommands.command(eq(RefParse.class))).thenReturn(mockRefParse);
        Optional<Ref> ref = Optional.absent();
        when(mockRefParse.call()).thenReturn(ref);

        List<ObjectId> oIds = Arrays.asList(ObjectId.forString("Object 1"),
                ObjectId.forString("Object 2"));
        when(mockIndexDb.lookUp(anyString())).thenReturn(oIds);
        when(mockCommands.stagingDatabase()).thenReturn(mockIndexDb);
        RevParse command = new RevParse();
        command.setContext(mockCommands);

        exception.expect(IllegalArgumentException.class);
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.