use of org.eclipse.vorto.core.api.repository.ModelResource in project vorto by eclipse.
the class RepositoryResourceDropAction method downloadAndSaveModel.
// Download and save model from repository to local project.
// It also recursively do the same for the model references.
private IModelElement downloadAndSaveModel(IModelProject modelProject, ModelId modelId) {
IModelElement modelElement = null;
try {
ModelResource model = modelRepo.getModel(modelId);
if (model != null) {
if (!modelProject.exists(modelId)) {
for (ModelId reference : model.getReferences()) {
downloadAndSaveModel(modelProject, reference);
}
downloadMappings(modelProject, model.getReferencedBy());
MessageDisplayFactory.getMessageDisplay().display("Downloading " + modelId.toString());
byte[] modelContent = modelRepo.downloadContent(model.getId());
modelElement = saveToProject(modelProject, modelContent, model.getId());
} else {
modelElement = modelProject.getModelElementById(modelId);
}
} else {
MessageDisplayFactory.getMessageDisplay().displayError("Model " + modelId.toString() + " not found in repository.");
}
} catch (RepositoryException e) {
ExceptionHandlerFactory.getHandler().handle(e);
}
return modelElement;
}
Aggregations