'Transform the ReferenceProperties of the given entity to fix app_id.'

def _translate_entity_proto(self, entity_proto):

    entity_key = entity_proto.mutable_key()
    entity_key.set_app(self.app_id)
    original_entity_namespace = entity_key.name_space()
    if self.namespace:
        entity_key.set_name_space(self.namespace)
    else:
        entity_key.clear_name_space()
    for prop in entity_proto.property_list():
        prop_value = prop.mutable_value()
        if prop_value.has_referencevalue():
            self.rewrite_reference_proto(original_entity_namespace, prop_value.mutable_referencevalue())
    for prop in entity_proto.raw_property_list():
        prop_value = prop.mutable_value()
        if prop_value.has_referencevalue():
            self.rewrite_reference_proto(original_entity_namespace, prop_value.mutable_referencevalue())
    return entity_proto
