Search in sources :

Example 1 with ActionCallIterator

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);
}
Also used : ActionCallIterator(org.whole.lang.actions.iterators.ActionCallIterator) FunctionBody(org.whole.lang.semantics.model.FunctionBody)

Example 2 with ActionCallIterator

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));
}
Also used : ActionCallIterator(org.whole.lang.actions.iterators.ActionCallIterator) SelectedEntities(org.whole.lang.actions.model.SelectedEntities) IEntityIterator(org.whole.lang.iterators.IEntityIterator)

Example 3 with ActionCallIterator

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);
}
Also used : ActionCallIterator(org.whole.lang.actions.iterators.ActionCallIterator) IEntity(org.whole.lang.model.IEntity) IOperationProgressMonitor(org.whole.lang.operations.IOperationProgressMonitor)

Aggregations

ActionCallIterator (org.whole.lang.actions.iterators.ActionCallIterator)3 SelectedEntities (org.whole.lang.actions.model.SelectedEntities)1 IEntityIterator (org.whole.lang.iterators.IEntityIterator)1 IEntity (org.whole.lang.model.IEntity)1 IOperationProgressMonitor (org.whole.lang.operations.IOperationProgressMonitor)1 FunctionBody (org.whole.lang.semantics.model.FunctionBody)1