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;
}
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());
}
}
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());
}
}
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());
}
}
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;
}
Aggregations