use of org.whole.lang.bindings.IBindingScope in project whole by wholeplatform.
the class SequenceIterator method updateCurrentIterator.
protected boolean updateCurrentIterator() {
final IBindingManager bindings = getBindings();
final Map<String, IEntity> lookaheadBindings = new HashMap<String, IEntity>();
IBindingScope currentLookaheadScope = currentIterator().lookaheadScope();
for (String name : currentLookaheadScope.wLocalNames()) {
bindings.wUnset(name);
lookaheadBindings.put(name, currentLookaheadScope.wGet(name));
}
if (currentIterator().hasNext())
return true;
else {
for (Entry<String, IEntity> entry : lookaheadBindings.entrySet()) if (bindings.wIsSet(entry.getKey()))
bindings.wSet(entry.getKey(), entry.getValue());
else
bindings.wDef(entry.getKey(), entry.getValue());
lookaheadScope().getFilterNames().addAll(lookaheadBindings.keySet());
while (iteratorIndex < iteratorChain.length - 1) {
iteratorIndex++;
// currentIterator().reset(resetEntity);
if (currentIterator().hasNext())
return true;
}
return false;
}
}
use of org.whole.lang.bindings.IBindingScope in project whole by wholeplatform.
the class WholeOperationLaunchConfigurationDelegate method launch.
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
if (!"run".equals(mode))
throw new CoreException(new Status(Status.CANCEL, PLUGIN_ID, 1, "Only 'run' mode supported by this launcher", null));
String operationId = configuration.getAttribute(OPERATION_ID, (String) null);
if (operationId == null)
throw new CoreException(new Status(Status.CANCEL, PLUGIN_ID, 1, "No operation selected", null));
String targetModelPath = configuration.getAttribute(TARGET_MODEL_PATH, (String) null);
if (targetModelPath == null)
throw new CoreException(new Status(Status.CANCEL, PLUGIN_ID, 1, "No target model selected", null));
String targetModelPersistence = configuration.getAttribute(TARGET_MODEL_PERSISTENCE, (String) null);
if (targetModelPersistence == null)
throw new CoreException(new Status(Status.CANCEL, PLUGIN_ID, 1, "No persistence selected", null));
try {
monitor.beginTask("Executing " + operationId + " operation...", 100);
if (monitor.isCanceled())
return;
IOperationProgressMonitor operationProgressMonitor = new OperationProgressMonitorAdapter(monitor);
IFile targetModelFile = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromPortableString(targetModelPath));
IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
ResourceUtils.defineResourceBindings(bindings, targetModelFile);
IBindingScope scope = LaunchConfigurationUtils.loadBindingScope(configuration);
bindings.wEnterScope(scope, true);
IPersistenceKit persistenceKit = ReflectionFactory.getPersistenceKit(targetModelPersistence);
IEntity model = persistenceKit.readModel(new IFilePersistenceProvider(targetModelFile));
IOperationLauncher operationLauncher = OperationLauncherRegistry.instance.getOperationLauncher(operationId);
InputStream is = System.in;
OutputStream os = System.out;
if (configuration.getAttribute(CONSOLE_VIEW, false)) {
IOConsole ioConsole = WholeConsoleFactory.getIOConsole();
is = ioConsole.getInputStream();
os = ioConsole.newOutputStream();
}
operationLauncher.launch(model, bindings, is, os, operationProgressMonitor);
if (configuration.getAttribute(PERSIST_CHANGES, false))
persistenceKit.writeModel(model, new IFilePersistenceProvider(targetModelFile));
} catch (Throwable t) {
WholePlugin.log(t);
} finally {
monitor.done();
}
}
use of org.whole.lang.bindings.IBindingScope in project whole by wholeplatform.
the class MatcherTest method testSubstituteValue.
@Test
public void testSubstituteValue() {
SimpleEntity entityPattern = new SimpleEntityPattern().create();
IBindingScope args = BindingManagerFactory.instance.createSimpleScope();
args.wDefValue("entityName", "SE");
Matcher.substitute(entityPattern, args, false);
assertEquals("SE", entityPattern.getName().wStringValue());
assertEquals(ModelsEntityDescriptorEnum.SimpleName, entityPattern.getName().wGetEntityDescriptor());
}
Aggregations