use of com.google.api.ads.admanager.axis.v202205.Value in project entity-service by hypertrace.
the class PrimitiveFilteringExpressionConverter method convert.
@Override
public FilterTypeExpression convert(final ColumnIdentifier columnIdentifier, final Operator operator, final LiteralConstant constant, final RequestContext requestContext) throws ConversionException {
final String id = columnIdentifier.getColumnName();
final String subDocPath = getSubDocPathById(entityAttributeMapping, id, requestContext);
final Value value = constant.getValue();
final ValueType valueType = value.getValueType();
final IdentifierConverter identifierConverter = identifierConverterFactory.getIdentifierConverter(id, subDocPath, valueType, requestContext);
final IdentifierConversionMetadata metadata = IdentifierConversionMetadata.builder().subDocPath(subDocPath).operator(operator).valueType(valueType).build();
final String suffixedSubDocPath = identifierConverter.convert(metadata, requestContext);
final IdentifierExpression identifierExpression = IdentifierExpression.of(suffixedSubDocPath);
final RelationalOperator relationalOperator = convertOperator(operator);
final ConstantExpression constantExpression = constantExpressionConverter.convert(constant, requestContext);
return RelationalExpression.of(identifierExpression, relationalOperator, constantExpression);
}
use of com.google.api.ads.admanager.axis.v202205.Value in project entity-service by hypertrace.
the class DocumentConverterImpl method buildRow.
private Row buildRow(final ResultSetMetadata resultSetMetadata, final Map<String, Value> valueMap) {
final Row.Builder builder = Row.newBuilder();
final Value defaultValue = getNullPlaceholderValue();
for (final ColumnMetadata columnMetadata : resultSetMetadata.getColumnMetadataList()) {
final Value value = valueMap.getOrDefault(columnMetadata.getColumnName(), defaultValue);
builder.addColumn(value);
}
return builder.build();
}
use of com.google.api.ads.admanager.axis.v202205.Value in project entity-service by hypertrace.
the class ArrayGetter method getValue.
@Override
public Value getValue(final JsonNode jsonNode) throws ConversionException {
final Iterator<JsonNode> elements = jsonNode.elements();
final List<Value> values = new ArrayList<>();
while (elements.hasNext()) {
final JsonNode node = elements.next();
final Value value;
if (nestedValueGetter.matches(node)) {
value = nestedValueGetter.getValue(node);
} else if (directValueGetter.matches(node)) {
value = directValueGetter.getValue(node);
} else {
throw new ConversionException(String.format("Unexpected node (%s) found", node));
}
values.add(value);
}
final ValueType primitiveType = values.stream().map(Value::getValueType).findFirst().orElse(STRING);
final ValueType type = valueHelper.getArrayValueType(primitiveType);
final Value.Builder valueBuilder = Value.newBuilder().setValueType(type);
switch(type) {
case STRING_ARRAY:
values.stream().map(Value::getString).forEach(valueBuilder::addStringArray);
break;
case INT_ARRAY:
values.stream().map(Value::getInt).forEach(valueBuilder::addIntArray);
break;
case LONG_ARRAY:
values.stream().map(Value::getLong).forEach(valueBuilder::addLongArray);
break;
case FLOAT_ARRAY:
values.stream().map(Value::getFloat).forEach(valueBuilder::addFloatArray);
break;
case DOUBLE_ARRAY:
values.stream().map(Value::getDouble).forEach(valueBuilder::addDoubleArray);
break;
case BYTES_ARRAY:
values.stream().map(Value::getBytes).forEach(valueBuilder::addBytesArray);
break;
case BOOLEAN_ARRAY:
values.stream().map(Value::getBoolean).forEach(valueBuilder::addBooleanArray);
break;
default:
throw new ConversionException(String.format("Unknown array type: %s", type));
}
return valueBuilder.build();
}
use of com.google.api.ads.admanager.axis.v202205.Value in project entity-service by hypertrace.
the class MapValueGetter method getValue.
@Override
public Value getValue(final JsonNode jsonNode) throws ConversionException {
final JsonNode valuesNode = jsonNode.get(VALUE_MAP_KEY);
if (valuesNode == null || !valuesNode.isObject()) {
throw new ConversionException(String.format("Unexpected node (%s) found under %s", valuesNode, VALUE_MAP_KEY));
}
final JsonNode mapNode = valuesNode.get(VALUES_KEY);
final Iterator<Entry<String, JsonNode>> fields = mapNode == null ? emptyIterator() : mapNode.fields();
final Value.Builder valueBuilder = Value.newBuilder().setValueType(STRING_MAP);
while (fields.hasNext()) {
final Entry<String, JsonNode> entry = fields.next();
final String key = entry.getKey();
final JsonNode node = entry.getValue();
if (!nestedValueGetter.matches(node)) {
throw new ConversionException(String.format("Unexpected node (%s) found for key (%s)", node, key));
}
final Value value = nestedValueGetter.getValue(node);
final Object objValue = valueOneOfAccessor.access(value, value.getValueType());
valueBuilder.putStringMap(key, objValue.toString());
}
return valueBuilder.build();
}
use of com.google.api.ads.admanager.axis.v202205.Value in project grpc-gcp-java by GoogleCloudPlatform.
the class DataStoreChecksumClient method simpleLookup.
private static void simpleLookup(DatastoreBlockingStub stub, String projectId) {
PathElement pathElement = PathElement.newBuilder().setKind("Person").setName("weiranf").build();
Key key = Key.newBuilder().addPath(pathElement).build();
LookupRequest lookupRequest = LookupRequest.newBuilder().setProjectId(projectId).addKeys(key).build();
LookupResponse lookupResponse = stub.lookup(lookupRequest);
if (lookupResponse.getFoundCount() > 0) {
System.out.println("ENTITY FOUND:");
Entity entity = lookupResponse.getFound(0).getEntity();
Map<String, Value> map = entity.getPropertiesMap();
for (Map.Entry<String, Value> entry : map.entrySet()) {
System.out.printf("%s => %s\n", entry.getKey(), entry.getValue().getStringValue());
}
} else {
System.out.println("NO ENTITY FOUND!");
}
}
Aggregations