/*
 * SDK Pullenti Lingvo, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software.
 * This class is generated using the converter Unisharping (www.unisharping.ru) from Pullenti C#.NET project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

const Utils = require("./../../unisharp/Utils");
const StringBuilder = require("./../../unisharp/StringBuilder");

const Termin = require("./../core/Termin");
const IntOntologyItem = require("./../core/IntOntologyItem");
const ResumeItemType = require("./ResumeItemType");
const ReferentClass = require("./../metadata/ReferentClass");
const MetaResume = require("./MetaResume");
const Referent = require("./../Referent");

/**
 * Элемент резюме
 */
class ResumeItemReferent extends Referent {
    
    constructor() {
        super(ResumeItemReferent.OBJ_TYPENAME);
        this.instanceOf = MetaResume.GLOBAL_META;
    }
    
    get typ() {
        let str = this.getStringValue(ResumeItemReferent.ATTR_TYPE);
        if (str === null) 
            return ResumeItemType.UNDEFINED;
        try {
            return ResumeItemType.of(str);
        } catch (ex3528) {
        }
        return ResumeItemType.UNDEFINED;
    }
    set typ(_value) {
        this.addSlot(ResumeItemReferent.ATTR_TYPE, _value.toString().toLowerCase(), true, 0);
        return _value;
    }
    
    get value() {
        return this.getStringValue(ResumeItemReferent.ATTR_VALUE);
    }
    set value(_value) {
        this.addSlot(ResumeItemReferent.ATTR_VALUE, _value, true, 0);
        return _value;
    }
    
    get misc() {
        return this.getStringValue(ResumeItemReferent.ATTR_MISC);
    }
    set misc(_value) {
        this.addSlot(ResumeItemReferent.ATTR_MISC, _value, true, 0);
        return _value;
    }
    
    get ref() {
        return Utils.as(this.getSlotValue(ResumeItemReferent.ATTR_REF), Referent);
    }
    set ref(_value) {
        this.addSlot(ResumeItemReferent.ATTR_REF, _value, true, 0);
        return _value;
    }
    
    get dateRange() {
        return Utils.as(this.getSlotValue(ResumeItemReferent.ATTR_DATERANGE), Referent);
    }
    set dateRange(_value) {
        this.addSlot(ResumeItemReferent.ATTR_DATERANGE, _value, true, 0);
        return _value;
    }
    
    get expired() {
        return this.getStringValue(ResumeItemReferent.ATTR_EXPIRED) === "true";
    }
    set expired(_value) {
        this.addSlot(ResumeItemReferent.ATTR_EXPIRED, (_value ? "true" : null), true, 0);
        return _value;
    }
    
    toStringEx(shortVariant, lang = null, lev = 0) {
        let tmp = new StringBuilder();
        tmp.append(MetaResume.TYPES.convertInnerValueToOuterValue(this.getStringValue(ResumeItemReferent.ATTR_TYPE), null)).append(": ");
        if (this.ref !== null) {
            let dt = this.dateRange;
            if (dt !== null) 
                tmp.append(dt.toStringEx(true, null, 0)).append(": ");
            tmp.append(this.ref.toStringEx(shortVariant, lang, lev + 1));
            if (this.value !== null) 
                tmp.append(" (").append(this.value).append(")");
        }
        else if (this.value !== null) 
            tmp.append(this.value);
        if (this.expired) 
            tmp.append(" (не актуально)");
        if (this.misc !== null) 
            tmp.append(" (").append(this.misc).append(")");
        return tmp.toString();
    }
    
    createOntologyItem() {
        let oi = new IntOntologyItem(this);
        oi.termins.push(new Termin(this.value));
        return oi;
    }
    
    static _new3517(_arg1, _arg2) {
        let res = new ResumeItemReferent();
        res.typ = _arg1;
        res.ref = _arg2;
        return res;
    }
    
    static _new3526(_arg1) {
        let res = new ResumeItemReferent();
        res.typ = _arg1;
        return res;
    }
    
    static static_constructor() {
        ResumeItemReferent.OBJ_TYPENAME = "RESUME";
        ResumeItemReferent.ATTR_TYPE = "TYPE";
        ResumeItemReferent.ATTR_VALUE = "VALUE";
        ResumeItemReferent.ATTR_REF = "REF";
        ResumeItemReferent.ATTR_DATERANGE = "DATERANGE";
        ResumeItemReferent.ATTR_EXPIRED = "EXPIRED";
        ResumeItemReferent.ATTR_MISC = "MISC";
    }
}


ResumeItemReferent.static_constructor();

module.exports = ResumeItemReferent