Search in sources :

Example 1 with ChainedCodeGeneratorTask

use of org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask in project vorto by eclipse.

the class KuraGenerator method generate.

@Override
public IGenerationResult generate(InformationModel context, InvocationContext invocationContext, IVortoCodeGenProgressMonitor monitor) throws VortoCodeGeneratorException {
    GenerationResultZip outputter = new GenerationResultZip(context, getServiceKey());
    ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new EclipseClasspathTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new EclipseProjectFileTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new ManifestTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new BuildPropertiesTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new ComponentXmlTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new IDataServiceTemplate()));
    if (invocationContext.getConfigurationProperties().getOrDefault("boschcloud", "false").equalsIgnoreCase("true")) {
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new PomTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new BoschDataServiceTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new ThingClientFactoryTemplate()));
    } else if (invocationContext.getConfigurationProperties().getOrDefault("boschhub", "false").equalsIgnoreCase("true")) {
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new PomTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new BoschHubDataService()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new BoschHubClientTemplate()));
    } else {
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new KuraCloudDataServiceTemplate()));
    }
    if (invocationContext.getConfigurationProperties().getOrDefault("bluetooth", "false").equalsIgnoreCase("true")) {
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new MetatypeTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new DeviceBluetoothFinderTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new ConfigurationTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new DeviceFilterTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new DeviceToInformationModelTransformerTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new InformationModelConsumerTemplate()));
    } else {
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new DefaultAppTemplate()));
    }
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new InformationModelTemplate()));
    for (FunctionblockProperty fbProperty : context.getProperties()) {
        new GeneratorTaskFromFileTemplate<>(new FunctionblockTemplate(context)).generate(fbProperty.getType(), invocationContext, outputter);
    }
    generator.generate(context, invocationContext, outputter);
    return outputter;
}
Also used : EclipseClasspathTemplate(org.eclipse.vorto.codegen.kura.templates.EclipseClasspathTemplate) PomTemplate(org.eclipse.vorto.codegen.kura.templates.PomTemplate) InformationModelConsumerTemplate(org.eclipse.vorto.codegen.kura.templates.bluetooth.InformationModelConsumerTemplate) ComponentXmlTemplate(org.eclipse.vorto.codegen.kura.templates.osgiinf.ComponentXmlTemplate) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) BoschHubClientTemplate(org.eclipse.vorto.codegen.kura.templates.cloud.bosch.BoschHubClientTemplate) ConfigurationTemplate(org.eclipse.vorto.codegen.kura.templates.bluetooth.ConfigurationTemplate) ManifestTemplate(org.eclipse.vorto.codegen.kura.templates.ManifestTemplate) BoschHubDataService(org.eclipse.vorto.codegen.kura.templates.cloud.bosch.BoschHubDataService) EclipseProjectFileTemplate(org.eclipse.vorto.codegen.kura.templates.EclipseProjectFileTemplate) KuraCloudDataServiceTemplate(org.eclipse.vorto.codegen.kura.templates.KuraCloudDataServiceTemplate) GeneratorTaskFromFileTemplate(org.eclipse.vorto.codegen.api.GeneratorTaskFromFileTemplate) DeviceBluetoothFinderTemplate(org.eclipse.vorto.codegen.kura.templates.bluetooth.DeviceBluetoothFinderTemplate) MetatypeTemplate(org.eclipse.vorto.codegen.kura.templates.osgiinf.MetatypeTemplate) DeviceToInformationModelTransformerTemplate(org.eclipse.vorto.codegen.kura.templates.bluetooth.DeviceToInformationModelTransformerTemplate) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) BuildPropertiesTemplate(org.eclipse.vorto.codegen.kura.templates.BuildPropertiesTemplate) GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) IDataServiceTemplate(org.eclipse.vorto.codegen.kura.templates.IDataServiceTemplate) ThingClientFactoryTemplate(org.eclipse.vorto.codegen.kura.templates.cloud.bosch.ThingClientFactoryTemplate) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) FunctionblockTemplate(org.eclipse.vorto.codegen.kura.templates.cloud.FunctionblockTemplate) BoschDataServiceTemplate(org.eclipse.vorto.codegen.kura.templates.cloud.bosch.BoschDataServiceTemplate) InformationModelTemplate(org.eclipse.vorto.codegen.kura.templates.cloud.InformationModelTemplate) DefaultAppTemplate(org.eclipse.vorto.codegen.kura.templates.DefaultAppTemplate) DeviceFilterTemplate(org.eclipse.vorto.codegen.kura.templates.bluetooth.DeviceFilterTemplate)

Example 2 with ChainedCodeGeneratorTask

use of org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask in project vorto by eclipse.

the class LatexGenerator 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>();
    generator.addTask(new LatexInformationModelGeneratorTask(LATEX_FILE_EXTENSION, LATEX_TARGET_PATH));
    generator.generate(infomodel, invocationContext, zipOutputter);
    return zipOutputter;
}
Also used : GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) LatexInformationModelGeneratorTask(org.eclipse.vorto.codegen.latex.tasks.LatexInformationModelGeneratorTask)

Example 3 with ChainedCodeGeneratorTask

use of org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask in project vorto by eclipse.

the class MQTTPlatformGenerator method generate.

@Override
public IGenerationResult generate(InformationModel context, InvocationContext invocationContext, IVortoCodeGenProgressMonitor monitor) throws VortoCodeGeneratorException {
    GenerationResultZip outputter = new GenerationResultZip(context, getServiceKey());
    for (FunctionblockProperty property : context.getProperties()) {
        ChainedCodeGeneratorTask<FunctionblockModel> generator = new ChainedCodeGeneratorTask<FunctionblockModel>();
        if (property.getType().getFunctionblock().getStatus() != null) {
            generator.addTask(new GeneratorTaskFromFileTemplate<>(new IClientHandlerTemplate()));
            generator.addTask(new GeneratorTaskFromFileTemplate<>(new MqttConfigurationTemplate()));
        }
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new PomTemplate()));
        generator.generate(property.getType(), invocationContext, outputter);
    }
    IGenerationResult javaResult = invocationContext.lookupGenerator(JavabeanGenerator.KEY).generate(context, invocationContext, monitor);
    return GenerationResultBuilder.from(outputter).append(javaResult).build();
}
Also used : PomTemplate(org.eclipse.vorto.codegen.mqtt.templates.PomTemplate) FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) IClientHandlerTemplate(org.eclipse.vorto.codegen.mqtt.templates.IClientHandlerTemplate) IGenerationResult(org.eclipse.vorto.codegen.api.IGenerationResult) MqttConfigurationTemplate(org.eclipse.vorto.codegen.mqtt.templates.MqttConfigurationTemplate) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)

Example 4 with ChainedCodeGeneratorTask

use of org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask in project vorto by eclipse.

the class ProSystGenerator method generateForFunctionBlock.

private void generateForFunctionBlock(InformationModel infomodel, InvocationContext ctx, FunctionblockModel fbm, IGeneratedWriter outputter, String[] imports) {
    ChainedCodeGeneratorTask<FunctionblockModel> generator = new ChainedCodeGeneratorTask<FunctionblockModel>();
    generator.addTask(new FunctionalItemGeneratorTask(JAVA_FILE_EXTENSION, SOURCE, fbm.getNamespace()));
    generator.addTask(new FunctionalItemImplGeneratorTask(JAVA_FILE_EXTENSION, SOURCE, fbm.getNamespace(), imports));
    generator.generate(fbm, ctx, outputter);
}
Also used : FunctionalItemImplGeneratorTask(org.eclipse.vorto.codegen.prosystfi.tasks.FunctionalItemImplGeneratorTask) FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) FunctionalItemGeneratorTask(org.eclipse.vorto.codegen.prosystfi.tasks.FunctionalItemGeneratorTask)

Example 5 with ChainedCodeGeneratorTask

use of org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask in project vorto by eclipse.

the class ProSystGenerator method generateForEnum.

private void generateForEnum(InformationModel infomodel, InvocationContext ctx, Enum en, IGeneratedWriter outputter) {
    ChainedCodeGeneratorTask<Enum> generator = new ChainedCodeGeneratorTask<Enum>();
    generator.addTask(new JavaEnumGeneratorTask(JAVA_FILE_EXTENSION, SOURCE, en.getNamespace()));
    generator.generate(en, ctx, outputter);
}
Also used : Enum(org.eclipse.vorto.core.api.model.datatype.Enum) JavaEnumGeneratorTask(org.eclipse.vorto.codegen.prosystfi.tasks.JavaEnumGeneratorTask) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask)

Aggregations

ChainedCodeGeneratorTask (org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask)16 GenerationResultZip (org.eclipse.vorto.codegen.api.GenerationResultZip)11 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)10 FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)8 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)5 IGenerationResult (org.eclipse.vorto.codegen.api.IGenerationResult)3 GenerationResultBuilder (org.eclipse.vorto.codegen.utils.GenerationResultBuilder)2 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)2 Enum (org.eclipse.vorto.core.api.model.datatype.Enum)2 HashMap (java.util.HashMap)1 DatatypeGeneratorTask (org.eclipse.vorto.codegen.api.DatatypeGeneratorTask)1 GeneratorTaskFromFileTemplate (org.eclipse.vorto.codegen.api.GeneratorTaskFromFileTemplate)1 JavaClientTask (org.eclipse.vorto.codegen.bosch.things.javaclient.JavaClientTask)1 ThingsClientGeneratorTask (org.eclipse.vorto.codegen.bosch.things.javaclient.tasks.ThingsClientGeneratorTask)1 ThingsIntegrationUtilGeneratorTask (org.eclipse.vorto.codegen.bosch.things.javaclient.tasks.ThingsIntegrationUtilGeneratorTask)1 FunctionblockTemplate (org.eclipse.vorto.codegen.bosch.things.javaclient.templates.FunctionblockTemplate)1 LogbackTemplate (org.eclipse.vorto.codegen.bosch.things.javaclient.templates.LogbackTemplate)1 PomTemplate (org.eclipse.vorto.codegen.bosch.things.javaclient.templates.PomTemplate)1 CoAPClientInformationModelGeneratorTask (org.eclipse.vorto.codegen.coap.client.tasks.CoAPClientInformationModelGeneratorTask)1 ClientDemoAppTemplate (org.eclipse.vorto.codegen.coap.client.templates.ClientDemoAppTemplate)1