public static FeatureDiff compare(String path, RevFeature oldRevFeature, RevFeature newRevFeature, RevFeatureType oldRevFeatureType, RevFeatureType newRevFeatureType) { return new FeatureDiff(path, newRevFeature, oldRevFeature, newRevFeatureType, oldRevFeatureType, false); }
private FeatureDiff compare(RevFeature oldRevFeature, RevFeature newRevFeature, RevFeatureType oldRevFeatureType, RevFeatureType newRevFeatureType) { return new FeatureDiff(oldNodeRef.path(), newRevFeature, oldRevFeature, newRevFeatureType, oldRevFeatureType, false); }
private FeatureDiff compare(RevFeature oldRevFeature, RevFeature newRevFeature, RevFeatureType oldRevFeatureType, RevFeatureType newRevFeatureType) { return new FeatureDiff(mergeInto.path(), newRevFeature, oldRevFeature, newRevFeatureType, oldRevFeatureType, false); }
private FeatureDiff compare(RevFeature oldRevFeature, RevFeature newRevFeature, RevFeatureType oldRevFeatureType, RevFeatureType newRevFeatureType) { return new FeatureDiff(mergeInto.path(), newRevFeature, oldRevFeature, newRevFeatureType, oldRevFeatureType, false); }
/** * Returns a reversed version of the feature difference * * @return */ public FeatureDiff reversed() { Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Set<Entry<PropertyDescriptor, AttributeDiff>> entries = diffs.entrySet(); for (Iterator<Entry<PropertyDescriptor, AttributeDiff>> iterator = entries .iterator(); iterator.hasNext();) { Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next(); map.put(entry.getKey(), entry.getValue().reversed()); } return new FeatureDiff(path, map, newFeatureType, oldFeatureType); }
/** * Returns a reversed version of the feature difference * * @return */ public FeatureDiff reversed() { Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Set<Entry<PropertyDescriptor, AttributeDiff>> entries = diffs.entrySet(); for (Iterator<Entry<PropertyDescriptor, AttributeDiff>> iterator = entries .iterator(); iterator.hasNext();) { Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next(); map.put(entry.getKey(), entry.getValue().reversed()); } return new FeatureDiff(path, map, newFeatureType, oldFeatureType); }
@Given("^I have a patch file$") public void I_have_a_patch_file() throws Throwable { 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); File file = new File(localRepo.platform.pwd(), "test.patch"); BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); PatchSerializer.write(writer, patch); writer.flush(); writer.close(); }
@Given("^I have a patch file$") public void I_have_a_patch_file() throws Throwable { 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); File file = new File(localRepo.platform.pwd(), "test.patch"); BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); PatchSerializer.write(writer, patch); writer.flush(); writer.close(); }
@Given("^I have a patch file$") public void I_have_a_patch_file() throws Throwable { 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, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(feaureDiff); File file = new File(localRepo.platform.pwd(), "test.patch"); BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); PatchSerializer.write(writer, patch); writer.flush(); writer.close(); }
@Test public void testRemoveFeatureAttributePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, null); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(modifiedPointsType), RevFeatureTypeBuilder.build(pointsType)); patch.addModifiedFeature(featureDiff); patch.addFeatureType(RevFeatureTypeBuilder.build(pointsType)); testPatch(patch); }
@Test public void testAddFeatureAttributePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object newValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(null, newValue); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(pointsType), RevFeatureTypeBuilder.build(modifiedPointsType)); patch.addModifiedFeature(featureDiff); patch.addFeatureType(RevFeatureTypeBuilder.build(modifiedPointsType)); testPatch(patch); }
@Test public void testAddFeatureAttributePatch() throws Exception { insert(points1); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object newValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(null, newValue); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(pointsType), RevFeatureTypeBuilder.build(modifiedPointsType)); patch.addModifiedFeature(featureDiff); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); // TODO }
@Test public void testModifyFeatureAttributePatch() throws Exception { 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"); Geometry oldGeometry = (Geometry) points1.getProperty("pp").getValue(); Geometry newGeometry = new WKTReader2().read("POINT (2 2)"); GeometryAttributeDiff geomDiff = new GeometryAttributeDiff(oldGeometry, newGeometry); map.put(pointsType.getDescriptor("sp"), diff); map.put(pointsType.getDescriptor("pp"), geomDiff); FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(pointsType), RevFeatureTypeBuilder.build(pointsType)); patch.addModifiedFeature(feaureDiff); testPatch(patch); }
@Test public void testModifiedFeatureDoesNotExists() throws Exception { 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 featureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(pointsType), RevFeatureTypeBuilder.build(pointsType)); patch.addModifiedFeature(featureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testModifyFeatureAttributePatch() throws Exception { 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"); Geometry oldGeometry = (Geometry) points1.getProperty("pp").getValue(); Geometry newGeometry = new WKTReader2().read("POINT (2 2)"); GeometryAttributeDiff geomDiff = new GeometryAttributeDiff(oldGeometry, newGeometry); map.put(pointsType.getDescriptor("sp"), diff); map.put(pointsType.getDescriptor("pp"), geomDiff); FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(feaureDiff); testPatch(patch); }
@Test public void testAddFeatureAttributePatch() throws Exception { insert(points1); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object newValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(null, newValue); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(modifiedPointsType).build()); patch.addModifiedFeature(featureDiff); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); // TODO }
@Test public void testRemoveFeatureAttributePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, null); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(modifiedPointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(featureDiff); patch.addFeatureType(RevFeatureType.builder().type(pointsType).build()); testPatch(patch); }
@Test public void testAddFeatureAttributePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object newValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(null, newValue); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(modifiedPointsType).build()); patch.addModifiedFeature(featureDiff); patch.addFeatureType(RevFeatureType.builder().type(modifiedPointsType).build()); testPatch(patch); }
@Test public void testModifiedFeatureDoesNotExists() throws Exception { 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 featureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(featureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testModifyFeatureAttributeOutdatedPatch() throws Exception { insert(points1_modified); 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, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(feaureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }