"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Asset = void 0;
const constants_1 = require("../../constants");
const final_life_cycle_status_mapper_1 = require("../../mappers/final-life-cycle-status-mapper");
const entity_1 = require("../base/entity");
const culture_load_option_1 = require("../querying/culture-load-option");
const entity_load_configuration_1 = require("../querying/entity-load-configuration");
const property_load_option_1 = require("../querying/property-load-option");
const relation_load_option_1 = require("../querying/relation-load-option");
class Asset extends entity_1.Entity {
    get title() {
        return this.getPropertyValue(constants_1.DEFINITIONS["Asset"].title);
    }
    set title(value) {
        this.setPropertyValue(constants_1.DEFINITIONS["Asset"].title, value);
    }
    get fileName() {
        return this.getPropertyValue(constants_1.DEFINITIONS["Asset"].fileName);
    }
    set fileName(value) {
        this.setPropertyValue(constants_1.DEFINITIONS["Asset"].fileName, value);
    }
    getDescription(culture) {
        return this.getPropertyValue(constants_1.DEFINITIONS["Asset"].description, culture);
    }
    setDescription(culture, description) {
        return this.setPropertyValue(constants_1.DEFINITIONS["Asset"].description, description, culture);
    }
    getFinalLifeCycleStatusAsync() {
        return __awaiter(this, void 0, void 0, function* () {
            const relation = this.getRelation(constants_1.DEFINITIONS["Asset"].finalLifeCycleStatusToAsset);
            if (relation == null || relation.parent == null) {
                return null;
            }
            const loadConfiguration = new entity_load_configuration_1.EntityLoadConfiguration(culture_load_option_1.CultureLoadOption.None, new property_load_option_1.PropertyLoadOption(constants_1.DEFINITIONS["FinalLifeCycleStatus"].statusValue), relation_load_option_1.RelationLoadOption.None);
            const parent = yield this._client.entities.getAsync(relation.parent, loadConfiguration);
            if (parent == null) {
                return null;
            }
            const statusString = parent.getPropertyValue(constants_1.DEFINITIONS["FinalLifeCycleStatus"].statusValue);
            const status = final_life_cycle_status_mapper_1.FinalLifeCycleStatusMapper.fromString(statusString);
            return status;
        });
    }
    loadTypedMembersAsync() {
        return __awaiter(this, void 0, void 0, function* () {
            const propertyLoadOption = new property_load_option_1.PropertyLoadOption([
                constants_1.DEFINITIONS["Asset"].title,
                constants_1.DEFINITIONS["Asset"].fileName,
                constants_1.DEFINITIONS["Asset"].description,
            ]);
            const relationLoadOption = new relation_load_option_1.RelationLoadOption([constants_1.DEFINITIONS["Asset"].finalLifeCycleStatusToAsset]);
            yield this.loadMembersAsync(propertyLoadOption, relationLoadOption);
        });
    }
}
exports.Asset = Asset;
//# sourceMappingURL=asset.js.map