Retrieve Model class connected to Entity
971464
def get_model(self, entity_cls):
        """"""
        entity_record = self._get_entity_by_class(entity_cls)

        model_cls = None
        if entity_record.model_cls:
            model_cls = entity_record.model_cls
        else:
            # We should ask the Provider to give a fully baked model the first time
            #   that has been initialized properly for this entity
            provider = self.get_provider(entity_record.provider_name)
            baked_model_cls = provider.get_model(entity_record.entity_cls)

            # Record for future reference
            new_entity_record = entity_record._replace(model_cls=baked_model_cls)
            self._registry[entity_record.qualname] = new_entity_record

            model_cls = baked_model_cls

        return model_cls
232999
def get_model(obj):
    
    p = obj
    while hasattr(p, 'parent'):
        p = p.parent
    return p
1369082
public function findModelClassObject($modelClass, $id, $relationContext)
    {
        $keys = $modelClass::primaryKey();
        if (count($keys) > 1) {
            $values = explode(',', $id);
            if (count($keys) === count($values)) {
                return $this->findModelFromCondition(array_combine($keys, $values), $keys, $modelClass, $relationContext);
            }
        } elseif ($id !== null) {
            return $this->findModelFromCondition($id, $keys, $modelClass, $relationContext);
        }

        return false;
    }
1033412
def get_form_class(self):
        
        if self.form_class:
            form_class = self.form_class

        else:
            if self.model is not None:
                # If a model has been explicitly provided, use it
                model = self.model
            elif hasattr(self, 'object') and self.object is not None:
                # If this view is operating on a single object, use
                # the class of that object
                model = self.object.__class__
            else:
                # Try to get a queryset and extract the model class
                # from that
                model = self.get_queryset().model

            # run time parameters when building our form
            factory_kwargs = self.get_factory_kwargs()
            form_class = model_forms.modelform_factory(model, **factory_kwargs)

        return form_class
34962
def fetch_entity_cls_from_registry(entity):
    """"""
    # Defensive check to ensure we only process if `to_cls` is a string
    if isinstance(entity, str):
        try:
            return repo_factory.get_entity(entity)
        except AssertionError:
            # Entity has not been registered (yet)
            # FIXME print a helpful debug message
            raise
    else:
        return entity
394508
public static TableModel entity2ReadOnlyModel(Class<?> entityClass) {
		DialectException.assureNotNull(entityClass, "Entity class can not be null");
		TableModel model = globalTableModelCache.get(entityClass);
		if (model != null)
			return model;
		model = entity2ModelWithConfig(entityClass);
		model.setReadOnly(true);
		globalTableModelCache.put(entityClass, model);
		return model;
	}
434355
private final Object find(Class<?> clazz, EntityMetadata metadata, Object rowId, List<String> relationNames) {

        List<Object> result = null;
        try {
            MetamodelImpl metaModel =
                (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());

            EntityType entityType = metaModel.entity(clazz);

            List<ManagedType> subTypes = ((AbstractManagedType) entityType).getSubManagedType();

            if (!subTypes.isEmpty()) {
                for (ManagedType subEntity : subTypes) {
                    EntityMetadata subEntityMetadata =
                        KunderaMetadataManager.getEntityMetadata(kunderaMetadata, subEntity.getJavaType());
                    result = populate(clazz, subEntityMetadata, rowId, subEntityMetadata.getRelationNames(), metaModel);
                    if (result != null && !result.isEmpty()) {
                        break;
                    }
                }
            } else {
                result = populate(clazz, metadata, rowId, relationNames, metaModel);
            }
        } catch (Exception e) {
            log.error("Error while retrieving records from database for entity {} and key {}, Caused by: .", clazz,
                rowId, e);

            throw new PersistenceException(e);
        }

        return result != null && !result.isEmpty() ? result.get(0) : null;
    }
379693
def get_model_at_related_field(model, attr):
    

    field = model._meta.get_field(attr)

    if hasattr(field, 'related_model'):
        return field.related_model

    raise ValueError("{model}.{attr} ({klass}) is not a relationship field.".format(**{
        'model': model.__name__,
        'attr': attr,
        'klass': field.__class__.__name__,
    }))
489841
def create_model_class(cls, name, table_name, attrs, validations=None, *, otherattrs=None,
                         other_bases=None):
    """"""
    members = dict(table_name=table_name, attrs=attrs, validations=validations or [])
    if otherattrs:
      members.update(otherattrs)
    return type(name, other_bases or (), members)
696711
def get_data(self, entity):
        """"""
        data = self._filter_queryset('view_data', entity.data.all())

        return self._serialize_data(data)
56715
def timeline_entities_for_model(model_class)
      @timeline_entities_for_model[model_class] ||= begin
        result = { }

        self.timelines.each do |timeline_kind, timeline_class|
          result[timeline_class] = [ ]

          timeline_class.routes.each do |route|
            entities_ary = @activity_entities[route.activity_class]
            (entities_ary || [ ]).each do |entity_name|
              result[timeline_class] << entity_name if (@entity_classes[entity_name] == model_class)
            end
          end

          result[timeline_class].uniq!
        end

        result
      end
    end
60197
def models(klass)
      return @models if defined? @models
      return [] if frozen?

      # Use select_all to retrieve hashes for each row instead of arrays of values.
      @models = connection.
        select_all(query, "#{klass.name} Load via #{self.class.name}").
          collect! { |record| klass.send :instantiate, record }

      retrieve_found_row_count
      freeze

      @models
    end
358193
def _select_class(self, line):
        
        g = self.current['graph']
        if not line:
            out = g.all_classes
            using_pattern = False
        else:
            using_pattern = True
            if line.isdigit():
                line = int(line)
            out = g.get_class(line)
        if out:
            if type(out) == type([]):
                choice = self._selectFromList(out, using_pattern, "class")
                if choice:
                    self.currentEntity = {'name': choice.locale or choice.uri,
                                          'object': choice, 'type': 'class'}
            else:
                self.currentEntity = {'name': out.locale or out.uri, 'object': out, 'type': 'class'}
            # ..finally:
            if self.currentEntity:
                self._print_entity_intro(entity=self.currentEntity)

        else:
            print("not found")
1020382
def _get_object_class(cls, class_name):
        

        class_name = class_name.lstrip(cls.__STRING_FORMAT_UNDERSCORE)

        if class_name in cls._override_field_map:
            class_name = cls._override_field_map[class_name]

        try:
            return getattr(endpoint, class_name)
        except AttributeError:
            pass

        try:
            return getattr(object_, class_name)
        except AttributeError:
            pass

        raise BunqException(cls._ERROR_MODEL_NOT_FOUND.format(class_name))
609500
def get_state_data(cls, entity):
        
        attrs = get_domain_class_attribute_iterator(type(entity))
        return dict([(attr,
                      get_nested_attribute(entity, attr.entity_attr))
                     for attr in attrs
                     if not attr.entity_attr is None])
1246656
static synchronized <T extends Model> void load(T entity, Cursor cursor) {
		sAdapterHolder.getModelAdapter(entity.getClass()).load(entity, cursor);
	}
1029403
def _get_entity_by_class(self, entity_cls):
        """"""
        entity_qualname = fully_qualified_name(entity_cls)
        if entity_qualname in self._registry:
            return self._registry[entity_qualname]
        else:
            return self._find_entity_in_records_by_class_name(entity_cls.__name__)