graphdb/src/main/java/com/orientechnologies/orient/graph/graphml/OGraphSONUtility.java
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());
    }

    // 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;

      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;
  }
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());
    }

    // 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;

      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;
  }
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 ( ) ) ; } // 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 ; 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 ; }
Creates GraphSON for a single graph element.
Creates GraphSON for a single graph element .