use of org.eclipse.vorto.repository.core.impl.utils.DependencyManager in project vorto by eclipse.
the class ModelRepository method saveChangeSetIntoRepository.
/**
* saves the given changeset in a sorted way into the repository in the context of the given user
*
* @param changeSet
* @param user
*/
private void saveChangeSetIntoRepository(ChangeSet changeSet, IUserContext user) {
DependencyManager dm = new DependencyManager();
changeSet.getChanges().forEach(model -> dm.addResource(new ModelResource(model)));
dm.getSorted().forEach(sortedModel -> save((ModelResource) sortedModel, user));
}
use of org.eclipse.vorto.repository.core.impl.utils.DependencyManager in project vorto by eclipse.
the class ModelIdToModelContentConverter method getWorkspaceForModel.
private ModelWorkspaceReader getWorkspaceForModel(final ModelId modelId) {
Collection<ModelInfo> allModels = getModelWithAllDependencies(modelId);
DependencyManager dm = new DependencyManager(new HashSet<>(allModels));
allModels = dm.getSorted();
ModelWorkspaceReader workspaceReader = IModelWorkspace.newReader();
for (ModelInfo model : allModels) {
FileContent modelContent = repositoryFactory.getRepositoryByModel(model.getId()).getFileContent(model.getId(), Optional.of(model.getFileName())).get();
workspaceReader.addFile(new ByteArrayInputStream(modelContent.getContent()), model.getType());
}
return workspaceReader;
}
use of org.eclipse.vorto.repository.core.impl.utils.DependencyManager in project vorto by eclipse.
the class AbstractRepositoryController method getWorkspaceForModel.
protected IModelWorkspace getWorkspaceForModel(final ModelId modelId) {
List<ModelInfo> allModels = getModelWithAllDependencies(modelId);
DependencyManager dm = new DependencyManager(new HashSet<>(allModels));
allModels = dm.getSorted();
ModelWorkspaceReader workspaceReader = IModelWorkspace.newReader();
for (ModelInfo model : allModels) {
FileContent modelContent = getModelRepository(model.getId()).getFileContent(model.getId(), Optional.of(model.getFileName())).get();
workspaceReader.addFile(new ByteArrayInputStream(modelContent.getContent()), model.getType());
}
return workspaceReader.read();
}
use of org.eclipse.vorto.repository.core.impl.utils.DependencyManager in project vorto by eclipse.
the class DefaultPayloadMappingService method getWorkspaceForModel.
private IModelWorkspace getWorkspaceForModel(final ModelId modelId) {
List<ModelInfo> allModels = getModelWithAllDependencies(modelId);
DependencyManager dm = new DependencyManager(new HashSet<>(allModels));
allModels = dm.getSorted();
ModelWorkspaceReader workspaceReader = IModelWorkspace.newReader();
for (ModelInfo model : allModels) {
FileContent modelContent = this.modelRepositoryFactory.getRepositoryByModel(model.getId()).getFileContent(model.getId(), Optional.of(model.getFileName())).get();
workspaceReader.addFile(new ByteArrayInputStream(modelContent.getContent()), model.getType());
}
return workspaceReader.read();
}
use of org.eclipse.vorto.repository.core.impl.utils.DependencyManager in project vorto by eclipse.
the class AbstractModelImporter method sortAndSaveToRepository.
private List<ModelInfo> sortAndSaveToRepository(List<ModelResource> resources, FileUpload extractedFile, Context context) {
final IUserContext user = context.getUser();
List<ModelInfo> savedModels = new ArrayList<>();
DependencyManager dm = new DependencyManager();
for (ModelResource resource : resources) {
dm.addResource(resource);
}
dm.getSorted().forEach(resource -> {
try {
IModelRepository modelRepository = modelRepoFactory.getRepositoryByModel(resource.getId());
ModelInfo importedModel = modelRepository.save((ModelResource) resource, user);
savedModels.add(importedModel);
postProcessImportedModel(importedModel, new FileContent(extractedFile.getFileName(), extractedFile.getContent()), user);
} catch (Exception e) {
logger.error("Problem importing model", e);
throw new ModelImporterException("Problem importing model", e);
}
});
return savedModels;
}
Aggregations