use of org.whole.lang.workflows.model.ResourceKind in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method getPersistenceProvider.
protected IPersistenceProvider getPersistenceProvider(PersistenceActivity entity) {
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
getBindings().wEnterScope(bm, true);
entity.getBindings().accept(this);
getBindings().wExitScope();
String resource = getResourceString(entity);
ResourceKind resourceKind = getResourceKind(entity);
switch(resourceKind.getValue().getOrdinal()) {
case ResourceKindEnum.FILE_SYSTEM_ord:
return getFileSystemProvider(bm, resource);
case ResourceKindEnum.WORKSPACE_ord:
return getWorkspaceProvider(bm, resource);
case ResourceKindEnum.CLASSPATH_ord:
ReflectionFactory.setClassLoader(bm, ReflectionFactory.getClassLoader(getBindings()));
return getClasspathProvider(bm, resource);
case ResourceKindEnum.URL_ord:
return getURLProvider(bm, resource);
case ResourceKindEnum.VARIABLE_ord:
return getStringProvider(bm, resource);
default:
throw new IllegalArgumentException("Unsupported resource kind");
}
}
use of org.whole.lang.workflows.model.ResourceKind in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method getResourceKind.
protected ResourceKind getResourceKind(PersistenceActivity entity) {
ResourceKind resourceKind = entity.getResourceKind();
setResult(null);
resourceKind.accept(this);
return (ResourceKind) getResult();
}
use of org.whole.lang.workflows.model.ResourceKind in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method visit.
@Override
public void visit(LoadArtifacts entity) {
try {
IArtifactsEntity model = null;
Variable variable = entity.getModel();
String variableName = variable.getValue();
boolean isDefined = getBindings().wIsSet(variableName);
if (isDefined) {
variable.accept(this);
model = (IArtifactsEntity) getResult();
}
entity.getRootResource().accept(this);
String resource = getResultString();
ResourceKind resourceKind = entity.getRootResourceKind();
Traverse traverse = Traverse.valueOf(DataTypeUtils.getAsPersistenceString(entity.getTraversalStrategy()));
Synchronize synchronize = Synchronize.valueOf(DataTypeUtils.getAsPersistenceString(entity.getSynchronizeStrategy()));
IPersistenceKit defaultPersistenceKit = getPersistenceKit(entity.getDefaultPersistence());
IArtifactsEntity result = ArtifactsSynchronizerVisitor.synchronize(model, traverse, synchronize, createArtifactsBindings(resource, resourceKind), defaultPersistenceKit, true);
if (isDefined) {
if (EntityUtils.hasParent(model))
model.wGetParent().wSet(model, result);
getBindings().wSet(variableName, result);
} else
getBindings().wDef(variableName, result);
setResult(result);
} catch (Exception e) {
throw IWholeRuntimeException.asWholeException(e, entity, getBindings());
}
}
use of org.whole.lang.workflows.model.ResourceKind in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method visit.
@Override
public void visit(DeleteArtifacts entity) {
try {
entity.getModel().accept(this);
IArtifactsEntity model = (IArtifactsEntity) getResult();
entity.getRootResource().accept(this);
String resource = getResultString();
ResourceKind resourceKind = entity.getRootResourceKind();
IBindingManager bindings = createArtifactsBindings(resource, resourceKind);
ArtifactsDeleteVisitor.delete(model, bindings);
} catch (Exception e) {
throw IWholeRuntimeException.asWholeException(e, entity, getBindings());
}
}
use of org.whole.lang.workflows.model.ResourceKind in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method visit.
@Override
public void visit(SaveArtifacts entity) {
try {
entity.getModel().accept(this);
IArtifactsEntity model = (IArtifactsEntity) getResult();
entity.getRootResource().accept(this);
String resource = getResultString();
ResourceKind resourceKind = entity.getRootResourceKind();
Traverse traverse = Traverse.valueOf(DataTypeUtils.getAsPersistenceString(entity.getTraversalStrategy()));
Synchronize synchronize = Synchronize.valueOf(DataTypeUtils.getAsPersistenceString(entity.getSynchronizeStrategy()));
IPersistenceKit defaultPersistenceKit = getPersistenceKit(entity.getDefaultPersistence());
ArtifactsSynchronizerVisitor.synchronize(model, traverse, synchronize, createArtifactsBindings(resource, resourceKind), defaultPersistenceKit, false);
} catch (Exception e) {
throw IWholeRuntimeException.asWholeException(e, entity, getBindings());
}
}
Aggregations