Search in sources :

Example 16 with InformationModel

use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.

the class IOSPlatformGenerator 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 DatatypeGeneratorTask(new EntityClassTemplate(), new EnumClassTemplate()));
    IMapped<InformationModel> mappedElement = invocationContext.getMappedElement(context, "binding");
    if (mappedElement.hasAttribute("ble")) {
        generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new CoreBluetoothDetectionTemplate()));
        generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new DeviceServiceTemplate()));
    }
    generator.generate(context, invocationContext, outputter);
    return outputter;
}
Also used : EnumClassTemplate(org.eclipse.vorto.codegen.ios.templates.EnumClassTemplate) EntityClassTemplate(org.eclipse.vorto.codegen.ios.templates.EntityClassTemplate) GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) DeviceServiceTemplate(org.eclipse.vorto.codegen.ios.templates.DeviceServiceTemplate) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) CoreBluetoothDetectionTemplate(org.eclipse.vorto.codegen.ios.templates.CoreBluetoothDetectionTemplate) DatatypeGeneratorTask(org.eclipse.vorto.codegen.api.DatatypeGeneratorTask)

Example 17 with InformationModel

use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.

the class JavabeanGenerator method generate.

public IGenerationResult generate(InformationModel infomodel, InvocationContext invocationContext, IVortoCodeGenProgressMonitor monitor) throws VortoCodeGeneratorException {
    GenerationResultZip zipOutputter = new GenerationResultZip(infomodel, getServiceKey());
    for (FunctionblockProperty fbp : infomodel.getProperties()) {
        this.generateForFunctionBlock(infomodel, fbp.getType(), zipOutputter);
        FunctionBlock fb = fbp.getType().getFunctionblock();
        for (Entity entity : Utils.getReferencedEntities(fb)) {
            generateForEntity(infomodel, entity, zipOutputter);
        }
        for (Enum en : Utils.getReferencedEnums(fb)) {
            generateForEnum(infomodel, en, zipOutputter);
        }
    }
    new GeneratorTaskFromFileTemplate<InformationModel>(new PomFileTemplate()).generate(infomodel, invocationContext, zipOutputter);
    return zipOutputter;
}
Also used : Enum(org.eclipse.vorto.core.api.model.datatype.Enum) Entity(org.eclipse.vorto.core.api.model.datatype.Entity) PomFileTemplate(org.eclipse.vorto.codegen.javabean.tasks.template.PomFileTemplate) GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) FunctionBlock(org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)

Example 18 with InformationModel

use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel 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)

Example 19 with InformationModel

use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.

the class JavaClientTask method generate.

@Override
public void generate(InformationModel element, InvocationContext context, IGeneratedWriter writer) {
    ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new PomTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<>(new LogbackTemplate()));
    generator.addTask(new ThingsClientGeneratorTask());
    generator.addTask(new ThingsIntegrationUtilGeneratorTask());
    generator.generate(element, context, writer);
    for (FunctionblockProperty fbProperty : element.getProperties()) {
        if (context.getConfigurationProperties().getOrDefault(CONFIG_PARAM_SKIP_CLIENT, "false").equalsIgnoreCase("false")) {
            new GeneratorTaskFromFileTemplate<>(new FunctionblockTemplate()).generate(fbProperty.getType(), context, writer);
        }
    }
}
Also used : PomTemplate(org.eclipse.vorto.codegen.bosch.things.javaclient.templates.PomTemplate) LogbackTemplate(org.eclipse.vorto.codegen.bosch.things.javaclient.templates.LogbackTemplate) ThingsClientGeneratorTask(org.eclipse.vorto.codegen.bosch.things.javaclient.tasks.ThingsClientGeneratorTask) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) ThingsIntegrationUtilGeneratorTask(org.eclipse.vorto.codegen.bosch.things.javaclient.tasks.ThingsIntegrationUtilGeneratorTask) FunctionblockTemplate(org.eclipse.vorto.codegen.bosch.things.javaclient.templates.FunctionblockTemplate)

Example 20 with InformationModel

use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.

the class TestInfoModelFactory method createInformationModel.

public static InformationModel createInformationModel() {
    InformationModel informationModel = InformationModelFactory.eINSTANCE.createInformationModel();
    informationModel.setName("LightingDevice");
    informationModel.setDescription("Lighting Device");
    informationModel.setCategory("demo");
    informationModel.setDescription("comment");
    informationModel.setNamespace("www.bosch.com");
    informationModel.setVersion("1.2.3");
    informationModel.getProperties().add(createFunctionblockProperty(TestFunctionBlockFactory.createFunctionBlockModel()));
    return informationModel;
}
Also used : InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel)

Aggregations

InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)24 GenerationResultZip (org.eclipse.vorto.codegen.api.GenerationResultZip)13 ChainedCodeGeneratorTask (org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask)10 FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)8 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)7 IGenerationResult (org.eclipse.vorto.codegen.api.IGenerationResult)6 MappingModel (org.eclipse.vorto.core.api.model.mapping.MappingModel)6 Model (org.eclipse.vorto.core.api.model.model.Model)6 ZipInputStream (java.util.zip.ZipInputStream)5 IModelWorkspace (org.eclipse.vorto.server.commons.reader.IModelWorkspace)5 IVortoCodeGenerator (org.eclipse.vorto.codegen.api.IVortoCodeGenerator)4 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 HashMap (java.util.HashMap)3 Collectors (java.util.stream.Collectors)3 Generated (org.eclipse.vorto.codegen.api.Generated)3 InvocationContext (org.eclipse.vorto.codegen.api.InvocationContext)3 IOException (java.io.IOException)2 List (java.util.List)2 GeneratorTaskFromFileTemplate (org.eclipse.vorto.codegen.api.GeneratorTaskFromFileTemplate)2