use of org.apache.atlas.repository.graphdb.titan1.graphson.AtlasElementPropertyConfig.ElementPropertiesRule in project incubator-atlas by apache.
the class AtlasGraphSONUtility method objectNodeFromElement.
/**
* Creates GraphSON for a single graph element.
*/
private ObjectNode objectNodeFromElement(final AtlasElement element) {
final boolean isEdge = element instanceof AtlasEdge;
final boolean showTypes = mode == AtlasGraphSONMode.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, AtlasGraphSONTokens.INTERNAL_ID, element.getId());
}
// are graph implementations that have AtlasEdge extend from AtlasVertex
if (element instanceof AtlasEdge) {
final AtlasEdge edge = (AtlasEdge) element;
if (this.includeReservedEdgeId) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_ID, element.getId());
}
if (this.includeReservedEdgeType) {
jsonElement.put(AtlasGraphSONTokens.INTERNAL_TYPE, AtlasGraphSONTokens.EDGE);
}
if (this.includeReservedEdgeOutV) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_OUT_V, edge.getOutVertex().getId());
}
if (this.includeReservedEdgeInV) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_IN_V, edge.getInVertex().getId());
}
if (this.includeReservedEdgeLabel) {
jsonElement.put(AtlasGraphSONTokens.INTERNAL_LABEL, edge.getLabel());
}
} else if (element instanceof AtlasVertex) {
if (this.includeReservedVertexId) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_ID, element.getId());
}
if (this.includeReservedVertexType) {
jsonElement.put(AtlasGraphSONTokens.INTERNAL_TYPE, AtlasGraphSONTokens.VERTEX);
}
}
return jsonElement;
}
Aggregations