private OEntity toOEntity(EdmEntitySet ees, Entity entity, QueryInfo queryInfo, String parentPropName) {
final List<OProperty<?>> properties = new ArrayList<OProperty<?>>();
final List<OLink> links = new ArrayList<OLink>();
EdmEntityType eet = ees.getType();
String entityKeyName = eet.getKeys().get(0);
OEntityKey entityKey = OEntityKey.create(OProperties.int64(entityKeyName, entity.getKey().getId()));
if (queryInfo == null || queryInfo.select == null || queryInfo.select.size() == 0 || containsProperty(queryInfo.select, entityKeyName, parentPropName)) {
properties.add(OProperties.int64(entityKeyName, entity.getKey().getId()));
}
for (String propName : entity.getProperties().keySet()) {
Object propValue = entity.getProperty(propName);
if (propValue == null)
continue;
if (queryInfo != null && queryInfo.select != null && queryInfo.select.size() > 0) {
if (!containsProperty(queryInfo.select, propName, parentPropName)) {
continue;
}
}
EdmProperty prop = eet.findProperty(propName);
if (prop != null) {
if (propValue instanceof Text) {
propValue = ((Text) propValue).getValue();
} else if (propValue instanceof ShortBlob) {
propValue = ((ShortBlob) propValue).getBytes();
}
properties.add(OProperties.simple(propName, (EdmSimpleType<?>) prop.getType(), propValue));
} else {
EdmNavigationProperty navProp = eet.findNavigationProperty(propName);
if (navProp != null) {
List<OEntity> expandedProps = new ArrayList<OEntity>();
try {
if (queryInfo != null && queryInfo.expand != null && queryInfo.expand.size() > 0) {
for (EntitySimpleProperty esp : queryInfo.expand) {