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;
}
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;
}
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();
}
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);
}
}
}
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;
}
Aggregations