Search in sources :

Example 6 with ChainedCodeGeneratorTask

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

the class CoAPGenerator method generate.

public IGenerationResult generate(InformationModel infomodel, InvocationContext mappingContext, IVortoCodeGenProgressMonitor monitor) throws VortoCodeGeneratorException {
    GenerationResultZip zipOutputter = new GenerationResultZip(infomodel, getServiceKey());
    ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
    /*
		/ Generate the client part...
		*/
    String CLIENT_PROJ = infomodel.getName() + COAP_CLIENT_PROJECT_SUFFIX;
    initPaths(CLIENT_PROJ);
    generator.addTask(new CoAPClientInformationModelGeneratorTask(JAVA_FILE_EXTENSION, imTargetPath, IM_PACKAGE, JAVA_INTERFACE_PREFIX, JAVA_IMPL_SUFFIX, GETTER_PREFIX, SETTER_PREFIX, FB_INTERFACE_PACKAGE, FB_IMPL_PACKAGE));
    generator.addTask(new JavaInformationModelInterfaceGeneratorTask(JAVA_FILE_EXTENSION, imTargetPath, IM_PACKAGE, JAVA_INTERFACE_PREFIX, GETTER_PREFIX, SETTER_PREFIX, FB_INTERFACE_PACKAGE));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ClientTemplate(coapClientPath, COAP_CLIENT_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new CoAPMethodTemplate(coapClientPath, COAP_CLIENT_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ClientDemoAppTemplate(coapDemoPath, COAP_DEMO_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new PomFileTemplate("artifact", COAP_DEMO_PACKAGE + ".ClientDemoApp", CLIENT_PROJ)));
    generator.generate(infomodel, mappingContext, zipOutputter);
    for (FunctionblockProperty fbp : infomodel.getProperties()) {
        FunctionBlock fb = fbp.getType().getFunctionblock();
        for (Entity entity : Utils.getReferencedEntities(fb)) {
            generateForEntity(entity, zipOutputter);
        }
        for (Enum en : Utils.getReferencedEnums(fb)) {
            generateForEnum(en, zipOutputter);
        }
        for (Operation op : fb.getOperations()) {
            generateForOperation(op, zipOutputter);
        }
        if (fb.getStatus() != null) {
            for (Property property : fb.getStatus().getProperties()) {
                generateForProperty(property, zipOutputter);
            }
        }
        this.generateForClientFunctionBlock(fbp.getType(), zipOutputter);
    }
    /*
		/ Generate the server part...
		*/
    String SERVER_PROJ = infomodel.getName() + COAP_SERVER_PROJECT_SUFFIX;
    initPaths(SERVER_PROJ);
    generator.addTask(new CoAPServerGeneratorTask(COAP_SERVER_NAME, COAP_SERVER_PACKAGE, JAVA_FILE_EXTENSION, coapServerPath, JAVA_INTERFACE_PREFIX + COAP_REQUEST_HANDLER_NAME, COAP_REQUEST_HANDLER_PACKAGE));
    generator.addTask(new CoAPServerIMRequestHandlerGeneratorTask(COAP_REQUEST_HANDLER_NAME, JAVA_FILE_EXTENSION, coapRequestHandlerPath, COAP_REQUEST_HANDLER_PACKAGE, JAVA_INTERFACE_PREFIX, COAP_PRIM_TYPE_WRAPPER_SUFFIX, IM_PACKAGE, DT_PACKAGE, getOpParamSetPackage(), getPrimitiveParamWrapperPackage()));
    generator.addTask(new JavaInformationModelGeneratorTask(JAVA_FILE_EXTENSION, imTargetPath, IM_PACKAGE, JAVA_INTERFACE_PREFIX, JAVA_IMPL_SUFFIX, GETTER_PREFIX, SETTER_PREFIX, FB_INTERFACE_PACKAGE, FB_IMPL_PACKAGE));
    generator.addTask(new JavaInformationModelInterfaceGeneratorTask(JAVA_FILE_EXTENSION, imTargetPath, IM_PACKAGE, JAVA_INTERFACE_PREFIX, GETTER_PREFIX, SETTER_PREFIX, FB_INTERFACE_PACKAGE, FB_IMPL_PACKAGE));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ICoAPRequestHandlerTemplate(coapRequestHandlerPath, COAP_REQUEST_HANDLER_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new JsonTransformerTemplate(coapRequestHandlerPath, COAP_REQUEST_HANDLER_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new URIAnalyzerTemplate(coapRequestHandlerPath, COAP_REQUEST_HANDLER_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ResourceTemplate(coapServerPath, COAP_SERVER_PACKAGE, COAP_REQUEST_HANDLER_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new LinkTemplate(coapServerPath, COAP_SERVER_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new CoAPServerDemoAppTemplate(coapDemoPath, COAP_DEMO_PACKAGE, COAP_REQUEST_HANDLER_PACKAGE, COAP_SERVER_PACKAGE)));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new PomFileTemplate("artifact", COAP_DEMO_PACKAGE + ".ServerDemoApp", SERVER_PROJ)));
    generator.generate(infomodel, mappingContext, zipOutputter);
    for (FunctionblockProperty fbp : infomodel.getProperties()) {
        this.generateForFunctionBlock(fbp.getType(), zipOutputter);
        FunctionBlock fb = fbp.getType().getFunctionblock();
        for (Entity entity : Utils.getReferencedEntities(fb)) {
            generateForEntity(entity, zipOutputter);
        }
        for (Enum en : Utils.getReferencedEnums(fb)) {
            generateForEnum(en, zipOutputter);
        }
        for (Operation op : fb.getOperations()) {
            generateForOperation(op, zipOutputter);
        }
    }
    return zipOutputter;
}
Also used : Enum(org.eclipse.vorto.core.api.model.datatype.Enum) Entity(org.eclipse.vorto.core.api.model.datatype.Entity) ICoAPRequestHandlerTemplate(org.eclipse.vorto.codegen.coap.server.templates.ICoAPRequestHandlerTemplate) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ClientTemplate(org.eclipse.vorto.codegen.coap.client.templates.ClientTemplate) ClientDemoAppTemplate(org.eclipse.vorto.codegen.coap.client.templates.ClientDemoAppTemplate) Operation(org.eclipse.vorto.core.api.model.functionblock.Operation) JavaInformationModelInterfaceGeneratorTask(org.eclipse.vorto.codegen.coap.common.tasks.JavaInformationModelInterfaceGeneratorTask) JavaInformationModelGeneratorTask(org.eclipse.vorto.codegen.coap.common.tasks.JavaInformationModelGeneratorTask) PomFileTemplate(org.eclipse.vorto.codegen.coap.common.templates.PomFileTemplate) CoAPServerDemoAppTemplate(org.eclipse.vorto.codegen.coap.server.templates.CoAPServerDemoAppTemplate) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) Property(org.eclipse.vorto.core.api.model.datatype.Property) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) FunctionBlock(org.eclipse.vorto.core.api.model.functionblock.FunctionBlock) CoAPClientInformationModelGeneratorTask(org.eclipse.vorto.codegen.coap.client.tasks.CoAPClientInformationModelGeneratorTask) CoAPServerIMRequestHandlerGeneratorTask(org.eclipse.vorto.codegen.coap.server.tasks.CoAPServerIMRequestHandlerGeneratorTask) GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) CoAPMethodTemplate(org.eclipse.vorto.codegen.coap.client.templates.CoAPMethodTemplate) URIAnalyzerTemplate(org.eclipse.vorto.codegen.coap.server.templates.URIAnalyzerTemplate) ResourceTemplate(org.eclipse.vorto.codegen.coap.server.templates.ResourceTemplate) CoAPServerGeneratorTask(org.eclipse.vorto.codegen.coap.server.tasks.CoAPServerGeneratorTask) JsonTransformerTemplate(org.eclipse.vorto.codegen.coap.server.templates.JsonTransformerTemplate) LinkTemplate(org.eclipse.vorto.codegen.coap.server.templates.LinkTemplate)

Example 7 with ChainedCodeGeneratorTask

use of org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask 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 8 with ChainedCodeGeneratorTask

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

the class EclipseHonoGenerator method generate.

@Override
public IGenerationResult generate(InformationModel model, InvocationContext context, IVortoCodeGenProgressMonitor monitor) {
    GenerationResultZip output = new GenerationResultZip(model, getServiceKey());
    ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new PomFileTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new Log4jTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new CertificateTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new AppTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new IDataServiceTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new HonoDataService()));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new HonoMqttClientTemplate()));
    generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new InformationModelTemplate()));
    generator.generate(model, context, output);
    for (FunctionblockProperty fbProperty : model.getProperties()) {
        new GeneratorTaskFromFileTemplate<>(new FunctionblockTemplate(model)).generate(fbProperty.getType(), context, output);
    }
    return output;
}
Also used : GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) IDataServiceTemplate(org.eclipse.vorto.codegen.hono.service.IDataServiceTemplate) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) FunctionblockTemplate(org.eclipse.vorto.codegen.hono.model.FunctionblockTemplate) HonoDataService(org.eclipse.vorto.codegen.hono.service.hono.HonoDataService) InformationModelTemplate(org.eclipse.vorto.codegen.hono.model.InformationModelTemplate) HonoMqttClientTemplate(org.eclipse.vorto.codegen.hono.service.hono.HonoMqttClientTemplate) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)

Example 9 with ChainedCodeGeneratorTask

use of org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask 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 10 with ChainedCodeGeneratorTask

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

the class JavabeanGenerator method generateForFunctionBlock.

private void generateForFunctionBlock(InformationModel infomodel, FunctionblockModel fbm, IGeneratedWriter outputter) {
    ChainedCodeGeneratorTask<FunctionblockModel> generator = new ChainedCodeGeneratorTask<FunctionblockModel>();
    if (fbm.getFunctionblock().getStatus() != null) {
        generator.addTask(new JavaFunctionblockStatusGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, STATUS_SUFFIX, ENTITY_PACKAGE));
    }
    if (fbm.getFunctionblock().getConfiguration() != null) {
        generator.addTask(new JavaFunctionblockConfigurationGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, CONFIG_SUFFIX, ENTITY_PACKAGE));
    }
    if (fbm.getFunctionblock().getFault() != null) {
        generator.addTask(new JavaFunctionblockFaultGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, FAULT_SUFFIX, ENTITY_PACKAGE));
    }
    generator.addTask(new JavaFunctionblockImplGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, JAVA_IMPL_SUFFIX, ENTITY_PACKAGE));
    generator.addTask(new JavaFunctionblockInterfaceGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, ENTITY_PACKAGE));
    generator.generate(fbm, null, outputter);
}
Also used : FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) JavaFunctionblockInterfaceGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockInterfaceGeneratorTask) JavaFunctionblockConfigurationGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockConfigurationGeneratorTask) JavaFunctionblockStatusGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockStatusGeneratorTask) JavaFunctionblockFaultGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockFaultGeneratorTask) JavaFunctionblockImplGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockImplGeneratorTask)

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