getDatabaseIncrementalFieldsString

Retorna a relação de meta informação de propriedades vinculadas a persistencia com incremento a partir do
database

@return PropertyContract[]|boolean
962353
public function getDatabaseIncrementalFieldsMeta()
    {
        if (!empty($this->databaseIncrementalFieldsMeta)) {
            return $this->databaseIncrementalFieldsMeta;
        }

        $databaseIncrementalFieldsMeta = $this->getPropertyContainer()->getFields('hasMany');
        if (!empty($databaseIncrementalFieldsMeta)) {
            $databaseIncrementalFieldsMeta = array_filter(
                $databaseIncrementalFieldsMeta,
                function (PropertyContract $property) {
                    if (!$property->getBehavior()->isPersistent()) {
                        return false;
                    }

                    if (!$property->getBehavior() instanceof IntegerBehavior) {
                        return false;
                    }

                    if ($property->getBehavior()->getIncrementalBehavior() !== 'database') {
                        return false;
                    }

                    return true;
                }
            );
        }
        $this->databaseIncrementalFieldsMeta = $databaseIncrementalFieldsMeta;

        return $this->databaseIncrementalFieldsMeta;
    }
1077606
private function buildFields() {
        $fields = array();
        /** @var ResultSet $results */
        $results = $this->getConfiguration()->getConnection()->query('SHOW COLUMNS FROM `' . $this->getTableName() . '`');
        $dbName = $this->getCurrentDatabaseName();
        while($result = $results->fetch()) {
            $result = (object)$result;
            $params = array($dbName, $this->getTableName(), $result->Field);
            /** @var ResultSet $informationResults */
            $informationResults = $this->getConfiguration()->getInformationSchemaConnection()->query(
                'SELECT * FROM `COLUMNS` WHERE TABLE_SCHEMA=? AND TABLE_NAME=? AND COLUMN_NAME=?',
                $params
            );
            /** @var \stdClass $informationResult */
            $informationResult = (object)$informationResults->fetch();
            $field = new Field($result, $this->getTableName(), $informationResult);
            switch($field->getType()) {
                case 'Date':
                    $this->getAbstractClass()->addUse($this->getConfiguration()->getDateClassName());
                    break;
                case 'DateTime':
                    $this->getAbstractClass()->addUse($this->getConfiguration()->getDateTimeClassName());
                    break;
            }
            $fields[] = $field;
        }
        usort(
            $fields,
            function (Field $fieldA, Field $fieldB) {
                return strcasecmp($fieldA->getShortName(), $fieldB->getShortName());
            }
        );
        $this->setFields($fields);
    }
230811
public function dataFields()
    {
        if (empty($this->sequentialSet)) {
            $fields = [];
            $this->recursiveWalk(function (FormField $field) use (&$fields) {
                if (!$field->hasData()) {
                    return;
                }
                $name = $field->getName();
                if (isset($fields[$name])) {
                    $this->fieldNameError($field, __FUNCTION__);
                }
                $fields[$name] = $field;
            });
            $this->sequentialSet = $fields;
        }
        return $this->sequentialSet;
    }
509674
public function getCMSFields()
    {
        $fields = $this->scaffoldFormFields(
            array(
                // Don't allow has_many/many_many relationship editing before the record is first saved
                'includeRelations' => ($this->ID > 0),
                'tabbed' => true,
                'ajaxSafe' => true
            )
        );
        $fields->removeByName(
            array(
                'Title',
                'Instance',
                'Style',
                'Objects'
            )
        );
        if (!$this->IsMain) {
            $fields->addFieldsToTab(
                'Root.Main',
                array(
                    TextField::create(
                        'Title',
                        _t('PlaceableObject_Preset.TITLE', 'Title')
                    ),
                    DropdownField::create(
                        'Instance',
                        _t('PlaceableObject_Preset.INSTANCE', 'Instance'),
                        singleton('PlaceableObject_Preset')->dbObject('Instance')->enumValues()
                    )
                )
            );
        }
        if ($this->Styles) {
            $fields->addFieldToTab(
                'Root.Main',
                DropdownField::create(
                    'Style',
                    _t('PlaceableObject_Preset.STYLE', 'Style'),
                    $this->Styles
                )->setEmptyString(_t('PlaceableObject_Preset.DEFAULTSTYLE', 'Default'))
            );
        }
        $fields->addFieldsToTab(
            'Root.Objects',
            array(
                LabelField::create(
                    'ObjectsDescription',
                    _t('PlaceableObject_Preset.OBJECTSDESCRIPTION', 'List of all objects that use this use this preset.')
                ),
                GridField::create(
                    'Objects',
                    _t('PlaceableObject_Preset.OBJECTS', 'Objects'),
                    $this->Objects(),
                    GridFieldConfig_Base::create()
                )
            )
        );
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
802343
protected function getPreviewFieldData()
    {
        $data = ArrayList::create();

        $fields = $this->record->Form()->Fields()->filter(
            'ClassName:not',
            [
                EditableLiteralField::class,
                EditableFormHeading::class,
            ]
        );

        foreach ($fields as $field) {
            $data->push(ArrayData::create([
                'Name' => $field->dbObject('Name'),
                'Title' => $field->dbObject('Title'),
                'Value' => DBField::create_field('Varchar', '$' . $field->Name),
                'FormattedValue' => DBField::create_field('Varchar', '$' . $field->Name)
            ]));
        }

        return $data;
    }
793722
public function getPersistedAttributes() {
    $persisted = static::getAllPersistedAttributes();
    if (empty($persisted)) {
      // if the static persisted declaration is empty return empty
      return [];
    } else {
      // otherwise add the instance variables for primaryKey, typeField and dates
      return array_merge([$this->primaryKey, static::$singleTableTypeField], static::getAllPersistedAttributes(), $this->getDates());
    }
  }
608889
protected function getInsertColumnList()
    {
        $columns = array();

        foreach ($this->class->reflFields as $name => $field) {
            if ($this->class->isVersioned && $this->class->versionField == $name) {
                continue;
            }

            if (isset($this->class->embeddedClasses[$name])) {
                continue;
            }

            if (isset($this->class->associationMappings[$name])) {
                $assoc = $this->class->associationMappings[$name];
                if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) {
                    foreach ($assoc['joinColumns'] as $joinColumn) {
                        $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform);
                    }
                }

                continue;
            }

            if ($this->class->generatorType != ClassMetadata::GENERATOR_TYPE_IDENTITY || $this->class->identifier[0] != $name) {
                $columns[]                = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform);
                $this->columnTypes[$name] = $this->class->fieldMappings[$name]['type'];
            }
        }

        return $columns;
    }
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;
    }
188197
public function getApplicationIncrementalFieldsString()
    {
        if (!empty($this->applicationIncrementalFieldsString)) {
            return $this->applicationIncrementalFieldsString;
        }

        $applicationIncrementalFieldsMeta = $this->getApplicationIncrementalFieldsMeta();
        if (empty($applicationIncrementalFieldsMeta)) {
            return false;
        }

        $this->applicationIncrementalFieldsString = array_map(function (PropertyContract $property) {
            return $property->getField();
        }, $applicationIncrementalFieldsMeta);

        return $this->applicationIncrementalFieldsString;
    }
108440
public function init()
    {
        // the table model is an object list
        if (empty($this->table_model)) {
            return false;
        }

        // get a short tag based on the table name
        if (!$this->get_table_short_tag()) return false;

        $this->tpl_replacements['where_statement']    = '';
        $this->tpl_replacements['load_row_list']      = '';
        $this->tpl_replacements['trait_list']         = "\n\nuse " . $this->namespace . "Database;\n\n";
        $this->tpl_replacements['update_insert_list'] = '';

        $i     = 0;
        $count = count($this->table_model);
        // try to fit all possibilities of generated code in here
        // otherwise it would be iterated much more often
        foreach ($this->table_model as $column) {
            // to reduce the use of the strtolower function ;) just do it once
            $property_name = strtolower($column->Field);

            // get a list of properties
            $property_list_unsorted[(string)$property_name] = (string)"\t/**" . ($column->Comment ? self::STD_INTEND_PROPERTIES . " * comment: $column->Comment" : '');
            $property_list_unsorted[(string)$property_name] .= (string)($column->Extra || strtolower($column->Null) == 'no' ? self::STD_INTEND_PROPERTIES . " * Extra: $column->Extra[Not null]" : '');
            $property_list_unsorted[(string)$property_name] .= (string)" " . self::STD_INTEND_PROPERTIES . " * @var $column->Type" . ($column->Key == 'PRI' ? " [PRIMARY KEY]" : '') . self::STD_INTEND_PROPERTIES . " */" . self::STD_INTEND_PROPERTIES . "public $" . $property_name . " = " . $this->get_type_value((($column->Null == 'NO' && !$this->with_null) ? $column->Type : '')) . ";\n\n";

            if ($column->Key == 'PRI') {

                $this->primary_key[] = $column->Field;
                if (!empty($this->where_statement)) {
                    $this->tpl_replacements['where_statement'] .= (string)' AND ';
                }
                // generate generic where statement based on the primary keys
                $this->tpl_replacements['where_statement'] .= (string)"`$column->Field` = '\$this->" . $property_name . "'";
                $this->tpl_replacements['constructor_key_list'] = '';
                $this->tpl_replacements['constructor_key_list'] .= (string)"\t\t" . '$this->' . $property_name . ' = $' . $property_name . ";\n";

            }

            if ($column->Null == 'NO') {
                $this->tpl_replacements['mandatory_fields'][] = (string)$property_name;
            }

            // mysql list for the save function
            $this->tpl_replacements['update_insert_list'] .= (string)"\t\t\$sql .= (\$this->$property_name !== " . (($column->Null == 'NO' && !$this->with_null) ? $this->get_type_value($column->Type) : 'null') . ") ? \"";
            $this->tpl_replacements['update_insert_list'] .= (string)"`$column->Field`= '\" . Database_Tool::db_sanitize(stripslashes(\$this->$property_name)) . \"'";
            $this->tpl_replacements['update_insert_list'] .= (string)($count != $i + 1 ? ', "' : '"') . " : '';\n";

            // get multi keys for assignment
            if ($column->Key == 'MUL') {
                $this->key_list = (string)$column->Field;
            }
            // get multi keys for assignment
            if ($column->Key == 'UNI') {
                $this->key_list = (string)$column->Field;
            }

            // assign the SQL field list
            $this->sql_field_list[] = (string)"`$this->table_short_tag`.`$column->Field`";

            // generates the load row property assignment list
            $this->tpl_replacements['load_row_list'] .= (string)"\t\t\$this->" . strtolower($column->Field) . " = " . (($column->Null == 'NO' && !$this->with_null) ? $this->get_type_value($column->Type, true) : '') . " isset(\$row->" . $column->Field . ") ? \$row->" . $column->Field . " : " . (($column->Null == 'NO' && !$this->with_null) ? $this->get_type_value($column->Type) : 'null') . ";\n";
            $i = $i + 1;
        }
        // remove the last coma
        // add the db to the listing of the class properties
        $property_list_unsorted['db']        = (string)"\t/**" . self::STD_INTEND_PROPERTIES . " * Database object" . self::STD_INTEND_PROPERTIES . "  * @var Object" . self::STD_INTEND_PROPERTIES . " */" . self::STD_INTEND_PROPERTIES . "public \$db = null;\n\n";
        $property_list_unsorted['mandatory'] = (string)"\t/**" . self::STD_INTEND_PROPERTIES . " * list of mandatory fields " . self::STD_INTEND_PROPERTIES . "  * @var array" . self::STD_INTEND_PROPERTIES . " */" . self::STD_INTEND_PROPERTIES . "public \$mandatory_field = array('" . implode("','", $this->tpl_replacements['mandatory_fields']) . "');\n\n";
        // sort alpabetical based on the key
        ksort($property_list_unsorted);
        $this->tpl_replacements['property_list'] = implode("\n\n", $property_list_unsorted);
        unset($property_list_unsorted);

        $this->generate_primary_key_statement();

        // implode the field list
        $this->tpl_replacements['sql_field_list'] = implode(', ', $this->sql_field_list);

        $this->tpl_replacements['constructor_param_list'] = '$' . strtolower(implode("'\n\t\t* @param ', $", $this->primary_key));

        return true;
    }
417809
public function getValue()
    {
        switch ($this->method) {
            case 'createTable':
                $columns = [];

                foreach ((array)$this->data as $column => $schema) {
                    $columns[] = TableColumnFactory::build([
                        'schema' => $this->schema,
                        'name' => $column,
                        'type' => $schema['type'],
                        'length' => $schema['length'] ?? null,
                        'isNotNull' => $schema['isNotNull'] ?? null,
                        'isUnique' => $schema['isUnique'] ?? null,
                        'isPrimaryKey' => $schema['isPrimaryKey'] ?? null,
                        'check' => $schema['check'] ?? null,
                        'default' => $schema['default'] ?? null,
                        'append' => $schema['append'] ?? null,
                        'isUnsigned' => $schema['isUnsigned'] ?? null,
                        'comment' => !empty($schema['comment']) ? $schema['comment'] : null,
                    ]);
                }
                return $columns;

            case 'renameColumn':
                return [
                    'old' => $this->data[0],
                    'new' => $this->data[1],
                ];

            case 'addColumn':
            case 'alterColumn':
                return TableColumnFactory::build([
                    'schema' => $this->schema,
                    'name' => $this->data[0],
                    'type' => $this->data[1]['type'],
                    'length' => $this->data[1]['length'] ?? null,
                    'isNotNull' => $this->data[1]['isNotNull'] ?? null,
                    'isUnique' => $this->data[1]['isUnique'] ?? null,
                    'isPrimaryKey' => $this->data[1]['isPrimaryKey'] ?? null,
                    'check' => $this->data[1]['check'] ?? null,
                    'default' => $this->data[1]['default'] ?? null,
                    'append' => $this->data[1]['append'] ?? null,
                    'isUnsigned' => $this->data[1]['isUnsigned'] ?? null,
                    'comment' => !empty($this->data[1]['comment']) ? $this->data[1]['comment'] : null,
                ]);

            case 'addPrimaryKey':
                return new TablePrimaryKey([
                    'name' => $this->data[0],
                    'columns' => $this->data[1],
                ]);

            case 'addForeignKey':
                return new TableForeignKey([
                    'name' => $this->data[0],
                    'columns' => $this->data[1],
                    'refTable' => $this->data[2],
                    'refColumns' => $this->data[3],
                ]);

            case 'createIndex':
                return new TableIndex([
                    'name' => $this->data[0],
                    'columns' => $this->data[1],
                    'unique' => $this->data[2],
                ]);

            case 'addCommentOnColumn':
                return [
                    'name' => $this->data[0],
                    'comment' => $this->data[1],
                ];

            case 'renameTable':
            case 'dropTable':
            case 'dropColumn':
            case 'dropPrimaryKey':
            case 'dropForeignKey':
            case 'dropIndex':
            case 'dropCommentFromColumn':
            default:
                return $this->data;
        }
    }
1125822
public function fetchColumnAttributes()
    {
        if ( !is_object($this->datasource) )
            return false;

        $conn = $this->datasource->ado_connection;
        //$a = new Reportico($this->datasource);
        //$old_database = $a->database;

        $datadict = false;
        reset($this->columns);
        $lasttab = "";
        while ($d = key($this->columns)) {
            $value = &$this->columns[$d];

            if (array_key_exists($value->query_name, $this->clone_columns)) {
                $value->column_type =
                $this->clone_columns[$value->query_name][0];
                $value->column_length =
                $this->clone_columns[$value->query_name][1];

            } else if ($value->table_name) {
                if ($lasttab != $value->table_name) {
                    $datadict = $this->datasource->ado_connection->MetaColumns($value->table_name);
                    if (!$datadict) {
                        // echo "Data Dictionary Attack Failed Table $value->table_name\n";
                        // echo "Error ".$this->datasource->ado_connection->ErrorMsg()."<br>";
                        //die;
                    }
                }
                foreach ($datadict as $k => $v) {

                    if (strtoupper(trim($k)) == strtoupper($value->column_name)) {
                        //$coldets = $datadict[strtoupper($value->column_name)];
                        $coldets = $datadict[$k];
                        $value->column_type =
                        ReporticoDataSource::mapColumnType(
                            $this->datasource->driver,
                            $datadict[$k]->type);

                        if (strtoupper($value->column_type) == "INTEGER") {
                            $value->column_length = 0;
                        } else if (strtoupper($value->column_type) == "SMALLINT") {
                            $value->column_length = 0;
                        } else {
                            $value->column_length = (int) $datadict[$k]->max_length;
                        }

                        break;
                    }
                }
            }
            $lasttab = $value->table_name;
            next($this->columns);
        }
    }
1089390
public function getProperties()
    {
        //todo cache
        $result = array();
        foreach ($this->getReflectionClass()->getProperties() as $m)
        {
            $result[] = PropertyInfo::__internal_create($this, $m);
        }
        return $result;
    }
1290536
public function getProperties()
    {
        if ($this->properties === null) {
            // lazy load class properties list
            $this->properties = array();
            foreach ($this->node->stmts as $stmt) {
                if ($stmt instanceof Node\Stmt\Property) {
                    $this->properties[] = new PropertyModel($this, $stmt);
                }
            }
        }
        return array_values($this->properties);
    }
147081
public function getDataProperties()
    {
        $this->_dataProperties = (empty($this->_dataProperties)) ? new DataProperties($this->properties, $this->data) : $this->_dataProperties;
        return $this->_dataProperties;
    }
334169
public function getPersistentFields()
    {
        if (empty($this->persistentFields)) {

            $persistentFields = $this->getPropertyContainer()->getFields('hasMany');
            if (!empty($persistentFields)) {
                $persistentFields = array_filter(
                    $persistentFields,
                    function (PropertyContract $property) {
                        if (!$property->getBehavior()->isPersistent()) {
                            return false;
                        }

                        if (!$property->getBehavior() instanceof IntegerBehavior) {
                            return true;
                        }

                        if ($property->getBehavior()->getIncrementalBehavior() == 'database') {
                            return false;
                        }

                        return true;
                    }
                );
            }
            $this->persistentFields = $persistentFields;
        }

        return $this->persistentFields;
    }
1200555
public function getConcreteFields()
    {
        $concreteFields = [];

        /** @var $field Field */
        foreach ($this->getNonM2MForwardFields() as $name => $field) {
            if ($field->concrete) {
                $concreteFields[$name] = $field;
            }
        }

        return $concreteFields;
    }