Search in sources :

Example 1 with IArtifactsEntity

use of org.whole.lang.artifacts.model.IArtifactsEntity in project whole by wholeplatform.

the class ArtifactsSynchronizerVisitor method initialize.

private IArtifactsEntity initialize(IArtifactsEntity entity) {
    IEntity model;
    if (isLoading) {
        if (entity == null) {
            // build from scratch
            model = createFilesystemModel(entity, null, false);
            this.compareToEntityStack.push(cloneArtifact(model));
        } else {
            IEntity basePath = createBasePath(entity);
            model = createFilesystemModel(entity, basePath, false);
            this.compareToEntityStack.push(EntityUtils.clone(entity));
        }
    } else {
        IEntity basePath = createBasePath(entity);
        if (basePath != null) {
            IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
            model = EntityUtils.clone(basePath);
            IEntityIterator<IEntity> i = IteratorFactory.childIterator();
            i.reset(getChildren(entity));
            for (IEntity child : i) {
                bindings.wDef(SUB_TREE_ROOT, EntityUtils.clone(child));
                Matcher.substitute(model, bindings, false);
            }
            Matcher.removeVars(model, true);
        } else
            model = EntityUtils.clone(entity);
        // initialize the synchronization model
        IEntity filesystemModel = createFilesystemModel(entity, basePath, true);
        this.compareToEntityStack.push(filesystemModel);
    }
    return (IArtifactsEntity) model;
}
Also used : IArtifactsEntity(org.whole.lang.artifacts.model.IArtifactsEntity) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 2 with IArtifactsEntity

use of org.whole.lang.artifacts.model.IArtifactsEntity 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 3 with IArtifactsEntity

use of org.whole.lang.artifacts.model.IArtifactsEntity 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 4 with IArtifactsEntity

use of org.whole.lang.artifacts.model.IArtifactsEntity 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)

Example 5 with IArtifactsEntity

use of org.whole.lang.artifacts.model.IArtifactsEntity in project whole by wholeplatform.

the class NameWithExtensionPart method getModelSpecificChildren.

protected List getModelSpecificChildren() {
    NameWithExtension entity = getModelEntity();
    List<IArtifactsEntity> list = new ArrayList<IArtifactsEntity>(2);
    list.add(entity.getName());
    list.add(entity.getExtension());
    return list;
}
Also used : NameWithExtension(org.whole.lang.artifacts.model.NameWithExtension) IArtifactsEntity(org.whole.lang.artifacts.model.IArtifactsEntity) ArrayList(java.util.ArrayList)

Aggregations

IArtifactsEntity (org.whole.lang.artifacts.model.IArtifactsEntity)6 IOException (java.io.IOException)3 IWholeRuntimeException (org.whole.lang.exceptions.IWholeRuntimeException)3 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)3 ParseException (org.whole.lang.parsers.ParseException)3 MissingVariableException (org.whole.lang.visitors.MissingVariableException)3 VisitException (org.whole.lang.visitors.VisitException)3 ResourceKind (org.whole.lang.workflows.model.ResourceKind)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 ArrayList (java.util.ArrayList)1 NameWithExtension (org.whole.lang.artifacts.model.NameWithExtension)1 IArtifactsOperations (org.whole.lang.artifacts.util.IArtifactsOperations)1 IEntity (org.whole.lang.model.IEntity)1 Variable (org.whole.lang.workflows.model.Variable)1