<commit_before>var hash = require("object-hash");
var AttributeReader = require("../utils/AttributeReader");
var DocumentSchema = require("./DocumentSchema");
var ShowModel = require("./ShowModel");
var MaapError = require("../utils/MaapError");

var DocumentModel = function (param, connection) {
    this.showModel = new ShowModel({}, this);

    // Leggi i parametri obbligatori e opzionali
    AttributeReader.readRequiredAttributes(
        params, 
        this, 
        ["name", "label"], 
        function (param) {
            throw new MaapError(
                8000, 
                `Required parameter '${param}' in Document `+
                `'${self.toString()}'`
            );
        }
    );
    
    AttributeReader.readOptionalAttributes(params, this, [""]);
    AttributeReader.assertEmptyAttributes(params, function (param) {
	   throw new MaapError(
           8000, 
           `Unexpected parameter '${param}' in collection '${self.toString()}'`
       );
    });
    
    this.model = connection.model(this.name, DocumentSchema);
    this.id = hash(new Date().getMilliseconds());
}

DocumentModel.prototype.getId = function () {
    return this.id;
};

DocumentModel.prototype.getLabel = function() {
	return this.label;
};

DocumentModel.prototype.getShowModel = function () {
    return this.showModel;
};

DocumentModel.prototype.setShowModel = function(showModel) {
	this.showModel = showModel;
};

DocumentModel.prototype.toString = function () {
    return `Document ${this.getLabel()}`;
};

module.exports = DocumentModel;<commit_msg>Fix bug and add 'addRow' method<commit_after>var hash = require("object-hash");
var AttributeReader = require("../utils/AttributeReader");
var DocumentSchema = require("./DocumentSchema");
var ShowModel = require("./ShowModel");
var MaapError = require("../utils/MaapError");
var RequiredParamException = require("../utils/requiredParamException");
var UnexpectedParamException = require("../utils/unexpectedParamException");

var DocumentModel = function (params, connection) {
    this.showModel = new ShowModel({}, this);

    // Leggi i parametri obbligatori e opzionali
    AttributeReader.readRequiredAttributes(
        params, 
        this, 
        ["name", "label"], 
        (param) => {
	    throw new RequiredParamException(this, param);
	}
    );
    
    AttributeReader.readOptionalAttributes(params, this, [""]);
    AttributeReader.assertEmptyAttributes(params, (param) => {
	throw new UnexpectedParamException(this, param);
    });
    
    this.model = connection.model(this.name, DocumentSchema);
    this.id = hash(new Date().getMilliseconds());
}

DocumentModel.prototype.getId = function () {
    return this.id;
};

DocumentModel.prototype.getLabel = function() {
	return this.label;
};

DocumentModel.prototype.getShowModel = function () {
    return this.showModel;
};

DocumentModel.prototype.setShowModel = function(showModel) {
	this.showModel = showModel;
};

DocumentModel.prototype.toString = function () {
    return `Document ${this.getLabel()}`;
};

DocumentModel.prototype.addRow = function (attribute) {
    this.showModel.addRow(attribute);
};

module.exports = DocumentModel;
{'fraction_non_alphanumeric': 0.1393159711327267, 'fraction_numerical': 0.0025101976780671476, 'mean_word_length': 3.5870503597122303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1045745', 'n_tokens_mistral': 898, 'n_tokens_neox': 878, 'n_words': 182}