<commit_before>"use strict";

angular.module("ehelseEditor").factory("DownloadList",
    ["$rootScope", "FileUpload", "ServiceFunction", "StorageHandler", "Action", "Document", "DocumentField", "DocumentType", "LinkCategory", "Mandatory", "Status", "TargetGroup", "Topic",
    function ($rootScope, FileUpload, ServiceFunction, StorageHandler, Action, Document, DocumentField, DocumentType, LinkCategory, Mandatory, Status, TargetGroup, Topic) {

        /**
         * Returns list of topics ready for storage
         * @param topics
         * @returns {Array}
         */
        function constructOutputTopics(topics) {
            return (getFlatTopics(topics));
        }

        /**
         * Returns a flat version of the topic tree for storage
         * @param list
         * @returns {Array}
         */
        function getFlatTopics(list) {
            var result = [];
            for (var i = 0; i < list.length; i++) {
                var topic = list[i];
                console.log(topic);
                // Topic has children, add children to the result list
                if (topic.children) {
                    var children = getFlatTopics(topic.children);
                    // Add each children to the result list
                    for (var j = 0; j < children.length; j++) {
                        result.push(children[j]);
                    }
                }
                // Delete the children list for topic before it is added to the result list
                delete topic["children"];
                result.push(topic);
            }
            return result;
        }

        /**
         * Returns list of documents ready for storage
         * @param documents
         * @returns {Array}
         */
        function constructOutputDocuments(documents) {
            var output_documents = [];
            for (var i = 0; i < documents.length; i++) {
                var document = documents[i];
                delete document["profiles"];

                output_documents.push(document);
            }
            return output_documents;
        }

        /**
         * Returns deep copy of documents
         *
         * Removes the list populatedProfiles to avoid circular dependencies.
         * @param list
         * @returns {Array}
         */
        function cloneDocuments(list) {
            var clone = [];
            for (var element in list) {
                var element_clone = ServiceFunction.cloneObject(element);
                if (element_clone.populatedProfiles) {
                    delete element_clone["populatedProfiles"];
                }
                clone.push(element_clone);
            }
            return clone;
        }

        /**
         * Returns storage list<commit_msg>Fixed only ids listed in document list in downloaded file<commit_after>"use strict";

angular.module("ehelseEditor").factory("DownloadList",
    ["$rootScope", "FileUpload", "ServiceFunction", "StorageHandler", "Action", "Document", "DocumentField", "DocumentType", "LinkCategory", "Mandatory", "Status", "TargetGroup", "Topic",
    function ($rootScope, FileUpload, ServiceFunction, StorageHandler, Action, Document, DocumentField, DocumentType, LinkCategory, Mandatory, Status, TargetGroup, Topic) {

        /**
         * Returns list of topics ready for storage
         * @param topics
         * @returns {Array}
         */
        function constructOutputTopics(topics) {
            return (getFlatTopics(topics));
        }

        /**
         * Returns a flat version of the topic tree for storage
         * @param list
         * @returns {Array}
         */
        function getFlatTopics(list) {
            var result = [];
            for (var i = 0; i < list.length; i++) {
                var topic = list[i];
                console.log(topic);
                // Topic has children, add children to the result list
                if (topic.children) {
                    var children = getFlatTopics(topic.children);
                    // Add each children to the result list
                    for (var j = 0; j < children.length; j++) {
                        result.push(children[j]);
                    }
                }
                // Delete the children list for topic before it is added to the result list
                delete topic["children"];
                result.push(topic);
            }
            return result;
        }

        /**
         * Returns list of documents ready for storage
         * @param documents
         * @returns {Array}
         */
        function constructOutputDocuments(documents) {
            var output_documents = [];
            for (var i = 0; i < documents.length; i++) {
                var document = documents[i];
                delete document["profiles"];

                output_documents.push(document);
            }
            return output_documents;
        }

        /**
         * Returns deep copy of documents
         *
         * Removes the list populatedProfiles to avoid circular dependencies.
         * @param list
         * @returns {Array}
         */
        function cloneDocuments(list) {
            var clone = [];
            for (var i = 0; i < list.length; i++) {
                var element = list[i];
                var element_clone = ServiceFunction.cloneObject(element);
                if (element_clone.populatedProfiles) {
                    delete element_clone["populatedProfiles"];
                }
                clone.push(element_clone);
            }
            return clone;
        }

        /**
         * Returns storage list
{'fraction_non_alphanumeric': 0.09835776090411442, 'fraction_numerical': 0.0012360939431396785, 'mean_word_length': 1.5479082321187585, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2733348', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1306, 'n_words': 395}