use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.
the class RelationalOperationElementProcessor method processJoinTreeNode.
static void processJoinTreeNode(JoinTreeNode joinTreeNode, CoreInstance implementation, Matcher matcher, ProcessorState state, ModelRepository repository, ProcessorSupport processorSupport) {
String joinName = joinTreeNode._joinName();
Database database = (Database) ImportStub.withImportStubByPass(joinTreeNode._databaseCoreInstance(), processorSupport);
if (database == null) {
throw new PureCompilationException(joinTreeNode.getSourceInformation(), "The system can't figure out which database to use.");
}
PostProcessor.processElement(matcher, database, state, processorSupport);
CoreInstance joinType = joinTreeNode._joinTypeCoreInstance();
if (joinType != null) {
StringCoreInstance joinTypeString = (StringCoreInstance) joinType;
String type = "INNER".equals(joinTypeString.getValue()) ? "INNER" : "LEFT_OUTER";
Enumeration joinTypeEnumeration = (Enumeration) processorSupport.package_getByUserPath(M2RelationalPaths.JoinType);
Enum joinTypeEnumInstance = (Enum) org.finos.legend.pure.m3.navigation.enumeration.Enumeration.findEnum(joinTypeEnumeration, type);
if (joinTypeEnumInstance == null) {
throw new PureCompilationException(joinTreeNode.getSourceInformation(), "The enum value '" + type + "' can't be found in the enumeration " + PackageableElement.getUserPathForPackageableElement(joinTypeEnumeration, "::"));
}
joinTreeNode._joinTypeCoreInstance(joinTypeEnumInstance);
}
Join join = findJoin(joinTreeNode, database, joinName, processorSupport);
joinTreeNode._join(join);
PropertyMappingsImplementation owner = joinTreeNode._setMappingOwner();
if (owner == null && implementation != null) {
joinTreeNode._setMappingOwner((PropertyMappingsImplementation) implementation);
}
for (TreeNode child : joinTreeNode._childrenData()) {
processJoinTreeNode((JoinTreeNode) child, implementation, matcher, state, repository, processorSupport);
}
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.
the class RelationalPropertyMappingProcessor method collectJoinTreeNodes.
private static void collectJoinTreeNodes(Collection<? super JoinTreeNode> targetCollection, PropertyMapping propertyMapping) {
if (propertyMapping instanceof RelationalPropertyMapping) {
RelationalOperationElement relationalOperationElement = ((RelationalPropertyMapping) propertyMapping)._relationalOperationElement();
RelationalOperationElementProcessor.collectJoinTreeNodes(targetCollection, relationalOperationElement);
}
if (propertyMapping instanceof OtherwiseEmbeddedRelationalInstanceSetImplementation) {
PropertyMapping relationalOperationElement = ((OtherwiseEmbeddedRelationalInstanceSetImplementation) propertyMapping)._otherwisePropertyMapping();
collectJoinTreeNodes(targetCollection, relationalOperationElement);
}
if (propertyMapping instanceof PropertyMappingsImplementation) {
RichIterable<? extends PropertyMapping> propertyMappings = ((PropertyMappingsImplementation) propertyMapping)._propertyMappings();
for (PropertyMapping subMapping : propertyMappings) {
collectJoinTreeNodes(targetCollection, subMapping);
}
}
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.
the class RelationalOperationElementProcessor method processAliasForJoinTreeNode.
static void processAliasForJoinTreeNode(JoinTreeNode joinTreeNode, RelationalOperationElement startTable, ProcessorSupport processorSupport) {
TableAlias alias = findAliasForJoinTreeNode(joinTreeNode, startTable, processorSupport);
TableAlias aliasCopy = org.finos.legend.pure.m2.relational.TableAlias.copyTableAlias(alias, null, processorSupport);
PropertyMappingsImplementation setMappingOwner = joinTreeNode._setMappingOwner();
if (setMappingOwner != null) {
aliasCopy._setMappingOwner(setMappingOwner);
}
joinTreeNode._alias(aliasCopy);
RichIterable<? extends TreeNode> children = joinTreeNode._childrenData();
if (children.notEmpty()) {
RelationalOperationElement newStartTable = alias._relationalElement();
for (TreeNode child : children) {
processAliasForJoinTreeNode((JoinTreeNode) child, newStartTable, processorSupport);
}
}
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.
the class TableAlias method copyTableAlias.
private static org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias copyTableAlias(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias tableAlias, boolean replaceSourceInfo, SourceInformation newSourceInfo, ProcessorSupport processorSupport) {
org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias copy = (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias) processorSupport.newAnonymousCoreInstance(replaceSourceInfo ? newSourceInfo : tableAlias.getSourceInformation(), M2RelationalPaths.TableAlias);
copy._name(tableAlias._name());
copy._relationalElement(tableAlias._relationalElement());
PropertyMappingsImplementation setMappingOwner = tableAlias._setMappingOwner();
if (setMappingOwner != null) {
copy._setMappingOwner(setMappingOwner);
}
Database database = (Database) ImportStub.withImportStubByPass(tableAlias._databaseCoreInstance(), processorSupport);
if (database != null) {
copy._databaseCoreInstance(database);
}
String schema = tableAlias._schema();
if (schema != null) {
copy._schema(schema);
}
return copy;
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.
the class PropertyMappingUnloaderWalk method run.
@Override
public void run(PropertyMapping propertyMapping, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
PropertyMappingsImplementation owner = propertyMapping._owner();
matcher.fullMatch(owner, state);
}
Aggregations