<commit_before>import { Router } from '@angular/router';

import { OFormComponent } from '../components/form/o-form.component';
import { OFormValue } from '../components/form/OFormValue';
import { SQLOrder } from '../types/sql-order.type';
import { Codes } from './codes';
import { SQLTypes } from './sqltypes';
import { Util } from './util';

export class ServiceUtils {

  static getParentKeysFromForm(parentKeysObject: object, form: OFormComponent) {
    const result = {};
    const ownKeys = Object.keys(parentKeysObject || {});

    const formComponents = form ? form.getComponents() : {};
    const existsComponents = Object.keys(formComponents).length > 0;

    const formDataProperties = form ? form.getDataValues() : {};
    const existsProperties = Object.keys(formDataProperties).length > 0;

    const urlData = form ? form.getFormNavigation().getFilterFromUrlParams() : {};
    const existsUrlData = Object.keys(urlData).length > 0;
    if (existsUrlData) {
      form.keysArray.forEach((key: string, i: number) => {
        if (urlData.hasOwnProperty(key)) {
          urlData[key] = SQLTypes.parseUsingSQLType(urlData[key], form.keysSqlTypesArray[i]);
        }
      });
    }

    if (existsComponents || existsProperties || existsUrlData) {
      ownKeys.forEach(ownKey => {
        const keyValue = parentKeysObject[ownKey];
        // Parent key equivalence may be an object<commit_msg>new  getParentKeysFromExpandableContainer method<commit_after>import { Router } from '@angular/router';

import { OFormComponent } from '../components/form/o-form.component';
import { OFormValue } from '../components/form/OFormValue';
import { SQLOrder } from '../types/sql-order.type';
import { Codes } from './codes';
import { SQLTypes } from './sqltypes';
import { Util } from './util';
import { OExpandableContainerComponent } from '../components/expandable-container/expandable-container.component';

export class ServiceUtils {
  static getParentKeysFromExpandableContainer(parentKeysObject: object, expandableContainer: OExpandableContainerComponent): {} {
    const result = {};
    const ownKeys = Object.keys(parentKeysObject || {});
    const dataComponent = expandableContainer ? expandableContainer.data : {};
    const existsData = Object.keys(dataComponent).length > 0;


    if (existsData) {
      ownKeys.forEach(ownKey => {
        const keyValue = parentKeysObject[ownKey];
        if (dataComponent.hasOwnProperty(keyValue)) {
          const value = dataComponent[keyValue];
          if (Util.isDefined(value)) {
            switch (typeof (value)) {
              case 'string':
                if (value.trim().length > 0) {
                  result[ownKey] = value.trim();
                }
                break;
              case 'number':
                if (!isNaN(value)) {
                  result[ownKey] = value;
                }
                break;
            }
          }
        }
      });
    }
    return result;
  }

  static getParentKeysFromForm(parentKeysObject: object, form: OFormComponent) {
    const result = {};
    const ownKeys = Object.keys(parentKeysObject || {});

    const formComponents = form ? form.getComponents() : {};
    const existsComponents = Object.keys(formComponents).length > 0;

    const formDataProperties = form ? form.getDataValues() : {};
    const existsProperties = Object.keys(formDataProperties).length > 0;

    const urlData = form ? form.getFormNavigation().getFilterFromUrlParams() : {};
    const existsUrlData = Object.keys(urlData).length > 0;
    if (existsUrlData) {
      form.keysArray.forEach((key: string, i: number) => {
        if (urlData.hasOwnProperty(key)) {
          urlData[key] = SQLTypes.parseUsingSQLType(urlData[key], form.keysSqlTypesArray[i]);
        }
      });
    }

    if (existsComponents || existsProperties || existsUrlData) {
      ownKeys.forEach(ownKey => {
        const keyValue = parentKeysObject[ownKey];
        // Parent key equivalence may be an object
{'fraction_non_alphanumeric': 0.1271907861792689, 'fraction_numerical': 0.00200300450676014, 'mean_word_length': 2.998998998998999, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '412786', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1073, 'n_words': 238}