use of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue in project appengine-java-standard by GoogleCloudPlatform.
the class DataTypeTranslator method buildImplicitKeyProperty.
private static Property buildImplicitKeyProperty(EntityProto proto) {
Property keyProp = new Property();
keyProp.setName(Entity.KEY_RESERVED_PROPERTY);
PropertyValue propVal = new PropertyValue();
propVal.setReferenceValue(KeyType.toReferenceValue(proto.getKey()));
keyProp.setValue(propVal);
return keyProp;
}
use of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue in project appengine-java-standard by GoogleCloudPlatform.
the class DataTypeTranslator method getPropertyValue.
/**
* Returns the value for the property as its canonical type.
*
* @param property a not {@code null} property
* @return {@code null} if no value was set for {@code property}
*/
@Nullable
public static Object getPropertyValue(Property property) {
int meaningInt = property.getMeaning();
PropertyValue value = property.getValue();
if (meaningInt == 0) {
// The value has no meaning. Check possible types, most likely first.
for (Type<?> type : TYPES_WITHOUT_MEANING_IN_EXPECTED_FREQUENCY_ORDER) {
if (type.hasValue(value)) {
return type.getValue(value);
}
}
// The value is null or malformed.
} else if ((meaningInt > 0) && (meaningInt < MEANING_INT_TO_TYPE.length)) {
// The value has a meaning. Check that meaning's type.
Type<?> type = MEANING_INT_TO_TYPE[meaningInt];
if ((type != null) && type.hasValue(value)) {
return type.getValue(value);
}
// The value is malformed.
} else {
// The value is malformed.
}
return null;
}
use of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue in project appengine-java-standard by GoogleCloudPlatform.
the class LocalDatastoreService method validateRawPropLengthLimit.
private void validateRawPropLengthLimit(Property property) {
String name = property.getName();
PropertyValue value = property.getValue();
if (!value.hasStringValue() || !property.hasMeaning()) {
return;
}
if (property.getMeaningEnum() == Property.Meaning.BLOB || property.getMeaningEnum() == Property.Meaning.ENTITY_PROTO || property.getMeaningEnum() == Property.Meaning.TEXT) {
if (value.getStringValueAsBytes().length > MAX_BLOB_LENGTH) {
throw newError(ErrorCode.BAD_REQUEST, "Property " + name + " is too long. It cannot exceed " + MAX_BLOB_LENGTH + " bytes.");
}
}
}
use of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue in project appengine-java-standard by GoogleCloudPlatform.
the class EntityGroupPseudoKind method makeEntityGroupEntity.
/**
* Creates an __entity_group__ entity
*/
private static EntityProto makeEntityGroupEntity(Reference key, long version) {
EntityProto egEntity = new EntityProto().setKey(key);
// EntityProto.entity_group is a required PB field.
egEntity.getMutableEntityGroup().addElement(key.getPath().getElement(0));
PropertyValue value = new PropertyValue().setInt64Value(version);
egEntity.addProperty().setMultiple(false).setName(VERSION_RESERVED_PROPERTY).setValue(value);
return egEntity;
}
use of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue in project appengine-java-standard by GoogleCloudPlatform.
the class PropertyPseudoKind method addPropertyEntitiesToSchema.
/**
* Build __property__ entities from results of scanning entities, and add them to the schema
*/
private static void addPropertyEntitiesToSchema(List<EntityProto> schema, String kind, SortedSetMultimap<String, String> allProps, String app, String namespace, boolean keysOnly) {
// {@link SortedSet}s so the results will be ordered.
for (String prop : allProps.keySet()) {
// Create schema entity and set its key based on the kind
EntityProto propEntity = new EntityProto();
schema.add(propEntity);
Path path = new Path();
path.addElement().setType(KIND_METADATA_KIND).setName(kind);
path.addElement().setType(PROPERTY_METADATA_KIND).setName(prop);
Reference key = new Reference().setApp(app).setPath(path);
if (namespace.length() > 0) {
key.setNameSpace(namespace);
}
propEntity.setKey(key);
// EntityProto.entity_group is a required PB field.
propEntity.getMutableEntityGroup().addElement(path.getElement(0));
if (!keysOnly) {
for (String rep : allProps.get(prop)) {
PropertyValue repValue = new PropertyValue().setStringValue(rep);
propEntity.addProperty().setName("property_representation").setValue(repValue).setMultiple(true);
}
}
}
}
Aggregations