/** * Returns the reversed version of this difference * * @return */ public FeatureTypeDiff reversed() { return new FeatureTypeDiff(path, newFeatureType, oldFeatureType); }
/** * Returns the reversed version of this difference * * @return */ public FeatureTypeDiff reversed() { return new FeatureTypeDiff(path, newFeatureType, oldFeatureType); }
FeatureTypeDiff diff = new FeatureTypeDiff(headerTokens[0], ObjectId.valueOf(headerTokens[1]), ObjectId.valueOf(headerTokens[2])); patch.addAlteredTree(diff);
FeatureTypeDiff diff = new FeatureTypeDiff(headerTokens[0], ObjectId.valueOf(headerTokens[1]), ObjectId.valueOf(headerTokens[2])); patch.addAlteredTree(diff);
public void addAlteredTree(DiffEntry diff) { ObjectId oldFeatureType = diff.getOldObject() == null ? null : diff.getOldObject().getMetadataId(); ObjectId newFeatureType = diff.getNewObject() == null ? null : diff.getNewObject().getMetadataId(); String path = diff.oldPath() == null ? diff.newPath() : diff.oldPath(); alteredTrees.add(new FeatureTypeDiff(path, oldFeatureType, newFeatureType)); }
public void addAlteredTree(DiffEntry diff) { ObjectId oldFeatureType = diff.getOldObject() == null ? null : diff.getOldObject().getMetadataId(); ObjectId newFeatureType = diff.getNewObject() == null ? null : diff.getNewObject().getMetadataId(); String path = diff.oldPath() == null ? diff.newPath() : diff.oldPath(); alteredTrees.add(new FeatureTypeDiff(path, oldFeatureType, newFeatureType)); }
@Test public void testAddEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, null, featureType.getId())); testPatch(patch); }
@Test public void testRemoveEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, featureType.getId(), null)); testPatch(patch); }
@Test public void testAddEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, null, featureType.getId())); 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); assertEquals(featureType.getId(), typeTreeId.get().getMetadataId().get()); }
@Test public void testModifiedFeatureType() throws Exception { insert(points2, points3, points1B); Patch patch = new Patch(); RevFeatureType oldFeatureType = RevFeatureTypeBuilder.build(pointsType); RevFeatureType featureType = RevFeatureTypeBuilder.build(modifiedPointsType); patch.addFeatureType(featureType); patch.addAlteredTree( new FeatureTypeDiff(pointsName, oldFeatureType.getId(), featureType.getId())); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTree = findTreeChild(root, pointsName); assertTrue(typeTree.isPresent()); assertEquals(featureType.getId(), typeTree.get().getMetadataId().get()); Optional<Node> featureNode = findTreeChild(root, NodeRef.appendChild(pointsName, idP2)); assertTrue(featureNode.isPresent()); assertEquals(oldFeatureType.getId(), featureNode.get().getMetadataId().get()); featureNode = findTreeChild(root, NodeRef.appendChild(pointsName, idP1)); assertTrue(featureNode.isPresent()); assertFalse(featureNode.get().getMetadataId().isPresent()); }
@Test public void testAddEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureType.builder().type(pointsType).build(); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, null, featureType.getId())); testPatch(patch); }
@Test public void testRemoveEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureType.builder().type(pointsType).build(); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, featureType.getId(), null)); testPatch(patch); }
@Test public void testModifiedFeatureType() throws Exception { insert(points2, points3, points1B); Patch patch = new Patch(); RevFeatureType oldFeatureType = RevFeatureType.builder().type(pointsType).build(); RevFeatureType featureType = RevFeatureType.builder().type(modifiedPointsType).build(); patch.addFeatureType(featureType); patch.addAlteredTree( new FeatureTypeDiff(pointsName, oldFeatureType.getId(), featureType.getId())); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTree = findTreeChild(root, pointsName); assertTrue(typeTree.isPresent()); assertEquals(featureType.getId(), typeTree.get().getMetadataId().get()); Optional<Node> featureNode = findTreeChild(root, NodeRef.appendChild(pointsName, idP2)); assertTrue(featureNode.isPresent()); assertEquals(oldFeatureType.getId(), featureNode.get().getMetadataId().get()); featureNode = findTreeChild(root, NodeRef.appendChild(pointsName, idP1)); assertTrue(featureNode.isPresent()); assertFalse(featureNode.get().getMetadataId().isPresent()); }
@Test public void testAddEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureType.builder().type(pointsType).build(); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, null, featureType.getId())); 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); assertEquals(featureType.getId(), typeTreeId.get().getMetadataId().get()); }
@Test public void testModifiedEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); RevFeatureType modifiedFeatureType = RevFeatureTypeBuilder.build(modifiedPointsType); patch.addFeatureType(featureType); patch.addFeatureType(modifiedFeatureType); patch.addAlteredTree( new FeatureTypeDiff(pointsName, featureType.getId(), modifiedFeatureType.getId())); testPatch(patch); }
@Test public void testModifiedEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureType.builder().type(pointsType).build(); RevFeatureType modifiedFeatureType = RevFeatureType.builder().type(modifiedPointsType) .build(); patch.addFeatureType(featureType); patch.addFeatureType(modifiedFeatureType); patch.addAlteredTree( new FeatureTypeDiff(pointsName, featureType.getId(), modifiedFeatureType.getId())); testPatch(patch); }
@Test public void testRemoveEmptyFeatureTypePatch() throws Exception { WorkingTree workingTree = geogig.getRepository().workingTree(); workingTree.createTypeTree(pointsName, pointsType); geogig.command(AddOp.class).setUpdateOnly(false).call(); Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, featureType.getId(), null)); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTree = findTreeChild(root, pointsName); assertFalse(typeTree.isPresent()); }
@Test public void testRemoveEmptyFeatureTypePatch() throws Exception { WorkingTree workingTree = geogig.getRepository().workingTree(); workingTree.createTypeTree(pointsName, pointsType); geogig.command(AddOp.class).setUpdateOnly(false).call(); Patch patch = new Patch(); RevFeatureType featureType = RevFeatureType.builder().type(pointsType).build(); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, featureType.getId(), null)); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTree = findTreeChild(root, pointsName); assertFalse(typeTree.isPresent()); }