You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by am...@apache.org on 2018/04/13 16:37:59 UTC
atlas git commit: ATLAS-2554: Add support for BigDecimal, BigInteger.
Repository: atlas
Updated Branches:
refs/heads/branch-0.8 394a19fbd -> 49d2a2723
ATLAS-2554: Add support for BigDecimal, BigInteger.
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/49d2a272
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/49d2a272
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/49d2a272
Branch: refs/heads/branch-0.8
Commit: 49d2a272366c763c6954ab878fdc034c8acfab1a
Parents: 394a19f
Author: Ashutosh Mestry <am...@hortonworks.com>
Authored: Wed Apr 11 14:00:32 2018 -0700
Committer: Ashutosh Mestry <am...@hortonworks.com>
Committed: Fri Apr 13 09:32:32 2018 -0700
----------------------------------------------------------------------
.../atlas/migration/AtlasGraphSONUtility.java | 389 +++++++++++++++++++
.../atlas/migration/AtlasGraphSONWriter.java | 121 ++++++
.../org/apache/atlas/migration/Exporter.java | 6 +-
.../apache/atlas/migration/GraphSONTokens.java | 48 +++
4 files changed, 560 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/49d2a272/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/AtlasGraphSONUtility.java
----------------------------------------------------------------------
diff --git a/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/AtlasGraphSONUtility.java b/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/AtlasGraphSONUtility.java
new file mode 100644
index 0000000..1aeae71
--- /dev/null
+++ b/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/AtlasGraphSONUtility.java
@@ -0,0 +1,389 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.atlas.migration;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.tinkerpop.blueprints.Direction;
+import com.tinkerpop.blueprints.Edge;
+import com.tinkerpop.blueprints.Element;
+import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.blueprints.util.io.graphson.ElementPropertyConfig;
+import com.tinkerpop.blueprints.util.io.graphson.GraphSONMode;
+
+import java.lang.reflect.Array;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.*;
+
+public class AtlasGraphSONUtility {
+
+ private static final JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
+
+ private final GraphSONMode mode;
+ private final List<String> vertexPropertyKeys;
+ private final List<String> edgePropertyKeys;
+ private final ElementPropertyConfig.ElementPropertiesRule vertexPropertiesRule;
+ private final ElementPropertyConfig.ElementPropertiesRule edgePropertiesRule;
+ private final boolean normalized;
+
+ /**
+ * A AtlasGraphSONUtility that includes the specified properties.
+ */
+ public AtlasGraphSONUtility(GraphSONMode mode,
+ Set<String> vertexPropertyKeys, Set<String> edgePropertyKeys) {
+ this(mode, ElementPropertyConfig.includeProperties(vertexPropertyKeys, edgePropertyKeys));
+ }
+
+ public AtlasGraphSONUtility(GraphSONMode mode, ElementPropertyConfig config) {
+ this.vertexPropertyKeys = config.getVertexPropertyKeys();
+ this.edgePropertyKeys = config.getEdgePropertyKeys();
+ this.vertexPropertiesRule = config.getVertexPropertiesRule();
+ this.edgePropertiesRule = config.getEdgePropertiesRule();
+ this.normalized = config.isNormalized();
+
+ this.mode = mode;
+ }
+
+ /**
+ * Creates GraphSON for a single graph element.
+ */
+ public ObjectNode objectNodeFromElement(Element element) {
+ final boolean isEdge = element instanceof Edge;
+ final boolean showTypes = mode == GraphSONMode.EXTENDED;
+ final List<String> propertyKeys = isEdge ? this.edgePropertyKeys : this.vertexPropertyKeys;
+ final ElementPropertyConfig.ElementPropertiesRule elementPropertyConfig = isEdge ? this.edgePropertiesRule : this.vertexPropertiesRule;
+
+ final ObjectNode jsonElement = createJSONMap(createPropertyMap(element, propertyKeys, elementPropertyConfig, normalized), propertyKeys, showTypes);
+
+ putObject(jsonElement, GraphSONTokens._ID, element.getId());
+
+ // it's important to keep the order of these straight. check Edge first and then Vertex because there
+ // are graph implementations that have Edge extend from Vertex
+ if (element instanceof Edge) {
+ final Edge edge = (Edge) element;
+
+ putObject(jsonElement, GraphSONTokens._ID, element.getId());
+ jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.EDGE);
+ putObject(jsonElement, GraphSONTokens._OUT_V, edge.getVertex(Direction.OUT).getId());
+ putObject(jsonElement, GraphSONTokens._IN_V, edge.getVertex(Direction.IN).getId());
+ jsonElement.put(GraphSONTokens._LABEL, edge.getLabel());
+ } else if (element instanceof Vertex) {
+ putObject(jsonElement, GraphSONTokens._ID, element.getId());
+ jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.VERTEX);
+ }
+
+ return jsonElement;
+ }
+
+ private static ObjectNode objectNodeFromElement(Element element, List<String> propertyKeys, GraphSONMode mode) {
+ final AtlasGraphSONUtility graphson = element instanceof Edge ?
+ new AtlasGraphSONUtility(mode, null, new HashSet<String>(propertyKeys))
+ : new AtlasGraphSONUtility(mode, new HashSet<String>(propertyKeys), null);
+ return graphson.objectNodeFromElement(element);
+ }
+
+
+ private static ArrayNode createJSONList(List list, List<String> propertyKeys, boolean showTypes) {
+ final ArrayNode jsonList = jsonNodeFactory.arrayNode();
+ for (Object item : list) {
+ if (item instanceof Element) {
+ jsonList.add(objectNodeFromElement((Element) item, propertyKeys,
+ showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL));
+ } else if (item instanceof List) {
+ jsonList.add(createJSONList((List) item, propertyKeys, showTypes));
+ } else if (item instanceof Map) {
+ jsonList.add(createJSONMap((Map) item, propertyKeys, showTypes));
+ } else if (item != null && item.getClass().isArray()) {
+ jsonList.add(createJSONList(convertArrayToList(item), propertyKeys, showTypes));
+ } else {
+ addObject(jsonList, item);
+ }
+ }
+ return jsonList;
+ }
+
+ private static ObjectNode createJSONMap(Map map, List<String> propertyKeys, boolean showTypes) {
+ final ObjectNode jsonMap = jsonNodeFactory.objectNode();
+ for (Object key : map.keySet()) {
+ Object value = map.get(key);
+ if (value != null) {
+ if (value instanceof List) {
+ value = createJSONList((List) value, propertyKeys, showTypes);
+ } else if (value instanceof Map) {
+ value = createJSONMap((Map) value, propertyKeys, showTypes);
+ } else if (value instanceof Element) {
+ value = objectNodeFromElement((Element) value, propertyKeys,
+ showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL);
+ } else if (value.getClass().isArray()) {
+ value = createJSONList(convertArrayToList(value), propertyKeys, showTypes);
+ }
+ }
+
+ putObject(jsonMap, key.toString(), getValue(value, showTypes));
+ }
+
+ return jsonMap;
+ }
+
+ private static void addObject(ArrayNode jsonList, Object value) {
+ if (value == null) {
+ jsonList.add((JsonNode) null);
+ } else if (value.getClass() == Boolean.class) {
+ jsonList.add((Boolean) value);
+ } else if (value.getClass() == Long.class) {
+ jsonList.add((Long) value);
+ } else if (value.getClass() == Integer.class) {
+ jsonList.add((Integer) value);
+ } else if (value.getClass() == Float.class) {
+ jsonList.add((Float) value);
+ } else if (value.getClass() == Double.class) {
+ jsonList.add((Double) value);
+ } else if (value.getClass() == Byte.class) {
+ jsonList.add((Byte) value);
+ } else if (value.getClass() == Short.class) {
+ jsonList.add((Short) value);
+ } else if (value.getClass() == String.class) {
+ jsonList.add((String) value);
+ } else if (value.getClass() == BigDecimal.class) {
+ jsonList.add((BigDecimal) value);
+ } else if (value.getClass() == BigInteger.class) {
+ jsonList.add(((BigInteger) value).longValue());
+ } else if (value instanceof ObjectNode) {
+ jsonList.add((ObjectNode) value);
+ } else if (value instanceof ArrayNode) {
+ jsonList.add((ArrayNode) value);
+ } else {
+ jsonList.add(value.toString());
+ }
+ }
+
+ private static void putObject(ObjectNode jsonMap, String key, Object value) {
+ if (value == null) {
+ jsonMap.put(key, (JsonNode) null);
+ } else if (value.getClass() == Boolean.class) {
+ jsonMap.put(key, (Boolean) value);
+ } else if (value.getClass() == Long.class) {
+ jsonMap.put(key, (Long) value);
+ } else if (value.getClass() == Integer.class) {
+ jsonMap.put(key, (Integer) value);
+ } else if (value.getClass() == Float.class) {
+ jsonMap.put(key, (Float) value);
+ } else if (value.getClass() == Double.class) {
+ jsonMap.put(key, (Double) value);
+ } else if (value.getClass() == Short.class) {
+ jsonMap.put(key, (Short) value);
+ } else if (value.getClass() == Byte.class) {
+ jsonMap.put(key, (Byte) value);
+ } else if (value.getClass() == String.class) {
+ jsonMap.put(key, (String) value);
+ } else if(value.getClass() == BigDecimal.class) {
+ jsonMap.put(key, (BigDecimal) value);
+ } else if(value.getClass() == BigInteger.class) {
+ jsonMap.put(key, ((BigInteger) value).longValue());
+ } else if (value instanceof ObjectNode) {
+ jsonMap.put(key, (ObjectNode) value);
+ } else if (value instanceof ArrayNode) {
+ jsonMap.put(key, (ArrayNode) value);
+ } else {
+ jsonMap.put(key, value.toString());
+ }
+ }
+
+ private static Map createPropertyMap(Element element, List<String> propertyKeys,
+ ElementPropertyConfig.ElementPropertiesRule rule, boolean normalized) {
+ final Map map = new HashMap<String, Object>();
+ final List<String> propertyKeyList;
+ if (normalized) {
+ final List<String> sorted = new ArrayList<String>(element.getPropertyKeys());
+ Collections.sort(sorted);
+ propertyKeyList = sorted;
+ } else {
+ propertyKeyList = new ArrayList<String>(element.getPropertyKeys());
+ }
+
+ if (propertyKeys == null) {
+ for (String key : propertyKeyList) {
+ final Object valToPutInMap = element.getProperty(key);
+ if (valToPutInMap != null) {
+ map.put(key, valToPutInMap);
+ }
+ }
+ } else {
+ if (rule == ElementPropertyConfig.ElementPropertiesRule.INCLUDE) {
+ for (String key : propertyKeys) {
+ final Object valToPutInMap = element.getProperty(key);
+ if (valToPutInMap != null) {
+ map.put(key, valToPutInMap);
+ }
+ }
+ } else {
+ for (String key : propertyKeyList) {
+ if (!propertyKeys.contains(key)) {
+ final Object valToPutInMap = element.getProperty(key);
+ if (valToPutInMap != null) {
+ map.put(key, valToPutInMap);
+ }
+ }
+ }
+ }
+ }
+
+ return map;
+ }
+
+ private static Object getValue(Object value, boolean includeType) {
+
+ Object returnValue = value;
+
+ // if the includeType is set to true then show the data types of the properties
+ if (includeType) {
+
+ // type will be one of: map, list, string, long, int, double, float.
+ // in the event of a complex object it will call a toString and store as a
+ // string
+ String type = determineType(value);
+
+ ObjectNode valueAndType = jsonNodeFactory.objectNode();
+ valueAndType.put(GraphSONTokens.TYPE, type);
+
+ if (type.equals(GraphSONTokens.TYPE_LIST)) {
+
+ // values of lists must be accumulated as ObjectNode objects under the value key.
+ // will return as a ArrayNode. called recursively to traverse the entire
+ // object graph of each item in the array.
+ ArrayNode list = (ArrayNode) value;
+
+ // there is a set of values that must be accumulated as an array under a key
+ ArrayNode valueArray = valueAndType.putArray(GraphSONTokens.VALUE);
+ for (int ix = 0; ix < list.size(); ix++) {
+ // the value of each item in the array is a node object from an ArrayNode...must
+ // get the value of it.
+ addObject(valueArray, getValue(getTypedValueFromJsonNode(list.get(ix)), includeType));
+ }
+
+ } else if (type.equals(GraphSONTokens.TYPE_MAP)) {
+
+ // maps are converted to a ObjectNode. called recursively to traverse
+ // the entire object graph within the map.
+ ObjectNode convertedMap = jsonNodeFactory.objectNode();
+ ObjectNode jsonObject = (ObjectNode) value;
+ Iterator keyIterator = jsonObject.fieldNames();
+ while (keyIterator.hasNext()) {
+ Object key = keyIterator.next();
+
+ // no need to getValue() here as this is already a ObjectNode and should have type info
+ convertedMap.put(key.toString(), jsonObject.get(key.toString()));
+ }
+
+ valueAndType.put(GraphSONTokens.VALUE, convertedMap);
+ } else {
+
+ // this must be a primitive value or a complex object. if a complex
+ // object it will be handled by a call to toString and stored as a
+ // string value
+ putObject(valueAndType, GraphSONTokens.VALUE, value);
+ }
+
+ // this goes back as a JSONObject with data type and value
+ returnValue = valueAndType;
+ }
+
+ return returnValue;
+ }
+
+ static Object getTypedValueFromJsonNode(JsonNode node) {
+ Object theValue = null;
+
+ if (node != null && !node.isNull()) {
+ if (node.isBoolean()) {
+ theValue = node.booleanValue();
+ } else if (node.isDouble()) {
+ theValue = node.doubleValue();
+ } else if (node.isFloatingPointNumber()) {
+ theValue = node.floatValue();
+ } else if (node.isInt()) {
+ theValue = node.intValue();
+ } else if (node.isLong()) {
+ theValue = node.longValue();
+ } else if (node.isBigDecimal()) {
+ theValue = node.bigIntegerValue();
+ } else if (node.isBigInteger()) {
+ theValue = node.bigIntegerValue();
+ } else if (node.isTextual()) {
+ theValue = node.textValue();
+ } else if (node.isArray()) {
+ // this is an array so just send it back so that it can be
+ // reprocessed to its primitive components
+ theValue = node;
+ } else if (node.isObject()) {
+ // this is an object so just send it back so that it can be
+ // reprocessed to its primitive components
+ theValue = node;
+ } else {
+ theValue = node.textValue();
+ }
+ }
+
+ return theValue;
+ }
+
+ private static List convertArrayToList(final Object value) {
+ final ArrayList<Object> list = new ArrayList<Object>();
+ int arrlength = Array.getLength(value);
+ for (int i = 0; i < arrlength; i++) {
+ Object object = Array.get(value, i);
+ list.add(object);
+ }
+ return list;
+ }
+
+ private static String determineType(Object value) {
+ String type = GraphSONTokens.TYPE_STRING;
+ if (value == null) {
+ type = GraphSONTokens.TYPE_UNKNOWN;
+ } else if (value.getClass() == Double.class) {
+ type = GraphSONTokens.TYPE_DOUBLE;
+ } else if (value.getClass() == Float.class) {
+ type = GraphSONTokens.TYPE_FLOAT;
+ } else if (value.getClass() == Byte.class) {
+ type = GraphSONTokens.TYPE_BYTE;
+ } else if (value.getClass() == Short.class) {
+ type = GraphSONTokens.TYPE_SHORT;
+ } else if (value.getClass() == Integer.class) {
+ type = GraphSONTokens.TYPE_INTEGER;
+ } else if (value.getClass() == Long.class) {
+ type = GraphSONTokens.TYPE_LONG;
+ } else if (value.getClass() == Boolean.class) {
+ type = GraphSONTokens.TYPE_BOOLEAN;
+ } else if(value.getClass() == BigInteger.class) {
+ type = GraphSONTokens.TYPE_BIG_INTEGER;
+ } else if(value.getClass() == BigDecimal.class) {
+ type = GraphSONTokens.TYPE_BIG_DECIMAL;
+ } else if (value instanceof ArrayNode) {
+ type = GraphSONTokens.TYPE_LIST;
+ } else if (value instanceof ObjectNode) {
+ type = GraphSONTokens.TYPE_MAP;
+ }
+
+ return type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/49d2a272/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/AtlasGraphSONWriter.java
----------------------------------------------------------------------
diff --git a/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/AtlasGraphSONWriter.java b/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/AtlasGraphSONWriter.java
new file mode 100644
index 0000000..ade4594
--- /dev/null
+++ b/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/AtlasGraphSONWriter.java
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.atlas.migration;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.MappingJsonFactory;
+import com.tinkerpop.blueprints.Edge;
+import com.tinkerpop.blueprints.Graph;
+import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.blueprints.util.io.graphson.ElementPropertyConfig;
+import com.tinkerpop.blueprints.util.io.graphson.GraphSONMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Set;
+
+public class AtlasGraphSONWriter {
+ private static final Logger LOG = LoggerFactory.getLogger(AtlasGraphSONWriter.class);
+
+ private static final JsonFactory jsonFactory = new MappingJsonFactory();
+ private final Graph graph;
+
+ /**
+ * @param graph the Graph to pull the data from
+ */
+ private AtlasGraphSONWriter(final Graph graph) {
+ this.graph = graph;
+ }
+
+ public void outputGraph(final OutputStream jsonOutputStream, final Set<String> vertexPropertyKeys,
+ final Set<String> edgePropertyKeys, final GraphSONMode mode, final boolean normalize) throws IOException {
+ final JsonGenerator jg = jsonFactory.createGenerator(jsonOutputStream);
+
+ // don't let the JsonGenerator close the underlying stream...leave that to the client passing in the stream
+ jg.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
+
+ final AtlasGraphSONUtility graphson = new AtlasGraphSONUtility(mode,
+ ElementPropertyConfig.includeProperties(vertexPropertyKeys, edgePropertyKeys, normalize));
+
+ jg.writeStartObject(); // start
+ jg.writeStringField(GraphSONTokens.MODE, mode.toString());
+
+ LOG.info("Starting vertices...");
+ jg.writeArrayFieldStart(GraphSONTokens.VERTICES);
+
+ final Iterable<Vertex> vertices = vertices();
+ long vertexCount = 0;
+ for (Vertex v : vertices) {
+ jg.writeTree(graphson.objectNodeFromElement(v));
+ vertexCount++;
+ }
+
+ jg.writeEndArray(); // vertices end
+
+ LOG.info("Starting edges...");
+ jg.writeArrayFieldStart(GraphSONTokens.EDGES);
+
+ final Iterable<Edge> edges = edges();
+ long edgeCount = 0;
+ for (Edge e : edges) {
+ jg.writeTree(graphson.objectNodeFromElement(e));
+ edgeCount++;
+ }
+
+ jg.writeEndArray(); // edges end
+
+ writeMetrics(jg, vertexCount, edgeCount);
+
+ jg.writeEndObject(); // end
+ jg.flush();
+ jg.close();
+ }
+
+ private void writeMetrics(JsonGenerator jg, long vertexCount, long edgeCount) throws IOException {
+ jg.writeNumberField("vertexCount", vertexCount);
+ jg.writeNumberField("edgeCount", edgeCount);
+ }
+
+ private Iterable<Vertex> vertices() {
+ return graph.getVertices();
+ }
+
+ private Iterable<Edge> edges() {
+ return graph.getEdges();
+ }
+
+
+ /**
+ * Write the data in a Graph to a JSON OutputStream. All keys are written to JSON.
+ *
+ * @param graph the graph to serialize to JSON
+ * @param fos the JSON file to write the Graph data to
+ * @param mode determines the format of the GraphSON
+ * @throws IOException thrown if there is an error generating the JSON data
+ */
+ public static void outputGraph(Graph graph, FileOutputStream fos, GraphSONMode mode) throws IOException {
+ final AtlasGraphSONWriter writer = new AtlasGraphSONWriter(graph);
+ writer.outputGraph(fos, null, null, mode, false);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/49d2a272/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/Exporter.java
----------------------------------------------------------------------
diff --git a/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/Exporter.java b/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/Exporter.java
index 2af8b7d..a5f4bdf 100644
--- a/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/Exporter.java
+++ b/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/Exporter.java
@@ -21,7 +21,6 @@ package org.apache.atlas.migration;
import com.thinkaurelius.titan.core.TitanGraph;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.util.io.graphson.GraphSONMode;
-import com.tinkerpop.blueprints.util.io.graphson.GraphSONWriter;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.graphdb.titan0.Titan0GraphDatabase;
import org.apache.atlas.type.AtlasType;
@@ -38,7 +37,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.OutputStream;
import java.util.ArrayList;
@@ -139,14 +137,14 @@ public class Exporter {
private void exportData() throws Exception {
displayMessage("exporting data to file " + dataFileName);
- OutputStream os = null;
+ FileOutputStream os = null;
try {
os = new FileOutputStream(dataFileName);
Graph graph = getTitan0GraphDatabase();
- GraphSONWriter.outputGraph(graph, os, GraphSONMode.EXTENDED);
+ AtlasGraphSONWriter.outputGraph(graph, os, GraphSONMode.EXTENDED);
} finally {
if (os != null) {
try {
http://git-wip-us.apache.org/repos/asf/atlas/blob/49d2a272/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/GraphSONTokens.java
----------------------------------------------------------------------
diff --git a/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/GraphSONTokens.java b/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/GraphSONTokens.java
new file mode 100644
index 0000000..fb8d324
--- /dev/null
+++ b/tools/atlas-migration-exporter/src/main/java/org/apache/atlas/migration/GraphSONTokens.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.migration;
+
+public class GraphSONTokens {
+
+ public static final String VERTEX = "vertex";
+ public static final String EDGE = "edge";
+ public static final String _ID = "_id";
+ public static final String _LABEL = "_label";
+ public static final String _TYPE = "_type";
+ public static final String _OUT_V = "_outV";
+ public static final String _IN_V = "_inV";
+ public static final String VALUE = "value";
+ public static final String TYPE = "type";
+ public static final String TYPE_LIST = "list";
+ public static final String TYPE_STRING = "string";
+ public static final String TYPE_DOUBLE = "double";
+ public static final String TYPE_INTEGER = "integer";
+ public static final String TYPE_FLOAT = "float";
+ public static final String TYPE_MAP = "map";
+ public static final String TYPE_BOOLEAN = "boolean";
+ public static final String TYPE_LONG = "long";
+ public static final String TYPE_SHORT = "short";
+ public static final String TYPE_BYTE = "byte";
+ public static final String TYPE_UNKNOWN = "unknown";
+ public static final String TYPE_BIG_INTEGER = "biginteger";
+ public static final String TYPE_BIG_DECIMAL = "bigdecimal";
+
+ public static final String VERTICES = "vertices";
+ public static final String EDGES = "edges";
+ public static final String MODE = "mode";
+}