use of org.eclipse.vorto.plugin.generator.utils.GenerationResultZip 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;
}
use of org.eclipse.vorto.plugin.generator.utils.GenerationResultZip 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')");
}
use of org.eclipse.vorto.plugin.generator.utils.GenerationResultZip in project vorto by eclipse.
the class EclipseHonoGenerator method generate.
@Override
public IGenerationResult generate(InformationModel model, InvocationContext context) throws GeneratorException {
GenerationResultZip output = new GenerationResultZip(model, "eclipsehono");
GenerationResultBuilder result = GenerationResultBuilder.from(output);
String platform = context.getConfigurationProperties().getOrDefault(KEY_LANGUAGE, "java");
if (platform.equalsIgnoreCase("arduino")) {
result.append(generateArduino(model, context));
} else if (platform.equalsIgnoreCase("python")) {
result.append(generatePython(model, context));
} else {
result.append(generateJava(model, context));
}
return output;
}
Aggregations