<commit_before>/** Copyright 2013-2020 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see http://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

const ValidatedJDLObject = require('../core/validated_jdl_object');
const JDLEntity = require('../core/jdl_entity');
const JDLUnaryOption = require('../core/jdl_unary_option');
const JDLBinaryOption = require('../core/jdl_binary_option');
const ApplicationTypes = require('../core/jhipster/application_types');
const BinaryOptions = require('../core/jhipster/binary_options');
const { lowerFirst } = require('../utils/string_utils');

const { convertApplications } = require('../converters/parsedJDLToJDLObject/application_converter');
const { convertEntities } = require('../converters/parsedJDLToJDLObject/entity_converter');
const { convertEnums } = require('../converters/parsedJDLToJDLObject/enum_converter');
const { convertField } = require('../converters/parsedJDLToJDLObject/field_converter');
const { convertValidations } = require('../converters/parsedJDLToJDLObject/validation_converter');
const { convertOptions } = require('../converters/parsedJDLToJDLObject/option_converter');
const { convertRelationships } = require('../converters/parsedJDLToJDLObject/relationship_converter');
const { convertDeployments } = require('../converters/parsedJDLToJDLObject/deployment_converter');

module.exports = {
  parseFromConfigurationObject
};

const USER = 'User';

let parsedContent;
let configuration;
let jdlObject;
let entityNames;
let applicationsPerEntityName;

/**
 * Converts the intermediate parsedContent to a JDLObject from a configuration object.
 * @param {Object} configuration - The configuration object.
 * @param {Object} configuration.document - Deprecated set parsedContent instead, the parsed JDL content
 * @param {Object} configuration.parsedContent - The parsed JDL content
 * @param {String} configuration.applicationType - The application's type
 * @param {String} configuration.applicationName - The application's name
 * @param {String} configuration.generatorVersion - The generator's version
 * @param {Boolean} configuration.skippedUserManagement - Whether user management is skipped
 * @return {ValidatedJDLObject} the built JDL object.
 */
function parseFromConfigurationObject(configuration) {
  parsedContent = configuration.parsedContent || configuration.document;
  if (!parsedContent) {
    throw new Error('The parsed JDL content must be passed.');
  }
  init(configuration);
  fillApplications();
  fillDeployments();
  fillEnums();
  fillClassesAndFields();
  fillAssociations();
  fillOptions();
  return jdlObject;
}

function init(passedConfiguration) {
  configuration = passedConfiguration;<commit_msg>Renamed configuration variable<commit_after>/** Copyright 2013-2020 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see http://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

const ValidatedJDLObject = require('../core/validated_jdl_object');
const JDLEntity = require('../core/jdl_entity');
const JDLUnaryOption = require('../core/jdl_unary_option');
const JDLBinaryOption = require('../core/jdl_binary_option');
const ApplicationTypes = require('../core/jhipster/application_types');
const BinaryOptions = require('../core/jhipster/binary_options');
const { lowerFirst } = require('../utils/string_utils');

const { convertApplications } = require('../converters/parsedJDLToJDLObject/application_converter');
const { convertEntities } = require('../converters/parsedJDLToJDLObject/entity_converter');
const { convertEnums } = require('../converters/parsedJDLToJDLObject/enum_converter');
const { convertField } = require('../converters/parsedJDLToJDLObject/field_converter');
const { convertValidations } = require('../converters/parsedJDLToJDLObject/validation_converter');
const { convertOptions } = require('../converters/parsedJDLToJDLObject/option_converter');
const { convertRelationships } = require('../converters/parsedJDLToJDLObject/relationship_converter');
const { convertDeployments } = require('../converters/parsedJDLToJDLObject/deployment_converter');

module.exports = {
  parseFromConfigurationObject
};

const USER = 'User';

let parsedContent;
let configuration;
let jdlObject;
let entityNames;
let applicationsPerEntityName;

/**
 * Converts the intermediate parsedContent to a JDLObject from a configuration object.
 * @param {Object} configurationObject - The configuration object.
 * @param {Object} configurationObject.document - Deprecated set parsedContent instead, the parsed JDL content
 * @param {Object} configurationObject.parsedContent - The parsed JDL content
 * @param {String} configurationObject.applicationType - The application's type
 * @param {String} configurationObject.applicationName - The application's name
 * @param {String} configurationObject.generatorVersion - The generator's version
 * @param {Boolean} configurationObject.skippedUserManagement - Whether user management is skipped
 * @return {ValidatedJDLObject} the built JDL object.
 */
function parseFromConfigurationObject(configurationObject) {
  parsedContent = configurationObject.parsedContent || configurationObject.document;
  if (!parsedContent) {
    throw new Error('The parsed JDL content must be passed.');
  }
  init(configurationObject);
  fillApplications();
  fillDeployments();
  fillEnums();
  fillClassesAndFields();
  fillAssociations();
  fillOptions();
  return jdlObject;
}

function init(passedConfiguration) {
  configuration = passedConfiguration;
{'fraction_non_alphanumeric': 0.10567048667956541, 'fraction_numerical': 0.0035719601131120704, 'mean_word_length': 5.455331412103747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6319905', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1791, 'n_words': 519}