use of org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Literal in project legend-pure by finos.
the class RelationalOperationElementProcessor method processColumnExpr.
static void processColumnExpr(RelationalOperationElement impl, CoreInstance implementation, CoreInstance mappingOwner, MutableSet<TableAlias> tableAliases, Matcher matcher, ProcessorState state, ModelRepository repository, ProcessorSupport processorSupport) throws PureCompilationException {
if (impl instanceof TableAliasColumn) {
processTableAliasColumn((TableAliasColumn) impl, mappingOwner, tableAliases, processorSupport);
} else if (impl instanceof DynaFunction) {
processDynaFunction((DynaFunction) impl, implementation, mappingOwner, tableAliases, matcher, state, repository, processorSupport);
} else if (impl instanceof RelationalOperationElementWithJoin) {
RelationalOperationElement relationalOperationElement = ((RelationalOperationElementWithJoin) impl)._relationalOperationElement();
if (relationalOperationElement != null) {
if (relationalOperationElement instanceof DynaFunction) {
processDynaFunction((DynaFunction) relationalOperationElement, implementation, mappingOwner, tableAliases, matcher, state, repository, processorSupport);
} else if (relationalOperationElement instanceof TableAliasColumn) {
processTableAliasColumn((TableAliasColumn) relationalOperationElement, mappingOwner, tableAliases, processorSupport);
}
}
JoinTreeNode joinTreeNode = ((RelationalOperationElementWithJoin) impl)._joinTreeNode();
if (joinTreeNode != null) {
processJoinTreeNode(joinTreeNode, mappingOwner, matcher, state, repository, processorSupport);
tableAliases.clear();
}
} else if (impl instanceof Literal) {
// Do nothing
} else {
throw new PureCompilationException(impl.getSourceInformation(), "Not Supported Yet! " + impl);
}
}
use of org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Literal in project legend-pure by finos.
the class RelationalOperationElementUnbind method cleanNode.
public static void cleanNode(RelationalOperationElement element, ModelRepository modelRepository, ProcessorSupport processorSupport) throws PureCompilationException {
if (element instanceof TableAliasColumn) {
TableAliasColumn tableAliasColumn = (TableAliasColumn) element;
ImportStub database = (ImportStub) tableAliasColumn._alias()._databaseCoreInstance();
Shared.cleanUpReferenceUsage(database, tableAliasColumn, processorSupport);
Shared.cleanImportStub(database, processorSupport);
tableAliasColumn._columnRemove();
TableAlias alias = tableAliasColumn._alias();
alias._relationalElementRemove();
} else if (element instanceof DynaFunction) {
for (RelationalOperationElement val : ((DynaFunction) element)._parameters()) {
cleanNode(val, modelRepository, processorSupport);
}
} else if (element instanceof RelationalOperationElementWithJoin) {
if (((RelationalOperationElementWithJoin) element)._relationalOperationElement() != null) {
cleanNode(((RelationalOperationElementWithJoin) element)._relationalOperationElement(), modelRepository, processorSupport);
}
if (((RelationalOperationElementWithJoin) element)._joinTreeNode() != null) {
cleanJoinTreeNode(((RelationalOperationElementWithJoin) element)._joinTreeNode(), modelRepository, processorSupport);
}
} else if (element instanceof Literal) {
// Nothing to do
} else {
throw new RuntimeException("TO CODE: clean relational operation element node of type " + PackageableElement.getUserPathForPackageableElement(element.getClassifier()));
}
}
use of org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Literal in project legend-engine by finos.
the class HelperRelationalBuilder method processRelationalOperationElement.
public static RelationalOperationElement processRelationalOperationElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.RelationalOperationElement operationElement, CompileContext context, MutableMap<String, org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias> aliasMap, MutableList<org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAliasColumn> selfJoinTargets) {
if (operationElement instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.TableAliasColumn) {
org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.TableAliasColumn tableAliasColumn = (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.TableAliasColumn) operationElement;
// Self join
if (tableAliasColumn.table.table.equals(SELF_JOIN_TABLE_NAME) && tableAliasColumn.tableAlias.equals(SELF_JOIN_TABLE_NAME)) {
org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAliasColumn selfJoin = new Root_meta_relational_metamodel_TableAliasColumn_Impl("")._columnName(tableAliasColumn.column);
selfJoinTargets.add(selfJoin);
return selfJoin;
}
Relation relation = getRelation((Database) context.resolveStore(tableAliasColumn.table.database, tableAliasColumn.table.sourceInformation), tableAliasColumn.table.schema, tableAliasColumn.table.table, tableAliasColumn.table.sourceInformation);
Column col = getColumn(relation, tableAliasColumn.column, tableAliasColumn.sourceInformation);
TableAlias alias = aliasMap.getIfAbsentPut(tableAliasColumn.table.schema + "." + tableAliasColumn.tableAlias, (Function0<TableAlias>) () -> new Root_meta_relational_metamodel_TableAlias_Impl("")._name(tableAliasColumn.tableAlias)._relationalElement(col._owner())._database(HelperRelationalBuilder.resolveDatabase(tableAliasColumn.table.getDb(), tableAliasColumn.table.sourceInformation, context)));
return new Root_meta_relational_metamodel_TableAliasColumn_Impl("")._columnName(col._name())._column(col)._alias(alias);
} else if (operationElement instanceof ElementWithJoins) {
ElementWithJoins elementWithJoins = (ElementWithJoins) operationElement;
RelationalOperationElementWithJoin res = new Root_meta_relational_metamodel_RelationalOperationElementWithJoin_Impl("")._joinTreeNode(buildElementWithJoinsJoinTreeNode(elementWithJoins.joins, context));
return elementWithJoins.relationalElement == null ? res : res._relationalOperationElement(processRelationalOperationElement(elementWithJoins.relationalElement, context, UnifiedMap.newMap(), selfJoinTargets));
} else if (operationElement instanceof DynaFunc) {
DynaFunc dynaFunc = (DynaFunc) operationElement;
MutableList<RelationalOperationElement> ps = ListIterate.collect(dynaFunc.parameters, relationalOperationElement -> processRelationalOperationElement(relationalOperationElement, context, aliasMap, selfJoinTargets));
return new Root_meta_relational_metamodel_DynaFunction_Impl("")._name(dynaFunc.funcName)._parameters(ps);
} else if (operationElement instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.Literal) {
org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.Literal literal = (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.Literal) operationElement;
return new Root_meta_relational_metamodel_Literal_Impl("")._value(convertLiteral(convertLiteral(literal.value)));
} else if (operationElement instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.LiteralList) {
org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.LiteralList literalList = (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.LiteralList) operationElement;
return new Root_meta_relational_metamodel_LiteralList_Impl("")._values(ListIterate.collect(literalList.values, l -> new Root_meta_relational_metamodel_Literal_Impl("")._value(convertLiteral(l.value))));
}
throw new UnsupportedOperationException();
}
use of org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Literal in project legend-pure by finos.
the class MilestoningPropertyMappingProcessor method createSQLNullLiteral.
private static Literal createSQLNullLiteral(ProcessorSupport processorSupport) {
Literal literal = (Literal) processorSupport.newEphemeralAnonymousCoreInstance(M2RelationalPaths.Literal);
SQLNull sqlNull = (SQLNull) processorSupport.newEphemeralAnonymousCoreInstance(M2RelationalPaths.SQLNull);
literal._value(sqlNull);
return literal;
}
use of org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Literal in project legend-pure by finos.
the class MilestoningPropertyMappingUnbind method unbindRelationalPropertyMappings.
private static void unbindRelationalPropertyMappings(RelationalPropertyMapping relationalPropertyMapping, ProcessorSupport processorSupport) {
RelationalOperationElement relationalOperationElement = relationalPropertyMapping._relationalOperationElement();
relationalPropertyMapping._targetSetImplementationIdRemove();
relationalPropertyMapping._sourceSetImplementationIdRemove();
relationalPropertyMapping._ownerRemove();
relationalPropertyMapping._propertyRemove();
relationalPropertyMapping._localMappingPropertyRemove();
relationalPropertyMapping._relationalOperationElementRemove();
if (relationalOperationElement instanceof Literal) {
unbindLiteral((Literal) relationalOperationElement);
} else {
unbindTableAliasColumn((TableAliasColumn) relationalOperationElement, processorSupport);
}
}
Aggregations