This method is used to return an array of entity row data that have either
been changed or are new.

@return array
160778
public function getAffectedRowData()
    {
        $data = array();

        $description = $this->getEntityDescription();

        switch ($this->getEntityState()) {
            case AnDomain::STATE_NEW :
                //get all the serializable property/value pairs
                foreach ($description->getProperty() as $name => $property) {
                    if ($property instanceof AnDomainPropertySerializable) {
                        $data[$name] = $name;
                    }
                }
                //@TODO why are we forcing to unset the property
                //unset($data[$description->getIdentityProperty()->getName()]);
                break;
            case AnDomain::STATE_MODIFIED :
                //get all the updated serializable property/value pairs
                $data = array_keys($this->_modified);
                break;
            case  AnDomain::STATE_DELETED :
                break;
            default :
                return $data;
        }

        $tmp = array();

        foreach ($data as $name) {
            $value = $this->get($name);
            $property = $description->getProperty($name);
            $tmp = array_merge($tmp, $property->serialize($value));
        }

        $data = $tmp;

        if ($description->getInheritanceColumn() && $this->getEntityState() == AnDomain::STATE_NEW) {
            $data[(string) $description->getInheritanceColumn()] = (string) $description->getInheritanceColumnValue();
        }

        return $data;
    }
301483
public function getVersions()
    {
        $record = $this->getRecord();
        $return = ArrayList::create();

        if ($record->hasExtension(Versioned::class)) {
            $versions = $record->AllVersions();

            foreach ($versions as $version) {
                $i = $version->Version;
                $diff = null;

                if ($i > 1) {
                    $frm = Versioned::get_version(
                        $record->ClassName,
                        $record->ID,
                        $i - 1
                    );
                    $to = Versioned::get_version(
                        $record->ClassName,
                        $record->ID,
                        $i
                    );
                    if ($frm && $to) {
                        $diff = DataDifferencer::create($frm, $to);
                        $diff->ignoreFields(["LastEdited"]);
                    }
                }

                $return->add(ArrayData::create(
                    [
                        "Version" => $version,
                        "Diff" => $diff
                    ]
                ));
            }
        }

        $this->extend("updateVersions", $versions);

        return $return;
    }
373374
public function getFieldsData()
    {
        $fieldsData = array();
        foreach ($this->getFields() as $field) {
            $fieldData = $this->$field;
            // If the field is an Entity, decode it.
            if ($fieldData instanceof self) {
                $fieldData = $fieldData->getFieldsData();
            } elseif (@reset($fieldData) instanceof Entity) {
                // If the field is an array of Entity, decode them all.
                $newFieldData = array();
                foreach ($fieldData as $key => $entity) {
                    $newFieldData[$key] = $entity->getFieldsData();
                }
                $fieldData = $newFieldData;
            }

            $fieldsData[$field] = $fieldData;
        }

        return $fieldsData;
    }
1013686
public function changes()
    {
        $changes = array();
        foreach(array_unique($this->_changed) as $key)
            $changes[$key] = $this->get($key, false);

        return $changes;
    }
833811
public function changedFieldNames()
    {
        $diffed = clone $this->fromRecord;
        $fields = array_keys($diffed->toMap());

        $changedFields = [];

        foreach ($fields as $field) {
            if (in_array($field, $this->ignoredFields)) {
                continue;
            }
            if ($this->fromRecord->$field != $this->toRecord->$field) {
                $changedFields[] = $field;
            }
        }

        return $changedFields;
    }
1036849
public function getChangedAttributes()
    {
        $output = array();

        foreach ($this->attributes as $name => $value) {
            if ($this->hasChanged($name)) {
                $output[$name] = $value;
            }
        }

        return $output;
    }
23094
protected function buildUpData()
    {
        $data   = [];
        $fields = $this->definition->getEditableFieldNames();
        foreach ($fields as $field) {
            $data[$field] = $this->entity->getRaw($field);
            $fixed        = $this->definition->getField($field, 'value');
            if ($fixed) {
                $data[$field] = $fixed;
            }
        }
        return $data;
    }
1076656
protected function getData()
    {
        $data = [];
        foreach ($this->data as $dataValue) {
            $row = [];
            foreach ($this->table->getColumns() as $column) {
                if ($column instanceof ColumnInterface) {
                    $row[$column->getData()] = $column->getContent($dataValue);
                    continue;
                }

                if (is_callable($column->getFormatter())) {
                    $row[$column->getData()] = call_user_func_array(
                        $column->getFormatter(),
                        [
                            $dataValue[$column->getData()],
                            $dataValue
                        ]
                    );
                } else {
                    $row[$column->getData()] = (string)$dataValue[$column->getData()];
                }
            }
            $data[] = $row;
        }

        return $data;
    }
620504
protected function getDefaultRow()
    {
        $results = array();
        foreach ($this->getFields() as $name => $field) {
            $results[$name] = $field->getDefault();
        }
        return $results;
    }
603274
protected function getData()
    {
        $data = [];
        foreach ($this->_schema as $name => $desc) {
            $data[$name] = $this->$name;
            if (isset($desc['updateDate']) && $desc['updateDate']) {
                $data[$name] = new MongoDate();
            }
        }
        if ($data['_id'] === null) {
            // @codeCoverageIgnoreStart
            unset($data['_id']);
            // @codeCoverageIgnoreEnd
        }
        return $data;
    }
998849
public function getUpdated()
    {
        $set = new ArrayList();
        foreach ($this->updated as $arrItem) {
            $set->push(ArrayData::create($arrItem));
        }
        return $set;
    }
165064
public function getRows()
    {
        $query = $this->getQuery();
        
        if (!empty($this->columns)) {
            $query->select(implode(', ', $this->columns));
        }
        
        foreach ($this->sort as $key => $value) {
            $query->sortBy($key, $value);
        }
        
        if ($this->range) {
            $query->limit($this->start, $this->range);
        }
        
        if (!empty($this->group)) {
            $query->groupBy($this->group);
        }
        
        return $this->database->query($query, $this->database->getBinds());
    }
681401
public function getNewMigrations( )
    {
        // check if migration table exists
        $exists = $this->db->tableExists( $this->migrationTable );
        
        if ( !$exists )
        {
            $this->createMigrationTable( );
        }
        
        $query = "SELECT * FROM $this->migrationTable";
        
        $applied = $this->db->query( $query );
        
        $migrations = $this->getMigrations();
        
        $list = array();
        
        foreach( $migrations as $migration )
        {
            $done = FALSE;
            $migToFind = NULL;
            
            foreach( $this->namespaces as $ns )
            {
                $cls = $ns . $migration;
                
                if ( class_exists( $cls ) )
                {
                    $migToFind = $cls;
                    
                    break;
                }
            }
            
            foreach( $applied as $mig )
            {
                if ( $mig[ 'migration_name' ] === $migToFind )
                {
                    $done = TRUE;
                    break;
                }
            }
            
            if ( !$done )
            {
                $list[] = $migration;
            }
        }
        
        return $this->filter( self::ON_GET_NEW_MIGRATIONS_FILTER, $list );
    }
799517
protected function commitChanges(): array
    {
        $updated = [];
        foreach ($this->sortedTables() as $table) {
            if ($table->getStatus() == AbstractTable::STATUS_DECLARED_DROPPED) {
                $table->save(HandlerInterface::DO_DROP);
                continue;
            }

            $updated[] = $table;
            $table->save(
                HandlerInterface::DO_ALL
                ^ HandlerInterface::DROP_FOREIGN_KEYS
                ^ HandlerInterface::DROP_INDEXES
                ^ HandlerInterface::CREATE_FOREIGN_KEYS
            );
        }

        return $updated;
    }
950650
public function getOriginalData()
    {
        $data = $this->data;
        $originals = array();
        foreach ($this->getOriginalFields() as $field) {
            $key = 'original_' . $field;
            if (array_key_exists($key, $data)) {
                $originals[$field] = $data[$key];
            }
        }
        return $originals;
    }
508455
protected function getUpdatedEventAttributes(): array
    {
        $old = [];
        $new = [];

        foreach ($this->getDirty() as $attribute => $value) {
            if ($this->isAttributeAuditable($attribute)) {
                $old[$attribute] = Arr::get($this->original, $attribute);
                $new[$attribute] = Arr::get($this->attributes, $attribute);
            }
        }

        return [
            $old,
            $new,
        ];
    }
886173
public function getAffectedEntityIds()
    {
        $categoryIds = [];
        while ($bunch = $this->_dataSourceModel->getNextBunch()) {
            foreach ($bunch as $rowNum => $rowData) {
                $this->filterRowData($rowData);
                if (!$this->isRowAllowedToImport($rowData, $rowNum)) {
                    continue;
                }
                if (!isset($this->newCategory[$rowData[self::COL_ROOT]][$rowData[self::COL_CATEGORY]]['entity_id'])) {
                    continue;
                }
                $categoryIds[] = $this->newCategory[$rowData[self::COL_ROOT]][$rowData[self::COL_CATEGORY]]['entity_id'];
            }
        }
        return $categoryIds;
    }