Search in sources :

Example 1 with ImportStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub in project legend-pure by finos.

the class MilestoningFunctions method isGeneratedMilestoningProperty.

public static boolean isGeneratedMilestoningProperty(CoreInstance property, ProcessorSupport processorSupport, String stereotype, String milestoningPathSuffix) {
    if (property instanceof ElementWithStereotypes) {
        RichIterable<? extends CoreInstance> stereotypes = ((ElementWithStereotypes) property)._stereotypesCoreInstance();
        if (stereotypes.notEmpty()) {
            CoreInstance profile = processorSupport.package_getByUserPath(M3Paths.Milestoning);
            CoreInstance milestoningStereotype = Profile.findStereotype(profile, stereotype);
            return stereotypes.anySatisfy(st -> (st instanceof ImportStub) ? ((ImportStub) st)._idOrPath().endsWith(milestoningPathSuffix) : milestoningStereotype.equals(st));
        }
    }
    return false;
}
Also used : ElementWithStereotypes(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.ElementWithStereotypes) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) ImportStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub)

Example 2 with ImportStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub in project legend-pure by finos.

the class NavigationGraphBuilder method visitEnumStub.

@Override
public CoreInstance visitEnumStub(EnumStubContext ctx) {
    Token type = ctx.VALID_STRING(0).getSymbol();
    Token enumValue = ctx.VALID_STRING(1).getSymbol();
    ImportStub importStub = ImportStubInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(type), type.getText(), this.importId);
    return EnumStubInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(type), enumValue.getText(), importStub);
}
Also used : Token(org.antlr.v4.runtime.Token) ImportStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub)

Example 3 with ImportStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub in project legend-pure by finos.

the class RootGraphFetchTreeUnbind method unbindPropertyGraphFetchTree.

private void unbindPropertyGraphFetchTree(PropertyGraphFetchTree propertyGraphFetchTree, RootGraphFetchTree mainTree, MatcherState state, Matcher matcher) {
    ProcessorSupport processorSupport = state.getProcessorSupport();
    PropertyStub property = (PropertyStub) propertyGraphFetchTree._propertyCoreInstance();
    CoreInstance resolved = property._resolvedPropertyCoreInstance();
    if (resolved != null) {
        ReferenceUsage.removeReferenceUsagesForUser(resolved, mainTree, state.getProcessorSupport());
    }
    Shared.cleanPropertyStub(property, processorSupport);
    property._ownerRemove();
    for (ValueSpecification vs : propertyGraphFetchTree._parameters()) {
        if (vs instanceof InstanceValue) {
            for (CoreInstance value : ((InstanceValue) vs)._valuesCoreInstance()) {
                Shared.cleanEnumStub(value, processorSupport);
            }
            vs._genericTypeRemove();
            vs._multiplicityRemove();
        }
        matcher.fullMatch(vs, state);
    }
    for (GraphFetchTree subTree : propertyGraphFetchTree._subTrees()) {
        this.unbindPropertyGraphFetchTree((PropertyGraphFetchTree) subTree, mainTree, state, matcher);
    }
    ImportStub subTypeClass = (ImportStub) propertyGraphFetchTree._subTypeCoreInstance();
    if (subTypeClass != null) {
        CoreInstance resolvedSubTypeClass = subTypeClass._resolvedNodeCoreInstance();
        if (resolvedSubTypeClass != null) {
            ReferenceUsage.removeReferenceUsagesForUser(resolvedSubTypeClass, mainTree, state.getProcessorSupport());
        }
        Shared.cleanImportStub(subTypeClass, processorSupport);
    }
    propertyGraphFetchTree._classifierGenericTypeRemove();
}
Also used : PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) RootGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree) GraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree) PropertyGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) ImportStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub)

Example 4 with ImportStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub in project legend-pure by finos.

the class DatabaseUnloadUnbind method processTableAliasColumn.

private static void processTableAliasColumn(TableAliasColumn tableAliasColumn, TableAlias joinTarget, ProcessorSupport processorSupport) throws PureCompilationException {
    TableAlias tableAlias = tableAliasColumn._alias();
    if ((joinTarget != null) && (tableAlias == joinTarget)) {
        // Replace the join target with a {target} alias
        ModelRepository repository = tableAliasColumn.getRepository();
        TableAlias targetAlias = (TableAlias) repository.newAnonymousCoreInstance(tableAliasColumn.getSourceInformation(), joinTarget.getClassifier());
        targetAlias._name(DatabaseProcessor.SELF_JOIN_TABLE_NAME);
        tableAliasColumn._alias(targetAlias);
    } else {
        tableAlias._relationalElementRemove();
        ImportStub tableAliasDatabase = (ImportStub) tableAlias._databaseCoreInstance();
        if (tableAliasDatabase != null) {
            Shared.cleanImportStub(tableAliasDatabase, processorSupport);
        }
    }
    tableAliasColumn._columnRemove();
}
Also used : ModelRepository(org.finos.legend.pure.m4.ModelRepository) TableAlias(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias) ImportStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub)

Example 5 with ImportStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub in project legend-pure by finos.

the class RelationalAssociationImplementationUnbind method run.

@Override
public void run(RelationalAssociationImplementation instance, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
    ProcessorSupport processorSupport = state.getProcessorSupport();
    ImportStub mappingImportStub = (ImportStub) instance._parentCoreInstance();
    RelationalPropertyMappingUnbind.cleanPropertyMappings(instance, modelRepository, processorSupport, mappingImportStub);
}
Also used : ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) ImportStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub)

Aggregations

ImportStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub)17 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)9 ProcessorSupport (org.finos.legend.pure.m3.navigation.ProcessorSupport)5 Token (org.antlr.v4.runtime.Token)3 ImportStubInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStubInstance)3 TaggedValue (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.TaggedValue)3 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)3 GenericTypeInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericTypeInstance)3 ValueSpecification (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)3 TableAlias (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias)3 M3ProcessorSupport (org.finos.legend.pure.m3.navigation.M3ProcessorSupport)3 PrimitiveCoreInstance (org.finos.legend.pure.m4.coreinstance.primitive.PrimitiveCoreInstance)3 RuleContext (org.antlr.v4.runtime.RuleContext)2 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)2 RichIterable (org.eclipse.collections.api.RichIterable)2 Lists (org.eclipse.collections.api.factory.Lists)2 PackageInstance (org.finos.legend.pure.m3.coreinstance.PackageInstance)2 PropertyStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub)2 LambdaFunction (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction)2 Property (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property)2