Search in sources :

Example 1 with DEPRECATED_PureGrammarComposerCore

use of org.finos.legend.engine.language.pure.grammar.to.DEPRECATED_PureGrammarComposerCore in project legend-engine by finos.

the class TransformJsonToGrammar method transformJsonToGrammar.

@Deprecated
@POST
@Path("transformJsonToGrammar")
@ApiOperation(value = "Generates Pure language text from Pure protocol JSON")
@Consumes({ MediaType.APPLICATION_JSON, APPLICATION_ZLIB })
public Response transformJsonToGrammar(JsonToGrammarInput jsonInput, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> pm) {
    MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(pm);
    try (Scope scope = GlobalTracer.get().buildSpan("Service: transformJsonToGrammar").startActive(true)) {
        PureGrammarComposerExtensionLoader.logExtensionList();
        PureGrammarComposer grammarTransformer = PureGrammarComposer.newInstance(PureGrammarComposerContext.Builder.newInstance().withRenderStyle(jsonInput.renderStyle).build());
        DEPRECATED_PureGrammarComposerCore grammarTransformerVisitor = DEPRECATED_PureGrammarComposerCore.Builder.newInstance().withRenderStyle(jsonInput.renderStyle).build();
        GrammarToJsonInput symmetricResult = new GrammarToJsonInput();
        MutableMap<String, String> resMap = Maps.mutable.empty();
        if (jsonInput.isolatedLambdas != null) {
            MapIterate.toListOfPairs(jsonInput.isolatedLambdas.lambdas).collect(p -> Tuples.pair(p.getOne(), p.getTwo().accept(grammarTransformerVisitor))).forEach((Procedure<Pair<String, String>>) p -> resMap.put(p.getOne(), p.getTwo()));
        }
        symmetricResult.isolatedLambdas = resMap;
        if (jsonInput.modelDataContext != null) {
            symmetricResult.code = grammarTransformer.renderPureModelContextData(jsonInput.modelDataContext);
        }
        return ManageConstantResult.manageResult(profiles, symmetricResult);
    } catch (Exception ex) {
        return ExceptionTool.exceptionManager(ex, LoggingEventType.TRANSFORM_JSON_TO_GRAMMAR_ERROR, profiles);
    }
}
Also used : Maps(org.eclipse.collections.impl.factory.Maps) LoggingEventType(org.finos.legend.engine.shared.core.operational.logs.LoggingEventType) CommonProfile(org.pac4j.core.profile.CommonProfile) Produces(javax.ws.rs.Produces) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) PureGrammarComposer(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposer) Procedure(org.eclipse.collections.api.block.procedure.Procedure) DEPRECATED_PureGrammarComposerCore(org.finos.legend.engine.language.pure.grammar.to.DEPRECATED_PureGrammarComposerCore) MutableList(org.eclipse.collections.api.list.MutableList) ExceptionTool(org.finos.legend.engine.shared.core.operational.errorManagement.ExceptionTool) ApiOperation(io.swagger.annotations.ApiOperation) MediaType(javax.ws.rs.core.MediaType) MutableMap(org.eclipse.collections.api.map.MutableMap) Consumes(javax.ws.rs.Consumes) Tuples(org.eclipse.collections.impl.tuple.Tuples) Api(io.swagger.annotations.Api) Pair(org.eclipse.collections.api.tuple.Pair) MapIterate(org.eclipse.collections.impl.utility.MapIterate) Pac4JProfileManager(org.pac4j.jax.rs.annotations.Pac4JProfileManager) POST(javax.ws.rs.POST) GrammarToJsonInput(org.finos.legend.engine.language.pure.grammar.api.grammarToJson.GrammarToJsonInput) GlobalTracer(io.opentracing.util.GlobalTracer) ProfileManager(org.pac4j.core.profile.ProfileManager) APPLICATION_ZLIB(org.finos.legend.engine.shared.core.operational.http.InflateInterceptor.APPLICATION_ZLIB) PureGrammarComposerContext(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext) Response(javax.ws.rs.core.Response) ProfileManagerHelper(org.finos.legend.engine.shared.core.kerberos.ProfileManagerHelper) PureGrammarComposerExtensionLoader(org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtensionLoader) Scope(io.opentracing.Scope) ManageConstantResult(org.finos.legend.engine.shared.core.api.result.ManageConstantResult) Scope(io.opentracing.Scope) CommonProfile(org.pac4j.core.profile.CommonProfile) DEPRECATED_PureGrammarComposerCore(org.finos.legend.engine.language.pure.grammar.to.DEPRECATED_PureGrammarComposerCore) PureGrammarComposer(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposer) GrammarToJsonInput(org.finos.legend.engine.language.pure.grammar.api.grammarToJson.GrammarToJsonInput) Pair(org.eclipse.collections.api.tuple.Pair) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Scope (io.opentracing.Scope)1 GlobalTracer (io.opentracing.util.GlobalTracer)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1 Procedure (org.eclipse.collections.api.block.procedure.Procedure)1 MutableList (org.eclipse.collections.api.list.MutableList)1 MutableMap (org.eclipse.collections.api.map.MutableMap)1 Pair (org.eclipse.collections.api.tuple.Pair)1 Maps (org.eclipse.collections.impl.factory.Maps)1 Tuples (org.eclipse.collections.impl.tuple.Tuples)1 MapIterate (org.eclipse.collections.impl.utility.MapIterate)1 GrammarToJsonInput (org.finos.legend.engine.language.pure.grammar.api.grammarToJson.GrammarToJsonInput)1 DEPRECATED_PureGrammarComposerCore (org.finos.legend.engine.language.pure.grammar.to.DEPRECATED_PureGrammarComposerCore)1