Search in sources :

Example 1 with ResourceKind

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");
    }
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) ResourceKind(org.whole.lang.workflows.model.ResourceKind) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Example 2 with ResourceKind

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();
}
Also used : ResourceKind(org.whole.lang.workflows.model.ResourceKind)

Example 3 with ResourceKind

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());
    }
}
Also used : Variable(org.whole.lang.workflows.model.Variable) IArtifactsEntity(org.whole.lang.artifacts.model.IArtifactsEntity) Synchronize(org.whole.lang.artifacts.visitors.ArtifactsSynchronizerVisitor.Synchronize) ResourceKind(org.whole.lang.workflows.model.ResourceKind) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit) MissingVariableException(org.whole.lang.visitors.MissingVariableException) IOException(java.io.IOException) IWholeRuntimeException(org.whole.lang.exceptions.IWholeRuntimeException) VisitException(org.whole.lang.visitors.VisitException) ParseException(org.whole.lang.parsers.ParseException) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) Traverse(org.whole.lang.artifacts.visitors.ArtifactsSynchronizerVisitor.Traverse)

Example 4 with ResourceKind

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());
    }
}
Also used : IArtifactsEntity(org.whole.lang.artifacts.model.IArtifactsEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ResourceKind(org.whole.lang.workflows.model.ResourceKind) MissingVariableException(org.whole.lang.visitors.MissingVariableException) IOException(java.io.IOException) IWholeRuntimeException(org.whole.lang.exceptions.IWholeRuntimeException) VisitException(org.whole.lang.visitors.VisitException) ParseException(org.whole.lang.parsers.ParseException) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Example 5 with ResourceKind

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());
    }
}
Also used : IArtifactsEntity(org.whole.lang.artifacts.model.IArtifactsEntity) Synchronize(org.whole.lang.artifacts.visitors.ArtifactsSynchronizerVisitor.Synchronize) ResourceKind(org.whole.lang.workflows.model.ResourceKind) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit) MissingVariableException(org.whole.lang.visitors.MissingVariableException) IOException(java.io.IOException) IWholeRuntimeException(org.whole.lang.exceptions.IWholeRuntimeException) VisitException(org.whole.lang.visitors.VisitException) ParseException(org.whole.lang.parsers.ParseException) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) Traverse(org.whole.lang.artifacts.visitors.ArtifactsSynchronizerVisitor.Traverse)

Aggregations

ResourceKind (org.whole.lang.workflows.model.ResourceKind)5 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)4 IOException (java.io.IOException)3 IArtifactsEntity (org.whole.lang.artifacts.model.IArtifactsEntity)3 IWholeRuntimeException (org.whole.lang.exceptions.IWholeRuntimeException)3 ParseException (org.whole.lang.parsers.ParseException)3 MissingVariableException (org.whole.lang.visitors.MissingVariableException)3 VisitException (org.whole.lang.visitors.VisitException)3 Synchronize (org.whole.lang.artifacts.visitors.ArtifactsSynchronizerVisitor.Synchronize)2 Traverse (org.whole.lang.artifacts.visitors.ArtifactsSynchronizerVisitor.Traverse)2 IBindingManager (org.whole.lang.bindings.IBindingManager)2 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)2 Variable (org.whole.lang.workflows.model.Variable)1