<commit_before>Attribute.prototype = new Item();           // Inheritance
Attribute.prototype.constructor = Attribute;

Attribute.prototype.attributes = {};

function Attribute (name, id)
{
    this.innitItem(id == undefined ? 'attribute' : id);

    this.owner = null;
    this.name = name;
    this.type = null;
    this.subtype = null;
    this.size = null;
    this.null = false;
    this.primary = false;
    this.foreign = false;
    this.autoincrement = false;
    this.unique = false;
    this.default = null;
    this.description = null;
    this.links = [];

    this.setter = true;
    this.getter = true;
    this.minSize = null;
    this.email = false;
    this.min = null;
    this.max = null;

    this.static = false;

    Attribute.prototype.attributes[this.id] = this;
}

Attribute.prototype.remove = function ()
{
    delete Attribute.prototype.attributes[this.id];

    this.destroyItem();
};

Attribute.prototype.setType = function (type)
{
    if (type != this.type) {
        switch (type) {
            case 'array':
            case 'bigint':
            case 'boolean':
            case 'date':
            case 'datetime':
            case 'decimal':
            case 'integer':
            case 'object':
            case 'smallint':
            case 'string':
            case 'text':
            case 'time':
                this.type = type;
                break;
            default:
                this.type = null;
        }

        // Update linked attributes
        if (this.links.length > 0) {
            for (var i = 0; i < this.links.length; i++) {
                if (Link.prototype.links[this.links[i]].getFromAttribute() == this.getId()) {
                    Attribute.prototype.attributes[Link.prototype.links[this.links[i]].getToAttribute()].setType(type);
                    Connectable.prototype.connectables[Link.prototype.links[this.links[i]].getTo()].reDraw();
                }
            }
        }
    }
};

Attribute.prototype.getType = function ()
{
    return this.type;
};

Attribute.prototype.setSubtype = function (subtype)
{
    if (subtype !== this.subtype) {
        var oldSubtype = this.subtype;

        if (subtype === '') {
            subtype = null;
        }

        if (subtype !== null) {
            this.subtype = subtype;
        }

        if (oldSubtype !== '' && oldSubtype !== null && Config.prototype.types.indexOf(oldSubtype) === -1) { // It was a class subtype
            Connectable.prototype.getConnectableFromName(oldSubtype).removeDependantAttribute(this.getId());
        }

        if (subtype !== '' && subtype !== null && subtype !== undefined && Config.prototype.types.indexOf(subtype) === -1) { // Is a class subtype
            Connectable.prototype.getConnectableFromName(subtype).addDependantAttribute(this.getId());
        }

        // Update linked attributes
        if (this.links.length > 0) {
            for (var i = 0; i < this.links.length; i++) {
                if (Link.prototype.links[this.links[i]].getFromAttribute() == this.getId()) {
                    Attribute.prototype.attributes[Link.prototype.links[this.links[i]].getToAttribute()].setSubtype(subtype);
                    Connectable.prototype.connectables[Link.prototype.links[this.links[i]].getTo()].reDraw();
                }
            }
        }
    }
};

Attribute.prototype.getSubtype = function ()
{
    return this.subtype;
};

Attribute.prototype.setName = function (desiredName)
{
    this.name = Connectable.prototype.connectables[this.getOwner()].getValidAttributeName(desiredName, this);
};

Attribute.prototype.setSize = function (size)
{
    if (size != this.size) {
        if (size != '') {
            this.size = size;
        } else {
            this.size = null;
        }

        // Update linked attributes
        if (this.links.length > 0) {
            for (var i = 0; i < this.links.length; i++) {<commit_msg>Fixed an issue where sometimes it will try to use an attribute that has not yet been loaded<commit_after>Attribute.prototype = new Item();           // Inheritance
Attribute.prototype.constructor = Attribute;

Attribute.prototype.attributes = {};

function Attribute (name, id)
{
    this.innitItem(id == undefined ? 'attribute' : id);

    this.owner = null;
    this.name = name;
    this.type = null;
    this.subtype = null;
    this.size = null;
    this.null = false;
    this.primary = false;
    this.foreign = false;
    this.autoincrement = false;
    this.unique = false;
    this.default = null;
    this.description = null;
    this.links = [];

    this.setter = true;
    this.getter = true;
    this.minSize = null;
    this.email = false;
    this.min = null;
    this.max = null;

    this.static = false;

    Attribute.prototype.attributes[this.id] = this;
}

Attribute.prototype.remove = function ()
{
    delete Attribute.prototype.attributes[this.id];

    this.destroyItem();
};

Attribute.prototype.setType = function (type)
{
    if (type != this.type) {
        switch (type) {
            case 'array':
            case 'bigint':
            case 'boolean':
            case 'date':
            case 'datetime':
            case 'decimal':
            case 'integer':
            case 'object':
            case 'smallint':
            case 'string':
            case 'text':
            case 'time':
                this.type = type;
                break;
            default:
                this.type = null;
        }

        // Update linked attributes
        if (this.links.length > 0) {
            for (var i = 0; i < this.links.length; i++) {
                if (Link.prototype.links[this.links[i]].getFromAttribute() == this.getId()) {
                    Attribute.prototype.attributes[Link.prototype.links[this.links[i]].getToAttribute()].setType(type);
                    Connectable.prototype.connectables[Link.prototype.links[this.links[i]].getTo()].reDraw();
                }
            }
        }
    }
};

Attribute.prototype.getType = function ()
{
    return this.type;
};

Attribute.prototype.setSubtype = function (subtype)
{
    if (subtype !== this.subtype) {
        var oldSubtype = this.subtype;

        if (subtype === '') {
            subtype = null;
        }

        if (subtype !== null) {
            this.subtype = subtype;
        }

        if (oldSubtype !== '' && oldSubtype !== null && Config.prototype.types.indexOf(oldSubtype) === -1) { // It was a class subtype
            Connectable.prototype.getConnectableFromName(oldSubtype).removeDependantAttribute(this.getId());
        }

        if (subtype !== '' && subtype !== null && subtype !== undefined && Config.prototype.types.indexOf(subtype) === -1) { // Is a class subtype
            Connectable.prototype.getConnectableFromName(subtype).addDependantAttribute(this.getId());
        }

        // Update linked attributes
        if (this.links.length > 0) {
            for (var i = 0; i < this.links.length; i++) {
                if (Link.prototype.links[this.links[i]].getFromAttribute() == this.getId()) {
                    Attribute.prototype.attributes[Link.prototype.links[this.links[i]].getToAttribute()].setSubtype(subtype);
                    Connectable.prototype.connectables[Link.prototype.links[this.links[i]].getTo()].reDraw();
                }
            }
        }
    }
};

Attribute.prototype.getSubtype = function ()
{
    return this.subtype;
};

Attribute.prototype.setName = function (desiredName)
{
    // Before runtime the attribute names are assumed to be correct. This is because it could happen that an attribute
    // is required that has not been loaded yet. Otherwise it has to check that it is available.

    this.name = System.prototype.runtime
        ? Connectable.prototype.connectables[this.getOwner()].getValidAttributeName(desiredName, this)
        : desiredName;
};

Attribute.prototype.setSize = function (size)
{
    if (size != this.size) {
        if (size != '') {
            this.size = size;
        } else {
            this.size = null;
        }

        // Update linked attributes
        if (this.links.length > 0) {
            for (var i = 0; i < this.links.length; i++) {
{'fraction_non_alphanumeric': 0.13475609756097562, 'fraction_numerical': 0.001951219512195122, 'mean_word_length': 2.028434268833087, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3871496', 'n_tokens_mistral': 2372, 'n_tokens_neox': 2308, 'n_words': 491}