Search in sources :

Example 1 with PureGrammarComposerContext

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;
}
Also used : PureGrammarComposerContext(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData)

Example 2 with PureGrammarComposerContext

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());
}
Also used : PureGrammarComposerUtility.convertString(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.convertString) KeyedExecutionParameter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedExecutionParameter) KeyedSingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedSingleExecutionTest) MultiExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.MultiExecutionTest) DEPRECATED_PureGrammarComposerCore(org.finos.legend.engine.language.pure.grammar.to.DEPRECATED_PureGrammarComposerCore) HelperRuntimeGrammarComposer(org.finos.legend.engine.language.pure.grammar.to.HelperRuntimeGrammarComposer) Runtime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.Runtime) PureGrammarComposerUtility.unsupported(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.unsupported) RuntimePointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.RuntimePointer) EngineRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime) ServiceTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.ServiceTest) List(java.util.List) PureMultiExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureMultiExecution) LazyIterate(org.eclipse.collections.impl.utility.LazyIterate) PureGrammarComposerContext(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext) PureSingleExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest) PureGrammarComposerUtility.getTabString(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.getTabString) TestContainer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.TestContainer) LegacyRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime) PureGrammarComposerUtility.appendTabString(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.appendTabString) Execution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution) MultiExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.MultiExecutionTest) KeyedSingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedSingleExecutionTest) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest)

Example 3 with PureGrammarComposerContext

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();
}
Also used : PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) ServiceParserExtension(org.finos.legend.engine.language.pure.dsl.service.grammar.from.ServiceParserExtension) HelperDomainGrammarComposer(org.finos.legend.engine.language.pure.grammar.to.HelperDomainGrammarComposer) ListIterate(org.eclipse.collections.impl.utility.ListIterate) PureGrammarComposerUtility(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility) Function3(org.eclipse.collections.api.block.function.Function3) PureGrammarComposerExtension(org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension) List(java.util.List) LazyIterate(org.eclipse.collections.impl.utility.LazyIterate) PureGrammarComposerContext(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext) Lists(org.eclipse.collections.impl.factory.Lists) Service(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Service) PureExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureExecution) Execution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution) PureExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureExecution) Execution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution) PureExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureExecution)

Aggregations

PureGrammarComposerContext (org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext)3 List (java.util.List)2 LazyIterate (org.eclipse.collections.impl.utility.LazyIterate)2 Execution (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution)2 Function3 (org.eclipse.collections.api.block.function.Function3)1 Lists (org.eclipse.collections.impl.factory.Lists)1 ListIterate (org.eclipse.collections.impl.utility.ListIterate)1 ServiceParserExtension (org.finos.legend.engine.language.pure.dsl.service.grammar.from.ServiceParserExtension)1 DEPRECATED_PureGrammarComposerCore (org.finos.legend.engine.language.pure.grammar.to.DEPRECATED_PureGrammarComposerCore)1 HelperDomainGrammarComposer (org.finos.legend.engine.language.pure.grammar.to.HelperDomainGrammarComposer)1 HelperRuntimeGrammarComposer (org.finos.legend.engine.language.pure.grammar.to.HelperRuntimeGrammarComposer)1 PureGrammarComposerUtility (org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility)1 PureGrammarComposerUtility.appendTabString (org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.appendTabString)1 PureGrammarComposerUtility.convertString (org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.convertString)1 PureGrammarComposerUtility.getTabString (org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.getTabString)1 PureGrammarComposerUtility.unsupported (org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.unsupported)1 PureGrammarComposerExtension (org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension)1 PureModelContextData (org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData)1 PackageableElement (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement)1 EngineRuntime (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime)1