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

core_servicestore.contract.storeContract.pure Maven / Gradle / Ivy

The newest version!
// Copyright 2021 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::store::*;
import meta::pure::router::clustering::*;
import meta::pure::router::systemMapping::tests::*;
import meta::pure::executionPlan::*;
import meta::pure::graphFetch::execution::*;
import meta::pure::graphFetch::executionPlan::*;
import meta::pure::mapping::*;
import meta::pure::extension::*;
import meta::core::runtime::*;
import meta::external::store::service::functions::pureToServiceStoreQuery::*;
import meta::external::store::service::metamodel::mapping::*;
import meta::external::store::service::metamodel::runtime::*;
import meta::external::store::service::executionPlan::nodes::*;
import meta::pure::graphFetch::executionPlan::*;
import meta::pure::graphFetch::routing::*;


function meta::external::store::service::contract::serviceStoreStoreContract():StoreContract[1]
{
   ^StoreContract
   (
     id = 'serviceStore',
     supports = meta::external::store::service::contract::supports_FunctionExpression_1__Boolean_1_,
     planExecution = meta::external::store::service::contract::planExecution_StoreQuery_1__RoutedValueSpecification_$0_1$__Mapping_$0_1$__Runtime_$0_1$__ExecutionContext_1__Extension_MANY__DebugContext_1__ExecutionNode_1_,
     planGraphFetchExecution = meta::external::store::service::contract::planGraphFetchExecution_StoreMappingLocalGraphFetchExecutionNodeGenerationInput_1__LocalGraphFetchExecutionNode_1_,
     planCrossGraphFetchExecution = meta::external::store::service::contract::planCrossGraphFetchExecution_StoreMappingCrossLocalGraphFetchExecutionNodeGenerationInput_1__LocalGraphFetchExecutionNode_1_,

     supportsSetImplementation = s:SetImplementation[1]|$s->instanceOf(RootServiceInstanceSetImplementation) || $s->instanceOf(EmbeddedServiceStoreSetImplementation),
     supportsStore = s:Store[1]|$s->instanceOf(meta::external::store::service::metamodel::ServiceStore),
     resolveStoreFromSetImplementation = s:InstanceSetImplementation[1]|$s->match(
                                                                            [
                                                                              r : RootServiceInstanceSetImplementation[1] | $r.serviceStore(),
                                                                              e : EmbeddedServiceStoreSetImplementation[1] | $e->resolveRootFromEmbedded()->cast(@RootServiceInstanceSetImplementation).serviceStore();
                                                                            ]
                                                                        ),
     supportsNativeJoinAmongElements = false,

     printConnectionToString = {extensions:meta::pure::extension::Extension[*]|
                                       [
                                           s:ServiceStoreConnection[1]| meta::external::store::service::executionPlan::toString::serviceStoreConnectionToString($s);
                                       ]},
     printPlanNodeToString = {space : String[1], extensions:meta::pure::extension::Extension[*]|
                                       [
                                          s:RestServiceExecutionNode[1] | meta::external::store::service::executionPlan::toString::serviceStoreExecutionNodeToString($s, $space, $extensions);,
                                          sp:ServiceParametersResolutionExecutionNode[1] | meta::external::store::service::executionPlan::toString::serviceParametersResolutionExecutionNodeToString($sp, $space, $extensions);,
                                          l:LimitExecutionNode[1] | meta::external::store::service::executionPlan::toString::limitExecutionNodeToString($l, $space, $extensions);
                                       ]},
    extractSourceClassFromSetImplementation =
            [
              s: RootServiceInstanceSetImplementation[1]  | $s.class,
              e: EmbeddedServiceStoreSetImplementation[1] | $e.class
            ],
    crossStoreSourceSupportsBatching = {
        set:InstanceSetImplementation[1], xProperties:AbstractProperty[*], params : Map[1] |
          if ($set->instanceOf(RootServiceInstanceSetImplementation),
            | $xProperties->meta::external::store::service::executionPlan::generation::querySupportsBatching($params, $set->cast(@RootServiceInstanceSetImplementation)),
            | false
          )
    }
   )
}

// Execution Plan
function meta::external::store::service::contract::planExecution(sq:StoreQuery[1], ext:RoutedValueSpecification[0..1], mapping:Mapping[0..1], runtime:Runtime[0..1], exeCtx:meta::pure::runtime::ExecutionContext[1], extensions:Extension[*], debug:DebugContext[1]):ExecutionNode[1]
{
   let fe = $sq.fe->evaluateAndDeactivate()->cast(@FunctionExpression);
   assert($fe.func->in(graphFetchFunctions()), 'Service Store supports graphFetch queries only');
   planGraphFetchExecution($sq, $ext, $mapping->toOne(), $runtime->toOne(), $exeCtx, $extensions, $debug);
}

function meta::external::store::service::contract::planGraphFetchExecution(input: StoreMappingLocalGraphFetchExecutionNodeGenerationInput[1]): LocalGraphFetchExecutionNode[1]
{
  meta::external::store::service::executionPlan::generation::planRootGraphFetchExecutionServiceStore($input.storeQuery, $input.ext, $input.clusteredTree, $input.orderedPaths, $input.mapping, $input.runtime, $input.exeCtx, $input.enableConstraints, $input.checked, $input.extensions, $input.debug)
}

function meta::external::store::service::contract::planCrossGraphFetchExecution(input: StoreMappingCrossLocalGraphFetchExecutionNodeGenerationInput[1]): LocalGraphFetchExecutionNode[1]
{
  meta::external::store::service::executionPlan::generation::planCrossStoreGraphFetchExecutionServiceStore($input.clusteredTree, $input.orderedPaths, $input.parentPath, $input.inScopeVars, $input.mapping, $input.runtime, $input.exeCtx, $input.enableConstraints, $input.checked, $input.extensions, $input.debug)
}

// Functions supported by serviceStore execution
function meta::external::store::service::contract::supports(f:FunctionExpression[1]):Boolean[1]
{
   !findSupportedFunction($f, getSupportedFunctions())->isEmpty()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy