<commit_before>// Defines requirement documents on business process requirements map

'use strict';

var ensureArray         = require('es5-ext/array/valid-array')
  , forEach             = require('es5-ext/object/for-each')
  , ensureObject        = require('es5-ext/object/valid-object')
  , ensureStringifiable = require('es5-ext/object/validate-stringifiable-value')
  , uncapitalize        = require('es5-ext/string/#/uncapitalize')
  , isType              = require('dbjs/is-dbjs-type')
  , ensureType          = require('dbjs/valid-dbjs-type')
  , defineDocument      = require('../../document')
  , defineRequirements  = require('../requirements')

  , create = Object.create;

module.exports = function (BusinessProcess, data) {
	var db = ensureType(BusinessProcess).database, Document = defineDocument(db)
	  , definitions = create(null), typesMap = create(null);
	defineRequirements(db);
	ensureArray(data).forEach(function (conf) {
		var RequiredDocument, name;
		if (!isType(ensureObject(conf))) {
			RequiredDocument = ensureType(conf.class);
			name = ensureStringifiable(conf.name);
		} else {
			RequiredDocument = conf;
			name = uncapitalize.call(RequiredDocument.__id__);
		}
		if (!Document.isPrototypeOf(RequiredDocument)) {
			throw new TypeError(RequiredDocument.__id__ + " must extend Document.");
		}
		definitions[name] = { nested: true };
		typesMap[name] = RequiredDocument;
	});
	BusinessProcess.prototype.requirements.map.defineProperties(definitions);
	forEach(typesMap, function (RequiredDocument, name) {
		this[name].Document = RequiredDocument;
	}, BusinessProcess.prototype.requirements.map);
	return BusinessProcess;
};<commit_msg>#786 added label and legend<commit_after>// Defines requirement documents on business process requirements map

'use strict';

var ensureArray         = require('es5-ext/array/valid-array')
  , forEach             = require('es5-ext/object/for-each')
  , ensureObject        = require('es5-ext/object/valid-object')
  , ensureStringifiable = require('es5-ext/object/validate-stringifiable-value')
  , uncapitalize        = require('es5-ext/string/#/uncapitalize')
  , isType              = require('dbjs/is-dbjs-type')
  , ensureType          = require('dbjs/valid-dbjs-type')
  , defineDocument      = require('../../document')
  , defineRequirements  = require('../requirements')

  , create = Object.create;

module.exports = function (BusinessProcess, data) {
	var db = ensureType(BusinessProcess).database, Document = defineDocument(db)
	  , definitions = create(null), typesMap = create(null);
	defineRequirements(db);
	ensureArray(data).forEach(function (conf) {
		var RequiredDocument, name;
		if (!isType(ensureObject(conf))) {
			RequiredDocument = ensureType(conf.class);
			name = ensureStringifiable(conf.name);
		} else {
			RequiredDocument = conf;
			name = uncapitalize.call(RequiredDocument.__id__);
		}
		if (!Document.isPrototypeOf(RequiredDocument)) {
			throw new TypeError(RequiredDocument.__id__ + " must extend Document.");
		}
		definitions[name] = { nested: true };
		typesMap[name] = { Document: RequiredDocument, label: conf.label, legend: conf.legend };
	});
	BusinessProcess.prototype.requirements.map.defineProperties(definitions);
	forEach(typesMap, function (configItem, name) {
		this[name].Document = configItem.Document;
		if (configItem.label) {
			this[name].label = configItem.label;
		}
		if (configItem.legend) {
			this[name].legend = configItem.legend;
		}
	}, BusinessProcess.prototype.requirements.map);
	return BusinessProcess;
};
{'fraction_non_alphanumeric': 0.1356457980823463, 'fraction_numerical': 0.0036661026508742244, 'mean_word_length': 4.193265007320644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4149893', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1031, 'n_words': 187}