Search in sources :

Example 6 with IGenerationResult

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

the class WebDeviceGenerator 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>();
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new ServiceClassTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<>(new PageTemplate()));
        generator.generate(property.getType(), invocationContext, outputter);
    }
    ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new WebSocketConfigTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new PomFileTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new IndexHtmlFileTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new DeviceInfoTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new DeviceInfoServiceTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new ControllersScriptFileTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new AppScriptFileTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new ApplicationMainTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new CssTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new ApplicationYmlTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new ReadmeTemplate()));
    generator.generate(context, invocationContext, outputter);
    IGenerationResult javaResult = invocationContext.lookupGenerator(JavabeanGenerator.KEY).generate(context, invocationContext, monitor);
    return GenerationResultBuilder.from(outputter).append(javaResult).build();
}
Also used : GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) PageTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.PageTemplate) ControllersScriptFileTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.ControllersScriptFileTemplate) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) DeviceInfoServiceTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.DeviceInfoServiceTemplate) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) ServiceClassTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.ServiceClassTemplate) IGenerationResult(org.eclipse.vorto.codegen.api.IGenerationResult) IndexHtmlFileTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.IndexHtmlFileTemplate) FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) PomFileTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.PomFileTemplate) ReadmeTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.ReadmeTemplate) AppScriptFileTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.AppScriptFileTemplate) ApplicationMainTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.ApplicationMainTemplate) CssTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.CssTemplate) WebSocketConfigTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.WebSocketConfigTemplate) DeviceInfoTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.DeviceInfoTemplate) ApplicationYmlTemplate(org.eclipse.vorto.codegen.webdevice.tasks.templates.ApplicationYmlTemplate) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)

Aggregations

IGenerationResult (org.eclipse.vorto.codegen.api.IGenerationResult)6 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)5 GenerationResultZip (org.eclipse.vorto.codegen.api.GenerationResultZip)4 HashMap (java.util.HashMap)3 ChainedCodeGeneratorTask (org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask)3 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 ZipInputStream (java.util.zip.ZipInputStream)2 Generated (org.eclipse.vorto.codegen.api.Generated)2 IVortoCodeGenerator (org.eclipse.vorto.codegen.api.IVortoCodeGenerator)2 MappingModel (org.eclipse.vorto.core.api.model.mapping.MappingModel)2 Model (org.eclipse.vorto.core.api.model.model.Model)2 IModelWorkspace (org.eclipse.vorto.server.commons.reader.IModelWorkspace)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1