use of com.google.storage.onestore.PropertyType in project appengine-java-standard by GoogleCloudPlatform.
the class PropertyPseudoKind method getProperties.
/**
* Get the results of a __property__ query over the specified range.
*/
private List<EntityProto> getProperties(String app, String namespace, boolean keysOnly, KindProperty start, boolean startInclusive, KindProperty end, boolean endInclusive) {
Profile profile = getDatastore().getOrCreateProfile(app);
Map<String, Extent> extents = profile.getExtents();
List<EntityProto> schema = Lists.newArrayList();
synchronized (extents) {
// that kind.
for (Map.Entry<String, Extent> entry : extents.entrySet()) {
String kind = entry.getKey();
boolean startKindEqual = false;
boolean endKindEqual = false;
// Apply kind filter (inclusive is only meaningful at the property level).
if (start.kind != null) {
int kindsCompared = kind.compareTo(start.kind);
startKindEqual = kindsCompared == 0;
if (kindsCompared < 0) {
continue;
}
}
if (end.kind != null) {
int kindsCompared = kind.compareTo(end.kind);
endKindEqual = kindsCompared == 0;
if (kindsCompared > 0) {
continue;
}
}
List<EntityProto> entities = getEntitiesForNamespace(entry.getValue(), namespace);
// Skip kinds with no entities in the specified namespace
if (entities.isEmpty()) {
continue;
}
// Collect and add the indexed properties. (schema queries don't
// report unindexed properties; details in http://b/1004244)
SortedSetMultimap<String, String> allProps = TreeMultimap.create();
for (EntityProto entity : entities) {
for (Property prop : entity.propertys()) {
String name = prop.getName();
PropertyType type = PropertyType.getType(prop.getValue());
// Apply start property filter if kind equal to start.kind
if (startKindEqual) {
int propertysCompared = name.compareTo(start.property);
if ((startInclusive && propertysCompared < 0) || (!startInclusive && propertysCompared <= 0)) {
continue;
}
}
// Apply end property filter if kind equal to end.kind
if (endKindEqual) {
int propertysCompared = name.compareTo(end.property);
if ((endInclusive && propertysCompared > 0) || (!endInclusive && propertysCompared >= 0)) {
continue;
}
}
// Skip invisible special properties.
if (getDatastore().getSpecialPropertyMap().containsKey(name) && !getDatastore().getSpecialPropertyMap().get(name).isVisible()) {
continue;
}
allProps.put(name, type.name());
}
}
addPropertyEntitiesToSchema(schema, kind, allProps, app, namespace, keysOnly);
}
}
return schema;
}
Aggregations