Search in sources :

Example 1 with ProvisionDeviceScriptTemplate

use of org.eclipse.vorto.codegen.bosch.templates.ProvisionDeviceScriptTemplate in project vorto by eclipse.

the class BoschIoTSuiteGenerator method generate.

@Override
public IGenerationResult generate(InformationModel infomodel, InvocationContext invocationContext) throws GeneratorException {
    GenerationResultZip output = new GenerationResultZip(infomodel, KEY);
    GenerationResultBuilder result = GenerationResultBuilder.from(output);
    String platform = invocationContext.getConfigurationProperties().getOrDefault(KEY_LANGUAGE, "");
    if (platform.equalsIgnoreCase("arduino")) {
        result.append(generateArduino(infomodel, invocationContext));
    } else if (platform.equalsIgnoreCase("python")) {
        result.append(generatePython(infomodel, invocationContext));
    } else if (platform.equalsIgnoreCase("java")) {
        result.append(generateJava(infomodel, invocationContext));
    } else if (invocationContext.getConfigurationProperties().getOrDefault(KEY_PROVISION, "false").equals("true")) {
        SingleGenerationResult singleOutput = new SingleGenerationResult("application/json");
        if (invocationContext.getConfigurationProperties().getOrDefault(KEY_BODY_TEMPLATE, "false").equals("true")) {
            new GeneratorTaskFromFileTemplate<>(REQUEST_TEMPLATE).generate(infomodel, invocationContext, singleOutput);
        } else {
            new GeneratorTaskFromFileTemplate<>(new ProvisionDeviceScriptTemplate(REQUEST_TEMPLATE)).generate(infomodel, invocationContext, singleOutput);
        }
        return singleOutput;
    }
    return output;
}
Also used : GenerationResultZip(org.eclipse.vorto.plugin.generator.utils.GenerationResultZip) GeneratorTaskFromFileTemplate(org.eclipse.vorto.plugin.generator.utils.GeneratorTaskFromFileTemplate) GenerationResultBuilder(org.eclipse.vorto.plugin.generator.utils.GenerationResultBuilder) ProvisionDeviceScriptTemplate(org.eclipse.vorto.codegen.bosch.templates.ProvisionDeviceScriptTemplate) SingleGenerationResult(org.eclipse.vorto.plugin.generator.utils.SingleGenerationResult)

Aggregations

ProvisionDeviceScriptTemplate (org.eclipse.vorto.codegen.bosch.templates.ProvisionDeviceScriptTemplate)1 GenerationResultBuilder (org.eclipse.vorto.plugin.generator.utils.GenerationResultBuilder)1 GenerationResultZip (org.eclipse.vorto.plugin.generator.utils.GenerationResultZip)1 GeneratorTaskFromFileTemplate (org.eclipse.vorto.plugin.generator.utils.GeneratorTaskFromFileTemplate)1 SingleGenerationResult (org.eclipse.vorto.plugin.generator.utils.SingleGenerationResult)1