Search in sources :

Example 1 with BusinessMilestoning

use of org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessMilestoning in project legend-engine by finos.

the class HelperRelationalBuilder method getColumn.

private static Column getColumn(TableAlias tableAlias, String propertyName) {
    Table table = (Table) tableAlias._relationalElement();
    BusinessMilestoning businessMilestoning = table._milestoning().selectInstancesOf(BusinessMilestoning.class).getFirst();
    ProcessingMilestoning processingMilestoning = table._milestoning().selectInstancesOf(ProcessingMilestoning.class).getFirst();
    switch(propertyName) {
        case "from":
            return businessMilestoning._from();
        case "thru":
            return businessMilestoning._thru();
        case "in":
            return processingMilestoning._in();
        case "out":
            return processingMilestoning._out();
        default:
            return null;
    }
}
Also used : Table(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Table) BusinessMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessMilestoning) ProcessingMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.ProcessingMilestoning)

Example 2 with BusinessMilestoning

use of org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessMilestoning in project legend-pure by finos.

the class DatabaseProcessor method processTableMilestoning.

private static void processTableMilestoning(CoreInstance tableCoreInstance, MapIterable<String, Column> columnsByName, Matcher matcher, ProcessorState processorState, ProcessorSupport processorSupport) {
    if (tableCoreInstance instanceof Table) {
        Table table = (Table) tableCoreInstance;
        for (Milestoning milestoningInfo : table._milestoning()) {
            milestoningInfo._owner(table);
            if (milestoningInfo instanceof BusinessMilestoning) {
                BusinessMilestoning businessMilestoning = (BusinessMilestoning) milestoningInfo;
                if (processorSupport.instance_instanceOf(businessMilestoning._from(), M3Paths.String)) {
                    String businessFrom = businessMilestoning._from() == null ? "" : businessMilestoning._from().getName();
                    Column businessFromColumn = getColumn(table, columnsByName, businessFrom);
                    businessMilestoning._from(businessFromColumn);
                }
                if (processorSupport.instance_instanceOf(businessMilestoning._thru(), M3Paths.String)) {
                    String businessThru = businessMilestoning._thru() == null ? "" : businessMilestoning._thru().getName();
                    Column businessThruColumn = getColumn(table, columnsByName, businessThru);
                    businessMilestoning._thru(businessThruColumn);
                }
            } else if (milestoningInfo instanceof BusinessSnapshotMilestoning) {
                BusinessSnapshotMilestoning businessSnapshotMilestoning = (BusinessSnapshotMilestoning) milestoningInfo;
                if (processorSupport.instance_instanceOf(businessSnapshotMilestoning._snapshotDate(), M3Paths.String)) {
                    String snapshotDateColumnName = businessSnapshotMilestoning._snapshotDate().getName();
                    Column snapshotDateColumn = getColumn(table, columnsByName, snapshotDateColumnName);
                    if (!(snapshotDateColumn._type() instanceof Date)) {
                        throw new PureCompilationException(snapshotDateColumn.getSourceInformation(), "Column set as BUS_SNAPSHOT_DATE can only be of type : [Date]");
                    }
                    businessSnapshotMilestoning._snapshotDate(snapshotDateColumn);
                }
            } else if (milestoningInfo instanceof ProcessingMilestoning) {
                ProcessingMilestoning processingMilestoning = (ProcessingMilestoning) milestoningInfo;
                if (processorSupport.instance_instanceOf(processingMilestoning._in(), M3Paths.String)) {
                    String processingIn = processingMilestoning._in() == null ? "" : processingMilestoning._in().getName();
                    Column processingInColumn = getColumn(table, columnsByName, processingIn);
                    processingMilestoning._in(processingInColumn);
                }
                if (processorSupport.instance_instanceOf(processingMilestoning._out(), M3Paths.String)) {
                    String processingOut = processingMilestoning._out() == null ? "" : processingMilestoning._out().getName();
                    Column processingOutColumn = getColumn(table, columnsByName, processingOut);
                    processingMilestoning._out(processingOutColumn);
                }
            } else {
                PostProcessor.processElement(matcher, milestoningInfo, processorState, processorSupport);
                if (!milestoningInfo.hasBeenProcessed()) {
                    throw new PureCompilationException(milestoningInfo.getSourceInformation(), "Unknown milestoning type: " + PackageableElement.getUserPathForPackageableElement(milestoningInfo.getClassifier()));
                }
            }
        }
    }
}
Also used : BusinessMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessMilestoning) Milestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Milestoning) ProcessingMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.ProcessingMilestoning) BusinessSnapshotMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessSnapshotMilestoning) Table(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Table) BusinessSnapshotMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessSnapshotMilestoning) TableAliasColumn(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAliasColumn) Column(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Column) BusinessMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessMilestoning) ProcessingMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.ProcessingMilestoning) Date(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.datatype.Date) PureCompilationException(org.finos.legend.pure.m4.exception.PureCompilationException)

Example 3 with BusinessMilestoning

use of org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessMilestoning in project legend-pure by finos.

the class MilestoningPropertyMappingProcessor method getColumn.

private static Column getColumn(String milestoningPropertyName, TableAlias tableAlias) {
    Table table = (Table) tableAlias._relationalElement();
    BusinessMilestoning businessMilestoning = table._milestoning().selectInstancesOf(BusinessMilestoning.class).getFirst();
    ProcessingMilestoning processingMilestoning = table._milestoning().selectInstancesOf(ProcessingMilestoning.class).getFirst();
    switch(milestoningPropertyName) {
        case "from":
            return businessMilestoning._from();
        case "thru":
            return businessMilestoning._thru();
        case "in":
            return processingMilestoning._in();
        case "out":
            return processingMilestoning._out();
        default:
            return null;
    }
}
Also used : Table(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Table) BusinessMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessMilestoning) ProcessingMilestoning(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.ProcessingMilestoning)

Aggregations

BusinessMilestoning (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessMilestoning)3 ProcessingMilestoning (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.ProcessingMilestoning)3 Table (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Table)3 Column (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Column)1 TableAliasColumn (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAliasColumn)1 Date (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.datatype.Date)1 BusinessSnapshotMilestoning (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.BusinessSnapshotMilestoning)1 Milestoning (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Milestoning)1 PureCompilationException (org.finos.legend.pure.m4.exception.PureCompilationException)1