Search in sources :

Example 1 with Profile

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile in project legend-engine by finos.

the class DomainParseTreeWalker method visitProfile.

// ----------------------------------------------- PROFILE -----------------------------------------------
private Profile visitProfile(DomainParserGrammar.ProfileContext ctx) {
    Profile profile = new Profile();
    profile.name = PureGrammarParserUtility.fromIdentifier(ctx.qualifiedName().identifier());
    profile._package = ctx.qualifiedName().packagePath() == null ? "" : PureGrammarParserUtility.fromPath(ctx.qualifiedName().packagePath().identifier());
    profile.stereotypes = ctx.stereotypeDefinitions() == null ? Lists.mutable.empty() : ListIterate.collect(ctx.stereotypeDefinitions().identifier(), PureGrammarParserUtility::fromIdentifier);
    profile.tags = ctx.tagDefinitions() == null ? Lists.mutable.empty() : ListIterate.collect(ctx.tagDefinitions().identifier(), PureGrammarParserUtility::fromIdentifier);
    profile.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    return profile;
}
Also used : PureGrammarParserUtility(org.finos.legend.engine.language.pure.grammar.from.PureGrammarParserUtility) Profile(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile)

Example 2 with Profile

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile in project legend-engine by finos.

the class QueryStoreManager method documentToQuery.

private static Query documentToQuery(Document document) {
    Query query = new Query();
    query.id = document.getString("id");
    query.name = document.getString("name");
    query.description = document.getString("description");
    query.groupId = document.getString("groupId");
    query.artifactId = document.getString("artifactId");
    query.versionId = document.getString("versionId");
    query.mapping = document.getString("mapping");
    query.runtime = document.getString("runtime");
    query.content = document.getString("content");
    query.owner = document.getString("owner");
    if (document.get("taggedValues") != null) {
        query.taggedValues = ListIterate.collect(document.getList("taggedValues", Document.class), _doc -> {
            TaggedValue taggedValue = new TaggedValue();
            taggedValue.tag = new TagPtr();
            taggedValue.tag.profile = _doc.getEmbedded(Lists.fixedSize.of("tag", "profile"), String.class);
            taggedValue.tag.value = _doc.getEmbedded(Lists.fixedSize.of("tag", "value"), String.class);
            taggedValue.value = _doc.getString("value");
            return taggedValue;
        });
    }
    if (document.get("stereotypes") != null) {
        query.stereotypes = ListIterate.collect(document.getList("stereotypes", Document.class), _doc -> {
            StereotypePtr stereotypePtr = new StereotypePtr();
            stereotypePtr.profile = _doc.getString("profile");
            stereotypePtr.value = _doc.getString("value");
            return stereotypePtr;
        });
    }
    return query;
}
Also used : Document(org.bson.Document) MongoClient(com.mongodb.client.MongoClient) MongoCollection(com.mongodb.client.MongoCollection) Projections(com.mongodb.client.model.Projections) Lists(org.eclipse.collections.api.factory.Lists) TaggedValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TaggedValue) QuerySearchSpecification(org.finos.legend.engine.application.query.model.QuerySearchSpecification) MongoDatabase(com.mongodb.client.MongoDatabase) Vault(org.finos.legend.engine.shared.core.vault.Vault) ArrayList(java.util.ArrayList) Filters(com.mongodb.client.model.Filters) Bson(org.bson.conversions.Bson) TagPtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TagPtr) Query(org.finos.legend.engine.application.query.model.Query) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ListIterate(org.eclipse.collections.impl.utility.ListIterate) Instant(java.time.Instant) SourceVersion(javax.lang.model.SourceVersion) QueryEvent(org.finos.legend.engine.application.query.model.QueryEvent) List(java.util.List) LazyIterate(org.eclipse.collections.impl.utility.LazyIterate) Response(javax.ws.rs.core.Response) Pattern(java.util.regex.Pattern) StereotypePtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.StereotypePtr) Query(org.finos.legend.engine.application.query.model.Query) TaggedValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TaggedValue) TagPtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TagPtr) StereotypePtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.StereotypePtr)

Example 3 with Profile

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile in project legend-engine by finos.

the class TestQueryStoreManager method createTestTaggedValue.

private static TaggedValue createTestTaggedValue(String profile, String tag, String value) {
    TaggedValue taggedValue = new TaggedValue();
    taggedValue.tag = new TagPtr();
    taggedValue.tag.profile = profile;
    taggedValue.tag.value = tag;
    taggedValue.value = value;
    return taggedValue;
}
Also used : TaggedValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TaggedValue) TagPtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TagPtr)

Example 4 with Profile

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile in project legend-engine by finos.

the class TestQueryStoreManager method createTestStereotype.

private static StereotypePtr createTestStereotype(String profile, String stereotype) {
    StereotypePtr taggedValue = new StereotypePtr();
    taggedValue.profile = profile;
    taggedValue.value = stereotype;
    return taggedValue;
}
Also used : StereotypePtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.StereotypePtr)

Example 5 with Profile

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile in project legend-engine by finos.

the class PureModelContextDataGenerator method generatePureModelContextDataFromProfile.

public static PureModelContextData generatePureModelContextDataFromProfile(RichIterable<org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile> pureProfiles, String pureVersion, CompiledExecutionSupport compiledExecutionSupport) throws RuntimeException {
    Method transformMethod = profileTransforms.getIfAbsentPut(pureVersion, () -> {
        try {
            if ("vX_X_X".equals(pureVersion) || PureClientVersions.versionAGreaterThanOrEqualsVersionB(pureVersion, "v1_18_0")) {
                return java.lang.Class.forName("org.finos.legend.pure.generated.core_pure_protocol_" + pureVersion + "_transfers_metamodel").getMethod("Root_meta_protocols_pure_" + pureVersion + "_transformation_fromPureGraph_transformProfile_Profile_1__RouterExtension_MANY__Profile_1_", org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile.class, RichIterable.class, ExecutionSupport.class);
            } else {
                return loadTransClass(pureVersion).getMethod("Root_meta_protocols_pure_" + pureVersion + "_transformation_fromPureGraph_transformProfile_Profile_1__RouterExtension_MANY__Profile_1_", org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile.class, ExecutionSupport.class);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    PureModelContextData.Builder builder = PureModelContextData.newBuilder();
    pureProfiles.forEach(f -> {
        try {
            Object profile;
            if ("vX_X_X".equals(pureVersion) || PureClientVersions.versionAGreaterThanOrEqualsVersionB(pureVersion, "v1_18_0")) {
                profile = transformMethod.invoke(null, f, core_pure_extensions_extension.Root_meta_pure_router_extension_defaultExtensions__RouterExtension_MANY_(compiledExecutionSupport), compiledExecutionSupport);
            } else {
                profile = transformMethod.invoke(null, f, compiledExecutionSupport);
            }
            org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile p = objectMapper.readValue(org.finos.legend.pure.generated.core_pure_protocol_protocol.Root_meta_alloy_metadataServer_alloyToJSON_Any_1__String_1_(profile, compiledExecutionSupport), org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile.class);
            builder.addElement(p);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    return builder.build();
}
Also used : org.finos.legend.pure.generated.core_pure_extensions_extension(org.finos.legend.pure.generated.core_pure_extensions_extension) Method(java.lang.reflect.Method) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData)

Aggregations

StereotypePtr (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.StereotypePtr)2 TagPtr (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TagPtr)2 TaggedValue (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TaggedValue)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 MongoClient (com.mongodb.client.MongoClient)1 MongoCollection (com.mongodb.client.MongoCollection)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 Filters (com.mongodb.client.model.Filters)1 Projections (com.mongodb.client.model.Projections)1 Method (java.lang.reflect.Method)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Pattern (java.util.regex.Pattern)1 SourceVersion (javax.lang.model.SourceVersion)1 Response (javax.ws.rs.core.Response)1 Document (org.bson.Document)1 Bson (org.bson.conversions.Bson)1 Lists (org.eclipse.collections.api.factory.Lists)1