Search in sources :

Example 1 with ChainedCodeGeneratorTask

use of org.eclipse.vorto.plugin.generator.utils.ChainedCodeGeneratorTask in project vorto by eclipse.

the class EclipseDittoGenerator method generate.

@Override
public IGenerationResult generate(InformationModel infomodel, InvocationContext invocationContext) {
    String target = invocationContext.getConfigurationProperties().getOrDefault("target", "");
    if (THING_JSON.equalsIgnoreCase(target)) {
        SingleGenerationResult output = new SingleGenerationResult("application/json");
        new GeneratorTaskFromFileTemplate<>(DITTO_THING_JSON_TEMPLATE).generate(infomodel, invocationContext, output);
        return output;
    }
    if (JSON_SCHEMA.equalsIgnoreCase(target)) {
        GenerationResultZip zipOutput = new GenerationResultZip(infomodel, GENERATOR_KEY);
        ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<>();
        generator.addTask(new SchemaValidatorTask());
        generator.generate(infomodel, invocationContext, zipOutput);
        GenerationResultBuilder result = GenerationResultBuilder.from(zipOutput);
        return result.build();
    }
    throw new IllegalArgumentException("The request parameter 'target' is required. It must have one of the values ('jsonSchema', " + "'thingJson')");
}
Also used : GenerationResultZip(org.eclipse.vorto.plugin.generator.utils.GenerationResultZip) SchemaValidatorTask(org.eclipse.vorto.codegen.ditto.schema.SchemaValidatorTask) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ChainedCodeGeneratorTask(org.eclipse.vorto.plugin.generator.utils.ChainedCodeGeneratorTask) GenerationResultBuilder(org.eclipse.vorto.plugin.generator.utils.GenerationResultBuilder) SingleGenerationResult(org.eclipse.vorto.plugin.generator.utils.SingleGenerationResult)

Aggregations

SchemaValidatorTask (org.eclipse.vorto.codegen.ditto.schema.SchemaValidatorTask)1 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)1 ChainedCodeGeneratorTask (org.eclipse.vorto.plugin.generator.utils.ChainedCodeGeneratorTask)1 GenerationResultBuilder (org.eclipse.vorto.plugin.generator.utils.GenerationResultBuilder)1 GenerationResultZip (org.eclipse.vorto.plugin.generator.utils.GenerationResultZip)1 SingleGenerationResult (org.eclipse.vorto.plugin.generator.utils.SingleGenerationResult)1