use of com.tinkerpop.blueprints.util.io.graphson.ElementPropertyConfig.ElementPropertiesRule in project orientdb by orientechnologies.
the class OGraphSONUtility method objectNodeFromElement.
/**
* Creates GraphSON for a single graph element.
*/
public ObjectNode objectNodeFromElement(final Element element) {
final boolean isEdge = element instanceof Edge;
final boolean showTypes = mode == GraphSONMode.EXTENDED;
final List<String> propertyKeys = isEdge ? this.edgePropertyKeys : this.vertexPropertyKeys;
final ElementPropertiesRule elementPropertyConfig = isEdge ? this.edgePropertiesRule : this.vertexPropertiesRule;
final ObjectNode jsonElement = createJSONMap(createPropertyMap(element, propertyKeys, elementPropertyConfig, normalized), propertyKeys, showTypes);
if ((isEdge && this.includeReservedEdgeId) || (!isEdge && this.includeReservedVertexId)) {
putObject(jsonElement, GraphSONTokens._ID, element.getId());
}
// are graph implementations that have Edge extend from Vertex
if (element instanceof Edge) {
final Edge edge = (Edge) element;
if (this.includeReservedEdgeId) {
putObject(jsonElement, GraphSONTokens._ID, element.getId());
}
if (this.includeReservedEdgeType) {
jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.EDGE);
}
if (this.includeReservedEdgeOutV) {
putObject(jsonElement, GraphSONTokens._OUT_V, edge.getVertex(Direction.OUT).getId());
}
if (this.includeReservedEdgeInV) {
putObject(jsonElement, GraphSONTokens._IN_V, edge.getVertex(Direction.IN).getId());
}
if (this.includeReservedEdgeLabel) {
jsonElement.put(GraphSONTokens._LABEL, edge.getLabel());
}
} else if (element instanceof Vertex) {
if (this.includeReservedVertexId) {
putObject(jsonElement, GraphSONTokens._ID, element.getId());
}
if (this.includeReservedVertexType) {
jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.VERTEX);
}
}
return jsonElement;
}
use of com.tinkerpop.blueprints.util.io.graphson.ElementPropertyConfig.ElementPropertiesRule in project blueprints by tinkerpop.
the class GraphSONUtility method objectNodeFromElement.
/**
* Creates GraphSON for a single graph element.
*/
public ObjectNode objectNodeFromElement(final Element element) {
final boolean isEdge = element instanceof Edge;
final boolean showTypes = mode == GraphSONMode.EXTENDED;
final List<String> propertyKeys = isEdge ? this.edgePropertyKeys : this.vertexPropertyKeys;
final ElementPropertiesRule elementPropertyConfig = isEdge ? this.edgePropertiesRule : this.vertexPropertiesRule;
final ObjectNode jsonElement = createJSONMap(createPropertyMap(element, propertyKeys, elementPropertyConfig, normalized), propertyKeys, showTypes);
if ((isEdge && this.includeReservedEdgeId) || (!isEdge && this.includeReservedVertexId)) {
putObject(jsonElement, GraphSONTokens._ID, element.getId());
}
// are graph implementations that have Edge extend from Vertex
if (element instanceof Edge) {
final Edge edge = (Edge) element;
if (this.includeReservedEdgeId) {
putObject(jsonElement, GraphSONTokens._ID, element.getId());
}
if (this.includeReservedEdgeType) {
jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.EDGE);
}
if (this.includeReservedEdgeOutV) {
putObject(jsonElement, GraphSONTokens._OUT_V, edge.getVertex(Direction.OUT).getId());
}
if (this.includeReservedEdgeInV) {
putObject(jsonElement, GraphSONTokens._IN_V, edge.getVertex(Direction.IN).getId());
}
if (this.includeReservedEdgeLabel) {
jsonElement.put(GraphSONTokens._LABEL, edge.getLabel());
}
} else if (element instanceof Vertex) {
if (this.includeReservedVertexId) {
putObject(jsonElement, GraphSONTokens._ID, element.getId());
}
if (this.includeReservedVertexType) {
jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.VERTEX);
}
}
return jsonElement;
}
Aggregations