use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class TestsUIInterpreterVisitor method reportFailure.
@Override
protected void reportFailure(String name, TestsException e) {
super.reportFailure(name, e);
IBindingManager debugEnv = getBindings();
if ((debugEnv.wIsSet("debug#reportModeEnabled") && !debugEnv.wBooleanValue("debug#reportModeEnabled")) || (debugEnv.wIsSet("debug#debugModeEnabled") && !debugEnv.wBooleanValue("debug#debugModeEnabled")) || (debugEnv.wIsSet("debug#breakpointsEnabled") && !debugEnv.wBooleanValue("debug#breakpointsEnabled")))
return;
else
E4Utils.suspendOperation(SuspensionKind.RECOVERABLE_ERROR, e, e.getSubjectStatement(), e.getBindings());
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class PersistenceLibraryDeployer method stringToModelIterator.
public static IEntityIterator<IEntity> stringToModelIterator() {
return IteratorFactory.singleValuedRunnableIterator((IEntity selfEntity, IBindingManager bm, IEntity... arguments) -> {
StringPersistenceProvider pp = new StringPersistenceProvider(selfEntity.wStringValue());
IPersistenceKit persistenceKit = null;
try {
persistenceKit = derivePersistenceKit(bm, pp);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load the persistence kit", e);
}
try {
bm.setResult(persistenceKit.readModel(pp));
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load the resource with the given persistence: " + persistenceKit.getId(), e);
}
});
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class PersistenceLibraryDeployer method modelToStringIterator.
public static IEntityIterator<IEntity> modelToStringIterator() {
return IteratorFactory.singleValuedRunnableIterator((IEntity selfEntity, IBindingManager bm, IEntity... arguments) -> {
StringPersistenceProvider pp = new StringPersistenceProvider();
pp.getBindings().wDefValue("entityURI", selfEntity.wGetEntityDescriptor().getURI());
IPersistenceKit persistenceKit = null;
try {
persistenceKit = derivePersistenceKit(bm, pp);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load the persistence kit", e);
}
try {
persistenceKit.writeModel(selfEntity, pp);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load the resource with the given persistence: " + persistenceKit.getId(), e);
}
bm.setResult(BindingManagerFactory.instance.createValue(pp.getStore()));
});
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class JavaBuilderPersistenceKit method doReadModel.
@SuppressWarnings("unchecked")
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
IBindingManager bm = pp.getBindings();
if (bm.wIsSet("compilationUnitName")) {
ClassLoader classLoader = ReflectionFactory.getClassLoader(bm);
Class<?> codebaseClass = classLoader.loadClass(bm.wStringValue("compilationUnitName"));
if (ITemplateFactory.class.isAssignableFrom(codebaseClass))
return ((ITemplateFactory<IEntity>) codebaseClass.newInstance()).create();
}
byte[] buffer = new byte[1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream(buffer.length * 16);
BufferedInputStream bis = new BufferedInputStream(pp.getInputStream(), buffer.length);
int bytesRead;
while ((bytesRead = bis.read(buffer, 0, buffer.length)) > 0) baos.write(buffer, 0, bytesRead);
Interpreter javaInterpreter = new Interpreter();
javaInterpreter.setClassLoader(ReflectionFactory.getPlatformClassLoader());
Object result = javaInterpreter.eval(toBeanShellScript(baos.toString(pp.getEncoding())));
if (!(result instanceof IEntity))
throw new IllegalStateException("not a whole model");
return (IEntity) result;
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class WorkflowsInterpreterVisitorTest method testShallowSaveArtifacts.
@Test
public void testShallowSaveArtifacts() {
IEntity shallowSaveArtifactsTest = WorkflowsTestTemplateManager.instance().create("shallowSaveArtifactsTest");
IBindingManager args = BindingManagerFactory.instance.createArguments();
InterpreterOperation.interpret(shallowSaveArtifactsTest, args);
Assert.assertTrue(args.wIsSet("artifacts"));
IEntity artifacts = args.wGet("artifacts");
Assert.assertTrue(args.wIsSet("shallowResult"));
IEntity shallowResult = args.wGet("shallowResult");
Assert.assertTrue(args.wIsSet("deepFileResult"));
IEntity deepFileResult = args.wGet("deepFileResult");
Assert.assertTrue(args.wIsSet("deepDirectoryResult"));
IEntity deepDirectoryResult = args.wGet("deepDirectoryResult");
Assert.assertTrue(args.wIsSet("deepResult"));
IEntity deepResult = args.wGet("deepResult");
// shallow save & deep file load == shallow save & deep
Assert.assertTrue(OrderedMatcher.match(deepFileResult, deepResult, comparatorsMap));
// shallow save & deep directory load == shallow save & shallow
Assert.assertTrue(OrderedMatcher.match(deepDirectoryResult, shallowResult, comparatorsMap));
// the original model differs from every other model
Assert.assertFalse(OrderedMatcher.match(artifacts, shallowResult, comparatorsMap));
Assert.assertFalse(OrderedMatcher.match(artifacts, deepFileResult, comparatorsMap));
Assert.assertFalse(OrderedMatcher.match(artifacts, deepDirectoryResult, comparatorsMap));
Assert.assertFalse(OrderedMatcher.match(artifacts, deepResult, comparatorsMap));
// the only difference is the content on the file artifact
IEntityIterator<IEntity> iterator = IteratorFactory.matcherIterator(IteratorFactory.descendantOrSelfIterator()).withPattern(ArtifactsFeatureDescriptorEnum.content);
iterator.reset(deepFileResult);
while (iterator.hasNext()) {
iterator.next();
iterator.remove();
}
Assert.assertTrue(OrderedMatcher.match(deepDirectoryResult, deepFileResult, comparatorsMap));
}
Aggregations