lib/z_Original_Working_meta.js
// Declare a function that we will use to drill into the object.
Declare a function that we will use to drill into the object.
Declare a function that we will use to drill into the object .
function drillIntoObject(address, objKey, previousObjKey, objectNestLevel)
            {      
              if(address[objKey][objKey + "0"])
              { 
                for (let property in address[objKey][objKey + "0"])
                {
                  if(address[objKey][objKey + "0"][property][property + "0"])
                  {
                    drillIntoObject(address[objKey][objKey + "0"], property, objKey, objectNestLevel + 1);                    
                  }
                  else 
                  { 
                    let objectPath = objKey + "." + objKey + "0" + "." + property;
                    if(address[objKey][objKey + "0"][property].calculation && Object.keys(address[objKey][objKey + "0"][property].calculation).length > 0)
                    {
                      calculatedFieldsArray.push(objectPath);  
                      for (let calcKey in address[objKey][objKey + "0"][property].calculation)
                      {
                        if(calcKey === "putHandlerPreprocessing")
                        {
                          fieldCalculationCode = address[objKey][objKey + "0"][property].calculation[calcKey]; 
                          break;           
                        }
                      } 
                      if(fieldCalculationCode)
                      {
                        htmlString = htmlString + 
                        "        // Preprocessing for " + objectPath + "\n" +
                        "        " + fieldCalculationCode + "\n\n";
                      }
                      else 
                      {
                        let fieldName = objectPath.split(".")[objectPath.split(".").length - 1]
                        let xPath = objectPath.split("0").join("X")
                        let containerX = objectPath.split("0")[0].split(".")[objectPath.split("0")[0].split(".").length -1];
                        htmlString = htmlString + 
`        for (let arrayIndex = 0; arrayIndex < ${fieldName}Array.length; arrayIndex++) 
        {
          // Preprocessing for ${xPath}
          if(${fieldName}Array[arrayIndex]) // If the user supplied data for ${xPath}
          {
            // No preprocessing was specifed for ${xPath}. Use it as was supplied by the user.
          }
          else // If the user did not supply data for ${xPath}
          {
            // Save ${xPath} from the most recent record.
            ${recordObject.tableName}Object.${containerX}["${containerX}" + arrayIndex.toString()]["${fieldName}"] = ${fieldName}Array[arrayIndex];
          }
        } 
`
                      }  
                    } 
                  } 
                } 
              } 
            } 
function drillIntoObject ( address , objKey , previousObjKey , objectNestLevel ) { if ( address [ objKey ] [ objKey + "0" ] ) { for ( let property in address [ objKey ] [ objKey + "0" ] ) { if ( address [ objKey ] [ objKey + "0" ] [ property ] [ property + "0" ] ) { drillIntoObject ( address [ objKey ] [ objKey + "0" ] , property , objKey , objectNestLevel + 1 ) ; } else { let objectPath = objKey + "." + objKey + "0" + "." + property ; if ( address [ objKey ] [ objKey + "0" ] [ property ] . calculation && Object . keys ( address [ objKey ] [ objKey + "0" ] [ property ] . calculation ) . length > 0 ) { calculatedFieldsArray . push ( objectPath ) ; for ( let calcKey in address [ objKey ] [ objKey + "0" ] [ property ] . calculation ) { if ( calcKey === "putHandlerPreprocessing" ) { fieldCalculationCode = address [ objKey ] [ objKey + "0" ] [ property ] . calculation [ calcKey ] ; break ; } } if ( fieldCalculationCode ) { htmlString = htmlString + "        // Preprocessing for " + objectPath + "\n" + "        " + fieldCalculationCode + "\n\n" ; } else { let fieldName = objectPath . split ( "." ) [ objectPath . split ( "." ) . length - 1 ] let xPath = objectPath . split ( "0" ) . join ( "X" ) let containerX = objectPath . split ( "0" ) [ 0 ] . split ( "." ) [ objectPath . split ( "0" ) [ 0 ] . split ( "." ) . length - 1 ] ; htmlString = htmlString + ` ${ fieldName } ${ xPath } ${ fieldName } ${ xPath } ${ xPath } ${ xPath } ${ xPath } ${ recordObject . tableName } ${ containerX } ${ containerX } ${ fieldName } ${ fieldName } ` } } } } } }
Declare a function that we will use to drill into the object.
Declare a function that we will use to drill into the object .
// if the subfield is also an object then this function calls itself using the subfield parameters. // This will continue drilling in until we are at the end of the branches // Check each property of the subobject to see if it too is an object. // If the property is also an object // This function calls itself so as to go deeper into the object // This property is not an object. We are at the end of the branch where we encounter a data field. // Assemble the path through the current object to the current data field. // Check if the current field contains the calculation object and if it has any properties. // Get the (PUT Handler Pre-processing code) from the calculation object for the current field if it exists. // If the programmer entered code in data dictionary then insert it into the put handler. // No code in the data dictionary for this process. So build generic code. // Get fieldName from the objectPath. That's the very last part. // Replacing the zero with the letter X for use in comments. // Gives us the subObject with out a zero or X at the end. // End of: Else: no code in the data dictionary for this process. // End of: if(address[objKey].subObject[property].calculation && ... // End of: else - This property is not an object. // End of: for-let Check each property of the subobject to see if it too is an object. // End of: if the subfield is also an objectCheck if the current field contains the calculation object and if it has any // End of: function drillIntoObject(address, objKey, previousObjKey, previousKeyPart, objectNestLevel){...}