Search in sources :

Example 1 with Traverse

use of org.whole.lang.artifacts.visitors.ArtifactsSynchronizerVisitor.Traverse 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 2 with Traverse

use of org.whole.lang.artifacts.visitors.ArtifactsSynchronizerVisitor.Traverse 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

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