patch.addRemovedFeature(fullPath, revFeature, revFeatureType); } else { patch.addAddedFeature(fullPath, revFeature, revFeatureType);
patch.addRemovedFeature(fullPath, revFeature, revFeatureType); } else { patch.addAddedFeature(fullPath, revFeature, revFeatureType);
obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (obj.isPresent()) { toReject.addAddedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache)); } else { toApply.addAddedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache));
patch.addAddedFeature(name, (RevFeature) revObject, featureType); } else if (revObject instanceof RevTree) { ObjectId metadataId = diffEntry.getNewObject().getMetadataId();
obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (obj.isPresent()) { toReject.addAddedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache)); } else { toApply.addAddedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache));
patch.addAddedFeature(name, (RevFeature) revObject, featureType); } else if (revObject instanceof RevTree) { ObjectId metadataId = diffEntry.getNewObject().getMetadataId();
@Test public void testAddFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeatureBuilder.build(points1), RevFeatureTypeBuilder.build(pointsType)); testPatch(patch); }
@Test public void testAddFeatureWithNonDefaultFeatureType() throws Exception { insert(points2, points3); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeatureBuilder.build(points1B), RevFeatureTypeBuilder.build(modifiedPointsType)); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTreeId = findTreeChild(root, pointsName); assertEquals(typeTreeId.get().getMetadataId().get(), RevFeatureTypeBuilder.build(pointsType).getId()); RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId()); assertNotNull(typeTree); Optional<Node> featureBlobId = findTreeChild(root, path); assertEquals(RevFeatureTypeBuilder.build(modifiedPointsType).getId(), featureBlobId.get().getMetadataId().orNull()); assertTrue(featureBlobId.isPresent()); path = NodeRef.appendChild(pointsName, points3.getIdentifier().getID()); featureBlobId = findTreeChild(root, path); assertEquals(null, featureBlobId.get().getMetadataId().orNull()); }
@Test public void testAddFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeature.builder().build(points1), RevFeatureType.builder().type(pointsType).build()); testPatch(patch); }
@Test public void testAddFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeatureBuilder.build(points1), RevFeatureTypeBuilder.build(pointsType)); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTreeId = findTreeChild(root, pointsName); RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId()); assertNotNull(typeTree); Optional<Node> featureBlobId = findTreeChild(root, path); assertTrue(featureBlobId.isPresent()); }
@Test public void testAddFeatureWithNonDefaultFeatureType() throws Exception { insert(points2, points3); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeature.builder().build(points1B), RevFeatureType.builder().type(modifiedPointsType).build()); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTreeId = findTreeChild(root, pointsName); assertEquals(typeTreeId.get().getMetadataId().get(), RevFeatureType.builder().type(pointsType).build().getId()); RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId()); assertNotNull(typeTree); Optional<Node> featureBlobId = findTreeChild(root, path); assertEquals(RevFeatureType.builder().type(modifiedPointsType).build().getId(), featureBlobId.get().getMetadataId().orNull()); assertTrue(featureBlobId.isPresent()); path = NodeRef.appendChild(pointsName, points3.getIdentifier().getID()); featureBlobId = findTreeChild(root, path); assertEquals(null, featureBlobId.get().getMetadataId().orNull()); }
@Test public void testAddFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeature.builder().build(points1), RevFeatureType.builder().type(pointsType).build()); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTreeId = findTreeChild(root, pointsName); RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId()); assertNotNull(typeTree); Optional<Node> featureBlobId = findTreeChild(root, path); assertTrue(featureBlobId.isPresent()); }
@Test public void testAddedFeatureExists() throws Exception { insert(points1); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeatureBuilder.build(points1), RevFeatureTypeBuilder.build(pointsType)); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testReversedPatch() throws Exception { insert(points1, points2); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1.getProperty("sp").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, "new"); map.put(pointsType.getDescriptor("sp"), diff); FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(pointsType), RevFeatureTypeBuilder.build(pointsType)); patch.addModifiedFeature(feaureDiff); String removedPath = NodeRef.appendChild(pointsName, points2.getIdentifier().getID()); patch.addRemovedFeature(removedPath, RevFeatureBuilder.build(points2), RevFeatureTypeBuilder.build(pointsType)); String addedPath = NodeRef.appendChild(pointsName, points3.getIdentifier().getID()); patch.addAddedFeature(addedPath, RevFeatureBuilder.build(points3), RevFeatureTypeBuilder.build(pointsType)); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); geogig.command(ApplyPatchOp.class).setPatch(patch.reversed()).call(); RevTree root = repo.workingTree().getTree(); Optional<Node> featureBlobId = findTreeChild(root, removedPath); assertTrue(featureBlobId.isPresent()); featureBlobId = findTreeChild(root, addedPath); assertFalse(featureBlobId.isPresent()); Optional<RevFeature> feature = geogig.command(RevObjectParse.class) .setRefSpec("WORK_HEAD:" + path).call(RevFeature.class); assertTrue(feature.isPresent()); assertEquals(oldValue, feature.get().getValues().get(0).get()); }
RevFeatureType.builder().type(pointsType).build()); String addedPath = NodeRef.appendChild(pointsName, points3.getIdentifier().getID()); patch.addAddedFeature(addedPath, RevFeature.builder().build(points3), RevFeatureType.builder().type(pointsType).build()); geogig.command(ApplyPatchOp.class).setPatch(patch).call();
@Test public void testAddedFeatureExists() throws Exception { insert(points1); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeature.builder().build(points1), RevFeatureType.builder().type(pointsType).build()); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }