core_analytics_mapping.modelCoverage.utility.pure Maven / Gradle / Ivy
// 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::analytics::mapping::modelCoverage::utility::*;
function meta::analytics::mapping::modelCoverage::utility::isMilestoned(type:Type[1]):Boolean[1]
{
$type->isBiTemporal() || $type->meta::analytics::mapping::modelCoverage::utility::isProcessingTemporal() || $type->meta::analytics::mapping::modelCoverage::utility::isBusinessTemporal();
}
function meta::analytics::mapping::modelCoverage::utility::isProcessingTemporal(type:Type[1]):Boolean[1]
{
$type->generalizations()->exists(c | $c->hasStereotype('processingtemporal', temporal));
}
function meta::analytics::mapping::modelCoverage::utility::isBusinessTemporal(type:Type[1]):Boolean[1]
{
$type->generalizations()->exists(c | $c->hasStereotype('businesstemporal', temporal));
}
function meta::analytics::mapping::modelCoverage::utility::isBiTemporal(type:Type[1]):Boolean[1]
{
$type->generalizations()->exists(c | $c->hasStereotype('bitemporal', temporal));
}
function meta::analytics::mapping::modelCoverage::utility::getValue(pairs : meta::pure::functions::collection::Pair[*], key : X[1]) : Y[1]
{
let r = newMap($pairs)->get($key);
assert($r->isNotEmpty(), | 'No value found for ' + $key->makeString() + if($pairs->size() < 15 && ($key->instanceOf(String) || $key->instanceOf(Enumeration)), |', expected one of ' + $pairs.first->map(x|$x->makeString())->sort()->joinStrings('[', ',', ']'), |''));
$r->toOne();
}
function meta::analytics::mapping::modelCoverage::utility::getValue(pairs : meta::pure::functions::collection::Pair[*], key : X[1], defaultValue : Y[1]) : Y[1]
{
let r = newMap($pairs)->get($key);
if ($r->isEmpty(),
| $defaultValue,
| $r->toOne();
);
}
function meta::analytics::mapping::modelCoverage::utility::findValues(pairs : Pair[*], value : X[1]) : Y[*]
{
$pairs->filter(p|$p.first == $value)->map(p | $p.second)
}
function meta::analytics::mapping::modelCoverage::utility::getFunctionPath(f:Function[1]):String[1]
{
$f->elementToPath()->replace($f.name->toOne(), $f.functionName->toOne());
}
function meta::analytics::mapping::modelCoverage::utility::qualifiedProperties(class:Class[1]):QualifiedProperty[*]
{
$class->generalizations()->init()->cast(@Class)->map(c |
$c.qualifiedProperties->concatenate($c.qualifiedPropertiesFromAssociations));
}
function meta::analytics::mapping::modelCoverage::utility::properties(class:Class[1]):Property[*]
{
$class->generalizations()->init()->cast(@Class)->map(c |
$c.properties->concatenate($c.propertiesFromAssociations));
}
function meta::analytics::mapping::modelCoverage::utility::allPropertiesRecursive(class:Class[1]):AbstractProperty[*]
{
$class->properties()->concatenate($class->qualifiedProperties());
}
function meta::analytics::mapping::modelCoverage::utility::getAutoMapFunctions():Function[*]
{
[
map_T_m__Function_1__V_m_,
map_T_MANY__Function_1__V_MANY_,
map_T_$0_1$__Function_1__V_$0_1$_
]
}
function meta::analytics::mapping::modelCoverage::utility::isAutoMap(func:Function[1]):Boolean[1]
{
$func->in(getAutoMapFunctions());
}
function meta::analytics::mapping::modelCoverage::utility::convertToPure(str:String[1]):LambdaFunction[1]
{
let compile = $str->compileValueSpecification();
assert($compile.succeeded, | $compile.failure.message->toOne());
$compile.result->toOne()->reactivate()->cast(@LambdaFunction)->toOne();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy