use of org.alien4cloud.tosca.editor.operations.AbstractEditorOperation in project alien4cloud by alien4cloud.
the class EditorStepDefinitions method do_i_execute_the_operation.
public static void do_i_execute_the_operation(Map<String, String> operationMap) throws Throwable {
Class operationClass = Class.forName(operationMap.get("type"));
AbstractEditorOperation operation = (AbstractEditorOperation) operationClass.newInstance();
EvaluationContext operationContext = new StandardEvaluationContext(operation);
SpelParserConfiguration config = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(config);
for (Map.Entry<String, String> operationEntry : operationMap.entrySet()) {
if (!"type".equals(operationEntry.getKey())) {
parser.parseRaw(operationEntry.getKey()).setValue(operationContext, operationEntry.getValue());
}
}
do_i_execute_the_operation(operation);
}
use of org.alien4cloud.tosca.editor.operations.AbstractEditorOperation in project alien4cloud by alien4cloud.
the class EditorService method doSave.
private void doSave() throws IOException {
EditionContext context = EditionContextManager.get();
if (context.getLastOperationIndex() <= context.getLastSavedOperationIndex()) {
// nothing to save..
return;
}
StringBuilder commitMessage = new StringBuilder();
// copy and cleanup all temporary files from the executed operations.
for (int i = context.getLastSavedOperationIndex() + 1; i <= context.getLastOperationIndex(); i++) {
AbstractEditorOperation operation = context.getOperations().get(i);
IEditorOperationProcessor<?> processor = (IEditorOperationProcessor) processorMap.get(operation.getClass());
if (processor instanceof IEditorCommitableProcessor) {
((IEditorCommitableProcessor) processor).beforeCommit(operation);
}
commitMessage.append(operation.getAuthor()).append(": ").append(operation.commitMessage()).append("\n");
}
saveYamlAndZipFile();
Topology topology = EditionContextManager.getTopology();
// Save the topology in elastic search
topologyServiceCore.save(topology);
// Topology has changed means that dependencies might have changed, must update the dependencies
csarService.setDependencies(EditionContextManager.getCsar(), topology.getDependencies());
// update substitution type if needed
topologySubstitutionServive.updateSubstitutionType(topology, EditionContextManager.getCsar());
// Local git commit
repositoryService.commit(EditionContextManager.get().getCsar(), commitMessage.toString());
// TODO add support for undo even after save, this require ability to rollback files to git state, we need file rollback support for that..
context.setOperations(Lists.newArrayList(context.getOperations().subList(context.getLastOperationIndex() + 1, context.getOperations().size())));
context.setLastOperationIndex(-1);
}
use of org.alien4cloud.tosca.editor.operations.AbstractEditorOperation in project alien4cloud by alien4cloud.
the class EditorStepDefs method i_execute_the_operation_on_topology_number.
@Given("^I execute the operation on the topology number (\\d+)$")
public void i_execute_the_operation_on_topology_number(int indexOfTopologyId, DataTable operationDT) throws Throwable {
Map<String, String> operationMap = Maps.newHashMap();
for (DataTableRow row : operationDT.getGherkinRows()) {
operationMap.put(row.getCells().get(0), row.getCells().get(1));
}
Class operationClass = Class.forName(operationMap.get("type"));
AbstractEditorOperation operation = (AbstractEditorOperation) operationClass.newInstance();
EvaluationContext operationContext = new StandardEvaluationContext(operation);
SpelParserConfiguration config = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(config);
for (Map.Entry<String, String> operationEntry : operationMap.entrySet()) {
if (!"type".equals(operationEntry.getKey())) {
parser.parseRaw(operationEntry.getKey()).setValue(operationContext, getValue(operationEntry.getValue()));
}
}
doExecuteOperation(operation, topologyIds.get(indexOfTopologyId));
}
Aggregations