} 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) {
if (esp.getPropertyName().equals(propName)) {
EdmEntitySet eesNavProp = metadata.getEdmEntitySet(navProp.getToRole().getRole());
EdmMultiplicity emNavProp = navProp.getRelationship().getEnd2().getMultiplicity();
if (emNavProp == EdmMultiplicity.ZERO_TO_ONE) {
Entity e = datastore.get((Key) propValue);
expandedProps.add(toOEntity(eesNavProp, e, queryInfo, propName));
} else if (emNavProp == EdmMultiplicity.MANY) {
@SuppressWarnings("unchecked")
Collection<Key> keys = (Collection<Key>) propValue;
for (Key key : keys) {
Entity e = datastore.get(key);
expandedProps.add(toOEntity(eesNavProp, e, queryInfo, propName));
}
} else {
throw new NotImplementedException("Property " + propName + " of type " + propValue.getClass().getName());
}
}
}
}
} catch (EntityNotFoundException e) {
e.printStackTrace();
}
if (expandedProps.size() == 0) {
links.add(OLinks.relatedEntity(navProp.getRelationship().getName(), propName, null));
} else {
links.add(OLinks.relatedEntitiesInline(navProp.getRelationship().getName(), propName, null, expandedProps));
}
} else {
throw new NotImplementedException("Property " + propName + " of type " + propValue.getClass().getName());
}
}