Search in sources :

Example 1 with JavaClientTask

use of org.eclipse.vorto.codegen.bosch.things.javaclient.JavaClientTask in project vorto by eclipse.

the class BoschIoTThingsGenerator method generate.

public IGenerationResult generate(InformationModel infomodel, InvocationContext invocationContext, IVortoCodeGenProgressMonitor monitor) throws VortoCodeGeneratorException {
    GenerationResultZip zipOutputter = new GenerationResultZip(infomodel, getServiceKey());
    ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
    GenerationResultBuilder result = GenerationResultBuilder.from(zipOutputter);
    if (hasNoTarget(invocationContext)) {
        result.append(generateSchema(infomodel, monitor, invocationContext));
    } else {
        if (invocationContext.getConfigurationProperties().getOrDefault(SIMULATOR, FALSE).equalsIgnoreCase(TRUE)) {
            generator.addTask(new JavaClientTask());
        }
        if (invocationContext.getConfigurationProperties().getOrDefault(SCHEMAVALIDATOR, FALSE).equalsIgnoreCase(TRUE)) {
            result.append(generateSchema(infomodel, monitor, invocationContext));
        }
    }
    generator.generate(infomodel, invocationContext, zipOutputter);
    if (invocationContext.getConfigurationProperties().getOrDefault("kura", FALSE).equalsIgnoreCase(TRUE)) {
        Map<String, String> props = new HashMap<>();
        props.put("boschcloud", "true");
        props.put("bluetooth", "true");
        IGenerationResult kuraResult = invocationContext.lookupGenerator("kura").generate(infomodel, InvocationContext.simpleInvocationContext(props), monitor);
        result.append(kuraResult);
    }
    if (invocationContext.getConfigurationProperties().getOrDefault("alexa", FALSE).equalsIgnoreCase(TRUE)) {
        Map<String, String> props = new HashMap<>();
        props.put("cloud", "bosch");
        props.put("thingId", invocationContext.getConfigurationProperties().getOrDefault("thingId", ""));
        IGenerationResult awsResult = invocationContext.lookupGenerator("aws").generate(infomodel, InvocationContext.simpleInvocationContext(props), monitor);
        result.append(awsResult);
    }
    if (invocationContext.getConfigurationProperties().getOrDefault("webui", FALSE).equalsIgnoreCase(TRUE)) {
        Map<String, String> props = new HashMap<>();
        props.put("boschcloud", "true");
        props.put("swagger", "true");
        props.put("persistence", "true");
        IGenerationResult webuiResult = invocationContext.lookupGenerator("webui").generate(infomodel, InvocationContext.simpleInvocationContext(props), monitor);
        result.append(webuiResult);
    }
    return result.build();
}
Also used : JavaClientTask(org.eclipse.vorto.codegen.bosch.things.javaclient.JavaClientTask) GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) HashMap(java.util.HashMap) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) IGenerationResult(org.eclipse.vorto.codegen.api.IGenerationResult) GenerationResultBuilder(org.eclipse.vorto.codegen.utils.GenerationResultBuilder)

Aggregations

HashMap (java.util.HashMap)1 ChainedCodeGeneratorTask (org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask)1 GenerationResultZip (org.eclipse.vorto.codegen.api.GenerationResultZip)1 IGenerationResult (org.eclipse.vorto.codegen.api.IGenerationResult)1 JavaClientTask (org.eclipse.vorto.codegen.bosch.things.javaclient.JavaClientTask)1 GenerationResultBuilder (org.eclipse.vorto.codegen.utils.GenerationResultBuilder)1 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)1