use of org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext in project legend-sdlc by finos.
the class PureProtocolHelper method serializeForComparison.
public static String serializeForComparison(PackageableElement element) {
PureModelContextData pureModelContextData = PureModelContextData.newBuilder().withElement(element).build();
PureGrammarComposerContext composerContext = PureGrammarComposerContext.Builder.newInstance().withRenderStyle(RenderStyle.PRETTY).build();
String result = PureGrammarComposer.newInstance(composerContext).renderPureModelContextData(pureModelContextData);
if (result.startsWith("###")) {
result = result.substring(result.indexOf('\n') + 1);
}
return result;
}
use of org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext in project legend-engine by finos.
the class HelperServiceGrammarComposer method renderServiceTest.
public static String renderServiceTest(ServiceTest serviceTest, PureGrammarComposerContext context) {
int baseIndentation = 1;
if (serviceTest instanceof SingleExecutionTest) {
SingleExecutionTest singleExecutionTest = (SingleExecutionTest) serviceTest;
StringBuilder builder = new StringBuilder().append("Single\n");
appendTabString(builder, baseIndentation).append("{\n");
appendTabString(builder, baseIndentation + 1).append("data: ").append(convertString(singleExecutionTest.data, true)).append(";\n");
appendTabString(builder, baseIndentation + 1).append("asserts:\n").append(renderTestContainers(singleExecutionTest.asserts, baseIndentation + 1, context)).append("\n");
return builder.append(getTabString(baseIndentation)).append("}\n").toString();
} else if (serviceTest instanceof MultiExecutionTest) {
MultiExecutionTest multiExecutionTest = (MultiExecutionTest) serviceTest;
StringBuilder builder = new StringBuilder().append("Multi\n");
appendTabString(builder, baseIndentation).append("{\n");
builder.append(LazyIterate.collect(multiExecutionTest.tests, test -> renderKeyedSingleExecution(test, context)).makeString("\n"));
return builder.append("\n").append(getTabString(baseIndentation)).append("}\n").toString();
}
return unsupported(serviceTest.getClass());
}
use of org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext in project legend-engine by finos.
the class ServiceGrammarComposerExtension method renderService.
private static String renderService(Service service, PureGrammarComposerContext context) {
StringBuilder serviceBuilder = new StringBuilder().append("Service").append(" ").append(HelperDomainGrammarComposer.renderAnnotations(service.stereotypes, service.taggedValues)).append(PureGrammarComposerUtility.convertPath(service.getPath()));
serviceBuilder.append("\n{\n");
serviceBuilder.append(getTabString()).append("pattern: ").append(convertString(service.pattern, true)).append(";\n");
if (!service.owners.isEmpty()) {
serviceBuilder.append(getTabString()).append("owners:\n").append(getTabString()).append("[\n").append(LazyIterate.collect(service.owners, o -> getTabString(2) + convertString(o, true)).makeString(",\n")).append("\n").append(getTabString()).append("];\n");
}
serviceBuilder.append(getTabString()).append("documentation: ").append(convertString(service.documentation, true)).append(";\n");
serviceBuilder.append(getTabString()).append("autoActivateUpdates: ").append(service.autoActivateUpdates ? "true" : "false").append(";\n");
Execution execution = service.execution;
if (execution instanceof PureExecution) {
serviceBuilder.append(getTabString()).append("execution: ").append(HelperServiceGrammarComposer.renderServiceExecution(execution, context));
} else {
serviceBuilder.append(getTabString()).append(unsupported(execution.getClass(), "service execution type"));
}
serviceBuilder.append(getTabString()).append("test: ");
serviceBuilder.append(HelperServiceGrammarComposer.renderServiceTest(service.test, context));
return serviceBuilder.append("}").toString();
}
Aggregations