Search in sources :

Example 1 with GenerationResultBuilder

use of org.eclipse.vorto.codegen.utils.GenerationResultBuilder in project vorto by eclipse.

the class EclipseDittoGenerator method generate.

@Override
public IGenerationResult generate(InformationModel infomodel, InvocationContext invocationContext, IVortoCodeGenProgressMonitor monitor) throws VortoCodeGeneratorException {
    GenerationResultZip zipOutputter = new GenerationResultZip(infomodel, getServiceKey());
    ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
    generator.addTask(new SchemaValidatorTask());
    generator.generate(infomodel, invocationContext, zipOutputter);
    GenerationResultBuilder result = GenerationResultBuilder.from(zipOutputter);
    return result.build();
}
Also used : GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) SchemaValidatorTask(org.eclipse.vorto.codegen.ditto.schema.SchemaValidatorTask) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) GenerationResultBuilder(org.eclipse.vorto.codegen.utils.GenerationResultBuilder)

Example 2 with GenerationResultBuilder

use of org.eclipse.vorto.codegen.utils.GenerationResultBuilder 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

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