use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl 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;
}
use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl in project legend-engine by finos.
the class HelperMappingBuilder method buildMappingClassOutOfLocalProperties.
public static void buildMappingClassOutOfLocalProperties(SetImplementation setImplementation, RichIterable<? extends org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping> propertyMappings, CompileContext context) {
if (setImplementation instanceof InstanceSetImplementation && propertyMappings != null) {
List<? extends org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping> localPropertyMappings = ListIterate.select(propertyMappings.toList(), x -> x._localMappingProperty() != null && x._localMappingProperty());
if (!localPropertyMappings.isEmpty()) {
String mappingClassName = setImplementation._class().getName() + "_" + setImplementation._parent().getName() + "_" + setImplementation._id();
final MappingClass mappingClass = new Root_meta_pure_mapping_MappingClass_Impl<>(mappingClassName);
mappingClass._name(mappingClassName);
GenericType classifierGenericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::type::Class"))._typeArguments(Lists.fixedSize.of(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(mappingClass)));
mappingClass._classifierGenericType(classifierGenericType);
GenericType superType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(setImplementation._class());
Generalization newGeneralization = new Root_meta_pure_metamodel_relationship_Generalization_Impl("")._specific(mappingClass)._general(superType);
mappingClass._generalizations(Lists.immutable.with(newGeneralization));
setImplementation._class()._specializationsAdd(newGeneralization);
mappingClass._properties(ListIterate.collect(localPropertyMappings, pm -> {
Property property = pm._property();
property._owner(mappingClass);
property._classifierGenericType()._typeArguments().toList().get(0)._rawType(mappingClass);
return property;
}));
((InstanceSetImplementation) setImplementation)._mappingClass(mappingClass);
}
}
}
use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl in project legend-engine by finos.
the class HelperMappingBuilder method processPurePropertyMappingTransform.
public static LambdaFunction processPurePropertyMappingTransform(PurePropertyMapping ppm, Lambda lambda, PropertyMappingsImplementation owner, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type inputVarType, CompileContext context, String mappingName) {
List<ValueSpecification> expressions = lambda.body;
VariableExpression lambdaParam = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name("src")._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(inputVarType));
MutableList<VariableExpression> pureParameters = Lists.mutable.with(lambdaParam);
ProcessingContext ctx = new ProcessingContext("Pure M2M Transform Lambda");
ctx.addInferredVariables("src", lambdaParam);
MutableList<String> openVariables = Lists.mutable.empty();
MutableList<org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification> valueSpecifications = ListIterate.collect(expressions, p -> p.accept(new ValueSpecificationBuilder(context, openVariables, ctx)));
MutableList<String> cleanedOpenVariables = openVariables.distinct();
cleanedOpenVariables.removeAll(pureParameters.collect(e -> e._name()));
GenericType functionType = context.pureModel.buildFunctionType(pureParameters, valueSpecifications.getLast()._genericType(), valueSpecifications.getLast()._multiplicity());
String propertyName = owner._id() + "." + ppm.property.property;
String mappingPath = Root_meta_pure_functions_meta_elementToPath_PackageableElement_1__String_1_(owner._parent(), context.pureModel.getExecutionSupport()).replace("::", "_");
ctx.flushVariable("src");
return new Root_meta_pure_metamodel_function_LambdaFunction_Impl(propertyName, new SourceInformation(mappingPath, 0, 0, 0, 0), null)._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::LambdaFunction"))._typeArguments(FastList.newListWith(functionType)))._openVariables(cleanedOpenVariables)._expressionSequence(valueSpecifications);
}
use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl in project legend-engine by finos.
the class HelperMappingBuilder method processEnumMapping.
public static org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping<Object> processEnumMapping(EnumerationMapping em, Mapping pureMapping, CompileContext context) {
// validate there is no mixed protocol format for source value
List<Object> sourceValues = em.enumValueMappings.stream().flatMap(enumValueMapping -> enumValueMapping.sourceValues.stream()).collect(Collectors.toList());
if (sourceValues.stream().anyMatch(sourceValue -> !(sourceValue instanceof EnumValueMappingSourceValue)) && sourceValues.stream().anyMatch(sourceValue -> sourceValue instanceof EnumValueMappingSourceValue)) {
throw new EngineException("Mixed formats for enum value mapping source values", em.sourceInformation, EngineErrorType.COMPILATION);
}
// process enum value mappings
String id = getEnumerationMappingId(em);
return new Root_meta_pure_mapping_EnumerationMapping_Impl<>(id, SourceInformationHelper.toM3SourceInformation(em.sourceInformation), null)._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::mapping::EnumerationMapping"))._typeArguments(FastList.newListWith(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::type::Any")))))._name(id)._parent(pureMapping)._enumeration(context.resolveEnumeration(em.enumeration, em.sourceInformation))._enumValueMappings(ListIterate.collect(em.enumValueMappings, v -> new Root_meta_pure_mapping_EnumValueMapping_Impl(null, SourceInformationHelper.toM3SourceInformation(em.sourceInformation), null)._enum(context.resolveEnumValue(em.enumeration, v.enumValue))._sourceValues(convertSourceValues(em, v.sourceValues, context))));
}
use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl in project legend-engine by finos.
the class HelperMeasureBuilder method processUnitPackageableElementFirstPass.
public static org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Unit processUnitPackageableElementFirstPass(Unit unit, CompileContext context) {
final org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Unit targetUnit = new Root_meta_pure_metamodel_type_Unit_Impl(unit.name, SourceInformationHelper.toM3SourceInformation(unit.sourceInformation), null);
context.pureModel.typesIndex.put(context.pureModel.buildPackageString(unit._package, unit.name), targetUnit);
final GenericType genericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(targetUnit);
context.pureModel.typesGenericTypeIndex.put(context.pureModel.buildPackageString(unit._package, unit.name), genericType);
GenericType unitGenericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::type::Unit"));
org.finos.legend.pure.m3.coreinstance.Package pack = context.pureModel.getOrCreatePackage(unit._package);
org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Unit res = targetUnit._name(unit.name)._classifierGenericType(unitGenericType)._package(pack);
pack._childrenAdd(res);
return res;
}
Aggregations