use of org.whole.lang.actions.iterators.ActionCallIterator in project whole by wholeplatform.
the class SemanticsDynamicCompilerVisitor method visit.
@Override
public void visit(SemanticFunction entity) {
FunctionBody rules = entity.getRules();
if (Matcher.match(SemanticsEntityDescriptorEnum.InferenceRules, rules)) {
// TODO not supported yet
setResultIterator(IteratorFactory.emptyIterator().withSourceEntity(entity));
return;
}
IEntityIterator<?> ac = new ActionCallIterator("whole:org.whole.lang.semantics:SemanticsActions:1.0.0#Translate Normalized Function to Query", null);
stagedVisit(ac.evaluate(entity, getBindings()));
IEntityIterator<?> functionBehavior = getResultIterator();
FunctionLibraryRegistry.instance().putFunctionCode(getLibraryUri(entity) + "#" + entity.getName().getValue(), functionBehavior);
}
use of org.whole.lang.actions.iterators.ActionCallIterator in project whole by wholeplatform.
the class ActionsDynamicCompilerVisitor method visit.
@Override
public void visit(ActionCall entity) {
SelectedEntities selectedEntitiesFeature = entity.getSelectedEntities();
IEntityIterator<?>[] argumentsIterators = null;
if (EntityUtils.isNotResolver(selectedEntitiesFeature)) {
selectedEntitiesFeature.accept(this);
IEntityIterator<?> resultIterator = getResultIterator();
argumentsIterators = new IEntityIterator<?>[1];
argumentsIterators[0] = resultIterator;
}
setResultIterator(new ActionCallIterator(entity.getName().getValue(), argumentsIterators).withSourceEntity(entity));
}
use of org.whole.lang.actions.iterators.ActionCallIterator in project whole by wholeplatform.
the class HandlersBehavior method actionCall.
public static void actionCall(IBindingManager bm) {
IEntity model = bm.wGet("self");
boolean analyzing = bm.wBooleanValue("analyzing");
if (analyzing) {
// clone model if is analyzing
model = EntityUtils.clone(model);
CommonsEntityFactory.instance.createRootFragment(model.wGetAdapter(CommonsEntityDescriptorEnum.Any));
ReflectionFactory.getHistoryManager(model).setHistoryEnabled(true);
// map selected entities if analyzing
IEntity tuple = bm.wGet("selectedEntities");
int size = tuple.wSize();
for (int i = 0; i < size; i++) tuple.wSet(i, EntityUtils.mapEntity(tuple.wGet(i), model));
bm.wSet("primarySelectedEntity", EntityUtils.mapEntity(bm.wGet("primarySelectedEntity"), model));
bm.wSet("focusEntity", EntityUtils.mapEntity(bm.wGet("focusEntity"), model));
}
IEntityIterator<?> iterator = new ActionCallIterator(bm.wStringValue("functionUri"));
if (analyzing) {
iterator.setBindings(bm);
iterator.reset(model);
IEntity results = MiscEntityFactory.instance.createMisc();
for (IEntity result : iterator) {
results.wAdd(GenericEntityFactory.instance.create(CommonsEntityDescriptorEnum.StageUpFragment, // CommonsEntityFactory.instance.createStageUpFragment(
EntityUtils.cloneIfParented(// TODO substitute with a no containment fragment
result)));
((IOperationProgressMonitor) bm.wGetValue("progressMonitor")).worked(1);
}
bm.setResult(results);
} else
iterator.evaluate(model, bm);
}
Aggregations