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);
}
}
Aggregations