use of org.apache.atlas.repository.graphdb.AtlasElement in project atlas by apache.
the class AtlasGraphSONUtility method createJSONMap.
private static ObjectNode createJSONMap(final Map<String, Object> map, final List<String> propertyKeys, final boolean showTypes) {
final ObjectNode jsonMap = JSON_NODE_FACTORY.objectNode();
for (Object key : map.keySet()) {
Object value = map.get(key);
if (value != null) {
if (value instanceof List) {
value = createJSONList((List<Object>) value, propertyKeys, showTypes);
} else if (value instanceof Map) {
value = createJSONMap((Map<String, Object>) value, propertyKeys, showTypes);
} else if (value instanceof AtlasElement) {
value = objectNodeFromElement((AtlasElement) value, propertyKeys, showTypes ? AtlasGraphSONMode.EXTENDED : AtlasGraphSONMode.NORMAL);
} else if (value.getClass().isArray()) {
value = createJSONList(convertArrayToList(value), propertyKeys, showTypes);
}
}
putObject(jsonMap, key.toString(), getValue(value, showTypes));
}
return jsonMap;
}
use of org.apache.atlas.repository.graphdb.AtlasElement in project incubator-atlas by apache.
the class Titan0Element method setPropertyFromElementsIds.
@Override
public void setPropertyFromElementsIds(String propertyName, List<AtlasElement> values) {
List<String> propertyValue = new ArrayList<>(values.size());
for (AtlasElement element : values) {
propertyValue.add(element.getId().toString());
}
setProperty(propertyName, propertyValue);
}
use of org.apache.atlas.repository.graphdb.AtlasElement in project incubator-atlas by apache.
the class AtlasGraphSONUtility method createJSONMap.
private static ObjectNode createJSONMap(final Map<String, Object> map, final List<String> propertyKeys, final boolean showTypes) {
final ObjectNode jsonMap = JSON_NODE_FACTORY.objectNode();
for (Object key : map.keySet()) {
Object value = map.get(key);
if (value != null) {
if (value instanceof List) {
value = createJSONList((List<Object>) value, propertyKeys, showTypes);
} else if (value instanceof Map) {
value = createJSONMap((Map<String, Object>) value, propertyKeys, showTypes);
} else if (value instanceof AtlasElement) {
value = objectNodeFromElement((AtlasElement) value, propertyKeys, showTypes ? AtlasGraphSONMode.EXTENDED : AtlasGraphSONMode.NORMAL);
} else if (value.getClass().isArray()) {
value = createJSONList(convertArrayToList(value), propertyKeys, showTypes);
}
}
putObject(jsonMap, key.toString(), getValue(value, showTypes));
}
return jsonMap;
}
use of org.apache.atlas.repository.graphdb.AtlasElement in project incubator-atlas by apache.
the class GraphHelper method findElement.
private AtlasElement findElement(boolean isVertexSearch, Object... args) throws EntityNotFoundException {
AtlasGraphQuery query = graph.query();
for (int i = 0; i < args.length; i += 2) {
query = query.has((String) args[i], args[i + 1]);
}
Iterator<AtlasElement> results = isVertexSearch ? query.vertices().iterator() : query.edges().iterator();
AtlasElement element = (results != null && results.hasNext()) ? results.next() : null;
if (element == null) {
throw new EntityNotFoundException("Could not find " + (isVertexSearch ? "vertex" : "edge") + " with condition: " + getConditionString(args));
}
if (LOG.isDebugEnabled()) {
LOG.debug("Found {} with condition {}", string(element), getConditionString(args));
}
return element;
}
use of org.apache.atlas.repository.graphdb.AtlasElement in project atlas by apache.
the class GraphHelper method findElement.
private AtlasElement findElement(boolean isVertexSearch, Object... args) throws EntityNotFoundException {
AtlasGraphQuery query = graph.query();
for (int i = 0; i < args.length; i += 2) {
query = query.has((String) args[i], args[i + 1]);
}
Iterator<AtlasElement> results = isVertexSearch ? query.vertices().iterator() : query.edges().iterator();
AtlasElement element = (results != null && results.hasNext()) ? results.next() : null;
if (element == null) {
throw new EntityNotFoundException("Could not find " + (isVertexSearch ? "vertex" : "edge") + " with condition: " + getConditionString(args));
}
if (LOG.isDebugEnabled()) {
LOG.debug("Found {} with condition {}", string(element), getConditionString(args));
}
return element;
}
Aggregations