use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.
the class TypeImportValidation method validate.
@Override
public void validate(ModelInfo modelResource, InvocationContext context) throws ValidationException {
Collection<String> unImportedReferences = Lists.newArrayList();
ModelEMFResource emfModel = (ModelEMFResource) modelResource;
Model model = emfModel.getModel();
if (model == null)
return;
if (model instanceof Entity) {
unImportedReferences.addAll(getUnimportedProperties(((Entity) model).getProperties(), model.getReferences()));
} else if (model instanceof FunctionblockModel) {
unImportedReferences.addAll(validateFunctionBlock((FunctionblockModel) model));
} else if (model instanceof InformationModel) {
unImportedReferences.addAll(getUnimportedFunctionblocks(((InformationModel) model).getProperties(), model.getReferences()));
}
unImportedReferences.forEach(ref -> System.out.println("Missing : " + ref));
if (!unImportedReferences.isEmpty()) {
throw new ValidationException(errorMessage(unImportedReferences), modelResource);
}
}
use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.
the class VortoService method getModel.
public Optional<InformationModel> getModel(String namespace, String name, String version) {
Optional<byte[]> modelResources = downloadUrl(urlForModel(namespace, name, version));
if (!modelResources.isPresent()) {
return Optional.empty();
}
IModelWorkspace workspace = IModelWorkspace.newReader().addZip(new ZipInputStream(new ByteArrayInputStream(modelResources.get()))).read();
return toInformationModel(workspace.get().stream().filter(p -> p.getName().equals(name)).findFirst().get());
}
use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.
the class VortoService method generate.
public IGenerationResult generate(String key, String namespace, String name, String version, Map<String, String> parameters) {
LOGGER.info(String.format("Generating for Platform [%s] and Model [%s.%s:%s]", key, namespace, name, version));
Generator generator = repo.get(key).orElseThrow(GatewayUtils.notFound(String.format("[Generator %s]", key)));
InformationModel model = getModel(namespace, name, version).orElseThrow(GatewayUtils.notFound(String.format("[Model %s.%s:%s]", namespace, name, version)));
List<MappingModel> mappings = getMappings(key, namespace, name, version);
InvocationContext invocationContext = new InvocationContext(mappings, repo.newGeneratorLookup(), parameters);
return generate(generator.getInstance(), model, invocationContext);
}
use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.
the class KuraGenerator 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 GeneratorTaskFromFileTemplate<>(new EclipseClasspathTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new EclipseProjectFileTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new ManifestTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new BuildPropertiesTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new ComponentXmlTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new IDataServiceTemplate()));
if (invocationContext.getConfigurationProperties().getOrDefault("boschcloud", "false").equalsIgnoreCase("true")) {
generator.addTask(new GeneratorTaskFromFileTemplate<>(new PomTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new BoschDataServiceTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new ThingClientFactoryTemplate()));
} else if (invocationContext.getConfigurationProperties().getOrDefault("boschhub", "false").equalsIgnoreCase("true")) {
generator.addTask(new GeneratorTaskFromFileTemplate<>(new PomTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new BoschHubDataService()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new BoschHubClientTemplate()));
} else {
generator.addTask(new GeneratorTaskFromFileTemplate<>(new KuraCloudDataServiceTemplate()));
}
if (invocationContext.getConfigurationProperties().getOrDefault("bluetooth", "false").equalsIgnoreCase("true")) {
generator.addTask(new GeneratorTaskFromFileTemplate<>(new MetatypeTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new DeviceBluetoothFinderTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new ConfigurationTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new DeviceFilterTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new DeviceToInformationModelTransformerTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<>(new InformationModelConsumerTemplate()));
} else {
generator.addTask(new GeneratorTaskFromFileTemplate<>(new DefaultAppTemplate()));
}
generator.addTask(new GeneratorTaskFromFileTemplate<>(new InformationModelTemplate()));
for (FunctionblockProperty fbProperty : context.getProperties()) {
new GeneratorTaskFromFileTemplate<>(new FunctionblockTemplate(context)).generate(fbProperty.getType(), invocationContext, outputter);
}
generator.generate(context, invocationContext, outputter);
return outputter;
}
use of org.eclipse.vorto.core.api.model.informationmodel.InformationModel in project vorto by eclipse.
the class LatexGenerator 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>();
generator.addTask(new LatexInformationModelGeneratorTask(LATEX_FILE_EXTENSION, LATEX_TARGET_PATH));
generator.generate(infomodel, invocationContext, zipOutputter);
return zipOutputter;
}
Aggregations