use of org.whole.lang.workflows.model.Variable in project whole by wholeplatform.
the class WorkflowsDynamicCompilerVisitor method visit.
@Override
public void visit(InvokeJavaClassMethod entity) {
final Variable resultVariable = entity.getResult();
Expressions arguments = entity.getArguments();
int size = arguments.wSize();
IEntityIterator<?>[] runnableIterators = new IEntityIterator<?>[2 + size];
entity.getClassName().accept(this);
runnableIterators[0] = getResultIterator();
entity.getMethod().accept(this);
runnableIterators[1] = getResultIterator();
for (int i = 0; i < size; i++) {
arguments.get(i).accept(this);
runnableIterators[2 + i] = getResultIterator();
}
setResultIterator(IteratorFactory.multiValuedRunnableIterator(new AbstractWorkflowsRunnable() {
public void run(IEntity selfEntity, IBindingManager bm, IEntity... argsEntities) {
String className = argsEntities[0].wStringValue();
IEntity methodData = argsEntities[1];
Method method;
if (DataTypeUtils.getDataKind(methodData).isString())
method = JavaReflectUtils.getMethod(className, methodData.wStringValue(), ReflectionFactory.getClassLoader(bm));
else
method = (Method) methodData.wGetValue();
Object[] arguments = toArguments(method.getParameterTypes(), method.isVarArgs(), argsEntities);
Object resultValue = JavaReflectUtils.invokeMethod(null, method, arguments);
setResult(bm, resultVariable, resultValue, method.getReturnType());
}
}, runnableIterators).withSourceEntity(entity));
}
use of org.whole.lang.workflows.model.Variable in project whole by wholeplatform.
the class ChooseModelsDialog method open.
@Override
public int open() {
int status = super.open();
if (status == Dialog.OK) {
WorkflowsEntityFactory wef = WorkflowsEntityFactory.instance;
Tuple tuple = QueriesEntityFactory.instance.createTuple(0);
for (Object element : getResult()) try {
IEntity model = getPersistenceKit().readModel(new IFilePersistenceProvider((IFile) element));
tuple.wAdd(createStageUpFragment(QueriesEntityDescriptorEnum.Expression, model));
} catch (Exception e) {
}
Variable variable = wef.createVariable("selectedModels");
Expression fragment = createSameStageFragment(Expression, tuple);
Assign assign = wef.createAssign(variable, fragment);
assignments.wAdd(assign);
}
return status;
}
use of org.whole.lang.workflows.model.Variable in project whole by wholeplatform.
the class WorkflowsIDEInterpreterVisitor method visit.
@Override
public void visit(Task entity) {
entity.getLabel().accept(this);
String title = PrettyPrinterOperation.toPrettyPrintString(getResult());
entity.getDescription().accept(this);
String description = PrettyPrinterOperation.toPrettyPrintString(getResult());
Assignments assignments = EntityUtils.clone(entity.getAssignments());
Variable factoryVariable = entity.getFactory();
ITaskDialogFactory factory;
if (EntityUtils.isNotResolver(factoryVariable)) {
factoryVariable.accept(this);
factory = (ITaskDialogFactory) getResultValue();
} else if (EntityUtils.isNotResolver(assignments)) {
factory = AssignmentsDialogFactory.instance();
} else
factory = ConfirmationDialogFactory.instance();
if (EntityUtils.isNotResolver(assignments)) {
stagedVisit(assignments, 1);
assignments = (Assignments) getResult();
}
if (!TaskDialogHelper.showTaskDialog(factory, title, description, assignments, getBindings()))
throw new OperationCanceledException(new VisitException("task not completed: " + description));
assignments.accept(this);
}
use of org.whole.lang.workflows.model.Variable in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method afterWriteModel.
protected void afterWriteModel(SaveModel entity, IPersistenceProvider provider) throws Exception {
if (getResourceKind(entity).wContainsValue(ResourceKindEnum.VARIABLE)) {
String result = ((StringPersistenceProvider) provider).getStore();
Variable variable = (Variable) entity.getResource();
getBindings().wDefValue(variable.getValue(), result);
}
}
use of org.whole.lang.workflows.model.Variable in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method visit.
@Override
public void visit(InvokeQuery entity) {
Variable queryName = entity.getQueryName();
Arguments arguments = entity.getArguments();
IEntityIterator<? extends IEntity>[] argsIterators = new IEntityIterator<?>[0];
Set<String> filterNames = getOperation().getResultsScope().wNames();
IBindingManager args = BindingManagerFactory.instance.createBindingManager(BindingManagerFactory.instance.createExcludeFilterScope(filterNames).wWithEnclosingScope(getBindings()), getBindings().wGetEnvironmentManager());
if (!EntityUtils.isNotResolver(arguments)) {
setResultValue(argsIterators);
arguments.accept(this);
argsIterators = (IEntityIterator<?>[]) getResultValue();
} else if (Matcher.match(WorkflowsEntityDescriptorEnum.Expressions, arguments)) {
IEntity selfEntity = getBindings().wGet("self");
argsIterators = new IEntityIterator<?>[arguments.wSize()];
for (int i = 0; i < argsIterators.length; i++) {
((Expressions) arguments).get(i).accept(this);
argsIterators[i] = getResultIterator();
setResultIterator(null);
resetSelfEntity(selfEntity);
}
} else
define(args, (Assignments) arguments);
IEntityIterator<?> iterator = QueriesIteratorFactory.callIterator(queryName.getValue(), argsIterators);
iterator.setBindings(args);
resetIterator(iterator);
while (iterator.hasNext()) iterator.next();
}
Aggregations