<commit_before>//	Copyright 2013 - 2014, <NAME>. All rights reserved. 
//
//		This file is part of hyperstore (http://www.hyperstore.org)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// <reference path="../_references.ts" />

module Hyperstore
{
// -------------------------------------------------------------------------------------
//
// -------------------------------------------------------------------------------------
export class SchemaElement extends SchemaInfo
{
    private _properties;
    private _references;
    private proto;
    subElements : SchemaElement[];

    // -------------------------------------------------------------------------------------
    //
    // -------------------------------------------------------------------------------------
    constructor(schema:Schema, kind:SchemaKind, id:string, public baseElement?:SchemaElement)
    {
        super(schema, kind, id);
        this.subElements = [];
        this._properties = {};
        this._references = {};
        this.proto = Object.create(
                baseElement ? baseElement.proto  : (kind === SchemaKind.Entity ? ModelElement.prototype : ModelRelationship.prototype)
        );
        if( baseElement) baseElement.subElements.push(this);
    }


    getKeyValueFromJson(data, parent?:ModelElement) : string {
        var empty = "";
        var keyProperties = this.getKeyProperties().toArray();
        if( keyProperties.length === 0) return;
        var keys = [];<commit_msg>Ajout interceptor et changement chargement des types avec le loader<commit_after>//	Copyright 2013 - 2014, <NAME>. All rights reserved. 
//
//		This file is part of hyperstore (http://www.hyperstore.org)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// <reference path="../_references.ts" />

module Hyperstore
{
// -------------------------------------------------------------------------------------
//
// -------------------------------------------------------------------------------------
export class SchemaElement extends SchemaInfo
{
    private _properties;
    private _references;
    private proto;
    subElements : SchemaElement[];
    private _interceptors : IInterceptor[];

    // -------------------------------------------------------------------------------------
    //
    // -------------------------------------------------------------------------------------
    constructor(schema:Schema, kind:SchemaKind, id:string, public baseElement?:SchemaElement)
    {
        super(schema, kind, id);
        this.subElements = [];
        this._properties = {};
        this._references = {};
        this.proto = Object.create(
                baseElement ? baseElement.proto  : (kind === SchemaKind.Entity ? ModelElement.prototype : ModelRelationship.prototype)
        );
        if( baseElement) baseElement.subElements.push(this);
    }

    addInterceptor(interceptor) {
        if(!interceptor) return;
        this._interceptors = this._interceptors || [];
        this._interceptors.push(interceptor);
    }

    onAfter(ctx)  {
        if(this._interceptors) {
            Utils.forEach(this._interceptors, i => ctx.action === "Create" ? i.afterCreate && i.afterCreate(ctx.mel) : i.afterRemove && i.afterRemove(ctx.id, ctx.schema));
        }
        if( this.baseElement)
            this.baseElement.onAfter(ctx);
    }

    onBefore(ctx)  {
        if(this._interceptors) {
            Utils.forEach(this._interceptors, i => ctx.action === "Create" ? i.beforeCreate && i.beforeCreate(ctx.mel) : i.beforeRemove && i.beforeRemove(ctx.mel));
        }
        if( this.baseElement)
            this.baseElement.onBefore(ctx);
    }

    getKeyValueFromJson(data, parent?:ModelElement) : string {
        var empty = "";
        var keyProperties = this.getKeyProperties().toArray();
        if( keyProperties.length === 0) return;
        var keys = [];
{'fraction_non_alphanumeric': 0.24208375893769152, 'fraction_numerical': 0.005311542390194076, 'mean_word_length': 1.6886326194398682, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2350929', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1143, 'n_words': 337}