use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel 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();
}
use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.
the class WebUIGenerator method generate.
@Override
public IGenerationResult generate(InformationModel model, InvocationContext context, IVortoCodeGenProgressMonitor monitor) {
GenerationResultZip output = new GenerationResultZip(model, getServiceKey());
ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
/**
* config templates
*/
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new LocalConfigurationTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new WebSecurityConfigTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new WebSocketConfigTemplate()));
/**
* model templates
*/
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingTemplate()));
/**
* web controller templates
*/
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new IdentityControllerTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingControllerTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingMessageControllerTemplate()));
/**
* Root Application templates
*/
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new PomTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingApplicationTemplate()));
/**
* Web static javascript templates
*/
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new AppTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new BrowserControllerTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new DetailsControllerTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new LoginControllerTemplate()));
/**
* Web static css templates
*/
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new StyleTemplace()));
/**
* Web static html partial templates
*/
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new IndexHtmlTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new BrowserTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new LocatorTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new LoginTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new DetailsTemplate()));
/**
* Swagger stuff
*/
if (context.getConfigurationProperties().getOrDefault("swagger", "true").equalsIgnoreCase("true")) {
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new SwaggerConfigurationTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ApiControllerTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ApiTemplate()));
}
/**
* History stuff
*/
if (context.getConfigurationProperties().getOrDefault("persistence", "true").equalsIgnoreCase("true")) {
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new CrudRepositoryTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new HistoryDataControllerTemplate()));
}
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ApplicationConfigTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new AngularGageTemplate()));
/**
* IoT Cloud Platform Integration stuff
*/
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new QueryTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new DataServiceTemplate()));
if (context.getConfigurationProperties().getOrDefault("boschcloud", "false").equalsIgnoreCase("true")) {
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingsQueryTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingClientTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingClientBuilderTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingBuilderTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new org.eclipse.vorto.codegen.webui.templates.service.bosch.model.ThingTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new org.eclipse.vorto.codegen.webui.templates.service.bosch.model.FeatureTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingSearchResultTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingTypeAwareTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new FeatureImplTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingImplTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingSearchResultImplTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new AsyncInvocationTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new DefaultThingClient()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new ThingsInvocationTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new BoschThingsDataServiceTemplate()));
} else {
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new SampleDataServiceTemplate()));
}
generator.generate(model, context, output);
ChainedCodeGeneratorTask<FunctionblockProperty> fbPropertyGenerators = new ChainedCodeGeneratorTask<FunctionblockProperty>();
for (FunctionblockProperty property : model.getProperties()) {
fbPropertyGenerators.addTask(new GeneratorTaskFromFileTemplate<>(new FeatureTemplate()));
fbPropertyGenerators.addTask(new GeneratorTaskFromFileTemplate<>(new LocationControllerTemplate()));
fbPropertyGenerators.generate(property, context, output);
FunctionBlock fb = property.getType().getFunctionblock();
for (Entity entity : Utils.getReferencedEntities(fb)) {
generateForEntity(model, entity, output);
}
for (Enum en : Utils.getReferencedEnums(fb)) {
generateForEnum(model, en, output);
}
}
return output;
}
use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.
the class ModelReaderTest method testReadInfomodelFromZipFile.
@Test
public void testReadInfomodelFromZipFile() throws Exception {
IModelWorkspace workspace = IModelWorkspace.newReader().addZip(new ZipInputStream(getClass().getClassLoader().getResourceAsStream("models.zip"))).read();
Model model = workspace.get().stream().filter(p -> p.getName().equals("TI_SensorTag_CC2650")).findAny().get();
assertNotNull(model);
assertTrue(model instanceof InformationModel);
}
use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.
the class ModelReaderTest method testReadFromFile.
@Test
public void testReadFromFile() {
IModelWorkspace workspace = IModelWorkspace.newReader().addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.example_AWSIoTButton_1_0_0.infomodel"), ModelType.InformationModel).addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.example.aws_AWSButtonMapping_1_0_0.mapping"), ModelType.Mapping).addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.example.aws_Button1Mapping_1_0_0.mapping"), ModelType.Mapping).addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.example.aws_Button2Mapping_1_0_0.mapping"), ModelType.Mapping).addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.ipso.smartobjects_Push_button_0_0_1.fbmodel"), ModelType.Functionblock).read();
InformationModel model = (InformationModel) workspace.get().stream().filter(p -> p instanceof InformationModel).findAny().get();
assertNotNull(model);
assertEquals("AWSIoTButton", model.getName());
assertEquals("AWSButtonMapping", workspace.get().stream().filter(p -> p.getName().equals("AWSButtonMapping")).findAny().get().getName());
}
Aggregations