private function getPreparedModelData(\Tx_Oelib_Model $model)
    {
        if (!$model->hasUid()) {
            $model->setCreationDate();
        }
        $model->setTimestamp();

        $data = $model->getData();

        foreach ($this->relations as $key => $relation) {
            if ($this->isOneToManyRelationConfigured($key)) {
                $functionName = 'count';
            } elseif ($this->isManyToOneRelationConfigured($key)) {
                $functionName = 'getUid';

                if ($data[$key] instanceof \Tx_Oelib_Model) {
                    $this->saveManyToOneRelatedModels(
                        $data[$key],
                        \Tx_Oelib_MapperRegistry::get($relation)
                    );
                }
            } else {
                if ($this->isManyToManyRelationConfigured($key)) {
                    $functionName = 'count';
                } else {
                    $functionName = 'getUids';
                }

                if ($data[$key] instanceof \Tx_Oelib_List) {
                    $this->saveManyToManyAndCommaSeparatedRelatedModels(
                        $data[$key],
                        \Tx_Oelib_MapperRegistry::get($relation)
                    );
                }
            }

            $data[$key] = (isset($data[$key]) && is_object($data[$key]))
                ? $data[$key]->$functionName() : 0;
        }

        return $data;
    }