Generates this classes hqmf-model equivalent
342162
def to_model
      mps = preconditions.collect(&:to_model)
      HQMF::PopulationCriteria.new(id, hqmf_id, type, mps, title, aggregator, comments)
    end
412940
def _generate_union_class_m(self, union):
        """"""
        self.emit()
        self._generate_imports_m(
            self._get_imports_m(
                union,
                default_imports=['DBStoneSerializers', 'DBStoneValidators']))

        union_name = fmt_class_prefix(union)

        self.emit('#pragma mark - API Object')
        self.emit()
        with self.block_m(fmt_class_prefix(union)):
            self._generate_synthesize_ivars(union)
            self.emit('#pragma mark - Constructors')
            self.emit()
            self._generate_union_cstor_funcs(union)
            self.emit('#pragma mark - Instance field accessors')
            self.emit()
            self._generate_union_tag_vars_funcs(union)
            self.emit('#pragma mark - Tag state methods')
            self.emit()
            self._generate_union_tag_state_funcs(union)
            self.emit('#pragma mark - Serialization methods')
            self.emit()
            self._generate_serializable_funcs(union_name)
            self.emit('#pragma mark - Description method')
            self.emit()
            self._generate_description_func(union_name)
            self.emit('#pragma mark - Copyable method')
            self.emit()
            self._generate_copyable_func()
            self.emit('#pragma mark - Hash method')
            self.emit()
            self._generate_hash_func(union)
            self.emit('#pragma mark - Equality method')
            self.emit()
            self._generate_equality_func(union)

        self.emit()
        self.emit()

        self.emit('#pragma mark - Serializer Object')
        self.emit()
        with self.block_m(fmt_serial_class(union_name)):
            self._generate_union_serializer(union)
            self._generate_union_deserializer(union)
207027
def generateClassView(self):
        '''
        
        '''
        class_view_stream = StringIO()

        for n in self.namespaces:
            n.toHierarchy(True, 0, class_view_stream)

        # Add everything that was not nested in a namespace.
        missing = []
        # class-like objects (structs and classes)
        for cl in sorted(self.class_like):
            if not cl.in_class_hierarchy:
                missing.append(cl)
        # enums
        for e in sorted(self.enums):
            if not e.in_class_hierarchy:
                missing.append(e)
        # unions
        for u in sorted(self.unions):
            if not u.in_class_hierarchy:
                missing.append(u)

        if len(missing) > 0:
            idx = 0
            last_missing_child = len(missing) - 1
            for m in missing:
                m.toHierarchy(True, 0, class_view_stream, idx == last_missing_child)
                idx += 1
        elif configs.createTreeView:
            # need to restart since there were no missing children found, otherwise the
            # last namespace will not correctly have a lastChild
            class_view_stream.close()
            class_view_stream = StringIO()

            last_nspace_index = len(self.namespaces) - 1
            for idx in range(last_nspace_index + 1):
                nspace = self.namespaces[idx]
                nspace.toHierarchy(True, 0, class_view_stream, idx == last_nspace_index)

        # extract the value from the stream and close it down
        class_view_string = class_view_stream.getvalue()
        class_view_stream.close()
        return class_view_string
302533
private MapObject iterateAndPopulateRmap(Object entity, MetamodelImpl metaModel, Iterator<Attribute> iterator)
    {
        MapObject map = r.hashMap();
        while (iterator.hasNext())
        {
            Attribute attribute = iterator.next();
            Field field = (Field) attribute.getJavaMember();
            Object value = PropertyAccessorHelper.getObject(entity, field);
            if (field.isAnnotationPresent(Id.class))
            {
                map.with(ID, value);
            }
            else
            {
                map.with(((AbstractAttribute) attribute).getJPAColumnName(), value);
            }
        }
        return map;
    }
384631
def as_hqmf_model
      json = {
        'id' => hqmf_id,
        'title' => title,
        'description' => description,
        'population_criteria' => population_criteria,
        'data_criteria' => data_criteria,
        'source_data_criteria' => source_data_criteria,
        'measure_period' => measure_period,
        'attributes' => measure_attributes,
        'populations' => populations,
        'hqmf_id' => hqmf_id,
        'hqmf_set_id' => hqmf_set_id,
        'hqmf_version_number' => hqmf_version_number,
        'cms_id' => cms_id
      }
      HQMF::Document.from_json(json)
    end
618558
private function _generateModelClassFile ()
    {
        $skeleton_dir = __DIR__.'/../../Skeleton';
        $model_dir    = LIB.'/'.APP.'/Model';
        $file_path    = $model_dir.'/%s'.$this->model_name.'%s.php';

        // Modelクラス
        $skeleton = file_get_contents($skeleton_dir.'/ModelSkeleton.php');
        $skeleton = str_replace('${app}', APP, $skeleton);
        $skeleton = str_replace('${model}', $this->model_name, $skeleton);
        file_put_contents(sprintf($file_path, '', 'Model'), $skeleton);

        // Queryクラス
        $skeleton = file_get_contents($skeleton_dir.'/QuerySkeleton.php');
        $skeleton = str_replace('${app}', APP, $skeleton);
        $skeleton = str_replace('${query}', $this->model_name, $skeleton);
        file_put_contents(sprintf($file_path, 'Query/', 'Query'), $skeleton);

        // Columnクラス
        $skeleton = file_get_contents($skeleton_dir.'/ColumnSkeleton.php');
        $skeleton = str_replace('${app}', APP, $skeleton);
        $skeleton = str_replace('${column}', $this->model_name, $skeleton);
        file_put_contents(sprintf($file_path, 'Column/', 'Column'), $skeleton);
    }
837674
def make(base_classes=(), have_mt=False):
        """"""

        good_bc = ModelFactory.__fix_bases(base_classes, have_mt)
        print "Base classes are:", good_bc
        key = "".join(map(str, good_bc))
        if key in ModelFactory.__memoized:
            return ModelFactory.__memoized[key]

        cls = new.classobj('', good_bc, {'__module__': '__main__', '__doc__': None})
        ModelFactory.__memoized[key] = cls
        return cls
408140
def build_model_classes(metadata):
    """"""
    i = importlib.import_module(metadata)
    env = get_jinja_env()
    model_template = env.get_template('model.py.jinja2')
    for model in i.models:
        with open(model_path(model.name.lower()), 'w') as t:
            t.write(model_template.render(model_md=model))
1122949
public void generateClass(TreeLogger logger, GeneratorContext context, List<JClassType> subclasses) {

        PrintWriter printWriter = context.tryCreate(logger, PACKAGE_NAME, CLASS_NAME);
        if (printWriter == null) {
            return;
        }
        ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(PACKAGE_NAME, CLASS_NAME);
        composer.addImplementedInterface(INIT_INTERFACE_NAME);
        SourceWriter sourceWriter = composer.createSourceWriter(context, printWriter);
        sourceWriter.println("public java.util.Map<String, " + COMMAND_INTERFACE + "> initCommands() {");
        sourceWriter.indent();
        sourceWriter.println(
            "java.util.Map<String, "
                + COMMAND_INTERFACE
                + "> result=new java.util.HashMap<String, "
                + COMMAND_INTERFACE
                + ">();");
        for (JClassType type : subclasses) {
            sourceWriter.println(
                "result.put(\""
                    + type.getQualifiedSourceName()
                    + "\","
                    + type.getQualifiedSourceName()
                    + "."
                    + GET_COMMAND_METHOD
                    + "());");
        }
        sourceWriter.println("return result;");
        sourceWriter.outdent();
        sourceWriter.println("}");
        sourceWriter.outdent();
        sourceWriter.println("}");
        context.commit(logger, printWriter);
    }
208041
def modelresource_factory(model, resource_class=ModelResource):
    
    attrs = {'model': model}
    Meta = type(str('Meta'), (object,), attrs)

    class_name = model.__name__ + str('Resource')

    class_attrs = {
        'Meta': Meta,
    }

    metaclass = ModelDeclarativeMetaclass
    return metaclass(class_name, (resource_class,), class_attrs)
924234
private void generateUMLClass(PackageDoc[] pkgs) throws IOException {
        for (int i=0; i < pkgs.length; i++) {
            // generate statistics
            generateUMLClass(pkgs[i].ordinaryClasses(), pkgs[i].name());
        }
    }
388075
public function generateModel()
    {
        app('Luthfi\CrudGenerator\Generators\ModelGenerator', ['command' => $this])->generate();
        app('Luthfi\CrudGenerator\Generators\MigrationGenerator', ['command' => $this])->generate();
        app('Luthfi\CrudGenerator\Generators\ModelPolicyGenerator', ['command' => $this])->generate();
        app('Luthfi\CrudGenerator\Generators\ModelFactoryGenerator', ['command' => $this])->generate();
    }
4313
public Blacklist generateBlacklist(Model model)
	{
		ChemicalNameNormalizer normalizer = new ChemicalNameNormalizer(model);
		SIFSearcher searcher = new SIFSearcher(new Fetcher(normalizer), SIFEnum.USED_TO_PRODUCE);

		Set<SIFInteraction> sifs = searcher.searchSIF(model);

		// read interactions into maps

		Map<String, Set<String>> upstrMap = new HashMap<String, Set<String>>();
		Map<String, Set<String>> dwstrMap = new HashMap<String, Set<String>>();
		Map<String, Set<String>> neighMap = new HashMap<String, Set<String>>();

		for (SIFInteraction sif : sifs)
		{
			String source = sif.sourceID;
			String target = sif.targetID;

			if (!neighMap.containsKey(source)) neighMap.put(source, new HashSet<String>());
			if (!neighMap.containsKey(target)) neighMap.put(target, new HashSet<String>());
			if (!dwstrMap.containsKey(source)) dwstrMap.put(source, new HashSet<String>());
			if (!dwstrMap.containsKey(target)) dwstrMap.put(target, new HashSet<String>());
			if (!upstrMap.containsKey(source)) upstrMap.put(source, new HashSet<String>());
			if (!upstrMap.containsKey(target)) upstrMap.put(target, new HashSet<String>());

			neighMap.get(source).add(target);
			neighMap.get(target).add(source);
			dwstrMap.get(source).add(target);
			upstrMap.get(target).add(source);
		}

		// remove intersection of upstream and downstream

		for (String name : neighMap.keySet())
		{
			if (!upstrMap.containsKey(name) || !dwstrMap.containsKey(name)) continue;

			Set<String> upstr = upstrMap.get(name);
			Set<String> dwstr = dwstrMap.get(name);

			Set<String> temp = new HashSet<String>(upstr);
			upstr.removeAll(dwstr);
			dwstr.removeAll(temp);
		}


		Blacklist blacklist = new Blacklist();

		// populate the blacklist

		for (SmallMoleculeReference smr : model.getObjects(SmallMoleculeReference.class))
		{
			String name = normalizer.getName(smr);

			int neighSize = neighMap.containsKey(name) ? neighMap.get(name).size() : 0;
			int upstrOnly = upstrMap.containsKey(name) ? upstrMap.get(name).size() : 0;
			int dwstrOnly = dwstrMap.containsKey(name) ? dwstrMap.get(name).size() : 0;

//			if (neighSize > 30) System.out.println(name + "\t" + neighSize + "\t" + upstrOnly + "\t" + dwstrOnly);

			if (decider.isUbique(neighSize, upstrOnly, dwstrOnly))
			{
				blacklist.addEntry(smr.getUri(),
					decider.getScore(neighSize, upstrOnly, dwstrOnly),
					decider.getContext(neighSize, upstrOnly, dwstrOnly));
			}
		}

		return blacklist;
	}
1219830
def to_model
      vm = value ? value.to_model : nil
      HQMF::SubsetOperator.new(type, vm)
    end
1183348
function generateModelFiles(db, next) {
    var q, templateTable, allNamingErrors = [];

    q = async.queue(function (task, workerCallback) {
        var output = getConfig('output.beautify') ? beautify(task.content, { indent_size: getConfig('output.indent'), preserve_newlines: getConfig('output.preserveNewLines') }) : task.content;
        fs.writeFile(path.join(getConfig('output.folder'), 'definition-files', getFileName(task.table)), output, workerCallback);
        if (getConfig('output.log')) { logger.info('(Created) File \'' + getFileName(task.table) + '\' is created for model \'' + getModelNameFor(task.table) + '\''); }
    }, 4);

    db.schemas(function (schema) {
        schema.tables(function (table) {
            var namingError = '';
            logger.debug('Now parsing table: %s', table.name());
            if (getSpecificConfig(table.name(), 'generate.hasManyThrough') && getSpecificConfig(table.name(), 'generate.belongsToMany')) {
                next(new Error('Configuration error: Both "generate.hasManyThrough" and "generate.belongsToMany" configuration is set to be true for table "' + table.schema().name() + '.' + table.name() + '". They cannot be true at the same time.'));
            }

            if (shouldSkip(table, 'table')) { return; }
            templateTable           = getTableOptions(table);
            table.columns(function (column) {
                templateTable.columns.push(getColumnDetails(column));
            });
            table.hasManies(function (hasMany) {
                if (shouldSkip(hasMany.referencesTable(), 'relation')) { return; }
                templateTable.hasManies.push(getHasManyDetails(hasMany));
            });
            table.hasManyThroughs(function (hasManyThrough) {
                if (getSpecificConfig(table.name(), 'generate.addRelationNameToManyToMany') && getSpecificConfig(table.name(), 'generate.addTableNameToManyToMany')) {
                    next(new Error('Configuration error: Both "generate.addRelationNameToManyToMany" and "generate.addTableNameToManyToMany" configuration is set to be true for table "' + table.schema().name() + '.' + table.name() + '". They cannot be true at the same time.'));
                }

                if (shouldSkip(hasManyThrough.referencesTable(), 'relation') || shouldSkip(hasManyThrough.through(), 'relation')) { return; }
                if (getSpecificConfig(table.name(), 'generate.hasManyThrough')) {
                    templateTable.hasManies.push(getHasManyDetails(hasManyThrough)); // has many throughs are deprecated after Sequelize 2.0 RC3
                }
                if (getSpecificConfig(table.name(), 'generate.belongsToMany')) {
                    templateTable.belongsToManies.push(getBelongsToManyDetails(hasManyThrough));
                }
            });
            table.foreignKeyConstraints(function (fkc) {
                if (shouldSkip(fkc.referencesTable(), 'relation')) { return; }
                templateTable.belongsTos.push(getBelongsToDetails(fkc));
            });
            templateTable.relations = templateTable.hasManies.concat(templateTable.belongsTos, templateTable.belongsToManies);

            namingError = validateNaming(templateTable);

            if (namingError) {
                allNamingErrors.push(namingError);
            }

            template('index', {
                table: templateTable,
                mainScript: path.join(getConfig('output.folder'), 'index.js'),
                warning: getConfig('output.warning'),
                dataTypeVariable: getSpecificConfig(table.name(), 'generate.dataTypeVariable')
            }, function (err, result) {
                if (err) { next(err); }
                q.push({content: result, table: table}, function (err) { if (err) { next(err); } });
            });
        });
    });

    q.drain = function () {
        if (allNamingErrors.length > 0) {
            next(new Error('There are naming errors. Either set "generate.addRelationNameToManyToMany" true in configuration or rename your relations.\n' + allNamingErrors.join('\n')));
        } else {
            next(null);
        }
    };
}
614480
def to_model
      dcs = all_data_criteria.collect(&:to_model)
      pcs = all_population_criteria.collect(&:to_model)
      sdc = source_data_criteria.collect(&:to_model)
      HQMF::Document.new(@id, @id, @hqmf_set_id, @hqmf_version_number, @cms_id,
                         title, description, pcs, dcs, sdc,
                         @attributes, @measure_period, @populations)
    end
1017364
def create_mixin(self):
        

        _builder = self

        class CustomModelMixin(object):
            @cached_property
            def _content_type(self):
                return ContentType.objects.get_for_model(self)

            @classmethod
            def get_model_custom_fields(cls):
                """ Return a list of custom fields for this model, callable at model level """
                return _builder.fields_model_class.objects.filter(content_type=ContentType.objects.get_for_model(cls))

            def get_custom_fields(self):
                """ Return a list of custom fields for this model """
                return _builder.fields_model_class.objects.filter(content_type=self._content_type)

            def get_custom_value(self, field):
                """ Get a value for a specified custom field """
                return _builder.values_model_class.objects.get(custom_field=field,
                                                               content_type=self._content_type,
                                                               object_id=self.pk)

            def set_custom_value(self, field, value):
                """ Set a value for a specified custom field """
                custom_value, created = \
                    _builder.values_model_class.objects.get_or_create(custom_field=field,
                                                                      content_type=self._content_type,
                                                                      object_id=self.pk)
                custom_value.value = value
                custom_value.full_clean()
                custom_value.save()
                return custom_value

            #def __getattr__(self, name):
            #    """ Get a value for a specified custom field """
            #    try:
            #        obj = _builder.values_model_class.objects.get(custom_field__name=name,
            #                                                      content_type=self._content_type,
            #                                                      object_id=self.pk)
            #        return obj.value
            #    except ObjectDoesNotExist:
            #        pass
            #    return super(CustomModelMixin, self).__getattr__(name)

        return CustomModelMixin