"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectTreeController = void 0;
const tslib_1 = require("tslib");
const authorization_1 = require("@loopback/authorization");
// Uncomment these imports to begin using these cool features!
const core_1 = require("@loopback/core");
const repository_1 = require("@loopback/repository");
const rest_1 = require("@loopback/rest");
const object_node_repository_1 = require("../repositories/object-node.repository");
const application_service_1 = require("../services/application.service");
// import {inject} from '@loopback/context';
const object_tree_service_1 = require("../services/object-tree/object-tree.service");
const object_tree_model_1 = require("./../models/object-tree.model");
const access_rights_tree_const_1 = require("./../services/access-rights/access-rights-tree.const");
const access_rights_const_1 = require("./../services/access-rights/access-rights.const");
let ObjectTreeController = class ObjectTreeController {
    constructor(objectTreeService, objectNodeRepository) {
        this.objectTreeService = objectTreeService;
        this.objectNodeRepository = objectNodeRepository;
    }
    async findChildren(treeId, ctx) {
        return this.objectTreeService.loadTree(treeId, ctx);
    }
    async findOwnerTree(ownerType, ownerName, ctx) {
        return this.objectTreeService.getOwnerTree(ownerType, ownerName, ctx);
    }
    async findTree(ownerType, ownerName, namespaceType, namespaceName, treeType, treeName, ctx) {
        return this.objectTreeService.getTree(ownerType, ownerName, namespaceType, namespaceName, treeType, treeName, ctx);
    }
    async findNamespaceTree(ownerType, ownerName, namespaceType, namespaceName, ctx) {
        return this.objectTreeService.getNamespaceTree(ownerType, ownerName, namespaceType, namespaceName, ctx);
    }
    async findNode(ownerType, ownerName, namespaceType, namespaceName, treeType, treeName, nodeType, nodeName, ctx) {
        return this.objectTreeService.getNode(ownerType, ownerName, namespaceType, namespaceName, treeType, treeName, nodeType, nodeName, ctx);
    }
};
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectTree,
        scopes: [access_rights_const_1.AccessRightsScope.read],
    }),
    rest_1.get('/object-trees/{treeId}', {
        responses: {
            '200': {
                description: 'Array of ObjectNode model instances',
                content: {
                    'application/json': {
                        schema: {
                            items: rest_1.getModelSchemaRef(object_tree_model_1.ObjectTree),
                        },
                    },
                },
            },
        },
    }),
    tslib_1.__param(0, rest_1.param.path.string('treeId')),
    tslib_1.__param(1, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ObjectTreeController.prototype, "findChildren", null);
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectTree,
        scopes: [access_rights_const_1.AccessRightsScope.read, access_rights_tree_const_1.AccessRightsTreeScope.searchOwner],
    }),
    rest_1.get('/object-trees/owner/{ownerType}/{ownerName}', {
        responses: {
            '200': {
                description: 'ObjectTree model',
                content: {
                    'application/json': {
                        schema: {
                            items: rest_1.getModelSchemaRef(object_tree_model_1.ObjectTree),
                        },
                    },
                },
            },
        },
    }),
    tslib_1.__param(0, rest_1.param.path.string('ownerType')),
    tslib_1.__param(1, rest_1.param.path.string('ownerName')),
    tslib_1.__param(2, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ObjectTreeController.prototype, "findOwnerTree", null);
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectTree,
        scopes: [access_rights_const_1.AccessRightsScope.read, access_rights_tree_const_1.AccessRightsTreeScope.searchTree],
    }),
    rest_1.get('/object-trees/tree/{ownerType}/{ownerName}/{namespaceType}/{namespaceName}/{treeType}/{treeName}', {
        responses: {
            '200': {
                description: 'ObjectTree model',
                content: {
                    'application/json': {
                        schema: {
                            items: rest_1.getModelSchemaRef(object_tree_model_1.ObjectTree),
                        },
                    },
                },
            },
        },
    }),
    tslib_1.__param(0, rest_1.param.path.string('ownerType')),
    tslib_1.__param(1, rest_1.param.path.string('ownerName')),
    tslib_1.__param(2, rest_1.param.path.string('namespaceType')),
    tslib_1.__param(3, rest_1.param.path.string('namespaceName')),
    tslib_1.__param(4, rest_1.param.path.string('treeType')),
    tslib_1.__param(5, rest_1.param.path.string('treeName')),
    tslib_1.__param(6, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, String, String, String, String, application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ObjectTreeController.prototype, "findTree", null);
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectTree,
        scopes: [access_rights_const_1.AccessRightsScope.read, access_rights_tree_const_1.AccessRightsTreeScope.searchNamespace],
    }),
    rest_1.get('/object-trees/namespace/{ownerType}/{ownerName}/{namespaceType}/{namespaceName}', {
        responses: {
            '200': {
                description: 'ObjectTree model',
                content: {
                    'application/json': {
                        schema: {
                            items: rest_1.getModelSchemaRef(object_tree_model_1.ObjectTree),
                        },
                    },
                },
            },
        },
    }),
    tslib_1.__param(0, rest_1.param.path.string('ownerType')),
    tslib_1.__param(1, rest_1.param.path.string('ownerName')),
    tslib_1.__param(2, rest_1.param.path.string('namespaceType')),
    tslib_1.__param(3, rest_1.param.path.string('namespaceName')),
    tslib_1.__param(4, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, String, String, application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ObjectTreeController.prototype, "findNamespaceTree", null);
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectTree,
        scopes: [access_rights_const_1.AccessRightsScope.read, access_rights_tree_const_1.AccessRightsTreeScope.searchNode],
    }),
    rest_1.get('/object-trees/node/{ownerType}/{ownerName}/{namespaceType}/{namespaceName}/{treeType}/{treeName}/{nodeType}/{nodeName}', {
        responses: {
            '200': {
                description: 'ObjectTree model',
                content: {
                    'application/json': {
                        schema: {
                            items: rest_1.getModelSchemaRef(object_tree_model_1.ObjectTree),
                        },
                    },
                },
            },
        },
    }),
    tslib_1.__param(0, rest_1.param.path.string('ownerType')),
    tslib_1.__param(1, rest_1.param.path.string('ownerName')),
    tslib_1.__param(2, rest_1.param.path.string('namespaceType')),
    tslib_1.__param(3, rest_1.param.path.string('namespaceName')),
    tslib_1.__param(4, rest_1.param.path.string('treeType')),
    tslib_1.__param(5, rest_1.param.path.string('treeName')),
    tslib_1.__param(6, rest_1.param.path.string('nodeType')),
    tslib_1.__param(7, rest_1.param.path.string('nodeName')),
    tslib_1.__param(8, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, String, String, String, String, String, String, application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ObjectTreeController.prototype, "findNode", null);
ObjectTreeController = tslib_1.__decorate([
    tslib_1.__param(0, core_1.service(object_tree_service_1.ObjectTreeService)),
    tslib_1.__param(1, repository_1.repository(object_node_repository_1.ObjectNodeRepository)),
    tslib_1.__metadata("design:paramtypes", [object_tree_service_1.ObjectTreeService,
        object_node_repository_1.ObjectNodeRepository])
], ObjectTreeController);
exports.ObjectTreeController = ObjectTreeController;
//# sourceMappingURL=object-tree.controller.js.map