<commit_before>'use strict';

angular.module('app')
    .controller('rgiNewRefDialogCtrl', function (
        $q,
        $scope,
        $rootScope,
        $route,
        $timeout,
        $http,
        ngDialog,
        rgiAllowedFileExtensionGuideSrvc,
        rgiDialogFactory,
        rgiNotifier,
        FileUploader,
        rgiUtilsSrvc,
        rgiFileUploaderSrvc,
        rgiRequestSubmitterSrvc,
        rgiAnswerMethodSrvc,
        rgiAssessmentSrvc,
        rgiIntervieweeSrvc,
        rgiIntervieweeMethodSrvc,
        rgiIdentitySrvc
    ) {
        /////////////
        //INTERVIEWEE
        /////////////
        $scope.current_user = rgiIdentitySrvc.currentUser;
        $scope.editorContentMaxLength = $scope.$root.editorContentMaxLength;
        $scope.taToolbarOptions = $scope.$root.taToolbarOptions;

        $scope.role_opts = [
            {text: 'Government', value: 'government'},
            {text: 'CSO', value: 'cso'},
            {text: 'Industry', value: 'industry'},
            {text: 'Expert', value: 'expert'},
            {text: 'Other', value: 'other'}];
        $scope.salutation_opts = ['mr.', 'mrs.', 'ms.'];
        //Datepicker opts
        var today = new Date();
        $scope.date_default = today;
        $scope.date_max_limit = today;
        $scope.date_options = {
            formatYear: 'yy',
            startingDay: 1
        };
        $scope.date_formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
        $scope.date_format = $scope.date_formats[0];
        $scope.status = {
            opened: false
        };
        $scope.calendarOpen = function () {
            $scope.status.opened = true;
        };
        $scope.maxDate = today;

        $scope.answer_update = $scope.$parent.answer;
        $scope.interviewee_list = [];
        //rgiIntervieweeSrvc.get({assessment_ID: 'DZ-2015-PI'}, function (interviewees) {
        rgiIntervieweeSrvc.query({}, function (interviewees) {
            interviewees.forEach(function (interviewee) {
                var interviewee_add = {
                    firstName: interviewee.firstName,
                    lastName: interviewee.lastName,
                    id: interviewee._id,
                    assessments: interviewee.assessments,
                    email: interviewee.email,
                    assessment_countries: []
                };
                interviewee.assessments.forEach(function (assessment_ID) {
                    rgiAssessmentSrvc.get({assessment_ID: assessment_ID}, function (assessment) {
                        interviewee_add.assessment_countries.push(assessment.country);
                    });
                });
                $scope.interviewee_list.push(interviewee_add);
            });
        });

        $scope.intervieweeSelect = function (selection) {
            $scope.interviewee_selection = selection;
        };

        $scope.interviewRefSubmit = function (selected_interviewee) {
            var contact_date, email_domain, new_ref_data, selected_interviewee_ID,
                new_answer_data = $scope.answer_update,
                current_user = $scope.current_user;

            //error handling
            if (!new_answer_data.human_ref_comment) {
                rgiNotifier.error('You must enter interview content!');
            } else if (!new_answer_data.human_ref_contact_date) {
                rgiNotifier.error('You must enter interview date!');
            } else if (!selected_interviewee) {
                rgiNotifier.error('You must select an existing contact or create a new one!');
            } else {
                contact_date = new Date(new_answer_data.human_ref_contact_date).toISOString();

                if ($scope.interviewee_selection==='new') {
                    if (!selected_interviewee.firstName || !selected_interviewee.lastName) {
                        rgiNotifier.error('You must enter a first and last name for new interviewees!');
                    } else if (!selected_interviewee.role) {
                        rgiNotifier.error('You must select a role for new interviewees!');
                    } else if (!selected_interviewee.organization) {
                        rgiNotifier.error('You must enter an organization for new interviewees!');
                    } else {
                        if (!selected_interviewee.email && selected_interviewee.phone) {
                            rgiNotifier.error('You must enter a valid email address or phone number!');
                        } else {
                            email_domain = 'http://' + selected_interviewee.email.split('@')[1];
                            if (email_domain === 'http://undefined') {
                                rgiNotifier.error('You must enter a valid email address!');
                            } else {
                                selected_interviewee.answers = [new_answer_data.answer_ID];
                                selected_interviewee.assessments = [new_answer_data.assessment_ID];
                                selected_interviewee.questions = [new_answer_data.question_ID];
                                selected_interviewee.users = [current_user._id];
                                rgiIntervieweeMethodSrvc.createInterviewee(selected_interviewee)
                                    .then(function (interviewee) {
                                        new_ref_data = {
                                            citation_type: 'interview',
                                            interviewee_ID: interviewee._id,
                                            contact_date: contact_date,<commit_msg>changed error message for missing interviewee role. closes #192<commit_after>'use strict';

angular.module('app')
    .controller('rgiNewRefDialogCtrl', function (
        $q,
        $scope,
        $rootScope,
        $route,
        $timeout,
        $http,
        ngDialog,
        rgiAllowedFileExtensionGuideSrvc,
        rgiDialogFactory,
        rgiNotifier,
        FileUploader,
        rgiUtilsSrvc,
        rgiFileUploaderSrvc,
        rgiRequestSubmitterSrvc,
        rgiAnswerMethodSrvc,
        rgiAssessmentSrvc,
        rgiIntervieweeSrvc,
        rgiIntervieweeMethodSrvc,
        rgiIdentitySrvc
    ) {
        /////////////
        //INTERVIEWEE
        /////////////
        $scope.current_user = rgiIdentitySrvc.currentUser;
        $scope.editorContentMaxLength = $scope.$root.editorContentMaxLength;
        $scope.taToolbarOptions = $scope.$root.taToolbarOptions;

        $scope.role_opts = [
            {text: 'Government', value: 'government'},
            {text: 'CSO', value: 'cso'},
            {text: 'Industry', value: 'industry'},
            {text: 'Expert', value: 'expert'},
            {text: 'Other', value: 'other'}];
        $scope.salutation_opts = ['mr.', 'mrs.', 'ms.'];
        //Datepicker opts
        var today = new Date();
        $scope.date_default = today;
        $scope.date_max_limit = today;
        $scope.date_options = {
            formatYear: 'yy',
            startingDay: 1
        };
        $scope.date_formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
        $scope.date_format = $scope.date_formats[0];
        $scope.status = {
            opened: false
        };
        $scope.calendarOpen = function () {
            $scope.status.opened = true;
        };
        $scope.maxDate = today;

        $scope.answer_update = $scope.$parent.answer;
        $scope.interviewee_list = [];
        //rgiIntervieweeSrvc.get({assessment_ID: 'DZ-2015-PI'}, function (interviewees) {
        rgiIntervieweeSrvc.query({}, function (interviewees) {
            interviewees.forEach(function (interviewee) {
                var interviewee_add = {
                    firstName: interviewee.firstName,
                    lastName: interviewee.lastName,
                    id: interviewee._id,
                    assessments: interviewee.assessments,
                    email: interviewee.email,
                    assessment_countries: []
                };
                interviewee.assessments.forEach(function (assessment_ID) {
                    rgiAssessmentSrvc.get({assessment_ID: assessment_ID}, function (assessment) {
                        interviewee_add.assessment_countries.push(assessment.country);
                    });
                });
                $scope.interviewee_list.push(interviewee_add);
            });
        });

        $scope.intervieweeSelect = function (selection) {
            $scope.interviewee_selection = selection;
        };

        $scope.interviewRefSubmit = function (selected_interviewee) {
            var contact_date, email_domain, new_ref_data, selected_interviewee_ID,
                new_answer_data = $scope.answer_update,
                current_user = $scope.current_user;

            //error handling
            if (!new_answer_data.human_ref_comment) {
                rgiNotifier.error('You must enter interview content!');
            } else if (!new_answer_data.human_ref_contact_date) {
                rgiNotifier.error('You must enter interview date!');
            } else if (!selected_interviewee) {
                rgiNotifier.error('You must select an existing contact or create a new one!');
            } else {
                contact_date = new Date(new_answer_data.human_ref_contact_date).toISOString();

                if ($scope.interviewee_selection==='new') {
                    if (!selected_interviewee.firstName || !selected_interviewee.lastName) {
                        rgiNotifier.error('You must enter a first and last name for new interviewees!');
                    } else if (!selected_interviewee.role) {
                        rgiNotifier.error('You must select a type of organization for new interviewees!');
                    } else if (!selected_interviewee.organization) {
                        rgiNotifier.error('You must enter an organization for new interviewees!');
                    } else {
                        if (!selected_interviewee.email && selected_interviewee.phone) {
                            rgiNotifier.error('You must enter a valid email address or phone number!');
                        } else {
                            email_domain = 'http://' + selected_interviewee.email.split('@')[1];
                            if (email_domain === 'http://undefined') {
                                rgiNotifier.error('You must enter a valid email address!');
                            } else {
                                selected_interviewee.answers = [new_answer_data.answer_ID];
                                selected_interviewee.assessments = [new_answer_data.assessment_ID];
                                selected_interviewee.questions = [new_answer_data.question_ID];
                                selected_interviewee.users = [current_user._id];
                                rgiIntervieweeMethodSrvc.createInterviewee(selected_interviewee)
                                    .then(function (interviewee) {
                                        new_ref_data = {
                                            citation_type: 'interview',
                                            interviewee_ID: interviewee._id,
                                            contact_date: contact_date,
{'fraction_non_alphanumeric': 0.101421301982804, 'fraction_numerical': 0.0014914897350412353, 'mean_word_length': 1.6144495412844038, 'pattern_counts': {'":': 0, '<': 3, '<?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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1211792', 'n_tokens_mistral': 3262, 'n_tokens_neox': 3027, 'n_words': 523}