All Downloads are FREE. Search and download functionalities are using the official Maven repository.

core.pure.lineage.scanMapping.pure Maven / Gradle / Ivy

There is a newer version: 4.57.1
Show newest version
// Copyright 2022 Goldman Sachs
//
// 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.

import meta::pure::lineage::scanMapping::*;
import meta::pure::mapping::*;

function meta::pure::lineage::scanMapping::scanMapping(val:Any[1]):Mapping[*]
{
   $val->scanMappingInternal()->removeDuplicates();
}

function <> meta::pure::lineage::scanMapping::scanMappingInternal(val:Any[1]):Mapping[*]
{
   $val->match([
      l:LambdaFunction[1]|$l->scanMappingFunctionDefinition(),
      f:FunctionDefinition[1]|$f->scanMappingFunctionDefinition(),
      n:NativeFunction[1]|[],
      fe:FunctionExpression[1]|let fromParams = $fe.parametersValues->map(pw|$pw->scanMappingInternal());
                                 if($fe.func->toOne()->elementToPath()->startsWith('meta::'), |[], |$fe.func->scanMappingInternal())->concatenate($fromParams);,
      i:InstanceValue[1]|$i.values->map(i|$i->scanMappingInternal());,
      p:VariableExpression[1]|[],
      p:KeyExpression[1]|[],
      p:Mapping[1]|$p,
      c:Class[1]|[],
      p:Property[1]|[],
      e:Enumeration[1]|[],
      p:String[1]|[],
      p:Boolean[1]|[],
      p:Integer[1]|[],
      a:Any[1]|[]
   ]
  );
}

function <> meta::pure::lineage::scanMapping::scanMappingFunctionDefinition(f:FunctionDefinition[1]):Mapping[*]
{
   $f.expressionSequence->evaluateAndDeactivate()->map(a|$a->scanMappingInternal());
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy