Create classifitions for specific entity
343110
def create(self, data, **kwargs):
        
        self.client.post(self.url, data=data)
1311614
private function generatorClassEntity() {

        /* Lista os schemas do banco de dados */
        foreach ($this->oMetadata->getSchemas() as $valueSchema) {

            $tableNames = $this->oMetadata->getTableNames($valueSchema);

            $namespaceSchema = 'Orm\\' . $this->toCamelCase($valueSchema) . '\Entities';

            /* Lista as tabelas do banco de dados */
            foreach ($tableNames as $tableName) {

                $multiPk = $primaryKey = $bodyExchangeArray = null;

                $class = new ClassGenerator();

                $class->setNamespaceName($namespaceSchema);

                $docBlockClass = DocBlockGenerator::fromArray(array(
                            'shortDescription' => 'Classe tipo model da tabela ' . $tableName . ' dentro do schema ' . $valueSchema,
                            'longDescription' => null,
                ));

                $class->setDocBlock($docBlockClass);
                $class->setName($this->toCamelCase($tableName));

                $class->addProperty('DBSCHEMA', $valueSchema, PropertyGenerator::FLAG_STATIC);
                $class->addProperty('DBTABLE', $tableName, PropertyGenerator::FLAG_STATIC);

                foreach ($this->oMetadata->getConstraints($tableName, $valueSchema) as $constraint) {
                    if (!$constraint->hasColumns()) {
                        continue;
                    }

                    if ($constraint->isPrimaryKey()) {
                        $columns = $constraint->getColumns();

                        if (count($columns) > 1) {
                            $multiPk = true;
                            $primaryKey = implode(', ', $columns);
                        } else {
                            $multiPk = false;
                            $primaryKey = $columns[0];
                        }
                        $class->addProperty('MULTIPK', $multiPk, PropertyGenerator::FLAG_STATIC);
                        $class->addProperty('PKCOLUMN', $primaryKey, PropertyGenerator::FLAG_STATIC);
                    }
                }




                /* Cria os metodos setter/getter e as variáveis das colunas da tabela */

                $table = $this->oMetadata->getTable($tableName, $valueSchema);

                /* Lista as colunas da tabela do banco de dados */
                foreach ($table->getColumns() as $column) {

                    $varName = $this->camelCase($column->getName());
                    $class->addProperty($varName, null, PropertyGenerator::FLAG_PRIVATE);

                    $methodGet = 'get' . $this->toCamelCase($column->getName());
                    $methodSet = 'set' . $this->toCamelCase($column->getName());

                    $docBlockSet = DocBlockGenerator::fromArray(array(
                                'shortDescription' => 'Setter da coluna ' . $column->getName(),
                                'longDescription' => null,
                                'tags' => array(
                                    new Tag\ParamTag($varName, $this->prepareSqlTypeDocBlock($column->getDataType())),
                                ),
                    ));

                    $docBlockGet = DocBlockGenerator::fromArray(array(
                                'shortDescription' => 'Getter da coluna ' . $column->getName(),
                                'longDescription' => null,
                                'tags' => array(
                                    new Tag\ReturnTag(array(
                                        'datatype' => $this->prepareSqlTypeDocBlock($column->getDataType()),
                                            )),
                                ),
                    ));

                    $bodyGet = 'return $this->' . $varName . ';';
                    $bodySet = '$this->' . $varName . ' = $' . $this->camelCase($column->getName()) . ';';

                    $class->addMethod($methodSet, array($this->camelCase($column->getName())), MethodGenerator::FLAG_PUBLIC, $bodySet, $docBlockSet);
                    $class->addMethod($methodGet, array(), MethodGenerator::FLAG_PUBLIC, $bodyGet, $docBlockGet);

                    $bodyExchangeArray .= '$this->' . $varName . ' = (isset($data["' . $column->getName() . '"])) ? $data["' . $column->getName() . '"] : null;' . "\n\n";
                }

                $docBlockExchangeArray = DocBlockGenerator::fromArray(array(
                            'shortDescription' => 'Função para settar todos os objetos por meio de array',
                            'longDescription' => null,
                            'tags' => array(
                                new Tag\ParamTag('data', 'array'),
                            ),
                ));
                $class->addMethod('exchangeArray', array('data'), MethodGenerator::FLAG_PUBLIC, $bodyExchangeArray, $docBlockExchangeArray);

                $docBlockGetArrayCopy = DocBlockGenerator::fromArray(array(
                            'shortDescription' => 'Função para retornar os valores por meio de array dos objetos da classe',
                            'longDescription' => null,
                            'tags' => array(
                                new Tag\ReturnTag(array(
                                    'datatype' => 'mixed',
                                        )),
                            ),
                ));
                $class->addMethod('getArrayCopy', array(), MethodGenerator::FLAG_PUBLIC, 'return get_object_vars($this);', $docBlockGetArrayCopy);

                $classCode = "<?php" . PHP_EOL;

                $classCode .= $class->generate();

                /*
                  $idxConstraint = 0;
                  foreach ($this->oMetadata->getConstraints($tableName, $valueSchema) as $constraint) {

                  $typeConstraint = ($constraint->isPrimaryKey()) ? 'pk' : (($constraint->isForeignKey()) ? 'fk' : null);
                  if (!empty($typeConstraint)) {

                  $consName = $constraint->getName();
                  $contraintObj = $this->oMetadata->getConstraint($consName, $tableName, $valueSchema);

                  $constraintColumns = $contraintObj->getColumns();
                  if (count($constraintColumns) > 1) {
                  foreach ($constraintColumns as $valueConsColumns) {
                  $this->aDatabase[$valueSchema][$tableName][$valueConsColumns]['constraints']['type'] = $typeConstraint;
                  if ($typeConstraint === 'fk') {
                  $this->aDatabase[$valueSchema][$tableName][$valueConsColumns]['constraints']['schemaRef'] = $contraintObj->getReferencedTableSchema();
                  $this->aDatabase[$valueSchema][$tableName][$valueConsColumns]['constraints']['tableRef'] = $contraintObj->getReferencedTableName();
                  $this->aDatabase[$valueSchema][$tableName][$valueConsColumns]['constraints']['columnsRef'] = $contraintObj->getReferencedColumns();
                  }
                  }
                  } else {
                  $this->aDatabase[$valueSchema][$tableName][$constraintColumns[0]]['constraints']['type'] = $typeConstraint;
                  if ($typeConstraint === 'fk') {
                  $this->aDatabase[$valueSchema][$tableName][$constraintColumns[0]]['constraints']['schemaRef'] = $contraintObj->getReferencedTableSchema();
                  $this->aDatabase[$valueSchema][$tableName][$constraintColumns[0]]['constraints']['tableRef'] = $contraintObj->getReferencedTableName();
                  $this->aDatabase[$valueSchema][$tableName][$constraintColumns[0]]['constraints']['columnsRef'] = $contraintObj->getReferencedColumns();
                  }
                  }
                  }

                  $idxConstraint++;
                  }
                 * 
                 */
                file_put_contents($this->ormFolder . $this->toCamelCase($valueSchema) . DS . 'Entities' . DS . $this->toCamelCase($tableName) . '.php', $classCode);
                chmod($this->ormFolder . $this->toCamelCase($valueSchema) . DS . 'Entities' . DS . $this->toCamelCase($tableName) . '.php', 0644);

                $this->generatorClassEntityTable($valueSchema, $tableName);
            }


            //gera arquivo por tabela
        }
        return $this;
    }
64422
private Object instantiateEntity(Class entityClass, Object entity)
    {
        if (entity == null)
        {
            return KunderaCoreUtils.createNewInstance(entityClass);
        }
        return entity;
    }
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)
954597
def entity_categories(self, entity_id):
        
        attributes = self.entity_attributes(entity_id)
        return attributes.get(ENTITY_CATEGORY, [])
1344456
private void initEntityMetadata(Entity entity) {
    String kind = entity.kind();
    if (kind.trim().length() == 0) {
      kind = entityClass.getSimpleName();
    }
    entityMetadata = new EntityMetadata(entityClass, kind);
  }
592719
protected function setupClass() {
		$this->_class->setName($this->getNames()->entityAbstractName);
		$this->_class->setImplementedInterfaces(['RowGatewayInterface']);
		$this->_class->setAbstract(true);
	
		$docBlock = new DocBlockGenerator();
		$docBlock->setShortDescription("Entity for {$this->getNames()->tableName}");
		$tags = [];
		
		$tags[] = [
			'name' => 'namespace',
			'description' => $this->getNames()->namespace_entity
		];
		
		foreach ($this->getNames()->properties as $name => $values) {
			// Extract array to $type, $default, $primary
			$type = null;
			$default = null;
			extract($values);
			
			$property = new PropertyGenerator($name);
			$property->setVisibility('protected');
			if ($default != null) {
				$property->setDefaultValue($default);
			}
			
			$property->setDocBlock(DocBlockGenerator::fromArray([
				'shortDescription' => $name,
				'tags' => [[
					'name' => 'var',
					'description' => $type]]]));
			$this->_class->addPropertyFromGenerator($property);
			
			$tags[] = [
				'name' => 'property',
				'description' => "{$type} \${$name}"
			];
		}
		$docBlock->setTags($tags);
		$this->_class->setDocBlock($docBlock);
		
		$docBlock = DocBlockGenerator::fromArray([
			'shortDescription' => 'DataTable Link',
			'tags' => [[
				'name' => 'var',
				'description' => "\\{$this->getNames()->namespace_model}\\{$this->getNames()->modelName}"]]]);
		
		$property = new PropertyGenerator();
		$property->setName('dataTable');
		$property->setDocBlock($docBlock);
		$property->setVisibility('private');
		$this->_class->addPropertyFromGenerator($property);
		
		$this->_file->setClass($this->_class);
	}
675167
def _onClass(self, name, line, pos, absPosition,
                 keywordLine, keywordPos,
                 colonLine, colonPos, level):
        """"""
        self.__flushLevel(level)
        c = Class(name, line, pos, absPosition, keywordLine, keywordPos,
                  colonLine, colonPos)
        if self.__lastDecorators is not None:
            c.decorators = self.__lastDecorators
            self.__lastDecorators = None
        self.objectsStack.append(c)
640967
private void validateEntity(final DbEntity entity) throws DatabaseEngineException {
        if (entity.getName() == null || entity.getName().length() == 0) {
            throw new DatabaseEngineException("You have to define the entity name");
        }

        final int maxIdentSize = properties.getMaxIdentifierSize();
        if (entity.getName().length() > maxIdentSize) {
            throw new DatabaseEngineException(String.format("Entity '%s' exceeds the maximum number of characters (%d)", entity.getName(), maxIdentSize));
        }

        if (entity.getColumns().isEmpty()) {
            throw new DatabaseEngineException("You have to specify at least one column");
        }

        int numberOfAutoIncs = 0;
        for (DbColumn c : entity.getColumns()) {
            if (c.getName() == null || c.getName().length() == 0) {
                throw new DatabaseEngineException(String.format("Column in entity '%s' must have a name", entity.getName()));
            }

            if (c.getName().length() > maxIdentSize) {
                throw new DatabaseEngineException(String.format("Column '%s' in entity '%s' exceeds the maximum number of characters (%d)", c.getName(), entity.getName(), maxIdentSize));
            }

            if (c.isAutoInc()) {
                numberOfAutoIncs++;
            }
        }

        if (numberOfAutoIncs > 1) {
            throw new DatabaseEngineException("You can only define one auto incremented column");
        }

        // Index validation

        List<DbIndex> indexes = entity.getIndexes();
        if (!indexes.isEmpty()) {
            for (DbIndex index : indexes) {
                if (index.getColumns().isEmpty()) {
                    throw new DatabaseEngineException(String.format("You have to specify at least one column to create an index in entity '%s'", entity.getName()));
                }

                for (String column : index.getColumns()) {
                    if (column == null || column.length() == 0) {
                        throw new DatabaseEngineException(String.format("Column indexes must have a name in entity '%s'", entity.getName()));
                    }
                }
            }
        }

        // FK validation

        List<DbFk> fks = entity.getFks();
        if (!fks.isEmpty()) {
            for (DbFk fk : fks) {
                if (fk.getForeignTable() == null || fk.getForeignTable().length() == 0) {
                    throw new DatabaseEngineException(String.format("You have to specify the table when creating a Foreign Key in entity '%s'", entity.getName()));
                }

                if (fk.getLocalColumns().isEmpty()) {
                    throw new DatabaseEngineException(String.format("You must specify at least one local column when defining a Foreign Key in '%s'", entity.getName()));
                }

                if (fk.getForeignColumns().isEmpty()) {
                    throw new DatabaseEngineException(String.format("You must specify at least one foreign column when defining a Foreign Key in '%s'", entity.getName()));
                }

                if (fk.getLocalColumns().size() != fk.getForeignColumns().size()) {
                    throw new DatabaseEngineException(String.format("Number of local columns does not match foreign ones in entity '%s'", entity.getName()));
                }
            }
        }
    }
149732
function createEntity(html, id) {
    let $ = parser.load(html)

    let table = $('tr.past')

    let states = utils.tableParser(table, {
        date: {
            idx: 3,
            mandatory: true
        },
        hours: {
            idx: 5,
            mandatory: true
        },
        state: {
            idx: 7,
            mandatory: true
        },
        area: {
            idx: 9,
            mandatory: false
        }
    }).map(line => {
        let d = line.date + ' ' + line.hours
        return {
            date: moment.tz(d, "DD/MM/YYYY HH:mm", zone).format(),
            state: line.state,
            area: line.area
        }
    })

    return new EntityInfo({
        id: id,
        states: states
    })
}
347198
static <E> List<E> toEntities(Class<E> entityClass, Entity[] nativeEntities) {
    if (nativeEntities == null || nativeEntities.length == 0) {
      return new ArrayList<>();
    }
    return toEntities(entityClass, Arrays.asList(nativeEntities));
  }
51319
def filtany(entities, **kw):
  
  ret = set()
  for k,v in kw.items():
    for entity in entities:
      if getattr(entity, k)() == v:
        ret.add(entity)
  return ret
1207590
private function buildColumnDescription()
    {
        if (!$info = entity_get_info($this->entityType)) {
            throw new ConfigurationError(sprintf("entity type '%s' does not exist", $this->entityType));
        }

        $this->baseTable = $info['base table'];

        $excluded = [];

        // Identifier and revision identifier
        foreach (['id' => "Identifier", 'revision' => "Revision identifier", 'label' => "Label", 'language' => "Language"] as $alias => $label) {
            if (!empty($info['entity keys'][$alias])) {
                $column = $info['entity keys'][$alias];
                $excluded[] = $column;

                $this->fields[$alias] = [
                    'label'   => $label,
                    'column'  => 'base.'.$column,
                    'choices' => null,
                ];
            }
        }

        // Enable fulltext search if there is a label field
        if (isset($this->fields['label'])) {
            $this->fulltextField = $this->fields['label']['column'];
        }
        if (isset($this->fields['id'])) {
            $this->idColumn = $this->fields['id']['column'];
        }
        if (isset($this->fields['revision'])) {
            $this->revisionColumn = $this->fields['revision']['column'];
        }

        // Bundles
        if (!empty($info['bundles']) && isset($info['entity keys']['bundle'])) {
            $column = $info['entity keys']['bundle'];
            $excluded[] = $column;

            $choices = [];
            foreach ($info['bundles'] as $bundle => $description) {
                $choices[$bundle] = $description['label'];
            }

            $this->fields['bundle'] = [
                'label'   => "Bundle",
                'column'  => 'base.'.$column,
                'choices' => $choices,
            ];
        }

        // Base and revision table columns
        foreach (['base table' => 'base', 'revision table' => 'revision'] as $table => $alias) {
            if (isset($info['schema_fields_sql'][$table])) {
                $schema = drupal_get_schema($info[$table]);

                foreach ($info['schema_fields_sql'][$table] as $column) {
                    $columnAlias = 'base' === $alias ? $column : $alias.'_'.$column;

                    if (isset($this->fields[$columnAlias]) || in_array($column, $excluded)) {
                        continue;
                    }

                    if (isset($schema['fields'][$column]['description'])) {
                        $label = $schema['fields'][$column]['description'];
                    } else {
                        $label = $column;
                    }

                    $this->fields[$columnAlias] = [
                        'label'   => $label,
                        'column'  => $alias.'.'.$column,
                        'choices' => null,
                    ];
                }
            }
        }

        if (!empty($info['revision table'])) {
            $idColumn = $info['entity keys']['id'];
            $revColumn = $info['entity keys']['revision'];

            $this->joins['revision'] = [
                'type'      => 'INNER',
                'table'     => $info['revision table'],
                'condition' => sprintf(
                    "base.%s = revision.%s AND base.%s = revision.%s",
                    $idColumn, $idColumn, $revColumn, $revColumn
                )
            ];
        }
    }
1185696
@Override
  public void buildClassifier(Database database, Relation<? extends ClassLabel> labelrep) {
    Object2IntOpenHashMap<ClassLabel> count = new Object2IntOpenHashMap<>();
    for(DBIDIter iter = labelrep.iterDBIDs(); iter.valid(); iter.advance()) {
      count.addTo(labelrep.get(iter), 1);
    }
    int max = Integer.MIN_VALUE;
    double size = labelrep.size();

    distribution = new double[count.size()];
    labels = new ArrayList<>(count.size());
    ObjectIterator<Entry<ClassLabel>> iter = count.object2IntEntrySet().fastIterator();
    for(int i = 0; iter.hasNext(); ++i) {
      Entry<ClassLabel> entry = iter.next();
      distribution[i] = entry.getIntValue() / size;
      labels.add(entry.getKey());
      if(entry.getIntValue() > max) {
        max = entry.getIntValue();
        prediction = entry.getKey();
      }
    }
  }
976239
def init_from_datastore(self):
    """"""
    self._data = {}
    client = self._datastore_client
    for entity in client.query_fetch(kind=KIND_CLASSIFICATION_BATCH):
      class_batch_id = entity.key.flat_path[-1]
      self.data[class_batch_id] = dict(entity)
434883
def create_entity_class(self):
        '''
        
        '''
        entity = Entity()

        # Partition key and row key must be strings and are required
        entity.PartitionKey = 'pk{}'.format(str(uuid.uuid4()).replace('-', ''))
        entity.RowKey = 'rk{}'.format(str(uuid.uuid4()).replace('-', ''))

        # Some basic types are inferred
        entity.age = 39  # EdmType.INT64
        entity.large = 933311100  # EdmType.INT64
        entity.sex = 'male'  # EdmType.STRING
        entity.married = True  # EdmType.BOOLEAN
        entity.ratio = 3.1  # EdmType.DOUBLE
        entity.birthday = datetime(1970, 10, 4)  # EdmType.DATETIME

        # Binary, Int32 and GUID must be explicitly typed
        entity.binary = EntityProperty(EdmType.BINARY, b'xyz')
        entity.other = EntityProperty(EdmType.INT32, 20)
        entity.clsid = EntityProperty(EdmType.GUID, 'c9da6455-213d-42c9-9a79-3e9149a57833')
        return entity
251374
private Set<Classification> getClassification(final List<Long> _classIds)
        throws CacheReloadException
    {
        final Set<Classification> noadd = new HashSet<>();
        final Set<Classification> add = new HashSet<>();
        if (_classIds != null) {
            for (final Long id : _classIds) {
                Classification clazz = (Classification) Type.get(id);
                if (!noadd.contains(clazz)) {
                    add.add(clazz);
                    while (clazz.getParentClassification() != null) {
                        clazz = clazz.getParentClassification();
                        if (add.contains(clazz)) {
                            add.remove(clazz);
                        }
                        noadd.add(clazz);
                    }
                }
            }
        }
        return add;
    }