Gets the datalist of records in the given group in the current state

Assumes that the desired variant state is in effect.

@param SolrIndex $indexInstance
@param string $class
@param int $groups
@param int $group
@return DataList
337098
protected function getRecordsInGroup(SolrIndex $indexInstance, $class, $groups, $group)
    {
        // Generate filtered list of local records
        $baseClass = DataObject::getSchema()->baseDataClass($class);
        $items = DataList::create($class)
            ->where(sprintf(
                '"%s"."ID" %% \'%d\' = \'%d\'',
                DataObject::getSchema()->tableName($baseClass),
                intval($groups),
                intval($group)
            ))
            ->sort("ID");

        // Add child filter
        $classes = $indexInstance->getClasses();
        $options = $classes[$class];
        if (!$options['include_children']) {
            $items = $items->filter('ClassName', $class);
        }

        return $items;
    }
915421
public function getCollection($collectionClass = CreateFromAttributesInterface::class)
    {
        $collection = [];
        if ($this->isSuccessful()) {
            $data = $this->getData();
            foreach ($data as $attributes) {
                /** @var AbstractModel $collectionClass */
                $collection[] = $collectionClass::createFromAttributes($attributes);
            }
        }

        return $collection;
    }
573359
public function getBatchObjects($class, ProxyQueryInterface $queryProxy)
    {
        $queryProxy->select('DISTINCT '.$queryProxy->getRootAlias());

        return $queryProxy->getQuery()->execute();
    }
1325487
public function getJoinedGroupList($limit, $offset, $groupType = null, $responseFilter = null)
    {
        $request = new GetJoinedGroupListRequest($this->identifier, $limit, $offset, $groupType, $responseFilter);
        $response = new GetJoinedGroupListResponse();
        return $this->client->sendRequest($request, $response);
    }
510941
@Override
    public Iterator findEntitiesForGroup(IEntityGroup group) throws GroupsException {
        Collection entities = new ArrayList();
        Connection conn = null;
        String groupID = group.getLocalKey();
        Class cls = group.getLeafType();

        try {
            conn = RDBMServices.getConnection();
            Statement stmnt = conn.createStatement();
            try {

                String query =
                        "SELECT "
                                + MEMBER_MEMBER_KEY_COLUMN
                                + " FROM "
                                + MEMBER_TABLE
                                + " WHERE "
                                + MEMBER_GROUP_ID_COLUMN
                                + " = '"
                                + groupID
                                + "' AND "
                                + MEMBER_IS_GROUP_COLUMN
                                + " = '"
                                + MEMBER_IS_ENTITY
                                + "'";

                ResultSet rs = stmnt.executeQuery(query);
                try {
                    while (rs.next()) {
                        String key = rs.getString(1);
                        IEntity e = newEntity(cls, key);
                        entities.add(e);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                stmnt.close();
            }
        } catch (SQLException sqle) {
            LOG.error("Problem retrieving Entities for Group: " + group, sqle);
            throw new GroupsException("Problem retrieving Entities for Group", sqle);
        } finally {
            RDBMServices.releaseConnection(conn);
        }

        return entities.iterator();
    }
187726
protected function cacheDefaultDatabaseIndexes($class)
    {
        if (array_key_exists($class, $this->defaultDatabaseIndexes)) {
            return $this->defaultDatabaseIndexes[$class];
        }
        $this->defaultDatabaseIndexes[$class] = [];

        $fieldSpecs = $this->fieldSpecs($class, self::UNINHERITED);
        foreach ($fieldSpecs as $field => $spec) {
            /** @var DBField $fieldObj */
            $fieldObj = Injector::inst()->create($spec, $field);
            if ($indexSpecs = $fieldObj->getIndexSpecs()) {
                $this->defaultDatabaseIndexes[$class][$field] = $indexSpecs;
            }
        }
        return $this->defaultDatabaseIndexes[$class];
    }
1332143
private function getManagerForClass($class)
    {
        $tries = [];

        foreach ($this->managers as $manager) {
            if ($manager->supportsClass($class)) {
                return $manager;
            }

            $tries[] = get_class($manager);
        }

        throw new \RuntimeException(
            sprintf(
                'Class "%s" is not supported by any UserManager. Tried "%s".',
                $class,
                implode('", "', $tries)
            )
        );
    }
1087033
public function setGroupClass(string $classname)
    {
        if (!class_exists($classname) || !is_subclass_of($classname, GroupInterface::class))
            throw new DomainException("Invalid group class: $classname");
        $this->group_class = $classname;
        return $this;
    }
481550
public function fetchAllObj(string $class = null): array
    {
        if (!$this->wasExecuted()) {
            $this->exec();
        }

        if ($class === null) {
            return $this->getAdapter()->getStatement()->fetchAll(\PDO::FETCH_OBJ);
        } else {
            $objectInstances = [];

            foreach ($this->fetchAll() as $r) {
                $objectInstances[] = new $class($r);
            }

            return $objectInstances;
        }
    }
777107
public function getGroup($group)
    {
        $timeStamp = time();
        if ($group instanceof BundleEntity\MemberGroup) {
            return new ModelResponse($group, 1, 0, null, false, 'S:D:002', 'Entries successfully fetched from database.', $timeStamp, time());
        }
        $result = null;
        switch ($group) {
            case is_numeric($group):
                $result = $this->em->getRepository($this->entity['mg']['name'])->findOneBy(array('id' => $group));
                break;
            case is_string($group):
                $result = $this->em->getRepository($this->entity['mg']['name'])->findOneBy(array('code' => $group));
                break;
        }
        if (is_null($result)) {
            return new ModelResponse($result, 0, 0, null, true, 'E:D:002', 'Unable to find request entry in database.', $timeStamp, time());
        }

        return new ModelResponse($result, 1, 0, null, false, 'S:D:002', 'Entries successfully fetched from database.', $timeStamp, time());
    }
142008
public function getItems($locale, $namespace, $group)
    {
        return $this->model
            ->whereLocale($locale)
            ->whereNamespace($namespace)
            ->whereGroup($group)
            ->get()
            ->toArray();
    }
686604
public function findByIds($class, array $ids)
    {
        if (count($ids) === 0) {
            return array();
        }

        $dql = "SELECT object FROM {$class} object WHERE object.id IN (:ids)";
        $query = $this->wrapped->createQuery($dql);
        $query->setParameter('ids', $ids);
        $objects = $query->getResult();

        if (($entityCount = count($objects)) !== ($idCount = count($ids))) {
            throw new MissingObjectException(
                "{$entityCount} out of {$idCount} ids don't match any existing object"
            );
        }

        return $objects;
    }
1307486
public static function map_in_groups($groups = null)
    {
        $groupIDList = array();

        if ($groups instanceof SS_List) {
            foreach ($groups as $group) {
                $groupIDList[] = $group->ID;
            }
        } elseif (is_array($groups)) {
            $groupIDList = $groups;
        } elseif ($groups) {
            $groupIDList[] = $groups;
        }

        // No groups, return all Members
        if (!$groupIDList) {
            return static::get()->sort(array('Surname' => 'ASC', 'FirstName' => 'ASC'))->map();
        }

        $membersList = new ArrayList();
        // This is a bit ineffective, but follow the ORM style
        /** @var Group $group */
        foreach (Group::get()->byIDs($groupIDList) as $group) {
            $membersList->merge($group->Members());
        }

        $membersList->removeDuplicates('ID');

        return $membersList->map();
    }
315867
public function getActiveRecordObjects($class, $orderBy=NULL, $descOrder=FALSE) {

		if (!class_exists($class) or !is_subclass_of($class, 'Pair\ActiveRecord')) {
			return array();
		}
		
		// sets pagination count
		$this->db->setQuery('SELECT COUNT(*) FROM `' . $class::TABLE_NAME . '`');
		$this->pagination->count = $this->db->loadCount();
	
		$orderDir = $descOrder ? 'DESC' : 'ASC';
		
		$query =
			'SELECT *' .
			' FROM `' . $class::TABLE_NAME . '`' .
			($orderBy ? ' ORDER BY `' . $orderBy . '` ' . $orderDir : NULL) .
			' LIMIT ' . $this->pagination->start . ', ' . $this->pagination->limit;
	
		$this->db->setQuery($query);
		$list = $this->db->loadObjectList();
	
		$objects = array();
	
		foreach ($list as $item) {
			$objects[] = new $class($item);
		}

		return $objects;
	
	}
978929
public function getGroup(int $index): Group
    {
        if ($index >= count($this->groups)) {
            throw new \UndefinedOffsetException();
        }
        return $this->groups[$index];
    }
123740
public function source(string $class): RecordSource
    {
        $source = $this->define($class, self::R_SOURCE_CLASS);

        if (empty($source)) {
            //Let's use default source
            $source = RecordSource::class;
        }

        $handles = $source::RECORD;
        if (empty($handles)) {
            //Force class to be handled
            $handles = $class;
        }

        return $this->getFactory()->make($source, [
            'class' => $handles,
            'orm'   => $this
        ]);
    }
1168903
public function classHasTable($class)
    {
        if (!is_subclass_of($class, DataObject::class)) {
            return false;
        }

        $fields = $this->databaseFields($class, false);
        return !empty($fields);
    }