public static RevFeatureType readFeatureType(ObjectId id, DataInput in, FeatureTypeFactory typeFactory) throws IOException { Name name = readName(in); int propertyCount = in.readInt(); List<AttributeDescriptor> attributes = new ArrayList<AttributeDescriptor>(); for (int i = 0; i < propertyCount; i++) { attributes.add(readAttributeDescriptor(in, typeFactory)); } SimpleFeatureType ftype = typeFactory.createSimpleFeatureType(name, attributes, null, false, Collections.<Filter> emptyList(), BasicFeatureTypes.FEATURE, null); return RevFeatureType.builder().id(id).type(ftype).build(); }
public RevFeatureType readFeatureType(@Nullable ObjectId id, DataInput in, FeatureTypeFactory typeFactory) throws IOException { Name name = readName(in); int propertyCount = readUnsignedVarInt(in); List<AttributeDescriptor> attributes = new ArrayList<AttributeDescriptor>(); for (int i = 0; i < propertyCount; i++) { attributes.add(readAttributeDescriptor(in, typeFactory)); } SimpleFeatureType ftype = typeFactory.createSimpleFeatureType(name, attributes, null, false, Collections.<Filter> emptyList(), BasicFeatureTypes.FEATURE, null); return RevFeatureType.builder().id(id).type(ftype).build(); }
@Override protected void setUpInternal() throws Exception { featureType = RevFeatureType.builder().type(pointsType).build(); }
private Iterator<Feature> transformFeatures(SimpleFeatureType featureType, String path) { String refspec = Ref.WORK_HEAD + ":" + path; Iterator<NodeRef> oldFeatures = command(LsTreeOp.class).setReference(refspec) .setStrategy(Strategy.FEATURES_ONLY).call(); RevFeatureType revFeatureType = RevFeatureType.builder().type(featureType).build(); Iterator<Feature> transformedIterator = transformIterator(oldFeatures, revFeatureType); return transformedIterator; }
@Override protected void setUpInternal() throws Exception { insertAndAdd(points1, points2, points3); commit("inital"); SimpleFeatureType fullSchema = pointsType; RevFeatureType nativeType = RevFeatureType.builder().type(fullSchema).build(); Context actualContext = repo.context(); context = spy(actualContext); difftree = spy(context.command(DiffTree.class)); doReturn(difftree).when(context).command(eq(DiffTree.class)); NodeRef typeRef = context.workingTree().getFeatureTypeTrees().get(0); FeatureReaderBuilder b = FeatureReaderBuilder.builder(context, nativeType, typeRef); builder = spy(b); }
@Test public void testToString() { RevFeatureType featureType = RevFeatureType.builder().type(linesType).build(); String actual = featureType.toString(); String expected = RevObjects.toString(featureType); assertEquals(expected, actual); } }
protected void insert(Repository repo, Iterable<? extends Feature> features) throws Exception { WorkingTree workingTree = repo.workingTree(); FeatureType type = features.iterator().next().getType(); repo.objectDatabase().put(RevFeatureType.builder().type(type).build()); final String treePath = type.getName().getLocalPart(); Iterable<FeatureInfo> featureInfos = Iterables.transform(features, (f) -> featureInfo(treePath, f)); workingTree.insert(featureInfos.iterator(), new DefaultProgressListener()); }
@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 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); }
public FeatureInfo featureInfo(String treePath, Feature f) { final String path = NodeRef.appendChild(treePath, f.getIdentifier().getID()); RevFeature feature = RevFeature.builder().build(f); FeatureType type = f.getType(); RevFeatureType ftype = RevFeatureType.builder().type(type).build(); return FeatureInfo.insert(feature, ftype.getId(), path); }
@Test public void testCreateTypeTree() throws Exception { NodeRef treeRef = workTree.createTypeTree("points2", pointsType); assertNotNull(treeRef); assertEquals("points2", treeRef.path()); assertEquals("", treeRef.getParentPath()); assertTrue(treeRef.getNode().getMetadataId().isPresent()); assertEquals(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); RevObjectTestUtil.deepEquals(RevFeatureType.builder().type(pointsType).build(), featureType); }
@Test public void testCreateTypeNestedNonExistingParent() throws Exception { NodeRef treeRef = workTree.createTypeTree("path/to/nested/type", pointsType); assertNotNull(treeRef); assertEquals("path/to/nested/type", treeRef.path()); assertEquals("path/to/nested", treeRef.getParentPath()); assertTrue(treeRef.getNode().getMetadataId().isPresent()); assertEquals(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); RevObjectTestUtil.deepEquals(RevFeatureType.builder().type(pointsType).build(), featureType); }
@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 testRemoveFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addRemovedFeature(path, RevFeature.builder().build(points1), RevFeatureType.builder().type(pointsType).build()); testPatch(patch); }
public FeatureInfo featureInfo(String treePath, Feature f) { final String path = NodeRef.appendChild(treePath, f.getIdentifier().getID()); RevFeature feature = RevFeature.builder().build(f); FeatureType type = f.getType(); RevFeatureType ftype = RevFeatureType.builder().type(type).build(); repo.objectDatabase().put(ftype); return FeatureInfo.insert(feature, ftype.getId(), path); }
protected FeatureInfo featureInfo(SimpleFeatureType type, String id, Object... values) { RevFeature feature = RevFeature.builder().build(feature(type, id, values)); RevFeatureType ftype = RevFeatureType.builder().type(type).build(); repo.objectDatabase().put(ftype); String path = NodeRef.appendChild(type.getName().getLocalPart(), id); return FeatureInfo.insert(feature, ftype.getId(), path); }
@Test public void testCommitAddsFeatureTypeToObjectDatabase() throws Exception { insertAndAdd(points1); ObjectId id = RevFeatureType.builder().type(pointsType).build().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()); }
protected ObjectId insert(Repository repo, Feature f) throws Exception { final WorkingTree workTree = repo.workingTree(); Name name = f.getType().getName(); String parentPath = name.getLocalPart(); RevFeatureType type = RevFeatureType.builder().type(f.getType()).build(); repo.objectDatabase().put(type); String path = NodeRef.appendChild(parentPath, f.getIdentifier().getID()); FeatureInfo fi = FeatureInfo.insert(RevFeature.builder().build(f), type.getId(), path); workTree.insert(fi); return fi.getFeature().getId(); }