use of org.eclipse.vorto.repository.core.ModelInfo 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.ModelInfo in project vorto by eclipse.
the class ModelInfoRetrieverTask method compute.
@Override
protected List<ModelInfo> compute() {
RequestContextHolder.setRequestAttributes(requestAttributes, true);
SecurityContextHolder.setContext(securityContext);
ModelInfo modelInfo = factory.getRepositoryByModelWithoutSessionHelper(rootID).getById(rootID);
if (Objects.nonNull(modelInfo)) {
modelInfos.add(modelInfo);
if (!modelInfo.getReferences().isEmpty()) {
modelInfos.addAll(processChildren(modelInfo));
}
}
return modelInfos;
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class MixedSearchTest method testSearchAllModelsWithWildCard.
@Test
public void testSearchAllModelsWithWildCard() {
assertEquals(4, testInfrastructure.getSearchService().search("*").size());
ModelInfo model = testInfrastructure.getSearchService().search("*").stream().filter(m -> m.getId().getName().equals("ColorLight")).findAny().get();
assertEquals(1, model.getReferences().size());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class DefaultWorkflowService method doAction.
@Override
public ModelInfo doAction(ModelId model, IUserContext user, String actionName) throws WorkflowException {
ModelInfo modelInfo = getModelRepository(user).getById(model);
final Optional<IState> state = SIMPLE_WORKFLOW.getState(modelInfo.getState());
final Optional<IAction> action = state.get().getAction(actionName);
if (action.isPresent() && isValidInput(modelInfo, action.get(), user) && passesConditions(action.get().getConditions(), modelInfo, user)) {
// test
IAction actionTest = action.get();
final IState newState = action.get().getTo();
modelInfo.setState(newState.getName());
ModelInfo updatedInfo = getModelRepository(user).updateMeta(modelInfo);
Map<String, Object> ctx = new HashMap<>();
action.get().getFunctions().stream().forEach(a -> executeFunction(a, modelInfo, user, ctx));
return updatedInfo;
} else {
throw new WorkflowException(modelInfo, "The given action is invalid.");
}
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class BulkApproveFunction method execute.
@Override
public void execute(ModelInfo model, IUserContext user, Map<String, Object> context) {
for (ModelId referenceId : model.getReferences()) {
IModelRepository repository = repositoryFactory.getRepositoryByModel(referenceId);
ModelInfo referenceModel = repository.getById(referenceId);
if (ModelState.InReview.getName().equals(referenceModel.getState())) {
try {
workflowService.doAction(referenceId, user, SimpleWorkflowModel.ACTION_APPROVE.getName());
} catch (WorkflowException e) {
logger.error("Problem executing release for model " + referenceId + "during bulk approve function", e);
}
}
}
}
Aggregations