Search in sources :

Example 1 with Root_meta_external_shared_format_binding_Binding

use of org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding in project legend-engine by finos.

the class BindingCompiler method firstPass.

// First pass - create and index schemas
private PackageableElement firstPass(Binding srcSchemaOp, CompileContext context) {
    Root_meta_external_shared_format_binding_Binding binding = new Root_meta_external_shared_format_binding_Binding_Impl(srcSchemaOp.name)._name(srcSchemaOp.name)._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::external::shared::format::binding::Binding")));
    String path = context.pureModel.buildPackageString(srcSchemaOp._package, srcSchemaOp.name);
    this.bindingIndex.put(path, binding);
    context.pureModel.storesIndex.put(path, binding);
    return binding;
}
Also used : Root_meta_external_shared_format_binding_Binding(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) Root_meta_external_shared_format_binding_Binding_Impl(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding_Impl)

Example 2 with Root_meta_external_shared_format_binding_Binding

use of org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding in project legend-engine by finos.

the class BindingCompiler method fourthPass.

// Fourth pass - ensure correlation using the extension
private void fourthPass(Binding srcBinding, CompileContext context) {
    String path = context.pureModel.buildPackageString(srcBinding._package, srcBinding.name);
    Root_meta_external_shared_format_binding_Binding compiled = bindingIndex.get(path);
    ExternalFormatExtension schemaExtension = getExtension(compiled, srcBinding);
    Root_meta_external_shared_format_binding_validation_BindingDetail bindingDetail = schemaExtension.bindDetails(compiled, context);
    if (bindingDetail instanceof Root_meta_external_shared_format_binding_validation_FailedBindingDetail) {
        Root_meta_external_shared_format_binding_validation_FailedBindingDetail failed = (Root_meta_external_shared_format_binding_validation_FailedBindingDetail) bindingDetail;
        throw new EngineException("Model and schema are mismatched:\n" + failed._errorMessages().makeString("\n"), srcBinding.sourceInformation, EngineErrorType.COMPILATION);
    }
}
Also used : Root_meta_external_shared_format_binding_Binding(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding) Root_meta_external_shared_format_binding_validation_FailedBindingDetail(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_validation_FailedBindingDetail) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) ExternalFormatExtension(org.finos.legend.engine.external.shared.format.model.ExternalFormatExtension) Root_meta_external_shared_format_binding_validation_BindingDetail(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_validation_BindingDetail)

Example 3 with Root_meta_external_shared_format_binding_Binding

use of org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding in project legend-engine by finos.

the class ExternalFormatConnectionCompilerExtension method getExtraConnectionSecondPassProcessors.

@Override
public List<Procedure3<Connection, org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Connection, CompileContext>> getExtraConnectionSecondPassProcessors() {
    return Collections.singletonList((connectionValue, pureConnection, context) -> {
        if (connectionValue instanceof ExternalFormatConnection) {
            ExternalFormatConnection externalFormatConnection = (ExternalFormatConnection) connectionValue;
            List<IExternalFormatCompilerExtension> extensions = IExternalFormatCompilerExtension.getExtensions(context);
            Root_meta_external_shared_format_executionPlan_ExternalFormatConnection connection = (Root_meta_external_shared_format_executionPlan_ExternalFormatConnection) pureConnection;
            Store store = context.pureModel.getStore(connectionValue.element, connectionValue.elementSourceInformation);
            if (!(store instanceof Root_meta_external_shared_format_binding_Binding)) {
                throw new EngineException("Store for ExternalFormatConnection must be a Binding", connectionValue.sourceInformation, EngineErrorType.COMPILATION);
            }
            connection._element(store);
            Root_meta_external_shared_format_executionPlan_ExternalSource externalSource = IExternalFormatCompilerExtension.process(externalFormatConnection.externalSource, ListIterate.flatCollect(extensions, IExternalFormatCompilerExtension::getExtraExternalSourceSpecificationProcessors), context);
            connection._externalSource(externalSource);
        }
    });
}
Also used : Root_meta_external_shared_format_binding_Binding(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding) Root_meta_external_shared_format_executionPlan_ExternalFormatConnection(org.finos.legend.pure.generated.Root_meta_external_shared_format_executionPlan_ExternalFormatConnection) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Root_meta_external_shared_format_executionPlan_ExternalSource(org.finos.legend.pure.generated.Root_meta_external_shared_format_executionPlan_ExternalSource) Store(org.finos.legend.pure.m3.coreinstance.meta.pure.store.Store) Root_meta_external_shared_format_executionPlan_ExternalFormatConnection(org.finos.legend.pure.generated.Root_meta_external_shared_format_executionPlan_ExternalFormatConnection) ExternalFormatConnection(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatConnection)

Example 4 with Root_meta_external_shared_format_binding_Binding

use of org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding in project legend-engine by finos.

the class HelperExternalFormat method getBinding.

public static Root_meta_external_shared_format_binding_Binding getBinding(String fullPath, SourceInformation sourceInformation, CompileContext context) {
    Root_meta_external_shared_format_binding_Binding binding = getExternalFormatCompilerExtension(context).bindingCompiler.getCompiledBinding(fullPath);
    Assert.assertTrue(binding != null, () -> "Can't find (external format) Binding '" + fullPath + "'", sourceInformation, EngineErrorType.COMPILATION);
    return binding;
}
Also used : Root_meta_external_shared_format_binding_Binding(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding)

Example 5 with Root_meta_external_shared_format_binding_Binding

use of org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding in project legend-engine by finos.

the class Generator method transformBinding.

protected Binding transformBinding(Root_meta_external_shared_format_binding_Binding binding) {
    ModelUnit modelUnit = new ModelUnit();
    modelUnit.packageableElementIncludes = binding._modelUnit()._packageableElementIncludes().collect(this::elementToPath).toList();
    modelUnit.packageableElementExcludes = binding._modelUnit()._packageableElementExcludes().collect(this::elementToPath).toList();
    Binding result = new Binding();
    result.name = binding._name();
    result._package = elementToPath(binding._package());
    result.schemaSet = elementToPath(binding._schemaSet());
    result.schemaId = binding._schemaId();
    result.contentType = binding._contentType();
    result.modelUnit = modelUnit;
    return result;
}
Also used : Root_meta_external_shared_format_binding_Binding(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding) Binding(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.Binding) ModelUnit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.ModelUnit)

Aggregations

Root_meta_external_shared_format_binding_Binding (org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding)12 EngineException (org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)6 ExternalFormatExtension (org.finos.legend.engine.external.shared.format.model.ExternalFormatExtension)4 EngineErrorType (org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType)4 Root_meta_external_shared_format_binding_validation_BindingDetail (org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_validation_BindingDetail)4 ListIterate (org.eclipse.collections.impl.utility.ListIterate)3 PureModelContextData (org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData)3 Binding (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.Binding)3 Root_meta_external_shared_format_binding_Binding_Impl (org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding_Impl)3 Root_meta_external_shared_format_binding_validation_FailedBindingDetail (org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_validation_FailedBindingDetail)3 Root_meta_pure_metamodel_type_generics_GenericType_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl)3 Collections (java.util.Collections)2 Map (java.util.Map)2 Maps (org.eclipse.collections.api.factory.Maps)2 MutableMap (org.eclipse.collections.api.map.MutableMap)2 PureModel (org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel)2 Processor (org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor)2 ExternalFormatSchemaSet (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatSchemaSet)2 Root_meta_external_shared_format_metamodel_SchemaSet (org.finos.legend.pure.generated.Root_meta_external_shared_format_metamodel_SchemaSet)2 Root_meta_pure_model_unit_ModelUnit (org.finos.legend.pure.generated.Root_meta_pure_model_unit_ModelUnit)2