use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project janusgraph by JanusGraph.
the class GeoshapeTest method testGeoJsonGeometry.
@Test
public void testGeoJsonGeometry() throws IOException {
Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer();
Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Point\",\n" + " \"coordinates\": [20.5, 10.5]\n" + "}", HashMap.class);
assertEquals(Geoshape.point(10.5, 20.5), s.convert(json));
}
use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project janusgraph by JanusGraph.
the class GeoshapeTest method testGeoJsonInvalidBox2.
@Test(expected = IllegalArgumentException.class)
public void testGeoJsonInvalidBox2() throws IOException {
Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer();
Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Polygon\",\n" + " \"coordinates\": [[20.5, 10.5],[22.5, 10.5],[22.5, 12.5]]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class);
s.convert(json);
}
use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project unipop by unipop-graph.
the class ContextManager method reloadContexts.
private void reloadContexts() throws IOException {
SQLDialect dialect = SQLDialect.valueOf(this.conf.getString("sqlDialect"));
BasicDataSource ds = new BasicDataSource();
ds.setUrl(new ObjectMapper().readValue(conf.getJSONArray("address").toString(), List.class).get(0).toString());
ds.setDriverClassName(conf.getString("driver"));
String user = conf.optString("user");
String password = conf.optString("password");
if (!user.isEmpty())
ds.setUsername(user);
if (!password.isEmpty())
ds.setPassword(password);
Settings settings = new Settings();
settings.setRenderNameStyle(RenderNameStyle.AS_IS);
Configuration conf = new DefaultConfiguration().set(ds).set(dialect).set(settings).set(new DefaultExecuteListenerProvider(new TimingExecuterListener()));
this.context = DSL.using(conf);
}
use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project timbuctoo by HuygensING.
the class DatabaseLogTest method setUp.
@Before
public void setUp() throws Exception {
objectMapper = new ObjectMapper();
logEntryFactory = mock(LogEntryFactory.class);
vertexLogEntry = mock(LogEntry.class);
given(logEntryFactory.createForVertex(any(Vertex.class))).willReturn(vertexLogEntry);
given(logEntryFactory.createForEdge(any(Edge.class))).willReturn(mock(LogEntry.class));
}
use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project timbuctoo by HuygensING.
the class IndexAllEntityIds method execute.
@Override
public void execute(TinkerPopGraphManager graphManager) throws IOException {
Vres vres = getVres(graphManager);
Neo4jIndexHandler indexHandler = new Neo4jIndexHandler(graphManager);
ObjectMapper mapper = new ObjectMapper();
GraphTraversalSource traversalSource = graphManager.getGraph().traversal();
traversalSource.V().has(// only valid entities
"types").forEachRemaining(vertex -> {
try {
String[] types = mapper.readValue(vertex.<String>value("types"), String[].class);
for (String type : types) {
if (TYPES_TO_IGNORE.contains(type)) {
continue;
}
if (vres.getCollectionForType(type).isPresent()) {
VertexProperty<String> timIdProp = vertex.property("tim_id");
if (timIdProp.isPresent()) {
try {
UUID timId = UUID.fromString(timIdProp.value());
indexHandler.insertIntoIdIndex(timId, vertex);
} catch (IllegalArgumentException e) {
// This exception should not happen, but we do not want our migration to fail on it.
LOG.error("'{}' is not a valid id", timIdProp.value());
}
} else {
LOG.error("Vertex with id '{}' has no 'tim_id' property", vertex.id());
}
} else {
LOG.error("'{}' is not a known entity type.", type);
}
}
} catch (IOException e) {
LOG.error("And exception occurred while indexing vertex with vertex id '{}'.", vertex.id());
}
});
}
Aggregations