@Override public RevFeatureType getFeatureType(ObjectId id) { return subject.get().getFeatureType(id); }
@Override public RevFeatureType getFeatureType(ObjectId id) { return subject.get().getFeatureType(id); }
public RevFeatureType get(ObjectId ftId) { RevFeatureType type = cache.get(ftId); if (type == null) { type = db.getFeatureType(ftId); cache.put(ftId, type); } return type; } }
private RevFeatureType getType(ObjectId featureTypeId, Map<ObjectId, RevFeatureType> typeCache) { RevFeatureType type = typeCache.get(featureTypeId); if (null == type) { type = objectDatabase().getFeatureType(featureTypeId); typeCache.put(featureTypeId, type); } return type; }
private RevFeatureType getType(ObjectId featureTypeId, Map<ObjectId, RevFeatureType> typeCache) { RevFeatureType type = typeCache.get(featureTypeId); if (null == type) { type = objectDatabase().getFeatureType(featureTypeId); typeCache.put(featureTypeId, type); } return type; }
private Map<String, Integer> attributeIndexMapping(Set<String> attNames) { Map<String, Integer> attToValueIndex = new HashMap<>(); RevFeatureType featureType = objectDatabase().getFeatureType(revFeatureTypeId); for (String attName : attNames) { int attIndex = indexOf(attName, featureType); attToValueIndex.put(attName, Integer.valueOf(attIndex)); } return attToValueIndex; }
private Map<String, Integer> attributeIndexMapping(Set<String> attNames) { Map<String, Integer> attToValueIndex = new HashMap<>(); RevFeatureType featureType = objectDatabase().getFeatureType(revFeatureTypeId); for (String attName : attNames) { int attIndex = indexOf(attName, featureType); attToValueIndex.put(attName, Integer.valueOf(attIndex)); } return attToValueIndex; }
private Optional<RevTreeBuilder> getTreeBuilder(final String treePath) { RevTreeBuilder builder = treeBuilders.get(treePath); if (builder == null) { Optional<NodeRef> treeNode = context.command(FindTreeChild.class).setParent(workHead) .setChildPath(treePath).call(); if (treeNode.isPresent()) { RevTree parentTree = db.getTree(treeNode.get().getObjectId()); ObjectId metadataId = treeNode.get().getMetadataId(); if (!metadataId.isNull()) { RevFeatureType featureType = db.getFeatureType(metadataId); revFeatureTypes.put(treePath, featureType); } builder = createBuilder(parentTree); treeBuilders.put(treePath, builder); } } return Optional.fromNullable(builder); }
RevFeatureType getNativeType() { GeogigContentState state = (GeogigContentState) getEntry().getState(getTransaction()); RevFeatureType nativeType = state.getNativeType(); if (nativeType == null) { final NodeRef typeRef = getTypeRef(); final ObjectId metadataId = typeRef.getMetadataId(); Context context = getCommandLocator(); nativeType = context.objectDatabase().getFeatureType(metadataId); state.setNativeType(nativeType); } return nativeType; }
RevFeatureType getNativeType() { GeogigContentState state = (GeogigContentState) getEntry().getState(getTransaction()); RevFeatureType nativeType = state.getNativeType(); if (nativeType == null) { final NodeRef typeRef = getTypeRef(); final ObjectId metadataId = typeRef.getMetadataId(); Context context = getCommandLocator(); nativeType = context.objectDatabase().getFeatureType(metadataId); state.setNativeType(nativeType); } return nativeType; }
@Test public void testCreateTypeTreeAutomaticallyWhenInsertingWitNoExistingTypeTree() throws Exception { insert(points1, points2); Optional<NodeRef> treeRef = repo.command(FindTreeChild.class).setChildPath(pointsName) .setParent(workTree.getTree()).call(); assertTrue(treeRef.isPresent()); assertTrue(treeRef.get().getNode().getMetadataId().isPresent()); assertFalse(treeRef.get().getNode().getMetadataId().get().isNull()); RevFeatureType featureType = repo.objectDatabase() .getFeatureType(treeRef.get().getMetadataId()); assertEquals(pointsType, featureType.type()); }
@Test public void testCreateTypeTreeAutomaticallyWhenInsertingWitNoExistingTypeTree() throws Exception { insert(points1, points2); Optional<NodeRef> treeRef = repo.command(FindTreeChild.class).setChildPath(pointsName) .setParent(workTree.getTree()).call(); assertTrue(treeRef.isPresent()); assertTrue(treeRef.get().getNode().getMetadataId().isPresent()); assertFalse(treeRef.get().getNode().getMetadataId().get().isNull()); RevFeatureType featureType = repo.objectDatabase() .getFeatureType(treeRef.get().getMetadataId()); RevObjectTestUtil.deepEquals(RevFeatureType.builder().type(pointsType).build(), featureType); }
@Test public void testBuild() throws Exception { ObjectId meta1 = getOID(1); SimpleFeatureType fType1 = DataUtilities.createType("location", "the_geom:Point:srid=4326,name:String,name2:String"); RevFeatureType revft1 = RevFeatureTypeBuilder.create(getOID(1), fType1); ObjectDatabase odb = mock(ObjectDatabase.class); when(odb.getFeatureType(meta1)).thenReturn(revft1); WKTReader2 wkt = new WKTReader2(); RevFeature feat = RevObjectTestSupport.feature(wkt.read("POINT(0 0)"), "abc", "def"); Node n1 = Node.create("name1", getOID(2), meta1, TYPE.FEATURE, new Envelope()); NodeRef nr1 = new NodeRef(n1, "testcase", meta1); ObjectInfo<RevFeature> fi = ObjectInfo.of(nr1, feat); MultiFeatureTypeBuilder builder = new MultiFeatureTypeBuilder(odb); SimpleFeature sf = builder.apply(fi); Assert.isTrue(sf.getAttribute("name").equals("abc")); Assert.isTrue(sf.getAttribute("name2").equals("def")); }
@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()); assertSame(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); assertEquals(pointsType, featureType.type()); }
@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()); assertSame(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); assertEquals(pointsType, featureType.type()); }
@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 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 testCommitAddsFeatureTypeToObjectDatabase() throws Exception { insertAndAdd(points1); ObjectId id = RevFeatureTypeBuilder.build(pointsType).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()); }
@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()); }
private void assertDiffFeature(NodeRef ref, SimpleFeature diffFeature, String attribute, SimpleFeatureType valueType) { Object value = diffFeature.getAttribute(attribute); assertTrue(value instanceof SimpleFeature); SimpleFeature valueFeature = (SimpleFeature) value; assertEquals(valueType, valueFeature.getType()); assertEquals(ref.name(), valueFeature.getID()); RevFeatureType nativeType = repo.objectDatabase().getFeatureType(ref.getMetadataId()); RevFeature expected = repo.getFeature(ref.getObjectId()); SimpleFeature expectedFeatureValue = (SimpleFeature) new FeatureBuilder(nativeType) .build(ref.name(), expected); List<Object> expectedAttributes = expectedFeatureValue.getAttributes(); List<Object> actualAttributes = valueFeature.getAttributes(); assertEquals(expectedAttributes, actualAttributes); }