use of org.finos.legend.pure.generated.Root_meta_pure_mapping_MappingClass_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_mapping_MappingClass_Impl in project legend-engine by finos.
the class HelperMappingBuilder method processMappingClass.
public static Root_meta_pure_mapping_MappingClass_Impl processMappingClass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.MappingClass mappingclass, CompileContext context, Mapping parent) {
Root_meta_pure_mapping_MappingClass_Impl mappingClass = new Root_meta_pure_mapping_MappingClass_Impl<>(" ");
mappingClass._name(mappingclass.name);
MutableList<Generalization> generalizations = ListIterate.collect(mappingclass.superTypes, (superType) -> {
Generalization generalization = new Root_meta_pure_metamodel_relationship_Generalization_Impl("")._general(context.resolveGenericType(superType))._specific(mappingClass);
context.resolveType(superType)._specializationsAdd(generalization);
return generalization;
});
mappingClass._generalizations(generalizations);
if (mappingclass.setImplementation != null) {
mappingClass._setImplementation(mappingclass.setImplementation.accept(new ClassMappingFirstPassBuilder(context, parent)).getOne());
}
if (mappingclass.rootClass != null) {
mappingClass._class((org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) mappingclass.rootClass.accept(new PackageableElementThirdPassBuilder(context)));
}
return mappingClass;
}
use of org.finos.legend.pure.generated.Root_meta_pure_mapping_MappingClass_Impl in project legend-engine by finos.
the class HelperRelationalBuilder method processRelationalClassMapping.
public static SetImplementation processRelationalClassMapping(RelationalClassMapping relationalClassMapping, CompileContext context, RelationalInstanceSetImplementation base, RootRelationalInstanceSetImplementation topParent, Mapping parent, MutableList<org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.EmbeddedRelationalInstanceSetImplementation> embeddedRelationalPropertyMappings, RichIterable<org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping<Object>> enumerationMappings, MutableMap<String, TableAlias> aliasMap) {
final org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class pureClass = relationalClassMapping._class != null ? context.resolveClass(relationalClassMapping._class, relationalClassMapping.classSourceInformation) : base._class();
RichIterable<org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement> primaryKey = ListIterate.collect(relationalClassMapping.primaryKey, p -> processRelationalOperationElement(p, context, UnifiedMap.newMap(), FastList.newList()));
MutableList<org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyMapping> localMappingProperties = ListIterate.select(relationalClassMapping.propertyMappings, p -> p.localMappingProperty != null);
if (localMappingProperties.notEmpty()) {
MappingClass mappingClass = new Root_meta_pure_mapping_MappingClass_Impl<>("");
mappingClass._name(pureClass._name() + "_" + parent._name() + "_" + base._id());
GenericType gType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::mapping::MappingClass"))._typeArguments(Lists.mutable.with(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(mappingClass)));
mappingClass._classifierGenericType(gType);
Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("")._specific(mappingClass)._general(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(pureClass));
mappingClass._generalizations(Lists.mutable.with(g));
mappingClass._properties(localMappingProperties.collect((Function<org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyMapping, Property>) propertyMapping -> {
GenericType returnGenericType = context.resolveGenericType(propertyMapping.localMappingProperty.type, propertyMapping.localMappingProperty.sourceInformation);
return new Root_meta_pure_metamodel_function_property_Property_Impl<>(propertyMapping.property.property)._name(propertyMapping.property.property)._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::property::Property"))._typeArguments(Lists.fixedSize.of(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(mappingClass), returnGenericType)))._genericType(returnGenericType)._multiplicity(context.pureModel.getMultiplicity(propertyMapping.localMappingProperty.multiplicity))._owner(mappingClass);
}));
base._mappingClass(mappingClass);
}
base._class(pureClass)._primaryKey(primaryKey)._propertyMappings(ListIterate.collect(relationalClassMapping.propertyMappings, propertyMapping -> processAbstractRelationalPropertyMapping(propertyMapping, context, base, topParent, embeddedRelationalPropertyMappings, enumerationMappings, aliasMap)))._parent(parent);
return base;
}
Aggregations